4
$\begingroup$

This should be easy but I can't seem to find the right way to do it.

I have an equation of the form $a x + b x + c y + a z + d z = 0$, and I'd like to solve for relations between the parameters $a,b,c,d$, etc. such that the equation holds for all values of $x,y,z$, etc.

This is a very simplified example of the kind of equation I'm dealing with; there are actually 308 variables $x,y,\ldots$ and 42 parameters $a,b,\ldots$, making this nontrivial. As in the short sample equation, different variables could have the same parameter and could appear multiple times with different parameters.

So far my best attempt is:

Solve[ForAll[{x, y, ...}, a*x + b*y + ... == 0], {a, b, ...}]

This yields the correct solution on a smaller equation (about 20 variables and 9 parameters) but is far too slow for this one. Is there a more specific technique I could use that's more optimized for this kind of problem specifically? Leaving out ForAll yields solutions in terms of the x-variables, which is kind of useless.

EDIT: nikie mentioned a much better way to do it (in the comments)! Thanks!

$\endgroup$
  • 2
    $\begingroup$ Isn't this equivalent to solving the equation system a+b==0 && c==0 && a+d==0, without x,y,z and ForAll? $\endgroup$ – Niki Estner May 22 '12 at 20:26
  • $\begingroup$ Huh. Yes, I think so, now that you point it out. Thanks! I'll see if I can rework the larger equation into that form, shouldn't be too hard. $\endgroup$ – Abilinglortly May 22 '12 at 20:40
6
$\begingroup$
Coefficient[a x + b x + c y + a z + d z, #] == 0 & /@ {x, y, z} // Reduce[#, {a, b, c, d}] &

b == -a && c == 0 && d == -a
$\endgroup$
6
$\begingroup$

You can use SolveAlways for the type of problems you describe. I haven't looked if it's fast enough for a very large system though.

In[1]:= SolveAlways[a x + b x + c y + a z + d z == 0, {x, y, z}]

Out[1]= {{a -> -d, b -> d, c -> 0}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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