lecture 5 - single variable problems cven 302 june 12, 2002
TRANSCRIPT
![Page 1: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/1.jpg)
Lecture 5 - Single Variable Lecture 5 - Single Variable ProblemsProblems
CVEN 302
June 12, 2002
![Page 2: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/2.jpg)
Lecture’s GoalsLecture’s Goals
• Introduction of Solving Equations of 1 Variable– Bisection Method – Linear interpolation & Secant Method– Newton’s Method– Muller’s Method– Fixed Point Iteration
![Page 3: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/3.jpg)
General ConsiderationsGeneral Considerations
• Is the function to be evaluated often?
• How much precision is needed?
– If so you may be able to create a custom algorithm for the problem.
– Engineering calculations are often required for a few significant figures. A simple root finding procedure may be adequate.
![Page 4: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/4.jpg)
General ConsiderationsGeneral Considerations
• How fast and robust must the method be?
– If the root finding is embedded in another program that automatically changes the parameter f(x), it is important that the root finder is robust. A robust procedure is relatively immune to initial guess and it converges quickly without being overly sensitive to the behavior of the function.
![Page 5: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/5.jpg)
General ConsiderationsGeneral Considerations
• Is the function a polynomial?
– There are special procedures for finding roots of polynomials. These should be used instead of general procedures such as bisection, Newton’s method or secant method.
![Page 6: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/6.jpg)
Does the function have singularities?Does the function have singularities?
Some root finding procedure will converge to a singularity, as well as converge to a root. This must be guarded against.
![Page 7: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/7.jpg)
Basic Root Finding TechniquesBasic Root Finding Techniques
The initial procedure is to find the roots of a function. The main concept of each technique is to bracket the root and do a series of iteration until the method converges on a solution.
![Page 8: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/8.jpg)
Root Finding TechniquesRoot Finding Techniques
• Bracket the roots• Determine the method• Iterate to find the solution
![Page 9: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/9.jpg)
Convergence CriteriaConvergence Criteria
• The algorithm must decide on how close to the root the guess should be before stopping.
• Two criteria can be applied in testing.
– Magnitude by which estimate of root changes.
– Magnitude by which the function will change.
![Page 10: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/10.jpg)
Bisection MethodBisection Method
• The method is known as the Bolzano method and can be called interval halving technique.
• The method is simple and straight-forward.
• Given a bracketed root, the method repeatedly halves the interval while continuing to bracket the root and it will converge on the solution.
![Page 11: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/11.jpg)
Bisection Method (Algorithm)Bisection Method (Algorithm)
Do while 0.5*|x1 - x2| >= tolerance value
Set x3 =(x1 + x2)/2
IF f(x3) of opposite sign of f(x1);
Set x2 = x3;
ELSE
Set x1 = x3;
ENDIF
END loop
![Page 12: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/12.jpg)
Bisection MethodBisection Method
DemoBisect: the example program does a simple bisection for a cubic polynomial equation.
![Page 13: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/13.jpg)
Bisection MethodBisection Method
• Example Problemf(x) = a5 x5 + a4 x4 + a3 x3 + a2 x2 + a1 x + a0
• Let the functiona0 = -2, a1 = -3, a2 = 4, a3 = 1, a4 = 0, a5 = 1
f(x) = x5 + x3 + 4x2 - 3x - 2
![Page 14: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/14.jpg)
Bisection MethodBisection MethodFunctional Plot
-1200
-1000
-800
-600
-400
-200
0
200
400
600
800
-6 -4 -2 0 2 4
x value
f(x
)
Functional Plot
-6
-4
-2
0
2
4
6
8
-2 -1.5 -1 -0.5 0 0.5 1 1.5
x value
f(x
)
There are 3 roots
(a) -2 < x < -1
(b) -1 < x < 0
(c) 0.5 < x <1.5
![Page 15: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/15.jpg)
Bisection MethodBisection Method
x1 f(x1) x2 f(x2) x3 f(x3)
-2.0000 -20.000 -1.0000 3.00000 1.0000 -1.5000 0.53125
-2.0000 -20.000 -1.5000 0.53125 0.5000 -1.7500 -6.27246
-1.7500 -6.2725 -1.5000 0.53125 0.2500 -1.6250 -2.18448
-1.6250 -2.1848 -1.5000 0.53125 0.1250 -1.5625 -0.67480
-1.5625 -0.6748 -1.5000 0.53125 0.0625 -1.53125 -0.03612
etc. etc. etc. etc. etc. etc. etc.
![Page 16: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/16.jpg)
Linear InterpolationLinear Interpolation
• The bisection method is not very efficient. We would like to converge to the root at a faster rate with a different algorithm.
• One of these method is linear interpolation method or the method of false position (Latinized version Regula Falsi )
![Page 17: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/17.jpg)
Method of Linear InterpolationMethod of Linear InterpolationRegula FalsiRegula Falsi
Do while |x2 - x1| >= tolerance value 1
or |f(x3)|>= tolerance value 2
Set x3 = x2 - f(x2)*(x2 - x1)/(f(x2)-f(x1))
IF f(x3) of opposite sign of f(x1);
Set x2 = x3;
ELSE
Set x1 = x3;
ENDIF
END loop
![Page 18: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/18.jpg)
Regula Flasi or Regula Flasi or Linear InterpolationLinear Interpolation
The program uses the slope of the two points to find the intersection. However, the upper bound is kept constant.
The program uses a similar triangle to estimate the location of the root.
![Page 19: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/19.jpg)
Linear InterpolationLinear Interpolation
• Same example problem
f(x) = x5 + x3 + 4x2 - 3x - 2
• roots are between (-1.7,-1.3), (-1,0), & (0.5,1.5)
![Page 20: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/20.jpg)
Regula Falsi MethodRegula Falsi Method
x1 f(x1) x2 f(x2) x2-x1 f(x2)-f(x1) x3 f(x3)
-1.7000 -4.4516 -1.3000 2.75007 0.4000 7.2016 -1.45275 1.2635
-1.7000 -4.4516 -1.4528 1.2635 0.2472 5.7143 -1.50743 0.40265
-1.7000 -4.4516 -1.5074 0.40265 0.1926 4.8547 -1.52339 0.11307
-1.7000 -4.4516 -1.5234 0.11293 0.1766 4.5645 -1.52777 0.03052
etc. etc. etc. etc. etc. etc. etc. etc.
![Page 21: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/21.jpg)
Secant MethodSecant Method
• The algorithm is similar to the linear interpolation method but it oscillates from one side to the next.
• The method converges quickly with well behaved functions.
![Page 22: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/22.jpg)
Secant MethodSecant Method
Do while |x2 - x1| >= tolerance value 1
or |f(x3)|>= tolerance value 2
Set x3 = x2 - f(x2)*(x2 - x1)/(f(x2)-f(x1))
Set x1 = x2;
Set x2 = x3;
END loop
![Page 23: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/23.jpg)
Comparison between Linear Comparison between Linear Interpolation and Secant MethodInterpolation and Secant Method
The secant can be faster method, because it does not have a large slope at the root.
![Page 24: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/24.jpg)
Problems with the Secant MethodProblems with the Secant Method
The convergence condition is :
x3 = x2 - f(x2)*
(x2-x1)/(f(x2)-f(x1))
It is tempting to rewrite the
convergence condition.
x3 = (f(x2)*x1-f(x1)* x2 )
/(f(x2)-f(x1))
![Page 25: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/25.jpg)
Problems with the Secant MethodProblems with the Secant Method
This method can be
catastrophic if the points
are near a point where the
first derivative is zero.
Example: SecantProb
Try for the interval (1,3)
![Page 26: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/26.jpg)
Secant MethodSecant Method
• The Secant method is the same as the linear interpolation method, but you do not do a comparison between +/- values and do the substitution.
• Problem if the points are on opposite ends of a peak or trough.
![Page 27: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/27.jpg)
Secant Method x1 f(x1) x2 f(x2) x2x1 f(x2)-f(x1) x3 f(x3)
-1.7000 -4.4516 -1.3000 2.7501 0.4000 7.2016 -1.45275 1.2635
-1.4528 1.2635 -1.7000 -4.4516 -0.2472 -5.7143 -1.50743 0.40265
-1.5074 0.4031 -1.4528 1.2635 0.0546 0.8596 -1.53300 -0.07000
-1.5330 -0.0700 -1.5074 0.4031 0.0256 0.4731 -1.52921 -0.00297
etc. etc. etc. etc. etc. etc. etc. etc.
![Page 28: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/28.jpg)
Newton’s MethodNewton’s Method
• This method is one of the most widely used methods to solve equations also known as the Newton-Raphson.
• The idea for the method comes from a Taylor series expansion, where you know the function and its’ first derivative.
f(xk+1) = f(xk) + (xk+1 - xk)*f ‘(xk) + ...
![Page 29: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/29.jpg)
Newton’s MethodNewton’s Method• The goal of the calculations is to find a f(x)=0, so
set f(xk+1) = 0 and rearrange the equation. [ f ‘(xk) is the first derivative of f(x). ]
dx
xdfxf
xx
dx
xdfxxxf
k
kk1k
kk1kk0
![Page 30: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/30.jpg)
Newton-Raphson MethodNewton-Raphson Method
The method uses the
slope of the line to
project to the x axis and
find the root. The
method converges on the
solution quickly.
![Page 31: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/31.jpg)
Newton’s MethodNewton’s MethodDo while |x2 - x1| >= tolerance value 1
or |f(x2)|>= tolerance value 2
or f’(x1) ~= 0
Set x2 = x1 - f(x1)/f’(x1)
Set x1 = x2;
END loop
![Page 32: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/32.jpg)
Newton’s MethodNewton’s Method
• Same example problem
f(x) = x5 + x3 + 4x2 - 3x - 2
and
f’(x) = 5x4 + 3x2 + 8x - 3
• roots are between (-1.7,-1.3), (-1,0), & (0.5,1.5)
![Page 33: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/33.jpg)
Newton’s MethodNewton’s Method x1 f(x1) f’(x1) f(x1)/f’(x1) x2
-2.0000 -20.0000 73.0000 -0.27397 -1.7260
-1.7260 -5.3656 36.5037 -0.14699 -1.5790
-1.5790 -1.0423 22.9290 -0.04546 -1.5335
-1.5335 -0.0797 19.4275 -0.00410 -1.5294
-1.5294 -0.0005 19.1381 -0.00003 -1.5294
etc. etc. etc. etc. etc.
![Page 34: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/34.jpg)
SummarySummary
• Bisection - need to know f(x) and two bounds.• Regula Flasi (linear interpolation) - need to know
the function and two bounds.• Secant - need to know f(x) and two bounds.• Newton’s - need to know f(x) and f’(x) and an
initial guess.
![Page 35: Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002](https://reader035.vdocument.in/reader035/viewer/2022062301/5697bf931a28abf838c8f618/html5/thumbnails/35.jpg)
HomeworkHomework
• Check the Homework webpage