How Does the 4th Order Runge-Kutta Method Solve Coupled First Order Linear ODEs?

  • Thread starter Thread starter snelson989
  • Start date Start date
  • Tags Tags
    Method Runge kutta
snelson989
Messages
3
Reaction score
0
I just need to know the general form of the 4th order Runge-Kutta method?
For two coupled first order linear ODEs.
I can not find it specifically written online, I need it to write a program for the structure of white dwarfs stars, but I am okay with the Physics, just I have never used the runge-Kutta method.

Thanks.
 
Physics news on Phys.org
Welcome to PF!

Searching your references for "Runge Kutta 4", or simply "RK4", should provide you with equations that you very easily can turn into a program. If you are not supposed to implement the method yourself, then searching for both RK4 and your favorite language at the same time may even provide you with a code snippet.
 
For one ODE:

To approximate the solution of the initial-value problem
y' = f(t, y), a <t <b, y(a) = y0,
at (N + 1) equally spaced numbers in the interval [a,b]:
INPUT endpoints a, b; integer N; initial condition y0.
OUTPUT approximation w to y at the (N + 1) values of t.
Step 1 Set h = (b - a)/N;
t = a;
w = y0;
OUTPUT (t, w).
Step 2 For i = 1, 2,... , N do Steps 3-5.
Step 3 Set K1=hf(t,w);
K2 = hf(t + h/2,w + K1 /2);
K3 = hf(t+h/2,w + K2/2);
K4 = hf(t + h,w + K3).
Step 4 Set w = w + (K1 + 2K2 + 2K3 + K4)/6; (Compute w_i)
t = a + ih. (Compute t_i)
Step 5 OUTPUT (t, w).
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top