4 Applications of the Derivative

4.4 Newton’s Method

Solving equations is one of the most important things we do in mathematics, yet we are surprisingly limited in what we can solve analytically. For instance, equations as simple as x5+x+1=0 or cosx=x cannot be solved by algebraic methods in terms of familiar functions. Fortunately, there are methods that can give us approximate solutions to equations like these. These methods can usually give an approximation correct to as many decimal places as we like. In Section 1.6 we learned about the Bisection Method. This section focuses on another technique (which generally works faster), called Newton’s Method.

margin:

-1

-0.5

0.5

1

x0

x1

x

y
(a)

-1

-0.5

0.5

1

x0

x1

x2

x

y
(b)

-1

-0.5

0.5

1

x0

x1

x2

x3

x

y
(c)
Figure 4.4.1: Demonstrating the geometric concept behind Newton’s Method.

Newton’s Method is built around tangent lines. The main idea is that if x is sufficiently close to a root of f(x), then the tangent line to the graph at (x,f(x)) will cross the x-axis at a point closer to the root than x.

We start Newton’s Method with an initial guess about roughly where the root is. Call this x0. (See Figure 4.4.1(a).) Draw the tangent line to the graph at (x0,f(x0)) and see where it meets the x-axis. Call this point x1. Then repeat the process — draw the tangent line to the graph at (x1,f(x1)) and see where it meets the x-axis. (See Figure 4.4.1(b).) Call this point x2. Repeat the process again to get x3, x4, etc. This sequence of points will often converge rather quickly to a root of f.

We can use this geometric process to create an algebraic process. Let’s look at how we found x1. We started with the tangent line to the graph at (x0,f(x0)). The slope of this tangent line is f(x0) and the equation of the line is

y=f(x0)(x-x0)+f(x0).

This line crosses the x-axis when y=0, and the x-value where it crosses is what we called x1. So let y=0 and replace x with x1, giving the equation:

0=f(x0)(x1-x0)+f(x0).

Now solve for x1:

x1=x0-f(x0)f(x0).

Since we repeat the same geometric process to find x2 from x1, we have

x2=x1-f(x1)f(x1).

In general, given an approximation xn, we can find the next approximation, xn+1 as follows:

xn+1=xn-f(xn)f(xn).

We summarize this process as follows.

Key Idea 4.4.1      Newton’s Method

Let f be a differentiable function on an interval I with a root in I. To approximate the value of the root, accurate to d decimal places:

  1. 1.

    Choose a value x0 as an initial approximation of the root. (This is often done by looking at a graph of f.)

  2. 2.

    Create successive approximations iteratively; given an approximation xn, compute the next approximation xn+1 as

    xn+1=xn-f(xn)f(xn).
  3. 3.

    Stop the iterations when successive approximations do not differ in the first d places after the decimal point.

margin: Note: Newton’s Method is not infallible. The sequence of approximate values may not converge, or it may converge so slowly that one is “tricked” into thinking a certain approximation is better than it actually is. These issues will be discussed at the end of the section.

Let’s practice Newton’s Method with a concrete example.

Example 4.4.1 Using Newton’s Method

Approximate the real root of x3-x2-1=0, accurate to the first 3 places after the decimal, using Newton’s Method and an initial approximation of x0=1.

SolutionTo begin, we compute f(x)=3x2-2x. Then we apply the Newton’s Method algorithm, outlined in Key Idea 4.4.1.

x1 =1-f(1)f(1)=1-13-12-1312-21=2,
x2 =2-f(2)f(2)=2-23-22-1322-22=1.625,
x3 =1.625-f(1.625)f(1.625)=1.625-1.6253-1.6252-131.6252-21.6251.48579,
x4 =1.48579-f(1.48579)f(1.48579)1.46596,
x5 =1.46596-f(1.46596)f(1.46596)1.46557

We performed 5 iterations of Newton’s Method to find a root accurate to the first 3 places after the decimal; our final approximation is 1.465. The exact value of the root, to six decimal places, is 1.465571; It turns out that our x5 is accurate to more than just 3 decimal places.

margin:

0.5

1

1.5

-1.5

-1

-0.5

0.5

x

y
Figure 4.4.2: A graph of f(x)=x3-x2-1 in Example 4.4.1.

A graph of f(x) is given in Figure 4.4.2. We can see from the graph that our initial approximation of x0=1 was not particularly accurate; a closer guess would have been x0=1.5. Our choice was based on ease of initial calculation, and shows that Newton’s Method can be robust enough that we do not have to make a very accurate initial approximation.

We can automate this process on a calculator that has an Ans key that returns the result of the previous calculation. Start by pressing 1 and then Enter. (We have just entered our initial guess, x0=1.) Now compute

