There are at least 2 open source parsers for Mathematica code. The trivial stuff -- parsing x Sin[x] into x*sin(x) equivalent could be done by following directions in any intro to compilers book.
The rest of the stuff, which requires pattern matching, simplification, and a whole collection of specific commands all sitting inside the Mathematica rule-based evaluation mechanism ... well you won't get that by translating naively into python. It's like saying you can translate Lisp into C. Sure. But if you want to execute it, you need a whole bunch of stuff, like a garbage collector, arbitrary-precision integers, etc etc etc that you don't get by translating (+ a b) into a+b. On Wednesday, October 8, 2014 7:16:02 PM UTC-7, [email protected] wrote: > > you can try this expression for a test > (-6x^2-x-7)(2x^3+3x^2-2x-5) > > 在 2012年5月2日星期三UTC+8上午12时19分18秒,Aaron Meurer写道: >> >> This probably is doable, but we would need an actual parser in SymPy, >> which is the difficult part. If we had that, adding rules for >> Mathematica functions would ideally not be hard. See >> https://github.com/sympy/sympy/wiki/parsing for some ideas on parsing. >> >> More realistically, in >> http://code.google.com/p/sympy/issues/detail?id=161, it is suggested >> that for Maxima, Sage can be used. So I'm wondering if Sage, or maybe >> some other project has a parser for Mathematica that can put it in a >> form that SymPy can read, or at least on close. >> http://code.google.com/p/sympy/issues/detail?id=2864 is also related >> to this. >> >> Can you give an example of a Mathematica expression that you want to >> parse? >> >> Aaron Meurer >> >> On Tue, May 1, 2012 at 9:00 AM, [email protected] >> <[email protected]> wrote: >> > I doubt that any automated translation will produce quality code. The >> > style of Mathematica code is much more functional than the object >> > oriented python style. What you get from automatic translation will >> > not be human-readable (it will be python but very obfuscated). >> > >> > So I am very pessimistic. However if you have any success with this it >> > will be great for sympy. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "sympy" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> [email protected]. >> > For more options, visit this group at >> http://groups.google.com/group/sympy?hl=en. >> > >> > -- 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 http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/c775df6f-0fd4-414d-91ae-e5aa53fbd10f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
