2
$\begingroup$

I've tried several functions related to trigonometric transformations, namely TrigFactor, TrigExpand, TrigReduce, as well as FunctionExpand and some others, but none gives me the following result (or similar) which I can verify with FullSimplify:

FullSimplify[ A Cos[x] + B Sin[x] == Sqrt[A^2+B^2] Sin[x+ArcTan[B,A]] ]

Of course, this is not a simplification of the LHS, so it's unreasonable to expect FullSimplify to yield it directly, but maybe I'm missing some more functions, which could directly lead me to expression similar to RHS of the above equality (i.e. containing only one $\sin$ or $\cos$ of shifted $x$ instead of superposition of multiple $\sin$-$\cos$es). Are there any such functions?

$\endgroup$
1
  • 1
    $\begingroup$ Perhaps this function: CosSin[A_ Cos[x_]+B_ Sin[x_]] := Sqrt[A^2+B^2] Sin[x+ArcTan[B, A]]; {CosSin[3 Cos[y]+4 Sin[y]], CosSin[p Sin[z]+q Cos[z]]} $\endgroup$
    – Bill
    Feb 13, 2016 at 18:01

1 Answer 1

3
$\begingroup$

You can define some new TransformationFunctions and ComplexityFunction for Simplify.

tfun[expr_] := 
  expr /. a_ Cos[x_] + b_ Sin[x_] :> Sqrt[a^2 + b^2] Sin[x + ArcTan[b, a]];
cfun[expr_] := 
  Plus @@ (Count[expr, #, {0, Infinity}, Heads -> True] & /@ {Sin, Cos});

Then

Simplify[A Cos[x] + B Sin[x], TransformationFunctions -> {Automatic, tfun}, 
ComplexityFunction -> cfun]
(* -> Sqrt[A^2 + B^2] Sin[x + ArcTan[B, A]] *)
$\endgroup$

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