2
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

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][[1]]
  ]

And for example:

solveMany[x1 + x2 + x3 == 4, {x1, x3}]
x1 + x3 == 4 - x2
$\endgroup$

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