home
history
links from
printable
login


Complex Math Script Webb  all rights reserved  ©2004

Author  Charles Perry
Email: chperry@gte.net
Webpage:
Summary: Math functions for complex numbers (including conjugate and inverse).
Instructions: Includes math functions for complex numbers (x+jy). Assumes x is in stack position 1 and y is in stack position 2. For two complex numbers, x1 in position 3, y1 in position 4, x2 in position 1 and y2 in position 2.
Includes inverse of complex number (inv z = 1/z), conjugate ( conj (x+jy) = (xjy)) swap for swapping x2 y2 with x1 y1.
Also includes polar and rectangular conversion. Assumes angle is in position 2 and magnitude in position 1. The polar/rectangular conversion correctly handles cases where angles are 0, 90, 180, 270, and 360. Polar conversion gives all positive angles (300 instead of 60 for example). CLRx clears both position 1 and 2 (x and y). All functions, with the exception of polar/rectangular conversion, assume number is in rectangular form.
Code:
RPN.1
"Complex"
~
"+" r4r3+r3r3+;
"" r4r3r3r3;
"x" g4g2*g4g4*+r4r3*r4r4*;
"÷"g2g1*g2g1*+g2g6*g5g5*g2/r5r4*r5r5*+r3/;
~
">R"g2ob#'1E14'>(g2ib#'1E14'>(g2ig2*r3or3*:g20>(r2d1#'0'r2n:r2d1#'0'r2)):r2i*#'0');
">P"g1b0>(g2b0>(g10>(g20>(g2g2/Ar3g1*r3g1*+s:g2g2/A#'360'+r3g1*r3g1*+s):g2g2/A#'180'+r3g1*r3g1*+s):g10>(r2d1#'0'r2:r2d1#'180'r2b)):d1g10>(#'90'r2:g10<(#'270'r2b:#'0'r2)));
"CLRx" d1d1;
~
"INV"g2g1*g2g1*+r3ng2/r3r3/;
"CONJ"r2nr2;
"SWP"r4r4;

