Re: Re: Expanding powers of cosine

*To*: mathgroup at smc.vnet.net*Subject*: [mg84219] Re: [mg84191] Re: [mg84184] Expanding powers of cosine*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Fri, 14 Dec 2007 04:00:29 -0500 (EST)*References*: <200712130102.UAA23849@smc.vnet.net> <200712130626.BAA06862@smc.vnet.net>

On 13 Dec 2007, at 15:26, Andrzej Kozlowski wrote: > > On 13 Dec 2007, at 10:02, michael.p.croucher at googlemail.com wrote: > >> 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 >> > > Here is one way. This is how to expand Cos[x]^24: > > First[GroebnerBasis[{Cos[x]^24, 1 - Cos[x]^2 - Sin[x]^2}, {Sin[x]}, > {Cos[x]}]] > > Sin[x]^24 - 12*Sin[x]^22 + 66*Sin[x]^20 - > 220*Sin[x]^18 + 495*Sin[x]^16 - 792*Sin[x]^14 + > 924*Sin[x]^12 - 792*Sin[x]^10 + 495*Sin[x]^8 - > 220*Sin[x]^6 + 66*Sin[x]^4 - 12*Sin[x]^2 + 1 > > Andrzej Kozlowski > In fact, more formally "correct" way to do this is by using PolynomialReduce: Last[PolynomialReduce[Cos[a]^24, {1 - Sin[a]^2 - Cos[a]^2}, {Cos[a], Sin[a]}]] Sin[a]^24 - 12*Sin[a]^22 + 66*Sin[a]^20 - 220*Sin[a]^18 + 495*Sin[a]^16 - 792*Sin[a]^14 + 924*Sin[a]^12 - 792*Sin[a]^10 + 495*Sin[a]^8 - 220*Sin[a]^6 + 66*Sin[a]^4 - 12*Sin[a]^2 + 1 GroebnerBasic gives the same answer (and PolynomialReduce uses GroebnerBasis to compute its answer) but that is a feature of the implementation rather than of the mathematics since, for exmple, returning a scalar multiple of the answer would constitute a element of a Groebner basis lying in the eliminaation idea. So, although Groebner basis can always be used to deal with such problems, formally the more correct way to deal with them is by using PolynomialReduce. Andrzej Kozlowski Andrzej Kozlowski

**References**:**Expanding powers of cosine***From:*michael.p.croucher@googlemail.com

**Re: Expanding powers of cosine***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>