Does solve Return an Appropriate Solution for a System of Rational Equations?

Consider a system of equations with LHS being rational functions in two variables.
syms x y
g = (x-1)/(y-2) == 0;
h = (y-2)/(x-1) == 0;
In solving either equation alone, solve understands that the solution is constrained
sol = solve(g,x,'ReturnConditions',true)
sol = struct with fields:
x: 1 parameters: [1×0 sym] conditions: y ~= 2
sol = solve(h,y,'ReturnConditions',true)
sol = struct with fields:
y: 2 parameters: [1×0 sym] conditions: x ~= 1
However, when solving both equations simultaneously solve happily returns an unconstrained solution
sol = solve([g,h],[x,y],'ReturnConditions',true)
sol = struct with fields:
x: 1 y: 2 parameters: [1×0 sym] conditions: symtrue
which can't be correct.
Is this an appropriate and expected behavior of solve?
The doc page at solve does say that IF using IgnoreAnalyticContraints then:
"The solver can multiply both sides of an equation by any expression except 0."
Maybe the solution above would be expected if IgnoreAnalyticConstraints was true, but it wasn't.
BTW, vpasolve works the same way
vpasolve([g,h],[x,y])
ans = struct with fields:
x: 1.0 y: 2.0
Hoewever, the documentation at vpasolve states:
"When you solve a system of rational equations, vpasolve transforms the rational equations to polynomials by multiplying out the denominators. vpasolve returns all solutions of the resulting polynomial system, which also include the roots of the denominators."

1 Commento

syms x y
g = (x-1)/(y-2) == 0;
h = (y-2)/(x-1) == 0;
solve([g,h],[x,y])
ans = struct with fields:
x: 1 y: 2
vpasolve([g,h],[x,y])
ans = struct with fields:
x: 1.0 y: 2.0
So if the quote from the documentation applies both to vpasolve and solve, the answer is to be expected (although it is wrong).
Mathematica gives the correct result:

Accedi per commentare.

Risposte (0)

Categorie

Prodotti

Release

R2026a

Richiesto:

il 5 Lug 2026

Commentato:

il 7 Lug 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by