Science Fair Projects Ideas - Secant method

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Secant method

In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function f.

Contents

The method

The secant method is defined by the recurrence relation

x_{n+1} = x_n - \frac{x_n-x_{n-1}}{f(x_n)-f(x_{n-1})} f(x_n).

As can be seen from the recurrence relation, the secant method requires two initial values, x0 and x1, which should ideally be chosen to lie close to the root.

Derivation of the method


Given a and b, we construct the line through the points (a, f(a)) and (b, f(b)), as demonstrated in the picture on the right. Note that this line is a secant or chord of the graph of the function f. In point-slope form, it can be defined as

y - f(b) = \frac{f(b)-f(a)}{b-a} (x-b).

We now choose c to be the root of this line, so c is chosen such that

f(b) + \frac{f(b)-f(a)}{b-a} (c-b) = 0.

Solving this equation gives the recurrence relation for the secant method.

Convergence

The iterates xn of the secant method converge to a root of f, if the initial values x0 and x1 are sufficiently close to the root. The order of convergence is φ, where

\varphi = \frac{1+\sqrt{5}}{2} \approx 1.618

is the golden ratio. In particular, the convergence is superlinear.

Of course, this result only hold under some technical conditions, namely: f is twice continuously differentiable and the root in question is a simple root.

Comparison with other root-finding methods

The secant method does not require that the root remain bracketed like the bisection method does. The false position method, which is based on the secant method, avoids this problem by checking the brackets at each step.

The recurrent formula of the secant method can be derived from the formula for Newton's method

x_{n+1} = x_n + \frac{f(x_n)}{f'(x_n)}

by using the finite difference approximation

f'(x_n) \approx \frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}.

If we compare Newton's method with the secant method, we see that Newton's method converges faster (order 2 against φ ≈ 1.6). However, Newton's method requires the evaluation of both f and its derivative at every step, while the secant method only requires the evaluation of f. Therefore, the secant method may well be faster in practice. For instance, if we assume that evaluating f takes as much time as evaluating its derivative and we neglect all other costs, we can do two steps of the secant method (decreasing the error by a factor φ² ≈ 2.6) for the same cost as one step of Newton's method (decreasing the error by a factor 2), so the secant method is faster.

Example code

The following C code was written for clarity instead of efficiency. It was designed to solve the same problem as solved by the Newton's method and false position method code: to find the positive number x where cos(x) = x3. This problem is transformed into a root-finding problem of the form f(x) = cos(x) - x3 = 0.

In the code below, the secant method continues until one of two conditions occur:

  1. | xn + 1 - xn | < e
  2. n > m

for some given m and e.

#include <stdio.h>
#include <math.h>
  
double f(double x)
{
    return cos(x) - x*x*x;
}
  
double SecantMethod(double xn_1, double xn, double e, int m)
{
    int n;
    double d;
    for (n = 1; n <= m; n++)
    {
        d = (xn - xn_1) / (f(xn) - f(xn_1)) * f(xn);
        if (fabs(d) < e)
            return xn;
        xn_1 = xn;
        xn = xn - d;
    }
    return xn;
}
  
int main(void)
{
    printf("%0.15f\n", SecantMethod(0, 1, 5E-11, 100));
    return 0;
}

After running this code, the final answer is approximately 0.865474033101614. The initial, intermediate, and final approximations are listed below:

x_0 = 0  \,\!
x_1 = 1  \,\!
x_2 = 0.685073357326045  \,\!
x_3 = 0.841355125665652  \,\!
x_4 = 0.870353470875526  \,\!
x_5 = 0.865358300319342  \,\!
x_6 = 0.865473486654304  \,\!
x_7 = 0.865474033163012  \,\!
x_8 = 0.865474033101614  \,\!

The following graph shows the function f in red and the last secant line in blue. In the graph, the x-intercept of the secant line seems to be a good approximation of the root of f.

Image:Secantmethod_jaredwf.png
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice