The noncancellation is also about computational issues here. Automatically performing a cancel when an object is created could be potentially be very expensive. However, SymPy automatically cancels terms. Actually, it just combines exponents, so x*x becomes x**2, x/x**2 becomes 1/x and x/x becomes x**0 == 1 (these are all the same because SymPy treats 1/x as x**-1). Of course, anything with a nonpositive exponent does not make sense if x is 0.
Without knowing more of what you are doing, I can't give the best advice, but I would suggest just keeping the numerator and denominator separate. Aaron Meurer On Tue, May 13, 2014 at 7:08 PM, Eric Dennison <[email protected]> wrote: > When I type in an expression (x is a symbol): > >>>> (x**2-1)/(x-1) > (x**2 - 1)/(x - 1) > > One presumes this does not do any automatic cancellation because we don't > want to lose undefined behavior at x = 1. > > Then, > >>>> (x+1)*(x-1)/(x-1) > x + 1 > > or > >>>> (x-1)/(x-1) > 1 > > This oversimplifies the expression and loses the undefined behavior at x = > 1. > > Is it possible to create an expression like the latter that does not get > oversimplified? > > -- > 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/0b461aec-c962-407a-b886-48d7d464f4f8%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/CAKgW%3D6Khd08tCM%2BniLH_e8wxG2Jg3g4QbWFMSX65KzkDXeYrBg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
