You are on page 1of 4

Solution to CSCI E-201 Numerical Analysis Final

Name:
November 10, 2012
1)

(25 points) Gram-Schmidt

Use the Gram-Schmidt algorithm or Housholder Reflectors to derive a QR decomposition of


the following matrix. The first two columns are orthogonal.

1
1

1
1 0
0 2 3 0 0
2 1 0
2 3 0 0
3
3
2

1
1
2 0 3 =
0
3
2 0
0
3 0 3 0 1 0 = 3
1
1
1

2 1 1
0 0 1
0
0 1
1 1
2 1
3
3

1
13
3
1
3

1
2

0
12

4
2 3 0
0.5774
0.7071
0.4082
3.4641
0
2.3094
3

2 0
2 12 = 0.5774 0.0000
0.8165 0
1.4142 0.7071
6
1
5
0.5774 0.7071 0.4082
0
0
2.0412

6
0
0
6
16

The hard work is in reworking the last column. In slow motion:


1
1



0
1
1
1
0
h
i 0
i 0
h
3
2
4 1 5
1
1
1

3 1 1 1 3
0
1 +
0 =
2
= 3
3 2 0 2 3
3
3
3
3
2
6
1
1

1
1
1 2
1
1
1
1
3

2)

(30 points) Numeric Integration

We wish to devise an integration method for the interval [1, 1] that samples the function
f (x) which we wish to evaluate at the points x0 = 21 , x1 = 0, x2 = 12 .
Our approximation will be
Z

1
1
f (x)dx A0 f (x0 ) + A1 f (x1 ) + A2 f (x2 ) = A0 f ( ) + A1 f (0) + A2 f ( )
2
2
1

Use the method of undetermined coefficients to find values A0 , A1 , A2 , so that the approximation is exact for functions f (x) that are constant, linear, or quadratic.
(a) Equations Provide the system of equations for {Ai }.
Z 1
A0 + A1 + A2 =
dx = 2
1

Solution to CSCI E-201 Numerical Analysis Final

Name:
1

Z
A0 x0 + A1 x1 + A2 x2 =

xdx = 0
1

A0 x20

A1 x21

A2 x22

x2 dx =

=
1

2
3

(b) Solution Solve the system of equations and find {Ai }.


We take the second and third equations, and see that
(A0 A2 ) = 0
1
2
(A0 + A2 ) =
4
3
4
A0 = A2 =
3
4
2
A1 = 2 2 =
3
3
(c) Degree of Precision What is the degree of precision of this method?
This works up to cubics, as A0 and A2 will cancel.
Z 1
3
3
3
A0 x0 + A1 x1 + A2 x2 =
x3 dx = 0
1

However, it does not work for x4 , as we see below:


1
1
= (A0 + A2 ) = A0 x40 + A1 x41 + A2 x42 6=
12
16

x4 dx =

2
5

(d) Interpolation Sketch (draw freehand) the three components of the Lagrange Interpolating polynomials that can be used to determine the weights {Ai }. For example, the first
polynomial runs through the points {(1/2, 1), (0, 0), (1/2, 0)}.
The key insight is that A1 is parabola opening downward with a negative area. If we
move x0 and x2 out, we will get a parabola with area of 0. I have uploaded an image of the
areas to the Exam page.
(e) Revising If we keep x0 = x2 but modify x2 and repeat this exercise, we can find
a value of x2 where the weight A1 changes sign. What is the value of x2 when A1 = 0?
If we want A1 = 0, then A0 = A2 = 1 and A0 x20 = 13 , so x0 =

1 .
3

(f ) Degree of Precision What is the degree of precision of the method using these new
values of x0 and x2 that make A1 = 0? Is this a method we have seen before?
This is the two point Gaussian Integration we studied, which also has precision 3.

2 of ??

Solution to CSCI E-201 Numerical Analysis Final

3)

Name:

(10 points) Runga-Kutta

The Butcher tableau below describes a third-order Runga-Kutta method.


Write down MATLAB code or Pseudo Code that could be used to take h, f (t, y) and
(ti , wi ), and compute (ti+1 , wi+1 ) using the method described by the tableau.
0
1/2 1/2
-1
1
1/6

2
4/6

1/6
k1 = f (ti , wi )
h
h
k2 = f (ti + , wi + k1 )
2
2
k3 = f (ti + h, wi + h(2k2 k1 ))
1
wi+1 = wi + (k1 + 4k2 + k3 )
6

4)

(35 points) Initial Value Problem

Given the differential equation y 0 = 15(2 y), and initial condition y(0) = 1, or w0 = 1,
compute an estimate of (t, y) (0.1, w1 ) after one step with h = 0.1 using each of the
following methods. Show your work.
(e) Analytic Solution Find closed form solution to this problem.
y0
= 15
(2 y)
Z
Z
dy
= 15 dt
y2
ln(y 2) = 15t + K
y 2 = Ce15t
When t = 0, y = 1, so C = 1
y = 2 e15t
When t = 0.1, we have
y(0.1) = 2 e1.5 = 1.777
Note the natural solution y(t) = 2. Compare to a) below.

3 of ??

Solution to CSCI E-201 Numerical Analysis Final

Name:

(a) Euler method


wi+1 = 1 + hf (t, y) = 1 + 0.1 15(2 1) = 2.5 We have overshot the solution y(t) = 2.
Error is 2.5 1.777 = 0.7231
(b) Backwards Euler method
wi+1 = 1 + hf (t, wi+1 ) = 1 + 1.5(2 wi+1 ) = (1 + 3) 1.5wi+1 = 4 1.5wi+1
wi+1 =

4
2.5

8
5

= 1.6

Error is 0.1769
(c) Trapezoid Method
wi+1 = wi + h2 (f (ti , wi ) + f (ti + h, wi + f (ti , wi ))) = wi + h2 (f (0, 1) + f (0.1, 2.5))
) = 1 + h 15
= 1.375
wi+1 = 1 + h2 (15 15
2
4
Error = 1.375 1.777 = 0.4018
(d) Classic 4-th order Runge-Kutta
Enter your intermediate computations for the Runge-Kutta solution in the table below.
k1
k2
k3
k4
w1

f (ti , wi )
f (ti + h2 , wi + h2 k1 )
f (ti + h2 , wi + h2 k2 )
f (ti + h, wi + hk3 )
w0 + h6 (k1 + k2 + k3 + k4 )

f(1)
15
f(1.75)
3.75
f(1.1875)
12.18750
f(2.218750)
-3.28125
1 + (43.59375)/60 1.7265625

Error is 1.7265 1.7768 = 0.0503

4 of ??

You might also like