2

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?

kglr
  • 394,356
  • 18
  • 477
  • 896
TwoAbove
  • 25
  • 5

1 Answers1

0

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
Kuba
  • 136,707
  • 13
  • 279
  • 740