I’m trying to algebraic calculations where both the variable and the exponent are symbols. But it seems that sympy does not fully understand the meaning of law of exponents:
>>> from sympy import *
>>> u, n = symbols('u n')
>>> u**(2*n) / u**n # this is good
u**n
>>> u**n / u # not good
u**n/u
>>> u**n * u # not good
u*u**n
What can I do to get sympy to turn
u**n / u
into
u**(n-1)
and
u**n * u
into
u**(n+1)?
Thanks!