Cs 201 Final 2010 Solution

Embed Size (px)

Citation preview

  • 8/10/2019 Cs 201 Final 2010 Solution

    1/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 ofthe following matrix. The first two columns are orthogonal.

    2 1 02 0 32

    1 1

    =

    13

    1 013

    0 313

    1 1

    2

    3 0 00 1 00 0 1

    =

    13

    12

    013

    0 313

    12

    1

    2

    3 0 0

    0

    2 00 0 1

    =

    13

    12 1

    613

    0 26

    13 1

    2 1

    6

    2

    3 0 43

    0

    2 12

    0 0 56

    =

    0.5774 0.7071 0.40820.5774 0.0000 0.8165

    0.5774 0.7071 0.4082

    3.4641 0 2.30940 1.4142 0.707

    0 0 2.0412

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

    03

    1

    13

    13

    13

    03

    1

    131313

    12

    0 12

    03

    1

    12

    0

    12

    =

    03

    1

    4

    3

    11

    1

    +1

    2

    10

    1

    =5

    6

    2

    2) (30 points) Numeric Integration

    We wish to devise an integration method for the interval [1, 1] that samples the functionf(x) which we wish to evaluate at the points x0 = 12 , x1 = 0, x2= 12 .

    Our approximation will be

    1

    1

    f(x)dx

    A0f(x0) +A1f(x1) +A2f(x2) =A0f(

    1

    2

    ) +A1f(0) +A2f(1

    2

    )

    Use the method of undetermined coefficients to find values A0, A1, A2, so that the ap-proximation is exact for functions f(x) that are constant, linear, or quadratic.

    (a) Equations Provide the system of equations for{Ai}.

    A0+A1+A2 =

    1

    1dx= 2

    1

  • 8/10/2019 Cs 201 Final 2010 Solution

    2/4

    Solution to CSCI E-201 Numerical Analysis Final Name:

    A0x0+A1x1+A2x2 =

    1

    1xdx= 0

    A0x2

    0+A1x2

    1+A2x2

    2 =

    1

    1x2dx=

    2

    3

    (b) Solution Solve the system of equations and find{Ai}.We take the second and third equations, and see that

    (A0 A2) = 01

    4(A0+A2) =

    2

    3

    A0 = A2=4

    3

    A1= 2 2 43

    = 23

    (c) Degree of Precision What is the degree of precision of this method?This works up to cubics, as A0 and A2 will cancel.

    A0x3

    0+A1x3

    1+A2x3

    2=

    1

    1x3dx= 0

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

    1

    12=

    1

    16(A0+A2) =A0x

    4

    0+A1x4

    1+A2x4

    2=

    1

    1x4dx=

    2

    5

    (d) Interpolation Sketch (draw freehand) the three components of the Lagrange Inter-polating polynomials that can be used to determine the weights {Ai}. For example, the firstpolynomial 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 wemove x0 andx2 out, we will get a parabola with area of 0. I have uploaded an image of theareas to the Exam page.

    (e) Revising If we keep x0 =x2 but modify x2 and repeat this exercise, we can finda value ofx2 where the weight A1 changes sign. What is the value ofx2 when A1 = 0?

    If we want A1 = 0, thenA0 = A2= 1 andA0x2

    0= 1

    3 , so x0 = 13 .

    (f) Degree of Precision What is the degree of precision of the method using these newvalues ofx0 andx2 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??

  • 8/10/2019 Cs 201 Final 2010 Solution

    3/4

    Solution to CSCI E-201 Numerical Analysis Final Name:

    3) (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.

    01/2 1/2

    1 -1 21/6 4/6 1/6

    k1 = f(ti, wi)

    k2= f(ti+h

    2, wi+

    h

    2k1)

    k3= f(ti+h, wi+h(2k2 k1))

    wi+1= wi+1

    6(k1+ 4k2+k3)

    4) (35 points) Initial Value Problem

    Given the differential equation y = 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 thefollowing methods. Show your work.

    (e) Analytic Solution Find closed form solution to this problem.

    y

    (2 y) = 15 dy

    y 2=

    15 dt

    ln(y 2) = 15t+Ky 2 =Ce15t

    Whent= 0,y= 1, so C= 1y= 2 e15t

    Whent= 0.1, we havey(0.1) = 2 e1.5 = 1.777

    Note the natural solution y(t) = 2. Compare to a) below.

    3 of??

  • 8/10/2019 Cs 201 Final 2010 Solution

    4/4

    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 is0.1769

    (c) Trapezoid Method

    wi+1= wi+ h

    2(f(ti, wi) +f(ti+h, wi+f(ti, wi))) =wi+

    h

    2(f(0, 1) +f(0.1, 2.5))

    wi+1= 1 + h

    2(15 15

    2) = 1 +h 15

    4 = 1.375

    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 f(ti, wi) f(1) 15

    k2 f(ti+ h

    2 , wi+ h

    2k1) f(1.75) 3.75k3 f(ti+

    h

    2, wi+

    h

    2k2) f(1.1875) 12.18750

    k4 f(ti+h, wi+hk3) f(2.218750) -3.28125w1 w0+

    h

    6(k1+k2+k3+k4) 1 + (43.59375)/60 1.7265625

    Error is 1.7265 1.7768 = 0.0503

    4 of??