Status: New
Owner: pr...@goodok.ru
Labels: Type-Defect Priority-Medium Polynomial Simplify

New issue 2245 by pr...@goodok.ru: assumption while canceling the polynomials
http://code.google.com/p/sympy/issues/detail?id=2245

Consider simplification:

    >>> a = (x**2 - 3*x + 2)/(x - 1)
    >>> a.cancel()
    -2 + x

It seems that result is correct: `(x**2 - 3*x + 2)` is equal to `(x - 1)*(x - 2)`,
so `(x - 1)` is canceling, and `(x - 2)` is obtained.

But no one told to the SymPy that `x` might not to be equals to the one.

And mathematically, it brings the incorrect behavior, when someone wants to consider the value of expression at some point:

    >>> a.subs(x, 1)
    nan
    >>> a.cancel().subs(x, 1)
    -1

The answer must be `nan` in both.

Or, while solving equation:

    >>> solve((x**2 - 3*x + 2)/(x - 1))
    [1, 2]

The right answer is 2 only.

For this aims, it seems that would be convenient a few variants:

1) while simplification like cancel, return the `Piecewise`:
    E.g.:
    >>> a.cancel()
    Piecewise(-2 + x, x<>1)

2) while simplification set assumption about `x` somehow:
    E.g.:
    >>> a.cancel(a, assume=(x<>1) )
    -2 + x

    >>> a.cancel(a, assume=(x==1) )
    nan

The same with simplify.

or use assumption attached to `x` symbol.

It seems that 1) is easy, and 2) can use 1) implementation.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to