Skip to content

Commit 1ae631f

Browse files
authored
Trying a simple fix for issue-619. During debugging, I found that AnalyticalEquationSolver.Solve( "{-(x + -1000) / (-1)}", "{x}" ) was returning "{{ } \/ { 1000 } \ { }}". That wasn't being interpreted as a FiniteSet. Getting InnerSimplified results in "{1000}", and that fits the FiniteSet type. (#622)
1 parent 79490e3 commit 1ae631f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Sources/AngouriMath/AngouriMath/Functions/Continuous/Solvers/EquationSolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal static List<List<Entity>> InSolveSystem(List<Entity> equations, ReadOnl
7777
{
7878
var var = vars[^1];
7979
if (equations.Count == 1)
80-
return equations[0].InnerSimplified.SolveEquation(var) is FiniteSet els
80+
return equations[0].InnerSimplified.SolveEquation(var).InnerSimplified is FiniteSet els
8181
? els.Select(sol => new List<Entity> { sol }).ToList()
8282
: new();
8383
var result = new List<List<Entity>>();

Sources/Tests/UnitTests/Algebra/SolveTest/SolveSystem.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,24 @@ public void EquationWithDivisionIsSolved() => AssertSystemSolvable(new Entity[]
102102
"x2 + y",
103103
"y - x - 3"
104104
}, new Entity.Variable[] { "x", "y" }, 2);
105+
106+
107+
[Fact]
108+
public void SystemWithZero() => AssertSystemSolvable(new Entity[] {
109+
"x - y - 1000",
110+
"y - 0"
111+
}, new Entity.Variable[] { "x", "y" }, 1);
112+
113+
[Fact]
114+
public void SystemWithZero2() => AssertSystemSolvable(new Entity[] {
115+
"y - 0",
116+
"x - y - 1000"
117+
}, new Entity.Variable[] { "x", "y" }, 1);
118+
119+
[Fact]
120+
public void SystemWithZero3() => AssertSystemSolvable(new Entity[] {
121+
"y - 0",
122+
"x - y"
123+
}, new Entity.Variable[] { "x", "y" }, 1);
105124
}
106125
}

0 commit comments

Comments
 (0)