CS3911 Introduction to Numerical Methods with Fortran Final Exam - PDF

Document Sample
CS3911 Introduction to Numerical Methods with Fortran Final Exam - PDF Powered By Docstoc
					CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007   1

   CS3911 Introduction to Numerical Methods with Fortran
                         Final Exam
                          Fall 2007
                                  200 points { 9 pages


                      Name:



  • Write to the point. If I don't understand what you are
    saying, I believe, in most cases, you don't understand the
    subject.
  • Justify your answer with a convincing argument. If there
    is no justification when it is needed, you will receive ZERO
    point for that question even though you have provided a
    correct answer. I consider a good and correct justification
    more important than a right answer. Thus, if you provide
    a very vague answer without a convincing argument to
    show your answer being correct, you will likely receive a
    very low grade.
  • For computation-based problems, always show the com-
    putation steps. Only providing an answer receives ZERO
    point unless the problem only requires an answer.
  • Your calculations should have at least 5 significant digits.
  • Do those problems you know how to do first. Otherwise,
    you may not be able to complete this exam on time. None
    of the following problems require extensive calculations.
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                       2

  1. Accuracy and Reliability:

      (a) [15 points] Euler proved the following result centuries ago:
                                                        n
                                                    1
                                        lim    1+           = e = 2.71828 . . .
                                        n→∞         n
          A programmer wrote a program to verify this result using single precision (i.e., about 7 signif-
          icant digits) and a Fortran 90 statement E = (1.0 + 1.0/n)**n in a DO loop, where n is an
          INTEGER and E is a REAL, and obtained the following table with n = 10, 100, . . ., 10000000
          and 100000000.

                                    n         Computed (1 + 1/n)n        Absolute Error
                                      10          2.593743               0.12453866
                                     100          2.7048113              0.013470411
                                    1000          2.7170507              1.2309551E-3
                                   10000          2.718597               3.1518936E-4
                                  100000          2.7219622              3.6804676E-3
                                 1000000          2.5952267              0.12305498
                                10000000          3.2939677              0.575686
                               100000000          1.0                    1.7182817


          The problem is that the computed value (1 + 1/n)n is about 2.718597 when n = 10000;
          however, accuracy of further results gets worse if n > 10000, and eventually the computed
          result becomes 1, which is obviously incorrect. This programmer is sure that his/her program
          logic is correct. So, what is the numerical problem (or problems) in this computation?
          You should not make any correction to the Fortran 90 statement. What you have to
          do is to point out the numerical problem (or problems) with a clear and to-the-point
          explanation. Vague answers such as \because of cancelation" and meaningless answers
          such as \should use double precision" will receive zero point.
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                 3

  2. Linear Algebra:

      (a) [15 points] Matrix A and its LU-decomposition L and U are shown below:
                                                                             
                                     1 2                        1 0         1 2
                                                                             
                            A=               A=L·U =               ·         
                                     2 7                        2 1         0 3

          Find A−1 using the given LU-decomposition. Show all calculation steps clearly. Otherwise,
          you will receive zero point.




      (b) [15 points] Use Jacobi method to find all eigenvalues and their corresponding eigenvectors
          of the following symmetric matrix A. You should clearly provide all computation details,
          and clearly match each eigenvalue with its corresponding eigenvector. Otherwise, you
          will risk low grade. Additionally, you will receive zero point if you do not use Jacobi
          method.                                            
                                                     1 0 1
                                                             
                                              A= 0 3 0 
                                                     1 0 1
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                       4

  3. Interpolation: Suppose there are five data points (x0, y0 ) = (−2, 0), (x1, y1) = (−1, 3), (x2, y2) =
     (0, 4), (x3 , y3) = (1, 3) and (x4, y4 ) = (2, 0). Do the following problems:

      (a) [10 points] Given a polynomial of degree n as follows,

                                 Pn (x) = a0 + a1 x + a2x2 + a3x3 + · · · + an xn

          suggest an efficient way to evaluate Pn (x) so that the complexity is O(n). You should provide
          an algorithm and its complexity analysis. A method that does not achieve O(n) receives
          zero point.




      (b) [15 points] Find the Lagrange interpolating polynomial for the given data points. You should
          show all computation steps. Only providing an answer and/or using a wrong method
          receives zero point.
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                  5

      (c) [15 points] Find the Newton interpolating polynomial for the given data points using the
          divided difference method. You should show all computation steps. Only providing an
          answer and/or using a wrong method receives zero point.




  4. Numerical Differentiation:

      (a) [15 points] Use the 3-point backward difference method to compute the derivative of f (x) =
          ex sin(x) at x = 1 with ∆ = 0.01. You should show all computation steps. Only providing
          an answer and/or using a wrong method receives zero point.
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                 6

      (b) [20 points] Use Richardson's extrapolation method to compute the derivative of f (x) =
          ex sin(x) at x = 1 with initial ∆ = 0.1. You should carry out the extrapolation steps un-
          til the computation for ∆ = 0.025 completes, and clearly indicate the desired answer. You
          should show all computation steps. Only providing an answer and/or using a wrong
          method receives zero point.




  5. Numerical Integration: The following integral has an exact solution:
                                     1
                                         ex dx = e1 − e0 = e − 1 = 1.71828 . . .
                                 0

      (a) [20 points] Use Romberg's method to compute the above integration and use the trapezoid
          method for column 0. You should carry out all steps until the computation for ∆ = 0.25
          completes, and clearly indicate the desired answer. You should show all computation steps.
          Only providing an answer and/or using a wrong method receives zero point.
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                     7

      (b) [20 points] Use the iterative 3-point Simpson method to compute the above integration. You
          should start with ∆ = 0.5, update the result in each iteration, and stop after the result of
          ∆ = 0.125 is obtained. You should show all computation steps. Only providing an an-
          swer and/or using a wrong method receives zero point.




  6. ODE Initial Value Problems: Solve y = xy with initial value y(0) = 1.

      (a) [10 points] Use Euler's method to solve the given equation on [0, 4] with ∆ = 1, and fill your
          results in the following table.


                            Iteration     x                        y

                          Initial Value   0                        1

                               1          1

                               2          2

                               3          3

                               4          4
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007                                      8

      (b) [15 points] Solve the given equation on [0, 4] using Ralston's second-order Runge-Kutta method
          with ∆ = 1, and fill your results in the following table.


                            Iteration     x                       y

                          Initial Value   0                       1

                               1          1

                               2          2

                               3          3




  7. Random Numbers:

      (a) [15 points] Suppose a random vertical cut followed by a random horizontal cut are applied to
          a square of edge length 1. This yields four smaller rectangles as shown below. What is the
          probability of the area of the largest rectangle being larger than or equal to 0.7?




          The following shows a sequence of pre-generated random numbers. Each number has five
          digits, and a decimal point is assumed to appear to the left of the first digit. For example,
          random number 53479 should be interpreted as 0.53479. Therefore, all random numbers are
          in the range of [0,1). Use Monte Carlo method with 10 runs to find an approximation of this
          probability. You should show all computation steps. Only providing an answer and/or
          using a wrong method receives zero point.

            x1 to x8      53479     81115     98036     12217     59526     40238    40577     39351
            x9 to x16     43211     69255     97344     70328     58116     91964    26240     44643
            x17 to x24    83287     97391     92823     77578     66023     38277    74523     71118
CS3911 Intro. to Numerical Methods with Fortran Final { Fall 2007   9

                                    Grade Report



             Problem Possible You Received
            1 a         15
               a        15
            2
               b        15
               a        10
            3 b         15
               c        15
               a        15
            4
               b        20
               a        20
            5
               b        20
               a        10
            6
               b        15
            7 a         15
             Total     200
             Some Important and Complex Formulas


The following has some important and complex formulas discussed in class. They are provided for
your convenience. If you have anything in doubt, use the version discussed in class or ask questions.
                                                                                  
                                                n               n
                                                     ai                (x − xj )
                                             i=0           j=0,j=i



                                              1
                                                (3fi − 4fi−1 + fi−2 )
                                             2∆

                                                                                               
                                            n                                    i−1
                                f [x0 ] +           f [x0 , x1, . . . , xi]           (x − xj )
                                            i=1                               j=0



                                                  f0 + fn n−1
                                                ∆        +     fi
                                                     2     i=1



                                        2(n − i) + 1
                           xi = cos                  π                     where i = 0, 1, . . ., n
                                          2n + 2

                                             1
                                               (−fi+2 + 4fi+1 − 3fi )
                                            2∆

                                                               di,j − di−1,j
                                                    di,j +
                                                                 4j+1 − 1

                                                     m             m
                                  ∆
                                    (f0 + f2m ) + 4     f2i−1 + 2     f2i
                                  3                 i=1           i=1


                   n
                           (x − x0 )(x − x1 ) · · · (x − xi−1 )(x − xi+1 ) · · · (x − xn )
                                                                                             yi
                   i=0
                         (xi − x0)(xi − x1 ) · · · (xi − xi−1 )(xi − xi+1 ) · · · (xi − xn )


                                                                                           1
                                      c1 = 0           c2 = 1             p2 = a2,1 =
                                                                                           2

                                                           1
                                        c1 = c2 =                       p2 = a2,1 = 1
                                                           2

                                            1                   2                           3
                                    c1 =               c2 =               p2 = a2,1 =
                                            3                   3                           4



                                                                    1