From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Gough To: Andrew W Steiner Cc: gsl-discuss@sources.redhat.com Subject: Re: Multi-dimensional root finding Date: Wed, 19 Dec 2001 13:20:00 -0000 Message-id: <15226.25086.45908.98721@debian> References: X-SW-Source: 2001/msg00396.html 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