1 /* Magnitude of complex z
16 a + i b sqrt(a^2 + b^2)
20 1. Handles mixed polar and rectangular forms, e.g. 1 + exp(i pi/3)
22 2. jean-francois.debroux reports that when z=(a+i*b)/(c+i*d) then
24 mag(numerator(z)) / mag(denominator(z))
26 must be used to get the correct answer. Now the operation is
61 if (isnegativenumber(p1
)) {
64 } else if (car(p1
) == symbol(POWER
) && equaln(cadr(p1
), -1))
67 else if (car(p1
) == symbol(POWER
) && cadr(p1
) == symbol(E
)) {
72 } else if (car(p1
) == symbol(MULTIPLY
)) {
82 } else if (car(p1
) == symbol(ADD
)) {
85 rect(); // convert polar terms, if any
100 // default (all real)
121 "mag(1+exp(i*pi/3))",
124 "mag((a+i*b)/(c+i*d))",
125 "(a^2+b^2)^(1/2)/((c^2+d^2)^(1/2))",
130 "mag(exp(-i theta))",
136 "mag((-1)^(-theta))",
142 "mag(3*(-1)^(-theta))",
145 "mag(-3*(-1)^theta)",
148 "mag(-3*(-1)^(-theta))",
155 test(__FILE__
, s
, sizeof s
/ sizeof (char *));