home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d916 / mathplot.lha / MathPlot / Macros / DGL.mapl < prev    next >
Text File  |  1993-10-04  |  1KB  |  62 lines

  1. /* Test of getintervall2 */
  2. options results
  3.  
  4. /* Plot solution of a differential equation.                */
  5. /* Asks for the function and the initial values for x and y */
  6. /* and a value for dx.                                      */
  7.  
  8.  
  9. requeststring 'prompt "y´ = ???"'
  10. fx = result
  11.  
  12. requeststring 'prompt "Start y: "'
  13. /* Make sure that one can use PI and similar things... */
  14. evalstring result
  15. y0 = result
  16.  
  17. requeststring 'prompt "Start x: "'
  18. evalstring result
  19. x0 = result
  20.  
  21. requeststring 'prompt "dx = "'
  22. dx = result
  23.  
  24. x=x0
  25. y=y0
  26.  
  27. /* Where to stop */
  28. getintervall2 stem a.
  29.  
  30. /* OK, MathPlot will clear the screen before every plot when there */
  31. /* was no REAL plot before. So we have to do some trick to get a   */
  32. /* real plot....                                                   */
  33. /* If you do not understand this: Try this script and then plot    */
  34. /* another function or the axis. Then delete the next lines, clear */
  35. /* screen and do it again. The first time, you will se both        */
  36. /* functions, the second time only the last function.              */
  37.  
  38. getfunc 0
  39. a = result
  40.  
  41. setfunc 0 10000
  42. plot 0 normal
  43.  
  44. setfunc 0 a
  45.  
  46. /* End of trick.... */
  47.  
  48.  
  49. /* And here is the routine.... */
  50.  
  51. maxx = a.xmaxreal
  52.  
  53. do while x < maxx 
  54.  evalstring fx "x=" x
  55.  dy = result*dx
  56.  y = y + dy
  57.  x = x + dx
  58.  say x y
  59.  line x0 y0 x y "pixel=off"
  60.  x0 = x
  61.  y0 = y
  62. end