@@ -708,6 +708,7 @@ private static IExpr solveNumeric(IExpr expr, boolean isNumeric, EvalEngine engi
708
708
*
709
709
* @param termsEqualZeroList a list of expressions which equals zero.
710
710
* @param variable the variable which should be eliminated in the term
711
+ * @param multipleValues if <code>true</code> multiple results are returned as list of values
711
712
* @param numeric evaluate in numericMode
712
713
* @param engine
713
714
* @return
@@ -984,7 +985,7 @@ private IASTMutable solveTimesEquationsRecursively(IASTMutable termsEqualZero,
984
985
IExpr termEQZero = termsEqualZero .get (i );
985
986
if (termEQZero .isTimes ()) {
986
987
solveTimesAST ((IAST ) termEQZero , termsEqualZero , inequationsList , numericFlag ,
987
- variables , multipleValues , engine , subSolutionSet , i );
988
+ variables , multipleValues , subSolutionSet , i , engine );
988
989
} else {
989
990
if (termEQZero .isAST ()) {
990
991
// try factoring
@@ -1006,7 +1007,7 @@ private IASTMutable solveTimesEquationsRecursively(IASTMutable termsEqualZero,
1006
1007
termEQZero = S .Factor .of (engine , termEQZero );
1007
1008
if (termEQZero .isTimes ()) {
1008
1009
solveTimesAST ((IAST ) termEQZero , termsEqualZero , inequationsList , numericFlag ,
1009
- variables , multipleValues , engine , subSolutionSet , i );
1010
+ variables , multipleValues , subSolutionSet , i , engine );
1010
1011
}
1011
1012
}
1012
1013
}
@@ -1106,9 +1107,24 @@ private static IASTMutable crossChecking(IASTMutable termsEqualZero, IASTMutable
1106
1107
return result ;
1107
1108
}
1108
1109
1110
+ /**
1111
+ * Analyze the <code>Time(..., ...)</code> expression in the given list of equations. If the
1112
+ * expression is of the form <code>Times(..., ...) == 0</code>, set each factor equal to
1113
+ * <code>0</code> and solve the resulting equations recursively.
1114
+ *
1115
+ * @param times the <code>Times(..., ...)</code> expression
1116
+ * @param termsEqualZeroList the list of expressions, which should equal <code>0</code>
1117
+ * @param inequationsList a list of inequality constraints
1118
+ * @param numericFlag if <code>true</code>, try to find a numeric solution
1119
+ * @param variables the variables for which the equations should be solved
1120
+ * @param multipleValues if <code>true</code> multiple results are returned as list of values
1121
+ * @param subSolutionSet a set of rules which should solve the terms
1122
+ * @param i the index of the current equation in the list
1123
+ * @param engine the evaluation engine
1124
+ */
1109
1125
private void solveTimesAST (IAST times , IAST termsEqualZeroList , IAST inequationsList ,
1110
- boolean numericFlag , IAST variables , boolean multipleValues , EvalEngine engine ,
1111
- Set < IExpr > subSolutionSet , int i ) {
1126
+ boolean numericFlag , IAST variables , boolean multipleValues , Set < IExpr > subSolutionSet ,
1127
+ int i , EvalEngine engine ) {
1112
1128
IAST temp ;
1113
1129
for (int j = 1 ; j < times .size (); j ++) {
1114
1130
if (!times .get (j ).isFree (Predicates .in (variables ), true )) {
@@ -1127,6 +1143,9 @@ private void solveTimesAST(IAST times, IAST termsEqualZeroList, IAST inequations
1127
1143
if (replaceAll .isPlusTimesPower () && //
1128
1144
S .PossibleZeroQ .ofQ (engine , replaceAll )) {
1129
1145
subSolutionSet .add (solution );
1146
+ } else if (!solution .isFree (S .ConditionalExpression )) {
1147
+ // TODO create some cross-check for C(1),... variables?
1148
+ subSolutionSet .add (solution );
1130
1149
}
1131
1150
}
1132
1151
}
0 commit comments