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:
- A function handle (the function for which the fixed point is to
be found);
- An initial guess; and
- A bound on the estimated relative error (as defined in lecture).
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.
-
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?
-
Repeat for a tank with radius 3 meters and desired volume of
20 m3?
-
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:
- Create a folder titled Last_First_HW4 (replacing "Last" and "First"
with your actual names) on the Desktop.
- Move the files you are supposed to turn in into that folder.
Nothing else should be in the folder.
- Create a zip file containing the folder and its contents.
(The main
course web page has instructions for creating
a zip archive.)
Important: Verify that the contents of the zip
archive are correct. It should contain the directory (folder) and the
three files, and nothing else. (Do this by double-clicking the zip
file.)
- Upload the zip archive via the portal, as
Important: save the folder and its contents to a
flash drive or elsewhere, for
two reasons: (i) in case something goes wrong with your submission;
and (ii) we will sometimes build on your solutions in later
problems.
- Very Important: save the number the submission
system gives after you upload your submission. It is
the only acceptable proof that you uploaded your file.