4 Numerical Methods Root Finding Secant Method Modified Secant

Slides:



Advertisements
Similar presentations
Engineering Computation
Advertisements

Lecture 5 Newton-Raphson Method
Open Methods Chapter 6 The Islamic University of Gaza
ROOTS OF EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
Regula-Falsi Method. Type of Algorithm (Equation Solver) The Regula-Falsi Method (sometimes called the False Position Method) is a method used to find.
Engineering Computation
Open Methods Chapter 6 The Islamic University of Gaza
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 7 Roots of Equations Bracketing Methods.
Chapter 4 Roots of Equations
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 51.
Roots of Equations Open Methods (Part 2).
Chapter 6 Open Methods.
Second Term 05/061 Roots of Equations Bracketing Methods.
A few words about convergence We have been looking at e a as our measure of convergence A more technical means of differentiating the speed of convergence.
Open Methods (Part 1) Fixed Point Iteration & Newton-Raphson Methods
Roots of Equations Bracketing Methods.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 9 Roots of Equations Open Methods.
Open Methods Chapter 6 The Islamic University of Gaza
NUMERICAL METHODS WITH C++ PROGRAMMING
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 8 Roots of Equations Open Methods.
Bracketing Methods Chapter 5 The Islamic University of Gaza
Roots of Equations Open Methods Second Term 05/06.
FP1: Chapter 2 Numerical Solutions of Equations
Chapter 3 Root Finding.
Secant Method Another Recursive Method. Secant Method The secant method is a recursive method used to find the solution to an equation like Newton’s Method.
Roots of Equations Chapter 3. Roots of Equations Also called “zeroes” of the equation –A value x such that f(x) = 0 Extremely important in applications.
Solving Non-Linear Equations (Root Finding)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 Roots of Equations Why? But.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
1 Nonlinear Equations Jyun-Ming Chen. 2 Contents Bisection False Position Newton Quasi-Newton Inverse Interpolation Method Comparison.
Lecture 6 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
Newton’s Method Other Recursive Methods Modified Fixed Point Method.
Chapter 3 Roots of Equations. Objectives Understanding what roots problems are and where they occur in engineering and science Knowing how to determine.
Numerical Methods for Engineering MECN 3500
Quadrature rules 1Michael Sokolov / Numerical Methods for Chemical Engineers / Numerical Quadrature Michael Sokolov ETH Zurich, Institut für Chemie- und.
Numerical Methods.
CHAPTER 3 NUMERICAL METHODS
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Roots of Equations ~ Bracketing Methods Chapter 5.
Numerical Methods Root Finding 4. Fixed-Point Iteration---- Successive Approximation Many problems also take on the specialized form: g(x)=x, where we.
Today’s class Roots of equation Finish up incremental search
Newton-Raphson Method. Figure 1 Geometrical illustration of the Newton-Raphson method. 2.
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 5 Bracketing Methods.
Solving Non-Linear Equations (Root Finding)
Numerical Methods Solution of Equation.
4 Numerical Methods Root Finding Secant Method Modified Secant
SOLVING NONLINEAR EQUATIONS. SECANT METHOD MATH-415 Numerical Analysis 1.
4 Numerical Methods Root Finding.
Solution of Nonlinear Equations ( Root Finding Problems ) Definitions Classification of Methods  Analytical Solutions  Graphical Methods  Numerical.
CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 / Chapter 5.
Solution of Nonlinear Equations ( Root Finding Problems )
4 Numerical Methods Root Finding Secant Method Modified Secant
Numerical Methods and Analysis
Secant Method.
Newton’s Method for Systems of Non Linear Equations
Secant Method – Derivation
Solution of Equations by Iteration
Numerical Analysis Lecture 7.
Newton-Raphson Method
Computers in Civil Engineering 53:081 Spring 2003
Newton-Raphson Method
4 Numerical Methods Root Finding.
ROOTS OF EQUATIONS.
FP1: Chapter 2 Numerical Solutions of Equations
Newton-Raphson Method
Copyright © Cengage Learning. All rights reserved.
MATH 1910 Chapter 3 Section 8 Newton’s Method.
Solutions for Nonlinear Equations
Presentation transcript:

4 Numerical Methods Root Finding Secant Method Modified Secant False Position Method Newton Method

Root Finding False Position Method

The False-Position Method (Regula-Falsi) We can approximate the solution by doing a linear interpolation between f(xu) and f(xl) Find xr such that l(xr)=0, where l(x) is the linear approximation of f(x) between xl and xu Derive xr using similar triangles

Based on similar triangles next estimate, xr f(xu) xl xu f(xl)

Example k xk (Bisection) fk xk (False Position) 1 0.5 0.471 2 0.25 0.372 3 0.375 0.362 4 0.3125 0.360 5 0.34315 -0.042 2.93×10-5

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

