Hi,
On 8 October 2014 12:05, <[email protected]> wrote:
> Is there any function in SymPy can take this TEX command as an input
>
> (-6x^2-x-7)(2x^3+3x^2-2x-5)
>
> to find the derivative?
I wanted to suggest a mathematica parser for this:
In [1]: import sympy.parsing.mathematica as m
In [2]: m.parse("(-6x^2-x-7)(2x^3+3x^2-2x-5)")
Out[2]: '(-6*x**2-x-7)*(2*x**3+3*x**2-2*x-5)'
In [3]: eval(_)
Out[3]:
⎛ 2 ⎞ ⎛ 3 2 ⎞
⎝- 6⋅x - x - 7⎠⋅⎝2⋅x + 3⋅x - 2⋅x - 5⎠
But there is bug there and the above output requires the following patch:
diff --git a/sympy/parsing/mathematica.py b/sympy/parsing/mathematica.py
index f86d59a..eeb12f7 100644
--- a/sympy/parsing/mathematica.py
+++ b/sympy/parsing/mathematica.py
@@ -39,7 +39,7 @@ def parse(s):
(r"\A\((.+)\)([\w\.].*)\Z", # Implied multiplication - (a)b
lambda m: "(" + parse(m.group(1)) + ")*" + parse(m.group(2))),
- (r"\A([\d\.]+)([a-zA-Z].*)\Z", # Implied multiplicatin - 2a
+ (r"\A([+-]?[\d\.]+)([a-zA-Z].*)\Z", # Implied multiplicatin - 2a
lambda m: parse(m.group(1)) + "*" + parse(m.group(2))),
(r"\A([^=]+)([\^\-\*/\+=]=?)(.+)\Z", # Infix operator
Mateusz
> --
> 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/04e0cbd4-5b6b-4418-8166-024a0729aff8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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/CAGBZUCZfJVXw27Rh0U31ST9tU%3DwZbkuqUS792ff364JYvdG%2BHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.