Skip to content

A system with more or fewer equations than unknowns is solved or declined - #2124

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-short-system-it-cannot-take-is-declined
Oct 26, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-short-system-it-cannot-take-is-declined

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

EquationSystem.Solve threw WrongNumberOfArgumentsException for a system with more or fewer equations than unknowns, unless the triangularisation took it or it was short and linear with rational coefficients. The exception says the call was wrong, and it was not. On #212, @Happypig375 said accepting new forms and not throwing is fine, which answers the question my earlier comment there left open.

Such a system is now eliminated one unknown at a time:

  • An unknown that nothing is left to constrain becomes a parameter, t_1, as in the linear case.
  • With no unknown left, an equation that is a number away from zero drops its branch. One that cannot be decided, such as (a + b)/2 - c, means that equation gives no answer, and the next equation is tried.
  • Every family is substituted back into every equation and kept only where each one vanishes. Otherwise the system is declined as null, which Solve documents as no solution found.

A square system does not reach this path, so no square answer changes.

2.6.0 this branch
x^2 + y^2 - 1 in x, y WrongNumberOfArgumentsException [[t_1, sqrt(-(t_1 ^ 2 + -1))], [t_1, -sqrt(-(t_1 ^ 2 + -1))]]
a*x + y - 1 in x, y WrongNumberOfArgumentsException [[t_1, -(a * t_1 + -1)]]
sin(x), x in x WrongNumberOfArgumentsException [0]
sin(x) - y, cos(x) - y, x - pi/4 in x, y WrongNumberOfArgumentsException [[pi / 4, 1/2 * sqrt(2)]]
sqrt(y) - x in x, y WrongNumberOfArgumentsException null
x + y - a, x - y - b, x - c in x, y WrongNumberOfArgumentsException null

Why the substitution back is needed. Two of the declines would otherwise be wrong answers:

  • sqrt(y) = x is solved for y as x^2, which is no solution for a negative x. sqrt(t^2) - t does not simplify to 0, so the family (t, t^2) is not returned.
  • A coefficient that is zero without being written so. For x^2 - c y with c = (a + 1)^2 - a^2 - 2a - 1, the elimination divides by c, and Simplify calls the residual 0 provided not c = 0. A provided condition counts only where it holds with the symbols pinned, so that family is declined too.

NonSquareSystemTest checks the families numerically at negative and positive values of their parameters, instead of the way the solver checks them. It also checks the overdetermined answers exactly, and the three declines. ParametricSystemTest.WhatIsNotLinearInTheUnknownsIsRefused pinned the exception for four of these shapes and is removed. Entry in BREAKING-CHANGES.md; Exceptions.md and the Solve doc comment no longer say the counts must match.

Not in this PR:

  • The square path has the same missing check, and it answers wrongly. sqrt(y) - x, x + 1 in x, y gives [[-1, 1]], while sqrt(1) - (-1) is 2. That is a changed answer for square systems, so it goes in its own PR, for A system of equations is answered with rows that do not satisfy it #2123.
  • A family with an integer parameter is declined. sin(x) - 1/2 in x, y gives null, because sin(pi/6 + 2 pi n_1) - 1/2 does not simplify to 0 without knowing that n_1 is an integer.

Part of #212

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…ined

EquationSystem.Solve threw WrongNumberOfArgumentsException for a non-square system unless the
triangularisation took it (polynomial over Q, rational solutions) or it was short and linear with
rational coefficients. The exception says the call was wrong, and it was not: x^2 + y^2 = 1 for x
and y has a family of solutions, and sin(x) = 0 with x = 0 has one. Happypig375 agreed on #212 that
accepting new forms and not throwing is fine.

Such a system now goes to NonSquareSystemSolver. It eliminates the last unknown from the equation
with the fewest occurrences of it, recurses on each root, and makes an unknown that nothing is left
to constrain a parameter, t_1, as the linear path does. With no unknown left, an equation that is a
number away from zero drops its branch; one that cannot be decided, like (a + b)/2 - c, makes that
equation's roots no answer, and the next equation is tried.

Every family is substituted back into every equation and kept only where each one vanishes, and a
system with one that does not is declined as null, which Solve documents as no solution found. Two
cases need that check:
- sqrt(y) = x is solved for y as x^2, which is no solution for a negative x; sqrt(t^2) - t does not
  simplify to 0, so the system is declined rather than answered (t, t^2).
- A coefficient that is zero without being written so: t^2 - c (t^2/c) simplifies to
  0 provided not c = 0 for c = (a + 1)^2 - a^2 - 2a - 1. A provided condition counts only where it
  holds with the symbols pinned, so that family is declined too.

A square system does not reach this, so no square answer changes.

Measured, each non-square shape probed on 2.6.0 and on this branch:
  x^2 + y^2 - 1 in x, y                   exception -> [[t_1, sqrt(-(t_1 ^ 2 + -1))],
                                                        [t_1, -sqrt(-(t_1 ^ 2 + -1))]]
  a*x + y - 1 in x, y                     exception -> [[t_1, -(a * t_1 + -1)]]
  sin(x); x in x                          exception -> [0]
  sin(x) - y; cos(x) - y; x - pi/4        exception -> [[pi / 4, 1/2 * sqrt(2)]]
  sqrt(y) - x in x, y                     exception -> null
  x + y - a; x - y - b; x - c in x, y     exception -> null

Part of #212

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 26, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit 429f5f6 into master Oct 26, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 26, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-short-system-it-cannot-take-is-declined branch October 26, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant