1
$\begingroup$

I'm trying to find aproximated solution for this Initial Value Problem (IVP)

$y'' - 2y^3 = 0$ with $y(1)=1$ and $y'(1)=-1$, $x\in [1,2]$ with a step size $h=0.1$ A using Runge-Kutta-2 (RK2)

$y_{i+1}=y_i + \frac{K_1 + K_2}{2}$

$K_1 = hf(x_i,y_i)$

$K_2 = hf(x_i + h, y_i + K_1)$

But as you can see there is a 2nd order differential equation. So I tried to do a conversion to a system of differential equations of 1st degree as follow:

Let $y' = z$ and $y''=z'$ and therefore $z' = 2y^3$.

So now I have to equations:

$\alpha : y' = z$

$\beta : z' = 2y^3$

with $x_0 =1, y_0 = 1$ and $z_0=-1$

And then after an adaptation to RK2 method I need to evaluate in:

$K_1^{\alpha} = h \alpha (x_i,y_i,z_i)$

So far so good, right?

but my problem is that I am not really sure in wich function to evaluate: $\alpha (x_i,y_i,z_i)$ cause that represesents $y' = z$ but there isn't an actual $y'$ on the IVP equation, so i'm wondering if I should evaluate it as a null function, I mean that $y' = 0$ for every value?

Thanks in advance, and I hope I explained myself. If not, let me know and I'll try to do it better

$\endgroup$
1
$\begingroup$

The conversion to first order equations is correct and the right way to go. The final part missing is that you need to use the multidimensional form of the Runge-Kutta method. The equations look exactly the same as in the one-dimensional case with the exception that the quantities involved are now vectors instead of just pure numbers.

As you have shown you can write the system as $\dot{{\bf Y}} = {\bf f}({\bf Y})$ where ${\bf Y} = \pmatrix{y\\z}$, ${\bf f}({\bf Y}) = \pmatrix{z\\2y^3}$ and the initial conditions reads ${\bf Y}_0 = \pmatrix{1\\-1}$. Note that $y$ and $z$ are treated as independent variables for the purpose of applying this method: we are solving for $y$ and $y'$ at the same time. At every step you need to compute

$${\bf K}_1 = h{\bf f}({\bf Y}_i) = \pmatrix{hz_i\\2hy_i^3}$$

$${\bf K}_2 = h{\bf f}({\bf Y}_i + {\bf K}_1) = \pmatrix{h(z_i+2hy_i^3)\\2h(y_i + hz_i)^3}~~~\text{since}~~~~{\bf Y}_i + {\bf K}_1 = \pmatrix{y_i + hz_i\\z_i + 2hy_i^3}$$ and update ${\bf Y}$ using

$${\bf Y}_{i+1} = {\bf Y}_i + \frac{{\bf K}_1 + {\bf K}_2}{2}$$

As you can see if you just use vector notation (which is easy to do also in an numerical code) then it's just as easy to do the multidimensional case as the one dimensional case.

$\endgroup$
  • $\begingroup$ Great approach with vector notation. It is easier to understand. Thanks $\endgroup$ – DarK_FirefoX Apr 10 '17 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.