CS 221 Fall 2011 Problem Set 4

CS 221 Fall 2011 Problem Set 3

Out: Tuesday, November 8
Due: 23:59:59 Wednesday, November 16

Problem 1: Implementing the Fixed-Point Root-Finding Method

Implement a function fixpoint() that takes three arguments: The function returns a single value, x, such that |f(x)-x|/f(x) is less than the given bound.

Your function should include checks to detect when it is diverging (Hint: conditions for convergence are given in the slides from lecture; the computation is diverging if successive estimates are getting further apart.)

Save the function in a file "fixpoint.m", and include it in the zip archive you turn in.


Problem 2: Solving Problems

Solve the following problems using (i) the root-finding methods of MATLAB (you may use whichever method applies); (ii) the fixpoint() function you implemented above; and (iii) Excel. For each method, show the value of the root calculated with that method, and the value of the function evaluated at that point. When you have a choice, use an error bound of 10-4.

  1. You are designing a water tank for a village in Africa. The tank is spherical, with a radius R meters. The volume of water it holds when filled to height h is given by:

    V = πh2(3R-h)/3

    If the radius of the tank is 4 meters, to what height must it be filled to hold 30 m3 of water?

  2. Repeat for a tank with radius 3 meters and desired volume of 20 m3?

  3. When calculating the payment on a mortgage, the relationship between the principal P (i.e., the loan amount), the monthly payment m, the term n of the loan in months, and the annual interest rate r, is given by the annuity equation:
                 P r
     m =     -----------
           12(1 - 1/(1+r/12)^n)
    
    What duration (n) is required for $200,000 loan at 3.7% (use 0.037 as the parameter value) to get a monthly payment of $1200?


Submission Instructions

To submit your solutions, follow these steps: