diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index fad9d71b9..a41604b3a 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -713,6 +713,26 @@ multiple of `pi/3` for large x, so no finite set answers them and they are left
| `"e^(-x) = sin(3x)".Solve("x")` | stack overflow after about 2.5 min | `{ x : e ^ (-x) = sin(3 * x) }`, 0.6 s |
| `"e^(-x) + sin(x)^3 = 3 sin(x) cos(x)^2".Solve("x")` | did not finish in 60 s | `{ x : e ^ (-x) + sin(x) ^ 3 = 3 * sin(x) * cos(x) ^ 2 }`, 0.8 s |
+### A root of a modulus raised to a negative number has no roots
+
+**Silent: a circle of non-roots becomes `{ }`.** A root of `abs(u)` is real and not negative, but raising
+`sqrt(abs(x)) = -1` gives `abs(x) = 1`, and its roots `e^(i r)` were answered. Each was checked by substituting it, and a
+family with a real parameter was not, so it was kept. Where `x` is only inside one modulus the equation depends on
+`|u|` alone, which is the same at every member of such a family, so one member is now checked
+([#2712](https://github.com/asc-community/AngouriMath/issues/2712)).
+
+Measured over 90 equations of an even or fractional root of a modulus, on `409d68805` and on this branch: 27 answers
+changed, each to `{ }` or to the old answer without its non-roots. Every root left was checked with mpmath.
+
+| `.Solve("x")` | Was (`409d68805`) | Now |
+|---|---|---|
+| `sqrt(abs(x)) = -1` | `{ e ^ (i * r_1) provided r_1 in RR }` | `{ }` |
+| `sqrt(abs(x - 4) - 3) = -5` | `{ 28 * e ^ (i * r_1) + 4 provided r_1 in RR }` | `{ }` |
+| `sqrt(abs(x) + 1) = -1` | `{ 0 provided r_1 in RR }` | `{ }` |
+| `abs(x)^(3/2) = -8` | `{ 4 * e ^ (i * r_1) provided r_1 in RR }` | `{ }` |
+| `sqrt(abs(x)) = abs(x) - 2` | `{ e ^ (i * r_1) provided r_1 in RR, 4 * e ^ (i * r_1) provided r_1 in RR }` | `{ 4 * e ^ (i * r_1) provided r_1 in RR }` |
+| `sqrt(abs(x)) = -abs(x)` | `{ 0 provided r_1 in RR, e ^ (i * r_1) provided r_1 in RR }` | `{ 0 provided r_1 in RR }` |
+
### The whole part of a large rational power is taken out
**Silent, in the printed form only.** A rational raised to a rational power was written as a whole part times a
diff --git a/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolutionParameters.cs b/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolutionParameters.cs
index a5e158d07..0829158d3 100644
--- a/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolutionParameters.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolutionParameters.cs
@@ -247,15 +247,17 @@ private Set Bind(FiniteSet listed)
///
/// at one member of its family: each symbol in it a whole
/// parameter minted in the scope open, put at the whole number nearest 0 in its set; or
- /// where a symbol is anything else.
+ /// where a symbol is anything else. With
+ /// , a real parameter, the angle a modulus is inverted with, is
+ /// put at 0 as well.
///
- internal static Entity? AtAMember(Entity root)
+ internal static Entity? AtAMember(Entity root, bool angles = false)
{
if (current is not { } scope)
return null;
foreach (var parameter in root.Vars.Distinct().ToList())
{
- if (scope.SetOf(parameter) is not { } set || !IsWhole(set))
+ if (scope.SetOf(parameter) is not { } set || !(IsWhole(set) || angles && set == MathS.Sets.R))
return null;
Entity? value = null;
foreach (var candidate in Nearest)
diff --git a/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolveStatement.cs b/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolveStatement.cs
index df9698c17..79821883b 100644
--- a/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolveStatement.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/SolveStatement.cs
@@ -264,8 +264,13 @@ private static RootVerdict Verdict(Entity equation, Variable x, Entity root)
// members, as the principal root alone was before the family was written: a member
// that fails is evidence against the family, and one that passes proves nothing
// about the rest, so the family is kept. https://github.com/asc-community/AngouriMath/issues/2319
+ // So is a family the modulus is inverted into, |u| = c being u = c e^(i r) for every real r,
+ // where the equation has x only inside that one modulus: there it is a function of |u|,
+ // which is c at every member, so every member is a root or none is. Raising
+ // sqrt(abs(x)) = -1 gives abs(x) = 1, and e^(i r) was answered, whose members all have
+ // sqrt(abs(x)) = 1. https://github.com/asc-community/AngouriMath/issues/2712
if (root.Vars.Any())
- return SolutionParameters.AtAMember(root) is { } member && !member.Vars.Any() && Verdict(equation, x, member) is var verdict and not RootVerdict.Kept
+ return SolutionParameters.AtAMember(root, angles: HasXOnlyInsideOneModulus(equation, x)) is { } member && !member.Vars.Any() && Verdict(equation, x, member) is var verdict and not RootVerdict.Kept
? verdict
: RootVerdict.Kept;
var substituted = equation.Substitute(x, root);
@@ -396,6 +401,31 @@ private static bool IsAWrittenInteger(Real part)
return part.EDecimal.IsFinite && part.EDecimal.Exponent.IsZero;
}
+ ///
+ /// Whether every in is inside a modulus, and
+ /// every modulus with in it, outermost, is the same one.
+ ///
+ private static bool HasXOnlyInsideOneModulus(Entity equation, Variable x)
+ {
+ Entity? modulus = null;
+ bool Walk(Entity node)
+ {
+ if (node is Absf && node.ContainsNode(x))
+ {
+ modulus ??= node;
+ return modulus == node;
+ }
+ if (node == x)
+ return false;
+ var children = node.DirectChildren;
+ for (var i = 0; i < children.Count; i++)
+ if (!Walk(children[i]))
+ return false;
+ return true;
+ }
+ return Walk(equation) && modulus is not null;
+ }
+
/// What does with a root.
private enum RootVerdict
{
diff --git a/Sources/Tests/UnitTests/Algebra/SolveTest/ARadicalOfAModulusIsNeverNegativeTest.cs b/Sources/Tests/UnitTests/Algebra/SolveTest/ARadicalOfAModulusIsNeverNegativeTest.cs
new file mode 100644
index 000000000..e91a10e6a
--- /dev/null
+++ b/Sources/Tests/UnitTests/Algebra/SolveTest/ARadicalOfAModulusIsNeverNegativeTest.cs
@@ -0,0 +1,57 @@
+//
+// 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 System.Linq;
+using AngouriMath;
+using AngouriMath.Extensions;
+using Xunit;
+using static AngouriMath.Entity;
+
+namespace AngouriMath.Tests.Algebra
+{
+ ///
+ /// A root of a modulus is real and not negative, so raising sqrt(abs(x)) = -1 to
+ /// abs(x) = 1 adds the circle e^(i r), none of whose members is a root. The equation
+ /// has x only inside the modulus, so one member decides the family.
+ /// https://github.com/asc-community/AngouriMath/issues/2712
+ ///
+ [Trait("Area", "Algebra")]
+ public sealed class ARadicalOfAModulusIsNeverNegativeTest
+ {
+ [Theory]
+ [InlineData("sqrt(abs(x)) = -1")]
+ [InlineData("sqrt(abs(x - 4) - 3) = -5")]
+ [InlineData("sqrt(abs(x)) + 1 = 0")]
+ [InlineData("sqrt(abs(x) + 1) = -1")]
+ [InlineData("2 sqrt(abs(x)) + 3 = 0")]
+ [InlineData("abs(x) ^ (1/4) = -1")]
+ [InlineData("abs(x) ^ (3/4) = -1")]
+ [InlineData("abs(x) ^ (3/2) = -8")]
+ [InlineData("sqrt(abs(x)) * abs(x) = -8")]
+ public void HasNoRoot(string equation)
+ => Assert.Equal(Set.Empty, equation.ToEntity().Solve("x"));
+
+ // Each answer is one family, every member of which is a root: |x| = 4 and |x| = 0, and not
+ // the |x| = 1 and |x| = 1/4 the squares add.
+ [Theory]
+ [InlineData("sqrt(abs(x)) - abs(x) + 2", 4)]
+ [InlineData("sqrt(abs(x)) + 2 abs(x)", 0)]
+ [InlineData("sqrt(abs(x)) + abs(x)", 0)]
+ [InlineData("sqrt(abs(x)) - 2", 4)]
+ [InlineData("abs(x) ^ (3/2) - 8", 4)]
+ public void HasOneCircleOfRoots(string residual, int modulus)
+ {
+ var root = Assert.Single(Assert.IsType(residual.ToEntity().Equalizes(0).Solve("x")));
+ foreach (var angle in new[] { "0", "1/3", "2", "-5/2" })
+ {
+ var member = root.Vars.Aggregate(root, (at, parameter) => at.Substitute(parameter, angle.ToEntity()));
+ Assert.Equal(0, ((Entity.Number.Complex)(MathS.Abs(member) - modulus).Evaled).Abs().EDecimal.ToDouble(), 12);
+ Assert.Equal(0, ((Entity.Number.Complex)residual.ToEntity().Substitute("x", member).Evaled).Abs().EDecimal.ToDouble(), 12);
+ }
+ }
+ }
+}