2
$\begingroup$

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. >>

$\endgroup$
2
  • $\begingroup$ You can expand this, substitute bcd as bcd, so that it is a variable. Then you can solve. $\endgroup$ Dec 1, 2014 at 15:29
  • 2
    $\begingroup$ 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. $\endgroup$ Dec 1, 2014 at 15:39

3 Answers 3

2
$\begingroup$

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]
$\endgroup$
0
1
$\begingroup$

How about this?

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).

$\endgroup$
0
$\begingroup$
    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   *)

?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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