Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
2  
Isn't this equivalent to solving the equation system a+b==0 && c==0 && a+d==0, without x,y,z and ForAll? –  nikie May 22 '12 at 20:26
    
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. –  Abilinglortly May 22 '12 at 20:40
add comment

migrated from stackoverflow.com May 23 '12 at 3:42

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 6 down vote accepted
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
share|improve this answer
add comment

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

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.