diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 2b95ece7c..5e3652b2a 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -856,8 +856,13 @@ Expression Expression::CreateComplexExpression(Expression ra, Expression tb, Pre Expression norm; Expression exp; if (!isOneRa || isZeroTb) { - assert(!isNegativeRa); // norm cannot be negative - norm = ra; + /* Norm cannot be negative but can be preceded by a negative sign (for + * instance "-log(0.3)") which would lead to isNegativeRa = True. */ + if (isNegativeRa) { + norm = Opposite::Builder(ra); + } else { + norm = ra; + } } if (!isZeroRa && !isZeroTb) { Expression arg; diff --git a/poincare/test/simplification.cpp b/poincare/test/simplification.cpp index 9379274d4..86a546098 100644 --- a/poincare/test/simplification.cpp +++ b/poincare/test/simplification.cpp @@ -941,6 +941,7 @@ QUIZ_CASE(poincare_simplification_complex_format) { assert_parsed_expression_simplify_to("[[1,√(-1)]]", "[[1,ℯ^\u0012π/2×𝐢\u0013]]", User, Radian, Polar); assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Polar); assert_parsed_expression_simplify_to("atan(-2)", "atan(2)×ℯ^\u0012π×𝐢\u0013", User, Radian, Polar); + assert_parsed_expression_simplify_to("cos(42π)", "-cos(42×π)×ℯ^\x12π×𝐢\x13", User, Degree, Polar); // User defined variable assert_parsed_expression_simplify_to("a", "a", User, Radian, Polar);