<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu" -->

---
title: Notes on the discrete Fourier transform (DFT) | daily.dev
description: The Discrete Fourier Transform (DFT) turns a finite sequence of samples into frequency coefficients by treating the samples as one period of a periodic signal....
canonical: https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Notes on the discrete Fourier transform (DFT) | daily.dev
og:description: The Discrete Fourier Transform (DFT) turns a finite sequence of samples into frequency coefficients by treating the samples as one period of a periodic signal....
og:url: https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu
og:image: https://api.daily.dev/og/posts/fFCGXUwIu.png
og:image:alt: Notes on the discrete Fourier transform (DFT)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Notes on the discrete Fourier transform (DFT)

**[Eli Bendersky](https://daily.dev/sources/elibendersky)** · 9 min read · 1 upvotes · 0 comments

## Summary

The Discrete Fourier Transform (DFT) turns a finite sequence of samples into frequency coefficients by treating the samples as one period of a periodic signal. It equals the DTFS coefficients, and also corresponds to equally spaced samples of the DTFT. The post gives Python code computing the DFT directly and via the Fourier matrix, where rows are powers of the N-th roots of unity forming an orthogonal basis. It derives the inverse DFT formula two ways and shows a worked example reconstructing a 12-sample triangle wave exactly. It also covers the Fast Fourier Transform, which computes the same result in fewer operations than direct matrix multiplication, and explains spectral leakage when sampled data doesn't cover a full cycle.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://eli.thegreenplace.net/2026/notes-on-the-discrete-fourier-transform-dft>

## Questions this post answers

### How do I compute the DFT of a signal in Python without using numpy.fft?

You can compute it directly with a loop over frequency bins k, multiplying the signal by exp(-2j*pi*k*n/N) weights and summing, as in a function 'dft(x)' that returns X[k] = sum_n x[n] exp(-2 pi i k n / N). Alternatively, build the Fourier matrix F with F[k,n] = W_N**(k*n) where W_N = exp(-2j*pi/N), then compute F @ x.

_daily.dev surfaces DSP implementation notes like this for developers writing their own signal processing code._

### Why is the FFT faster than computing the DFT with the Fourier matrix?

The Fast Fourier Transform exploits the structure of the Fourier matrix to compute the matrix-vector product F @ x in fewer operations than direct matrix-vector multiplication requires, which takes on the order of N squared operations. FFT is considered one of the most important algorithms of the 20th century because of this efficiency gain for large signals.

_Engineers comparing DFT implementation approaches can track deeper signal-processing writeups on daily.dev._

### What causes spectral leakage in a DFT and how do you reduce it?

Spectral leakage happens when sampled data covers only part of a signal's cycle, so naively treating it as periodic creates a jump at the loop boundary; the signal's true frequencies then no longer align with the DFT's frequency bins and spread across multiple bins. Applying window functions that taper the signal toward zero near the edges helps alleviate this effect, though reconstruction via the inverse DFT remains exact regardless.

_Developers tuning frequency analysis pipelines can find similar signal-processing deep dives via daily.dev._

## Community take

How the wider developer community reacted, aggregated from 1 discussion and 14 comments across hackernews (as of 2026-11-22).

**TL;DR:** The discussion is largely appreciative, with developers adding mathematical depth (proofs of invertibility, relationships between the four Fourier transform variants) and pointing to related tools and resources for cases where the DFT doesn't directly apply.

**Sentiment:** 70% positive · 25% mixed · 5% skeptical

**The case for**

- Several commenters praised the post for clearly distinguishing the DFT from the FFT algorithm.
- Some found the author's other writing memorable and were glad to rediscover the blog.

**The pushback**

- One commenter questioned whether the author's work might be AI-generated, though this was clarified and pushed back on.

**By community**

- hackernews (positive): People extended the post's math with their own proofs and context, pointed to related tools like Lomb-Scargle periodograms, and generally praised the writing.

**Open questions**

- Whether newer techniques like compressed sensing produce better results than periodograms for irregularly sampled data.

**Highlights**

> There are four Fourier Transforms: 1. The (traditional) Fourier Transform for real-domain functions. 2. The Discrete Time Fourier Transform (DTFT) for integer-domain function. 3. The Continuous Time Fourier Transform (CTFT) for unit circle-domain (or periodic) functions, also known as Fourier Series decomposition. 4. The Discrete   Fourier Transform (DFT) for finite integer domain functions. You might say there are only three of these transforms because 2 and 3 are essentially, but not quite, inverses of each other. But really there is only one Fourier transform. In a few senses actually. There's character theory which unites them all based on the (topology and group structure of the) function domain. So reals, integers, unit circle, and finite integers are the function example domains. But another way they are all united is with distributions and dirac delta functions. The dirac comb is very important for understanding it. Any time you have a discrete series, represent it as dirac impulses and apply the normal Fourier Transform (operating on distributions) maps it to the other transforms. You can represent the DFT as a periodic sequence of impulses and just apply the normal transform. You can also interpret the DFT as the DTFT operating on a finitely supported discrete sequence. The math is the same but you just compute it at a finite grid in frequency space. This is why zero padding increases your frequency resolution or interpolates in the frequency domain.
> — [abnry on hackernews · 1 comments](https://news.ycombinator.com/item?id=50602605)

> DFT works great if you have a single with equal spacing in the time domain (e.g. you have a microphone, and you measure the signal every 1/20k s or so). If that's not the case, rather than interpolating into a time grid, it's often better to use a generalization of the DFT called the "Lomb-Scargle Periodogram". For example if you have a periodic process like measuring the distance between two planets, but you only get measurements at random timestamps, that's the way to go. See for example https://docs.astropy.org/en/stable/timeseries/lombscargle.ht...
> — [perlgeek on hackernews · 1 comments](https://news.ycombinator.com/item?id=50602022)

> During college, this guy had some banger articles. Had completely forgotten about the blog. Now I check it and the burning question.. is it full of AI slop/psychosis (i.e. similar to the https://nullprogram.com guy..) Seems to have escaped the scourge. Likely made enough $ at GOOG to retire.
> — [brcmthrowaway on hackernews · 2 comments](https://news.ycombinator.com/item?id=50597478)

> The simplest way to show this is that the adjoint (complex transpose) DFT matrix is the inverse, so U^H U = I. (For DFT there are different scaling conventions which may be taken into account.)
> — [uecker on hackernews · 1 comments](https://news.ycombinator.com/item?id=50597453)

**Source threads**

- [hackernews](https://news.ycombinator.com/item?id=50596960) · 90 points · 14 comments

## Similar posts on daily.dev

- [Notes on discrete-time Fourier series and transform](https://daily.dev/posts/notes-on-discrete-time-fourier-series-and-transform-zeurckvji) · Eli Bendersky · 0 upvotes · 0 comments
- [How the Fourier Transform Converts Sound Into Frequencies](https://daily.dev/posts/how-the-fourier-transform-converts-sound-into-frequencies-9uyp5rdfw) · Towards Data Science · 0 upvotes · 0 comments
- [Understanding the FFT Algorithm](https://daily.dev/posts/understanding-the-fft-algorithm-o2mnh31j6) · Hacker News · 0 upvotes · 0 comments
- [Notes on the Fourier Transform](https://daily.dev/posts/notes-on-the-fourier-transform-go3dssqrp) · Eli Bendersky · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#data-science](https://daily.dev/tags/data-science), [#math](https://daily.dev/tags/math), [#numpy](https://daily.dev/tags/numpy)

[View this post on daily.dev](https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Notes on the discrete Fourier transform (DFT)","url":"https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu"},"datePublished":"2026-11-21T22:42:36.384Z","dateModified":"2026-11-22T17:30:48.546Z","description":"The Discrete Fourier Transform (DFT) turns a finite sequence of samples into frequency coefficients by treating the samples as one period of a periodic signal....","image":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","thumbnailUrl":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","isAccessibleForFree":true,"articleSection":"Eli Bendersky","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Eli Bendersky","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ac2e84092d814b68aa34080a3232a3cd","url":"https://daily.dev/sources/elibendersky"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,data-science,math,numpy","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Eli Bendersky","item":"https://daily.dev/sources/elibendersky"},{"@type":"ListItem","position":3,"name":"Notes on the discrete Fourier transform (DFT)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/notes-on-the-discrete-fourier-transform-dft--ffcgxuwiu#faq","mainEntity":[{"@type":"Question","name":"How do I compute the DFT of a signal in Python without using numpy.fft?","acceptedAnswer":{"@type":"Answer","text":"You can compute it directly with a loop over frequency bins k, multiplying the signal by exp(-2j*pi*k*n/N) weights and summing, as in a function 'dft(x)' that returns X[k] = sum_n x[n] exp(-2 pi i k n / N). Alternatively, build the Fourier matrix F with F[k,n] = W_N**(k*n) where W_N = exp(-2j*pi/N), then compute F @ x. daily.dev surfaces DSP implementation notes like this for developers writing their own signal processing code."}},{"@type":"Question","name":"Why is the FFT faster than computing the DFT with the Fourier matrix?","acceptedAnswer":{"@type":"Answer","text":"The Fast Fourier Transform exploits the structure of the Fourier matrix to compute the matrix-vector product F @ x in fewer operations than direct matrix-vector multiplication requires, which takes on the order of N squared operations. FFT is considered one of the most important algorithms of the 20th century because of this efficiency gain for large signals. Engineers comparing DFT implementation approaches can track deeper signal-processing writeups on daily.dev."}},{"@type":"Question","name":"What causes spectral leakage in a DFT and how do you reduce it?","acceptedAnswer":{"@type":"Answer","text":"Spectral leakage happens when sampled data covers only part of a signal's cycle, so naively treating it as periodic creates a jump at the loop boundary; the signal's true frequencies then no longer align with the DFT's frequency bins and spread across multiple bins. Applying window functions that taper the signal toward zero near the edges helps alleviate this effect, though reconstruction via the inverse DFT remains exact regardless. Developers tuning frequency analysis pipelines can find similar signal-processing deep dives via daily.dev."}}]}
```

