Skip to content

Commit

Permalink
WIP #856 improve Together - handle "inverse denominator number"
Browse files Browse the repository at this point in the history
>> 1/(sqrt[7] - 2 sqrt[2]) + 1/(sqrt[7] + 2 sqrt[2]) // Together
-2*Sqrt(7)
  • Loading branch information
axkr committed Nov 12, 2023
1 parent e8ef761 commit aa2166e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4365,9 +4365,6 @@ private static IExpr togetherPlus(IAST plusAST) {
return F.C0;
}
if (!exprDenominator.isOne()) {
if (exprDenominator.isMinusOne()) {
return exprNumerator.negate();
}
try {
IExpr[] result = cancelGCD(exprNumerator, exprDenominator);
if (result != null) {
Expand All @@ -4380,6 +4377,9 @@ private static IExpr togetherPlus(IAST plusAST) {
} catch (JASConversionException jce) {
LOGGER.debug("Together.togetherPlus()", jce);
}
if (exprDenominator.isNumber()) {
return exprDenominator.inverse().times(exprNumerator);
}
return F.Times(exprNumerator, F.Power(denom, -1));
}
return exprNumerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public LinearAlgebraTestCase(String name) {

public void testAdjugate() {
check("Adjugate({{E^5, 1, 3 - 2*I}, {1 + I, Pi/2, 5}, {0, 1, -4}})", //
"{{2*(-5/2-Pi),7-I*2,(3/2-I)*(30/13+I*20/13-Pi)},\n" //
"{{-2*(5/2+Pi),7-I*2,(3/2-I)*(30/13+I*20/13-Pi)},\n" //
+ " {4+I*4,-4*E^5,5*(1+I*1/5-E^5)},\n" //
+ " {1+I,-E^5,1/2*(-2-I*2+E^5*Pi)}}");
// https://en.wikipedia.org/wiki/Adjugate_matrix
Expand Down

0 comments on commit aa2166e

Please sign in to comment.