4th order runge kutta method

  • Thread starter snelson989
  • Start date
  • #1
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.
 

Answers and Replies

  • #2
Filip Larsen
Gold Member
1,275
209
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.
 
  • #3
1,444
4
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).
 

Related Threads on 4th order runge kutta method

Replies
0
Views
8K
Replies
14
Views
801
Replies
6
Views
1K
Replies
2
Views
2K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
1
Views
4K
Replies
1
Views
3K
  • Last Post
Replies
8
Views
2K
Replies
5
Views
2K
Top