/* ---------------------------------------------------------------------- ** Figure 23.8 The root.h header file. */ #ifndef ROOT #define ROOT /* Constants for root finders. ------------------------------------------ ** Return when approximation is within EPS of root. */ #define EPS 1.0e-4 /* Numbers with smaller magnitude than this will be treated as zero. */ #define LIMIT 1.0e-10 /* Loop cutoff for secant method */ #define MAX_ITER 50 /* ---------------------------------------------------------------------- ** error codes returned by the roots modules and used by main(). */ typedef enum { ROOT_OK, NO_ROOT, BAD_INITIAL_POINTS, HORIZONTAL, TOO_MANY_ITERATIONS } er_type; /* ---------------------------------------------------------------------- ** Table of error messages; used by main(). */ static string const errmsg[] = { "root found", "no root in interval", "initial points too close together", "secant almost horizontal", "iteration limit exceeded" }; /* ---------------------------------------------------------------------- ** root-finding methods called by main(). */ er_type secant( double x1, double x2, double *rootp ); er_type bisect( double xlow, double xup, double *rootp );