A function defined by its derivative and its inverse.
This is an extension of Trigfun which allows a function to be defined by its derivative. In this case the derivative must be even, so that its integral is odd (and taken to be zero at the origin).
In addition, this class offers a flexible interface to computing the inverse of the function. If the inverse is only required at a few points
Example of use:
#include <iostream>
#include <iomanip>
#include <exception>
int main(
int argc,
const char*
const argv[]) {
try {
auto f = [k2] (double x) -> double
{
return 1/sqrt(1 - k2 *
Math::sq(sin(x))); };
cout << "Number of coefficients: " << tfe.NCoeffs() << "\n";
cout << "x tf(x) tf(x)-F(x)\n";
for (int i = 0; i <= 20; ++i) {
double x = i/10.0;
cout << x << " " << tfe(x) << " " << tfe(x) - ell.F(x) << "\n";
}
}
catch (const std::exception& e) {
std::cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
int main(int argc, const char *const argv[])
Header for GeographicLib::EllipticFunction class.
Header for GeographicLib::Trigfun class.
Elliptic integrals and functions.
A function defined by its derivative and its inverse.
Namespace for GeographicLib.
Definition at line 498 of file Trigfun.hpp.
| real GeographicLib::TrigfunExt::inv |
( |
real | z | ) |
const |
|
inline |
Evaluate the inverse of f
- Parameters
-
- Returns
- the value of x = f −1(z).
This compute the inverse using Newton's method with the derivate function fp supplied on construction. Initially, the starting guess is based on just the secular component of f(x). However, if ComputeInverse() is called, a rough Trigfun approximation to the inverse is found and this is used as the starting point for Newton's method.
Definition at line 577 of file Trigfun.hpp.
| void GeographicLib::TrigfunExt::ComputeInverse |
( |
| ) |
|
|
inline |
Compute a coarse Fourier series approximation of the inverse.
This is used to provide a better starting guess for Newton's method in inv(). Because ComputeInverse() is fairly expensive, this only makes sense if inv() will be called many times. In order to limit the expense in computing this approximate inverse, the number of Fourier componensts in the Trigfun for the inverse is limited to 3/2 of the number of components for f and the tolerance is set to the square root of the machine epsilon.
Definition at line 591 of file Trigfun.hpp.