MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Expanding powers of cosine


I would like to express even powers of Cos[x] in terms of powers of
Sin[x] using the identity Sin[x]^2+Cos[x]^2 = 1.  For example

Cos[x]^4 = 1 - 2 Sin[x]^2 + Sin[x]^4

I could not get any of Mathematica's built in functions to do this for
me so I created my own rule:

expandCosn[z_] := Module[{s, res},
  s = Cos[x]^n_ :> (1 - Sin[x]^2) Cos[x]^(n - 2) ;
  res = z //. s;

which works fine:

In[14]:= expandCosn[Cos[x]^4]

Out[14]= 1 - 2 Sin[x]^2 + Sin[x]^4

My question is - have I missed something?  Is there an easier way to
do this?


  • Prev by Date: Re: NIntegrate bug in Mathematica 6?
  • Next by Date: GridBox Question
  • Previous by thread: Re: Silly question about Contexts
  • Next by thread: Re: Expanding powers of cosine