Next: , Previous: , Up: Nonlinear Least-Squares Fitting   [Index]

39.6 Finite Difference Jacobian

For the algorithms which require a Jacobian matrix of derivatives of the fit functions, there are times when an analytic Jacobian may be unavailable or too expensive to compute. Therefore GSL supports approximating the Jacobian numerically using finite differences of the fit functions. This is typically done by setting the relevant function pointers of the gsl_multifit_function_fdf data type to NULL, however the following functions allow the user to access the approximate Jacobian directly if needed.

Function: int gsl_multifit_fdfsolver_dif_df (const gsl_vector * x, const gsl_vector * wts, gsl_multifit_function_fdf * fdf, const gsl_vector * f, gsl_matrix * J)

This function takes as input the current position x, weight vector wts and function values computed at the current position f, along with fdf which specifies the fit function and parameters and approximates the n-by-p Jacobian J using forward finite differences: J_ij = sqrt(w_i) d f_i(x) / d x_j = sqrt(w_i) (f_i(x + h_j e_j) - f_i(x)) / h_j. where h_j = \epsilon |x_j|, and \epsilon is the square root of the machine precision GSL_DBL_EPSILON.

Function: int gsl_multifit_fdfsolver_dif_fdf (const gsl_vector * x, gsl_multifit_function_fdf * fdf, gsl_vector * f, gsl_matrix * J)

This function is deprecated and will be removed in a future release.