Post Reply 
RE: HP48-HP50G : Error functions ERF(z), FRESNEL integrals, PROBIT, etc.
11-15-2023, 02:13 PM (This post was last modified: 11-15-2023 02:55 PM by Gil.)
Post: #32
RE: RE: HP48-HP50G : Error functions ERF(x or z), ERFC (x or z) & iERF/iERFc —>x
1) I corrected ERF and Erfc programs, in particular regarding complex numbers.

For ERFc(z), with z=0+bi, i.e. (0 b) in the program, I cheated and calculated
ERFc(0.0000000001 b), and replaced at the end the real part (about 0.9999...) by 1.

2) I checked the results with Wolfram Alpha and the HP PRIME.
- On the HP PRIME, approximate(erfc(5*i)), ie with no real part in the complex number input (argument), returns -82982738 79.76*i (a complex number with no real part).
- On my HP50G program ERFc(0 5) returns (1.,-8298273880.6 1 ), with 1 as the real part of that complex number.
- Whereas Wolfram Alpha returns 1 - 8.2982738806 7680 ×10^9 i.

Fazit
1) As no real part of the HP PRIME result is shown, that part has to be considered being equal to 0, and the PRIME result as wrong here (a bug?).
2) Imaginary part of the HP PRIME result is "worse" than my HP50G program (algorithm of the HP PRIME should be improved?).

3) Regarding Albert Chan observations
Still to be taken into account...

New corresponding codes

ERF
\\<< \"1 Arg
.real x or
.complex (a b)\" DROP DUP IM 0 ==
IF
THEN RE DUP 0 \\>=
IF
THEN 1
ELSE ABS -1
END
ELSE 1
END SWAP ERFc NEG 1 + *
\\>>

ERFc
\\<< \"1 Arg
.real x or
.complex (a b)\" DROP DUP IM 0 ==
IF
THEN RE 0 .5 ROT UTPN 2 *
ELSE C\\->R SWAP DUP 0 ==
IF
THEN .00000000001 SWAP
ELSE 1
END \\-> y x z
\\<< 0 .5 x UTPN 2 * 'e^-x^2/(2*\\pi*x)*(1-COS(2*x*y)+i*SIN(2*x*y))' \\->NUM '2/\\pi*e^-x^2' \\->NUM '\\GS(k=1,30,e^(-k^2/4)/(k^2+4*x^2)*(2*x*(1-COS(2*x*y)*COSH(k*y))+k*SIN(2*x*y)*SINH(k*y)+i*(2*x*SIN(2*x*y)*COSH(k*y)+k*COS(2​*x*y)*SINH(k*y))))' \\->NUM * + - z 0 ==
IF
THEN C\\->R SWAP DROP 1 SWAP R\\->C
END
\\>>
END
\\>>


Attached File(s)
.hp  ERROR_03.HP (Size: 1.57 KB / Downloads: 1)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RE: HP48-HP50G : Error functions ERF(x or z), ERFC (x or z) & iERF/iERFc —>x - Gil - 11-15-2023 02:13 PM



User(s) browsing this thread: 1 Guest(s)