diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index b376b0c42..7b65bee9d 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -181,7 +181,18 @@ Expression * Power::shallowReduce(Context& context, AngleUnit angleUnit) { } #endif - /* Step 0: We look for square root and sum of square roots (two terms maximum + /* Step 0: if both operands are true complexes, the result is undefined. + * We can assert that evaluations is a complex as matrix are not simplified */ + Complex * op0 = static_cast *>(operand(0)->evaluate(context, angleUnit)); + Complex * op1 = static_cast *>(operand(1)->evaluate(context, angleUnit)); + bool bothOperandsComplexes = op0->b() != 0 && op1->b() != 0; + delete op0; + delete op1; + if (bothOperandsComplexes) { + return replaceWith(new Undefined(), true); + } + + /* Step 1: We look for square root and sum of square roots (two terms maximum * so far) at the denominator and move them to the numerator. */ Expression * r = removeSquareRootsFromDenominator(context, angleUnit); if (r) { diff --git a/poincare/test/simplify_easy.cpp b/poincare/test/simplify_easy.cpp index 755e43eef..5b57e16b9 100644 --- a/poincare/test/simplify_easy.cpp +++ b/poincare/test/simplify_easy.cpp @@ -511,6 +511,8 @@ QUIZ_CASE(poincare_simplify_easy) { assert_parsed_expression_simplify_to("A^0", "1"); assert_parsed_expression_simplify_to("(-3)^0", "1"); assert_parsed_expression_simplify_to("(R(2)*P + R(2)*X)/R(2)", "P+X"); + assert_parsed_expression_simplify_to("root(5^(-I)3^9,I)", "undef"); + assert_parsed_expression_simplify_to("I^I", "undef"); assert_parsed_expression_simplify_to("ln(1881676377434183981909562699940347954480361860897069)", "ln(1881676377434183981909562699940347954480361860897069)");