Module for the Secant Method

Check out the new Numerical Analysis Projects page.

 

    The Newton-Raphson algorithm requires two functions evaluations per iteration, [Graphics:Images/SecantMethodMod_gr_1.gif] and  [Graphics:Images/SecantMethodMod_gr_2.gif].  Historically, the calculation of a derivative could involve considerable effort.  But, with modern computer algebra software packages such as Mathematica, this has become less of an issue.  Moreover, many functions have non-elementary forms (integrals, sums, discrete solution to an I.V.P.), and it is desirable to have a method for finding a root that does not depend on the computation of a derivative. The secant method does not need a formula for the derivative and it can be coded so that only one new function evaluation is required per iteration.  

    The formula for the secant method is the same one that was used in the regula falsi method, except that the logical decisions regarding how to define each succeeding term are different.  

 

Algorithm (Secant Method).  Find a root of  [Graphics:Images/SecantMethodMod_gr_3.gif]  given two initial approximations  [Graphics:Images/SecantMethodMod_gr_4.gif]  using the iteration  

    [Graphics:Images/SecantMethodMod_gr_5.gif]   for    [Graphics:Images/SecantMethodMod_gr_6.gif].

 

Animations (Secant Method  Secant  Method) .  Internet hyperlinks to animations.

 

Mathematica Subroutine (Secant Method).

[Graphics:Images/SecantMethodMod_gr_7.gif]

Example 1.  Use the secant method to find the three roots of the cubic polynomial  [Graphics:Images/SecantMethodMod_gr_8.gif].  
Determine the secant iteration formula  [Graphics:Images/SecantMethodMod_gr_9.gif]  that is used.  
Show details of the computations for the starting value  [Graphics:Images/SecantMethodMod_gr_10.gif].
Solution 1.

 

Reduce the volume of printout.

After you have debugged you program and it is working properly, delete the unnecessary print statements  

[Graphics:Images/SecantMethodMod_gr_106.gif]  and  
[Graphics:Images/SecantMethodMod_gr_107.gif]  and  
[Graphics:Images/SecantMethodMod_gr_108.gif]

 

Concise Program for the Secant Method

[Graphics:Images/SecantMethodMod_gr_109.gif]

Now test the example to see if it still works.

[Graphics:Images/SecantMethodMod_gr_110.gif]

[Graphics:Images/SecantMethodMod_gr_111.gif]

[Graphics:Images/SecantMethodMod_gr_112.gif]

[Graphics:Images/SecantMethodMod_gr_113.gif]



[Graphics:Images/SecantMethodMod_gr_114.gif]
[Graphics:Images/SecantMethodMod_gr_115.gif] [Graphics:Images/SecantMethodMod_gr_116.gif] [Graphics:Images/SecantMethodMod_gr_117.gif] [Graphics:Images/SecantMethodMod_gr_118.gif]
[Graphics:Images/SecantMethodMod_gr_119.gif] [Graphics:Images/SecantMethodMod_gr_120.gif] [Graphics:Images/SecantMethodMod_gr_121.gif]

Error Checking in the Secant Method

Error checking can be added to the secant method.  Here we have added a third parameter  [Graphics:Images/SecantMethodMod_gr_122.gif]  to the subroutine which estimate the accuracy of the numerical solution.

[Graphics:Images/SecantMethodMod_gr_123.gif]

The following subroutine call uses a maximum of 20 iterations, just to make sure enough iterations are performed.  
However, it will terminate when the difference between consecutive iterations is less than  [Graphics:Images/SecantMethodMod_gr_124.gif].  
By interrogating  k  afterward we can see how many iterations were actually performed.

[Graphics:Images/SecantMethodMod_gr_125.gif]
[Graphics:Images/SecantMethodMod_gr_126.gif] [Graphics:Images/SecantMethodMod_gr_127.gif] [Graphics:Images/SecantMethodMod_gr_128.gif] [Graphics:Images/SecantMethodMod_gr_129.gif] [Graphics:Images/SecantMethodMod_gr_130.gif]
[Graphics:Images/SecantMethodMod_gr_131.gif] [Graphics:Images/SecantMethodMod_gr_132.gif] [Graphics:Images/SecantMethodMod_gr_133.gif] [Graphics:Images/SecantMethodMod_gr_134.gif] [Graphics:Images/SecantMethodMod_gr_135.gif]
[Graphics:Images/SecantMethodMod_gr_136.gif] [Graphics:Images/SecantMethodMod_gr_137.gif] [Graphics:Images/SecantMethodMod_gr_138.gif] [Graphics:Images/SecantMethodMod_gr_139.gif]

Research Experience for Undergraduates

Secant Method  Secant Method  Internet hyperlinks to web sites and a bibliography of articles.  

 

  

Downloads (Secant Method Secant Method).  
Download this Mathematica notebook.  

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2003