Discrete Fourier Transform of Sine Function

AI Thread 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?
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...
Is it possible to arrange six pencils such that each one touches the other five? If so, how? This is an adaption of a Martin Gardner puzzle only I changed it from cigarettes to pencils and left out the clues because PF folks don’t need clues. From the book “My Best Mathematical and Logic Puzzles”. Dover, 1994.
Thread 'Imaginary Pythagoras'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...

Similar threads

Replies
2
Views
2K
Replies
7
Views
2K
Replies
3
Views
2K
Replies
5
Views
3K
Replies
3
Views
2K
Replies
1
Views
11K
Back
Top