2. Example-2
2. Find y(0.5) for `y'=-2x-y`, y(0) = -1, with step length 0.1 using Modified Euler method
Solution: Given `y'=-2x-y, y(0)=-1, h=0.1, y(0.5)=?`
Here, `x_0=0,y_0=-1,h=0.1`
`y'=-2x-y`
`:. f(x,y)=-2x-y`
Modified Euler method `y_(m+1)=y_m+hf(x_m+1/2 h,y_m + 1/2 hf(x_m,y_m))`
`f(x_0,y_0)=f(0,-1)=1`
`x_0+1/2 h=0+0.1/2 =0.05`
`y_0 + 1/2 hf(x_0,y_0)=-1+0.1/2 * 1=-0.95`
`f(x_0+1/2 h, y_0 + 1/2 hf(x_0,y_0)=f(0.05,-0.95)=0.85`
`y_1=y_0+hf(x_0+1/2 h, y_0 + 1/2 hf(x_0,y_0))=-1+0.1*0.85=-0.915`
Again taking `(x_1,y_1)` in place of `(x_0,y_0)` repeat the process
`f(x_1,y_1)=f(0.1,-0.915)=0.715`
`x_1+1/2 h=0.1+0.1/2 =0.15`
`y_1 + 1/2 hf(x_1,y_1)=-0.915+0.1/2 * 0.715=-0.87925`
`f(x_1+1/2 h, y_1 + 1/2 hf(x_1,y_1)=f(0.15,-0.87925)=0.57925`
`y_2=y_1+hf(x_1+1/2 h, y_1 + 1/2 hf(x_1,y_1))=-0.915+0.1*0.57925=-0.85708`
Again taking `(x_2,y_2)` in place of `(x_1,y_1)` repeat the process
`f(x_2,y_2)=f(0.2,-0.85708)=0.45708`
`x_2+1/2 h=0.2+0.1/2 =0.25`
`y_2 + 1/2 hf(x_2,y_2)=-0.85708+0.1/2 * 0.45708=-0.83422`
`f(x_2+1/2 h, y_2 + 1/2 hf(x_2,y_2)=f(0.25,-0.83422)=0.33422`
`y_3=y_2+hf(x_2+1/2 h, y_2 + 1/2 hf(x_2,y_2))=-0.85708+0.1*0.33422=-0.82365`
Again taking `(x_3,y_3)` in place of `(x_2,y_2)` repeat the process
`f(x_3,y_3)=f(0.3,-0.82365)=0.22365`
`x_3+1/2 h=0.3+0.1/2 =0.35`
`y_3 + 1/2 hf(x_3,y_3)=-0.82365+0.1/2 * 0.22365=-0.81247`
`f(x_3+1/2 h, y_3 + 1/2 hf(x_3,y_3)=f(0.35,-0.81247)=0.11247`
`y_4=y_3+hf(x_3+1/2 h, y_3 + 1/2 hf(x_3,y_3))=-0.82365+0.1*0.11247=-0.81241`
Again taking `(x_4,y_4)` in place of `(x_3,y_3)` repeat the process
`f(x_4,y_4)=f(0.4,-0.81241)=0.01241`
`x_4+1/2 h=0.4+0.1/2 =0.45`
`y_4 + 1/2 hf(x_4,y_4)=-0.81241+0.1/2 * 0.01241=-0.81179`
`f(x_4+1/2 h, y_4 + 1/2 hf(x_4,y_4)=f(0.45,-0.81179)=-0.08821`
`y_5=y_4+hf(x_4+1/2 h, y_4 + 1/2 hf(x_4,y_4))=-0.81241+0.1*-0.08821=-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
|