Secant Method Industrial Engineering Majors Authors: Autar Kaw, Jai Paul

Download Report

Transcript Secant Method Industrial Engineering Majors Authors: Autar Kaw, Jai Paul

Secant Method
Industrial Engineering Majors
Authors: Autar Kaw, Jai Paul
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
5/20/2016
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,
f(xi )
xi 1 = xi f (xi )
(1)
i
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 =
 100
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
You are working for a start-up computer
assembly company and have been asked to
determine the minimum number of computers
that the shop will have to sell to make a profit.
The equation that gives the minimum number of
computers ‘x’ to be sold after considering the total costs
and the total sales is:
f( x)  40 x  875x  35000  0
1.5
8
http://numericalmethods.eng.usf.edu
Solution
Use the Secant method of finding roots of
equations to find



9
The minimum number of computers that
need to be sold to make a profit. 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.
http://numericalmethods.eng.usf.edu
Graph of function f(x)
1.5
f x   40 x  875x  35000  0
3.510
4
f ( x)
4 10
4
3 10
4
2 10
4
1 10
4
0
0
 1.2510
4
1 10
4
2 10
4
0
20
0
40
60
x
80
100
100
f(x)
10
http://numericalmethods.eng.usf.edu
Iteration #1
4 10
4
3.510
4
x1  25, x0  50
f  x0  x0  x1 
x1  x0 
f  x0   f  x1 
3 10
4
4
2 10
f ( x)
f ( x)
1 10
4

5392 50  25
x1  50 
5392  18125
f ( x)
0
secant ( x)
0
f ( x)
1 10
4
 60.587
2 10
4
 2.00710
4
3 10
4
0
20
x x 0  x 1'  x x 1
0
f(x)
x'1, (first guess)
x0, (previous guess)
Secant line
x1, (new guess)
11
40
60
80
100
a  17.474%
100
The number of significant
digits at least correct is 0.
http://numericalmethods.eng.usf.edu
Iteration #2
4 10
4
3.510
4
x0  50, x1  60.587
3 10
4
x2  x1 
2 10
4
f ( x)
f  x1  x1  x0 
f  x1   f  x0 
f ( x)
x2  60.5871 
1 10
4
f ( x)
secant ( x)
0
f ( x)
 62.569
0
a  3.1672%
1 10
4
 1.60610
4
2 10
4
0
20
40
x x 1  x 0  x x 2
0
f(x)
x1 (guess)
x0 (previous guess)
Secant line
x2 (new guess)
12
850.13360.587  50 
850.133  5392
60
80
100
100
The number of significant
digits at least correct is 1.
http://numericalmethods.eng.usf.edu
Iteration #3
Entered function along given interval with current and next root and the
tangent line of the curve at the current root
3.510
4
f ( x)
4 10
4
3 10
4
2 10
4
1 10
4
x1  60.587, x2  62.569
x3  x2 
x3  62.569 
f ( x)
f ( x)
49.219 62.569  60.587 
49.219  850.133
secant ( x)
0
0
f ( x)
 1.50810
4
1 10
4
2 10
4
 62.690
0
20
40
x x 2  x 1  x x 3
0
f(x)
x2 (guess)
x1 (previous guess)
Secant line
x3 (new guess)
13
f  x2  x2  x1 
f  x2   f  x1 
60
80
100
100
a  0.19425%
The number of significant
digits at least correct is 2.
http://numericalmethods.eng.usf.edu
Advantages


14
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 guess1  x guess2
f(x)
prev. guess
new guess
10
10
f x  Sinx  0
Division by zero
15
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, (first guess)
x0, (previous guess)
Secant line
x1, (new guess)
10
f x   Sinx  0
Root Jumping
16
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