예제 #1
0
 def _eval_subs(self, old, new):
     if self==old: return new
     if isinstance(old, self.__class__) and self.base==old.base:
         coeff1,terms1 = self.exp.as_coeff_terms()
         coeff2,terms2 = old.exp.as_coeff_terms()
         if terms1==terms2: return new ** (coeff1/coeff2) # (x**(2*y)).subs(x**(3*y),z) -> z**(2/3*y)
     if isinstance(old, Basic.exp):
         coeff1,terms1 = old[0].as_coeff_terms()
         coeff2,terms2 = (self.exp * Basic.log(self.base)).as_coeff_terms()
         if terms1==terms2: return new ** (coeff1/coeff2) # (x**(2*y)).subs(exp(3*y*log(x)),z) -> z**(2/3*y)
     return self.base.subs(old, new) ** self.exp.subs(old, new)
예제 #2
0
 def _eval_as_leading_term(self, x):
     if not self.exp.has(x):
         return self.base.as_leading_term(x) ** self.exp
     return Basic.exp(self.exp * Basic.log(self.base)).as_leading_term(x)
예제 #3
0
 def _eval_derivative(self, s):
     dbase = self.base.diff(s)
     dexp = self.exp.diff(s)
     return self * (dexp * Basic.log(self.base) + dbase * self.exp/self.base)