Roots of Equations.pdf

14
Roots of Equa+ons P2 Chapter 6, Numerical Methods for Engineers

description

Computational method

Transcript of Roots of Equations.pdf

Page 1: Roots of Equations.pdf

Roots  of  Equa+ons  P2    

Chapter  6,  Numerical  Methods  for  Engineers  

Page 2: Roots of Equations.pdf

2  

•  Open methods are based on formulas that require –  only a single starting value or –  two starting values that do not necessarily bracket the root.

Open  Methods  Overview  1/2  

Page 3: Roots of Equations.pdf

3  

•  ✗ May diverge or move away from true root •  ✔ Converge much more quickly than bracketing

methods •  Topics

•  Newton-Raphson •  Secant •  Multiple Roots

Open  Methods  Overview  2/2  

Page 4: Roots of Equations.pdf

Open  Method:  Newton-­‐Raphson  1/4  •  Background  – Recall  that  the  equaGon  of  a  straight  line  is  given  by    •  y  =  mx  +  c        [EquaGon  NR1]  

– Where  m  is  the  gradient  –  This  means  that  all  points  (x,y)  on  the  line  saGsfy  the  equaGon  

– The  differenGal  is  expressed  as    • Which  can  be  re-­‐arranged  as  

• Which  gives  

– Hence,    

4  

f '(x)= dydx

=y− yox − xo

= m

x = xo +y− yof '(x)

x = xo +f (xo )f '(x)

xn+1 = xn +f (xn )f '(xn )

-­‐  

xn+1 = xn −f (xn )f '(xn )

f '(x)= ΔyΔx

⇒Δx = Δyf '(x)

x0 − x1 =f (x0 )−0f '(x)

x1 = x0 −f (x0 )f '(x)

Page 5: Roots of Equations.pdf

Open  Method:  Newton-­‐Raphson  2/4  

5  

Same example Find a root of the equation x6 – x – 1 = 0 accurate to εa = 0.001. Suggested Solution – Microsoft Excel Guess xo = 1.5

Other examples to try: (a) ex – 3x = 0; (b) x3 + 2x2 – 3x – 1 = 0

true  root  is  =  1.134724138  

Iteration)# x f(x) f'(x) εa0 1.5 8.891 44.561 1.30049 2.537 21.32 0.153412 1.18148 0.538 12.81 0.100733 1.13946 0.049 10.52 0.036884 1.13478 6E-04 10.29 0.004125 1.13472 7E-08 10.29 0.00005

Page 6: Roots of Equations.pdf

Open  Method:  Newton-­‐Raphson  3/4  

6  

Same example Find a root of the equation x6 – x – 1 = 0 accurate to εa = 0.001. Suggested Solution - Matlab Guess xo = 1.5

Page 7: Roots of Equations.pdf

7  

•  Most widely used method. •  Advantages –  Error decreases rapidly with each iteration –  Very fast compared for example with Bisection method

•  Disadvantages –  May fail to converge for bad choices of xo. Hence choice

of xo is very important for method to work. –  Each iteration requires two function evaluations, while the

Bisection method requires only one. •  A good strategy for avoiding failure to converge is to

use the Bisection method for a few steps, then switch to Newton-Raphson for fast convergence

Open  Method:  Newton-­‐Raphson  4/4  

Page 8: Roots of Equations.pdf

Open  Method:  Secant  1/3  •  Same  idea  as  NR,  but  the  tangent  line  is  replaced  by  a  secant  line.  

•  A slight variation of NR for functions whose derivatives are difficult to evaluate.  – EquaGon  of  the  secant  line  is  given  as  

 – Hence,  the  iteraGon  becomes  

8  

xn+1 = xn − f (xn )xn − xn−1

f (xn )− f (xn−1)

y = f (x1)+ (x − x1)f (x1)− f (x0 )x1 − x0

Page 9: Roots of Equations.pdf

Open  Method:  Secant  2/3  

9  

Same example Find a root of the equation x6 – x – 1 = 0 accurate to εa = 0.001. Suggested Solution via Excel Guess xo = 1, x1 = 2

Other examples to try: (a) ex – 3x = 0; (b) x3 + 2x2 – 3x – 1 = 0

true  root  is  =  1.134724138  

Iteration)# x f(x) εa0 1.00000 $11 2.00000 61 0.500002 1.01613 $0.92 0.968253 1.03067 $0.83 0.014114 1.17569 0.465 0.123345 1.12368 $0.11 0.046296 1.13367 $0.01 0.008817 1.13475 3E$04 0.000958 1.13472 $0 0.00003

Page 10: Roots of Equations.pdf

10  

•  Advantages –  Error decreases slowly at first but then rapidly after a few

iterations –  Each iteration requires only one function evaluation, while

the NR method requires two. –  Does not require differentiation

•  Disadvantages –  Slower than NR but faster than Bisection –  Requires two initial estimates

Open  Method:  Secant  3/3  

Page 11: Roots of Equations.pdf

11  

•  “Multiple root” corresponds to a point where a function is tangent to the x axis.

•  Difficulties – Function does not change sign at

the multiple root, therefore we cannot use bracketing methods.

– Both f(x) and f′(x) may = 0 ! cannot use NR and Secant because division by zero.

– NR and Secant converges slowly for multiple roots

Multiple Roots 1/4

Page 12: Roots of Equations.pdf

12  

Multiple Roots 2/4 •  None of the methods deal with multiple roots

efficiently, however, one way to deal with problems is as follows:

Set u(xi ) =f (xi )!f (xi )

This  funcGon  has  roots  at  all  the  same  locaGons  as  the  original  funcGon  

Alternative form of NR: xn+1 = xn −u(xn )u '(xn )

Differentiate u(x) :u '(x)= f '(x) f '(x)− f (x) f "(x)f '(x)[ ]2

Hence the iteration becomes:

xn+1 = xn −f (xn ) f '(xn )

f '(xn )[ ]2− f (xn ) f ''(xn )

Page 13: Roots of Equations.pdf

13  

Multiple Roots 3/4 •  Example: x3 - 5x2 + 7x – 3 = 0

§  Plotting in Matlab reveals multiple roots § >>x= 0:0.1:4; § >>y=x.^3-5*x.^2+7*x-3; § >>plot(x,y)

Page 14: Roots of Equations.pdf

14  

Multiple Roots 4/4 •  Example: x3 - 5x2 + 7x – 3 = 0

§  f’(x) = 3x2 - 10x + 7; f’’(x) = 6x – 10 Iteration)# x f(x) f'(x) f''(x) εa εt

0 4 9 15 14 0.333331 2.63636 *0.97 1.488 5.818 *0.51724 *0.121212 2.82022 *0.6 2.659 6.921 0.06519 *0.059933 2.96173 *0.15 3.698 7.77 0.04778 *0.012764 2.99848 *0.01 3.988 7.991 0.01226 *0.000515 3.00000 *0 4 8 0.00051 0.00000

Iteration)# x f(x) f'(x) f''(x) εa εt0 0 "3 7 "10 "1.000001 1.10526 "0.02 "0.39 "3.37 1.00000 0.105262 1.00308 "0 "0.01 "3.98 "0.10187 0.003083 1.00000 "0 "0 "4 "0.00308 0.000004 1.00000 0 "0 "4 0.00000 0.00000

Other examples § x3 – 7x2 + 16x – 12 = 0 has roots of 2, 2, 3 § x4 – 7x3 + 9x2 + 81x – 108 = 0 has roots of 3, 3, 3, -2