Discrete Fourier Transform of Sine Function

Click For Summary
The discussion centers on the application of the Discrete Fourier Transform (DFT) to the sine function, specifically questioning why non-zero cosine coefficients (a_k values) appear when the function is expected to be purely odd. It is noted that for an odd function like sine, the Fourier integral transform indicates A(ω) should equal zero. However, when applying the DFT to sampled sine values, both sine and cosine coefficients emerge, leading to confusion about the expected results. The analysis reveals that the sampled sine function does not maintain its odd symmetry when extended periodically, which explains the presence of non-zero a_k values. This highlights the importance of correctly defining the function and its periodicity in Fourier analysis.
DuncanM
Messages
99
Reaction score
3
(1) For a real function, g(x), the Fourier integral transform is defined by
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

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

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

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

(2) For discrete points, the function is declared as
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})

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

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

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 a_{k} 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 a_{k} and b_{k} 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?
 
Mathematics news on Phys.org
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.
 
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:
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?
 
Here is a little puzzle from the book 100 Geometric Games by Pierre Berloquin. The side of a small square is one meter long and the side of a larger square one and a half meters long. One vertex of the large square is at the center of the small square. The side of the large square cuts two sides of the small square into one- third parts and two-thirds parts. What is the area where the squares overlap?

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
11K