[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Necessity of providing f, df, _and_ fdf?
From: |
Martin Jansche |
Subject: |
Re: [Help-gsl] Necessity of providing f, df, _and_ fdf? |
Date: |
Sun, 25 Jan 2009 18:58:10 -0500 |
On Sat, Jan 24, 2009 at 16:31, Liam Healy <address@hidden> wrote:
> On Wed, Jan 21, 2009 at 10:06 AM, Brian Gough <address@hidden> wrote:
>> At Mon, 19 Jan 2009 18:20:56 -0500,
>> Liam Healy wrote:
>>> Is possible to change GSL to allow f & df _or_ fdf instead of "and",
>>> say providing a null pointer for the unneeded function. If that's
>>> already the case, can the documentation be made clear?
>>
>> Hello,
>>
>> To keep things simple using a NULL pointer is not supported -- the
>> recommended way is to make a small function fdf which calls f and df.
>>
>>> In a related puzzle, I find this statement about fdf hard to understand:
>>> "This function provides an optimization of the separate functions for
>>> f(x) and g(x)—it is always faster to compute the function and its
>>> derivative at the same time. "
>>> The user is providing the function, so whether it's an optimization or
>>> not depends on how it's written. It seems like an overstatement that
>>> it's "always" faster to compute the function and its derivative at the
>>> same time; I'm willing to believe it's (essentially) at least as fast
>>> perhaps.
>>
>> I was thinking that for analytic functions, at least, the function and
>> the derivative always have some terms in common so it is faster to
>> compute them together.
>
> This has certainly been true in my experience. But then why is it
> necessary to supply f and df separately?
Because the minimizer may only need f(x) or df(x) at certain times and
one may be much more expensive to compute than the other.
> Why not just have fdf as a single argument?
Nothing stops client code from writing f() such that it calls fdf()
and ignores the df part.
> What happens if f and/or df are not consistent with
> the corresponding values set by fdf?
Bad things, but nothing worse than what happens if df is inconsistent
with f when you call fdf(), i.e., you compute the wrong derivative.
The library cannot isolate you from bugs. It's up to client code to
assure/test correctness of its implementation.
-- mj
> Liam
>
>> --
>> Brian Gough
>>
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>