Psi4
Namespaces | Functions

Simple root finding methods

 (1) Bisection method
 (2) Newton's method
 (3) Secant method

. More...

#include <cstdio>
#include <cmath>

Namespaces

 psi
 Rotate a set of vectors around an arbitrary axis Vectors are rows of input matrix.
 

Functions

double psi::bisect (double(*function)(double), double low, double high, double tolerance, int maxiter, int printflag)
 
double psi::newton (double(*F)(double), double(*dF)(double), double x, double tolerance, int maxiter, int printflag)
 
double psi::secant (double(*F)(double), double x0, double x1, double tolerance, int maxiter, int printflag)
 

Detailed Description

Simple root finding methods

 (1) Bisection method
 (2) Newton's method
 (3) Secant method

.

David Sherrill 20 Jan 1994

We know the maximum error for the bisection method, so this is used as the convergence criterion. However, we only know the general behavior of the error for the other two methods; we do not have an absolute value bounding it at each step. Therefore use the difference between successive guesses as a convergence criterion in those two cases.

Note also how these three routines access the mathematical function in question. Rather than using an inline function (which would be faster, but would require recompilation each time), we pass the function to be solved as an argument to the three root-finding routines. This means that this module could be added to a library and it would not need to be recompiled for each specific function to be solved.