How to transform an equation so that the coefficient of a certain term becomes 1

Say I have an equation like

A + 5 B + 10 C == 0


and I want to have Mathematica write this as

(A/5) + B + 2 C == 0


i.e., I want to pick a term (B in this case) and choose its coefficient (1 in this case) and have Mathematica divide or multiply the equation appropriately. I can't figure out a way other than using Solve to solve the equation for B, but that's not ideal (especially since it moves B to the other side of the equation).

Edit

A good solution should also be something one can apply after a Collect, a Simplify, etc., without undoing those commands, since the equations I'm dealing with are much more complicated than this simple example!

• Expand[# - #2] == 0 & @@ Solve[expr, b][[1, 1]] ? I don't think you can count on general solution if you do not provide more details. p.s. C has built in meaning, try to avoid capital letters. – Kuba Mar 1 '14 at 14:47
• Thanks Kuba. Can you please unpack this? I don't quite understand what's going on here. – Adam Mar 1 '14 at 15:33
• #/5 & /@ (A + 5 B + 10 C) == 0 yields A/5 + B + 2 C == 0. – Artes Mar 1 '14 at 16:38
• Very nice, @Artes, thanks! – Adam Mar 2 '14 at 20:39

By the sounds of it, you are saying this:

I have a linear homogeneous equation f(a,b,c,...,n)=0, and I have some monomial like b, ab^2, or cd^2m^5 and I want to divide out by that coefficient to make this term have coefficient 1.

The quickest way to do this might be:

EXP = a + 5 b + 10 c;
Expand[EXP/Coefficient[EXP, b]]


This will divide out by the coefficient of b in the expression EXP. You can do this with other variables in the expression:

MONIC[EXP_, n_] := Expand[EXP/Coefficient[EXP, n]]
MONIC[EXP, b]
MONIC[EXP, c]


However, if you try to do something more complicated:

EXP = a + 5 b + 10 c + 3 a b^2 + 11 c d m^5;
MONIC[EXP, b]
MONIC[EXP, c]
MONIC[EXP, a b^2]
MONIC[EXP, c d m^5]


it will fail to work because it doesn't treat nonlinear expressions properly. To fix that, you can use the whole list of monomials:

MONIC2[EXP_, n_] :=
Expand[EXP/Select[MonomialList[EXP]/n, IntegerQ[#] &][[1]]]
MONIC2[EXP, b]
MONIC2[EXP, c]
MONIC2[EXP, a b^2]
MONIC2[EXP, c d m^5]


That will do the trick. If you want to use this in a fool-proof way, you'd need to include some safeguards to prevent division by zero and/or picking from a list that has no elements. But assuming the user inputs something that ought to have an answer, this will give it. Issues could also occur trying to use symbols that have already been assigned values of some kind.

Your equation will now be MONIC2[EXP,b]==0.

And as others have noted, probably good to stick to lowercase letters for variables.