Answers to Exam 1(b) Mon 7 Oct 2005

  1. Consider a floating-point number system with base 10. There are five digits in the fraction (mantissa) and the exponents range between -8 and +9.
    1. What is the smallest positive floating-point number in this number system?
          +.10000E-8 = 10^(-9)
      
    2. What is the result of 42.873 + 0.079872 in this number system?
          42.873 = +.42873E+2
          0.079872 = +.79872E-1 = +.00079872E+2 (denormalize)
      
          +.42873E+2
          +.00079872E+2
         ---------------
          +.42952872E+2 = +.42953E+2 = 42.953
      
                                                            +--------+
                                                            |    /20 |
                                                            +--------+
    
  2. Derive the formula for the secant method for one equation f(x) = 0.
    Illustrate the working of the secant method with a plot.
       The line through (x(k),f(x(k))) and (x(k+1),f(x(k+1))) has equation
    
                        f(x(k+1)) - f(x(k))
          y - f(x+1) = --------------------- ( x - x(k+1) ).
                           x(k+1) - x(k)
    
       To obtain x(k+2) we solve for y = 0:
    
                           x(k+1) - x(k)
          x - x(k+1) = --------------------- ( 0 - f(x(k+1) ).
                        f(x(k+1)) - f(x(k))
    
       Setting x = x(k+2) we obtain
    
                               x(k+1) - x(k)
         x(k+2) = x(k+1) - --------------------- f(x(k+1)).
                            f(x(k+1)) - f(x(k))
    
       For an illustration of the method, see the solution handout.
    
                                                            +--------+
                                                            |    /15 |
                                                            +--------+
    
  3. Below is the plot of g(x) = -0.3x^2 + 0.8 x + 2.5. Starting at x(0) = -3, illustrate on the plot below how to produce three more points defined by x(k+1) = g(x(k)), k=0,1,...

    click here to see the plot
    See the solution handout for the answer.

                                                            +--------+
                                                            |    /15 |
                                                            +--------+
    
  4. Consider f(x) = x^2 - 0.5 x - 0.24 over the interval [0,1].
    1. Starting with [0,1], apply two steps of the golden section search method, and indicate on the graph below where you do the function evaluations.
      In addition, mark the new intervals as [a1,b1], [a2,b2], and [a3,b3] on the x-axis.

      click here to see the graph
      See the solution handout for the answer.

    2. Write the values for x1, x2, f(x1), and f(x2) (4 decimal places, scientific notation):
      +-------+------------+------------+------------+------------+
      | step  |     x1     |     x2     |    f(x1)   |    f(x2)   |
      +-------+------------+------------+------------+------------+
      |   0   |  3.820E-1  |  6.180E-1  | -2.851E-1  | -1.671E-1  |
      |   1   |  2.361E-1  |  3.820E-1  | -3.023E-1  | -2.851E-1  |
      |   2   |  1.459E-1  |  2.361E-1  | -2.917E-1  | -3.023E-1  |
      +-------+------------+------------+------------+------------+
      
                                                            +--------+
                                                            |    /20 |
                                                            +--------+
    
  5. Consider
                 [  9.229E-02  -1.324E+00   1.976E+00  ]
             A = [ -6.501E-01   1.201E+00  -3.308E-01  ]. 
                 [  2.245E+00  -1.265E+00  -1.277E+00  ]
    
    1. Compute the LU decomposition of A with partial pivoting. Use 4 decimal places with rounding, and write all floating-point numbers in scientific format.
                [  2.245E+00  -1.265E+00  -1.277E+00  ] 3
        A ----> [ -6.501E-01   1.201E+00  -3.308E-01  ] 2
                [  9.229E-02  -1.324E+00   1.976E+00  ] 1
      
                  -.6501      [                                     ]
       R2 := R2 - ------ R1   [  2.245E+00  -1.265E+00  -1.277E+00  ] 3
                   2.245      [                                     ]
       ---------------------> [ -2.896E-01   8.347E-01  -7.006E-01  ] 2
                  0.09229     [                                     ]
       R3 := R3 - ------- R1  [  4.111E-02  -1.272E+00   2.028E+00  ] 1
                   2.245      [                                     ]
      
                              [  2.245E+00  -1.265E+00  -1.277E+00  ] 3
       ---------------------> [  4.111E-02  -1.272E+00   2.028E+00  ] 1
                              [ -2.896E-01   8.347E-01  -7.006E-01  ] 2
      
                   .8347      [                                     ]
       R3 := R3 - ------ R2   [  2.245E+00  -1.265E+00  -1.277E+00  ] 3
                  -1.272      [                                     ]
       ---------------------> [  4.111E-02  -1.272E+00   2.028E+00  ] 1
                              [                                     ]
                              [ -2.896E-01  -6.562E-01   6.302E-01  ] 2
                              [                                     ]
      
           [ 0 0 1 ]       [     1           0            0      ]
       P = [ 1 0 0 ]  L =  [  4.111E-02      1            0      ]
           [ 0 1 0 ]       [ -2.896E-01  -6.562E-01       1      ]
      
                           [  2.245E+00  -1.265E+00  -1.277E+00  ]
                      U =  [     0       -1.272E+00   2.028E+00  ]
                           [     0           0        6.302E-01  ]
      
    2. What is the determinant of A?
       det(A) = det(P*L*U)
              = det(P)*det(L)*det(U)
              = (+1)*(+1)*(2.245E+00)*(-1.272E+00)*(6.302E-01)
              = -1.800E+00
    
                                                            +--------+
                                                            |    /30 |
                                                            +--------+