Node:Initializing the Solver, Next:, Previous:Root Finding Caveats, Up:One dimensional Root-Finding



Initializing the Solver

gsl_root_fsolver * gsl_root_fsolver_alloc (const gsl_root_fsolver_type * T) Function
This function returns a pointer to a newly allocated instance of a solver of type T. For example, the following code creates an instance of a bisection solver,
          const gsl_root_fsolver_type * T
            = gsl_root_fsolver_bisection;
          gsl_root_fsolver * s
            = gsl_root_fsolver_alloc (T);
          

If there is insufficient memory to create the solver then the function returns a null pointer and the error handler is invoked with an error code of GSL_ENOMEM.

gsl_root_fdfsolver * gsl_root_fdfsolver_alloc (const gsl_root_fdfsolver_type * T) Function
This function returns a pointer to a newly allocated instance of a derivative-based solver of type T. For example, the following code creates an instance of a Newton-Raphson solver,
          const gsl_root_fdfsolver_type * T
            = gsl_root_fdfsolver_newton;
          gsl_root_fdfsolver * s
            = gsl_root_fdfsolver_alloc (T);
          

If there is insufficient memory to create the solver then the function returns a null pointer and the error handler is invoked with an error code of GSL_ENOMEM.

int gsl_root_fsolver_set (gsl_root_fsolver * s, gsl_function * f, double x_lower, double x_upper) Function
This function initializes, or reinitializes, an existing solver s to use the function f and the initial search interval [x_lower, x_upper].

int gsl_root_fdfsolver_set (gsl_root_fdfsolver * s, gsl_function_fdf * fdf, double root) Function
This function initializes, or reinitializes, an existing solver s to use the function and derivative fdf and the initial guess root.

void gsl_root_fsolver_free (gsl_root_fsolver * s) Function
void gsl_root_fdfsolver_free (gsl_root_fdfsolver * s) Function
These functions free all the memory associated with the solver s.

const char * gsl_root_fsolver_name (const gsl_root_fsolver * s) Function
const char * gsl_root_fdfsolver_name (const gsl_root_fdfsolver * s) Function
These functions return a pointer to the name of the solver. For example,
          printf ("s is a '%s' solver\n",
                  gsl_root_fsolver_name (s));
          

would print something like s is a 'bisection' solver.