A closed form solution to

$$ X[k] = \texttt{DFT}\{\cos(2\pi f t + \phi)\} $$

confirmed many known properties of a finite sine's spectrum, also revealed new ones. Can the same be done for $|X|$, or $|X|^2$? Is there an expression for $|X|$ that's useful for analysis (not limited to one based on what's linked)?

For example, we know $X$ is Hermitian-symmetric for any real-valued $x$, and that $f=-f$ in spectrum, but are there any other symmetries for the sine's spectral envelope that $|X|$ can reveal? (the specific question isn't required, just an idea)

  • 1
    $\begingroup$ Hay, OLGD, are you still around? There are issues with this answer. You have discrete time on the left and continuous time on the right. $\endgroup$ Nov 25, 2023 at 17:37

2 Answers 2


This complements the other answer, while also revealing its own modulus insights. It also said my body is too large.

The denominator; sampling rate vs duration

For convenience, discarding modulus,

$$ K = \frac{1}{\cos(2\pi f/N) - \cos(2\pi k/N)} $$

For a given $f$, the left cosine is fixed and is within $[-1, 1]$. The right cosine sweeps $[-1, 1]$ once over $[0, N/2]$, and is guaranteed to approach left's value. For $f=3.5$, $N=32$, we have

where the x-axis is fractional, $k/N$. We add $K_{100}=K/100$ (rescaled to fit in same plot), in green:

where the dashed lines intersect $K_{100}$ at $k$ nearest to $f$, and is where the DFT is actually evaluated.

A helpful requisite for the following is "Addendum: Sampling Rate vs Duration" in the original article. We compare two scenarios, but we change our reference case to $f=3.25$:

Doubled sampling rate: $N \rightarrow 2N$, unchanged $f$ -- halved $f/N$

Absolute $f$ is unchanged. Samples are more tightly packed around any given $f$. For our $f=3.25$, the distances to $k=3$ and $k=4$ are approximately halved, hence the DFT is doubled.

To see the effect on all other $k$, we compare the $K$. Indeed, the new $K$ is nearly a simple shift and doubling of the previous $K$:

Orange is the previous $K_{100}$, orange dashed shifts it by $f/N_\text{new} = f/64$ and doubles it. Green is the current $K_{100}$. Over the $k$ closest to $f$, the realized values are very nearly same (i.e. doubled relative to previous). Over $k$ further out, they're also very close, except near DC. Note, near DC, the numerator also behaves differently, so this picture's incomplete.

Doubled duration: $N \rightarrow 2N$, $f \rightarrow 2f$ -- unchanged $f/N$

The denominator curve is completely untouched, as expected: its only dependence on $f, N$ is via $f/N$. But the denominator realization certainly changed: the tighter-packed $k$ samples it closer to its asymptote.

Why'd we have to double the curve before? Before, we moved in fractional space, hence also along the sweep of the numerator, which changes most rapidly near DC/Nyquist. We're double-dipping by sampling closer to asymptote and doubling all values, but that's to cancel the numerator being lower there (which, without peeking could also be higher, but we know the end-result).

Of course, the DFT certainly changes, and in this case this change is explained entirely by the numerator, whose curve has $f/N$- and $f$-dependency, latter being much more dominant.

$\Uparrow$ Duration $\rightarrow$ $\Uparrow$ Resolution [DR]

The numerator is too weak to influence resolution: the objective is to separate $f_0, f_1$, which by problem definition are apart by less than $[k, k + 1]$, over which the numerator is nearly constant.

From the previous plot, the case for duration is obvious: for another red line packed between blues in $N=32$, going to $N = 64$ inserts black dots between existing black dots:

Yet, with sampling rate, only $N$ increases, and the red lines grow closer in ratios to compensate for tighter black dots:

Mathematically: $|f_1/(2N) - f_0/(2N)| < |f_1/N - f_0/N|$, with factoring that's $1/2 < 1$, so true for all $f_0, f_1, N$. Of course what calls the shots is $\cos(2\pi f/N)$, but that's monotonic over $f/N \in [0, 1/2]$, hence the inequality holds for all $f_0, f_1, N$ (applying conjugate symmetry for intervals other than $[0, 1/2]$).

Proof: $N/4$-symmetry, even $N$

A symbolically-incomplete proof follows; code validates fully. The math is for modulus alone, but for non-modulus it's yet easier and follows immediately from the even/odd status of $U, V, k$.

First, write out the exact sign- and sine-status of $U$ and $V$, respectively, where $a, b, c$ are shorthands:

$$ \begin{alignat*}{1} N=0&:\ &\cos&(a \Delta f) &- 1, \ &\sin&(b \Delta f) &- \sin(c \Delta f)\\ N=1&:\ -&\sin&(a \Delta f) &- 1, \ &\cos&(b \Delta f) &- \sin(c \Delta f) \\ N=2&:\ -&\cos&(a \Delta f) &- 1, \ -&\sin&(b \Delta f) &- \sin(c \Delta f) \\ N=3&:\ &\sin&(a \Delta f) &- 1, \ -&\cos&(b \Delta f) &- \sin(c \Delta f) \\ N=4&:\ &\cos&(a \Delta f) &- 1, \ &\sin&(b \Delta f) &- \sin(c \Delta f)\quad (N = 0) \\ &... \end{alignat*} $$

From this, we write the symmetry statuses:

$$ \begin{alignat*}{1} N &&& U & V & UV &\ U^2 + V^2 &\ U^2 + V^2 - 2UV\cos\left(\frac{2\pi k}{N}\right) \\ 0:&\ & \text{even} &+ \text{even},\ \text{odd}\ &+\ \text{odd},\ \ & \text{odd}, \ \ \ & \text{even}, \ \quad & (\Delta k, \Delta f)\text{-even} \\ 1:&\ & \text{odd} &+ \text{even},\ \text{even}\ &+\ \text{odd},\ \ & \text{neither},\ \ \ & \text{neither},\ \quad & \text{neither} \\ 2:&\ & \text{even} &+ \text{even},\ \text{odd}\ &+\ \text{odd},\ \ & \text{odd}, \ \ \ & \text{even}, \ \quad & (\Delta k, \Delta f)\text{-even} \\ 3:&\ & \text{odd} &+ \text{even},\ \text{even}\ &+\ \text{odd},\ \ & \text{neither},\ \ \ & \text{neither},\ \quad & \text{neither} \\ 4:&\ & \text{even} &+ \text{even},\ \text{odd}\ &+\ \text{odd},\ \ & \text{odd}, \ \ \ & \text{even}, \ \quad & (\Delta k, \Delta f)\text{-even} \\ &... \end{alignat*} $$

