[sympy] speed of `replace` method

2014-06-03 Thread Andrei Berceanu
Hi guys, I am having trouble translating a one-liner from Mathematica to Sympy. The problem in question is explained in detail in this post: http://mathematica.stackexchange.com/questions/24794/symbolic-manipulation-of-functional-form I am currently trying to implement the second answer (becaus

[sympy] Re: Convert from a system of linear equations to a matrix

2014-06-05 Thread Andrei Berceanu
Was this implemented into sympy at any point? It could be the equivalent of Mathematica's CoefficientArrays function. On Thursday, November 14, 2013 5:56:22 AM UTC+1, Chris Smith wrote: > > I forgot that as_independent, without the as_Add=True flag will treat Muls > differently. The following wi

[sympy] pattern replacement for complex numbers and manual factorization

2014-06-05 Thread Andrei Berceanu
I have the following expression in sympy: "Add(Mul(Integer(-1), Integer(2), Symbol('g'), Symbol('psi^ss_1'), conjugate(Symbol('psi^ss_1'))), Mul(Integer(-1), Integer(2), Symbol('g'), Symbol('psi^ss_2'), conjugate(Symbol('psi^ss_2'))), Symbol('omega_2'), Mul(Integer(-1), Rational(1, 2), Pow(Symb

[sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
__ ___(-k + k₂) >> - 2⋅g⋅ψ_1__ss⋅ψ_1__ss - 2⋅g⋅ψ_2__ss⋅ψ_2__ss + ω₂ - ── >> 2⋅m >> >> In [3]: import re >> >> In [4]: eval(re.sub(r"(?PSymbol\('[^']+'\)

[sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
unchanged :) On Friday, June 6, 2014 1:07:26 PM UTC+2, F. B. wrote: > > > > On Friday, June 6, 2014 12:22:14 PM UTC+2, Andrei Berceanu wrote: >> >> Tnx! >> I think there is an error in the line (unbalanced paranthesis): >> >> return node.xreplace ({e: S.One, co

[sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
The unflatten_mul function factorized the 2, but not the g, i.e. it returns 2(g*|psi1|**2 + g*|psi2|**2) instead of 2g*(|psi1|**2 + |psi2|**2) On Friday, June 6, 2014 1:07:26 PM UTC+2, F. B. wrote: > > > > On Friday, June 6, 2014 12:22:14 PM UTC+2, Andrei Berceanu wrote: >>

Re: [sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
lo. > > All the receipts in this dicussion look very interesting.Maybe all of this > ones could be put in the official documentation. > > > Christophe BAL > > > 2014-06-06 13:34 GMT+02:00 Andrei Berceanu >: > >> The unflatten_mul function factorized the 2,

Re: [sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
Well yes, but that doesn´t change the fact that in Mathematica I can just do expr /.{x_*Conj[x_] -> Abs[x]^2} and it just works! On Friday, June 6, 2014 8:59:56 PM UTC+2, Christophe Bal wrote: > > A easy to use treeview will be a great tool. No ? > > > 2014-06-06 19:52 GMT+02:00 F. B. >: > >> I

Re: [sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-06 Thread Andrei Berceanu
(c)*Abs(d)**2 instead of the expected Abs(a)**2*Abs(b)**2 + Abs(c)**2*Abs(d)**2 It does what I want if I apply it two times, though. On Friday, June 6, 2014 9:49:22 PM UTC+2, Andrei Berceanu wrote: > > Well yes, but that doesn´t change the fact that in Mathematica I can just > do > >

[sympy] modify latex representation of user-defined function

2014-06-06 Thread Andrei Berceanu
I define a function gamma with the following code: from sympy import * x = Symbol('x') class gamma(Function): pass Its latex representation is print latex(gamma(x)) \Gamma\left(x\right) whereas I would like it to be \gamma\left(x\right) i.e. lowercase instead of capital. How can I achieve

Re: [sympy] Re: pattern replacement for complex numbers and manual factorization

2014-06-07 Thread Andrei Berceanu
By the way, I discovered another counter-example. Expressions like a**2*conjugate(a) are not transformed to a*abs(a)**2 About the friendly treeview class, I agree and hope its coming soon :) is it in the works? On Saturday, June 7, 2014 7:04:22 PM UTC+2, Christophe Bal wrote: > > Hello. > > >