Pitfalls of False Position Method

Bisection Method (Converge quicker) Iteration xl xu xr εa (%) εt (%) 1 1.3 0.65 35 2 0.975 33.3 25 3 1.1375 14.3 13.8 4 1.05625 7.7 5.6 5 1.015625 4.0 1.6 False-position Method Iteration xl xu xr εa (%) εt (%) 1 1.3 0.09430 90.6 2 0.18176 48.1 81.8 3 0.26287 30.9 73.7 4 0.33811 22.3 66.2 5 0.40788 17.1 59.2

Comparison of False Position and Secant Method 2 f(x) f(x) 2 1 1 x x new est. new est.

Secant method Math 685/CSI 700 Spring 08 George Mason University, Department of Mathematical Sciences

Secant method Math 685/CSI 700 Spring 08 George Mason University, Department of Mathematical Sciences

{ Secant method Select two estimates. Note: f(xi) and f(xi+1) f(x) are not opposite signs. f(x) { x initial estimates

Secant method f(x) slope between two estimates { x initial estimates

{ Secant method f(x) slope between two estimates x initial estimates new estimate

To get xn+1 from xn and xn-1 we write out the equation of the secant line and using the points xn and xn-1. We then plug in the point (xn+1,0) and solve for xn+1. equation of secant substitute (xn+1,0) solve for xn+1 xn+1=h(xn-1,xn) The equation above gives the recursively defined sequence for xn. This is what is used for the Secant Method. The halting condition is usually given by the Standard Cauchy Error.

Secant method table n xn-1 f(xn-1) xn f(xn) xn+1 1 4.0000 -3.4800 6.0000 9.8800 4.5210 2 6.0000 9.8800 4.5210 -1.6287 4.7303 3 4.5210 -1.6287 4.7303 -0.5967 4.8513 4 4.7303 -0.5967 4.8513 -0.0815 4.8368 5 4.8513 -0.0815 4.8373 -.0032 4.8373 We will assume initial guesses for xn-1 = 4.00 and xn = 6.00 (the same as we used for the bisection method). The value of the function at 4.00 is -3.4800 and at 6.00 it is 9.8800. Using these values the root approximation equation yields: xn+1 = 6.00 – 9.88*(6.00-4.00)/(9.88-(-3.48)) = 4.5210. We then replace xn-1 with xn and xn with xn+1 and repeat the procedure. After 6 iterations the root converges to 4.8373 and the absolute value of the function is less than 0.0001. The secant method is almost as fast as Newton’s method, and has the advantage of not requiring an analytical derivative. However, it has the same problem as Newton’s that when the root approaches a point near a maximum or minimum of the function, the new root calculation will approach infinity.

Secant Illustration F(x) = x2 - 10 1 (a=1, fa=-9) (b=10, fb=90)  int = 1.8, fint = -6.7 2 (a=10, fa=90) (b=1.8, fb= -6.7) int = 0.88, fint = -9.22 3 (a=1.8, fa=-6.7) (b=0.88, fb=-9.22) int = 4.25, fint = 8 4 (a=0.88, fa=-9.22) (b=4.25, fb=8) Int =2.68, fint = -2.8 Etc… 1 2 3 4

Example Determine the root of f(x) = e-x - x using the secant method. Use the starting points x0 = 0 and x1 = 1.0.

Choose two starting points Solution Choose two starting points x0 = 0 f(x0 ) =1 x1 = 1.0 f(x1) = -0.632 Calculate x2 x2 = 1 - (-0.632)(0 - 1)/(1+0.632) = 0.6127

NOTE: f(x) are the same sign. OK here. Solution Second iteration x1 = 1.0 f(x1) = -0.632 x2 = 0.613 f(x2) = -0.0708 NOTE: f(x) are the same sign. OK here. x3 = 0.613 - (-0.0708)(1-0.613)/(-0.632+0.0708) x3 = 0.564 f(x3) = 0.0052 ea = abs[(0.564-0.613)/(0.564)] x 100 = 8.23%

ea = 0.59% et = 0.0048% Third iteration x2 = 0.613 f(x2) = -0.0708 Solution Third iteration x2 = 0.613 f(x2) = -0.0708 x3 = 0.564 f(x3) = 0.0052 x4 = 0.567 f(x4) = -0.00004 ea = 0.59% et = 0.0048% Know the difference between these error terms

The change from ordinary double secant(double c, int iterations, double tol)… for ( int i = 0; i < iterations; i++) { double x = ( fa*b - fb*a ) / ( fa - fb ); double fx = func( x, c ); if ( fabs( fx ) < tol ) return x; a = b; fa = fb; b = x; fb = fx; } return -1; SECANT METHOD The change from ordinary regula is that the sign check is dropped and points are just “shifted over”

Math 685/CSI 700 Spring 08 Example George Mason University, Department of Mathematical Sciences

Use secant method to estimate the root of f(x) = ln x. Ex. Use secant method to estimate the root of f(x) = ln x. Start the computation with value of xl = xi-1 = 0.5 xu = xi = 5.0 Solution The secant method

Problems With the Secant Method The number of iterations required can not be determined before the algorithm begins. The algorithm will halt (program termination by division by zero if not checked for) if a horizontal secant line is encountered. The secant method will sometimes find an extraneous root.

Modified Secant Method

Modified Secant Method Original Secant Method Modified Secant Method

x0 = 1 f(x0) = -0.63212 x1+ x0 = 1.01 f(x1+ x0) = -0.64578 Ex. Use the secant method to estimate the root of f(x) = e-x – x. Use a value of 0.01 for  and start with x0 = 1.0. Solution (true root = 0.56714329…) First iteration x0 = 1 f(x0) = -0.63212 x1+ x0 = 1.01 f(x1+ x0) = -0.64578 Calculate t = 5.3%

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:

Root Finding Newton Method

Newton’s Method Open solution, that requires only one current guess. Root does not need to be bracketed. Consider some point x0. If we approximate f(x) as a line about x0, then we can again solve for the root of the line.

Newton Raphson f(xi) xi tangent xi+1

Newton’s Method (cont) Derived using Taylor’s expansion

Solving, leads to the following iteration: Newton’s Method Solving, leads to the following iteration:

Newton Raphson Pitfalls solution diverges f(x) (x)

Finding a square-root Example: 2 = 1.4142135623730950488016887242097 Let x0 be one and apply Newton’s method.

Finding a square-root Example: 2 = 1.4142135623730950488016887242097 Note the rapid convergence Note, this was done with the standard Microsoft calculator to maximum precision.

Math 685/CSI 700 Spring 08 Newton’s method George Mason University, Department of Mathematical Sciences

Use the Newton Raphson method to determine the root of Example Use the Newton Raphson method to determine the root of f(x) = x2 - 11 using an initial guess of xi = 3

f(x) = x2 - 11 f '(x) = 2x initial guess xi = 3 f(3) = -2 f '(3) = 6 Solution f(x) = x2 - 11 f '(x) = 2x initial guess xi = 3 f(3) = -2 f '(3) = 6

Solution In this method, we begin to use a numbering system: x0 = 3 Continue to determine x2, x3 etc.

Solution

Example: Newton’s Method f(x)= x3–3x2 – x+9=0 k xk 1 9 2 6.41 46 -1.5250 Worse than bisection !?

Newton’s Algorithm Requires the derivative function to be evaluated, hence more function evaluations per iteration. A robust solution would check to see if the iteration is stepping too far and limit the step. Most uses of Newton’s method assume the approximation is pretty close and apply one to three iterations blindly.

Division by Multiplication Newton’s method has many uses in computing basic numbers. For example, consider the equation: Newton’s method gives the iteration:

Quadratic Convergence of Newton Let x* be the converged solution Recall

Quadratic Convergence of Newton (cont) Subtracting x*: Or we say Newton’s method has quadratic convergence

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.

Roots of Equations Chemical Engineering (C&C 8.1, p. 187): van der Waals equation; v = V/n (= volume/# moles) Find the molal volume v such that p = pressure, T = temperature, R = universal gas constant, a & b = empirical constants

Roots of Equations Civil Engineering (C&C Prob. 8.17, p. 205): Find the horizontal component of tension, H, in a cable that passes through (0,y0) and (x,y) w = weight per unit length of cable

Roots of Equations Electrical Engineering (C&C 8.3, p. 194): Find the resistance, R, of a circuit such that the charge reaches q at specified time t L = inductance, C = capacitance, q0 = initial charge

Roots of Equations Mechanical Engineering (C&C 8.4, p. 196): Find the value of stiffness k of a vibrating mechanical system such that the displacement x(t) becomes zero at t= 0.5 s. The initial displacement is x0 and the initial velocity is zero. The mass m and damping c are known, and λ = c/(2m). in which

Comparison Newton’s method False Position (Newton) xk xk+1 ‧ f ’(xk)

Summary Method Pros Cons Bisection Newton Secant 4/25/2017 Summary Method Pros Cons Bisection - Easy, Reliable, Convergent - One function evaluation per iteration - No knowledge of derivative is needed - Slow - Needs an interval [a,b] containing the root, i.e., f(a)f(b)<0 Newton - Fast (if near the root) - Two function evaluations per iteration - May diverge - Needs derivative and an initial guess x0 such that f’(x0) is nonzero Secant - Fast (slower than Newton) - One function evaluation per iteration - Needs two initial points guess x0, x1 such that f(x0)- f(x1) is nonzero