Skip to content

Commit 4411d02

Browse files
An identity only the simplifier shows is solved to every value (#1562)
`sqrt(x)^2 = x` and `sin(x)^2 + cos(x)^2 = 1` reached Newton's method unread: their residual is zero wherever it is evaluated, so every start of its grid converged at once, and each was kept, 191 numbers for an equation every number satisfies. Where every analytical route has declined, the equation is simplified once before Newton's method is tried, and an unconditional zero is answered with CC, as `x + 1 = x + 1` already was. A zero with a condition goes on to Newton's method as before: `(x^2 - 1)/(x - 1) - x - 1` is zero for every x but 1. The unit tests pass (net10.0, 13333), every target builds, and the allocation gate passes. Part of #1420. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ddade7c commit 4411d02

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,21 @@ in 2.5.0.
17271727
| `forall p in PP : forall a in ZZ : a^p mod p = a mod p` | `UnhandledParseException` | `True` |
17281728
| `forall p in PP : forall a, b in ZZ : (a + b)^p = a^p + b^p (mod p)` | `UnhandledParseException` | `True` |
17291729

1730+
### An identity only the simplifier shows is solved to every value
1731+
1732+
`sqrt(x)^2 = x` was answered with the whole starting grid of Newton's method, 191 numbers. Nothing
1733+
analytical read it, and its residual is zero wherever it is evaluated, so every start converged at
1734+
once and each was kept. Where every analytical route has declined, the equation is now simplified
1735+
once before Newton's method is tried, and an unconditional zero is answered with `CC`, as
1736+
`x + 1 = x + 1` already was. A zero with a condition is not taken, and goes on to Newton's method as
1737+
before: `(x^2 - 1)/(x - 1) - x - 1` is zero for every `x` but 1, where `CC` would be wrong
1738+
([#1420](https://github.com/asc-community/AngouriMath/issues/1420)).
1739+
1740+
| Input | Was (2.5.0) | Now |
1741+
|---|---|---|
1742+
| `"sqrt(x)^2 = x".ToEntity().Solve("x")` | `{ -10, -49/5, -48/5, …, -8 - 8i, … }`, 191 numbers | `CC` |
1743+
| `"sin(x)^2 + cos(x)^2 = 1".ToEntity().Solve("x")` | the same 191 numbers | `CC` |
1744+
17301745
### An equation the solver cannot invert is left unsolved, not answered with no roots
17311746

17321747
`x! = 6` was answered `{ }`, a claim that it has no roots, and it has 3. The solver isolates `x`

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,16 @@ bool ProductIsDefinedAt(Entity root)
357357
// TODO: Solve factorials (Needs Lambert W function)
358358
// https://mathoverflow.net/a/28977
359359

360+
// An identity is satisfied by every x, and not by the points a numerical search
361+
// starts from: `sqrt(x)^2 - x` is zero wherever it is evaluated, so every start of
362+
// Newton's grid converged at once and each was kept, two hundred numbers for an
363+
// equation every number satisfies. Asked of the simplifier here, where every
364+
// analytical route has declined, since it is a whole simplification; and only an
365+
// unconditional zero, since `(x^2 - 1)/(x - 1) - x - 1` is zero for every x but 1.
366+
// https://github.com/asc-community/AngouriMath/issues/1420
367+
if (expr.Vars.Count == 1 && expr.Simplify() is Integer { IsZero: true })
368+
return MathS.Sets.C;
369+
360370
// A numerical search that comes back with nothing has not shown there is
361371
// nothing to find: Newton's method is started from finitely many points inside
362372
// a bounded region, so an empty result is a fact about the search rather than

‎Sources/Tests/UnitTests/Algebra/SolveTest/IdentityEquationTest.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ public sealed class IdentityEquationTest
3131
public void EveryValueSatisfiesAnIdentity(string equation) =>
3232
Assert.Equal(MathS.Sets.C, equation.ToEntity().Solve("x"));
3333

34+
/// <summary>
35+
/// And one that only the simplifier shows is an identity, which reached Newton's method
36+
/// and came back as every point of its starting grid, two hundred numbers --
37+
/// https://github.com/asc-community/AngouriMath/issues/1420.
38+
/// </summary>
39+
[Theory]
40+
[InlineData("sqrt(x)^2 = x")]
41+
[InlineData("sin(x)^2 + cos(x)^2 = 1")]
42+
public void EveryValueSatisfiesAnIdentityTheSimplifierShows(string equation) =>
43+
Assert.Equal(MathS.Sets.C, equation.ToEntity().Solve("x"));
44+
3445
[Theory]
3546
[InlineData("1 = 0")]
3647
[InlineData("x - x + 1 = 0")]

0 commit comments

Comments
 (0)