Re: [boost] [math] Does any one interesting in calculating derivative for a expression automatically?

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.
Bruno

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

Hi,
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.
Yes there would be a special version and maybe several versions for each function. For example a binary function would have a rt/rt version if both arguments are runtime, ct/rt if the first one is compile-time, rt/ct if the second one is compile-time, and a ct/ct metafunction is both are compile-time. A compile-time argument would be either a literal constant (int_<X>) or an expression whose terminals are only literal constants. It's a huge work I know, but the exercise is pretty interesting :-)
BTW: I do not know how to upload source to this system, do you know how to do that?
You can ask a sandbox SVN access and work in it, or upload a zip to the Boost Vault. The following discussion from Boost-users seems to be related to what you're trying to do: http://article.gmane.org/gmane.comp.lib.boost.user/44237 Bruno
participants (3)
-
Bruno Lalande
-
Chris Hamilton
-
Dongfei Yin