Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Discrete Fourier Transform of Sine Function

  1. Jun 10, 2015 #1
    (1) For a real function, g(x), the Fourier integral transform is defined by
    [tex]g(x) = \int_{0}^{\infty} A(\omega )cos(2\pi \omega x)d\omega - \int_{0}^{\infty} B(\omega )sin(2\pi \omega x)d\omega[/tex]

    where
    [tex]A(\omega ) = 2 \int_{-\infty}^{\infty} g(x)cos(2\pi \omega x)dx[/tex]

    and
    [tex]B(\omega ) = 2 \int_{-\infty}^{\infty} g(x)sin(2\pi \omega x)dx[/tex]

    For an even function, B(ω) = 0
    For an odd function A(ω) = 0

    (2) For discrete points, the function is declared as
    [tex]g_{j} = a_{0} + \sum_{k = 1}^{[N/2]} a_{k} cos(kj\frac{2\pi}{N}) + \sum_{k = 1}^{[N/2]} b_{k} sin(kj\frac{2\pi}{N})[/tex]

    where
    [tex]a_{k} = \frac{2}{N} \sum_{j = 0}^{N-1} g_{j} cos(jk\frac{2\pi}{N})[/tex]

    and
    [tex]b_{k} = \frac{2}{N} \sum_{j = 0}^{N-1} g_{j} sin(jk\frac{2\pi}{N})[/tex]

    The text I am reading states that the discrete coefficients approximate the exact Fourier coefficients of a periodic function.

    Now, taking a baby step, say I consider the function g(x) = sin(x), the plain, old sine function.
    Since the sine function is odd, the Fourier integral transform indicates that A(ω) = 0.
    Since the exact Fourier coefficients of a periodic function approximate discrete coefficients, I expected the [itex]a_{k}[/itex] values of a DFT to be 0. But they are not. In fact, substituting the results of a DFT back into the original equation do not work without both the [itex]a_{k}[/itex] and [itex]b_{k}[/itex] values.

    Here is what I did:
    I assumed a period of 1 time unit, over 1 period, and divided the motion into uniform intervals. Calculating the sine values at each interval, this data was then fed into a DFT. The resultant transform includes both sine and cosine coefficients.

    Shouldn't it include only coefficients for the sine terms?
    What is going on? Have I made an incorrect leap in logic?
     
  2. jcsd
  3. Jun 11, 2015 #2

    jbunniii

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    So you are setting ##g_j = \sin(j)##? This does not result in an odd function when you extend it periodically. To see this, observe that ##g_1 = \sin(1)## whereas ##g_{-1} = g_{N-1} = \sin(N-1)##, which does not equal ##-\sin(1)##. Therefore, ##g_1 \neq -g_{-1}##.

    Instead, try setting ##g_j = \sin(2\pi j / N)##, or more generally, ##g_j = \sin(2\pi j k /N)## where ##k## is any integer.
     
  4. Jun 12, 2015 #3
    Here is some sample data. I wanted to have the points at t = T/4 and t = 3T/4 included, so the motion was divided into 20 uniform intervals.
    T = 1 time unit.

    Code (Text):

    k =  0    t = 0.0       sin(2*PI/20*t) =  0.0
    k =  1    t =  0.05     sin(2*PI/20*t) =  0.309016994374947
    k =  2    t =  0.1      sin(2*PI/20*t) =  0.587785252292473
    k =  3    t =  0.15     sin(2*PI/20*t) =  0.809016994374947
    k =  4    t =  0.2      sin(2*PI/20*t) =  0.951056516295154
    k =  5    t =  0.25     sin(2*PI/20*t) =  1
    k =  6    t =  0.3      sin(2*PI/20*t) =  0.951056516295154
    k =  7    t =  0.35     sin(2*PI/20*t) =  0.809016994374947
    k =  8    t =  0.4      sin(2*PI/20*t) =  0.587785252292473
    k =  9    t =  0.45     sin(2*PI/20*t) =  0.309016994374948
    k =  10   t =  0.5      sin(2*PI/20*t) =  0
    k =  11   t =  0.55     sin(2*PI/20*t) =  -0.309016994374948
    k =  12   t =  0.6      sin(2*PI/20*t) =  -0.587785252292473
    k =  13   t =  0.65     sin(2*PI/20*t) =  -0.809016994374947
    k =  14   t =  0.7      sin(2*PI/20*t) =  -0.951056516295154
    k =  15   t =  0.75     sin(2*PI/20*t) =  -1
    k =  16   t =  0.8      sin(2*PI/20*t) =  -0.951056516295154
    k =  17   t =  0.85     sin(2*PI/20*t) =  -0.809016994374947
    k =  18   t =  0.9      sin(2*PI/20*t) =  -0.587785252292473
    k =  19   t =  0.95     sin(2*PI/20*t) =  -0.309016994374948
    k =  20   t = 1.0       sin(2*PI/20*t) =   0
     
    Taking just the sine values:

    0.0
    0.309016994374947
    0.587785252292473
    0.809016994374947
    0.951056516295154
    1
    0.951056516295154
    0.809016994374947
    0.587785252292473
    0.309016994374948
    0
    -0.309016994374948
    -0.587785252292473
    -0.809016994374947
    -0.951056516295154
    -1
    -0.951056516295154
    -0.809016994374947
    -0.587785252292473
    -0.309016994374948
    0

    and inputting them into a DFT, the following results are returned:

    The ak values follow:

    a0 = 0
    0.14475387005697557
    -0.020485172200211867
    -0.016913755515248936
    -0.015944715871194427
    -0.015536943989308476
    -0.015328780935943866
    -0.015211428505699521
    -0.015142744411310508
    -0.015103970855542756
    -0.015086357772515164

    The bk values follow:

    0.9603791769948659
    -0.06641129715700931
    -0.03512177522380782
    -0.02338660289058022
    -0.01674484324556045
    -0.01222429488042325
    -0.008782322342524462
    -0.005943089235252812
    -0.003447382785156719
    -0.0011305662206714806

    Shouldn't the ak values be 0? I mean, the DFT was performed on a simple sine function, and it doesn't get any more "pure" sine than that. Yet the DFT seems to indicate it includes some cosine factors. Is that correct, or am I making some wrong interpretation?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Discrete Fourier Transform of Sine Function
Loading...