Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Namespaces | Functions
MathUtils_Deriv.hxx File Reference
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <MathUtils_Core.hxx>
#include <cmath>

Namespaces

namespace  MathUtils
 Modern math solver types and result structures.
 

Functions

template<typename Function >
bool MathUtils::CentralDifference (Function &theFunc, double theX, double &theDeriv, double theStep=1.0e-8)
 Central difference derivative approximation for scalar functions. f'(x) ~= (f(x+h) - f(x-h)) / (2h) Accuracy: O(h^2)
 
template<typename Function >
bool MathUtils::ForwardDifference (Function &theFunc, double theX, double theFx, double &theDeriv, double theStep=1.0e-8)
 Forward difference derivative (one-sided). f'(x) ~= (f(x+h) - f(x)) / h Accuracy: O(h) Useful when central difference is not possible (e.g., at boundaries).
 
template<typename Function >
bool MathUtils::NumericalGradient (Function &theFunc, math_Vector &theX, math_Vector &theGrad, double theStep=1.0e-8)
 Numerical gradient using central differences for N-D functions. df/dx[i] ~= (f(x + h[i]*e[i]) - f(x - h[i]*e[i])) / (2*h[i])
 
template<typename Function >
bool MathUtils::NumericalGradientAdaptive (Function &theFunc, math_Vector &theX, math_Vector &theGrad, double theRelStep=1.0e-8)
 Numerical gradient with adaptive step size. Uses step proportional to |x[i]| for better conditioning.
 
template<typename Function >
bool MathUtils::NumericalJacobian (Function &theFunc, math_Vector &theX, math_Matrix &theJac, double theStep=1.0e-8)
 Numerical Jacobian matrix for vector-valued functions. J[i,j] = dF[i]/dx[j] ~= (F[i](x + h[j]*e[j]) - F[i](x - h[j]*e[j])) / (2*h[j])
 
template<typename Function >
bool MathUtils::NumericalHessian (Function &theFunc, math_Vector &theX, math_Matrix &theHess, double theStep=1.0e-5)
 Numerical Hessian matrix using finite differences. H[i,j] = d^2f/dx[i]dx[j] Uses central differences on gradient.
 
template<typename Function >
bool MathUtils::SecondDerivative (Function &theFunc, double theX, double theFx, double &theD2f, double theStep=1.0e-5)
 Second derivative using central difference. f''(x) ~= (f(x+h) - 2f(x) + f(x-h)) / h^2.