# Moving certain variables to one side of the equation [duplicate]

I am having trouble moving certain variables from one side of the equation to the other. For example, if i want to solve for x1:

Reduce[x1 + x2 + x3 == 4, x1]

x1 == 4 - x2 - x3


but if i want to solve for 2 variables (x1 and x2):

Reduce[x1 + x2 + x3 == 4, {x1, x2}]

x2 == 4 - x1 - x3


But what I need is

x1 + x2 == 4 - x3


What am i doing wrong?

• related: Arrange equation in normal form – kglr May 30 '15 at 9:11
• You can simply: Reduce[u + x3 == 4, u] /. u -> x1 + x2 – ubpdqn May 30 '15 at 10:08
• – Jens May 30 '15 at 17:35
• You can modify my answer to the question I linked above, to get the desired result: eqn = x1 + x2 + x3 == 4; Map[Subtract[#, First[eqn] - (x1 + x2)] &, eqn]. Alternatively, Distribute[eqn - (First[eqn] - (x1 + x2)), Equal]. Also, I think the other linked question, Arrange equation in normal form, is a duplicate of the earlier one. – Jens May 30 '15 at 17:52

## 1 Answer

Not perfect nor general but probably useful enough:

solveMany[expr_, vars_List] := Module[{u},
(Plus @@ vars) == u /. Solve[
Eliminate[{ expr, Plus @@ vars == u}, vars],
u][]
]


And for example:

solveMany[x1 + x2 + x3 == 4, {x1, x3}]

x1 + x3 == 4 - x2