public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Re: Multi-dimensional root finding
  2001-12-19 13:20 Multi-dimensional root finding Andrew W Steiner
@ 2001-12-19 13:20 ` Brian Gough
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw)
  To: Andrew W Steiner; +Cc: gsl-discuss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Multi-dimensional root finding
@ 2001-12-19 13:20 Andrew W Steiner
  2001-12-19 13:20 ` Brian Gough
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew W Steiner @ 2001-12-19 13:20 UTC (permalink / raw)
  To: gsl-discuss

Hello !

	The equations that I need to solve often have regions where the
functions are not well defined. For this reason, it is natural to want a
root-finding algorithm to have some sort of prescription to deal with an
attempted step which takes the input vector outside the function's domain.
	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 could place a gsl_vector inside the function parameters so that
I could store the last attempt, but that seems like a rather ugly.
	One way out of this would be to ensure that the solver retained a
copy of the last attempted step. Do you think that this might be
justified?

Thanks,
Andrew W. Steiner
Nuclear Theory Group
Department of Physics and Astronomy
State University of New York at Stony Brook
http://tonic.physics.sunysb.edu/~asteiner




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-12-19 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-19 13:20 Multi-dimensional root finding Andrew W Steiner
2001-12-19 13:20 ` Brian Gough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).