diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index c38076685..a9faf8020 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -268,21 +268,17 @@ Expression Logarithm::simpleShallowReduce(ExpressionNode::ReductionContext reduc Expression c = childAtIndex(0); Expression b = childAtIndex(1); - // log(x,1)->Undefined - if (b.type() == ExpressionNode::Type::Rational && static_cast(b).isOne()) { - return replaceWithUndefinedInPlace(); - } - // log(x,0) -> undef - if (b.type() == ExpressionNode::Type::Rational && static_cast(b).isZero()) { + // log(x,0) = log(x,1) = undef + if (b.type() == ExpressionNode::Type::Rational && (static_cast(b).isZero() || static_cast(b).isOne())) { return replaceWithUndefinedInPlace(); } if (c.type() == ExpressionNode::Type::Rational) { const Rational r = static_cast(c); - // log(0, x) = undef + // log(0,x) = undef if (r.isZero()) { return replaceWithUndefinedInPlace(); } - // log(1) = 0; + // log(1,x) = 0; if (r.isOne()) { Expression result = Rational::Builder(0); replaceWithInPlace(result); @@ -290,7 +286,7 @@ Expression Logarithm::simpleShallowReduce(ExpressionNode::ReductionContext reduc } } bool infiniteArg = c.recursivelyMatches(Expression::IsInfinity, reductionContext.context()); - // log(x,x)->1 with x != inf and log(inf,inf) = undef + // log(x,x) = 1 with x != inf, and log(inf,inf) = undef if (c.isIdenticalTo(b)) { Expression result = infiniteArg ? Undefined::Builder().convert() : Rational::Builder(1).convert(); replaceWithInPlace(result);