[sympy] defining a derivative

2016-10-14 Thread Riccardo Rossi
Dear List, i am writing since i would like to define the output of the derivative of a function, and i don't have a clue of how to achieve it to explain what i wish to do, let's consider the following script from sympy import * u = symbols('u') der = symbols('der') e = symbols('e',

Re: [sympy] defining a derivative

2016-10-14 Thread Aaron Meurer
If you want to define advanced things you need to subclass from Function rather than using symbols(cls=Function). For derivatives, you should define fdiff, which should return the derivative of the function without consideration of the chain rule. For example, search for "fdiff" in this file to

Re: [sympy] Re: Lambdify performance with repeated subexpressions

2016-10-14 Thread Aaron Meurer
To achieve this with lambdify you should call cse() first, then lambdify each expression separately. We ought to build a wrapper to make this easier (or a cse=True flag to lambdify). Aaron Meurer On Fri, Oct 14, 2016 at 11:06 AM, Björn Dahlgren wrote: > > > On Friday, 14

[sympy] Re: Lambdify performance with repeated subexpressions

2016-10-14 Thread Björn Dahlgren
On Friday, 14 October 2016 15:09:46 UTC+2, Albert Pető wrote: > > Hi, I plan to heavily use a function generated with lambdify from a sympy > expression which has repeated occurences of some subexpressions. > This functionality is available in symengine:

[sympy] Lambdify performance with repeated subexpressions

2016-10-14 Thread Albert Pető
Hi, I would like to evaluate certain functions created with lambdify. Those functions would come from rotations and would have a lot of trigonometric function invocations in them with the same parameters. For example, lets suppose that it would contain cos(a) many times. I plan to heavily use

[sympy] Lambdify performance with repeated subexpressions

2016-10-14 Thread Albert Pető
Hi, I plan to heavily use a function generated with lambdify from a sympy expression which has repeated occurences of some subexpressions. Specifically it will have a lot of cosine and sine expressions with the same arguments. I don't know if lambdify can notice this pattern and evaluate that

[sympy] Re: defining a derivative

2016-10-14 Thread Vicente Mataix Ferrándiz
What I am using right now dear Riccardo is the following: Suppose that my variable sigma(define as a symbol) depends of u, but at the same time this u is vectorial variable, which means for example in 3D the variable will be : u = [u_0, u_1, u_2], all the components of u are defined as