𝙰𝚗𝚜-f(𝙰𝚗𝚜)f(𝙰𝚗𝚜)

by entering the following and repeatedly press the Enter key:

Ans-(Ans^3-Ans^2-1)/(3*Ans^2-2*Ans)

Each time we press the Enter key, we are finding the successive approximations, x1, x2, …, and each one is getting closer to the root. In fact, once we get past around x7 or so, the approximations don’t appear to be changing. They actually are changing, but the change is far enough to the right of the decimal point that it doesn’t show up on the calculator’s display. When this happens, we can be pretty confident that we have found an accurate approximation.

We can use a similar approach in most spreadsheet programs, which intelligently copy formulas. Start by entering 1 in cell A1. Then in cell A2, enter:

A1-(A1^3-A1^2-1)/(3*A1^2-2*A1)

Copy this cell, and paste it into A3. The spreadsheet will automatically change A1 to A2, giving you the next approximation. Continue pasting this into A4, A5, and so on. Each time we paste the formula, we are finding the successive approximations, and each one is getting closer to the root.

Using a calculator in this manner makes the calculations simple; many iterations can be computed very quickly.

Example 4.4.2 Using Newton’s Method to find where functions intersect

Use Newton’s Method to approximate a solution to cosx=x, accurate to 5 places after the decimal.

SolutionNewton’s Method provides a method of solving f(x)=0; it is not (directly) a method for solving equations like f(x)=g(x). However, this is not a problem; we can rewrite the latter equation as f(x)-g(x)=0 and then use Newton’s Method.

So we rewrite cosx=x as cosx-x=0. Written this way, we are finding a root of f(x)=cosx-x. We compute f(x)=-sinx-1. Next we need a starting value, x0. Consider Figure 4.4.3, where f(x)=cosx-x is graphed. It seems that x0=0.75 is pretty close to the root, so we will use that as our x0. (The figure also shows the graphs of y=cosx and y=x, drawn with dashed lines. Note how they intersect at the same x value as when f(x)=0.)

margin:

-1

-0.5

0.5

1

-1

-0.5

0.5

1

x

y
Figure 4.4.3: A graph of f(x)=cosx-x used to find an initial approximation of its root.

We now compute x1, x2, etc. The formula for x1 is

x1=0.75-cos(0.75)-0.75-sin(0.75)-10.7391111388.

Apply Newton’s Method again to find x2:

x2=0.7391111388-cos(0.7391111388)-0.7391111388-sin(0.7391111388)-10.7390851334.

We can continue this way, but it is really best to automate this process. On a calculator with an Ans key, we would start by pressing 0.75, then Enter, inputting our initial approximation. We then enter:

Ans - (cos(Ans)-Ans)/(-sin(Ans)-1).

(In a spreadsheet, we would enter A1-(cos(A1)-A1)/(-sin(A1)-1) in A2.)

Repeatedly pressing the Enter key gives successive approximations. We quickly find:

x3 =0.7390851332
x4 =0.7390851332.

Our approximations x2 and x3 did not differ for at least the first 5 places after the decimal, so we could have stopped. However, using our calculator in the manner described is easy, so finding x4 was not hard. It is interesting to see how we found an approximation, accurate to as many decimal places as our calculator displays, in just 4 iterations.

If you know how to program, you can translate the following pseudocode into your favorite language to perform the computation in this problem.

x = .75
while true
    oldx = x
    x = x - (cos(x)-x)/(-sin(x)-1)
    print x
    if abs(x-oldx) < .0000000001
        break
margin:

-0.5

0.5

1

1.5

-1.5

-1

-0.5

0.5

x

y
Figure 4.4.4: A graph of f(x)=x3-x2-1, showing why an initial approximation of x0=0 with Newton’s Method fails.

This code calculates x1, x2, etc., storing each result in the variable x. The previous approximation is stored in the variable oldx. We continue looping until the difference between two successive approximations, abs(x-oldx), is less than some small tolerance, in this case, .0000000001.

Convergence of Newton’s Method

What should one use for the initial guess, x0? Generally, the closer to the actual root the initial guess is, the better. However, some initial guesses should be avoided. For instance, consider Example 4.4.1 where we sought the root to f(x)=x3-x2-1. Choosing x0=0 would have been a particularly poor choice. Consider Figure 4.4.4, where f(x) is graphed along with its tangent line at x=0. Since f(0)=0, the tangent line is horizontal and does not intersect the x-axis. Graphically, we see that Newton’s Method fails.

We can also see analytically that it fails. Since

x1=0-f(0)f(0)

