(new-plot) (message " 1. Use Newton's method to generate an approximation to the zeros of the function f(x) = e^x - \frac{1}{x} Note: f(x)=0 is a transcendental equation: it's solution cannot be obtained analytically, only approximated. Numerical approximations are important! 1) Write down x_{n+1} = x_{n} - \frac{f(x_n)}{f^\prime(x_n)} for this particular case. 2) Generate at least 5 iterates (x_1 through x_6) using a calculator or computer. ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (func f(x) exp x - 1 / x) ;; trying for initial values students tried: (newton-root f 1 5) (newton-root f -1 5) (newton-root f 3 5) (newton-root f .6 5) (newton-root f .568 5) (newton-root f 2 5) (domain .1 1) (newton f 2) (new-plot) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 2. Try to solve the following using Newton's method, and report what happens: f(x) = x^2 + 1, \hspace{1in} x_0 = 1 ln(x) = 0, \hspace{1in} x_0 = 4 ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (func f(x) x ^ 2 + 1) (newton-root f 1 5) (newton f 1 5) (func f(x) ln x) (newton-root f 4 5) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 3. The first failure in problem 2 is a quirk, but the second we can fix. Try solving for the root of ln(x) by considering the even function ln(|x|) instead. Generate 5 iterates. This trick won't work when x_0 = 10, however. Can you discover a range of initial values for which Newton will work with this function? ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (func f(x) ln (abs x)) (newton-root f 4 5) (newton-root f 6 5) (newton-root f 10 5) ;; When the iterates are exactly opposite each other, i.e. bouncing between x ;; and -x, we're done: That is, we must solve -x = x - f(x)/f'(x): (func bounce(x) (2 * x - (ln (abs x)) / (1 / x))) (domain 3 12) (newton-root bounce 4) (newton bounce 4) (new-plot) ;; (this can also be found analytically, to be e^2!) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 4. As noted in class, some roots can't be found using Newton's method when the derivative of the function of interest is infinite at the root (e.g. f(x)=\sqrt{x}): one possible solution in such a case is to use bisection. Another idea is to relax Newton's method: consider x_{n+1} = x_{n} - m\frac{f(x_n)}{f^\prime(x_n)} It turns out that for 0 < m < 1 this method will converge to the true solution of \sqrt{x}=0. Write down the equation for Newton's iterates for the case of f(x)=\sqrt{x} , and simplify. Generate 5 iterates with this iteration scheme for m=.25, m=.5, and m=.75. The iterates' behavior depends on the size of m: what is the difference for the two cases m < .5 and m > .5? For what values of m will ``relaxed Newton'' give the roots of f(x)=x^{\frac{1}{3}}? Can you explain the geometrical significance of the {\it{m-factor}}? ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (func f(x) sqrt x) (newton-root f 1 10 1e-6 .25) ;;(newton-root f 1 10 1e-6 .5) ; gives the zero then crashes, as f'(0)=infinity. (newton-root f 1 10 1e-6 .75) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 5. Yesterday we considered the ``smokestack'' problem, which gave rise to the function S(x) = k_2(\frac{7}{x^2}+\frac{1}{(20-x)^2}) Calculate the derivative, S^\prime, and plot it. Use Newton's method to approximate the root of S^\prime in [0,20], using a good initial approximation. Can you bound your approximation? That is, can you find a small interval such that the root must be inside? (This is related to the problem of finding a root to a given accuracy, e.g. 2 decimal places.) ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (title "smokestack function") (func s(x) 7 / x ^ 2 + 1 / (20 - x) ^ 2) (plot s 3 19) (diff s x sp) (newton-root sp 10) (sp 13.133) (sp 13.135) ;; These are of opposite sign, so the root is between, i.e. is 13.13something. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 6. A method related to Newton's method is the secant method, obtained by approximating the derivative f^\prime(x_n) in \ref{nm} by the discrete approximation using the two previous guesses: i.e., f^\prime(x_n) \approx \frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}} Rewrite Newton's method using this approximation to get the secant method. Notice that \u{two} initial guesses must be given to start the secant method: the two points are joined by a line (the secant line) and the root of that linear function is used as the next approximation. Draw a picture illustrating the idea behind the secant method. (Note: the secant method is particularly useful when a function is continuous but not differentiable, as is true of many real functions. An example is the motion of a particle in your favorite beverage: it makes random (but continuous) movements, called Brownian motion.) ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message " 7. Another method, called Muller's method, relies on parabolas, rather than secant lines: it thus requires \u{three} initial approximations, which are used to find the unique parabola passing through them. One root of this quadratic equation is then used as a next approximation. If you ever take the time to understand this method, you will say to yourself ``This is a really fantastic method!'' Draw the graph of f(x)=(x - 1)^3 + 4 and draw a parabola (as closely as you can!) through the points associated with x values of 1, 0 and -1. Try to write down the quadratic function that passes through the three points: if you succeed, what is your next approximation to the root using Muller's method? (The root of f is approximately -0.5874.) ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (func f(x) (x - 1) ^ 3 + 4) (func g(x) -2 * (x - 1) * x + 2 * (x + 1) * x + -3 * (x - 1) * (x + 1)) (plot f g -1 2) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;