Root finding routines.
This header covers the routines for root finding.
The routine LALSBracketRoot() expands the specified domain until a root is contained. The routine LALDBracketRoot() is the same but for a double-precision function.
The routine LALSBisectionFindRoot() bisects the domain (which must contain one root) until the root is found with the desired accuracy. The routine LALDBisectionFindRoot() is the same but for a double-precision function.
Suppose we want to find the root of the function \(y = F(x;y_0) = y_0 + x^2\). Define the function:
Then use the following code to bracket and find the root \(x_0=1\) where \(F(x_0;y_0=-1)=0\):
This is an implementation of the root bracketing and bisection finding routines zbrac and rtbis in Numerical Recipes [22] .
Prototypes | |
| void | LALSBracketRoot (LALStatus *status, SFindRootIn *inout, void *params) |
| int | XLALDBracketRoot (REAL8(*y)(REAL8, void *), REAL8 *xmin, REAL8 *xmax, void *params) |
| void | LALDBracketRoot (LALStatus *status, DFindRootIn *inout, void *params) |
| void | LALSBisectionFindRoot (LALStatus *status, REAL4 *root, SFindRootIn *input, void *params) |
| REAL8 | XLALDBisectionFindRoot (REAL8(*y)(REAL8, void *), REAL8 xmin, REAL8 xmax, REAL8 xacc, void *params) |
| void | LALDBisectionFindRoot (LALStatus *status, REAL8 *root, DFindRootIn *input, void *params) |
Data Structures | |
| struct | SFindRootIn |
| These are function pointers to functions that map REAL4 numbers to REAL4 numbers. More... | |
| struct | DFindRootIn |
| These are function pointers to functions that map REAL8 numbers to REAL8 numbers. More... | |
Files | |
| file | FindRootTest.c |
| Tests the routines in FindRoot.h. | |
Error Codes | |
| #define | FINDROOTH_ENULL 1 |
| Null pointer. More... | |
| #define | FINDROOTH_EIDOM 2 |
| Invalid initial domain. More... | |
| #define | FINDROOTH_EMXIT 4 |
| Maximum iterations exceeded. More... | |
| #define | FINDROOTH_EBRKT 8 |
| Root not bracketed. More... | |
| void LALSBracketRoot | ( | LALStatus * | status, |
| SFindRootIn * | inout, | ||
| void * | params | ||
| ) |
Definition at line 29 of file FindRoot.c.
Definition at line 97 of file FindRoot.c.
| void LALDBracketRoot | ( | LALStatus * | status, |
| DFindRootIn * | inout, | ||
| void * | params | ||
| ) |
Definition at line 147 of file FindRoot.c.
| void LALSBisectionFindRoot | ( | LALStatus * | status, |
| REAL4 * | root, | ||
| SFindRootIn * | input, | ||
| void * | params | ||
| ) |
Definition at line 215 of file FindRoot.c.
| REAL8 XLALDBisectionFindRoot | ( | REAL8(*)(REAL8, void *) | y, |
| REAL8 | xmin, | ||
| REAL8 | xmax, | ||
| REAL8 | xacc, | ||
| void * | params | ||
| ) |
Definition at line 308 of file FindRoot.c.
| void LALDBisectionFindRoot | ( | LALStatus * | status, |
| REAL8 * | root, | ||
| DFindRootIn * | input, | ||
| void * | params | ||
| ) |
Definition at line 381 of file FindRoot.c.
| #define FINDROOTH_ENULL 1 |
Null pointer.
Definition at line 99 of file FindRoot.h.
| #define FINDROOTH_EIDOM 2 |
Invalid initial domain.
Definition at line 100 of file FindRoot.h.
| #define FINDROOTH_EMXIT 4 |
Maximum iterations exceeded.
Definition at line 101 of file FindRoot.h.
| #define FINDROOTH_EBRKT 8 |
Root not bracketed.
Definition at line 102 of file FindRoot.h.