DEFDBL a-z DECLARE FUNCTION fy (x, y, z) DECLARE FUNCTION fz (x, y, z) ' ' Sample program to solve the system of two coupled ' differential equations ' ' y' = fy(x,y,z) ' z' = fz(x,y,z) ' ' using the simultaneous midpoint method ' ' The exact form of the right hand sides are placed ' in FUNCTION FY and FUNCTION FZ of this program INPUT "Initial condition x(0) = "; x INPUT "Initial condition y(0) = "; y INPUT "Initial condition z(0) = "; z 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 * fy(x, y, z) z12 = z + .5 * dx * fz(x, y, z) ' compute full iteration with slope at half the step x1 = x + dx y1 = y + dx * fy(x12, y12, z12) z1 = z + dx * fz(x12, y12, z12) ' display new iteration PRINT USING "#### #####.##### #####.###### #####.######"; i%; x1; y1; z1 ' prepare for next iteration x = x1 y = y1 z = z1 NEXT i% PRINT "Press any key to terminate the job!!!" DO LOOP WHILE INKEY$ = "" END FUNCTION fy(x, y, z) ' ' contains the right hand side of the differential equation ' y' = fy(x,y,z) ' fy = -2 * z END FUNCTION FUNCTION fz(x, y, z) ' ' contains the right hand side of the differential equation ' z' = fz(x,y,z) ' fz = y - (SIN(x)) ^ 2 END FUNCTION