Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,21 @@ in 2.5.0.
| `forall p in PP : forall a in ZZ : a^p mod p = a mod p` | `UnhandledParseException` | `True` |
| `forall p in PP : forall a, b in ZZ : (a + b)^p = a^p + b^p (mod p)` | `UnhandledParseException` | `True` |

### An identity only the simplifier shows is solved to every value

`sqrt(x)^2 = x` was answered with the whole starting grid of Newton's method, 191 numbers. Nothing
analytical read it, and its residual is zero wherever it is evaluated, so every start converged at
once and each was kept. Where every analytical route has declined, the equation is now 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 is not taken, and goes on to Newton's method as
before: `(x^2 - 1)/(x - 1) - x - 1` is zero for every `x` but 1, where `CC` would be wrong
([#1420](https://github.com/asc-community/AngouriMath/issues/1420)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"sqrt(x)^2 = x".ToEntity().Solve("x")` | `{ -10, -49/5, -48/5, …, -8 - 8i, … }`, 191 numbers | `CC` |
| `"sin(x)^2 + cos(x)^2 = 1".ToEntity().Solve("x")` | the same 191 numbers | `CC` |

### An equation the solver cannot invert is left unsolved, not answered with no roots

`x! = 6` was answered `{ }`, a claim that it has no roots, and it has 3. The solver isolates `x`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ bool ProductIsDefinedAt(Entity root)
// TODO: Solve factorials (Needs Lambert W function)
// https://mathoverflow.net/a/28977

// An identity is satisfied by every x, and not by the points a numerical search
// starts from: `sqrt(x)^2 - x` is zero wherever it is evaluated, so every start of
// Newton's grid converged at once and each was kept, two hundred numbers for an
// equation every number satisfies. Asked of the simplifier here, where every
// analytical route has declined, since it is a whole simplification; and only an
// unconditional zero, since `(x^2 - 1)/(x - 1) - x - 1` is zero for every x but 1.
// https://github.com/asc-community/AngouriMath/issues/1420
if (expr.Vars.Count == 1 && expr.Simplify() is Integer { IsZero: true })
return MathS.Sets.C;

// A numerical search that comes back with nothing has not shown there is
// nothing to find: Newton's method is started from finitely many points inside
// a bounded region, so an empty result is a fact about the search rather than
Expand Down
11 changes: 11 additions & 0 deletions Sources/Tests/UnitTests/Algebra/SolveTest/IdentityEquationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public sealed class IdentityEquationTest
public void EveryValueSatisfiesAnIdentity(string equation) =>
Assert.Equal(MathS.Sets.C, equation.ToEntity().Solve("x"));

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

[Theory]
[InlineData("1 = 0")]
[InlineData("x - x + 1 = 0")]
Expand Down
Loading