Lots of text, one by one:

  • "$\text{even}$" and "$\text{odd}$" are with respect to $\Delta f$ - so $\text{even}$ indicates $g(-\Delta f) = g(\Delta f)$, and $\text{odd}$ indicates $-g(-\Delta f) = g(\Delta f)$, for some $g$ (cosines in $U, V$)
  • $V$ for $N=4$ is $\text{odd} + \text{odd}$ ($=\text{odd}$) because, $V = \cos(4\cdot\pi/2 + 2\pi\Delta f - \pi/2 - 2\pi(\Delta f/4)) - \cos(-\pi/2 -2\pi(\Delta f/2))$, which is $V = \sin((3/2)\pi\Delta f) - \sin(-\pi\Delta f)$. For other $N$, the second cosine stays $\text{odd}$ since it's independent of $N$, but the first becomes $\text{even}$ for odd $N$ per the $N\pi /2$ term.
  • Identical analysis for $U$'s cosine, and the $-1$ is constant in $\Delta f$ and independent of $N$, and a constant is $\text{even}$.
  • $(\text{even} + \text{even}) = \text{even}$, $(\text{even} + \text{odd}) = \text{neither}$, $(\text{odd} + \text{odd}) = \text{odd}$
  • $(\text{even})\cdot(\text{even}) = \text{even}$, $(\text{even})\cdot(\text{odd})=\text{odd}$, $(\text{odd})\cdot(\text{odd})=\text{even}$
  • Squaring is same as multiplying, hence $V$ that's $\text{odd}$ becomes $\text{even}$, but $\text{neither}$ stays
  • The $-$ and $2$ have no effect (they're equivalently $\text{even}$, by which multiplying retains status)

$(\Delta k, \Delta f)$-$\text{even}$ is the goal, takes a bit more work to show. Begin with $\Delta k$, then join with $(\Delta k, \Delta f)$:

  • Imagine sweeping $k$ from $0$ to $N/2$, except instead we increment by $\Delta k$ to left or right of $N/4$, so $k = N/4 + \Delta k$. Recall, $U, V$ are $k$-independent. For any given $U, V$, we take our offset, $U^2 + V^2$, and from it subtract $2UV\cos(2\pi k/N)$. The cosine term is odd in $\Delta k$: for $\Delta k = 0$, the cosine is zero, for $\Delta k > 0$, it grows in negatives, for $\Delta k < 0$, it grows mirrored in positives. It can be shown explicitly by plugging in $k = N/4 + \Delta k$, which gives $-\sin((2\pi/N)\Delta k)$. Hence, the full term is odd in $\Delta k$.
  • Since the offset is $\text{even}$ in $\Delta f$, this part's taken care of. To show that $-2UV\cos(2\pi k/N)$, or rather $UV\cos(2\pi k/N)$, is even in $(\Delta k, \Delta f)$, is to show - let $U = u(\Delta f)$ - $u(\Delta f)v(\Delta f)\sin((2\pi/N)\Delta k) = u(-\Delta f)v(-\Delta f)\sin(-(2\pi/N)\Delta k)$. This is shown by observing that each sub-equality is true within a minus sign - that is, separately for $u(\Delta f)v(\Delta f)$ and for $\sin((2\pi/N)\Delta k)$. The sub-equalities are true within a negative since they're odd, and since there's two sub-equalities and two negatives, the negatives drop and yield equality in time reversal, or even-ness.

All together:

$$ \boxed{ U^2 + V^2 - 2UV\cos(2\pi k/N) \\ = \\ u^2(\Delta f) + u^2(\Delta f) + 2u(\Delta f)v(\Delta f)\sin((2\pi/N)\Delta k) \\ = \\ u^2(-\Delta f) + u^2(-\Delta f) + 2u(-\Delta f)v(-\Delta f)\sin(-(2\pi/N)\Delta k) } $$

Same can be shown replacing $(\Delta f)$ with $(\Delta f, \phi)$ everywhere above; it's a change of variables (but not a direct substitution).

Lastly, we've neglected two parts of $|X[k]|$. Its denominator: realizing it's entirely controlled by how $f$ and $k$ differ, and inspecting sweeps to left and right of $N/4$, its symmetries easily follow; it also equals $-2\sin\left(\frac{\pi}{N}(\Delta f - \Delta k)\right)\cos\left(\frac{\pi}{N}(\Delta f + \Delta k)\right)$. And, the square-root: one-to-one pointwise operators don't change symmetry status.

From Hermitian symmetry, identical status about $-N/4$, i.e. $N - N/4$, immediately follows.

What of (complex) $X$? It's conjugate even-symmetric, validated in code. It's likely even easier to prove, only need to consider $U, V, e^{j...}$ and the denominator, but I realized this later.

Why even $N$? Odd $N$'s cosine is only symmetric (of any kind) about $N/2$, hence none of the dependencies - $k, f, \phi$ - have symmetry.

Odd $N$, approximate $\lfloor{N/2\rfloor}/2$-symmetry

The larger the $N$ the better, eventually becoming float-equal, and the convergence on the cosine is rapid: $(N, \texttt{rel_l2}) = $ $(101, p10^{-2}), (1001, p10^{-3}),$ $(10001, p10^{-4})$, where $p=3.1$ (coincidental) and $\texttt{rel_l2} = \|x_0 - x_1\| / \|x_0\|$. But, the symmetry is over $\lfloor{N/2\rfloor}/2$, and the distinction from $N/4$ is significant. For $N = 10001$ and $(\Delta f, \Delta \phi) = (50.3, 0.145)$, it's $1.2 \times 10^{-6}$ for $|X|$ and $2.3 \times 10^{-6}$ for $X$, so much better than the formula's cosine by itself.

Why? The continuous cosine is symmetric just fine, sampling makes the mess.

Proof: shifting sinusoidally modulates $X$ with frequency $f$

To see exactly what's happening, we find $X_\tau[k]$ and express it in a form as closely as possible to $X[k]$, where $X[k] = \texttt{DFT}\{\cos(2\pi f t + \phi)\}$ and $X_\tau[k] = \texttt{DFT}\{\cos(2\pi f (t + \tau) + \phi)\}$.

First, simplify $X_\tau$ by realizing it's simply $\texttt{DFT}\{\cos(2\pi f t + \phi_\tau)\}$, where $\phi_\tau = \phi + 2\pi f \tau$. Hence, $U, V$ are:

$$ \begin{align} & U = \cos(2\pi f + \phi + 2\pi f\tau) - \cos(\phi + 2\pi f \tau) \\ & V = \cos(2\pi f + \phi + 2\pi f\tau - 2\pi f/N) - \cos(\phi + 2\pi f\tau - 2\pi f/N) \end{align} $$

$\tau$ is the only variable, so all else becomes a phase shift, and we have

$$ \begin{align} & U = \cos(2\pi f \tau + l_0) - \cos(2\pi f \tau + l_1)\\ & V = \cos(2\pi f \tau + l_2) - \cos(2\pi f \tau + l_3) \end{align} $$

Sum of sines of same frequency is another sine of same frequency, hence

$$ \begin{align} & U = a\cos(2\pi f\tau + p)\\ & V = b\cos(2\pi f \tau + q) \end{align} $$

We seek to simplify $Ue^{j2\pi k/N} - V$. That's

$$ \begin{align} a\cos(2\pi f\tau + p)s[k] - b\cos(2\pi f\tau + q) \end{align} $$

where $s[k] = s_\text{re}[k] + j s_\text{im}[k]$ is cisoid's shorthand. Realizing $V$ is real-valued, we thus have

$$ \begin{align} \Re e\{X_\tau[k]\} &= \frac{1}{2}K[k] \bigg(a\cos(2\pi f \tau + p) s_\text{re}[k] - b\cos(2\pi f\tau + q) \bigg) \\ \Im m\{X_\tau[k]\} &= \frac{1}{2}K[k] a\cos(2\pi f \tau + p) s_\text{im}[k] \end{align} $$

"Modulation" is multiplication, so we seek ratios: take a shift $\tau$ and divide by the $\tau=0$ case:

$$ \begin{align} \frac{\Re e\{X_\tau[k]\}}{\Re e\{X_0[k]\}} &= F[k] \bigg(a\cos(2\pi f \tau + p)s_\text{re}[k] - b\cos(2\pi f\tau + q)\bigg) \\ \frac{\Im m\{X_\tau[k]\}}{\Im m\{X_0[k]\}} &= G\cos(2\pi f\tau + p) \\ \end{align} $$

which works wonders for the imaginary part, but not real.

A simplification for the real part does arise if we're tracking just one $k = k_0$: this combines the sines and produces a sine whose amplitude and phase are $k_0$-dependent. We simplify notation by replacing $X_0$ with $X$, since $X$ already refers to the general $x(t) = \cos(2\pi f t + \phi)$, and avoid referring to any previous placeholders, only tracking whether they're $k_0$-dependent. Lastly, to express the result in samples (recall how $t$ is defined), we use $\tau/N$ instead of $\tau$ in all above equations, which remains a simple substitution in the end result. All together:

$$ \boxed{ \begin{align} \Re e\{X_\tau[k_0]\} &= \Re e\{X[k_0]\} \cdot L_0 \cos(2\pi f \tau/N + p_0), \\ \Im m\{X_\tau[k]\} &= \Im m\{X[k]\} \cdot L_1 \cos(2\pi f\tau/N + p_1), \\ (L_0, &\ p_0) = \texttt{f}\{f, N, \phi, k_0\},\ (L_1, p_1) = \texttt{g}\{f, N, \phi\} \\ \end{align} } $$

where $\texttt{f}, \texttt{g}$ are symbolic shorthands for functions that return constants, with constants' respective dependencies passed as arguments. If desired, closed form expressions for $L_0, L_1, p_0, p_1$ aren't too hard to find, but here our goal was just showing the effect of shifting by $\tau$ on the spectrum, which we've accomplished.

Interpretation summary

As a sine is being shifted in time by $\tau$,

  • All imaginary bins are modulated by a sine of frequency $f$ as a function of $\tau$, with modulation amplitude and offset that depends on the sine.
  • A given real bin modulated by a sine of frequency $f$ as a function of $\tau$, with modulation amplitude and offset that depends on the sine and the bin.

where "offset" = fixed phase, and "the sine" = original, unshifted $x(t)$.


I took non-nice $f, N, \phi, \tau$ and produced the following:

Red = positive, blue = negative, white = zero, and each plot is color-normed to its own maximum, with |max red| = |max blue|. The $x(t - \tau)[n]$ is to emphasize that it's a sampling of a shift, not a shift of sampling. Confirming the modulation's frequency matches input's:

where the overlap in right plot is imperfect because it's a circular shift of an arbitrarily long segment. Same's confirmed for R.

Without writing a whole bunch of stuff, let's just say that the odds of these plots being a happy coincidence are zero. The real part may look like it has tilted white lines, hence not pure sine along $\tau$, but it's an optical illusion that's revealed by plotting the rows/columns individually in 1D. I don't validate further elsewhere, but code to reproduce the plots is included in "Code validation".

Proof: shifting sinusoidally modulates $|X|^2$ with frequency $2f$

Pursuing $|X_\tau|/|X|$ here will be a mistake (explained later); instead, we go straight for $|X_\tau|$. Following the previous proof, we have

$$ \begin{align} \Re e\{X_\tau[k]\}^2 &= \Re e\{X[k]\}^2 \cdot L_0^2 \cos^2(2\pi f \tau/N + p_0), \\ \Im m\{X_\tau[k]\}^2 &= \Im m\{X[k]\}^2 \cdot L_1^2 \cos^2(2\pi f\tau/N + p_1) \end{align} $$

and of course

$$ |X_\tau[k]|^2 = \Re e\{X_\tau[k]\}^2 + \Im m\{X_\tau[k]\}^2 $$

Since we give up on $k$-independence (explained later), we rid of $\Re e\{X[k]\}^2$ by merging it with $L_0^2$, and likewise for $L_1$, yielding

$$ D_0^2\cos^2(2\pi f\tau/N + p_0) + D_1^2\cos^2(2\pi f\tau/N + p_1),\ \tag{x} \\ D_0 = \Re e\{X[k_0]\}L_0,\ D_1 = \Re e\{X[k_0]\}L_1 $$

which expands to

$$ \frac{1}{2}(D_0^2\cos(4\pi\tau/N + 2p_0) + D_1^2\cos(4\pi\tau/N + 2p_1) + D_0^2 + D_1^2) \tag{y} $$

which simplifies to

$$ D\cos(4\pi\tau/N + 2p_0) + \cos(4\pi\tau/N + 2p_1) + E $$

which simplifies to, in finalized form,

$$ \boxed{ |X_\tau[k_0]|^2 = A\cos(2\pi 2 \tau/N + p) + B,\\ A, B, p = \texttt{f}\{f, N, \phi, k_0\},\ |A| \leq B } $$

Again, the utility is in tracking individual bins - we don't care what $A, B$ are, as long as not $\tau$-dependent. (Note, $\texttt{f}$ here's different from earlier)

