pysolvegn.build_numerical_jacobian#

build_numerical_jacobian(residual_func, method='central', epsilon=1e-08)[source]#

Build a Jacobian function for the Gauss-Newton optimization by computing the numerical derivatives of the residual function with respect to the parameters using finite differences.

With the "central" method, the Jacobian is computed as:

\[J_{i,j} = \frac{R_i(p + \epsilon e_j) - R_i(p - \epsilon e_j)}{2\epsilon}\]

With the "forward" method, the Jacobian is computed as:

\[J_{i,j} = \frac{R_i(p + \epsilon e_j) - R_i(p)}{\epsilon}\]

With the "backward" method, the Jacobian is computed as:

\[J_{i,j} = \frac{R_i(p) - R_i(p - \epsilon e_j)}{\epsilon}\]
Parameters:
  • residual_func (Callable) – A function that computes the residuals for a given set of parameters. The function should take a 1D array of parameters as input and return a 1D array of residuals.

  • method (str, optional (default="central")) – The finite difference method to use for computing the numerical Jacobian. Must be one of “central”, “forward”, or “backward”.

  • epsilon (Real, optional (default=1e-8)) – A small perturbation value used for finite difference approximation of the Jacobian.

Returns:

  • jacobian_func (Callable) – A function that computes the Jacobian matrix for a given set of parameters. The function takes a 1D array of parameters as input and returns a 2D array representing the Jacobian matrix.

  • Version

  • ——-

  • - 0.0.1 (Initial version.)

  • - 0.0.2 (Renamed from build_jacobian to build_numerical_jacobian for clarity.)

  • - 1.0.0 (Added support for forward, backward, and central finite difference methods for numerical Jacobian computation.)

Return type:

Callable