What is the approximation obtained with the midpoint method after one step, answer is a function of h?

78 Views Asked by At

Write down the approximation obtained with the midpoint Runge Kutta method after one step (the answer will be a function of h).

I am stuck on this part for a first-order system. I'm not sure how to implement my system into the midpoint RK method

The RK midpoint method is $$ K_1 = f(t_n,y_n) \\ K_2 =f(t_n + \frac{h}{2},y_n +\frac{h}{2}K_1) \\y_{n+1} = y_n + hK_2 $$

The original IVP is $$ y'' + 2y' + y = te^{-t} - 1 \\y(0) = y'(0) = 0 \\0\leq t \leq1 $$

My system is $$ y_1' = y_2 $$

$$ y_2' = te^{-t} -1 -2y_2 -y_1 $$ where $y_1(0) = y_2(0) = 0$

1

There are 1 best solutions below

1
On

When you have two equations, $f$ and the $K$s are two position vectors. Now $y=\begin{pmatrix} y_1\\y_2 \end {pmatrix}$. You should write your system as a single equation working on two position vectors. The second argument of $f$ is also a two position vector. You are given $y_0$ and $t_0$. Plug them in to get $K_1$. Plug them and $K_1$ in to get $K_2$

Added: You may have confusion about the subscripts. The subscripts $1,2$ are the variables, the subscripts $n$ are the values of the variables at time step $n$. So at $t=0, y_{10}=y_{20}=0.$ You plug those into $K_{10}=\begin{pmatrix} 0\\-1 \end {pmatrix}$ Then $K_{20}=f\left(\frac h2,\frac h2\begin{pmatrix} 0\\-1 \end {pmatrix}\right)$ and you plug those last into the right side of your equations to compute $K_{20}$