home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-25 | 3.0 KB | 120 lines | [TEXT/R*ch] |
- The following documentation is for the Think Pascal libraries 'CMmath.lib'
- and 'CMmath6888x.lib. release 1.2.
-
- Note: CMmath.lib will work an any macintosh. CMmath6888x.lib will only
- function on machines with either a 68020 or 68030 with either a
- 68881 or 68882 coprocessor, or on a 68040. The CMmath6888x.lib
- library will NOT work with a 68LC040.
-
- {ComplexMath interface version 1.0, march 23, 1993, Jude Giampaolo}
- {Modified to version 1.1, june 4, 1993}
- {Modified to version 1.2, june 21, 1993. Added basic trancendental support}
- {If you find any of these functions to be helpful, or if you have any }
- {comments plese let me know at jcg@po.cwru.edu }
- {I in no way claim that these routines operate in their intended manner}
- {Please note that the accuracy is not all that great, it is reasonable however}
- {This should be corrected in a future revision}
-
- Types defigned:
- complex=record
- r,i:real;
- end;
-
- Complex numbers can be assigned in the following manner:
-
- var
- myNumber:complex;
- .
- .
- .
- myNumber.r:=12.5 {real part}
- myNumber.i:=-34.11 {imaginary part}
-
-
-
- function CMAdd (a, b: complex): complex;
- Adds two complex numbers.
-
- function CMSubtract (a, b: complex): complex;
- Subtracts number b from number a eg. (a-b).
-
- function CMMultiply (a, b: complex): complex;
- Multiplies a and b.
-
- function CMDivide (a, b: complex): complex;
- Divides number a by number b eg (a/b).
-
- function CMAbs (a: complex): real;
- Returns the magnitude of a complex number.
-
- function CMPower (base: complex; exponent: real): complex;
- Calculates base^exponent for a complex base and a real exponent.
-
- function CMExp(exponent:complex):complex;
- Calculates e raised to the power of exponent;
-
- function CMln (a:complex):complex;
- Calculates the natural logarithm of the complex number a.
-
- function CMr2c(a:real):complex;
- Type casts a real number into a complex number. For example:
- b:=CMr2c(a); is the same as:
- b.i:=0;
- b.r:=a;
-
- function CMi2c(a:real):complex;
- Type casts an imaginary (declared as a real) number into a complex
- number. For example:
- b:=CMi2c(a); is the same as:
- b.i:=a;
- b.r:=0;
-
- function CMcosh(z:complex):complex;
- Computes the hyperbolic cosine of z.
-
- function CMsinh(z:complex):complex;
- Computes the hyperbolic sine of z.
-
- fuction CMSin (z:complex):complex;
- Computes the sine of z.
-
- function CMCos (z:complex):complex;
- Computes the cosine of z.
-
- funtion CMArctan (z:complex):complex;
- Computes the inverse tangent of z.
-
-
- The following is example code for Think Pascal using this unit:
-
- program MandelTest;
- uses
- complex;
- var
- x, y, c: integer;
- z, w: complex;
- done: boolean;
- begin
- for x := 0 to 199 do
- for y := 0 to 199 do
- begin
- z.r := (x - 200) / 200;
- z.i := (y - 200) / 200;
- done := false;
- w := z;
- c := 0;
- while not done do
- begin
- z := CMAdd(w, CMMultiply(z, z));
- c := c + 1;
- if c > 100 then
- begin
- DrawLine(x, y, x, y);
- done := true;
- end;
- if CMAbs(z) > 2 then
- done := true;
- end;
- end;
- end.
-