Why is it possible to frequency sweep with just one sinusoid? One way to measure the frequency response of a filter is to input separate cosine/sine wave at the desired frequency, measure the steady state output, stack the inputs/outputs into complex arrays, and divide. A more efficient way is to use the DFT, and somehow we get away with just inputting one sinusoid.


Input $x_n = A \cos(\omega_0 n)$, with $\phi = 0$
Measure the steady-state output:
$$
  \begin{align*}
    y_n =  A | H(e^{j \omega_0}) | \cos\left (\omega_0 n + \angle H(e^{j\omega_0}) \right )
  \end{align*}
$$
Compute the DFTs $Y_k$ and $X_k$
Record $H_{\hat{k}} = \frac{Y_{\hat{k}}}{X_{\hat{k}}}$ at $\hat{k}$ that corresponds to $\omega_0$


What I'm trying to figure out is why this works, clearly there's phase information but I'm missing something in the derivation.

$$
\begin{align*}
  X_{\hat{k}} &amp;= \sum_{n=0}^{N-1} x_n e^{-j \omega_0 n} \quad \text{where } \frac{2\pi}{N} \hat{k} = \omega_0 \\
    &amp;= \sum_{n=0}^{N-1} A \cos(\omega_0 n) e^{-j \omega_0 n} \\
    &amp;= \frac{A}{2} \sum_{n=0}^{N-1} \left (e^{j\omega_0 n} + e^{-j\omega_0 n} \right ) e^{-j\omega_0 n} \\
    &amp;= \frac{A}{2} \sum_{n=0}^{N-1} 1 + e^{-j 2 \omega_0 n}
\end{align*}
$$

$$
\begin{align*}
  Y_{\hat{k}} &amp;= \sum_{n=0}^{N-1} A \left | H(e^{j\omega_0}) \right | \cos\left (\omega_0 n + \angle H(e^{j\omega_0}) \right ) e^{-j \omega_0} \\
    &amp;= \frac{A}{2} \left | H(e^{j\omega_0}) \right | \sum_{n=0}^{N-1} \left (e^{j(\omega_0 n + \angle H(e^{j\omega_0}))} + e^{-j(\omega_0 n + \angle H(e^{j \omega_0}))} \right ) e^{-j\omega_0 n} \\
    &amp;= \frac{A}{2} \left | H(e^{j\omega_0}) \right | \sum_{n=0}^{N-1} e^{j \angle H(e^{j\omega_0})} + e^{-j \angle H(e^{j \omega_0})} e^{-j 2 \omega_0 n} \\
    &amp; \; \Big\Downarrow \; \text{?} \\
    &amp;= \frac{A}{2} \left | H(e^{j\omega_0}) \right | e^{j \angle H(e^{j\omega_0})} \sum_{n=0}^{N-1} 1 + e^{-j 2 \omega_0 n}
\end{align*}
$$

The idea is that the phase information comes out by dividing:

$$
\begin{align*}
  H_{\hat{k}} &amp;= \frac{Y_{\hat{k}}}{X_{\hat{k}}} = \left | H(e^{j\omega_0}) \right | e^{j \angle H(e^{j\omega_0})}
\end{align*}
$$

What am I missing?
Thanks to geometrikal and Jason R, the sum of exponentials is equal to zero when $\omega_0 = \frac{2\pi}{N} \hat{k}$ and $0 \leq \hat{k} \leq N-1$, which is obvious when you realize that it's just the sum over $2 \hat{k}$ periods of $e^{-j2\omega_0n}$, where $T = \frac{2\pi}{2\omega_0} = \frac{N \pi}{2\pi \hat{k}} = \frac{N}{2 \hat{k}}$.

For $\hat{k} &gt; N-1$, I suppose you would have to zero pad, which is where the digital sinc Jason R. mentions comes in.