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.

I have this equation:

4b*Cos[2t]-4a*Sin[2t]==4Cos[2t]+8Sin[2t]

Which I would like to solve. Without using mathematica, you can pretty easily see that a = -2 and b = 1, but when I solve it with mathematica it gives me various long results including sometimes tan, sec cot etc.

I can break it up into to parts like this:

Solve[4b*Cos[2t]==4Cos[2t],b]
Solve[-4a*Sin[2t]==+8Sin[2t],a]

However, the point with mathematica isn't to make everything manually, and I would hope there is a method to use, without manually editing the equations.

So my question is: How do I solve this for a and b, with the results of a = -2 and b = 1?

share|improve this question
1  
You can try to use SolveAlways function. –  mmal Apr 26 '13 at 15:41
    
So in the first example you have 1 Equation with 2 variables, in the second example you have 2 equations with 2 variables. Don't you mean Solve[{[4b*Cos[2t]==4Cos[2t],-4a*Sin[2t]==+8Sin[2t]},{a,b}]? –  Sosi Apr 26 '13 at 15:42
2  
I'm guessing that it has to be solved for any t, so the (proper) approach is to write SolveAlways[ 4 b*Cos[2 t] - 4 a*Sin[2 t] == 4 Cos[2 t] + 8 Sin[2 t], t] or rather SolveAlways[4 b*Cos[2 t] - 4 a*Sin[2 t] == 4 Cos[2 t] + 8 Sin[2 t], {Sin[2 t], Cos[2 t]}] –  mmal Apr 26 '13 at 15:46
    
@mmal Thank you it works. Should I delete this question? –  Jens Jensen Apr 26 '13 at 15:47
    
No, don't delete it (but you may try to improve it to make it clearer) . Let @mmal post his answer. We don't see enough SolveAlways[] uses around. –  belisarius Apr 26 '13 at 15:49

1 Answer 1

up vote 8 down vote accepted

You should use the SolveAlways function, which will solve your equation for all values of the parameters (in this case for any t). So the solution to your question is

SolveAlways[4 b*Cos[2 t] - 4 a*Sin[2 t] == 4 Cos[2 t] + 8 Sin[2 t], t]

or rather

SolveAlways[4 b*Cos[2 t] - 4 a*Sin[2 t] == 4 Cos[2 t] + 8 Sin[2 t], {Sin[2 t], Cos[2 t]}]

(* => {{a -> -2, b -> 1}} *)

since we know that $\sin$ and $\cos$ are orthogonal functions.

share|improve this answer

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.