[sympy] Mathematica parser error ,bug ?

2014-11-27 Thread Lee Philip
test code here, error encountered there . http://codepad.org/hZEmO4Po what I want to do here is just convert it to a Python acceptable expression ,is there an easy way ? -- You received this message because you are subscribed to the Google Groups sympy group. To unsubscribe from this group

[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread Francesco Bonazzi
The regex parser fails to recognize in expressions such as *1/(4x-1)*, that 4x is 4 times x. I tried to call *M(1/(4x - 1))* and I got the following transformation: Integer (1 )/(Integer (4 )Symbol ('x' )-Integer (1 )) Obviously, Integer(4) Symbol('x') is not valid, as an asterisk (*) is

[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread Francesco Bonazzi
On Thursday, November 27, 2014 2:28:11 PM UTC+1, Francesco Bonazzi wrote: your_mathematica_expr = '((-2x+5)(4x-1)-4(-x^2+5x+1))/(4x-1)^2' new_math_expr = re.sub(([0-9])\ *([a-zA-Z]), \\1 * \\2, your_mathematica_expr) M(new_math_expr) Remember *import re* to use the *re* module. --

[sympy] Re: Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Francesco Bonazzi
On Thursday, November 27, 2014 12:19:04 AM UTC+1, James Crist wrote: All, In my spare time, I've been working on implementing a fast pattern matcher that accounts for Associative and Commutative symbols. It's going to be a while before I'm ready to release the code (it needs some serious

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Matthew Rocklin
Response in line On Wed, Nov 26, 2014 at 3:19 PM, James Crist crist...@umn.edu wrote: All, In my spare time, I've been working on implementing a fast pattern matcher that accounts for Associative and Commutative symbols. It's going to be a while before I'm ready to release the code (it

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Joachim Durchholz
Am 27.11.2014 um 16:47 schrieb Matthew Rocklin: - Is there need for nonlinear patterns? I plan to account for them, but they make the algorithm a bit more complicated. Nonlinear, AC pattern matching is NP complete. Linear AC pattern matches can be found in polynomial time. I haven't thought

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Joachim Durchholz
Am 27.11.2014 um 00:19 schrieb James Crist: All, In my spare time, I've been working on implementing a fast pattern matcher that accounts for Associative and Commutative symbols. It's going to be a while before I'm ready to release the code (it needs some serious cleanup), but as of now it is

[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread Richard Fateman
Does sympy really spell simplify without the L? On Thursday, November 27, 2014 5:29:16 AM UTC-8, Francesco Bonazzi wrote: On Thursday, November 27, 2014 2:28:11 PM UTC+1, Francesco Bonazzi wrote: your_mathematica_expr = '((-2x+5)(4x-1)-4(-x^2+5x+1))/(4x-1)^2' new_math_expr =

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Richard Fateman
There's a long history of pattern matching fast including work by Richard Jenks, (Scratchpad, predecessor of Axiom). The general scheme is to take a collection of patterns and compile them into a tree form so that partial results from pattern 1 can be used to improve speed on pattern 2, etc.

[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread Richard Fateman
answering my own question ... oh it is creating a sympy object, not simplifying. Sorry for the noise. 'RJF On Thursday, November 27, 2014 11:46:39 AM UTC-8, Richard Fateman wrote: Does sympy really spell simplify without the L? -- You received this message because you are subscribed to

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Joachim Durchholz
Am 27.11.2014 um 20:52 schrieb Richard Fateman: I don't know if your AC matcher is intended to be used for (say) arithmetic expressions or something else. But if arithmetic -- your stuff also needs to deal with identities. In that case if you don't handle identities, your matcher becomes far

Re:[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread redstone-cold
thanks for your kind help ! then it is surely a bug of the parser. At 2014-11-27 21:29:16, Francesco Bonazzi franz.bona...@gmail.com wrote: On Thursday, November 27, 2014 2:28:11 PM UTC+1, Francesco Bonazzi wrote: your_mathematica_expr ='((-2x+5)(4x-1)-4(-x^2+5x+1))/(4x-1)^2'

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread James Crist
Oh boy, this is going to be a big post. Responding to everyone in turn: *@Aaron:* Nonlinear, AC pattern matching is NP complete. Linear AC pattern matches can be found in polynomial time. Interesting. Why is that? Joachim got it right, having each match constrained by other matches,

[sympy] Re: Mathematica parser error ,bug ?

2014-11-27 Thread Lee Philip
I reported the bug here https://github.com/sympy/sympy/issues/8535 在 2014年11月27日星期四UTC+8下午8时42分53秒,Lee Philip写道: test code here, error encountered there . http://codepad.org/hZEmO4Po what I want to do here is just convert it to a Python acceptable expression ,is there an easy way ? --

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Aaron Meurer
On Thu, Nov 27, 2014 at 8:47 AM, Matthew Rocklin mrock...@gmail.com wrote: Response in line On Wed, Nov 26, 2014 at 3:19 PM, James Crist crist...@umn.edu wrote: All, In my spare time, I've been working on implementing a fast pattern matcher that accounts for Associative and Commutative

Re: [sympy] Writing a fast pattern matcher, updates and questions

2014-11-27 Thread Joachim Durchholz
Awesome. The papers I've read have been almost exclusively from the theorem proving world. I think you should be mostly fine working off these. Essentially it's all tree matching of some kind. Things will start to diverge as soon as domain specifics start to matter; it would be nice to have