The $|A| \leq B$ is forced from $(\text{x})$, and experimentally $|A| \ll B$ and $|A| \approx B$ are possible. It's forced since $(\text{x}) \rightarrow (\text{y})$ is conditioned upon it: $(\text{x})$ is only a sum of square sines, which is another square sine with offset, and not sine modulus (no "wrapping").

Why not derive for $|X_\tau| / |X|$?

I've tried, and the result doesn't show sinusoidal dependence on $\tau$ (though still has period $2\pi/(2\tau)$), while experimentally it is sinusoidal. The expression also includes the reference's bins, $|X[k]|$. Combined, these suggest we've compressed too much into $L_0, L_1, p_0, p_1$ that'd otherwise allow cancellation and obtaining of sinusoidal behavior. We could've also originally taken the path of deriving just for $X_\tau$, but we'd be unable to show any $k$-independent behavior (which we have for the imaginary part). Since we've already established the real part isn't $k$-independent, it of course follows for modulus.

Proof: shifting modulates energy ratios with period $2\pi / (2f)$ (sometimes near-sinusoidally)

Leakage can be measured this way. Define "energy ratio" as

$$ \texttt{ER}_I\{X_\tau\} = \frac{ \sum_{k\in I}|X_\tau[k]|^2 } { \sum_{k\notin I}|X_\tau[k]|^2 } $$

