mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 16:50:50 +01:00
[poincare/addition] Fix simplification with symbols
This commit is contained in:
@@ -389,11 +389,25 @@ Expression Addition::factorizeOnCommonDenominator(ExpressionNode::ReductionConte
|
||||
Power inverseDenominator = Power::Builder(commonDenominator, Rational::Builder(-1));
|
||||
Multiplication result = Multiplication::Builder(numerator, inverseDenominator);
|
||||
|
||||
/* To simplify the numerator and the denominator, we allow symbolic
|
||||
* computation: all unwanted symbols should have already disappeared by now,
|
||||
* and if we checked again for symbols we might find "paramter" symbols
|
||||
* disconnected from the parametered expression, which would be replaed with
|
||||
* undef.
|
||||
* Example: int((ℯ^(-x))-x^(0.5), x, 0, 3), when creating the common
|
||||
* denominator for the integrand. */
|
||||
ExpressionNode::ReductionContext contextWithSymbolicComputation = ExpressionNode::ReductionContext(
|
||||
reductionContext.context(),
|
||||
reductionContext.complexFormat(),
|
||||
reductionContext.angleUnit(),
|
||||
reductionContext.target(),
|
||||
true);
|
||||
|
||||
// Step 4: Simplify the numerator
|
||||
numerator.shallowReduce(reductionContext);
|
||||
numerator.shallowReduce(contextWithSymbolicComputation);
|
||||
|
||||
// Step 5: Simplify the denominator (in case it's a rational number)
|
||||
inverseDenominator.deepReduce(reductionContext);
|
||||
inverseDenominator.deepReduce(contextWithSymbolicComputation);
|
||||
|
||||
/* Step 6: We simplify the resulting multiplication forbidding any
|
||||
* distribution of multiplication on additions (to avoid an infinite loop).
|
||||
|
||||
Reference in New Issue
Block a user