SDDSlib
|
Implements the zeroInterp function for finding zeros of a function using successive interpolation. More...
#include <math.h>
#include <stdio.h>
#include "mdb.h"
Go to the source code of this file.
Macros | |
#define | sign(x) |
Functions | |
double | zeroInterp (double(*fn)(), double value, double x_i, double x_f, double dx, double _zero) |
Finds the zero of a function within a specified interval using successive interpolation. | |
Implements the zeroInterp function for finding zeros of a function using successive interpolation.
Definition in file zeroInterp.c.
#define sign | ( | x | ) |
Definition at line 20 of file zeroInterp.c.
double zeroInterp | ( | double(* | fn )(), |
double | value, | ||
double | x_i, | ||
double | x_f, | ||
double | dx, | ||
double | _zero ) |
Finds the zero of a function within a specified interval using successive interpolation.
This function attempts to find a value x
such that fn(x)
is approximately equal to the given value
. It uses an iterative interpolation method to locate the zero within the interval [x_i, x_f]
.
fn | Pointer to the function for which the zero is to be found. |
value | The target value to solve for, i.e., find x such that fn(x) = value . |
x_i | Initial value of the independent variable (start of the interval). |
x_f | Final value of the independent variable (end of the interval). |
dx | Step size to use when searching the interval. |
_zero | Acceptable tolerance for the zero, determining when to stop the interpolation. |
x
value where fn(x)
is approximately equal to value
, or x_f + dx
if no zero is found within the interval. Definition at line 37 of file zeroInterp.c.