11
$\begingroup$

I found some examples of Mathematica's commands usage in an old manual but the program gives me different result than expected

Expand[Cos[x]^3 Sin[x]^2, Trig -> True]

should give

Cos[x]/8 - Cos[3x]/16 - Cos[5x]/16

but returns an unaltered expression.

I tried out Expand with Sin[x+y] added to the expression, factored that and then I get what I expected in the first place. Why is that? I am surprised because I found that example in a book about Mathematica at my university's library. Although the book is from 1991 I don't think an unaltered expression is what Expand should return. Am I wrong?

$\endgroup$
  • $\begingroup$ What was the version of Mathematica ? $\endgroup$ – Artes Dec 30 '12 at 21:49
15
$\begingroup$

The function you want for this kind of case is TrigReduce:

TrigReduce[expr]
rewrites products and powers of trigonometric functions in expr in terms of trigonometric functions with combined arguments.

And it works:

enter image description here

$\endgroup$
8
$\begingroup$

Expand doesn't work as you'd like even with Trig -> True. TrigReduce yields the experssion a bit different than expected. Instead, you can use Apart with the option Trig therein (by default Options[Apart, Trig] yields {Trig -> False}) to get exactly the expected output, e.g. :

Apart[ Cos[x]^3 Sin[x]^2, Trig -> True]
Cos[x]/8 - 1/16 Cos[3 x] - 1/16 Cos[5 x]

exploiting your approach one could do this :

Unevaluated[ Expand[ Cos[x]^3 Sin[x]^2, Trig -> True]] /. Expand -> Apart

or

(Expand /. Expand -> Apart)[Cos[x]^3 Sin[x]^2, Trig -> True]

another ways use both Apart or Expand composed with TrigToExp and its "inverse" ExpToTrig :

ExpToTrig @ Apart @ TrigToExp[ Cos[x]^3 Sin[x]^2]

or

ExpToTrig @ Expand @ TrigToExp[ Cos[x]^3 Sin[x]^2]

Edit

Let's write all functions with the Trig option :

Select[ Names["*"], ( Length[ Quiet[ Options[ ToExpression @ #, Trig]]] == 1) &]
 {"Apart", "ApartSquareFree", "Cancel", "Collect", "Denominator", "Expand",     
  "ExpandAll", "ExpandDenominator", "ExpandNumerator", "Exponent", "Factor", 
  "FactorList", "FactorSquareFree", "FactorSquareFreeList", "FactorTerms", 
  "FactorTermsList", "FullSimplify", "Numerator", "PolynomialGCD",
  "PolynomialLCM", "PolynomialMod", "Simplify", "Together"}

For their default settings :

{#, Quiet[ Options[ ToExpression @ #, Trig]]} & /@ %
$\endgroup$
  • $\begingroup$ Brilliant. I did not know Apart had that option, +1. $\endgroup$ – rcollyer Oct 27 '12 at 19:32
  • $\begingroup$ @rcollyer Thanks ! $\endgroup$ – Artes Oct 27 '12 at 19:49

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.