# Solve an equation for a product

I have an equation a = bcd/fg and I have another one that I can take bcd out of. Easy enough to do by hand, but Mathematica won't let me solve for bcd (need to for completeness).

Solve[h + j + k - (l + m*n + b*c)*d == 0, bcd]


Solve::ivar: b c d is not a valid variable. >>

• You can expand this, substitute bcd as bcd, so that it is a variable. Then you can solve. Dec 1, 2014 at 15:29
• Actually kind of tricky. One way is to add an equation b*c*d==bcd, the solve for {bcd,b} for example. If you solve for only bcd you get an empty solution set because a condition is imposed that makes the solution set nongeneric. Dec 1, 2014 at 15:39

One way to attack this is to force the substitution. Observe that

Expand[a1 + b*a2 + c1*b + d*c2 - (e + a1*x + g*e)*y]

a1 + a2 b + b c1 + c2 d - e y - e g y - a1 x y


has the term you want. So make the substitution

eqn=Expand[a1 + b*a2 + c1*b + d*c2 - (e + a1*x + g*e)*y] //. a1 x y -> z


Then you can

Solve[eqn == 0, z]


Eliminate[{h + j + k - (l + m*n + b*c)*d == 0,
bcd == b c d}, c]

(* ==> h + j + k - d l - d m n == bcd *)


I see that Bill's answer was just accepted while I typed, but it's worth pointing out (as Daniel did) that in order to solve for bcd, you have to add a definition for it to the set of equations. And in that case, Eliminate is easier than Solve because you just have to pick one of the variables bcd depends on as the one to be eliminated (in general, one variable can be eliminated for every additional equation you impose).

    Solve[h + j + k - (l + m*n + b*c)*d == 0, b][[1, 1, 2]]*c*d

(*   h + j + k - d l - d m n   *)


?