2. Example-2
Find y(0.5) for `y'=-2x-y`, `x_0=0, y_0=-1`, with step length 0.1 using Runge-Kutta 2 method (1st order derivative)
Solution: Given `y'=-2x-y, y(0)=-1, h=0.1, y(0.5)=?`
Method-1 : Using formula `k_2=hf(x_0+h,y_0+k_1)`
Second order R-K method `k_1=hf(x_0,y_0)=(0.1)f(0,-1)=(0.1)*(1)=0.1`
`k_2=hf(x_0+h,y_0+k_1)=(0.1)f(0.1,-0.9)=(0.1)*(0.7)=0.07`
`y_1=y_0+(k_1+k_2)/2=-1+0.085=-0.915`
`:.y(0.1)=-0.915`
Again taking `(x_1,y_1)` in place of `(x_0,y_0)` and repeat the process
`k_1=hf(x_1,y_1)=(0.1)f(0.1,-0.915)=(0.1)*(0.715)=0.0715`
`k_2=hf(x_1+h,y_1+k_1)=(0.1)f(0.2,-0.8435)=(0.1)*(0.4435)=0.04435`
`y_2=y_1+(k_1+k_2)/2=-0.915+0.05792=-0.85708`
`:.y(0.2)=-0.85708`
Again taking `(x_2,y_2)` in place of `(x_1,y_1)` and repeat the process
`k_1=hf(x_2,y_2)=(0.1)f(0.2,-0.85708)=(0.1)*(0.45708)=0.04571`
`k_2=hf(x_2+h,y_2+k_1)=(0.1)f(0.3,-0.81137)=(0.1)*(0.21137)=0.02114`
`y_3=y_2+(k_1+k_2)/2=-0.85708+0.03342=-0.82365`
`:.y(0.3)=-0.82365`
Again taking `(x_3,y_3)` in place of `(x_2,y_2)` and repeat the process
`k_1=hf(x_3,y_3)=(0.1)f(0.3,-0.82365)=(0.1)*(0.22365)=0.02237`
`k_2=hf(x_3+h,y_3+k_1)=(0.1)f(0.4,-0.80129)=(0.1)*(0.00129)=0.00013`
`y_4=y_3+(k_1+k_2)/2=-0.82365+0.01125=-0.81241`
`:.y(0.4)=-0.81241`
Again taking `(x_4,y_4)` in place of `(x_3,y_3)` and repeat the process
`k_1=hf(x_4,y_4)=(0.1)f(0.4,-0.81241)=(0.1)*(0.01241)=0.00124`
`k_2=hf(x_4+h,y_4+k_1)=(0.1)f(0.5,-0.81117)=(0.1)*(-0.18883)=-0.01888`
`y_5=y_4+(k_1+k_2)/2=-0.81241-0.00882=-0.82123`
`:.y(0.5)=-0.82123`
`:.y(0.5)=-0.82123`
Method-2 : Using formula `k_2=hf(x_0+h/2,y_0+k_1/2)`
Second order R-K method `k_1=hf(x_0,y_0)=(0.1)f(0,-1)=(0.1)*(1)=0.1`
`k_2=hf(x_0+h/2,y_0+k_1/2)=(0.1)f(0.05,-0.95)=(0.1)*(0.85)=0.085`
`y_1=y_0+k_2=-1+0.085=-0.915`
`:.y(0.1)=-0.915`
Again taking `(x_1,y_1)` in place of `(x_0,y_0)` and repeat the process
`k_1=hf(x_1,y_1)=(0.1)f(0.1,-0.915)=(0.1)*(0.715)=0.0715`
`k_2=hf(x_1+h/2,y_1+k_1/2)=(0.1)f(0.15,-0.87925)=(0.1)*(0.57925)=0.05792`
`y_2=y_1+k_2=-0.915+0.05792=-0.85708`
`:.y(0.2)=-0.85708`
Again taking `(x_2,y_2)` in place of `(x_1,y_1)` and repeat the process
`k_1=hf(x_2,y_2)=(0.1)f(0.2,-0.85708)=(0.1)*(0.45708)=0.04571`
`k_2=hf(x_2+h/2,y_2+k_1/2)=(0.1)f(0.25,-0.83422)=(0.1)*(0.33422)=0.03342`
`y_3=y_2+k_2=-0.85708+0.03342=-0.82365`
`:.y(0.3)=-0.82365`
Again taking `(x_3,y_3)` in place of `(x_2,y_2)` and repeat the process
`k_1=hf(x_3,y_3)=(0.1)f(0.3,-0.82365)=(0.1)*(0.22365)=0.02237`
`k_2=hf(x_3+h/2,y_3+k_1/2)=(0.1)f(0.35,-0.81247)=(0.1)*(0.11247)=0.01125`
`y_4=y_3+k_2=-0.82365+0.01125=-0.81241`
`:.y(0.4)=-0.81241`
Again taking `(x_4,y_4)` in place of `(x_3,y_3)` and repeat the process
`k_1=hf(x_4,y_4)=(0.1)f(0.4,-0.81241)=(0.1)*(0.01241)=0.00124`
`k_2=hf(x_4+h/2,y_4+k_1/2)=(0.1)f(0.45,-0.81179)=(0.1)*(-0.08821)=-0.00882`
`y_5=y_4+k_2=-0.81241-0.00882=-0.82123`
`:.y(0.5)=-0.82123`
`:.y(0.5)=-0.82123`
This material is intended as a summary. Use your textbook for detail explanation. Any bug, improvement, feedback then
|