mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 09:40:07 +01:00
[poincare] Power: fix sqrt(-1*i) != i*sqrt(i)
This commit is contained in:
@@ -553,7 +553,9 @@ Expression Power::shallowReduce(Context & context, Preferences::AngleUnit angleU
|
||||
}
|
||||
}
|
||||
// (a)^(1/2) with a < 0 --> i*(-a)^(1/2)
|
||||
// WARNING: this rule true only if a real (ex: (-1*i)^(1/2) != i*i^(1/2)
|
||||
if (!letPowerAtRoot
|
||||
&& childAtIndex(0).isReal(context, angleUnit)
|
||||
&& childAtIndex(1).type() == ExpressionNode::Type::Rational
|
||||
&& childAtIndex(1).convert<Rational>().isHalf())
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ QUIZ_CASE(poincare_power_simplify) {
|
||||
assert_parsed_expression_simplify_to("(12^4*x)^(0.5)", "144*R(x)");
|
||||
assert_parsed_expression_simplify_to("R(32)", "4*R(2)");
|
||||
assert_parsed_expression_simplify_to("R(-1)", "I");
|
||||
assert_parsed_expression_simplify_to("R(-1*R(-1))", "R(2)/2-R(2)/2*I");
|
||||
assert_parsed_expression_simplify_to("R(3^2)", "3");
|
||||
assert_parsed_expression_simplify_to("2^(2+P)", "4*2^P");
|
||||
assert_parsed_expression_simplify_to("R(5513219850886344455940081)", "2348024669991");
|
||||
|
||||
Reference in New Issue
Block a user