On Tue, Jun 7, 2016 at 8:58 AM, Michi S <
misc...@gmail.com> wrote:
>
> Thanks for the answers! For the purpose of my master thesis I am trying to
> optimize the simulaion of helicopter dynamics. These dynamics are pretty
> complicated, which leads to huge equations for most states. In order to
> speed up the calculation I need to detect functions that where already
> evaluated. The inner derivative that is produced due to the chain rule is
> such a function, that I need to detect.
>
> factor() works only for the first derivative unfortunately. In the second
> and higher derivatives it does not factorize the inner derivates anymore:
>
> t = sym.symbols('t')
> diff( (sin(t)+exp(t))**5 , t )
>>> (exp(t) + sin(t))**4*(5*exp(t) + 5*cos(t))
>
> factor(diff( (sin(t)+exp(t))**5 , t ))
>>> 5*(exp(t) + sin(t))**4*(exp(t) + cos(t))
>
> factor(diff( (sin(t)+exp(t))**5 , t, t ))
>>> 5*(exp(t) + sin(t))**3*(5*exp(2*t) + 8*exp(t)*cos(t) - sin(t)**2 +
>>> 4*cos(t)**2)
can be factorized. Note however that it can be simplified slightly if