Contents Links Search
 

RPN Scripts

RPN Documentation

Submit Script

Conversion
   Conversions
   Convert
   Euro
   Euro_Calculator
   Soundex
Engineering
   Feet_&_Inch
   Units
   Water
Entertainment
   Master_Mind
   Sticks!
Finance
   Annuity
   Euro_Calculator
   TVM_Financial_Functions
Math
   3D_Vectors_v1.2
   Base
   Base_Conversions
   Complex_Arithmetic
   Complex_Math
   Discrete_Math
   EBBases
   Fractions
   Fractions
   Least
   Logs_&_Powers
   Misc
   Regressions
   Scientific
   Scientific_Functions
   Scientific_Programmable
   Simple_Complex_Math
   Standard_Normal_Distribution
   Trig
Misc
   Health
   Husband's_Calculator
Physics
   Angle_of_View
   Depth_of_Field
   Physics_Functions
Time
   Clock
   Julian
   Multiple_Timer
   Stop5Watch
   Stopwatch
   Timer
Utility
   Board_Foot_Calculator
   Calendar_Functions
   Checkbook_II
   MiniG
   Stack_Handling_and_Saving
   WindChill

Complex Arithmetic
Ray Franco, Ph.D., - email


summary
Ten functions (degrees or radians) with extensive help and
argument checking.

instructions
Includes the following complex math functions:
rectangular-to-polar,
polar-to-rectangular, clear complex, conjugate, inverse, addition,
subtraction, multiplication, division, and swap complex numbers.
For functions that require a single complex argument, X+iY, X should
be in stack position 1 and Y in position 2. For functions that require two
complex arguments, X2+iY2 and X1+iY1, X1 should be in stack
position 1, Y1 in position 2, X2 in position 3, and Y2 in position 4.
P->R function assumes the magnitude is in stack position 1 and the
angle in position 2. The results are returned using the same convention.
Multiplication and division are preformed by first converting the number
to polar form.

Why another complex number scrip: Perry's doesn't work in radians,
doesn't provide help, jumbles the stack if the right number of arguments
are not entered, and it's not efficient. Katsumata's rectangle-to-polar
function gives the wrong angle [atan(Re/Im)], and it bombs out when the
imaginary part is zero. Hey, this stuff is not easy, and these are the guys
that inspired me. We all owe them thanks.

code
RPN.2  \Complex #\
[p] g10<(1A4*:0)g3g3g1b0>(/A:d10<1A2*r2(n))+k32Pr22P+s;
[r] g2g2r2i*k3r2o*;
[c] r2nr2;
"Complex #"
"Complex #: ver 1.00 12-5-99\Ray Franco Ph.D.,\r.a.franco@ieee.org";
~
"conj:  X+iY-->X-iY"?2Cc;
"inv: X+iY-->1÷(X+iY)"?2CpCctCr;
"swp: (X2+iY2),(X1+iY1)\    -->(X1+iY1),(X2+iY2)"?2k4k4;
~
"+:    (X2+iY2)+(X1+iY1)\-->{(X2+X1)+i(Y2+Y1)}"?4k4r3+k3+;
"-:    (X2+iY2)-(X1+iY1)\-->{(X2-X1)+i(Y2-Y1)}"?4r2r4r2-k3-;
"x:   (X2+iY2)*(X1+iY1)-->\(X1X2-Y1Y2)+i(X1Y2+X2Y1)"?4Cpk4k3Cpk4+k3*Cr;
"÷:     
(X2+iY2)÷(X1+iY1)-->\{(X1X2+Y1Y2)+i(X1Y2-X2Y1)}\÷(X1X1+Y1Y1)"?4Cpk4k4Cpr3/k3r2-r2Cr;

~
"r>p:  (iY,X)-->\{atan(Y÷X), sqrt(XX+YY)}"?2Cp;
"p>r:\(¯,M)-->(i M sinr, M cos¯)"?2Cr;
"clrXY: (X2+iY2),(X1+iY1)\       -->(X2+iY2)"?2d1d1;

top
Nth Lab
©1996 - 2001 all rights reserved
August 03, 2001
contact