# Is it possible to use Reduce in a way that "eliminates" some unwanted variables, and only gives constraints between wanted variables?

Reduce[{x == z, y == z}] gives y == z && x == z but say I'm only interested in constraints that appear between x and y.

The desired result of this hypothetical reduce would be. x==y. Don't know if it helps, but I'm only working with equalities.

• There's undocumented syntax for that specific case: Reduce[{x == z, y == z}, {x, y}, z]. Apr 17 '20 at 3:33
• Eliminate[{x == y, y == z}, z] May 17 '20 at 4:18
• @J.M. As with Solve, it's best practice to put the eliminated variable(s) in braces, to tell MMA that it's not a domain specification, e.g., Reduce[{x == z, y == z}, {x, y}, {z}]. Jun 11 at 14:19
• @theorist, yes, that's a recent development. Jun 13 at 15:27

Clear["Global*"]


With Solve you can specify a list of variables to be eliminated. The list brackets are required even for a single variable to preclude interpretation as an attempt to specify a domain specification.

Solve[{x == z, y == z}, y, {z}][[1]]

(* {y -> x} *)

% /. Rule -> Equal

(* {y == x} *)

• Is this documented? Where to find?
– Acus
Jun 11 at 8:19
• @Acus - It is an outdated capability that still works (presumably for backward compatibility). See Version 7 "Solve[eqns, vars, elims] attempts to solve the equations for vars, eliminating the variables elims." There are other uses of it on this forum. Jun 11 at 11:25

Eliminate seems to do the job, but dosent work well when the resulting constraint should be an inequality (for example y==x*x, eliminating x, I would like to get y>=0. The operation Resolve with Exists over the unwanted variables and Reals` as domain should get the correct answer, the downside being that quantifier elimination might be computationally expensive.