Use simplify()

Aaron Meurer

On Fri, Oct 24, 2014 at 6:54 AM, redstone-cold <redstone-c...@163.com> wrote:
>
> Is there any way to simplify (-12*x - 1)*(2*x3 + 3*x2 - 2*x - 5) + (-6*x2 -
> x - 7)*(6*x2 + 6*x - 2) ? I want to get the final result ,not an
> intermediate one.
>
>
>
>
>
> At 2014-10-17 22:27:44, "Chris Smith" <smi...@gmail.com> wrote:
>
> The parser was fixed as indicated at
> http://stackoverflow.com/questions/26249993/6x2-x-72x33x2-2x-5-as-input-in-sympy
>
>>>> from sympy.parsing.mathematica import mathematica as m
>>>> m('(-6 * x**2 - x - 7) * (2 * x**3 + 3 * x**2 - 2 * x - 5)')
> (-6*x**2 - x - 7)*(2*x**3 + 3*x**2 - 2*x - 5)
>>>> _.diff(x)
> (-12*x - 1)*(2*x**3 + 3*x**2 - 2*x - 5) + (-6*x**2 - x - 7)*(6*x**2 + 6*x -
> 2)
>
>
>
> On Wednesday, October 8, 2014 8:42:16 AM UTC-5, Mateusz Paprocki wrote:
>>
>> Hi,
>>
>> On 8 October 2014 12:05,  <redsto...@163.com> 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 sympy+un...@googlegroups.com.
>> > To post to this group, send email to sy...@googlegroups.com.
>> > 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 a topic in the
> Google Groups "sympy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sympy/RoJ_o598B7Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> 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/94765cae-9366-4e3c-a64c-d7694104f038%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 sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> 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/5f2010a.1ee40.149420210e4.Coremail.redstone-cold%40163.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 sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
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/CAKgW%3D6J%2B-FXALezjyDqMALSpv09d%2Bn4mq%3DWWzF3nCRQeFi_r_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to