Internally, there is no difference between 1/(x + 1)**2 and (x + 1)**-2. There is no class in SymPy that represents division. 1/x is represented internally as just Pow(x, -1).
If all you care about is printing, then I recommend you modify the printer. Which printer are you using? What you need to do is subclass the appropriate printer and override the _print_Pow method. Aaron Meurer On Sun, Jun 16, 2013 at 11:40 PM, Ben Lucato <[email protected]> wrote: > If I have code like so: > > x = sympy.Symbol('x') > y = 1 / (x + 1)**2 > > it evaluates to > y = (x + 1)**(-2) > > > is there a way to prevent that happening and have it remain as 1 / (x + > 1)**2. > > **** OR: alternatively, is there a way to retrieve 1 / (x + 1)**2 from the > canonical form? I've looked at the docs and searched in this google group > but haven't found relevant discussions. The reason I want to do this is for > printing purposes > > -- > 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. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
