# HP Forums

Full Version: erfi, erfw (w(z)) functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi everybody,
Luckily Prime has inside its CAS two useful functions to magare problems connected to error treatment and statistics: the error function, erf() and the complementary error function, erfc().

If one want to "complete" that series, could think to implement also other two "sisters": the imaginary error function, erfi() and a function that I call "erfw", otherwise w(z) that handles every complex number.
See here for theory.

The code:
erfi()
Code:
``` #cas erfi(x):= return -i*erf(i*x) #end```

erfw()
Code:
``` // complex error function #cas erfw(x):= return (e^-(x^2))*erfc(-i*x) #end```

Enjoy with the Prime!

Salvo Micciché
A mnemonic I find useful
swap -1 and i, and swap the function (erf ↔ erfi, sin ↔ sinh, cos ↔ cosh, tan ↔ tanh)

Code:
```erf (-x) = - erf(x)    → erf (ix) = i erfi(x) erfi(-x) = - erfi(x)   → erfi(ix) = i erf(x) sin (-x) = - sin(x)    → sin (ix) = i sinh(x) sinh(-x) = - sinh(x)   → sinh(ix) = i sin(x) cos (-x) =   cos(x)    → cos (ix) =   cosh(x) cosh(-x) =   cosh(x)   → cosh(ix) =   cos(x) tan (-x) = - tan(x)    → tan (ix) = i tanh(x) tanh(-x) = - tanh(x)   → tanh(ix) = i tan(x)```
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :