Secant Method Nonlinear Equations

Download Report

Transcript Secant Method Nonlinear Equations

Secant Method
Computer Engineering Majors
Authors: Autar Kaw, Jai Paul
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
7/20/2015
http://numericalmethods.eng.usf.edu
1
Secant Method
http://numericalmethods.eng.usf.edu
Secant Method – Derivation
Newton’s Method
f(x)
x f x 
f(xi)
i,
xi 1 = xi -
i
f(xi )
f (xi )
(1)
Approximate the derivative
f ( xi ) 
f(xi-1)

xi+2
xi+1
xi
X
Figure 1 Geometrical illustration of
the Newton-Raphson method.
3
f ( xi )  f ( xi 1 )
xi  xi 1
(2)
Substituting Equation (2)
into Equation (1) gives the
Secant method
xi 1
f ( xi )(xi  xi 1 )
 xi 
f ( xi )  f ( xi 1 )
http://numericalmethods.eng.usf.edu
Secant Method – Derivation
The secant method can also be derived from geometry:
f(x)
f(xi)
The Geometric Similar Triangles
AB DC

AE DE
B
can be written as
f ( xi )
f ( xi 1 )

xi  xi 1 xi 1  xi 1
C
f(xi-1)
xi+1
E D
xi-1
A
xi
X
Figure 2 Geometrical representation of
the Secant method.
4
On rearranging, the secant
method is given as
xi 1
f ( xi )(xi  xi 1 )
 xi 
f ( xi )  f ( xi 1 )
http://numericalmethods.eng.usf.edu
Algorithm for Secant Method
5
http://numericalmethods.eng.usf.edu
Step 1
Calculate the next estimate of the root from two initial guesses
xi 1
f ( xi )(xi  xi 1 )
 xi 
f ( xi )  f ( xi 1 )
Find the absolute relative approximate error
xi 1- xi
a =
 10 0
xi 1
6
http://numericalmethods.eng.usf.edu
Step 2
Find if the absolute relative approximate error is greater
than the prespecified relative error tolerance.
If so, go back to step 1, else stop the algorithm.
Also check if the number of iterations has exceeded the
maximum number of iterations.
7
http://numericalmethods.eng.usf.edu
Example 1
To find the inverse of a number ‘a’, one can use the
equation
1
f ( x)  a   0
x
where x is the inverse of ‘a’.
Use the Secant method of finding roots of equations to
 Find the inverse of a = 2.5. Conduct three iterations
to estimate the root of the above equation.
 Find the absolute relative approximate error at the
end of each iteration, and
 The number of significant digits at least correct at the
end of each iteration.
8
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Solution
1.5

1
 a  ( xi  xi 1 )
xi 
xi 1  xi  

1 
1 
 a     a 

x
x
i  
i 1 

2
0
0

1
 a   xi  xi 1 
xi 
 xi  
1
1

xi 1 xi
2
f ( x)
4
6
 7.5
8
0
0.25
0.1
0.5
0.75
x
f(x)
9
Figure 3 Graph of the function f(x).
1
f x   a   0
x
1
1

1
 a   xi  xi 1 
xi 
 xi  
xi  xi 1 
xi xi 1

1
 xi  xi xi 1  a  
xi 

 xi  xi 1 axi  1
http://numericalmethods.eng.usf.edu
Example 1 Cont.
7.5
Initial guesses:
20
x1  0.1and x0  0.6
0
0
f ( x)
Iteration 1
The estimate of the root is
20
x1  x0  x1 ax0  1
f ( x)
f ( x)
x1  0.6  0.12.50.6  1
40
secant( x)
f ( x)
60
 0.55
80
 97.5
100
0
0.25
0.5
0.75
x x 0  x 1' x x 1
0
f(x)
x'1 , (fi rst gu ess)
x0 , (p rev io us gu ess)
Secant li ne
x1 , (n ew g uess)
Figure 4 Graph of the estimated root
after Iteration 1.
10
1
1
The absolute relative approximate
error is
x x
a  1 0 100
x1
 9.0909%
The number of significant digits
at least correct is 0.
http://numericalmethods.eng.usf.edu
Example 1 Cont.
2.045
20
Iteration 2
The estimate of the root is
0
0
f ( x)
x0  0.6, x1  0.55
x2  x1  x0 ax1  1
20
f ( x)
f ( x)
x2  0.55  0.62.50.55  1
40
secant( x)
f ( x)
 0.325
60
80
 97.5
100
0
0.25
0.5
0.75
x x 1  x 0  x x 2
0
f(x)
x1 (g uess)
x0 (p rev io u s gu ess)
Secant li n e
x2 (n ew g u ess)
Figure 5 Graph of the estimated root
after Iteration 2.
11
1
1
The absolute relative approximate
error is
x x
a  2 1 100
x2
 69.231%
The number of significant digits
at least correct is 0.
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Entered functi on al ong gi ven interval wi th current and next root and the
tangent l ine of the curve at the curr ent root
3.199
Iteration 3
The estimate of the root is
20
0
0
x1  0.55, x2  0.325
f ( x)
x3  x2  x1 ax2  1
20
f ( x)
f ( x)
x3  0.325 0.552.50.325  1
40
secant( x)
f ( x)
 0.42813
60
80
 97.5
100
0
0.25
0.5
0.75
x x 2  x 1  x x 3
0
f(x)
x2 (g uess)
x1 (p rev io u s gu ess)
Secant li ne
x3 (n ew g u ess)
Figure 6 Graph of the estimated root
after Iteration 3.
12
1
1
The absolute relative approximate
error is
x x
a  3 2 100
x2
 24.088%
The number of significant digits
at least correct is 0.
http://numericalmethods.eng.usf.edu
Advantages


13
Converges fast, if it converges
Requires two guesses that do not need to
bracket the root
http://numericalmethods.eng.usf.edu
Drawbacks
2
2
1
f ( x)
f ( x)
0
0
f ( x)
1
2
2
10
5
 10
0
5
x x guess 1 x guess 2
f(x)
p rev . gu ess
n ew g uess
10
10
f x   Sinx   0
Division by zero
14
http://numericalmethods.eng.usf.edu
Drawbacks (continued)
2
2
1
f ( x)
f ( x)
0
f ( x)
0
secant( x)
f ( x)
1
2
2
10
5
 10
0
5
10
x x 0  x 1' x x 1
f(x)
x'1 , (fi rst gu ess)
x0 , (p rev io us gu ess)
Secant li ne
x1 , (n ew g uess)
10
f x   Sinx  0
Root Jumping
15
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/secant_me
thod.html
THE END
http://numericalmethods.eng.usf.edu