+/** Implementation of ex::diff() for a power.
+ * @see ex::diff */
+ex power::derivative(const symbol & s) const
+{
+ if (exponent.info(info_flags::real)) {
+ // D(b^r) = r * b^(r-1) * D(b) (faster than the formula below)
+ epvector newseq;
+ newseq.reserve(2);
+ newseq.push_back(expair(basis, exponent - _ex1()));
+ newseq.push_back(expair(basis.diff(s), _ex1()));
+ return mul(newseq, exponent);
+ } else {
+ // D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
+ return mul(power(basis, exponent),
+ add(mul(exponent.diff(s), log(basis)),
+ mul(mul(exponent, basis.diff(s)), power(basis, -1))));
+ }
+}
+
+int power::compare_same_type(const basic & other) const