DEFDBL a-z
DECLARE FUNCTION f(x, y)
'
' Sample program to solve the differential equation
'
' y' = f(x,y)
'
' using Euler's method
'
' The exact form of the right hand side is placed in FUNCTION F
' of this program
INPUT "Initial condition x(0) = "; x
INPUT " y(0) = "; y
INPUT "Stepsize dx = "; dx
INPUT "Number of iteration to be computed = "; n%
FOR i% = 1 TO n%
' compute new iteration
x1 = x + dx
y1 = y + dx * f(x, y)
' display new iteration
PRINT USING "#### ####.#### ####.#######"; i%; x1; y1
' prepare for next iteration
x = x1
y = y1
NEXT i%
PRINT "Press any key to terminate the job!!!"
DO
LOOP WHILE INKEY$ = ""
END
FUNCTION f (x, y)
'
' contains the right hand side of the differential equation
'
f = -2 * y * x
END FUNCTION