where $I$ is an interval or set of indexes, e.g. $[0, 1, 2, 5, 8]$. So, we're dividing energy of $X_\tau$ over some indices, by energy of $X_\tau$ over all other indices (non-overlapping).

Following the previous proof, we write out the sums for a dummy case, $N=4$:

$$ \texttt{ER}_I\{X_\tau\} = \frac{ A[0]\cos(4\pi\tau/N + p[0]) + A[3]\cos(4\pi\tau/N + p[3]) + B[0] + B[3]} { A[1]\cos(4\pi\tau/N + p[1]) + A[2]\cos(4\pi\tau/N + p[2]) + B[1] + B[2]} $$

which, by same logic as always, and for any $N, I$, reduces to

$$ \boxed{ \begin{align} & \texttt{ER}_I\{X_\tau\} = \frac{C_0\cos(2\pi2\tau/N + q_0) + D_0} {C_1\cos(2\pi2\tau/N + q_1) + D_1} \\ & C_0, C_1, D_0, D_1, q_0, q_1 = \texttt{f}\{f, N, \phi, I\} \\ & |C_0| \leq D_0,\ |C_1| \leq D_1 \end{align} } $$

where the $C, D$ constraints follow by necessity ($\texttt{ER}$, numerator, and denominator are all $\geq 0$; also see previous proof). $\texttt{ER}$ is the most sinusoidal if $|C_1| \ll D_1$, and due to the constraints, it is the only criterion: sinusoid-ness is measured by $|D_1 / C_1|$ (explained below).

