From 7138a48a5256a7c70abfc7bdd3ee552b38fc4db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 4 Dec 2017 10:59:31 +0100 Subject: [PATCH] [poincare] In Logarithm: when looking for expressions of type e^ln(x), look also for expression of type e^(ln(x)) Change-Id: Ifeec5fbdd3866269903d63fd7ce55f46815449f3 --- poincare/src/logarithm.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index 43cea1765..52d275150 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -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(powerOperand0)->isTen()) { return true;