Boost logo

Boost :

Subject: Re: [boost] [math] Does any one interesting in calculating derivative for a expression automatically?
From: Chris Hamilton (chamilton_at_[hidden])
Date: 2009-03-04 06:43:48


> Hi Bruno,
> thank you for your interesting, I will try to use proto, I never use
> it before.
>
> yes, It's technically feasible. but the type of all the symbol in the
> expression can not be the build-in type.
> and gamma function should be a special version.
> integral is more difficult than derivative, else, to calculate the
> volume will be more easier.
> to simplify the expression is a interesting work. especially in
> compile time.
> BTW: I do not know how to upload source to this system, do you know
> how to do that?
>
> Dongfei.
>> >From my point of view, the main interest would be to compute
>> expressions containing some compile-time values provided by the user.
>> For example I want to calculate the volume of a hypersphere which is:
>> (pi^(N/2)*r^N) / gamma(N/2 + 1), with dimension N known at
>> compile-time. If the user happens to work only with N=2, that is
>> circles, I want the resulting expression to be as effective as a
>> hand-written pi*r^2 (the volume of a hypersphere<2> is the area of a
>> circle). It's technically feasible.

While not strictly the same, there are all sorts of C++ based packages
out there for doing this kind of thing. The approach taken is
'automatic differentiation', and it basically works by applying the
chain rule to every individual step in a sequence of operations. One
approach to doing this is through operator overloading, and replacing
the underlying 'double' class with something that maintains the
appropriate state. There are already some nice open source packages out
there for doing this. More info:

http://en.wikipedia.org/wiki/Automatic_differentiation
http://www.autodiff.org/
http://www.coin-or.org/CppAD/

Cheers,

Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk