home *** CD-ROM | disk | FTP | other *** search
- /* Test of getintervall2 */
- options results
-
- /* Plot solution of a differential equation. */
- /* Asks for the function and the initial values for x and y */
- /* and a value for dx. */
-
-
- requeststring 'prompt "y´ = ???"'
- fx = result
-
- requeststring 'prompt "Start y: "'
- /* Make sure that one can use PI and similar things... */
- evalstring result
- y0 = result
-
- requeststring 'prompt "Start x: "'
- evalstring result
- x0 = result
-
- requeststring 'prompt "dx = "'
- dx = result
-
- x=x0
- y=y0
-
- /* Where to stop */
- getintervall2 stem a.
-
- /* OK, MathPlot will clear the screen before every plot when there */
- /* was no REAL plot before. So we have to do some trick to get a */
- /* real plot.... */
- /* If you do not understand this: Try this script and then plot */
- /* another function or the axis. Then delete the next lines, clear */
- /* screen and do it again. The first time, you will se both */
- /* functions, the second time only the last function. */
-
- getfunc 0
- a = result
-
- setfunc 0 10000
- plot 0 normal
-
- setfunc 0 a
-
- /* End of trick.... */
-
-
- /* And here is the routine.... */
-
- maxx = a.xmaxreal
-
- do while x < maxx
- evalstring fx "x=" x
- dy = result*dx
- y = y + dy
- x = x + dx
- say x y
- line x0 y0 x y "pixel=off"
- x0 = x
- y0 = y
- end