Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Homework #3 - Newton's Method with Mathematica

Exercise

Problem #24, Section 2.3, Page 76, Burden, Faires, and Burden (10th edition)

Use Mathematica and Newton's method to solve the following problem.

The accumulated value of a savings account based on regular periodic payments can be determined from the annuity due equation,

A = i(P) ( (1+i)n - 1).

(Caution: Do not use square brackets on the right side of this equation, as appears in the text, in your Mathe- matica code.)

In this equation,A is the amount in the account, P is the amount regularly deposited, and i is the rate of interest per period for the n deposit periods. An engineer would like to have a savings account valued  at $750,000 upon retirement in 20 years and can aford to put $1500 per month toward this goal. What is the minimal interest rate at which this amount can be invested, assuming that the interest is com-    pounded monthly?

Note: In the problem statement, i is the monthly interest rate. For example, if the annual interest rate is 8% (which is 0.08 in decimal form), then i =  = 0.6(-) % (which is 0.006(-) in decimal form). Similarly, note that n = 20*12, should also be specified in months.

Give your answer as an annual interest rate in percent form (not as the monthly interest rate and not in decimal form).

Mathematica work should include the problem statement (for example, include this page), some documentation, labeled graphics (label the graphic(s) and the axes), a clear presentation of your solution algorithm and solution, and verification of your solution using the built-in Mathematica com- mand(s) (here, use FindRoot)  . If you are familiar with the Module command, you can implement Newton's method using the Module command. Print all your iterates in a labeled table format. Include the iteration index (counter), the current iterate, and the diference between the two most recent iterates (in order to observe the quadratic rate of convergence). Print enough iterates so that you can  observe the quadratic rate of convergence that this assignment will demonstrate.

Some commands that may be useful in this assignment (and in general) are SetPrecision, Break[], TableHeadings. See Mathematica's Help for assistance and examples of the use of these commands.

Note: Mathematica's Help states:

"If you specify only one starting value ofx,FindRoot searches for a solution using Newton methods. If you specify two starting values,FindRoot uses a variant of the secant method."

Specific programming instructions for this assignment:

1. We shall work with many more significant digits than would realistically be used, in order to better  study the fast convergence of Newton's method. However, in stating the solution to the problem, we'll round to a reasonable number of significant digits.

2. Work the problem with i, the monthly interest rate, in decimal form. At the end of your computa-   tions, convert your answer from the monthly interest rate in decimal form to the annual interest rate in percent form (rounded up to 3 significant digits).

3. Due to the presence of the exponential function, the function whose root we seek is extremely sensitive to changes in the independent variable, i. This means that a small change in the value of i can correspond to a very large change in the value of the function.

4. Use the function f(i) = A -  ((1 + i)n - 1) for Newton’s method, work with the given data, and use the domain interval [0.00555076, 0.00555079] to graph f (in order to observe suitable initial guesses).

For the convenience of the homework grader, use the following initial guess. Take

p[0] = SetPrecision[5/1000, 40]. SetPrecision is needed here so that enough significant digits are used (refer to Mathematica's Help for information on SetPrecision).

5. For the Newton's method loop use the termination criterion:   p[n] - p[n - 1]    is the nth Newton iterate.

6. The problem solution is: "The minimum annual interest rate that sufices is 6.67% (rounded up)." Some additional comments and code, etc., that may be adapted/used, as needed, are given below.

Solution

a) Initialization and data

We are given the functionA = [(1 + i)n - 1] which we rewrite in a form to which Newton's method can be applied. Recall that Newton's method approximates zeros of functions. We want to solve, for example, A -  [(1 + i)n - 1] = 0, for the unknown quantity, i. Let f(i) denote the left-hand side of this expression:

Remove[ "Global`*"]

Let f represent the function whose zero we seek:

f [i_ ] = A -  * ((1 + i)n - 1)

( - 1 + (1 + i )n )  P

-

i

The data are specified as:

n = 20 * 12;  A = 750 000;  P = 1500;

f [i ]

1500  ( - 1 + (1 + i )240 ) 

750 000 -

i

The Newton's method iteration function g is:

f [i ] 

g [i_ ] = i -

1500 ( -1+(1+i )240 )

b) Determine the exact solution for comparison purposes (to check the Newton's method result)

The real zeros of f(i) can be approximated by the FindRoot command. Here the command searches for a root (zero) of f close to 0.005 (monthly interest rate in decimal form), which corresponds to an annual interest rate (in percent form) of 6.7%:

Continue with creating Mathematica code....