0
$\begingroup$

So I have a sequence

{gk}^5, k=0 = {1, 0, 4, -1, 0, 0}

and I am to generate the Fourier sequence from that one. What I'm doing is simply using the formula:

Gk = gk * e^(-j2pi * n*k/T) where T = 6, n = 0...5 € Z

and to open up the previous formula because I'm sure it might look a bit confusing with the symbols I'm using/trying to use, here's how I generated G(0):

G(0) = g(0)*e^-j2pi*0*0/6) + 0 + g(2) * e^(-j2pi*0*2/6) - e^(-j2pi*0*3/6) + 0 + 0 
= 1 + 4 * e^0 - 1
= 4

and for G(1)

G(1) = g(0)*e^-j2pi*0*1/6) + 0 + g(2) * e^(-j2pi*1*2/6) - e^(-j2pi*1*3/6) + 0 + 0 
= 1 + 4(cos(2pi/3)-j*sin(2pi/3)) -(cos(pi)-j*sin(pi))
= 1 - 2 + 1 + 2*sqrt(2)j
= 2*sqrt(2)j

And this is the logic I'm using to calculate the DFT, but for some reason just about every online calculator regarding DFT is giving a different answer when compared to mine and other online DFT calculators, so I'm a little bit lost here.

Is there some glaring problem with how I'm trying to calculate the DFT or is this how it's supposed to go?

  • 0
    I have not looked into your code carefully. However, the Mathematica command Fourier[{1, 0, 4, -1, 0, 0}, FourierParameters -> {-1, 1}] gives you different results depending on what you set values of FourierParameters -> {-1, 1} to be. {-1,1} gives: {0.666667 + 0. I, 0. + 0.57735 I, -0.333333 - 0.57735 I, 1. + 0. I, -0.333333 + 0.57735 I, 0. - 0.57735 I} I don't remember what values of FourierParameters that correspond to the discrete fourier transform as formulated in Wikipedia.2017-02-07
  • 0
    for G(1) : 0*1/6, 1*2/6 you are counting up both n and k. also there are many definition of fourier transform, for example different types of normalization.2017-02-07
  • 0
    @mathreadler, so do you mean that G(1) should look like "g(0)*e^-j2pi*0*1/6)+ g(2) * e^(-j2pi*2*3/6) - e^(-j2pi*3*4/6)" instead? (I left out the redundant zeros)2017-02-07
  • 0
    It is a better idea that you learn to get the tools to check your own work. When you are going to build something with this you probably won't be having a teacher to ask.2017-02-07
  • 0
    What would you suggest if anything?2017-02-07

1 Answers 1

1

If we use Gnu Octave (and probably also if we use Matlab), the commands:

exp(-2*pi*1i*(0:5)'*(0:5)/6)*[1,0,4,-1,0,0]'

conforms with

fft([1,0,4,-1,0,0]')

which is the built in Fast-Fourier routine. Both give:

 4.00000 + 0.00000i
 0.00000 - 3.46410i
-2.00000 + 3.46410i
 6.00000 + 0.00000i
-2.00000 - 3.46410i
 0.00000 + 3.46410i

In excess of this it is important to know that there exist different definitions, for example can the normalization be different (constant multiplication).

You can take a look at the matrix

exp(-2*pi*1i*(0:5)'*(0:5)/6)

To see the coefficients in the sums too see if you got the coefficients right in the calculations.

Disrete Fourier Transform - Wikipedia ( compare Unitaire transformatie vs first expressions, there is a difference of a factor $\frac{1}{\sqrt{N}}$, where $N$ number of samples. )

Also Wolfram Alpha's answer seems to be using backwards phase (plus instead of minus in exponent) in excess to the normalization factor $1/\sqrt{6}$.

  • 0
    but the OP is using mathematica or something with symbolic calculus (sqrt(2))2017-02-07
  • 0
    Won't make a difference for this example. Single precision floating point is def. good enough for these numbers to remove doubt if calculations are right or wrong.2017-02-07
  • 1
    Actually I'm not using any programs per se, but instead only to make sure I've calculated them correctly (by hand/function calculator).2017-02-07