Boost logo

Boost :

Subject: Re: [boost] [math] Does any one interesting in calculating derivative for a expression automatically?
From: John Maddock (john_at_[hidden])
Date: 2009-03-03 13:41:34


>> ignored.
>> d(d(_x * _y, _x), _y)(1.0); // f(x,y)=x*y, f ''xy(x,y)=0,
>> so here one or two argument are all OK.
>> and it can calculate derivative for some complicated expressions.
>> theoretically, it can calculate high derivative for a expression as
>> high as you want until the expression become zero.
>> I want to share it with others, but it is not so perfect now. I need
>> some suggestion to make it better.
>
> Take a look at Proto. http://www.boost.org/libs/proto

Good idea, and this is all very neat, but I see a couple of issues:

1) Compile times for a compile time derivative is likely to be slow?
2) Isn't it easier to just calculate the derivative within a symbolic math
package and then cut and paste the result into your code (Yacas is free for
example)?
3) What happens for very complex expressions? Can the compile time code
simplify the resulting derivative so that it is optimally evaluated? Most
symbolic math packages will have a "simplify" function that does just that,
without it, code might be very inefficient to evaluate, with it, compile
times might be way too long :-(

Regards, John.


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