{ From user Lonnie, Model Cexp_error at 9-Jul-2010 9:04:25 AM } SoftwareVersion 4.3.0 LinkLibrary Complex_library Title: Complex Library Description: Contains a library of functions for working with complex numbers.~ Complex numbers as seen by users of this library should always be in the Euclidean_complex form.~ Addition, subtraction, and scalar multiply are done with the usual operators. Complex multiplication and complex division require use of explicit functions. Author: Lonnie Chrisman Date: Tue, Mar 04, 2003 9:28 AM SaveAuthor: Lonnie SaveDate: Fri, Jul 09, 2010 9:04 AM DefaultSize: 48,24 NodeSize: 48,24 NodeInfo: 1,1,1,1,1,1,0,0,0,0 DiagState: 2,189,29,790,617,17 WindState: 1,-6,86 FileInfo: 0,LinkLibrary Complex_library,2,2,0,0,..\Analytica\ExecDebug\Libraries\Complex Library.ANA Function Cdeterminant(A;I,J:IndexType) Title: CDeterminant(A,I,J) Description: The determinant of a matrix of complex numbers. Definition: if size(I)<=1 then~ Slice(Slice(A,I,1),J,1)~ else (~ sum( var k[] := cumulate(1,I) do ~ (-1)^(k-1) *~ CMult(Slice(Slice(A,J,1),I,k) , Cdetminor(A,I,J,k,1) ) , I)~ ) NodeLocation: 296,400,1 NodeSize: 52,24 WindState: 1,102,90 ParamNames: A,I,J Recursive: 1 Function Complex(Re,Im) Title: Complex(Re,Im) Description: Returns a complex number consisting of real part Re and imaginary part Im. Definition: Table(Euclidean_complex)(~ Re,Im) NodeLocation: 106,72,1 NodeSize: 70,24 WindState: 2,102,90,475,224 DefnState: 2,168,178,416,303,0,MIDM ParamNames: Re,Im Function Re(c) Title: Re(c) Description: Returns the real part of a complex number. Definition: c[Euclidean_Complex='Re'] NodeLocation: 240,72,1 NodeSize: 48,24 WindState: 1,133,57 ParamNames: c Function Im(c) Title: Im(c) Description: Returns the imaginary part of a complex number. Definition: c[Euclidean_Complex='Im'] NodeLocation: 344,72,1 NodeSize: 48,24 ParamNames: c Function Cmult(x,y) Title: CMult(x,y) Description: Complex multiplication Definition: Complex(Re(x)*Re(y) - Im(x)*Im(y),Re(x)*Im(y)+Im(x)*Re(y)) NodeLocation: 80,160,1 NodeSize: 48,24 ParamNames: x,y Function Cabs(c) Title: CAbs(c) Description: Magnitude of a complex number. Definition: sqrt(Re(c)^2+Im(c)^2) NodeLocation: 288,240,1 NodeSize: 48,24 ParamNames: c Function Ctopolar(c) Title: CToPolar(c) Description: Converts a complex number to polar coordinates. Definition: CPolar(Cabs(c),CTheta(c)) NodeLocation: 88,240,1 NodeSize: 52,24 WindState: 2,264,97,476,224 ParamNames: c Function Polartoc(z) Title: PolarToC(z) Description: Converts a polar complex number to standard (euclidean) coordinaets. Definition: var ang := degrees(z[Polar_complex='Th']);~ z[Polar_complex='A'] * Array(euclidean_complex,[cos(ang),sin(ang)]) NodeLocation: 188,240,1 NodeSize: 52,24 WindState: 2,23,339,476,224 ParamNames: z Function Csqrt(c) Title: CSqrt(c) Description: Returns a single square root of complex number c.~ Use CRoots(c,2) to get both roots. Definition: var pol := CToPolar(c);~ PolarToC( Table(Polar_complex)( sqrt(pol),pol/2 ) ) NodeLocation: 88,320,1 NodeSize: 48,24 ParamNames: c Function Croots(c;n:Atomic) Title: CRoots(c) Description: Returns the n complex nth roots of c. Definition: index R := 0..n-1;~ var re := CAbs(c);~ var Th := CTheta(c);~ PolarToC(CPolar(re^(1/n),(2*Pi*R+Th)/n)) NodeLocation: 184,320,1 NodeSize: 48,24 WindState: 2,580,24,476,224 ParamNames: c,n Function Cln(c) Title: CLn(c) Description: The natural log of a complex number.~ Note that the logarithm of a complex number is not unique. Any multiple of 2*Pi can be added to the imaginary part to obtain another log. Definition: Complex( ln(CAbs(c)), CTheta(c) ) NodeLocation: 280,320,1 NodeSize: 48,24 WindState: 1,67,400 ParamNames: c Function Cdiv(num,den) Title: CDiv(n,d) Description: Quotient of two complex numbers. Definition: var a:=Re(num);~ var b:=Im(num);~ var c:=Re(den);~ var d:=Im(den);~ Complex( a*c + b*d, b*c - a*d ) / (c^2 + d^2) NodeLocation: 176,160,1 NodeSize: 48,24 ParamNames: num,den Function Cinverse(A;I,J:IndexType) Title: CInverse(A;I,J) Description: The inverse of a matrix of complex numbers. Definition: CDiv( Cadjoint(A,I,J) , CDeterminant(A,I,J) ) NodeLocation: 192,400,1 NodeSize: 52,24 WindState: 1,62,472 ParamNames: A,I,J Function Cadjoint(A;I,J:IndexType) Title: CAdjoint(A;I,J) Description: The Adjoint of a complex matrix. Definition: var u := cumulate(1,I) in each;~ var v := cumulate(1,J) in each;~ CDetMinor(A,I,J,v,u) * (-1)^(u+v) NodeLocation: 408,400,1 NodeSize: 60,24 WindState: 1,74,227 ParamNames: A,I,J Function Cmatmult(A,B;I,J:IndexType) Title: CMatMult(A,B,I,J) Description: Matrix multiply of two square matrices of complex numbers, A,B, both of which are indexed by I,J. Definition: index K:=J;~ var D := B[J=K]; ~ var Q:= sum( for n:=J do CMult( A[J=n], D[I=n] ), J );~ Q[K=J] NodeLocation: 88,400,1 NodeSize: 48,24 WindState: 1,14,64 ParamNames: A,B,I,J Function Cexp(c) Title: CExp(c) Description: Complex exponentiation. Computes e^c , where e=2.718.. and c is complex. Definition: var x := re(c);~ var y := degrees(im(c));~ Exp(x) * array(Euclidean_complex, [ cos(y), sin(y) ]) NodeLocation: 376,320,1 NodeSize: 48,24 WindState: 2,512,725,476,461 ParamNames: c Function Ctheta(c) Title: CTheta(c) Description: Returns the angle (in radians) of a complex number when represented in polar coordinates. Definition: Arctan2(Im(c),Re(c)) * Pi / 180 NodeLocation: 456,72,1 NodeSize: 48,24 NodeInfo: 1,1,1,1,1,1,0,0,0,0 ParamNames: c Module Complex_internals Title: Complex Internals Author: indirect Date: Thu, Mar 20, 2003 8:08 AM DefaultSize: 48,24 NodeLocation: 512,200,1 NodeSize: 48,24 DiagState: 1,151,603,448,245,17 Function Minor(A;I,J:IndexType;r,c) Title: Minor(A;I,J;r,c) Description: The Minor of a matrix is obtained by deleting the ith row and jth column.~ The array must be redimensioned by new indexes that are shortened by one. Definition: var n:=size(I);~ index Row := 1..n-1;~ index Col := 1..n-1;~ Slice( Slice( A,I,if Row