Applying a Combination of Runge-Kutta and Midpoint Rule for this IVP

43 Views Asked by At

For a time step $h=0.5$, how can we apply a $RK2-M$ method to solve the following IVP? \begin{cases} y^{\prime}(t)=-1.2 y(t)+7 e^{-0.3 t}=f(t, y(t)), \quad t \in[0,1.5] \\ y(0)=3 \end{cases} Now the problem I am facing is in the transition of this IVP into the desired scheme. I know that $K_{1}=f(t_{i},y_{i})$ but I always get lost in computing $K_{2}$ and thus my computations are wrong. Any help is much appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

As indicated by @Lutz Lehmann, the implementation is not hard at all (a matter of practicing), The full $RK2-M$ scheme is given by : $$ \left\{\begin{array}{l} K_{1}=f\left(t_{i}, y_{i}\right)=-1.2 y_{i}+7 e^{-0.3 t_{i}} \\ K_{2}=f\left(t_{i}+\frac{h}{2}, y_{i}+\frac{h}{2} K_{1}\right)=-1.2\left(y_{i}+\frac{h}{2} K_{1}\right)+7 e^{-0.3\left(t_{i}+\frac{h}{2}\right)} \\ y_{i+1}=y_{i}+h K_{2} \end{array}\right. $$ By proceeding with computing $K_{1}$, $K_{2}$, and $y_{i+1}$ for different time intervals, we are able to recursively obtain a solution for the IVP, I have constructed this table that shows the obtained values : $$ \begin{array}{|c|c|c|c|c|c|} \hline \mathrm{i} & t_{i} & y_{i} & K_{1}=-1.2 y_{i}+7 e^{-0.3 t_{i}} & K_{2}=-1.2\left(y_{i}+\frac{h}{2} K_{1}\right)+7 e^{-0.3\left(t_{i}+\frac{4}{2}\right)} & y_{i+1}=y_{i}+h K_{2} \\ \hline 0 & 0 & 3 & -1.2 * 3+7=3.4 & -1.2 *\left(3+\frac{3.4}{4}\right)+7 e^{-0.075} & 3+1.8742 * 0.5 \\ & & & & =1.8742 & =3.9371 \\ \hline 1 & \frac{1}{2} & 3.9371 & -1.2 * 3.9371+7 e^{-0.15} & -1.2\left(3.9371+\frac{1}{4} 1.3004\right)+7 e^{-0.3\left(\frac{4}{4}\right)} & 3.9371+0.47497 * 0.5 \\ & & & =1.3004 & =0.47497 & =4.1746 \\ \hline 2 & 1 & 4.1746 & -1.2 * 4.1746+7 e^{-0.3} & -1.2 *\left(4.1746+\frac{1}{4} 0.17621\right)+7 e^{-0.3\left(\frac{5}{4}\right)} & 4.1746-0.25136 * 0.5 \\ & & & =0.17621 & =-0.25136 & =4.0489 \\ \hline 3 & \frac{3}{2} & 4.0489 & \mathrm{x} & \mathrm{x} & \mathrm{x} \\ \hline \end{array} $$ The exact solution is hence : $$ \boxed{y(t)=-\frac{43}{9}e^{-1.2t}+\frac{70}{9}e^{-0.3t}} $$

0
On

You have $$ K_2=f(t_i+h/2,y_i+hK_1/2) $$ and then $$ y_{i+1}=y_i+hK_2 $$ This should not be hard to implement.