Problem 3 25 pts Solve the following differential equation u
Solution
Given, x0 = 0 and y0 = 1
and let f(x,y) = slope = y\' = yx2 - y
For Step Size (h) of 0.5
f0 = f(0,1) = 1 (0)2 - 1 = -1
y1 = y0 + h * f0 = 1 + 0.5 (-1) = 0.5
and x1 = x0 + h = 0.5
Now f1 = f(0.5, 0.5) = 0.5 (0.5)2 - 0.5 = -0.375
y2 = y1 + h * f1 = 0.5 + 0.5 (-0.375) = 0.3125
and x2 = x1 + h = 1
Thus for x2 = 1, y2 = 0.3125
Also, from given analytical solution, y(1) = e(1/3 - 1) = 0.513417119
Absolute error = |0.513417119 - 0.3125| = 0.200917119
For Step Size (h) of 0.25
f0 = f(0,1) = 1 (0)2 - 1 = -1
y1 = y0 + h * f0 = 1 + 0.25 (-1) = 0.75
and x1 = x0 + h = 0.25
Now f1 = f(0.25, 0.75) = 0.75 (0.25)2 - 0.75 = -0.70313
y2 = y1 + h * f1 = 0.75 + 0.25 (-0.70313) = 0.574219
and x2 = x1 + h = 0.5
Now f2 = f(0.5, 0.574219) = -0.43066
y3 = y2 + h * f2 = 0.574219 + 0.25 (-0.43066) = 0.466553
and x3 = x2 + h = 0.75
Now f3 = f(0.75, 0.466553) = -0.20412
y4 = y3 + h * f3 = 0.466553 + 0.25 (-0.20412) = 0.415524
and x4 = x3 + h = 1
Thus for x2 = 1, y2 = 0.415524
Also, from given analytical solution, y(1) = e(1/3 - 1) = 0.513417119
Absolute error = |0.513417119 - 0.415524| = 0.09789358998