Sinusoidness criteria: Suppose $|C_1| \ll |D_1|$, and use $|D|$ for reading ease; then:

  • $|C_0| \approx |D_0|$: numerator is very sinusoidal, denominator is very constant: ratio is very sinusoidal
  • $|C_0| = |D_0| / 2$: denominator unaffected (still very constant)
  • $|C_0| \ll |D_0|$: numerator and denominator are very constant. Breaking up the fraction into its two numerator terms, we see left (one with $C_0$) vanishes, right is a big constant divided by a sine with big DC offset. The result is very sinusoidal - and I'm unsure why.
  • If $|C_1| \approx |D_1|$, we end up with a $U, V$ situation: the denominator dominates, and no matter what happens with $|C_0|, |D_0|$, the ratio's never sinusoidal. Ratio tends to $\sec(x)$.
  • Example

    Left vs right: same $f, N$, different $I$:

    • Top row: $\texttt{ER}$ (blue) -- mean of sine (orange) -- sine, trimmed (green) -- each is zoomed ideally onto itself, so not drawn to scale relative to each other
    • Middle row: $\texttt{ER}$ numerator (blue) -- $\texttt{ER}$ denominator (orange) -- y-limits are zero to max, but different for left and right
    • Bottom row: $\texttt{ER}$ denominator -- y-limits are same for left and right

    We see that an individual bin modulates per same frequency as the sine, and that $\texttt{ER}$ always has double the frequency but is sinusoidal only if the denominator sine's minimum is close to zero. Note, these aren't formula-generated, they're results from an actual sine and its fft:

    In general, there need not be much "meaning" attached, but in this case there is: left's interval is a superset (fully includes) of right's, and is x10 larger, and is centered around the DFT's peak. This is measuring leakage. Yet, from what we know so far, we cannot have predicted this result - we know left requires $|C_1| \approx |D_1|$, i.e. $|X|$ is strongly modulated away from its peak as a function of $\tau$. This would occur if the real and imaginary bins are modulated about equally strongly - yet the real bin's modulation is $k$-dependent, which we've not explored.

    Though we've not explored it, we do have the earlier heatmaps: there, each heatmap's color maxima are calibrated with respect to their own inputs - reproduced here for convenience (left shows $\Re e\{X_\tau\} / \Re e\{X\}$, right for imaginary part, y-axis is $k$, x-axis is $\tau$):

    However, if we set color min/maxima to be same...

    away from peak, they indeed become ~same. Conversely, if we confine $I$ to be close to peak, the $\texttt{ER}$ becomes very sinusoidal, since now the denominator isn't strongly sinusoidally modulated per differering $\Re e$ vs $\Im m$ modulations.

    $U, V$ sweeps

    • Red = positive, blue = negative, white = zero
    • $f$ is never integer (in linearly sweeping, if it were integer, I did f *= 1.0001)
    • All sweeps are linear; I tried log, I didn't find something interesting
    • Plots don't interpolate and the first section is heavily aliased (but not second), but I found that interpolation interpolates incorrectly. The second section is more pixelated because the sampling grid is smaller to avoid aliasing (this time it's bad aliasing)

    Fixed $N$, varying $f, \phi$:

    Fixed $\phi$, varying $f, N$:

    Heavy $\phi$-dependence near DC/Nyquist; time-domain perspective

    A low-frequency sine, over a finite segment, if shifted, changes significantly. Imagine 1/8 of period of a sine - depending where exactly we're looking, it could be all near $0$, all near $1$, or $-1$. On the other extreme, imagine Nyquist - $[1, -1, 1, -1, ...]$ - shifting does nothing. For general high frequencies, shifting likewise doesn't much affect "how much sine" there is (energy).

    How many periods (or cycles) "we're looking at", if the sine is plotted, is exactly what determines DFT's $f$, and not $f/N$. Low $f$'s effect is entirely due to duration deficit - high $f$'s effect is entirely due to sampling rate deficit.

    High frequencies are affected, if near Nyquist. Nyquist and DC themselves are excluded (easily confirmed for DC). Plotting said frequencies reveals why - below. As to why the plot is this way - with real consequences for local energy - it's covered in detail here. Off-topic, this can validly interpret as "amplitude modulation": in short, if assuming bandlimited case and sticking with Fourier definitions of "bandlimited" and "frequency", then not - and "not" is generally best.

    Addendum: Original version vs Modified

    $$ \boxed{ \texttt{DFT}\{\cos(2\pi f t + \phi)\}_{f \notin \mathbb{Z}}[k] = \frac{1}{2}\frac{1}{{\cos(2\pi f/N) - \cos(2\pi k/N)}} \left[ \\ \ \ (\cos(2\pi f + \phi) - \cos(\phi)) e^{j 2\pi k/N} - \left( \cos(2\pi f + \phi - 2\pi f/N) - \cos(\phi - 2\pi f/N) \right) \right] \\ } $$

    is what $U, V$ expand to. I showed the other version on top since this one looks a lot more complicated.

    Though longer, this form is superior for analysis: each of $U, V$ can be understood nicely, and once so, it's analytically irreducible: $Ue^{j2\pi k/N} - V$.

    The previous paragraph is what the reader should believe, temporarily. In reality, I found the other version only after I already finished all the work in this post and ones I reference, and I lack time to amend. I did, however, compare the two forms: in short, for analyzing spectrum behavior, the modified variant is mostly superior - for parameter recovery and other purposes, I can't speak there, but Cedron has used OV.

    Let "OV" = original version, "MV" = modified version:

    • Despite, expanded, the $UV$ formulation being much longer, there's only one numerator. The product with $\sin(\pi f)$ is the "second numerator"; once something's proven/understood for the numerator in $UV$ form, it's proven/understood period - not so with MV.
    • MV has its own version of $UV$ we can write: $\sin(\pi f)[U'e^{j2\pi k/N} - V']$ - and the $U'$ and $V'$ are simpler.
    • The $U'V'$ formulation is superior for $\phi$ analysis: $UV$ has four sines with $\phi$, $U'V'$ two.
    • $UV$ or not, the sheer fewer number of things to track is bound to win sometimes (MV).

    Revisiting all my work throughout the different posts, the MV would've made life easier in many places. Without saying much further, I don't rule it fully in favor of MV either.

    Note, the second solution also has a different denominator, but I kept OV's denominator in MV: here I'm confident OV's is superior - it's a single $k$-dependent.

    Simulations used

    Messy, not meant for others, but if anyone's interested:


    Same as in other answer, except the URL; if arbitrary (check your instructions), I prefer the other answer linked even if only this one contains what's cited.

    Code validation

    Linked in the other answer.


    This answer is based on this solution, and is best read after reading it.

    "I don't really care about all this, short version?" - read what's bolded, see images.

    Result & main insights

    The integer case - sparing a bunch of algebra (factor reals & imaginaries, square, trig identities, combine) - is

    $$ \boxed{ |X[k]|_{f\in \mathbb{Z}} = \frac{N}{2}\sqrt{ \delta[(k - f)_N] + \delta[(k + f)_N] + \delta[(k - f)_N] \delta[(k + f)_N](2\cos(2\phi)) } \\ |X[k]|_{f\in \mathbb{Z}, f\notin [0, N/2]} = \frac{N}{2}\big(\delta[(k - f)_N] + \delta[(k + f)_N]\big) } $$

    For the non-integer case, it's not hard to show: $|Ue^{jx} + V| = \sqrt{U^2 + V^2 - 2UV\cos(x)}$. Hence:

    $$ \boxed{|X[k]|_{f\notin \mathbb{Z}} = \frac{1}{2}\left(\frac{1}{|\cos(2\pi f/N) - \cos(2\pi k/N)|}\right) \sqrt{U^2 + V^2 - 2UV\cos(2\pi k/N)}} $$


    $$ \begin{aligned} & U = \cos(2\pi f + \phi) - \cos(\phi) \\ & V = \cos(2\pi f + \phi - 2\pi f/N) - \cos(\phi -2\pi f/N) \end{aligned} $$

    Unless stated otherwise, $f$ is non-integer, $|X|$ and "the spectrum" refer to sine's $|X|$ and spectrum, "the modulus" is sine's $|X|$, and domain bounds (e.g. $k \leq N/2$) all stay within $[0, N/2]$ and always carry to $[N/2, N-1]$ by conjugate symmetry. "Root term" and "numerator" are same. Wording around "the denominator" is inconsitent on purpose; it's clear from context (e.g. "denominator explodes" can mean "denominator goes to zero"). Optional reading is in greyed boxes, revealed by clicking.

    One can show, $U^2 + V^2 \geq 2UV$ for all $U, V \in \mathbb{R}$, so the root's argument is non-negative, further validating all relations. The following insights are revealed (or confirmed):

    1. Envelope decays according to $1/x$, with asymmetric stretching near DC and Nyquist. Fixing all else and varying only $k$, our mathematical form is $\sqrt{a - \cos(2\pi k/N)}/(b - \cos(2\pi k/N))$, or $\sqrt{a - x}/(b - x)$. Yet, the numerator is a smooth cosine sweep over $U^2 + V^2 \pm 2|UV|$ that's approximately locally constant near the peak (see "The root term"), hence the dominant behavior is according to $1/x$. The exception is $x\rightarrow a$, where the numerator dominates - math details reveal this is when $f$ is near DC or Nyquist (below, "Envelope decay rate", "Envelope asymmetry").

    2. Spectrum is never zero for non-integer $f$. We know that leakage is infinite, but since sinc has zero-crossings, one might reason that so does a sine's spectrum. That $U^2 + V^2 \mp 2UV$ being zero, i.e. $U=\pm V$, is attained only for integer $f$ and a degenerate case $U=V=x=0$, proves otherwise. This is seen by looking at a cosine's increments as its arguments' deviations from a multiple of $\pi$. The degenerate case is inobvious, $f=N/2$ (odd $N$ for non-integer), which is aliased, and zero with $\phi = \pi/2$ and its odd integer multiples: $x=\cos(2\pi f t \pm \phi) = \cos(2\pi \frac{N}{2}\frac{1}{N}[0, 1, ..., N - 1] \pm \pi/2) =$ $\mp\sin(\pi [0, 1, ..., N - 1])=[0, 0, ..., 0]$.

    3. Spectrum is $f$-symmetric about $N/4$, hence envelope is equally affected by proximity to DC and Nyquist ($(f, \phi)$-symmetric, and exact for even $N$, approx. for odd). The denominator is controlled fully by $k$'s proximity to $f$, so it can see neither DC nor Nyquist. The numerator's functional form is symmetric in $U, V$, and $U,V$'s cosine arguments both differ only by $2\pi f/N$, which is $\pi/2$ for $f=N/4$, and $\cos(\pi/2)$ is a zero-crossing and a point of symmetry (likewise for $\sin(\pi/2)$ in $e^{j....}$ in the complex case). More in "The root term", proof and exact statement in "Proof: $N/4$-symmetry".

    4. Envelope decay behavior is approximately same for all $f$ except near DC & Nyquist. The denominator is controlled exclusively by $k$'s proximity to $f$, meaning the differences in decay behavior are determined fully by the root term, which itself depends on how different $U$ and $V$ are, but is always a smooth cosine sweep over $k$. Since the lower bound is $0$, it's still possible to get especially rapid changes in ratios of subsequent $k$ (i.e. rapid decay), and because the said bound is only ever achievable with extrema of the cosine sweep, which only happen at $k=0$ and $k=N/2$, it follows that any unusual decay behavior can only occur near $0$ or $N/2$, and for $|X|$ to not be negligible when it happens, $f$ of course also must be near $0$ or $N/2$. To show this possibility is indeed realized with said $f$ takes more work - see "Envelope asymmetry".

    5. Energy of sines with frequencies very close to DC or Nyquist is heavily phase-dependent. This follows the integer $f$ case, where $f$ being zero or Nyquist are the only ones with $\phi$-dependence. It follows because the DFT is stable in norm with respect to $f, \phi$ - that is, small changes in either cannot cause drastic changes in DFT, because they do not cause drastic changes in $x[n]$ (this is called "stability"), and we have Parseval-Plancherel's theorem. That is, non-integer $|X[k]|$ is a smooth continuation of integer $|X[k]|$, which actually holds of all $f, \phi, N$ over $k$, as it must for stability. "Very close" means $|f| < 0.5$ and $|f - N/2| < 0.5$ - but I've only confirmed this experimentally, without proof.

    Indeed, it's not fractional and more $f$ don't qualify for larger $N$ - and it's not sufficient to argue smooth extension to prove this, as other behaviors do persist fractionally (e.g. asymmetric decay), but I've not looked further. Also, $=0.5$ in previous eliminates $\phi$-dependence, so it's more like $\ll 0.5$. Odd $N$ also qualifies. A more complete statement is, energy's phase-dependence grows as $f$ nears DC or Nyquist, but is only "heavy" if "extremely" close. Experimentally, this "growing" is fractionally ($f/N$) true, yet the "heavy" part remains only for absolute $f$.

    1. Greater duration reduces energy's phase-dependence for sines with very low or high frequencies. This is a reformulation of analysis in the previous point: for the same physical $f_\text{phys}$ over the same duration, greater sampling rate only increases $N$ in DFT, without changing DFT's $f$ - while increasing the duration also increases DFT's $f$. Note, it's both the energy of DFT and energy of sines themselves (PP-theorem)!

    Below can't be easily inferred from the equations themselves, but are covered later:

    1. Power bins are modulated sinusoidally with double input's frequency as the sine shifts. Ctrl + F "Proof: shifting sinusoidally"

    2. Spectrum energy ratios are modulated with half of input's period as the sine shifts, sometimes near-sinusoidally. Ctrl + F "Proof: shifting modulates"

    3. Spectrum is controlled completely by $f/N$, $f$'s decimal, and $\phi$'s $2\pi$-modulo. Ctrl + F "is what mainly controls".

    4. Envelope is mainly controlled by $k$'s proximity to $f$. Explained in several places but I just bold it here.

    5. $f$-uniqueness within $N/4$, and (unproven) $\phi$-uniqueness within $\pi$: envelope is completely mapped out by $f$ over a continuous interval of size $N/4$, and respectively for $\phi$. Ctrl + F "uniqueness within".

    6. Greater duration, not sampling rate, increases resolution. Confirms the known result. Minimal version is: first plot in "The root term" and in "The denominator;", and Ctrl + F "[DR]".

    7. D-CT Convergence: $\lim\limits_{N\rightarrow\infty,f\rightarrow\infty}\texttt{DFT}\{\cos(2\pi f t + \phi)\} = \mathcal{F}\{\cos(2\pi f t + \phi)\}$, where $\mathcal{F}=$ Fourier transform. Substituting $\lim\limits_{T\rightarrow\infty} (fT)/(NT) = f/N$, and since $k$ is continuous, $k/N = f/N$ is guaranteed and the denominator explodes. The integer $f$ case handles itself. (The original limit may not be accurate, but $T\rightarrow\infty$ should be, either way I'm not sure it's fully proper math.)

    $X$, $|X|$, and $N/4$-symmetry are fully code-validated, at bottom of this article.

    Why bother with modulus?

    "If a butterfly sneezes on the sine, all this analysis is out the window". Yes and no.

    We bother because the envelope says "how much spectrum" there is for all bins, without telling what the real and imaginary parts are exactly. The question isn't how is the envelope useful (which it very much is), but how is a sine's envelope useful for predicting envelopes of other signals?

    It's useful because more conclusions can be drawn about it and easier, than about $X$, since $|X|$ is lower-information, and because certain conclusions are overcomplicated for $X$ but not $|X|$. Some conclusions that were easier to find for $|X|$ may also hold for $X$, which is how I discovered $N/4$-symmetry.

    Besides that, the question is whether $|X|$ remains useful if we seek to express an arbitrary $x(t)$ as a sum of $\cos(\omega_i t + \phi_i)$. The answer's a weak "yes", and it'll require strong familiarity with said conclusions.

    Thus, to "Should I, a reader who won't do advanced and intricate analysis with this stuff, read beyond "insights" in the first section of this article" - the answer is no.

    Envelope decay rate

    Point 1 is elaborated here.

    The $\sqrt{a - x}/(b - x)$ observation is most useful for realizing that there's possibly unusual behavior. It is possible to analyze by computing $a, b$ precisely and relating to $f, N, \phi$, as I've first done, but it gets unnecessarily complicated.

    It suffices to look at numerator (root term) vs denominator. From the first plot in "The root term", it's clear that the numerator is approximately linear (rather than "constant") over any small $k$ interval, and near $f$, changes much less than the denominator (any green curve in "The denominator" plots). This "linear" sounds like replacing the numerator with $x$, and it is, but forget symbols and think variability: numerator change little, denominator change lot, denominator win.

    The exception is $f$ near DC/Nyquist. Indeed, without knowing what $a, b$ are, we can't tell the extent to which $\sqrt{x}$ and $x$ cancel in $\sqrt{a - x}/(b - x)$. But we know what they are, rather what they can't be: canceling means sharing zeros, yet we know numerator's zeros can only ever happen at $0$ or $N/2$, while denominator's is at $f$. Elaborated in "Envelope asymmetry".

    Envelope asymmetry

    A simple hint at DFT's behavior is by observing that the numerator can only ever tend to zero near $k=0$ and $k=N/2$ (see plot in "The root term"), and $|X[k]|$ already tends to zero for $f$ away from $0$ and $N/2$ per the denominator. Tending to zero maximizes ratios between values at adjacent $k$: if values differ by $0.1$, $0.2 / 0.1$ is much bigger than $0.9 / 0.8$.

    To confirm that $f$ being near $0$ or $N/2$ actually realizes the only possibility of rapid decay of $|X|$ to zero, we show that it results in $|U| \approx |V|$ (see point 3 under "The root term"). For $f\approx 0$, $2\pi f/N$ is negligible unless $N$ is very small, so - let $\epsilon \approx 0$ -

    $$ \begin{aligned} & U = \cos(2\pi f + \phi) - \cos(\phi) \approx 0 \\ & V = \cos(2\pi f + \phi - \epsilon) - \cos(\phi - \epsilon) \approx 0 \\ \end{aligned} $$

    hence $U, V$ grow together as $f$ changes, and retain approximate magnitude equality. We could repeat this analysis for $f=N/2$, but the identical result follows from $N/4$-symmetry (for even $N$, but it's indeed doable).

    Yet, all of the above isn't sufficient: the numerator and denominator must be considered jointly. Turns out, it's about the relative asymmetries of numerator vs denominator:

    Red vertical lines are $\lfloor{f\rfloor}/N$ and $\lceil{f\rceil}/N$ (nearest $k$); what matters is the ratios of where they cross the numerator (purple) and denominator (green, which divides by 1200); dashed black is $|X|$ (green times purple, times 4). We see, that the ratio of crossings of the numerator are greater than denominator's: the vertical distance is nearly same, but purple is closer to $0$.

    Since $|X|$ is mainly controlled by $f/N$, this asymmetry manifests in the same place in a full plot of rfft - e.g. if screen in 10cm wide, there'll be asymmetry if the sine peaks at 1cm or 9cm, for all $N$ except very small.

    For small $N$, there's firstly not enough points to express asymmetry. But also, $f/N$ and $k/N$ vary a lot with $f$ and $k$, which limits how close the cosines can be in the denominator, hence also limiting the ratios of values in the denominator, and "decay" is just ratios. Of course we still have infinitely rapid decay for integer $f$, but it's about $f$ having to be closer and closer to being integer to observe decay for small $N$, since otherwise there aren't $k/N$ that are sufficiently close to the $f/N$ (in the cosine sweeps).

    The root term

    In words: as we sweep $k$, we subtract scalings of $2UV$ according to a sinusoid, from a fixed upper bound controlled by input parameters. $k$ traces out one cycle of a cosine over $[0, N -1]$, zero-crossing at $N/4$ and its mirror, so the root term peaks at $k=0$, falls over $[0, N/4]$ rises over $[N/4, N/2]$, and is lowest at Nyquist, for any input parameterization. Since we know that the spectrum strongly depends on $f$, yet the variability imposed by $U, V$ is largely consistent for all parameters, this further emphasizes $k$'s proximity to $f$ in determination of peak location.

    For convenience:

    $$ \begin{aligned} & U = \cos(2\pi f + \phi) - \cos(\phi) \\ & V = \cos(2\pi f + \phi - 2\pi f/N) - \cos(\phi -2\pi f/N) \\ \end{aligned} $$

    (1) Non-negative radicand: closest to zero is with sign-aligned $U,V$ and cosine at 1, or sign-opposite $U,V$ and cosine at -1. With real-valued $U,V$, first is $U^2 + V^2 - 2UV = (U - V)^2 \geq 0$ - second is $U^2 + V^2 + 2UV = (U + V)^2 \geq 0$.

    (2) $[0, 4]$-bound: max of $|U|, |V|$ is $2$ for both, since two sines in each, and $(2^2)(2^2) + 2(2)(2) = 16$. The only case of reaching $16$ is $|U|=|V|=2$, and it guarantees a full sweep from $0$ to $16$. Reaching $0$ happens for any $|U|=|V|$. Sqrt of $16$ is $4$.

    (3) Widest sweep with $|U|=|V|$, narrowest with $|U| \gg |V|$ or $|V| \gg |U|$. "Widest" and "narrowest" refer to ratio of max to min of the sweep, rather than max minus min, since that's what determines how much the numerator influences $|X[k]|$. Former follows (2), as min being $0$ maximizes ratios for any sweep. Latter says the sweep is narrower the more $|U|, |V|$ differ, which can also be seen from the root's expression: "very different" means one of them is far below the max of $2$, so $UV$ is smaller.

    (4) $|X[k]|$ is mainly controlled by $k$'s proximity to $f$. Following (2), the numerator can never exceed $4$ (note, $16$ refers to radicand), yet the larger the $N$, the larger all $|X[k]|$ for any given $f, \phi$ - easily exceeding thousands. We also know, vast majority of energy is contained within a narrow interval of the peak, and over such interval the numerator is roughly constant. Hence, the biggest chunk of the spectrum is attributed exclusively to the denominator, which itself is a difference of $f, k$ passed through the same smooth function. The only exception is $f$ near DC or Nyquist, where the root term dominates per approaching $0$.

    (5) $N/4$-symmetry: For $\phi=0$ and some $f = N/4 + \Delta f$, we have

    $$ \begin{align} U &= \cos(N\pi/2 + 2\pi\Delta f) - 1, \\ V &= \cos(N\pi/2 + 2\pi\Delta f - \pi/2 - 2\pi(\Delta f/N)) - \cos(-2\pi(\Delta f/N)), \end{align} $$


    $$ \begin{align} U &= \pm(\cos \lor \sin)(a\Delta f) - 1, \\ V &= \pm(\cos \lor \sin)(b\Delta f) - \cos(c\Delta f), \end{align} $$

    where $\lor$ is "OR", $a,b,c$ are simple subs, and sign- or sine-matching isn't implied between $U$ and $V$ (if $U$ has $-\sin$, doesn't mean $V$ also does). From the first expression, we see that the first sines in $U, V$ alternate between sine and cosine, and their signs, and that $U$'s lags $V$'s by $\pi/2$ for all $N$.

    From this, it's not obvious that $N/4$-symmetry follows for the root, or entirety of $|X[k]|$, but combined with the above plot, one does see it's possible. This symmetry is proven for $|X[k]|$ and $X[k]$ (hence also root and denominator) in a below section, and is code-validated. Note, it's for even $N$, but also approximately for large odd $N$, but about $\lfloor{N/2\rfloor}/2$.

    (6) $f$-uniqueness within $N/4$, and (unproven) $\phi$-uniqueness within $\pi$. That is, a sine's DFT modulus is completely mapped out by $f$ over a continuous interval of size $N/4$, and respectively for $\phi$. I write "unproven" for $\phi$ as I verified it for many configurations in the simulation, but haven't done the math. Since $N/4$-symmetry with respect to $(\Delta f, \phi)$ is proven with a change of variables, a proof appears possible. Obviously, it's at most $2\pi$-unique.

    Side note: It is temping to say $\phi$-uniqueness within $2\pi f/N$ per the DFT shift property, as I first thought, but for non-integer $f$, a linear shift isn't equivalent to a circular shift, since such sines do not complete a full period over $[0, 1]$. It is, in reverse, approximately true within one-sample shift for large $N$, or exactly for time-limited (zero-padded) signals (up to a certain shift), so modulus is more robust to time-shifts with higher sampling rates. This agrees with converging to FT as $N \rightarrow \infty$, where we have $|\mathcal{F}\{x(t)\}| = |\mathcal{F}\{x(t - s)\}|,\ \forall s\in\mathbb{R}$.

    (7) Bounds' $f$-dependence: how rapidly the numerator varies - controlled by max/min ratio of its bounds - determines the envelope's asymmetry. So, we plot:

    $$ \begin{aligned} \sqrt{U^2 + V^2 - 2UV} &= 4|\sin(\pi f)\sin(\pi f/N)\cos(\pi f + \phi - \pi f/N)| \\ \sqrt{U^2 + V^2 + 2UV} &= 4|\sin(\pi f)\cos(\pi f/N)\sin(\pi f + \phi - \pi f/N)| \end{aligned} $$

    in blue and red respectively, as a function of fractional $f$ (i.e. $f/N$):

    where we immediately confirm the $[0, 4]$ bounds.

    Depending how we're counting, each has $N$ peaks. We could show more plots, but the insights aren't worth how complicated they are - in short, the max of blue and red has definitively $N$ peaks and $N$ minima, if domain's restricted to match the DFT's, $[-(N-1)/(2N), 0.5]$ - and greater $N$ doesn't imply greater numerator variability for $f$ between integers, as zooming above plot to same absolute interval shows same variability of red and blue.

    Full sweeps over $U, V$ are visualized in Addendum, without interpreting.

    $f/N$ is what mainly controls sine's $|X|$, not absolute $f$

    We ask, how does DFT's behavior change as we introduce more samples - but keep $f$ unchanged vs scale it with $N$? This answers whether "near" in "near DC/Nyquist" in previous conclusions refers to $|f - 0|$ or $|f/N - 0|$.

    The only absolute $f$-dependence is in the numerator, and it's less than it looks:

    $$ \cos(2\pi f\ +...) = \cos(2\pi (f)_1\ + ...) $$

    where $(f)_1$ takes modulo-1. This means, it only matters how far $f$ is from an integer $f$:

    $$ \cos(2\pi 500.4\ +...) = \cos(2\pi0.4\ + ...) $$

    since $\cos(2\pi 500.4 + x) = \cos(2\pi 500 + 2\pi 0.4 + x) = \cos(2\pi 0.4 + x),\ \forall x$.

    Since "only $f$" is, by definition, only $f$ and not $N$ or $\phi$, this holds for all $N, \phi$. The spectrum, $X$, is also entirely controlled by $(f)_1$, $f/N$, and $(\phi)_{2\pi}$, but since the implication is we care for phase (real vs imag), I don't call $f/N$ "mainly".

    Without $U, V$?

    $$ \boxed{ |X[k]|_{f\notin Z} = \frac{1}{\sqrt{2}}|\sin(\pi f)| \frac{ \sqrt{2 - \cos(2\pi f + 2\phi - 4\pi f/N) - \cos(2\pi f + 2\phi)- \\ 4\sin(\pi f + \phi)\sin(\pi f + \phi - 2\pi f/N)\cos(2\pi k/N)} }{|\cos(2\pi f/N) - \cos(2\pi k/N)|} } $$

    Expanding into separate $k$-dependent terms only makes more of a mess. I don't think it can be simplified into a more useful form, I've tried. Rather, in fact, the "more useful form" that we'd try to get to from this, is exactly what $U, V$ provide, and above would look a lot worse if coming from two complex sinusoids.

    I've not code-validated this formula, but I somewhat carefully put stuff together, with some | help. (Note, the "modified version" (in original post) doesn't help)

    Interactive simulation



    This work can be cited in two parts:

    John Muradeli, 2023. DFT modulus of a sine, closed form solution and insights. URL: https://dsp.stackexchange.com/a/88400/50076

    Cedron Dawg, 2015. DFT Bin Value Formulas for Pure Real Tones. URL: https://www.dsprelated.com/showarticle/771.php

    If must cite only one, cite first.

    Code validation

    Available at Github.


    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.