DEFDBL a-z DECLARE FUNCTION f(x, y) ' ' Sample program to solve the differential equation ' ' y' = f(x,y) ' ' using the midpoint 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 first half of new iteration x12 = x + .5 * dx y12 = y + .5 * dx * f(x, y) ' compute complete iteration with slope at half the step x1 = x + dx y1 = y + dx * f(x12, y12) ' display new iteration PRINT USING "#### ####.#### ####.#######"; i%; x1; y1 ' prepare for next iteration x = x1 y = y1 NEXT i% PRINT " Press any key to terminate!!!" DO LOOP WHILE INKEY$ = "" END FUNCTION f (x, y) ' ' contains the right hand side of the differential equation ' f = -2 * y * x END FUNCTION