# Need a hint using Runge-Kutta to solve this

Recall the fourth order Runge-Kutta method: $$x_{n+1} = x_n + \frac16(k_1 + 2k_2 + 2k_3 + k_4)$$ Apply it, with $h = 1$ to the initial value problem in the previous question to obtain a better approximation to $\sqrt2$. Provide a numerical answer rounded to five decimal places.

I need a hint solving this equation. Please help!

• What, exactly, is "the previous question"? And what have you tried? – Arthur Jan 4 '16 at 10:52
• Thank you for the edit. I do not understand, where to insert h. i tried k4 = hf(xn + k3, tn + h) – Spacemoose Jan 4 '16 at 10:54
• The first problem is this one: math.stackexchange.com/questions/1599366/… – Spacemoose Jan 4 '16 at 13:01

## 1 Answer

The differential equation in question is $$\frac{dx}{dt} = \frac{1}{2x}, \quad x(1) = 1$$ which has general solution $x(t) = \sqrt{t+C}$, and with the given initial value, we get the specific solution $x(t) = \sqrt t$. That means that starting at $t_0 = 1$, and using some numerical method with $h = 1$, we should get to an approximation of $\sqrt2$ in one step. We are told to use Runge-Kutta of fourth order, and that is what we're going to do.

Gathering what we're given, both from the problem itself and the definition of fourth-order Runge-Kutta, we have $$f(t, x) = \frac 1{2x}\\ x_0 = 1\\ t_0 = 0\\ x_{n+1} = x_n + \frac16(k_1 + 2k_2 + 2k_3 + k_4)\\ k_1 = f(t_n, x_n)\\ k_2 = f(t_n + \frac12, x_n + \frac{k_1}{2})\\ k_3 = f(t_n + \frac12, x_n + \frac{k_2}{2})\\ k_4 = f(t_n + 1, x_n + k_3)$$ (Note that there are supposed to be quite a lot of $h$ strewn in here and there as well. Since we're told that $h = 1$, I've skipped those.)

The solution to our problem is $x_1$. So we just start calculating: $$k_1 = f(t_0, x_0) = \frac{1}{2x_0} = \frac12\\ k_2 = f(t_0 + \frac12, x_0 + \frac{k_1}{2}) = \frac{1}{2(x_0 + k_1/2)} = \frac{1}{2(1 + 1/4)} = \frac25\\ k_3 = f(t_0 + \frac12, x_0 + \frac{k_2}{2}) = \frac1{2(x_0 + k_2/2)} = \frac{1}{2(1 + 1/5)} = \frac{5}{12}\\ k_4 = f(t_0 + 1, x_0 + k_3) = \frac{1}{2(x_0 + k_3)} = \frac{1}{2(1 + \frac{5}{12})} = \frac{6}{17}$$ and with this we can enter everything into the final expression: $$x_1 = x_0 + \frac16(k_1 + 2k_2 + 2k_3 + k_4)\\ = 1 + \frac16\left(\frac12 + \frac45 + \frac56 + \frac6{17}\right)\\ = \frac{1082}{765} \approx 1.414379084967320261437$$

• You are such a boss O.O – Spacemoose Jan 4 '16 at 16:21