Runge-Kutta Method for a System of Equation
This program computes the initial value for the equation:
dYi/dx = fi (Yj(x),x) , x>a where (i -1,2,. .., N) Yi (a) = Yai
using a 4th order Runge-Kutta method. You will need to enter an end point (b) so that x is bounded by (a,b). You will also need to define the functions fi ( Yj (x),x ) starting at line 2000. You must also specify a local error tolerance (E) and step size (H) for the independent variable (x). Two options are available:
1. Fixed step size. The program checks the local error tolerance at each integration step, prompting an error message if the tolerance is exceeded.
2. Controlled step size. The program automatically controls the step size, increasing it or decreasing it to meet the prescribed tolerance.
Program Notes
As written, this program will solve for systems of the 4th order at most. To increase this, the DIM statement in line 1 must be modified as follows:
Y(N), YO(N), W(N), Z(N), S(N), Ql(N) where N is the new dimension.
Downloads:
basic program - qbrkmfoe.bas (Qbasic)
basic program (liberty basic) lbrkmfoe.bas
Test Case:
for the following equations input at end of program:
[TWZEONZE] F = Y(2) RETURN [TWZETHZE] F = -.2*Y(2) RETURN [TWZEFIZE] F = Y(4) RETURN [TWZESEZE] F = -9.81-.2*Y(4) RETURN [TWZENIZE] F = 0
RUNGE-KUTTA METH0D FOR A FIRST ORDER EQUATION
NUMBER OF EQUATIONS M=4
ENTER LIMITS OF INTEGRATION A =0 B =1
ENTER INITIAL DATA Y1 (A) = 0 Y2 (A) = 3 Y3 (A) = 0 Y4 (A) = 5
INITIAL STEPSIZE H =.1
LOCAL ERROR TOLERANCE X AS IN 1E-X E = 6
STEPSIZE CONTROL?(Y/N)?y
SOLUTION ******** X = 0 Y1 =0 Y2 =3 Y3 =0 Y4 =5
X = 0.1 Y1 =0.2970199 Y2 =2.94059602 Y3 =0.44630854 Y4 =3.92973829
X = 0.3 Y1 =0.873532 Y2 =2.8252936 Y3 =1.0231348 Y4 =1.85237304
X = 0.5 Y1 =1.42743873 Y2 =2.71451225 Y3 =1.19268778 Y4 =-0.14353756
X = 0.7 Y1 =1.95962647 Y2 =2.60807471 Y3 =0.97093688 Y4 =-2.06118738
X = 0.9 Y1 =2.47094683 Y2 =2.50581063 Y3 =0.37322537 Y4 =-3.90364507
X = 1.1 Y1 =2.96221803 Y2 =2.40755639 Y3 =-0.58570515 Y4 =-5.67385897
END OF EXECUTION
|