The rule is if the terms are the same up to a rational (or floating
point) coefficient, then they are combined. So for example,

>>> x + 2*x
3*x

The coefficients are 1 and 2, respectively, and the remainder is x in
each case, so they are combined.

>>> 1/x + 2/x
3/x

Same thing.

>>> 1/x + 2/y
1/x + 2/y

The coefficients are 1 and 2, but the rest for the first is 1/x and
the rest for the second is 1/y.

A similar rule is applied for multiplication and powers. x**a*x**b is
combined to x**(a + b) only if a and b are the same, up to a
rational/floating point coefficient.

Aaron Meurer

On Wed, Jun 12, 2013 at 10:27 AM, Chris Smith <smi...@gmail.com> wrote:
> together brings terms together over a common denominator as the docstring
> explains. If you are just adding or subtracting terms this is not an
> automatic operation unless both terms are Rationals, hence
>
> 1/2 + 1/3 -> 5/6 but 1/x + 1/y -> unchanged
>
> /c
>
> --
> 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?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to