EE:211 Computational Techniques in Electrical Engineering Lecture#2 Dr. Mubashir Alam King Saud University
Outline Chapter#3 Rootfinding Bisection Method Newton's Algorithm Secant Method
Introduction
The Bisection Method
Example: 3.1.1
Error Bounds α is the true root and cn is its estimate Error: |α-cn|
Newton’s Algorithm
If x1 is the root of p(x) then p(x1)=0 Repeat the next with x1 as the initial estimate and determine x2 And so on
Newton’s Method
Example: 3.2.1
Stopping criteria
Example n xn f(xn) xn-xn-1 1.5 8.890625 ------------------ 1 1.5 8.890625 ------------------ 1 1.30049088 2.537264 -0.199950912 2 1.18148042 0.53845863 -0.11901046 3 1.13945559 0.04923525 -0.042025 4 1.13477763 5.50373 x 10-3 -4.678 x 10-3 Stopping criteria, ε = 1 x 10-2
Example: 3.2.1
Example: 3.2.2
Secant Method From this perspective, other straight-line approximation to y=f(x) would also lead to methods for approximating a root of f(x). One such straight-line approximation leads to SECANT METHOD
The two pints (x0,f(x0)) and (x1,f(x1)) , on the graph of y=f(x), determine a straight line , called a secant line. This line is an approximation to the graph of y=f(x), and its root x2 is an approximation to true root α.
Equation of lines Equation of line with slope = m and passing through a point (x1,y1): y-y1 = m(x-x1) y = y1+ m(x-x1) Slope of the line between points (x1,y1) and (x2,y2) Slope = m = (y2- y1) / (x2- x1)
Secant Method Find the equation of the line and then its root x2 Having found x2, we can drop x0, and use x1,x2 as a new set of approximate values for α. This will lead to an improved value x3. Continue this process …..
Secant Method General Formula: Two point method, since two approximate values are needed to obtain the next improved value.
Example: 3.3.1
Matlab Function: fzero This function uses ideas involved in the bisection and the secant method. Use: root=fzero(f_name, [a,b]) Produces a root within [a,b], assume f(a)f(b) <= 0 Use: root=fzero(f_name, xo) Find a root near x0.
Matlab Function: fzero Define function for: f(x)=x6-x-1 function f = myfun(x) f = x.^6-x-1; x=fzero(@myfun,[1,2]) x=1.134724138401519 x=fzero(@myfun,1.9)