oldexam_ws0910

  • Upload
    hisuin

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

  • 7/29/2019 oldexam_ws0910

    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

    Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Matr.Nr.: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Program: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    General Instructions

    Material: You may only use one hand-written sheet of paper (size A4, on both pages). All othermaterial including electronic devices of any kind are forbidden.

    Exercise 1 (multiple choice) has to be solved directly on this sheet. For all the other exercises,use the exam paper that was handed out to write down your solution. It is recommendable tostart a new page for every problem.

    Do not use a pencil, or red or green ink.

    General hint: In most cases, exercises b), c), etc. can be solved without the results from the previousexercise a): if you are stuck with exercise a), then dont immediately skip exercises b), c), etc.

    Show the solution steps in your answers and give reasons for your statements or conclusions(except the multiple choice part).

    Maximum score: The maximum score is 40 points plus a bonus of 3 points. Grades will be computedrelatively to a maximum score of 40 points.

    Working time: 105 minutes.

    http://www.google.de/

    exercise 1 2 3 4 5

    points 7 7 14 10 5 43

    http://www.google.de/

  • 7/29/2019 oldexam_ws0910

    2/8

    1) Multiple Choice ( 4 + 3 = 7 points)

    Which statements are correct?

    Remarks:

    For every question, there is at least one answer true.

    Mark true statements clearly with a cross (). If you wish to change your answer, cancel thewrong cross carefully ( ) so that your final answer is in evidence.

    For every correct cross, you will get 0.5 points. For every wrong cross, 0.5 points will bediscounted. If there isnt any cross, you will get 0 points.

    In a subtask, it is not possible to get negative points in total, i.e. if you have negative pointsin total in exercise a), this subtask will be rated with 0 points.

    Only mark a statement as true, if you are really sure!

    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 of

    equations?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).

    page 2 of 8

  • 7/29/2019 oldexam_ws0910

    3/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 convergestowards 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 higher 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.

    page 3 of 8

  • 7/29/2019 oldexam_ws0910

    4/8

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

    Let f : R R be a mapping. The condition number for the evaluation f(x) is given by

    cond(f, x) :=

    x f(x)

    f(x)

    .

    a) Is the problem evaluate f at a point x > 0 for the function

    f(x) =1

    1 + 2x 1. (1)

    well- or ill-conditioned? Why?

    b) Function (1) is evaluated with the following Matlab program:

    function y = stupidMethod(x)

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

    return;

    Why is the evaluation of stupidMethod not stable for all x > 0?Design another Matlab program smartMethod(x) that evaluates function (1), too, but is stablefor all x > 0!

    c) Consider the functiong(x, y) = x2 y2

    that is evaluated with the following Matlab program:

    function z = g(x,y)

    z = x*x - y*y;return;

    Compute the relative rounding error

    e :=

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

    that occurs when evaluating g.

    For which values (x, y) R2 is the evaluation algorithm not stable? Why?

    page 4 of 8

  • 7/29/2019 oldexam_ws0910

    5/8

    3) Interpolation ( 4 + 4 + 3 + 3 = 14 points)

    Consider the function f : R R that is defined by

    f(x) = (x + 4)2.

    a) Let p(x) be the polynomial interpolant of f with support points P0 = (x0, y0), P1 = (x1, y1),and P2 = (x2, y2) and support abscissas

    x0 = 5, x1 = 3, x2 = 2.

    Give an explicit representation of the interpolant p(x) by using divided differences and New-tons interpolation formula

    p(x) = [x0]f + [x0, x1]f (x x0) + . . . + [x0, . . . , xn]f n1k=0

    (x xk). (2)

    b) Now, let q(x) be the polynomial interpolant of f with support abscissas

    x0 = 2, x1 = 1, x2 = 1, x3 = 2.

    Proove the estimation

    |f(x) q(x)| 15

    16 x [2, 2].

    Hint: Use a known formula for the interpolation error to show that

    [2, 2] : |f(x) q(x)| =5 |x2 4| |x2 1|

    |+ 4|6

    holds, and find estimations for the factors |x2 4|, |x2 1|, and |+ 4|.

    c) Formulate a Matlab program

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

    that evaluates Newtons interpolation formula (2) with O(n) operations. The inputs of thefunction eval newton(c,x,xp) are denoted by

    c: a vector c = (c0, . . . , cn) with the divided differences ci = [x0, . . . , xi]f,

    x: a vector x = (x0, . . . , xn) with the support abscissas xi,

    xp: a scalar x that defines the point of evaluation of p.

    The function returns the value yp that is a scalar y with the result of the evaluation y = p(x).

    page 5 of 8

  • 7/29/2019 oldexam_ws0910

    6/8

    3) Interpolation (continued)

    d) Now, the scheme of Aitken and Neville is applied to the support points

    (x1, y1) = (1

    5, 1), (x2, y2) = (

    2

    5, 2), (x3, y3) = (

    3

    5, 1), (x4, y4) = (

    4

    5, 2).

    as illustrated in Fig. 1. What values do you get in the triangular scheme when evaluating thepolynomials at x = 0? Sketch the triangular scheme shown below on your sheet and insert thecorrect values.

    You do not have to compute all the values with the formula, but you may use the plot ofFig. 1 which illustrates the four support points and the interpolants with support abscissas

    {x1, x2, x3}, {x2, x3, x4}, and {x1, x2, x3, x4}, respectively. All values of the triangular schemeare contained in Z.

    x1 =1

    5? ? ? ?

    x2 =

    2

    5? ? ?

    x3 =3

    5? ?

    x4 =4

    5?

    Figure 1: Polynomial interpolation

    page 6 of 8

  • 7/29/2019 oldexam_ws0910

    7/8

    4) Numerical Quadrature ( 2 + 3 + 1 + 4 = 10 points)

    Consider the integral of a function f : [1, 1] R

    I(f) :=

    1

    1

    f(x) dx. (3)

    a) Which result do you get, when approximating integral (3) with the Simpson sum with n = 4subintervals for f(x) = 3x2 1 ?

    b) Estimate the error |I(f) QTS(f)| when approximating integral (3) with the trapezoidal sumQTS(f) with 16 subintervals when f is given by f(x) =

    1

    2ex

    2 .

    In general, when computing an integral numerically, the integral is approximated by a weighted sum

    I(f) n

    i=0

    gi f(xi) =: Q(f). (4)

    To find a good approximation formula (3), it should hold

    I(p) = Q(p) p Pk (5)

    for polynomials p with a degree k as large as possible.

    c) Which degree of accuracy (max. polynomial degree) kmax can be achieved at most in case ofn = 3 nodes, when the weights gi as well as the nodes xi can be chosen?

    d) Determine optimal weights and nodes g0, g1, and x0 so that the formula of quadrature

    Q(f) := g0f(x0) + g1f(0) + g0f(x0) (6)

    is exact for all polynomials up to a degree k that is as large as possible, i.e. Eq. (5) holds forp(x) = xj , j = 0, 1, 2, . . . , k.

    Is this degree of accuracy k equal to the maximal possible degree of accuracy kmax of thegeneral quadrature formula (4) for n = 3?

    page 7 of 8

  • 7/29/2019 oldexam_ws0910

    8/8

    5) Solving Linear Systems of Equations ( 2 + 3 = 5 points)

    Consider the following Matlab code:

    1 function A = lu factorization(A)2 n = size(A,1);3 for i=1:n

    4 for k=1:i-15 for j=1:k-16 A(i,k)=A(i,k)-A(i,j)*A(j,k);7 end8 A(i,k)=A(i,k)/A(k,k);9 end10 for k=i:n11 for j=1:i-112 A(i,k)=A(i,k)-A(i,j)*A(j,k);13 end14 end15 end16 end

    a) The given Matlab code computes the LU factorization of a matrix A in situ. What does insitu mean? What does the algorithm return as result in detail?

    b) Find the LU factorization of the matrix

    A =

    4 2 32 2 1

    2 2 2

    .

    page 8 of 8