Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Expanding powers of cosine

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84184] Expanding powers of cosine
  • From: michael.p.croucher at googlemail.com
  • Date: Wed, 12 Dec 2007 20:02:45 -0500 (EST)

Hi

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;
  Expand[res]
  ]

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?

Cheers,
Mike


  • 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