[Math] System of ODEs Runge-Kutta method.

numerical methodsordinary differential equationsrunge-kutta-methodssystems of equations

I need to solve the following Cauchy problem using Runge Kutta method (do 2 iterations).
$$ y'(t)=x(t)y(t)+x^2(t)$$
$$ x'(t)=y^2(t)$$
$$ y(0)=x(0)=1 $$
Let $h = 1/2 $, then we get
$x(1/2) = x(0) + \frac{1}{6}(k_1+2k_2+2k_3+k_4) $
$ k_1 = y^2(0) = 1 $
$ k_2 = y^2(1/4) $
What should I do in this case, when $ y^2(1/4) $ is unknown? Find it approximation (for example using Euler method)? Am I missing something?

Best Answer

You have $f(\binom{x}{y})=\binom{y^2}{x^2+xy}$. Give the state vector a different name, $v=\binom{x}{y}$. Then $$ k_1=hf(v_0) $$

The vector $k_2$ is computed at the position $v_0+\frac12k_1$, $$ k_2=hf(v_0+\tfrac12k_1)=\pmatrix{h(y_0+\tfrac12k_{y1})^2\\h(x_0+\tfrac12k_{x1})^2+h(x_0+\tfrac12k_{x1})(y_0+\tfrac12k_{y1})} $$ etc.

It is useful to have the evaluation of $f$ as a separate function so that one is forced to compute the intermediate positions only once.

Related Question