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

2014-06-07 Thread Christophe Bal
Hello. >>> in Mathematica I can just do expr /.{x_*Conj[x_] -> Abs[x]^2} With an easy to use treeview class, I do not think that it will be too hard to implement a method that can acheive this kind of using something like expr.replace(x_*Conj[x_], Abs[x]^2) Christophe BAL -- You received this

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. > > >

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

2014-06-07 Thread F. B.
The point is that the current pattern matcher only matches exact subtrees starting at one node, i.e. the tree of that node has to be matched entirely, while in many cases partial subtree matches would be desired. In any case the expression to_abs can be further simplified. Try something like th

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

2014-06-07 Thread F. B.
Sorry instead of rl try to put lambda x: next(rl(x)) into the exhaust ( ... ) expression. -- 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 sympy+unsubscr...@googlegroup

Re: [sympy] Erroneous series expansion of tan(x)

2014-06-07 Thread Aaron Meurer
I think what you're getting is a generalized Lambert series. Notice that one of the terms is 1/x. Aaron Meurer On Wed, Jun 4, 2014 at 11:01 AM, su225 wrote: > Hello. I'm new to sympy and took the tutorial today. But I noticed the > following error. I'm glad to contribute to this project. > Where

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

2014-06-07 Thread Matthew Rocklin
> I think that SymPy needs a better term rewriting system. And also a better pattern matcher. @Franz Are you interested in doing work in this area? On Sat, Jun 7, 2014 at 10:39 AM, F. B. wrote: > Sorry instead of rl try to put lambda x: next(rl(x)) into the exhaust ( > ... ) expression. > > -

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

2014-06-07 Thread Matthew Rocklin
Also I'm glad to see people using strategies. I've since pulled it out to an external package. Although this wouldn't support SymPy tree traversals like bottom_up without slightly more work. https://github.com/logpy/strategies On Sat, Jun 7, 2014 at 6:38 PM, Matthew Rocklin wrote: > > I thin

Re: [sympy] Erroneous series expansion of tan(x)

2014-06-07 Thread Ondřej Čertík
The series exists, and has the 1/x term in general, but it is missing the shift by pi/2: http://www.wolframalpha.com/input/?i=tan%28x%29+series+at+x%3Dpi%2F2 So I think there is a bug. Ondrej On Sat, Jun 7, 2014 at 1:23 PM, Aaron Meurer wrote: > I think what you're getting is a generalized Lam

Re: [sympy] Re: Help with Vector

2014-06-07 Thread Matthew Rocklin
1. How do I ensure methods like 'trigsimp' work with these classes? Currently, passing a vector like *(sin(a)+cos(a))**2*i - j* to trigsimp returns the correct answer mathematically, _but_ the instance is of type Add (instead of the expected VectorAdd). How do I prevent this? I ran into this when

Re: [sympy] Erroneous series expansion of tan(x)

2014-06-07 Thread Richard Fateman
yes, there is a bug. the terms should start.. - 1/(x-pi/2) + (x-pi/2)/3 + On Saturday, June 7, 2014 9:02:19 PM UTC-7, Ondřej Čertík wrote: > > The series exists, and has the 1/x term in general, but it is missing > the shift by pi/2: > > http://www.wolframalpha.com/input/?i=tan%28x%29+se

Re: [sympy] Re: Help with Vector

2014-06-07 Thread Sachin Joglekar
I see your point. But in that case, would the API remain the same? What you suggest, would involve either- A. modifying the code for trigsimp itself or B. having a 'trigsimp' method in Vector itself (already done this) On Sun, Jun 8, 2014 at 11:26 AM, Matthew Rocklin wrote: > 1. How do I e