I have 5(x-1)-(y+1)-(z+1)==0. If I use FullSimplify on it it returns
5x==7+x+y. This is not what I want: I want it to return 5x-y-z==7.
Asked
Active
Viewed 468 times
2
-
Closely related question: Is is possible to have mathematica move all terms to one side of an equation? – Jens Jun 01 '12 at 15:45
4 Answers
3
Try this:
eq = 5 (x - 1) - (y + 1) - (z + 1) == 0
Map[Plus[7, #] &, Expand[eq]]
(* 5 x - y - z == 7 *)
J. M.'s missing motivation
- 124,525
- 11
- 401
- 574
Alexei Boulbitch
- 39,397
- 2
- 47
- 96
3
The following works nicely:
Block[{cf = CoefficientArrays[#]}, Last[cf].Variables[Subtract @@ #] == -First[cf]] &[
5 (x - 1) - (y + 1) - (z + 1) == 0]
J. M.'s missing motivation
- 124,525
- 11
- 401
- 574
3
Another option:
expr = 5 (x - 1) - (y + 1) - (z + 1) == 0;
Expand[expr]//.{a_==b:Except[_?NumericQ]:>a-b==0,a___+b_?NumericQ==c_:>Plus@a==c-b}
Simon Woods
- 84,945
- 8
- 175
- 324
2
One way is
body = 5 (x - 1) - (y + 1) - (z + 1);
(#[[2]].Variables[body] == -1*#[[1]]) &@
Flatten[Normal@CoefficientArrays[{body == 0}, {x, y, z}], 1]
BR
PlatoManiac
- 14,723
- 2
- 42
- 74