Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    

The following works nicely:

Block[{cf = CoefficientArrays[#]}, Last[cf].Variables[Subtract @@ #] == -First[cf]] &[
       5 (x - 1) - (y + 1) - (z + 1) == 0]
share|improve this answer

Try this:

eq = 5 (x - 1) - (y + 1) - (z + 1) == 0
Map[Plus[7, #] &, Expand[eq]]

(*  5 x - y - z == 7  *)
share|improve this answer

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}
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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