[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Make function values in root finding algorithms accessible
From: |
Christian Krueger |
Subject: |
Make function values in root finding algorithms accessible |
Date: |
Fri, 7 May 2021 18:32:12 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
Hi,
I am using the root finding algorithms (mainly brent), and I realized
that it's not possible (at least not straightforwardly intended)
1) to provide function values when initializing the root solver or
2) to retrieve the function values at x_lower and x_upper after an iteration
directly from the methods.
I attach a patch (as a diff to commit e38f2146) which implements the
first of those two things I mentioned. Basically, besides the existing
function gsl_root_fsolver_set(...) it provides another such function
gsl_root_fsolver_set2(..., f_lower, f_upper) which allows to also
provide the function values at x_lower and x_upper and in return skips
the function evaluation in the initialization routine.
I don't think there is another way to implement this because my main
intention is to get rid of the two (in my case costly) function evaluations.
Explanation why I want this:
Evaluating my function f(x), of which I want to find a root, takes a few
minutes time (here, f(x) is a characteristic value of the solution of an
elliptic PDE). Furthermore, I don't know a priori what a good choice of
x_lower and x_upper is. I have to iterate first through some generic
interval before I can start the Brent search; this means that I have
already calculated f(x_lower) and f(x_upper). The Brent initialization
would calculate those values again and waste a few minutes time.
In the same way, I will write a patch that allows me to access the
function value at the end of the Brent iteration, rather than evaluating
f(x) yet another time. In the end, those changes would allow me to save
20% - 30% computational time.
If this patch is any interesting, I'm happy for it to be implemented in
GSL and I'm also happy to make changes (e.g. a nicer name as *set2() is
not very inventive or do the same for the fdfsolver methods) beforehand.
Christian
gsl_root_fsolver_set2.patch
Description: Text document
OpenPGP_0x5D5587E0B7C49590.asc
Description: application/pgp-keys
OpenPGP_signature
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Make function values in root finding algorithms accessible,
Christian Krueger <=