You may also be interested in PyDy which generates optimized C code from
symbolic equations of motion. It uses cse under the hood for some of the
optimizations. PyDy directly works with the EoMs that are formed from
sympy.physics.mechanics.


Jason
moorepants.info
+01 530-601-9791

On Tue, Jun 7, 2016 at 9:16 PM, Aaron Meurer <[email protected]> wrote:

> Yep.  It's called cse().
>
> Aaron Meurer
>
>
> On Tuesday, June 7, 2016, Richard Fateman <[email protected]> wrote:
>
>> I think you are merely trying to find common subexpressions to speed up
>> evaluation.
>> There are lots of ways to do that.
>> The simplest is to precompute sin(t), cos(t), exp(t) or whatever
>> non-elementary
>> functions are involved.  Then you can also consider using horner's rule
>>  or
>> something like factor.  But there should be a common-subexpression
>> extraction
>> program around, no?
>> RJF
>>
>>
>> On Tuesday, June 7, 2016 at 11:39:20 AM UTC-7, brombo wrote:
>>>
>>> You might want to look at "New Foundations for Classical Mechanics" by
>>> David Hestenes and the rigid body rotor description of equations of motion.
>>>
>>>
>>> http://www.amazon.com/Foundations-Classical-Mechanics-Fundamental-Theories/dp/0792353021
>>>
>>> Should be in your school library.
>>>
>>>
>>>
>>> On Tue, Jun 7, 2016 at 1:14 PM, Aaron Meurer <[email protected]> wrote:
>>>
>>>> On Tue, Jun 7, 2016 at 8:58 AM, Michi S <[email protected]> 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)
>>>>
>>>> What output were you expecting here? I don't think the second factor
>>>> can be factorized. Note however that it can be simplified slightly if
>>>> you call trigsimp() on it.
>>>>
>>>> Aaron Meurer
>>>>
>>>> >
>>>> >
>>>> > I think, writing my own differentiation programm will be a little bit
>>>> to
>>>> > hard to solve my issue. Is there no other way besides factor() and
>>>> wiriting
>>>> > my own programm?
>>>> >
>>>> >
>>>> > Thank for your help!
>>>> >
>>>> >
>>>> > Am Mittwoch, 1. Juni 2016 15:34:28 UTC+2 schrieb Michi S:
>>>> >>
>>>> >> Hello!
>>>> >>
>>>> >> Is there a way to turn off the automatic simplification by
>>>> calculating the
>>>> >> derivative of a function? For example
>>>> >>
>>>> >> t = sym.symbols('t')
>>>> >> sym.Derivative( (sin(t)+exp(t))**3 , t ).doit()
>>>> >>
>>>> >> gives:
>>>> >> (exp(t) + sin(t))**2*(3*exp(t) + 3*cos(t))
>>>> >>
>>>> >> I need the result without any simplifications (in order to detect the
>>>> >> inner derivative for further calculations)
>>>> >>
>>>> >> Should be:
>>>> >> (exp(t) + sin(t))**2*3*(exp(t) + cos(t))
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups
>>>> > "sympy" group.
>>>> > To unsubscribe from this group and stop receiving emails from it,
>>>> send an
>>>> > email to [email protected].
>>>> > To post to this group, send email to [email protected].
>>>> > Visit this group at https://groups.google.com/group/sympy.
>>>> > To view this discussion on the web visit
>>>> >
>>>> https://groups.google.com/d/msgid/sympy/c5e1f95e-d5e2-4334-b302-39bd6e2ebc9b%40googlegroups.com
>>>> .
>>>> >
>>>> > For more options, visit https://groups.google.com/d/optout.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "sympy" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/sympy.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/sympy/CAKgW%3D6J%3D%3Dq4K17wnEvJFagB3URSbJO9CHAjhDJ%3D6a6iQdbZ-gA%40mail.gmail.com
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/d5c4525a-207a-4561-8c8e-8ec397bef4c3%40googlegroups.com
>> <https://groups.google.com/d/msgid/sympy/d5c4525a-207a-4561-8c8e-8ec397bef4c3%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BAmqPi5kMO6OtBeeeSmXZW_a7H6jC0zyeLCe77d03-Vw%40mail.gmail.com
> <https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BAmqPi5kMO6OtBeeeSmXZW_a7H6jC0zyeLCe77d03-Vw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAP7f1AisaP4TmiPMgHWUZ6HOFMXAqCaAV3JFL%3DaGyec8X9NOHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to