home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / 1dchaos0 / funciont.p next >
Encoding:
Text File  |  1992-05-17  |  3.1 KB  |  119 lines

  1. UNIT ExternalFunction;
  2.  
  3. {For other language platforms: Your code must be stored un a file of type 'Plug' with creator}
  4. {'GrFP'.  The actual code must be stored in a resource of type 'Func'.  You must use the }
  5. {FPU,  since the program uses the FPU extended format.  Your code must accept a message }
  6. {integer and a variable info pointer.  It should not ever allocate memory for the pointer. }
  7. {It should return an extended type (96 bits) as it's result.  The messages are fairly self }
  8. {explanatory. Variables are passed each time in the Info pointer, and the numbers are stored as }
  9. {pointers to extended type.  X is the main variable and P is a variable parameter (used, for}
  10. {example in the bifurcation plot) .  For operations requiring a number of iterations, an integer N }
  11. {is passed}
  12.  
  13. INTERFACE
  14.  
  15.     CONST
  16.         GetName = -1;
  17. {Return the nameof the function in Info^ as you want it to appear in the menu}
  18. {Assume the space has been allocated}
  19.         InitFunc = 0;
  20. {Return the default parameters, bounds  in the form of Initrec.)}
  21. {Assume the space has been allocated}
  22.         ReturnFunc = 1;
  23. {return the flat out first iterate of your function}
  24.         ReturnNthX = 2;
  25. {return the Nth iterate with respect to x of your function}
  26. {YOU MUST RESTORE the value of X^ to its original value}
  27.         ReturnNthP = 3;
  28. {Not used}
  29.         Return1DerivX = 4;
  30. {return the real first derivative of x}
  31.         Return2DerivX = 5;{Not used}
  32.         Return3DerivX = 6;{Not used}
  33.         return4DerivX = 7;{Not used}
  34.         Return1DerivP = 8;{Not used}
  35.         Return2DerivP = 9;{Not used}
  36.         Return3DerivP = 10;{Not used}
  37.         return4DerivP = 11;{Not used}
  38.         ReturnIntegralX = 12;{Not used}
  39.         ReturnIntegralP = 13;{Not used}
  40.  
  41.     TYPE
  42.         NumberPtr = ^NumberType;
  43.         NumberType = extended;
  44.  
  45.         NamePtr = ^Str255;
  46.  
  47.         InitPtr = ^InitRec;
  48.         InitRec = RECORD
  49.                 Xmin, XMax, FXmin, FXmax, PMin, PMax: NumberType;
  50.                 InitialX, InitialX0, InitialP: NumberType;
  51.             END;
  52.  
  53.         DoFuncPtr = ^DoFuncRec;
  54.         DoFuncRec = RECORD
  55.                 X, P: NumberPtr;
  56.                 N: Integer;
  57.             END;
  58.  
  59.  
  60.     FUNCTION Main (message: integer; VAR Info: ptr): NumberType;
  61.  
  62. IMPLEMENTATION
  63.  
  64.     FUNCTION Main (message: integer; VAR Info: ptr): NumberType;
  65.         VAR
  66.             result, XHold: extended;
  67.             i: integer;
  68.     BEGIN
  69.         WITH DoFuncPtr(Info)^ DO
  70.             CASE message OF
  71.  
  72.                 GetName: 
  73.                     NamePtr(info)^ := 'Tan(x)*p';
  74.  
  75.  
  76.                 ReturnFunc:
  77. {*****************INSERT FUNCTION HERE*********************}
  78.                     result := Tan(x^) * p^;
  79. {******************************************************}
  80.  
  81.                 ReturnNthX: 
  82.                     BEGIN
  83.                         XHold := X^;
  84.                         FOR I := 1 TO N DO
  85. {*****************INSERT FUNCTION HERE*********************}
  86.                             X^ := Tan(x^) * p^;
  87. {******************************************************}
  88.                         Result := X^;
  89.                         X^ := XHold;
  90.                     END;
  91.  
  92.                 Return1DerivX:
  93. {*****************INSERT DERIVATIVE HERE*********************}
  94.                     result := 0;
  95. {******************************************************}
  96.  
  97.                 InitFunc: 
  98.                     WITH initptr(Info)^ DO
  99.                         BEGIN
  100.                             XMin := -6.29;
  101.                             XMax := 6.29;
  102.                             FXMin := -6.29;
  103.                             FXMax := 6.29;
  104.                             PMin := -1;
  105.                             PMax := 1;
  106.                             InitialX := 0;
  107.                             InitialX0 := 0;
  108.                             initialP := -2;
  109.                             result := 0;
  110.                         END;
  111.  
  112.                 OTHERWISE
  113.                     info := NIL;
  114.             END;
  115.  
  116.         Main := Result;
  117.     END;
  118.  
  119. END.