[poincare] In Logarithm: when looking for expressions of type e^ln(x),

look also for expression of type e^(ln(x))

Change-Id: Ifeec5fbdd3866269903d63fd7ce55f46815449f3
This commit is contained in:
Émilie Feral
2017-12-04 10:59:31 +01:00
parent d726d582c9
commit 7138a48a52

View File

@@ -125,8 +125,19 @@ Expression * Logarithm::shallowReduce(Context& context, AngleUnit angleUnit) {
}
bool Logarithm::parentIsAPowerOfSameBase() const {
if (parent()->type() == Type::Power && parent()->operand(1) == this) {
const Expression * powerOperand0 = parent()->operand(0);
// We look for expressions of types e^ln(x) or e^(ln(x)) where ln is this
const Expression * parentExpression = parent();
bool thisIsPowerExponent = parentExpression->type() == Type::Power ? parentExpression->operand(1) == this : false;
if (parentExpression->type() == Type::Parenthesis) {
const Expression * parentParentExpression = parentExpression->parent();
if (parentExpression == nullptr) {
return false;
}
thisIsPowerExponent = parentParentExpression->type() == Type::Power ? parentParentExpression->operand(1) == parentExpression : false;
parentExpression = parentParentExpression;
}
if (thisIsPowerExponent) {
const Expression * powerOperand0 = parentExpression->operand(0);
if (numberOfOperands() == 1) {
if (powerOperand0->type() == Type::Rational && static_cast<const Rational *>(powerOperand0)->isTen()) {
return true;