4th order Runge Kutta method ODE problem

146 Views Asked by At

This is a question from a test that I failed to pass and it really bugs, wish that someone could explain it to me.Consider the differential equation

$\frac{dx}{dt} = \frac{1}{2x}$

This is a separable O.D.E., so the solutions are of the form

$x(t) = \sqrt{t + C}$

where C is a constant. Imposing the initial condition x(1) = 1 fixes C = 0. Then we have $x(2) = \sqrt{2}$.

Use Euler's method with h = 1/2 to find an approximation to $\sqrt{2}$. Provide a numeric answer rounded to two decimal places.The answer to this is very obviously 1.45. The next part is issue: Apply the fourth order Runge-Kutta method: \begin{align} x_{n+1} ​ &=x_n ​ + 1/6 ​ (k_1 ​ +2k_2 ​ +2k_3 ​+k_4) \\\hline k_1 ​ & =hf(x_n ​ ,t_n ​ ) \\ k_2 ​ &=hf(x_n ​ + 1/2 ​ k_1 ​ ,t_n ​ + 1/2 ​ h) \\ k_3 ​ & =hf(x_n ​ + 1/2 ​ k_2 ​ ,t_n ​ + 1/2 ​ h) \\ k_4 ​ &=hf(x_n ​ +k_3 ​ ,t_n ​ +h) \end{align}

Apply it, with $h=1$, to the initial value problem of the previous Question to find a (better) approximation to $\sqrt{2}$ ​ Provide a numeric answer rounded to five decimal places. The following is the calculation that was rejected, I didn't understand why it was incorrect: $$ x=\sqrt{t};\:\frac{dx}{dt}=\frac{1}{2\sqrt{t}}\:; \\ t_0=1,\:x_0=\sqrt{t};x_0=\sqrt{1};x\left(1\right)=1\:h=1; \\ \:y\left(1\right)=1;\:x_0=1;\:y_0=1\:h=1; \\ k_1=1⋅\frac{1}{2\sqrt{1}}=\frac{1}{2}=0.5;\: \\ k_2=1⋅f\left(1+\frac{1}{2}⋅\frac{1}{2},1+\frac{1}{2}⋅1\right)=f\left(\frac{5}{3},\frac{3}{2}\right)=\frac{1}{2\sqrt{\frac{3}{2}}}=\frac{1}{6}=0.40825;\: \\ k_3=1⋅f\left(1+\frac{1}{2}⋅\left(0.40825\right)1+\frac{1}{2}⋅1\right)=f⋅\left(1.20412,1.5\right)=\frac{1}{2\sqrt{1.5}}=0.40825;\: \\ k_4=0.35355;\: \\ x_1=1+\frac{1}{6}\left(0.5+2⋅0.40825+2⋅0.40825+0.35355\right)=1.41442 $$ – Please, could someone illuminate my mistake or point me in the direction of a correct answer? I love math, although I am probably to dum to get it right, please, don't downvote!

2

There are 2 best solutions below

1
On

This is the correct solution I found online, monkey see monkey copy. The answer is $k1=\frac{1}{2};k2=\frac{2}{5};k3=\frac{5}{12};k4=\frac{6}{17};1+\frac{1}{6}\left(\frac{1}{2}+2\left(\frac{2}{5}\right)+2\left(\frac{5}{12}\right)+\frac{6}{17}\right)$ =1.41438 Does nothing for my understanding though

0
On

You ran RK4 for $\frac{dx}{dt}=\frac{1}{2\sqrt{t}},x(1)=1$. This ODE IVP has the same exact solution as yours, but nonetheless changing the equation in this way changes the numerical solution a little bit.