A guide to Newton R lab

Purpose

The purpose with Newton lab is to illustrate Newtons metod, for solving equations of the form f(x) = 0, and finding out about some of its basic properties.

What you can do

1. Define the function f(x) in the equation under consideration, or select an example one from the popup menu.
2. View the solution(s) (intersection(s) of the curve y = f(x) and the x-axis y = 0) in the graph window.
3. Zoom in or out to get a better of more complete view if desired.
4. Give an x-value and get an evaluation of the corresponding f(x). If very lucky you find that f(x) = 0.
5. Use the idea of "linearization", that is, replacing y = f(x) by its tangent through (x,(f(x)), and solve for the x for which the tangent intersects the x-axis.
6. Reevaluate (the residual) f(x) with the new x-value.
7. Iterate the linearization - linear solve - residual check steps by repeatedly pressing the iterate button.
8. Automize this iteration process by giving a certain number of iterations in the "nits =" text edit box, or ask for iterations until a certain error tolerance has been reached by defining a desired tolerance in the "tol =" text edit box.

How to do it

1. To give a function f(x), simply type the desired f(x) formula in the "f(x) =" text edit box, followed by a return. Recall that the given f(x) formula should be a valid matlab expression, allowed to depend on the varaible x.
2. To pick an example f(x) function, use the popupmenu below the "f(x) =" text edit box.
3. To zoom, in or out, press the desired zoom button and then click at the desired center point in the new zoomed plot in the plot window.
4. To give an x-value and get the corresponding f(x)-value computed, simply type the x-value in the "x =" text edit box followed by a return.
5. To Newton step "manually", simply press in turn the linearize button, the solve button, and finally the residual button.
6. To automize the iteration, repeatedly press the "iterate" button, or give a desired number of iteration steps in the "nits =" text edit box, or give an acceptable error tolerance for when to stop the iteration process.

Problems

1. Estimate the convergence rate r of Newtons method, with r defined as | x_{i+1} - x | = c | x_i - x |^r, by considering for example f(x) = x-x.*x with root x = 0 and starting from x = .1. Note that with e_i = | x_i - x | and taking logarithms, log e_{i+1} = log c + r log e_i, that is, r = (log e_{i+2} - log e_{i+1})/(log e_{i+1} - log e_i), so that you can estimate r by considering two succesive Newton iterations.
2. Repeat this examination with f(x) = x^2. Is the convergence rate the same?
3. Apply Newtons method to f(x) = x./sqrt(ans(x)) starting at x = 1, say. Try also some starting point closer to x = 0.