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
11 changes: 11 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,17 @@ real radical form still takes it ([#2143](https://github.com/asc-community/Angou
| `"sin(pi/18)".ToEntity().Simplify()` | `sqrt((1 - 1/4 * ((4 + 4 * sqrt(-3)) ^ (1/3) + (4 - 4 * sqrt(-3)) ^ (1/3))) / 2)` | `sin(pi / 18)` |
| `"sin(pi/5)".ToEntity().Simplify()` | `1/4 * sqrt(10 - 2 * sqrt(5))` | `1/4 * sqrt(10 - 2 * sqrt(5))` |

### A quotient is zero where its numerator is and its denominator is not

**Silent: `N/D = 0` is solved as `N = 0` less the zeros of `D`, where it was left to the spellings.** One of those took
`t = x^2` into half-integer powers of `t` and handed it to Newton's method, which answered near-copies of a root and left
out others. A non-strict inequality takes the roots of its equation, so its answer was wrong with it.

| Input | Was (2.6.0) | Now |
|---|---|---|
| `"(18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0".ToEntity().Solve("x")` | `{ 3 }` | `{ -2, 3 }` |
| `"(108x^2 - 18x^3 - 24x^4 + 6x^5)/(27x^2 - 18x^4 + 3x^6) >= 0".ToEntity().Solve("x")` | `{ -sqrt(9.000000…), …, -3, … } \/ (-2; -sqrt(3)) \/ …`, with `-3`, where the quotient is negative, and without `-2` | `[-2; -sqrt(3)) \/ (-sqrt(3); 0) \/ (0; sqrt(3)) \/ (sqrt(3); +oo)` |

### A step function at a jump takes the side its argument arrives from

**Silent: a limit of `floor`, `ceil` or `sgn` whose argument arrives on a jump is answered, where it was left
Expand Down
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[Tests/UnitTests/Convenience/RoundIsExactTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[Tests/UnitTests/Algebra/SolveTest/AQuotientIsZeroWhereItsNumeratorIsTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

[Tests/UnitTests/Core/FactorialCacheIsThreadSafeTest.cs]
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ when @base.ContainsNode(x) && !power.ContainsNode(x)
return TreeAnalyzer.Assuming(predicate, () => Solve(expression, x, compensateSolving)).Filter(predicate, x);
case Piecewise p:
return EquationSolver.SolvePiecewise(p, x, (e, x) => Solve(e, x, compensateSolving));
// A quotient is zero exactly where its numerator is and its denominator is not
// zero: (x^2 - x)/(x^2 + x) = 0 is x = 1, x = 0 being a zero of both. Left to the
// spellings below, (18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0 was taken
// by a substitution t = x^2 into powers t^(3/2) and t^(5/2) and given to Newton's
// method, which answered three near-copies of 3 beside it and left out -2. Only
// where the numerator's roots are finitely many numbers, each of which can be put
// into the denominator; anything else is left to the routes below.
case Divf(var numerator, var denominator)
when numerator.ContainsNode(x) && denominator.ContainsNode(x)
&& Solve(numerator, x, compensateSolving) is FiniteSet zeros
&& zeros.All(root => !root.Vars.Any()):
return zeros.Where(root => denominator.Substitute(x, root).Evaled is not Complex value
|| value.IsFinite && !(value is Rational rational ? rational.IsZero : IsZero(value))).ToSet();
// A product is zero exactly where one of its factors is. Without this the
// factors are expanded back into a polynomial and the equation is answered
// by the general formula for whatever degree that turns out to be, so
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Copyright (c) 2019-2026 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//

using AngouriMath.Extensions;
using Xunit;
using static AngouriMath.Entity;
using static AngouriMath.Entity.Set;

namespace AngouriMath.Tests.Algebra
{
/// <summary>
/// A quotient is zero exactly where its numerator is and its denominator is not. Left to the
/// spellings, <c>(18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0</c> was taken by a
/// substitution <c>t = x^2</c> into half-integer powers of <c>t</c> and given to Newton's method,
/// which answered three near-copies of 3 beside it and left out -2; and the inequality with it
/// for its <c>= 0</c> part lost -2 as well. Found by a cross-check of rational inequalities
/// against their exact values; no issue was filed.
/// </summary>
[Trait("Area", "Algebra")]
public sealed class AQuotientIsZeroWhereItsNumeratorIsTest
{
[Theory]
[InlineData("(18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0", "{ -2, 3 }")]
[InlineData("(108x^2 - 18x^3 - 24x^4 + 6x^5)/(27x^2 - 18x^4 + 3x^6) = 0", "{ -2, 3 }")]
// Zeros of the numerator that the denominator shares are not roots: 0/0 has no value.
[InlineData("(x^2 - 1)/(x - 1) = 0", "{ -1 }")]
[InlineData("(x^4 - 9x^2)/(x^6 - 3x^4) = 0", "{ 3, -3 }")]
public void TheRootsAreTheNumeratorsTheDenominatorDoesNotShare(string equation, string expected)
=> Assert.Equal(expected.ToEntity(), equation.ToEntity().Solve("x"));

[Fact]
public void TheNonStrictInequalityKeepsTheRootsOfItsEquation()
{
var answer = (Set)"(108x^2 - 18x^3 - 24x^4 + 6x^5)/(27x^2 - 18x^4 + 3x^6) >= 0".ToEntity().Solve("x");
foreach (var (at, inside) in new[] { ("-2", true), ("3", true), ("1", true), ("-3", false), ("0", false), ("sqrt(3)", false) })
{
Assert.True(answer.TryContains(at.ToEntity(), out var contains), $"{at} undecided in {answer}");
Assert.Equal(inside, contains);
}
}
}
}
Loading