# Math Help - Runge Kutta on second order differential

1. ## Runge Kutta on second order differential

Hi, As part of my project I have been asked to code a program that peforms the runge kutta 4th order algoritm on a equation of form:
$ax'' + bx' + c = 0$

The way I have been told to do this is use x_1 and x_2 and use them like this:
$ax'' + bx' + c = ax_1 +bx_2 +c$
and then perform the runge Kutta algoritm on x_1 and x_2 serperately.

I haven't done anything on second order differentials for awhile now, could someone tell me how to set this up? Also is an initial condition needed? I think the solution is something like f(x) =e^(Ax).

2. Originally Posted by kenny
Hi, As part of my project I have been asked to code a program that peforms the runge kutta 4th order algoritm on a equation of form:
$ax'' + bx' + c = 0$

The way I have been told to do this is use x_1 and x_2 and use them like this:
$ax'' + bx' + c = ax_1 +bx_2 +c$
and then perform the runge Kutta algoritm on x_1 and x_2 serperately.

I haven't done anything on second order differentials for awhile now, could someone tell me how to set this up? Also is an initial condition needed? I think the solution is something like f(x) =e^(Ax).
What you do is reduce the second order ODE to a first order system or vector ODE, then use RK4 on that.

You proceed by introducing the state vector:

$\bold{X}=\left[\begin{array}{c}x_1\\x_2\end{array}\right]$

where $x_1=x$ and $x_2=x'$, then your ODE becomes:

$
\bold{X}'=\left[\begin{array}{c}x_1'\\x_2'\end{array}\right]=\left[\begin{array}{c}x_2\\-\frac{bx_2+c}{a}\end{array}\right]
$

CB

3. Thanks for your fast response.

I'm still not quite sure how I am going to set it up. I have found the piece of paper with my supervisors hints. He does this:
$x'' + 5x' + 6x = 0$
$x_1 = x, x_2 = x'$
$x_1' = x_2, x_2' = x'' = -5x_2 -6x_1$ (which is what you said basically)
and sets up x' = Ax, which has solution $e^(At)x_0$

This is the analytical solution and I understand it, but I'm kind of confused on the numerical methods way of doing it.

I think its meant to be RK4 on $x_1' = x_2$ and then on $x_2' = -5x_2 -6x_1$, but what do I do with these two outputs?

I'm fairly sure the original equation is only meant to have 1 output.

4. Originally Posted by kenny
Thanks for your fast response.

I'm still not quite sure how I am going to set it up. I have found the piece of paper with my supervisors hints. He does this:
$x'' + 5x' + 6x = 0$
$x_1 = x, x_2 = x'$
$x_1' = x_2, x_2' = x'' = -5x_2 -6x_1$ (which is what you said basically)
and sets up x' = Ax, which has solution $e^(At)x_0$

This is the analytical solution and I understand it, but I'm kind of confused on the numerical methods way of doing it.

I think its meant to be RK4 on $x_1' = x_2$ and then on $x_2' = -5x_2 -6x_1$, but what do I do with these two outputs?

I'm fairly sure the original equation is only meant to have 1 output.
Have you used RK4 on a first order scalar ODE? You really need to have numerically integrated one of these before moving to the vector case.

CB

5. Yes I managed to code RK4 for a 1st order ODE (dx/dt = 5x) to run on my GPU and generate the answers fairly accurately.

6. Could anyone please tell step by step what my program needs to do? I'm still not really sure what it is meant to do.