3
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ You can try to use SolveAlways function. $\endgroup$ – mmal Apr 26 '13 at 15:41
  • $\begingroup$ 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}]? $\endgroup$ – Sos Apr 26 '13 at 15:42
  • 2
    $\begingroup$ 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]}] $\endgroup$ – mmal Apr 26 '13 at 15:46
  • $\begingroup$ @mmal Thank you it works. Should I delete this question? $\endgroup$ – Jens Jensen Apr 26 '13 at 15:47
  • $\begingroup$ 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. $\endgroup$ – Dr. belisarius Apr 26 '13 at 15:49
9
$\begingroup$

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.

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