|
| 1 | +// |
| 2 | +// Copyright (c) 2019-2026 Angouri. |
| 3 | +// AngouriMath is licensed under MIT. |
| 4 | +// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md. |
| 5 | +// Website: https://am.angouri.org. |
| 6 | +// |
| 7 | + |
| 8 | +using AngouriMath.Extensions; |
| 9 | +using Xunit; |
| 10 | +using static AngouriMath.Entity; |
| 11 | +using static AngouriMath.Entity.Set; |
| 12 | + |
| 13 | +namespace AngouriMath.Tests.Algebra |
| 14 | +{ |
| 15 | + /// <summary> |
| 16 | + /// A quotient is zero exactly where its numerator is and its denominator is not. Left to the |
| 17 | + /// spellings, <c>(18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0</c> was taken by a |
| 18 | + /// substitution <c>t = x^2</c> into half-integer powers of <c>t</c> and given to Newton's method, |
| 19 | + /// which answered three near-copies of 3 beside it and left out -2; and the inequality with it |
| 20 | + /// for its <c>= 0</c> part lost -2 as well. Found by a cross-check of rational inequalities |
| 21 | + /// against their exact values; no issue was filed. |
| 22 | + /// </summary> |
| 23 | + [Trait("Area", "Algebra")] |
| 24 | + public sealed class AQuotientIsZeroWhereItsNumeratorIsTest |
| 25 | + { |
| 26 | + [Theory] |
| 27 | + [InlineData("(18x^2 - 3x^3 - 4x^4 + x^5)/(9x^2 - 6x^4 + x^6) = 0", "{ -2, 3 }")] |
| 28 | + [InlineData("(108x^2 - 18x^3 - 24x^4 + 6x^5)/(27x^2 - 18x^4 + 3x^6) = 0", "{ -2, 3 }")] |
| 29 | + // Zeros of the numerator that the denominator shares are not roots: 0/0 has no value. |
| 30 | + [InlineData("(x^2 - 1)/(x - 1) = 0", "{ -1 }")] |
| 31 | + [InlineData("(x^4 - 9x^2)/(x^6 - 3x^4) = 0", "{ 3, -3 }")] |
| 32 | + public void TheRootsAreTheNumeratorsTheDenominatorDoesNotShare(string equation, string expected) |
| 33 | + => Assert.Equal(expected.ToEntity(), equation.ToEntity().Solve("x")); |
| 34 | + |
| 35 | + [Fact] |
| 36 | + public void TheNonStrictInequalityKeepsTheRootsOfItsEquation() |
| 37 | + { |
| 38 | + var answer = (Set)"(108x^2 - 18x^3 - 24x^4 + 6x^5)/(27x^2 - 18x^4 + 3x^6) >= 0".ToEntity().Solve("x"); |
| 39 | + foreach (var (at, inside) in new[] { ("-2", true), ("3", true), ("1", true), ("-3", false), ("0", false), ("sqrt(3)", false) }) |
| 40 | + { |
| 41 | + Assert.True(answer.TryContains(at.ToEntity(), out var contains), $"{at} undecided in {answer}"); |
| 42 | + Assert.Equal(inside, contains); |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | +} |
0 commit comments