Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9712

Re: Extract coefficients of a trig polynomial

From danl@wolfram.com
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Extract coefficients of a trig polynomial
Date 2012-04-20 11:49 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jmrifg$lea$1@smc.vnet.net> (permalink)
References <jmoge7$46g$1@smc.vnet.net>

Show all headers | View raw


On Thursday, April 19, 2012 2:55:51 AM UTC-5, Sam Takoy wrote:
> Hi,
> 
> Suppose I have an expression that is a trigonometric polynomial in
> theta. Is there a way to neatly pick out the coefficients of the
> polynomial. I find that FourierCoefficient takes quite a bit of time,
> probably because it does a lot of integrations. My coefficients are
> very complicated expressions but do not depend on theta.
> 
> Many thanks in advance,
> 
> Sam
> 
> PS: expr = (1/1536)(1536 BesselJ[0,\[Rho]]-72 \[Epsilon]^2 \[Rho]^2
> BesselJ[0,\[Rho]]-80 \[Epsilon]^3 \[Rho]^2 BesselJ[0,\[Rho]]-384 \
> [Epsilon] \[Rho] BesselJ[1,\[Rho]]-144 \[Epsilon]^2 \[Rho] BesselJ[1,\
> [Rho]]-80 \[Epsilon]^3 \[Rho] BesselJ[1,\[Rho]]+10 \[Epsilon]^3 \
> [Rho]^3 BesselJ[1,\[Rho]]-96 \[Epsilon]^2 \[Rho]^2 BesselJ[0,\[Rho]]
> Cos[2 \[Theta]]-120 \[Epsilon]^3 \[Rho]^2 BesselJ[0,\[Rho]] Cos[2 \
> [Theta]]-384 \[Epsilon] \[Rho] BesselJ[1,\[Rho]] Cos[2 \[Theta]]-192 \
> [Epsilon]^2 \[Rho] BesselJ[1,\[Rho]] Cos[2 \[Theta]]-120 \[Epsilon]^3 \
> [Rho] BesselJ[1,\[Rho]] Cos[2 \[Theta]]+15 \[Epsilon]^3 \[Rho]^3
> BesselJ[1,\[Rho]] Cos[2 \[Theta]]-24 \[Epsilon]^2 \[Rho]^2 BesselJ[0,\
> [Rho]] Cos[4 \[Theta]]-48 \[Epsilon]^3 \[Rho]^2 BesselJ[0,\[Rho]]
> Cos[4 \[Theta]]-48 \[Epsilon]^2 \[Rho] BesselJ[1,\[Rho]] Cos[4 \
> [Theta]]-48 \[Epsilon]^3 \[Rho] BesselJ[1,\[Rho]] Cos[4 \[Theta]]+6 \
> [Epsilon]^3 \[Rho]^3 BesselJ[1,\[Rho]] Cos[4 \[Theta]]-8 \[Epsilon]^3 \
> [Rho]^2 BesselJ[0,\[Rho]] Cos[6 \[Theta]]-8 \[Epsilon]^3 \[Rho]
> BesselJ[1,\[Rho]] Cos[6 \[Theta]]+\[Epsilon]^3 \[Rho]^3 BesselJ[1,\
> [Rho]] Cos[6 \[Theta]])

Not sure, but possibly this will do what you have in mind.

In[206]:= trigs = Union[Cases[expr, Cos[(_.)*\[Theta]], Infinity]]

Out[206]= {Cos[2*\[Theta]], Cos[4*\[Theta]], Cos[6*\[Theta]]}

In[207]:= (Coefficient[expr, #1]*#1 & ) /@ trigs

Out[207]= {(1/
    1536)*((-96*\[Epsilon]^2*\[Rho]^2*BesselJ[0, \[Rho]] - 
      120*\[Epsilon]^3*\[Rho]^2*BesselJ[0, \[Rho]] - 
           384*\[Epsilon]*\[Rho]*BesselJ[1, \[Rho]] - 
      192*\[Epsilon]^2*\[Rho]*BesselJ[1, \[Rho]] - 
      120*\[Epsilon]^3*\[Rho]*BesselJ[1, \[Rho]] + 
           15*\[Epsilon]^3*\[Rho]^3*BesselJ[1, \[Rho]])*
    Cos[2*\[Theta]]), 
   (1/1536)*((-24*\[Epsilon]^2*\[Rho]^2*BesselJ[0, \[Rho]] - 
      48*\[Epsilon]^3*\[Rho]^2*BesselJ[0, \[Rho]] - 
           48*\[Epsilon]^2*\[Rho]*BesselJ[1, \[Rho]] - 
      48*\[Epsilon]^3*\[Rho]*BesselJ[1, \[Rho]] + 
      6*\[Epsilon]^3*\[Rho]^3*BesselJ[1, \[Rho]])*
        Cos[
     4*\[Theta]]), ((-8*\[Epsilon]^3*\[Rho]^2*BesselJ[0, \[Rho]] - 
      8*\[Epsilon]^3*\[Rho]*BesselJ[1, \[Rho]] + 
           \[Epsilon]^3*\[Rho]^3*BesselJ[1, \[Rho]])*Cos[6*\[Theta]])/
  1536}

Daniel Lichtblau
Wolfram Research

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Extract coefficients of a trig polynomial Sam Takoy <sam.takoy@yahoo.com> - 2012-04-19 07:55 +0000
  Re: Extract coefficients of a trig polynomial danl@wolfram.com - 2012-04-20 11:49 +0000
  Re: Extract coefficients of a trig polynomial Ray Koopman <koopman@sfu.ca> - 2012-04-20 11:51 +0000
  Re: Extract coefficients of a trig polynomial Yi Wang <tririverwangyi@gmail.com> - 2012-04-20 11:54 +0000
  Re: Extract coefficients of a trig polynomial "Dr. Wolfgang Hintze" <weh@snafu.de> - 2012-04-21 04:30 +0000

csiph-web