# Calculate harmonics using DFT from real points

I have a real data of 144 points, when I perform a 144-point DFT on this data, I get $X$ with real and complex values. I want to calculate harmonics using these $X$'s.

• The $X$ and $X$, added together and divided by 144, would give me the DC component?
• And can I just use the next 71 $X$'s and their conjugates (Euler's identity), to calculate the harmonics? I believe it's $(X[i] + X^*[i])/144$?

Sorry about that, but I have this problem to solve, I'll try and explain it and what I'm supposed to do with it. Thanks for being patient.

I have a data set of 144 points. I want to express this in terms of a DC component and it's harmonics. So, I was asked to perform a DFT operation on this and get the harmonics that would represent this data in frequency domain. I performed a 144 point DFT on this data and got 144 $X[k]$'s with real and imaginary parts. As, per my understanding these 144 $X[k]$'s ($X$ being the DC) represent the time domain signal in frequency domain, but I'm still being asked for the DC(apparently ($X+X)/2$) and the 71 harmonics, which I'm not sure how to go about.

I apologize if this still doesn't makes sense, but it's what I'm supposed to do, probably you can give me some reference where I can get such concept or anything related.

• $X$ is the DC component. I'm not sure what you mean by "calculating the harmonics." – Jason R Feb 14 '12 at 18:15
• I just mean to ask, what are the harmonics for 144 points and how do I find them? Does the array X, contain all the harmonics and DC components of the 144 points? – Raaka Feb 14 '12 at 21:08
• I still don't know what you're asking for. You need to explain what you mean by "harmonics and DC components of the 144 points." – Jason R Feb 14 '12 at 22:01
• I have added more description above, thanks for your response and sorry if this still isn't clear. – Raaka Feb 15 '12 at 1:13
• Alas, your search for "a DC component and it's harmonics" is futile since DC has no harmonics. Also, as Jason R says, it is $X$ that is the DC component, and not $(X+X)/2$. You might want to look at the inverse DFT which, ignoring scale factors, expresses $x[n]$ as a sum of pairs of terms of the form $$X[k]\exp(j2\pi kn/144) + X[144-k]\exp(j 2\pi (144-k)n/144)$$ $$= X[k]\exp(j2\pi kn/144) + X[144-k]\exp(-j2\pi kn/144)$$ for $0 < n < 71$ and use Euler's formula on those. (Hint: $X[144-k] = X[k]^*$). Note that $X$ and $X$ do not participate in the pairings. – Dilip Sarwate Feb 15 '12 at 2:11

The DFT will express your time sequence as a weighted some of complex exponential (basically a set of orthogonal functions, if that's a helpful concept for you). DC is simply a special case of a complex exponential with the frequency being 0.

Let's assume a sample rate of 1440 Hz (to make the math simple). Then the DFT coefficients mean the following:

X: amplitude at 0 Hz
X: amplitude & phase at 10 Hz
X: amplitude & phase at 20 Hz
...
X: amplitude and phase at 710 Hz
X: amplitude at 720 Hz (Nyquist frequency)


Nyquist is a little bit of an odd-ball. It's a real number so the phase is 0. The value should also be small or close to 0, otherwise you have potentially aliasing.

Since your input is real, you have complex conjugate symmetry as follows

X = X';
X = X';
....
X = X';


Just a quick comment: (X + X[72)/2 is NOT the DC value. X is.

• There seem to be some typos in this answer. If $X$ is for $100$ Hz, $X$ for $200$ Hz, and presumably so on meaning $X$ for $300$ Hz etc, how does $X$ work out to be for $710$ Hz? Shouldn't it be $7100$ Hz and the Nyquist frequency work out to be $7200$ Hz? – Dilip Sarwate Feb 15 '12 at 13:27
• I'd also note that you only have a DFT coefficient at the Nyquist frequency if the transform length is even. So, you're not always guaranteed to have two real-valued outputs. – Jason R Feb 15 '12 at 13:53
• Dilip, thanks for the typo catch. I've fixed it. Jason, good point. – Hilmar Feb 15 '12 at 14:14
• Thanks guys, I totally understand what you are saying. But I'm in deep trouble, how do I explain this to my client, who has been constantly telling me, "to combine the 0th and 72nd element to get the DC"! He keeps telling me that X and it's conjugate with Euler's identity would give me a "Harmonic". What I need to get done is perform DFT, do some operation in between and then to reconstruct the input points within some error. So, I don't want to store all the harmonics, but the one that really matter in order for me to get the curve back. Any suggestions are welcome. Thanks again. – Raaka Feb 22 '12 at 1:29