Solutions of Problems about Numerical Methods

1.

(a) y0 = 2 , y1 = 2 + 1 (1-4) = -1

(b) y0 = 2 , y1 = 1/2 , y2 = 9/8

(c) y0 = 2 , y1 = 2 + 1(-3+1)/2 = 1

2.

(a) y0 = -1/4 , y1 = -3/4 , y2 = -5/4, y3 = 1/4

(b) Partial derivative is 2 which is positive, hence problem is unstable and we have to expect exponentially growing errors for a numerical method.

(c) linear ODE, y(t) = -t2/2 - t/2 - 1/4. Errors yj - y(j) for j=0,1,2,3: 0, 1/2, 2, 13/2. Exact solution goes to -infinity for t going to infinity. Euler values go to +infinity.

3.

Vectors should be written as column vectors, but for technical reasons I will write them as row vectors here.

(a) y1' = y2 , y2' = 1 - y1 , y1(0) = 2 , y2(0) = -1.

(b) at t=1: approximation for ( y1 , y2) is (2,-1) + 1(-1,1-2) = (1,-2)

(c) at t=1: approximation for ( y1 , y2) is (2,-1) + 1[(-1,-1)+(-2,0)]/2 = (1/2,-3/2)

(d) exact value is 1 - sin(1) + cos(1) = 0.6988
Euler error is 0.3012, Improved Euler error is 0.1988.
For the Euler method we expect that doubling the number of steps will roughly give one half of the error. So we would expect errors of 0.3012/2, 0.3012/4 for h=1/2, h=1/4.
For the Improved Euler method we expect that doubling the number of steps will roughly give one quarter of the error. So we would expect errors of 0.1988/4, 0.1988/16 for h=1/2, h=1/4.

4.

Let y1=y, y2=y'. Then we obtain the first order system
y1 = y2
y2' = t - y1y2
with initial conditions y1(2)=3, y2(2)=-4.

(a): s=(-4,14), y(1)=(1,3). Hence y(2.5) is approximatively equal to 1.

(b): s(1)=(-4,14), s(2)=(3,-.5), y(1)=(2.75,-0.625). Hence y(2.5) is approximatively equal to 2.75.

(c): Matlab code:

f = @(t,y) [y(2); t-y(1)*y(2)];
[ts,ys] = ode45(f,[2,8],[3;-4]);
ys(end,1)
plot(ts,ys(:,1))