2
$\begingroup$

Suppose I have a set of relations which I'd like to store as one variable.

setOfRelations = {x - y == 0, z - w == 0}

If I wish to obtain w in terms of the other variables in the system, I would have thought to do

Solve[setOfRelations, w]

with the expectation of {{w->z}}. Instead the output is {}. Obviously the irrelevant equations are messing up Solve.

What is the correct way to obtain some result given a set of relations, a subset of which may be coupled, and a subset of which may be irrelevant?

$\endgroup$
4
  • $\begingroup$ Are the equations going to be linear or general polynomial relationships in the variables? Or possibly more complicated than polynomials? $\endgroup$
    – Hugh
    Dec 24, 2018 at 7:32
  • 2
    $\begingroup$ Maybe: Solve[setOfRelations, w, MaxExtraConditions -> All] $\endgroup$ Dec 24, 2018 at 7:59
  • $\begingroup$ Solve[setOfRelations, w, {x}] or Solve[setOfRelations, w, {y}] $\endgroup$
    – Bob Hanlon
    Dec 24, 2018 at 14:52
  • $\begingroup$ @Hugh The equations are always linear, and homogenous (equal to zero on right hand side). $\endgroup$
    – QuantumDot
    Dec 24, 2018 at 18:12

2 Answers 2

2
$\begingroup$

A direct approach is to delete relations without the required variables and then solve:

setOfRels[a_] := Select[setOfRelations, ! FreeQ[#, a] &]
Solve[setOfRels[w], w]
$\endgroup$
2
$\begingroup$

When in doubt, try Reduce

setOfRelations = {x - y == 0, z - w == 0}

Reduce[setOfRelations, w] // ToRules
(*{x -> y, w -> z}*)

But this generally gives you more than you ask for.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.