Runge-Kutta Method for A First Order Equation
This program will compute the solution of the Cauchy problem for the first order differential equation using a 4th order Runge-Kutta method:
dy/dx=f(Y(x),x) , X >A
Y (A) = Ya
Program Notes
To run this program, you must define the function f(Y,X) in the function statement.
Example:
Compute the solution to the Cauchy problem:
dy/dx = x + y , x > 0
Y(0) = 0
Downloads:
basic program (liberty basic) lbrkmse.bas
Test Case:
Notice that the problem will not converge without the use of step size control:
RUNGE-KUTTA METH0D FOR A SYSTEM OF EQUATIONS
ENTER LIMITS OF INTEGRATION A = 0 B = 1 YA = 0 INITIAL STEPSIZE H = .5 LOCAL ERROR TOLERANCE X AS IN 1E-X X = 7 STEPSIZE CONTROL (Y/N) ?Y
SOLUTION ******** X = 0 Y = 0 X = 0.0625 Y = 0.19944589e-2 X = 0.125 Y = 0.8148453e-2 X = 0.1875 Y = 0.18730249e-1 X = 0.25 Y = 0.34025417e-1 X = 0.3125 Y = 0.54337941e-1 X = 0.375 Y = 0.79991415e-1 X = 0.4375 Y = 0.1113303 X = 0.5 Y = 0.14872127 X = 0.5625 Y = 0.19255466 X = 0.625 Y = 0.24324596 X = 0.6875 Y = 0.30123747 X = 0.75 Y = 0.36700002 X = 0.8125 Y = 0.44103479 X = 0.875 Y = 0.52387529 X = 0.9375 Y = 0.61608946 X = 1 Y = 0.71828183 END OF EXECUTION
|