integral competition HP50g vs. DM42

08242020, 04:28 PM
Post: #21




RE: integral competition HP50g vs. DM42
(08242020 10:30 AM)peacecalc Wrote: The algorithmus can be a kind of gaussian quadrature, because that one doesn't use the limits on the left and right side. Free42 uses are modified Romberg method that doesn't use the endpoints. The code was originally written by Hugh Steers; this comment is from core_math1.cc: Code:


08242020, 04:56 PM
Post: #22




RE: integral competition HP50g vs. DM42
(08242020 04:28 PM)Thomas Okken Wrote: Free42 uses are modified Romberg method that doesn't use the endpoints. That sounds familiar: http://holyjoe.net/HP71/integral.htm <0ɸ0> Joe 

08242020, 06:35 PM
Post: #23




RE: integral competition HP50g vs. DM42
Hello all,
Thank you: @Joe Horn, @John Keith and @Thomas Okken! It is known, why the algorithmus was not switched through the generations of calculators? It is a kind of "never change a running system"? Most interesting was for me the transformation from x to u avoiding misleading results for periodic functions. 

08242020, 08:03 PM
Post: #24




RE: integral competition HP50g vs. DM42
Hi !
here is an HP41 version that employs an ascending series for small x and a complex continued fraction otherwise: 01 LBL "CSX" 02 STO 01 03 ABS 04 PI 05 SQRT 06 X>Y? 07 GTO 04 08 DEG 09 * 10 24 11 STO 02 12 CLX 13 2 14 / 15 STO 03 16 ENTER 17 LBL 01 18 X<>Y 19 CHS 20 STO Z 21 X^2 22 RCL Y 23 X^2 24 + 25 DSE 02 26 X<0? 27 GTO 02 28 RCL 02 29 X<>Y 30 ST+ X 31 / 32 ST* Z 33 * 34 RCL 03 35 ST+ Z 36 + 37 GTO 01 38 LBL 02 39 PI 40 SQRT 41 * 42 ST/ Z 43 / 44 RP 45 RCL 01 46 X^2 47 90 48 * 49 R^ 50  51 X<>Y 52 CHS 53 PR 54 1 55 + 56 STO Z 57 X<>Y 58 ST+ Z 59  60 2 61 ST/ Z 62 / 63 GTO 05 64 LBL 03 65 X<> 00 66 PI 67 2 68 ST+ 02 69 / 70 RCL 01 71 X^2 72 * 73 X^2 74 * 75 RCL 02 76 ENTER 77 DSE X 78 * 79 / 80 CHS 81 STO 00 82 RCL 02 83 ST+ X 84 ISG X 85 CLX 86 / 87 X<>Y 88 ST+ Y 89 X#Y? 90 GTO 03 91 RTN 92 LBL 04 93 CLX 94 STO 02 95 X<>Y 96 STO 00 97 ENTER 98 XEQ 03 99 STO 03 100 1 101 STO 02 102 RCL 01 103 ABS 104 3 105 Y^X 106 PI 107 * 108 2 109 / 110 STO 00 111 3 112 / 113 ENTER 114 XEQ 03 115 RCL 03 116 LBL 05 117 RCL 01 118 SIGN 119 ST* Y 120 ST* Z 121 RDN 122 END Example: 1.2 XEQ "CSX" >>>> C(x) = 0.715437723 X<>Y S(x) = 0.623400918 3.9 R/S >>>> C(x) = 0.422332710 X<>Y S(x) = 0.475202402 Best regards. 

08242020, 08:15 PM
Post: #25




RE: integral competition HP50g vs. DM42
On my Prime G1 rev C I defined C(X) and S(X) with the Define key, and created two small programs looping on C(3.9) or S(3.9) and counting the TICKS difference.
The results: Average C(3.9) time: 74.05ms Average S(3.9) time: 73.67ms Thibault  not collector but in love with the few HP models I own  Also musician : http://walruspark.co 

08302020, 10:51 AM
Post: #26




RE: integral competition HP50g vs. DM42
Hello JMBaillard,
I converted your program "CSX" so, that's working for the DM42 (maybe for the HP42, too, but I've not this calc). Code:
Some commands are different: f. i. STO+ X is replaced by STO+ ST X; Have fun! 

08302020, 01:16 PM
Post: #27




