This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Multi-dimensional root finding
- To: Andrew W Steiner <asteiner at tonic dot physics dot sunysb dot edu>
- Subject: Re: Multi-dimensional root finding
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Wed, 15 Aug 2001 12:50:22 +0100 (BST)
- Cc: gsl-discuss at sources dot redhat dot com
- References: <Pine.LNX.4.21.0108150006240.26047-100000@tonic.physics.sunysb.edu>
Andrew W Steiner writes:
> I was attempting to implement such a prescription using the gsl
> code, but I have run into a problem. Since the solver retains only the
> best guess at present and not the last attempted step, it is difficult for
> me to recover from a GSL_EBADFUNC error. When I do know the last attempted
> step, I often try to cut it in half to see if the smaller step will remain
> in the domain. (This particular prescription is probably naive, but
> sufficient for the kinds of functions that I work with.)
I recommend making a user-defined algorithm to do this. User defined
algorithms can be called in the same way as the existing ones in the
library.
For example, you can grab the file gnewton.c, put it in your
application and rename all its functions to 'mygnewton_'. Then you
will have a mygnewton_ solver. If you modify this to back-track
instead of returning GSL_EBADFUNC it should do what you want.
Note that you can write a polyalgorithm which uses a second solver
(e.g. mygnewton) like this,
do {
status = gsl_multiroot_fdfsolver_iterate (s1);
if (status == GSL_EBADFUNC) {
/* Try alternate solver s2 on failed step */
gsl_multiroot_fdfsolver_set (s2, fdf, s1->x);
status = gsl_multiroot_fdfsolver_iterate (s2);
gsl_multiroot_fdfsolver_set (s1, fdf, s2->x);
}
....
}
regards
Brian Gough