home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Pascal / Libraries / CMmath / CMmath.doc next >
Encoding:
Text File  |  1993-06-25  |  3.0 KB  |  120 lines  |  [TEXT/R*ch]

  1. The following documentation is for the Think Pascal libraries 'CMmath.lib'
  2. and 'CMmath6888x.lib. release 1.2. 
  3.  
  4. Note: CMmath.lib will work an any macintosh. CMmath6888x.lib will only
  5.         function on machines with either a 68020 or 68030 with either a
  6.         68881 or 68882 coprocessor, or on a 68040. The CMmath6888x.lib
  7.         library will NOT work with a 68LC040.
  8.  
  9. {ComplexMath interface version 1.0, march 23, 1993, Jude Giampaolo}
  10. {Modified to version 1.1, june 4, 1993}
  11. {Modified to version 1.2, june 21, 1993. Added basic trancendental support}
  12. {If you find any of these functions to be helpful, or if you have any }
  13. {comments plese let me know at jcg@po.cwru.edu }
  14. {I in no way claim that these routines operate in their intended manner}
  15. {Please note that the accuracy is not all that great, it is reasonable however}
  16. {This should be corrected in a future revision}
  17.  
  18. Types defigned:
  19.     complex=record
  20.         r,i:real;
  21.         end;
  22.     
  23. Complex numbers can be assigned in the following manner:
  24.  
  25. var
  26.     myNumber:complex;
  27. .
  28. .
  29. .
  30. myNumber.r:=12.5    {real part}
  31. myNumber.i:=-34.11    {imaginary part}
  32.  
  33.  
  34.  
  35.  function CMAdd (a, b: complex): complex;
  36.      Adds two complex numbers.
  37.     
  38.  function CMSubtract (a, b: complex): complex;
  39.      Subtracts number b from number a eg. (a-b).
  40.     
  41.  function CMMultiply (a, b: complex): complex;
  42.      Multiplies a and b.
  43.     
  44.  function CMDivide (a, b: complex): complex;
  45.      Divides number a by number b eg (a/b). 
  46.     
  47.  function CMAbs (a: complex): real;
  48.      Returns the magnitude of a complex number.
  49.     
  50.  function CMPower (base: complex; exponent: real): complex;
  51.      Calculates base^exponent for a complex base and a real exponent.
  52.     
  53.  function CMExp(exponent:complex):complex;
  54.      Calculates e raised to the power of exponent;
  55.     
  56.  function CMln (a:complex):complex;
  57.      Calculates the natural logarithm of the complex number a.
  58.     
  59.  function CMr2c(a:real):complex;
  60.      Type casts a real number into a complex number. For example:
  61.         b:=CMr2c(a); is the same as:
  62.         b.i:=0;
  63.         b.r:=a;
  64.         
  65.  function CMi2c(a:real):complex;
  66.      Type casts an imaginary (declared as a real) number into a complex
  67.     number. For example:
  68.         b:=CMi2c(a); is the same as:
  69.         b.i:=a;
  70.         b.r:=0;
  71.         
  72.  function CMcosh(z:complex):complex;
  73.      Computes the hyperbolic cosine of z.
  74.     
  75.  function CMsinh(z:complex):complex;
  76.      Computes the hyperbolic sine of z.
  77.     
  78.  fuction CMSin (z:complex):complex;
  79.      Computes the sine of z.
  80.     
  81.  function CMCos (z:complex):complex;
  82.      Computes the cosine of z.
  83.     
  84.  funtion CMArctan (z:complex):complex;
  85.      Computes the inverse tangent of z.
  86.         
  87.     
  88. The following is example code for Think Pascal using this unit:
  89.     
  90. program MandelTest;
  91.  uses
  92.   complex;
  93.  var
  94.   x, y, c: integer;
  95.   z, w: complex;
  96.   done: boolean;
  97. begin
  98.  for x := 0 to 199 do
  99.   for y := 0 to 199 do
  100.    begin
  101.     z.r := (x - 200) / 200;
  102.     z.i := (y - 200) / 200;
  103.     done := false;
  104.     w := z;
  105.     c := 0;
  106.     while not done do
  107.      begin
  108.       z := CMAdd(w, CMMultiply(z, z));
  109.       c := c + 1;
  110.       if c > 100 then
  111.        begin
  112.        DrawLine(x, y, x, y);
  113.        done := true;
  114.        end;
  115.       if CMAbs(z) > 2 then
  116.        done := true;
  117.      end;
  118.    end;
  119. end.
  120.