# RK4 Approximation

I have the following differential equation:

$y'=xy^2-(y/x)$ with the initial value $y(1)=1$.

I'm trying to get a 4-digit approximation of this differential equation for $y(1.5)$ but I have thus far been unable to understand the RK4 method. I have been trying to understand how you would solve this without a computing system and so far I have been unable to figure this out.

Anything would help. Thanks!

• For me it is not clear what you actually want. Do you need to use the RK4 method? If not, why did you choose RK4? Commented Dec 8, 2017 at 15:47
• Well actually it doesn't matter. Since you don't care to appreciate help, I will not waste time here. Commented Dec 8, 2017 at 15:50

You set $h=0.5$. Then compute per cook-book recipe using rounding to 2 digits \begin{align} k_1&=hf(x,y)&&=0.5f(1,1)&&=0\\ k_2&=hf(x+0.5h, y+0.5k_1)&&=0.5f(1.25, 1)&&=0.22\\ k_3&=hf(x+0.5h, y+0.5k_2)&&=0.5f(1.25, 1.1)&&=0.5(1.25\cdot 1.21-1.1⋅0.8)=0.32\\ k_2&=hf(x+h, y+k_3)&&=0.5f(1.5,1.32)&&=0.5(2.73-0.9)=0.87\\ \\ y(1.5)&\approx 1+(k_1+2k_2+2k_3+k_4)/6&&=1+1.95/6&&=1.32 \end{align}

The double computation gives

k1 = 0.0
k2 = 0.225
k3 = 0.32853515625
k4 = 0.8809091939608258
1+(k1+2k2+2k3+k4)/6 = 1.331329917743471


The exact solution results from $u(x)=\dfrac1{xy(x)}$, $u(1)=1$ $$(xu)'=u+xu'=-\frac{y'}{y^2}=-x+u\\\implies u'=-1,\; u=2-x \\\implies y(x)=\frac{1}{2x-x^2}$$ so that $y(\frac32)=\frac43=1.3333...$