and f(0)=0, we see that x1 is not well defined.

This problem can also occur if, for instance, it turns out that f(x5)=0. Adjusting the initial approximation x0 by a very small amount will likely fix the problem.

It is also possible for Newton’s Method to not converge while each successive approximation is well defined. Consider f(x)=x1/3, as shown in Figure 4.4.5. It is clear that the root is x=0, but let’s approximate this with x0=0.1. Figure 4.4.5(a) shows graphically the calculation of x1; notice how it is farther from the root than x0. Figures 4.4.5(b) and (c) show the calculation of x2 and x3, which are even farther away; our successive approximations are getting worse. (It turns out that in this particular example, each successive approximation is twice as far from the true answer as the previous approximation.)

margin:

-1

1

-1

1

x0

x

y
(a)

-1

1

-1

1

x0

x1

x

y
(b)

-1

1

-1

1

x0

x1

x2

x3

x

y
(c)
Figure 4.4.5: Newton’s Method fails to find a root of f(x)=x1/3, regardless of the choice of x0.

There is no “fix” to this problem; Newton’s Method simply will not work and another method must be used.

While Newton’s Method does not always work, it does work “most of the time,” and it is generally very fast. Once the approximations get close to the root, Newton’s Method can as much as double the number of correct decimal places with each successive approximation. A course in Numerical Analysis will introduce the reader to more iterative root finding methods, as well as give greater detail about the strengths and weaknesses of Newton’s Method.

We first learned of the derivative in the context of instantaneous rates of change and slopes of tangent lines. We furthered our understanding of the power of the derivative by studying how it relates to the graph of a function (leading to ideas of increasing/decreasing and concavity). This chapter has put the derivative to yet more uses:

  • Related Rates (furthering our use of the derivative to find instantaneous rates of change)

  • Optimization (applied extreme values), and

  • Differentials (useful for various approximations and for something called integration).

  • Equation solving (Newton’s Method)

In the next chapters, we will consider the “reverse” problem to computing the derivative: given a function f, can we find a function whose derivative is f ? Being able to do so opens up an incredible world of mathematics and applications.

Exercises 4.4

 

Terms and Concepts

  1. 1.

    T/F: Given a function f(x), Newton’s Method produces an exact solution to f(x)=0.

  2. 2.

    T/F: In order to get a solution to f(x)=0 accurate to d places after the decimal, at least d+1 iterations of Newton’s Method must be used.

Problems

In Exercises 3–8, the roots of f(x) are known or are easily found. Use 5 iterations of Newton’s Method with the given initial approximation to approximate the root. Compare it to the known value of the root.

  1. 3.

    f(x)=cosx, x0=1.5

  2. 4.

    f(x)=sinx, x0=1

  3. 5.

    f(x)=x2+x-2, x0=0

  4. 6.

    f(x)=x2-2, x0=1.5

  5. 7.

    f(x)=lnx, x0=2

  6. 8.

    f(x)=x3-x2+x-1, x0=1

In Exercises 9–12, use Newton’s Method to approximate all roots of the given functions accurate to 3 places after the decimal. If an interval is given, find only the roots that lie in that interval. Use technology to obtain good initial approximations.

  1. 9.

    f(x)=x3+5x2-x-1

  2. 10.

    f(x)=x4+2x3-7x2-x+5

  3. 11.

    f(x)=x17-2x13-10x8+10 on (-2,2)

  4. 12.

    f(x)=x2cosx+(x-1)sinx on (-3,3)

In Exercises 13–16, use Newton’s Method to approximate when the given functions are equal, accurate to 3 places after the decimal. Use technology to obtain good initial approximations.

  1. 13.

    f(x)=x2, g(x)=cosx

  2. 14.

    f(x)=x2-1, g(x)=sinx

  3. 15.

    f(x)=ex2, g(x)=cosx+1

  4. 16.

    f(x)=x, g(x)=tanx on [-6,6]

  5. 17.

    Why does Newton’s Method fail in finding a root of f(x)=x3-3x2+x+3 when x0=1?

  6. 18.

    Why does Newton’s Method fail in finding a root of f(x)=-17x4+130x3-301x2+156x+156 when x0=1?

In Exercises 19–22, use Newton’s Method to approximate the given value.

  1. 19.

    16.5.

  2. 20.

    24.

  3. 21.

    633.

  4. 22.

    8.53.

  5. 23.
    Show graphically what happens when Newton’s Method is used at different x0 for the function shown. (a) x0=0 (b) x0=1 (c) x0=3 (d) x0=4 (e) x0=5

    -2

    2

    4

    6

    -2

    -1

    1

    2

    x

    y
Modern Campus CMS