RE: integral competition HP50g vs. DM42
(08302020 10:51 AM)peacecalc Wrote: I converted your program "CSX" so, that's working for the DM42 (maybe for the HP42, too, but I've not this calc). Actually, the encoder over on the SwissMicros website accepts both syntaxes but converts to HP42S syntax. Quoting from https://www.swissmicros.com/dm42/decoder/#tabs2 Quote:Many of the characters used in HP42S/DM42 programs cannot be entered directly with a keyboard. In order to help with this, we provide several special "codes" that you can use and there are also easytotype mnemonics for instructions that use them. This encoder also accepts HP41 style instructions, eg. you can type "ST/ 10" instead of "STO÷ 10" or "RCL T" instead of "RCL ST T". There are only 10 types of people in this world. Those who understand binary and those who don't. 

08302020, 11:27 PM
Post: #28




RE: integral competition HP50g vs. DM42
Hi !
The HP41 works with 10 digits, but to get 12digit precision, it's preferable to replace line 10 by 50 ( instead of 24 ). Best regards. 

04042024, 08:35 PM
(This post was last modified: 04042024 09:06 PM by John Keith.)
Post: #29




RE: integral competition HP50g vs. DM42
(08232020 07:38 PM)Albert Chan Wrote: >>> k = 2/pi**0.5 Bringing up an old thread with a question and a comment. The question: How do you get an accurate erfc(z) from 1erf(z)? erf(3.9) = 0.999999965208, and that number subtracted from 1 is 0.000000034792 which has only 5 significant digits. Now the comment: Much of the loss of precision in the first example comes from the large negative x in hyp1f1(1/2, 3/2, x*x) which involves summing large alternating positive and negative numbers resulting in cancellation losses. The result, 0.22723763473 has only 7 correct digits. JM Baillard's Special Function package uses a different formula, erf x = (2x/Pi^(1/2)) * exp(x*x) * 1F1( 1 , 3/2 , x^2 ), which returns 0.999999965204, which is within 4 ULPs of the exact result. The positive x seems to result in more stable behavior of the hypergeometric 1F1 program. Additional note: Baillard's program for C(x) and S(x) also uses a continued fraction if x > sqrt(pi). 

04042024, 10:53 PM
Post: #30




RE: integral competition HP50g vs. DM42
(04042024 08:35 PM)John Keith Wrote: How do you get an accurate erfc(z) from 1erf(z)? erf(3.9) = 0.999999965208, For big z, it is the other way around, erf(z) = 1  erfc(z) We need only few sig. digits of erfc(z) to get accurate erf(z) Quote:erf x = (2x/Pi^(1/2)) * exp(x*x) * 1F1( 1 , 3/2 , x^2 ) For CiS(3.9), erf argument is complex, A&S eqn 7.1.6 may not help with accuracy. p2> k = 2/sqrt(pi) p2> erf = lambda x: k*x * exp(x*x) * hyp1f1(1, 3/2, x*x) p2> CiS = lambda x, erf=erf: (1+1j)/2 * erf((11j)/k * x) p2> CiS(3.9) (0.42233255931844371+0.47520226114155328j) 

04052024, 12:23 PM
Post: #31




RE: integral competition HP50g vs. DM42
(04042024 10:53 PM)Albert Chan Wrote: For CiS(3.9), erf argument is complex, A&S eqn 7.1.6 may not help with accuracy. Thanks, that makes sense. I guess that's why continued fraction evaluation is needed for large z. 

04062024, 11:04 PM
(This post was last modified: 04092024 02:16 PM by Albert Chan.)
Post: #32




RE: integral competition HP50g vs. DM42
FYI, there is a problem with erfc continued fraction formula. Calculate bottom up, if any CF denominators caused massive cancellations, all we get is garbage. (*) Cas> erf(z := 3.16845945394*i) 1  58608047158.3*i // erf(z) = 1  erfc(z) ... but wrong Cas> 2/sqrt(pi) * quad(t > exp(t*t), 0, z)[1] 4325.2249097*i // actual integration, erf(z) correct. (11162023 01:22 PM)parisse Wrote: I have disabled the continued fraction, it should now work correctly (*) With re(z)≥0, denominator may get to 0 only if re(z)=0 z + n/z = r*cis(θ) + n/r*cis(θ) Since cos(θ) = cos(θ), we have: > re(z + n/z) ≥ re(z) > re(z + (n1/2)/(z + n/z)) ≥ re(z) ... > re(z + (1/2)/(z + 1/(z + (3/2)/(z + ...)))) ≥ re(z) 

« Next Oldest  Next Newest »

User(s) browsing this thread: