RE: HP48-HP50G : Error functions ERF(z), FRESNEL integrals, PROBIT, etc.
|
12-15-2023, 11:50 AM
(This post was last modified: 12-15-2023 12:44 PM by Gil.)
Post: #42
|
|||
|
|||
RE: RE: HP48-HP50G : Error functions ERF(x or z), ERFC (x or z) & iERF/iERFc —>x
Please note that the last uploaded version 9f
has a "print" error at variable VERSIO. Please change it from Version 9e 2023.12.14 campart @hotmail.com into Version 9f 2023.12.14 campart @hotmail.com ERF "\\<< \"1 Arg .real x (no limit for real) .complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' (b\\=/0 & |a| & |b| \\<=9) \" DROP DTAG DUP DUP DUP DUP PUSH euler DUP DUP RE SWAP IM \\oo \\->NUM 9 .01 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z critic \\<< arg.num inf.erf max.arg DROP -105 SF EVAL ABS \\oo == IF THEN SIGN -105 CF '\\oo' EVAL * END DUP DUP \"ERF (\" SWAP DROP \\<-z0 + \")\" + \"'\" \"\" SREPL DROP DUP \"F\" \"Fc\" SREPL DROP 4 ROLLD SWAP DUP TYPE 9 == IF THEN DROP \\<-z END CASE \\<-re DUP 0 \\>= 1 -1 IFTE SWAP ABS '\\oo' EVAL == THEN 1 * DUP 1 SWAP - ROT 5 ROLL DROP2 UNROT END DROP \\<-im 0 == \\<-re ABS critic \\<= AND IF THEN DROP '\\.S(-\\<-re,\\<-re,e^-X^2,X)/\\v/\\pi' \\->NUM ELSE \\<-im 0 == \\<-re 0 \\<= AND IF THEN -1 ELSE 1 END SWAP \\<-im 0 == IF THEN ABS END complex END \\<-im 0 == IF THEN \\<-re ABS critic \\<= IF THEN 1 SWAP ELSE END 4 ROLL DROP DUP 1 SWAP - ROT * DUP 0 < IF THEN DUP NEG 1 + ROT DROP SWAP END \\<-re ABS critic > IF THEN SWAP END UNROT ELSE ROT DROP SWAP UNROT END END \\<-im 0 \\=/ IF THEN 4 ROLL DROP END \\>> 'IERR' PURGE POP \\>>" " " INV¦ "\\<< \"1 Arg .a real p, |p| \\<= 1 <or equivalent complex z = p - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' > \" DROP PUSH DUP DUP 0 .9065 \\-> p0 \\<-z0 p \\<-z critic \\<< p0 euler DUP DUP '\\<-z' STO 'p' STO arg.num \\<-z0 'p0' STO IM 0 \\=/ p ABS 1 \\>= AND p RE ABS 1 > OR IF THEN POP p0 \"Not OK as: .Real |p| > 1 or .Complex p with |p| > 1\" DOERR END -105 CF \"InvERF \" \"(\" + p0 + \")\" + \"'\" \"\" SREPL DROP p IM 0 \\=/ IF THEN p inv\\166z ELSE p RE DUP 'p' STO 0 \\>= 1 -1 IFTE p ABS 'p' STO CASE p 1 == THEN '\\oo' EVAL END p 0 == THEN 0 END 1 p - critic \\<= THEN \\<< 1 p - 0 .5 x UTPN 2 * - \\>> 'x' 2 ROOT END p '\\.S(-x,x,e^-X^2,X)/\\v/\\pi' - 'x' 2 ROOT END * { x IERR } PURGE END POP \\>> \\>>" " " INV¦c "\\<< \"1 Arg .a real p in [0 2] <or equivalent complex z = p - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' > \" DROP PUSH DUP DUP 0 .9065 \\-> p0 \\<-z0 p \\<-z critic \\<< p0 euler DUP '\\<-z' STO 'p' STO arg.num \\<-z0 'p0' STO \"InvERFc \" \"(\" + p0 + \")\" + \"'\" \"\" SREPL DROP p IM 0 \\=/ 1 p - ABS 1 \\>= AND p RE 0 < OR p RE 2 > OR IF THEN DROP POP p0 \"Not OK as: .Real p<0, >2 or .Complex with IM(p)\\=/0 & |1-p| \\>= 1 \" DOERR ELSE 1 p - IM 0 \\=/ IF THEN 1 p - inv\\166z ELSE -105 CF p RE DUP 'p' STO 1 \\<= IF THEN 1 ELSE 2 p - 'p' STO -1 END CASE p 0 == THEN '\\oo' EVAL END p 1 == THEN 0 END p critic \\<= THEN \\<< p 0 .5 x UTPN 2 * - \\>> 'x' 2 ROOT END 1 p - RE '\\.S(-x,x,e^-X^2,X)/\\v/\\pi' - 'x' 2 ROOT END * { x IERR } PURGE END END POP \\>> \\>>" " " PROBIT "\\<< \"1 Arg .a real p in [0 1] <or equivalent complex z = p - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' > \" DROP PUSH DUP DUP 0 \\-> p0 \\<-z0 p \\<-z \\<< p0 euler DUP DUP '\\<-z' STO 'p' STO arg.num \\<-z0 'p0' STO \"Probit \" \"(\" + p0 + \")\" + \"'\" \"\" SREPL DROP p IM 0 \\=/ p RE 1 > OR p RE 0 < OR IF THEN DROP POP \"Not OK as: .Real p<0, >1 or .Complex with IM(p) \\=/ 0 or RE(p) <0, >1 \" DOERR END SWAP DROP -105 CF CASE p 1 == THEN \\oo EVAL END p 0 == THEN \\oo EVAL NEG END p RE 2 * 1 - INV\\166 2 \\v/ * \\->NUM SWAP DROP END POP \\>> \\>>" " " ERFi "\\<< \"1 Arg .real x |x| \\<=9 .Or complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' |a| & |b| \\<=7 \" DROP PUSH DUP DUP DUP DUP euler DUP DUP RE SWAP IM 9 7 0 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z \\<-inf1x \\<< arg.num inf2x DUP \"OK\" SAME IF THEN DROP inf1x.erfi \\<-inf1x 1 == IF THEN inf1x.end \"ERFi \" SWAP + \"(+\" \"(\" SREPL 5 ROLL 5 ROLL 3 DROPN SWAP ELSE max.arg -105 SF EVAL ABS \\oo == IF THEN SIGN -105 CF '\\oo' EVAL * '\\<-z0' STO ELSE DROP END \"ERFi \" \"(\" + \\<-z0 + \")\" + \"'\" \"\" SREPL ROT DROP2 CASE \\<-z ABS '\\oo' EVAL == THEN \\<-z SIGN -105 CF \\oo EVAL * END \\<-z i * \\->NUM ERF 4 ROLLD 3 DROPN i / \\->NUM END DUP IM 0 == { RE } IFT POP END ELSE \"ERFi \" SWAP + SWAP 5 ROLL 5 ROLL 5 ROLL 3 DROPN END POP \\>> \\>>" " " iERFc "\\<< \"1 Arg .real x (no limit) .or complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' (b\\=/0 & |a| or |b| \\<=9) \" DROP PUSH DUP DUP DUP DUP euler DUP DUP RE SWAP IM \\oo \\->NUM 9 0 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z \\<-inf1x \\<< arg.num max.arg \\->NUM ABS \\oo \\->NUM == IF THEN SIGN -105 CF '\\oo' EVAL * '\\<-z0' STO ELSE DROP END \"iERFc \" \"(\" + \\<-z0 + \")\" + \"'\" \"\" SREPL ROT DROP2 CASE \\<-z \\->NUM '\\oo' EVAL \\->NUM == THEN \"Undef by Wolfram as '0/0', or \\->0 (try iERFc(x) with x=10 x=20 x=33)\" END \\<-z \\->NUM '\\oo' EVAL NEG \\->NUM == IF THEN -105 CF \\oo EVAL NEG DUP NEG ELSE \\<-z ERF ROT 4 ROLLD 3 DROPN \\<-z * \\<-z SQ NEG EXP \\pi \\v/ / - \\->NUM DUP IM 0 == { RE } IFT DUP NEG END DUP 0 == IF THEN DROP ELSE \"Wiki_French\" \\->TAG SWAP \"Wolfram\" \\->TAG END END POP \\>> \\>>" " " ERFcx "\\<< \"1 Arg .real x |x| \\<=33 or .complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' (b\\=/0 & |a| or |b| \\<=9) \" DROP PUSH DUP DUP DUP DUP euler DUP DUP RE SWAP IM 33 9 0 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z \\<-inf1x \\<< arg.num max.arg -105 SF EVAL ABS \\oo == IF THEN SIGN -105 CF '\\oo' EVAL * '\\<-z0' STO ELSE DROP END \"ERFcx \" \"(\" + \\<-z0 + \")\" + \"'\" \"\" SREPL ROT DROP2 CASE \\<-z '\\oo' EVAL == THEN 0 END \\<-z '\\oo' EVAL NEG == THEN '\\oo' EVAL END \\<-z ERF ROT 4 ROLLD 3 DROPN \\<-z SQ EXP \\->NUM * DUP IM 0 == { RE } IFT END POP \\>> \\>>" " " FADDEEVA "\\<< \"1 Arg .real x |x| \\<=9 or .complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' (b\\=/0 & |a| or |b| \\<=9) \" DROP PUSH DUP DUP DUP DUP euler DUP DUP RE SWAP IM 9 9 0 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z \\<-inf1x \\<< arg.num max.arg -105 SF EVAL ABS \\oo == IF THEN SIGN -105 CF '\\oo' EVAL * '\\<-z0' STO ELSE DROP END \"w_Faaddeva-Kramp \" \"(\" + \\<-z0 + \")\" + \"'\" \"\" SREPL ROT DROP2 \\<-z i NEG * \\->NUM ERF ROT \\<-z SQ NEG EXP * \\->NUM 4 ROLLD 3 DROPN DUP IM 0 == { RE } IFT POP \\>> \\>>" " " DAWSON "\\<< \"1 Arg .real x |x| \\<=9 or .complex - (a b) - 'a+i*b' - 'r*e^(i\\Gh)' - 'r*EXP(i\\Gh)' |a| & |b| \\<=9 \" DROP PUSH DUP DUP DUP DUP euler DUP DUP RE SWAP IM 9 9 0 \\-> \\<-z0 \\<-z \\<-re \\<-im \\<-max.x \\<-max.z \\<-inf1x \\<< arg.num max.arg -105 SF EVAL ABS \\oo == IF THEN SIGN -105 CF '\\oo' EVAL * '\\<-z0' STO ELSE DROP END \"F_Dawson \" \"(\" + \\<-z0 + \")\" + \"'\" \"\" SREPL ROT DROP2 \\<-z ABS \\->NUM '\\oo' EVAL \\->NUM == IF THEN 0 ELSE \\<-z ERFi \\<-z SQ NEG EXP \\pi \\v/ * 2 / * \\->NUM SWAP DROP DUP IM 0 == { RE } IFT END POP \\>> \\>>" " " euler "\\<< -2. CF -103. SF -105. SF DUP \\->STR \"EXP\" \"e^\" SREPL DROP \\-> e s \\<< s \"e^(\" POS DUP \\-> p \\<< 0. == IF THEN e ELSE s p 2. + s SIZE SUB \"'\" SWAP + \"\\pi\" \"1\" SREPL DROP \"i\" \"1\" SREPL 0. == IF THEN DROP e ELSE OBJ\\-> \\->NUM DUP FP DUP 0. \\=/ SWAP .5 \\=/ AND IF THEN DROP e ELSE \\->Q \\pi * -105. CF i * EXP EVAL p 2. \\=/ IF THEN s 1. p 2. - SUB \"'\" + OBJ\\-> * END END END END \\->NUM DUP IM 0. == IF THEN RE END \\>> \\>> \\>>" " " arg.num "\\<< -105 SF \\<-z0 TYPE 9 == \\<-z0 TYPE 1 == \\<-z0 IM 0 == AND OR IF THEN \\<-z0 \" =\" + \\<-z DUP IM 0 == \\<-z RE FP 0 == AND { R\\->I } IFT + '\\<-z0' STO END \\>>" " " complex "\\<< 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 \\<< '\\.S(-x,x,e^-X^2,X)/\\v/\\pi' \\->NUM 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 * + NEG DUP 4 ROLL SWAP - UNROT + SWAP z 0 == IF THEN C\\->R SWAP DROP 0 SWAP R\\->C SWAP C\\->R SWAP DROP 1 SWAP R\\->C SWAP END \\>> END \\>>" " " max.arg "\\<< \\<-im 0. == IF THEN \\<-re ABS \\<-max.x > IF THEN message END ELSE \\<-re ABS \\<-max.z > \\<-im ABS \\<-max.z > OR IF THEN message END END \\>>" " " message "\\<< DROP2 POP \\<-max.x \\oo \\->NUM == IF THEN \"Not OK with z=a+ib, b\\=/0 if |a| or |b| >\" \\<-max.z R\\->I + DOERR ELSE \"Not OK with .Real if |x| >\" \\<-max.x DUP \\oo \\->NUM == IF THEN DROP \"\\oo\" ELSE R\\->I END + \" \\183Or z=a+ib & b\\=/0 if |a| or |b| >\" + \\<-max.z R\\->I + DOERR END \\>>" " " inf.erf "\\<< \\<-re ABS \\oo \\->NUM == \\<-im ABS \\oo \\->NUM == OR IF THEN DROP \\<-im ABS \\oo \\->NUM == \\<-re ABS \\oo \\->NUM == AND IF THEN \"Undef\" DUP \\<-re 0. \\>= \"(\\oo\" \"(-\\oo\" IFTE \\<-im 0. \\>= \"+i\\oo)\" \"-i\\oo)\" IFTE + ELSE CASE \\<-re ABS \\oo \\->NUM == THEN \\<-re 0. \\>= 1. -1. IFTE DUP 1. SWAP - SWAP \"(\" \\<-re 0. \\>= \"\" \"-\" IFTE + \"\\oo\" + \\<-im 0. \\=/ IF THEN \\<-im 0. \\>= \"+i\" \"-i\" IFTE + \\<-im ABS + END \")\" + END \"1\" \\<-im 0. \\>= \"-\" \"+\" IFTE + \"i\\oo\" + DUP \"1\" \"\" SREPL DROP \"-\" \"\" SREPL 0. == IF THEN \"+\" \"-\" SREPL DROP END \"(\" \\<-re 0. \\=/ IF THEN \\<-re + \" \" + END \\<-im 0. \\>= \"+\" \"-\" IFTE + \"i\\oo)\" + END END \"ERF \" SWAP + \"(+\" \"(\" SREPL DROP DUP \"F\" \"Fc\" SREPL DROP SWAP ROT 4. ROLL UNROT 6. ROLL 6. ROLL DROP2 POP KILL END \\>>" " " inf2x "\\<< \\<-im ABS \\oo \\->NUM == \\<-re ABS \\oo \\->NUM == AND IF THEN \"Undef\" \\<-re 0. \\>= \"(\\oo\" \"(-\\oo\" IFTE \\<-im 0. \\>= \"+i\\oo)\" \"-i\\oo)\" IFTE + ELSE \"OK\" END \\>>" " " inf1x.erfi "\\<< \\<-re ABS \\oo \\->NUM == \\<-im ABS \\oo \\->NUM == OR IF THEN DROP 1. '\\<-inf1x' STO \\<-im ABS \\oo \\->NUM == \\<-re ABS \\oo \\->NUM == AND IF THEN \"Undef\" \\<-im 0. \\>= \"+i\\oo)\" \"-i\\oo)\" IFTE ELSE CASE \\<-im \\oo \\->NUM == THEN \"i\" \"+i\\oo)\" END \\<-im NEG \\oo \\->NUM == THEN \"-i\" \"-i\\oo)\" END \\<-re 0. \\>= \"\\oo\" \"-\\oo\" IFTE \\<-im 0. \\=/ IF THEN \\<-im 0. > \"+i\" \"-i\" IFTE \\<-im ABS + ELSE \"\" END \")\" + END END END \\>>" " " inf1x.end "\\<< CASE \\<-re 0. == THEN \"(\" END \\<-re \\oo \\->NUM == THEN \"(\\oo\" END \\<-re NEG \\oo \\->NUM == THEN \"(-\\oo\" END \"(\" \\<-re + \" \" + END SWAP + \\>>" " " inv¦z "\\<< { 1 } 100 \"This last value can be incr. \\->160 or + if |z| \\-> 1 \" DROP \\-> z c max \\<< 1 max FOR k 0 0 k 1 - FOR m c m 1 + GET c k 1 - m - 1 + GET * m 1 + m 2 * 1 + * / + EVAL NEXT c SWAP \\->NUM + 'c' STO NEXT 0 0 max FOR k c k 1 + GET 2 k * 1 + / \\pi \\v/ 2 / z * 2 k * 1 + ^ * \\->NUM + NEXT \\>> \\>>" " " EXPL "\\<< \"ERF(z) ERFi(z): OK \\-> z=(a b),(\\177\\oo b), (a \\177 \\oo),(\\177\\oo \\177\\oo) iERFc(z) ERFcx FADDEEVA(z) DAWSON(z): \\-> z still \\=/ \\177\\oo(i) INV\\166 INV\\166c PROBIT: OK To speed up \\-> change max in 'inv\\166z' to 60\" 1 DISP 7 FREEZE \\>>" " " VERSIO "Version 9f 2023.12.14 campart @hotmail.com" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 23 Guest(s)