5
$\begingroup$

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.

$\endgroup$
6
$\begingroup$

Use the TrigFactor[] function, as in

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

Output

Cos[Pi/6 + x].
$\endgroup$
6
  • $\begingroup$ 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. $\endgroup$ – Hermano May 22 '15 at 16:21
  • $\begingroup$ Did you mean to have a parentheses around that $m-n$? $\endgroup$ – J. W. Perry May 22 '15 at 16:24
  • $\begingroup$ no. The expression is correct. $\endgroup$ – Hermano May 22 '15 at 16:28
  • $\begingroup$ 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. $\endgroup$ – J. W. Perry May 22 '15 at 16:30
  • $\begingroup$ 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. $\endgroup$ – J. W. Perry May 22 '15 at 16:32
1
$\begingroup$

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)}*)
$\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.