Oldexam Ws0910 Solution

  • Upload
    hisuin

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

  • 7/29/2019 Oldexam Ws0910 Solution

    1/8

    Technische Universitat Munchen WT 2009/10Institut fur InformatikProf. Dr. H.-J. BungartzDipl.-Tech. Math. S. Schraufstetter February 5, 2010

    Numerical Programming I (for CSE)Final Exam

    Proposal for solution

    exercise 1 2 3 4 5 points 7 7 14 10 5 43

    http://www.google.de/

  • 7/29/2019 Oldexam Ws0910 Solution

    2/8

    Numerical Programming I (for CSE) Final Exam, page 2 of 8

    1) Multiple Choice ( 4 + 3 = 7 points)a) Part I

    Which statements about numerical algorithms are true?

    The absolute distance between two neighboring floating point numbers is not constant.

    The condition describes the sensitivity of a problem, concerning changes in the inputdata.

    An algorithm that is applied to a well-conditioned problem is always stable.

    The phenomenon of cancellation occurs, if two numbers with different sign and identicalleading digits are added.

    How many operations have to be done in general when solving a triangular linear system ofequations?

    O(n),

    O(n log n),

    O(n2),O(n3).

    When solving a system of linear equations Ax = b with the help of LU-factorization, pivotingshould be used in order to . . .

    avoid division by zero,get a faster algorithm,

    reduce rounding errors and, thus, get a higher accuracy,improve the condition of the problem solve Ax=b.

    What has commonly much influence on the behavior of convergence of the method of Gau-Seidel?

    the spectral radius of the iteration matrix,the greatest absolute eigenvalue of the system matrix,

    the right-hand side of the system,

    the resolution of the grid (if the linear system results from a partial differential equation).

  • 7/29/2019 Oldexam Ws0910 Solution

    3/8

    Numerical Programming I (for CSE) Final Exam, page 3 of 8

    b) Part II

    Considering non-linear equations. Which methods are only locally convergent?

    bisection method,

    regula falsi (false position method),

    secant method, Newtons method.

    Which of the following statements are true, when solving an ordinary differential equation(ODE) numerically?

    To specify a solution of an ODE y(t) = f(t, y(t)) uniquely, initial values are needed.It holds: convergence + consistency stability.

    It holds: stability + consistency convergence.The Runge-Kutta method always leads to smaller errors than the method of Euler.

    If the local discretization error of a method for solving ordinary differential equations convergesagainst 0 for increasingly smaller steps in time, then the method always is . . .

    convergent,

    consistent,stable,

    well-conditioned.

    Choose the best method in case of a stiff problem!an explicit one-step method of high order, e.g. Runge-Kutta,

    the mid-point rule,

    an implicit method, e.g. implicit Eulers method,an explicit multistep method, e.g. Adams-Bashforth method.

  • 7/29/2019 Oldexam Ws0910 Solution

    4/8

    Numerical Programming I (for CSE) Final Exam, page 4 of 8

    2) Floating Point Numbers and Rounding ( 2 + 2 + 3 = 7 points)a)

    cond(f, x) =

    x f(x)f(x)

    =

    x 2(1+2x)2

    1

    1+2x 1

    =

    2x(1+2x)2

    2x

    1+2x

    =

    1

    1 + 2x

    < 1 x > 0

    small condition number well-conditionedb) The last operation 1 is a subtraction of two positive numbers ( 11+2x is positive for x > 0!).

    Subtraction is ill-conditioned and may cause cancellation for x 0.Better algorithm: eliminate subtraction by reformulation of the expression

    f(x) =1

    1 + 2x 1 = 2x

    1 + 2x

    function y = smartMethod(x)y = (-2*x)/(1+2*x);

    return;

    c)

    rd(g(x, y)) = (x2(1 + 1) y2(1 + 2))(1 + 3)= x2(1 + 1 + 3) y2(1 + 2 + 3)= g(x, y) + x2(1 + 3) y2(2 + 3)

    with i

    j=0 and|i

    | M:

    e =

    g(x, y) rd(g(x, y))g(x, y) =

    x2(1 + 3) y2(2 + 3)

    x2 y2

    2M (|x2| + |y2|)

    |x2 y2| = 2M

    11 yx2

    +1

    xy

    2 1

    for x = y

    not stable for x y

  • 7/29/2019 Oldexam Ws0910 Solution

    5/8

    Numerical Programming I (for CSE) Final Exam, page 5 of 8

    3) Interpolation ( 4 + 4 + 3 + 3 = 14 points)a) in a triangular scheme:

    xi i

    5 0 y0 = 1 0 14

    3 1 y1 = 1 34

    2 2 y2 = 14calculations:

    [x0]f = f(x0) = f(5) = 1[x1]f = f(x1) = f(3) = 1[x2]f = f(x2) = f(2) = 1

    4

    [x0, x1]f =[x1]f [x0]f

    x1 x0=

    1 13 (5)

    = 0

    [x1, x2]f =[x2]f [x1]f

    x2 x1 =1

    4 1

    2 (3) = 3

    4

    [x0, x1, x2]f =[x1, x2]f [x0, x1]f

    x2 x0 =3

    4 0

    2 (5) = 1

    4

    p(x) = 1 + 0 (x + 5) 14

    (x + 5)(x + 3)

    = 14

    x2 2x 114

    b) For a [2, 2], we have

    |f(x) q(x)| =D

    4f()

    4! (x + 2)(x + 1)(x 1)(x 2)

    =

    (2)(3)(4)(5)4! (+ 4)6 (x + 2)(x + 1)(x 1)(x 2)

    =

    5 (x2 4)(x2 1)(+ 4)6

    For , x

    [

    2, 2], it holds:

    |x2

    4

    | 4,

    |x2

    1

    | 3,

    |+ 4

    | 2. Thus, we get

    |f(x) q(x)| = 5 |x2 4| |x2 1||+ 4|6

    5 4 326

    =15

    16 x [2, 2].

  • 7/29/2019 Oldexam Ws0910 Solution

    6/8

    Numerical Programming I (for CSE) Final Exam, page 6 of 8

    c)

    function yp = eval newton(c,x,xp)

    n=length(c);

    yp=c(n);for i=n-1:-1:1

    yp = yp*(xp-x(i)) + c(i);

    end

    d) triangular scheme:

    x1 =15 1 0 -2 -6

    x2 =

    2

    52

    4

    10

    x3 =

    35 1 -2

    x4 =

    45 2

  • 7/29/2019 Oldexam Ws0910 Solution

    7/8

    Numerical Programming I (for CSE) Final Exam, page 7 of 8

    4) Numerical Quadrature ( 2 + 3 + 1 + 4 = 10 points)a) Simpson sum is exact for polynomials of degree 2. So the result will be the exact result

    11

    3x2 1 dx = [x3 x]11 = 0

    Or, alternatively:

    11

    3x2 1 dx 1(1)

    4

    3

    f(1) + 4 f(12

    ) + 2 f(0) + 4 f( 12

    ) + f(1)

    =1

    6

    2 + 4 14

    + 2 (1) + 4 14

    + 2

    = 0

    b) n = 16, H = b a = 1 (1) = 2, h = ban

    = 216 =18

    |I(f) QTS(f)| = h2 H f(2)()

    12 =

    1

    82 2 1

    8

    e2

    12 =

    1

    64 1

    48 e

    2

    164

    148

    e1

    2 =1

    64

    e

    48

    c) max. degree: 2n 1 = 2 3 1 = 5d)

    I(x0) = 2!

    = 2g0 + g1 = Q(x0) g1 = 2(1 g0)

    I(x2i+1) = 0!

    = 0 = Q(x2i+1) always fulfilledI(x2i) = 2

    2i + 1!= 2g0x

    2i0 = Q(x

    2i)

    I(x2) =2

    3!

    = 2g0x20 = Q(x

    2)

    I(x4) =2

    5!

    = 2g0x40 = Q(x

    4)

    I(x4) x20 I(x2) =2

    3 2

    5x20

    != 0= Q(x4) x20 Q(x2) x0 =

    3

    5

    x0 in I(x2) :

    2

    3!

    = 2g03

    5 g0 = 5

    9

    g0 in

    g1 :

    g1 = 2

    1

    5

    9

    =

    8

    9

    The degree of accuracy is maximal since the formula is exact for all polynomials of odd degreedue to its structure and, thus, it is exact for p P5.

  • 7/29/2019 Oldexam Ws0910 Solution

    8/8

    Numerical Programming I (for CSE) Final Exam, page 8 of 8

    5) Solving Linear Systems of Equations ( 2 + 3 = 5 points)a) The matrices L and U are stored in the matrix A (A is overwritten). The result is

    A =

    u11 u12 . . . u1nl21 u22 u2n

    ... . . . . . . ...ln1 . . . ln,n1 unn

    b)

    L1 =

    1 0 01

    2 1 012 0 1

    , A1 =

    4 2 30 1 12

    0 1 12

    L = L2 =

    1 0 012 1 012 1 1

    , U = A2 =

    4 2 30 1

    12

    0 0 1