Skip to content

MANE 3351

Lecture 12

Classroom Management

Agenda

  • Test 1 graded. Will return after lecture and before lab
  • Discuss Schedule
  • Lecture: Secant Method; last root finding method
  • Lab Session: Lab Five - GitHub/GitHub Desktop

Calendar

Week Monday Lecture Wednesday Lecture
7 10/13: Secant Method 10/15: Trapezoid Rule
8 10/20: Simpson's Rule 10/22: Romberg Integration
9 10/27: Gaussian Quadrature 10/29: Numerical Differentiation (not on Test 2)
10 11/3: Linear Algebra 11/5: Test 2 (Root Finding and Numerical Integration)

Resources

Handouts


Lecture 12 Content

  • Today's topic is the secant method.
  • The secant method does not utilize derivative information as Newton's method does.
  • The secant method is also similar to the false position method.
  • The secant method is the last root finding method covered

Limit Definition of the Derivative

Recall the limit definition of the derivative1

Definition of Derivative


Geometric Inspiration

Cheney and Kincaid (2004)2 demonstrate the geometric inspiration for secant method

Secant method


Secant Method

  • The formula is simply
\[ x_{n+1}=x_n - g(x_n)\frac{x_n-x_{n-1}}{g(x_n)-g(x_{n-1})} \]

Example Problem Used for Newton's Method

  • Consider a new function, \(f(x)=e^x+2^{-x}+2\cos(x)-6=0\)

Example Function for Newton's method


Pseudo-code

Brin (2020)3provides the following pseudo-code

Secant Method pseud-ocode


Convergence

  • Brin (2020)3 study the performance of Secant Method
  • The secant method converges with order \(\frac{1+\sqrt{5}}{2}=1.62\)
  • Not quite as fast as Newton's Method (quadratic)

Similarity to False Position

  • Secant method: \(x_{n+1}=x_n - g(x_n)\frac{x_n-x_{n-1}}{g(x_n)-g(x_{n-1})}\)
  • False Position method: \(x_r=x_u-\frac{f(x_u)(x_l-x_u)}{f(x_l)-f(x_u)}\)
  • Secant method is not guaranteed to bracket result when starting

Speed of Convergence

Chapra and Canale (2015)4 compared the performance of various root finding methods

Comparison


Secant Code

import math
def f(x):
    return (math.exp(x)+2**(-x)+2*math.cos(x)-6)

N=100
tol=0.0005
x0=6.0
x1=5.0
# step 1
y0=f(x0)
y1=f(x1)
# counter is additional
counter=0
for j in range(N+1):
    counter=counter+1
    # step 3
    x=x1-y1*((x1-x0)/(y1-y0))
    if math.fabs(x-x1)<tol:
        print("the root is {} with value {}, required {} steps".format(x,f(x),counter))
        break
    # step 5
    x0=x1
    y0=y1
    x1=x
    y1=f(x1)
print("completed")


  1. https://math.hmc.edu/calculus/hmc-mathematics-calculus-online-tutorials/single-variable-calculus/limit-definition-of-the-derivative/ 

  2. Cheny, W., and Kincaid, D., (2004), Numerical Mathematics and Computer, 5th edition 

  3. Brin, L, (2020), Tea Time Numerical Analysis: Experiences in Mathematics, 3rd edition 

  4. Chapra, S., and Canale, R., (2015), Numerical Methods for Engineers, 7th edition