# Trigonometric simplification

How can I simplify 1/2 (Sqrt[3] Cos[x] - Sin[x]) in order to get Cos[x + Pi/6] on Mathematica? I saw that Wolfram|Alpha lists this simplification on the AlternateForms.

Thanks.

Use the TrigFactor[] function, as in

TrigFactor[1/2*(Sqrt[3]*Cos[x] - Sin[x])]


Output

Cos[Pi/6 + x].

• That's great! But TrigFactor was not able to simplify the following expression: 1/2*((Sqrt[3]*Cos[x]-Sin[x])*m-n). I expect m*Cos[x+Pi/6]-n/2 as the result. – Hermano May 22 '15 at 16:21
• Did you mean to have a parentheses around that $m-n$? – J. W. Perry May 22 '15 at 16:24
• no. The expression is correct. – Hermano May 22 '15 at 16:28
• Well, that expression you have in comment is $\frac{1}{2} \left(m \left(\sqrt{3} \cos (x)-\sin (x)\right)-n\right)$. See that you can pull out the constant. $-\frac{n}{2}$. The remaining part will factor. – J. W. Perry May 22 '15 at 16:30
• In other words, that's just $\frac{1}{2} m \left(\sqrt{3} \cos (x)-\sin (x)\right)-\frac{n}{2}$. The trig part will factor, the constant will not. – J. W. Perry May 22 '15 at 16:32

You could call a function that fetches all WolframAlpha alternate expression forms:

AlternateExpressionForms[expression_]:=Module[{alternateFormData},
alternateFormData={};
alternateFormData=Quiet[Check[TimeConstrained[ReleaseHold[WolframAlpha[ToString[expression,InputForm],{"AlternateForm","Input"}]],60],{}]];
Flatten[Table[alternateFormData[[i,2]],{i,Length[alternateFormData]}]]
]
SetAttributes[AlternateExpressionForms,Listable];


Example:

AlternateExpressionForms[1/2 (Sqrt[3] Cos[x] - Sin[x])]
(*==> {Cos[\[Pi]/6 + x], 1/2 Sqrt[3] Cos[x] - Sin[x]/2, -(1/4) I E^(-I x) + 1/4 Sqrt[3] E^(-I x) + 1/4 I E^(I x) + 1/4 Sqrt[3] E^(I x)}*)