### 39.5 Providing the Function to be Minimized

You must provide n functions of p variables for the minimization algorithms to operate on. In order to allow for arbitrary parameters the functions are defined by the following data types:

Data Type: gsl_multifit_function

This data type defines a general system of functions with arbitrary parameters.

`int (* f) (const gsl_vector * x, void * params, gsl_vector * f)`

this function should store the vector result f(x,params) in f for argument x and arbitrary parameters params, returning an appropriate error code if the function cannot be computed.

`size_t n`

the number of functions, i.e. the number of components of the vector f.

`size_t p`

the number of independent variables, i.e. the number of components of the vector x.

`void * params`

a pointer to the arbitrary parameters of the function.

Data Type: gsl_multifit_function_fdf

This data type defines a general system of functions with arbitrary parameters and the corresponding Jacobian matrix of derivatives,

`int (* f) (const gsl_vector * x, void * params, gsl_vector * f)`

this function should store the vector result f(x,params) in f for argument x and arbitrary parameters params, returning an appropriate error code if the function cannot be computed.

`int (* df) (const gsl_vector * x, void * params, gsl_matrix * J)`

this function should store the n-by-p matrix result J_ij = d f_i(x,params) / d x_j in J for argument x and arbitrary parameters params, returning an appropriate error code if the function cannot be computed. If an analytic Jacobian is unavailable, or too expensive to compute, this function pointer may be set to NULL, in which case the Jacobian will be internally computed using finite difference approximations of the function f.

`size_t n`

the number of functions, i.e. the number of components of the vector f.

`size_t p`

the number of independent variables, i.e. the number of components of the vector x.

`void * params`

a pointer to the arbitrary parameters of the function.

`size_t nevalf`

This does not need to be set by the user. It counts the number of function evaluations and is initialized by the `_set` function.

`size_t nevaldf`

This does not need to be set by the user. It counts the number of Jacobian evaluations and is initialized by the `_set` function.

Note that when fitting a non-linear model against experimental data, the data is passed to the functions above using the params argument and the trial best-fit parameters through the x argument.