MathGroup Archive 2005

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

Search the Archive

Re: Extracting coefficients for sinusoidals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60530] Re: [mg60477] Extracting coefficients for sinusoidals
  • From: "W. Craig Carter" <ccarter at mit.edu>
  • Date: Mon, 19 Sep 2005 04:45:47 -0400 (EDT)
  • References: <200509170632.CAA16738@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

This works:
f[x_] := a1*x + a1*x^2 + a1*x^3 + a4*x^4 + a5*x^5
signal = Sin[p]

Coefficient[Expand[TrigReduce[f[signal]]],Sin[3 p]]
is
-a1/4  - 5 a5/16

and
Coefficient[Expand[TrigReduce[f[signal]]],Cos[4 p]]
is
a4/8



On Sat, 17 Sep 2005, Helge Stenstrom wrote:

> Date: Sat, 17 Sep 2005 02:32:01 -0400 (EDT)
> From: Helge Stenstrom <helge.stenstrom at ericsson.com>
To: mathgroup at smc.vnet.net
> Subject: [mg60530] [mg60477]  Extracting coefficients for sinusoidals
>
> Suppose I have a signal
> signal = Sin[p]
>
> and a non-linear function
> f[x_] := x - x^3/3
>
> then
>  f[signal] = Sin[p] - Sin[p]^3/3
>
> but I don't want this form (with powers of the Sin function), but
> rather the form with multiples of p. TrigReduce can solve that:
>
>  signal // f // TrigReduce
>
>  (9*Sin[p] + Sin[3*p])/12
>
> It's easy to extract the coefficients by visual inspection,
>
>  9/12, 1/12
>
> but how can it be done programmaticaly? With a more complex non-linear
> function, for example
>
>  a1*x + a1*x^2 + a1*x^3 + a4*x^4 + a5*x^5
> using
>  signal // f // TrigReduce // InputForm
> resulting in
>  (8*a1 + 6*a4 - 8*a1*Cos[2*p] - 8*a4*Cos[2*p] + 2*a4*Cos[4*p] + 28*a1*Sin[p] +
>  10*a5*Sin[p] - 4*a1*Sin[3*p] - 5*a5*Sin[3*p] + a5*Sin[5*p])/16
>
> visual ispection is no longer simple enough. So how can I get the
> coefficients, individually or as a list?
>
> I'm not sure how I want the Cos and Sin terms to be treated; probably
> a*Cos[x] should correspond to a*I*Sin[x] when the coefficients are
> collected.
>
> --
> Helge Stenstr=F6m
>
>

W. Craig Carter
Lord Foundation Professor of Materials Science and Engineering
MIT, Dept. of Materials Science and Engineering 13-5018  77 Massachusetts Ave, Cambridge, MA 02139-4307 USA
617-253-6048  ccarter at mit.edu http://pruffle.mit.edu/~ccarter http://pruffle.mit.edu/~ccarter/FAQS/ http://pruffle.mit.edu/~ccarter/I_do_not_use_microsoft.html


  • Prev by Date: Re: Maintenance of precision in NIntegrate
  • Next by Date: Decimal comma on input
  • Previous by thread: Extracting coefficients for sinusoidals
  • Next by thread: calling a C executable from within Mathematica