DEFDBL a-z
DECLARE FUNCTION f(x, y)
'
' Sample program to solve the differential equation
'
' y' = f(x,y)
'
' using the predictor-corrector 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 the predicted new iteration
x1p = x + dx
y1p = y + dx * f(x, y)
' compute the corrected new iteration
x1 = x + dx
y1 = y + .5 * dx * (f(x, y) + f(x1p, y1p))
' 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