# Proto :

Subject: Re: [proto] Manipulating an expression tree
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-04-08 08:37:27

On Fri, Apr 8, 2011 at 2:03 PM, Karsten Ahnert
<karsten.ahnert_at_[hidden]> wrote:
>>
>> Why not just write a transform that calculates one derivative and call
>> it N times to get the Nth derivative?
>
> Yes, that may be easy if you need two or three higher derivatives. For my
> application I need 10 to 20 or even more. I guess that currently no
> compiler can handle such large trees. For example, the simple product rule
> will result in 2^N terms.

Point taken. The expressions might get very long.
However, you could do an algeabric simplification transform (for
example constant propagation)
after every derivation step. Thus reducing the number of terms.

> But in the case of the product rule, one can use Leibnitz rule: If
> f(x)=g1(x) g2(x), then
> the N-th derivative of f(x) is sum_{k=0}^N binomial(N , k ) g1^k(x)
> g2^(N-k)(x). (g1^k is the k-th derivative of g1). This is exactly the
> point where I need intermediate values, to store previously calculated
> values of the derivatives of g1 and g2.
>
> Nevertheless, thank you for your example. I am a beginner with proto such
> that every example is highly illuminating.

Proto list run by eric at boostpro.com