560 likes | 742 Views
ROOTS OF EQUATIONS Student Notes. ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier. Applied Problem. The concentration of pollutant bacteria C in a lake decreases according to:.
E N D
ROOTS OF EQUATIONSStudent Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier
Applied Problem The concentration of pollutant bacteria C in a lake decreases according to: Determine the time required for the bacteria to be reduced to 10 ppm.
Applied Problem You buy a $20 K piece of equipment for nothing down and $5K per year for 5 years. What interest rate are you paying? The formula relating present worth (P), annual payments (A), number of years (n) and the interest rate (i) is:
Quadratic Formula This equation gives us the roots of the algebraic function f(x) i.e. the value of x that makes f(x) = 0 How can we solve for f(x) = e-x - x?
Roots of Equations • Plot the function and determine where it crosses the x-axis • Lacks precision • Trial and error
Overview of Methods • Bracketing methods • Bisection method • False position • Open methods • Newton-Raphson • Secant method
Specific Study Objectives • Understand the graphical interpretation of a root • Know the graphical interpretation of the false-position method (regula falsi method) and why it is usually superior to the bisection method • Understand the difference between bracketing and open methods for root location
Specific Study Objectives • Understand the concepts of convergence and divergence. • Know why bracketing methods always converge, whereas open methods may sometimes diverge • Know the fundamental difference between the false position and secant methods and how it relates to convergence
Specific Study Objectives • Understand the problems posed by multiple roots and the modification available to mitigate them • Use the techniques presented to find the root of an equation • Solve two nonlinear simultaneous equations using techniques similar to root finding methods
Bracketing Methods • Bisection method • False position method (regulafalsi method)
Graphically Speaking • Graph the function • Based on the graph, select two x values that “bracket the root” • What is the sign of the y value? • Determine a new x (xr) based on the method • What is the sign of the y value of xr? • Switch xr with the point that has a y value with the same sign • Continue until f(xr) = 0 xl xu xr
f(x) f(x) x x f(x) f(x) x x Theory Behind Bracketing Methods consider lower and upper bound same sign, no roots or even # of roots opposite sign, odd # of roots
f(x) x Bisection Method • xr = (xl + xu)/2 • Takes advantage of sign changing • There is at least one real root
Graphically Speaking • Graph the function • Based on the graph, select two x values that “bracket the root” • What is the sign of the y value? • xr = (xl + xu)/2 • What is the sign of the y value of xr? • Switch xr with the point that has a y value with the same sign • Continue until f(xr) = 0 xl xu xr
Algorithm • Choose xu and xl. Verify sign change • f(xl)f(xu) < 0 • Estimate root • xr = (xl + xu) / 2 • Determine if the estimate is in the lower or upper subinterval • f(xl)f(xr) < 0 then xu = xr RETURN • f(xl)f(xr) >0 then xl = xr RETURN • f(xl)f(xr) =0 then root equals xr - COMPLETE
Error Let’s consider an example problem:
Example Use the bisection method to determine the root • f(x) = e-x - x • xl = -1 xu = 1 STRATEGY
Strategy • Calculate f(xl) and f(xu) • Calculate xr • Calculate f(xr) • Replace xl or xu with xr based on the sign of f(xr) • Calculate ea based on xr for all iterations after the first iteration • REPEAT
False Position Method • “Brute Force” of bisection method is inefficient • Join points by a straight line • Improves the estimate • Replacing the curve by a straight line gives the “false position”
Based on similar triangles next estimate, xr f(xu) xl xu f(xl)
Example Determine the root of the following equation using the false position method starting with an initial estimate of xl=4.55 and xu=4.65 f(x) = x3 - 98 STRATEGY
Strategy • Calculate f(xl) and f(xu) • Calculate xr • Calculate f(xr) • Replace xl or xu with xr based on the sign of f(xr) • Calculate ea based on xr for all iterations after the first iteration • REPEAT
Example Spreadsheet • Use of IF-THEN statements • Recall in the bi-section or false position methods. • If f(xl)f(xr)>0 then they are the same sign • Need to replace xu with xr • If f(xl)f(xr)< 0 then they are opposite signs • Need to replace xl with xr
Example Spreadsheet ? If f(xl)f(xr) is negative, we want to leave xu as xu If f(xl)f(xr) is positive, we want to replace xu with xr The EXCEL command for the next xu entry follows the logic If f(xl)f(xr) < 0, xu,xr Example Spreadsheet
Open Methods • Newton-Raphson method • Secant method • Multiple roots • In the previous bracketing methods, the root is located within an interval prescribed by an upper and lower boundary
tangent f(xi) xi xi+1 Newton Raphson
Newton Raphson • A is the initial estimate • B is the function evaluated at A • C is the first derivative evaluated at A • D= A-B/C • Repeat
Newton RaphsonPitfalls Solution can “overshoot” the root and potentially diverge f(x) x1 x2 x0 x
Example Use the Newton Raphson method to determine the root of f(x) = x2 - 11 using an initial guess of xi = 3 STRATEGY
Strategy • Start a table to track your solution • Calculate f(x) and f’(x) • Estimate the next xi based on the governing equation • Use es to determine when to stop • Note: use of subscript “0”
Secant method Approximate derivative using a finite divided difference What is this? HINT: dy / dx = Dy / Dx Substitute this into the formula for Newton Raphson
Secant method Substitute finite difference approximation for the first derivative into this equation for Newton Raphson
Secant method • Requires two initial estimates • f(x) is not required to change signs, therefore this is not a bracketing method
Secant method f(x) slope between two estimates { x initial estimates new estimate
Example Determine the root of f(x) = e-x - x using the secant method. Use the starting points x0 = 0 and x1 = 1.0. STRATEGY
Strategy • Start a table to track your results • Note: here you need two starting points! • Use these to calculate x2 • Use x3 and x2 to calculate ea at i=3 • Use es
2 2 1 1 Comparison of False Position and Secant Method f(x) f(x) x x new est. new est.
Multiple Roots • Corresponds to a point where a function is tangential to the x-axis • i.e. double root • f(x) = x3 - 5x2 + 7x -3 • f(x) = (x-3)(x-1)(x-1) • i.e. triple root • f(x) = (x-3)(x-1)3
Difficulties • Bracketing methods won’t work • Limited to methods that may diverge
f(x) = 0 at root • f '(x) = 0 at root • Hence, zero in the denominator for Newton-Raphson and Secant Methods • Write a “DO LOOP” to check is f(x) = 0 before continuing
Systems of Non-Linear Equations • We will later consider systems of linear equations • f(x) = a1x1 + a2x2+...... anxn - C = 0 • where a1 , a2 .... an and C are constant • Consider the following equations • y = -x2 + x + 0.5 • y + 5xy = x3 • Solve for x and y
Systems of Non-Linear Equations cont. • Set the equations equal to zero • y = -x2 + x + 0.5 • y + 5xy = x3 • u(x,y) = -x2 + x + 0.5 - y = 0 • v(x,y) = y + 5xy - x3 = 0 • The solution would be the values of x and y that would make the functions u and v equal to zero
Write a first order Taylor series with respect to u and v The root estimate corresponds to the point where ui+1 = vi+1 = 0
Therefore THE DENOMINATOR OF EACH OF THESE EQUATIONS IS FORMALLY REFERRED TO AS THE DETERMINANT OF THE JACOBIAN This is a 2 equation version of Newton-Raphson
Example • Determine the roots of the following nonlinear simultaneous equations • x2+xy=10 • y + 3xy2 = 57 • Use and initial estimate of x=1.5, y=3.5 STRATEGY
Strategy • Rewrite equations to get • u(x,y) = 0 from equation 1 • v(x,y) = 0 from equation 2 • Determine the equations for the partial of u and v with respect to x and y • Start a table!