Expression simplify()

Possible simplifications:

  1. e^0 = 1
  2. e^1 = e
  3. e^(x*ln(y)) = y^x (usually easier to read for humans)

Source

Expression simplify() {
  Expression expSimpl = exp.simplify();

  if (_isNumber(expSimpl,0)) {
    return new Number(1); // e^0 = 1
  }

  if (_isNumber(expSimpl,1)) {
    return new Number(Math.E); // e^1 = e
  }

  if (expSimpl is Times && expSimpl.second is Ln) {
   Ln ln = expSimpl.second;
   return new Power(ln.arg, expSimpl.first); // e^(x*ln(y)) = y^x
  }

  return new Exponential(expSimpl);
}