Lab 6

Write a code

It requires F(x) to be differentiable with computable derivative DF(x).

The user should provide:

Newton converges fast typically, so maxIT=20 usually suffices.

For convenience, you may set

print out the iterates:

and, upon convergence, print out the value of the root, the residual (%e format), and how many iterations it took.

1. Debug the code on a simple problem with known solution, e.g.

2. Use your Newton code to find all three roots of the cubic:

Try various x0, like: 2, 1, 0.5, 0.1, 0.0, −0.5, −1, etc.

Do you notice anything unexpected/interesting? what?

3. Also try some big x0: 100, 1000, −100, etc

Do you notice anything unexpected/interesting? what?

4. Try some other maxIT and TOL.

5. Answer the questions:

6. Now find the real root of "Newton's cubic":

(comment out previous formulas in FCN and insert new one).

This is the only equation Newton ever bothered to solve with his method, in 1671 !

1. Name, Date, Lab6

2. Answers to the questions in B.5 (each labeled and separated by %------------------------%)

3. What are the roots of "Newton's cubic" ? in how many iterations, with what x0 for each ?

4. Insert your Newton.m code, and your FCN.

Using a PLAIN TEXT editor, edit the file

Then submit it on Canvas.