# Discrete Fourier transform over a ring

In mathematics, the discrete Fourier transform over a ring generalizes the discrete Fourier transform (DFT), of a function whose values are commonly complex numbers, over an arbitrary ring.

## Definition

Let R be any ring, let ${\displaystyle n\geq 1}$ be an integer, and let ${\displaystyle \alpha \in R}$ be a principal nth root of unity, defined by:[1]

 {\displaystyle {\begin{aligned}&\alpha ^{n}=1\\&\sum _{j=0}^{n-1}\alpha ^{jk}=0{\text{ for }}1\leq k (1)

The discrete Fourier transform maps an n-tuple ${\displaystyle (v_{0},\ldots ,v_{n-1})}$ of elements of R to another n-tuple ${\displaystyle (f_{0},\ldots ,f_{n-1})}$ of elements of R according to the following formula:

 ${\displaystyle f_{k}=\sum _{j=0}^{n-1}v_{j}\alpha ^{jk}.}$ (2)

By convention, the tuple ${\displaystyle (v_{0},\ldots ,v_{n-1})}$ is said to be in the time domain and the index j is called time. The tuple ${\displaystyle (f_{0},\ldots ,f_{n-1})}$ is said to be in the frequency domain and the index k is called frequency. The tuple ${\displaystyle (f_{0},\ldots ,f_{n-1})}$ is also called the spectrum of ${\displaystyle (v_{0},\ldots ,v_{n-1})}$. This terminology derives from the applications of Fourier transforms in signal processing.

If R is an integral domain (which includes fields), it is sufficient to choose ${\displaystyle \alpha }$ as a primitive nth root of unity, which replaces the condition (1) by:[1]

${\displaystyle \alpha ^{k}\neq 1}$ for ${\displaystyle 1\leq k
Proof

Take ${\displaystyle \beta =\alpha ^{k}}$ with ${\displaystyle 1\leq k. Since ${\displaystyle \alpha ^{n}=1}$, ${\displaystyle \beta ^{n}=(\alpha ^{n})^{k}=1}$, giving:

${\displaystyle \beta ^{n}-1=(\beta -1)\left(\sum _{j=0}^{n-1}\beta ^{j}\right)=0}$

where the sum matches (1). Since ${\displaystyle \alpha }$ is a primitive root of unity, ${\displaystyle \beta -1\neq 0}$. Since R is an integral domain, the sum must be zero. ∎

Another simple condition applies in the case where n is a power of two: (1) may be replaced by ${\displaystyle \alpha ^{n/2}=-1}$.[1]

## Inverse

The inverse of the discrete Fourier transform is given as:

 ${\displaystyle v_{j}={\frac {1}{n}}\sum _{k=0}^{n-1}f_{k}\alpha ^{-jk}.}$ (3)

where ${\displaystyle 1/n}$ is the multiplicative inverse of n in R (if this inverse does not exist, the DFT cannot be inverted).

Proof

Substituting (2) into the right-hand-side of (3), we get

{\displaystyle {\begin{aligned}&{\frac {1}{n}}\sum _{k=0}^{n-1}f_{k}\alpha ^{-jk}\\={}&{\frac {1}{n}}\sum _{k=0}^{n-1}\sum _{j'=0}^{n-1}v_{j'}\alpha ^{j'k}\alpha ^{-jk}\\={}&{\frac {1}{n}}\sum _{j'=0}^{n-1}v_{j'}\sum _{k=0}^{n-1}\alpha ^{(j'-j)k}.\end{aligned}}}

This is exactly equal to ${\displaystyle v_{j}}$, because ${\displaystyle \sum _{k=0}^{n-1}\alpha ^{(j'-j)k}=0}$ when ${\displaystyle j'\neq j}$ (by (1) with ${\displaystyle k=j'-j}$), and ${\displaystyle \sum _{k=0}^{n-1}\alpha ^{(j'-j)k}=n}$ when ${\displaystyle j'=j}$. ∎

## Matrix formulation

Since the discrete Fourier transform is a linear operator, it can be described by matrix multiplication. In matrix notation, the discrete Fourier transform is expressed as follows:

${\displaystyle {\begin{bmatrix}f_{0}\\f_{1}\\\vdots \\f_{n-1}\end{bmatrix}}={\begin{bmatrix}1&1&1&\cdots &1\\1&\alpha &\alpha ^{2}&\cdots &\alpha ^{n-1}\\1&\alpha ^{2}&\alpha ^{4}&\cdots &\alpha ^{2(n-1)}\\\vdots &\vdots &\vdots &\ddots &\vdots \\1&\alpha ^{n-1}&\alpha ^{2(n-1)}&\cdots &\alpha ^{(n-1)(n-1)}\\\end{bmatrix}}{\begin{bmatrix}v_{0}\\v_{1}\\\vdots \\v_{n-1}\end{bmatrix}}.}$

The matrix for this transformation is called the DFT matrix.

Similarly, the matrix notation for the inverse Fourier transform is

${\displaystyle {\begin{bmatrix}v_{0}\\v_{1}\\\vdots \\v_{n-1}\end{bmatrix}}={\frac {1}{n}}{\begin{bmatrix}1&1&1&\cdots &1\\1&\alpha ^{-1}&\alpha ^{-2}&\cdots &\alpha ^{-(n-1)}\\1&\alpha ^{-2}&\alpha ^{-4}&\cdots &\alpha ^{-2(n-1)}\\\vdots &\vdots &\vdots &\ddots &\vdots \\1&\alpha ^{-(n-1)}&\alpha ^{-2(n-1)}&\cdots &\alpha ^{-(n-1)(n-1)}\end{bmatrix}}{\begin{bmatrix}f_{0}\\f_{1}\\\vdots \\f_{n-1}\end{bmatrix}}.}$

## Polynomial formulation

Sometimes it is convenient to identify an n-tuple ${\displaystyle (v_{0},\ldots ,v_{n-1})}$ with a formal polynomial

${\displaystyle p_{v}(x)=v_{0}+v_{1}x+v_{2}x^{2}+\cdots +v_{n-1}x^{n-1}.\,}$

By writing out the summation in the definition of the discrete Fourier transform (2), we obtain:

${\displaystyle f_{k}=v_{0}+v_{1}\alpha ^{k}+v_{2}\alpha ^{2k}+\cdots +v_{n-1}\alpha ^{(n-1)k}.\,}$

This means that ${\displaystyle f_{k}}$ is just the value of the polynomial ${\displaystyle p_{v}(x)}$ for ${\displaystyle x=\alpha ^{k}}$, i.e.,

 ${\displaystyle f_{k}=p_{v}(\alpha ^{k}).\,}$ (4)

The Fourier transform can therefore be seen to relate the coefficients and the values of a polynomial: the coefficients are in the time-domain, and the values are in the frequency domain. Here, of course, it is important that the polynomial is evaluated at the nth roots of unity, which are exactly the powers of ${\displaystyle \alpha }$.

Similarly, the definition of the inverse Fourier transform (3) can be written:

 ${\displaystyle v_{j}={\frac {1}{n}}(f_{0}+f_{1}\alpha ^{-j}+f_{2}\alpha ^{-2j}+\cdots +f_{n-1}\alpha ^{-(n-1)j}).}$ (5)

With

${\displaystyle p_{f}(x)=f_{0}+f_{1}x+f_{2}x^{2}+\cdots +f_{n-1}x^{n-1},}$

this means that

${\displaystyle v_{j}={\frac {1}{n}}p_{f}(\alpha ^{-j}).}$

We can summarize this as follows: if the values of ${\displaystyle p_{v}(x)}$ are the coefficients of ${\displaystyle p_{f}(x)}$, then the values of ${\displaystyle p_{f}(x)}$ are the coefficients of ${\displaystyle p_{v}(x)}$, up to a scalar factor and reordering.[2]

## Special cases

### Complex numbers

If ${\displaystyle F={\mathbb {C} }}$ is the field of complex numbers, then the ${\displaystyle n}$th roots of unity can be visualized as points on the unit circle of the complex plane. In this case, one usually takes

${\displaystyle \alpha =e^{\frac {-2\pi i}{n}},}$

which yields the usual formula for the complex discrete Fourier transform:

${\displaystyle f_{k}=\sum _{j=0}^{n-1}v_{j}e^{{\frac {-2\pi i}{n}}jk}.}$

Over the complex numbers, it is often customary to normalize the formulas for the DFT and inverse DFT by using the scalar factor ${\displaystyle {\frac {1}{\sqrt {n}}}}$ in both formulas, rather than ${\displaystyle 1}$ in the formula for the DFT and ${\displaystyle {\frac {1}{n}}}$ in the formula for the inverse DFT. With this normalization, the DFT matrix is then unitary. Note that ${\displaystyle {\sqrt {n}}}$ does not make sense in an arbitrary field.

### Finite fields

If ${\displaystyle F=\mathrm {GF} (q)}$ is a finite field, where q is a prime power, then the existence of a primitive nth root automatically implies that n divides ${\displaystyle q-1}$, because the multiplicative order of each element must divide the size of the multiplicative group of F, which is ${\displaystyle q-1}$. This in particular ensures that ${\displaystyle n=\underbrace {1+1+\cdots +1} _{n\ {\rm {times}}}}$ is invertible, so that the notation ${\displaystyle {\frac {1}{n}}}$ in (3) makes sense.

An application of the discrete Fourier transform over ${\displaystyle \mathrm {GF} (q)}$ is the reduction of Reed–Solomon codes to BCH codes in coding theory. Such transform can be carried out efficiently with proper fast algorithms, for example, cyclotomic fast Fourier transform.

#### Polynomial formulation without nth root

Suppose ${\displaystyle F=\mathrm {GF} (p)}$. If ${\displaystyle p\nmid n}$, it may be the case that ${\displaystyle n\nmid p-1}$. This means we cannot find an ${\displaystyle n^{th}}$ root of unity in ${\displaystyle F}$. We may view the Fourier transform as an isomorphism ${\displaystyle \mathrm {F} [C_{n}]=\mathrm {F} [x]/(x^{n}-1)\cong \bigoplus _{i}\mathrm {F} [x]/(P_{i}(x))}$ for some polynomials ${\displaystyle P_{i}(x)}$, in accordance with Maschke's theorem. The map is given by the Chinese remainder theorem, and the inverse is given by applying Bézout's identity for polynomials.[3]

${\displaystyle x^{n}-1=\prod _{d|n}\Phi _{d}(x)}$, a product of cyclotomic polynomials. Factoring ${\displaystyle \Phi _{d}(x)}$ in ${\displaystyle F[x]}$ is equivalent to factoring the prime ideal ${\displaystyle (p)}$ in ${\displaystyle \mathrm {Z} [\zeta ]=\mathrm {Z} [x]/(\Phi _{d}(x))}$. We obtain ${\displaystyle g}$ polynomials ${\displaystyle P_{1}\ldots P_{g}}$ of degree ${\displaystyle f}$ where ${\displaystyle fg=\varphi (d)}$ and ${\displaystyle f}$ is the order of ${\displaystyle p{\text{ mod }}d}$.

As above, we may extend the base field to ${\displaystyle \mathrm {GF} (q)}$ in order to find a primitive root, i.e. a splitting field for ${\displaystyle x^{n}-1}$. Now ${\displaystyle x^{n}-1=\prod _{k}(x-\alpha ^{k})}$, so an element ${\displaystyle \sum _{j=0}^{n-1}v_{j}x^{j}\in F[x]/(x^{n}-1)}$ maps to ${\displaystyle \sum _{j=0}^{n-1}v_{j}x^{j}\mod (x-\alpha ^{k})\equiv \sum _{j=0}^{n-1}v_{j}(\alpha ^{k})^{j}}$ for each ${\displaystyle k}$.

#### When p divides n

When ${\displaystyle p|n}$, we may still define an ${\displaystyle F_{p}}$-linear isomorphism as above. Note that ${\displaystyle (x^{n}-1)=(x^{m}-1)^{p^{s}}}$ where ${\displaystyle n=mp^{s}}$ and ${\displaystyle p\nmid m}$. We apply the above factorization to ${\displaystyle x^{m}-1}$, and now obtain the decomposition ${\displaystyle F[x]/(x^{n}-1)\cong \bigoplus _{i}F[x]/(P_{i}(x)^{p^{s}})}$. The modules occurring are now indecomposable rather than irreducible.

#### Order of the DFT matrix

Suppose ${\displaystyle p\nmid n}$ so we have an ${\displaystyle n^{th}}$ root of unity ${\displaystyle \alpha }$. Let ${\displaystyle A}$ be the above DFT matrix, a Vandermonde matrix with entries ${\displaystyle A_{ij}=\alpha ^{ij}}$ for ${\displaystyle 0\leq i,j. Recall that ${\displaystyle \sum _{j=0}^{n-1}\alpha ^{(k-l)j}=n\delta _{k,l}}$ since if ${\displaystyle k=l}$, then every entry is 1. If ${\displaystyle k\neq l}$, then we have a geometric series with common ratio ${\displaystyle \alpha ^{k-l}}$, so we obtain ${\displaystyle {\frac {1-\alpha ^{n(k-l)}}{1-\alpha ^{k-l}}}}$. Since ${\displaystyle \alpha ^{n}=1}$ the numerator is zero, but ${\displaystyle k-l\neq 0}$ so the denominator is nonzero.

First computing the square, ${\displaystyle (A^{2})_{ik}=\sum _{j=0}^{n-1}\alpha ^{j(i+k)}=n\delta _{i,-k}}$. Computing ${\displaystyle A^{4}=(A^{2})^{2}}$ similarly and simplifying the deltas, we obtain ${\displaystyle (A^{4})_{ik}=n^{2}\delta _{i,k}}$. Thus, ${\displaystyle A^{4}=n^{2}I_{n}}$ and the order is ${\displaystyle 4\cdot {\text{ord}}(n^{2})}$.

#### Normalizing the DFT matrix

In order to align with the complex case and ensure the matrix is order 4 exactly, we can normalize the above DFT matrix ${\displaystyle A}$ with ${\displaystyle {\frac {1}{\sqrt {n}}}}$. Note that though ${\displaystyle {\sqrt {n}}}$ may not exist in the splitting field ${\displaystyle F_{q}}$ of ${\displaystyle x^{n}-1}$, we may form a quadratic extension ${\displaystyle F_{q^{2}}\cong F_{q}[x]/(x^{2}-n)}$ in which the square root exists. We may then set ${\displaystyle U={\frac {1}{\sqrt {n}}}A}$, and ${\displaystyle U^{4}=I_{n}}$.

#### Unitarity

Suppose ${\displaystyle p\nmid n}$. One can ask whether the DFT matrix is unitary over a finite field. If the matrix entries are over ${\displaystyle F_{q}}$, then one must ensure ${\displaystyle q}$ is a perfect square or extend to ${\displaystyle F_{q^{2}}}$ in order to define the order two automorphism ${\displaystyle x\mapsto x^{q}}$. Consider the above DFT matrix ${\displaystyle A_{ij}=\alpha ^{ij}}$. Note that ${\displaystyle A}$ is symmetric. Conjugating and transposing, we obtain ${\displaystyle A_{ij}^{*}=\alpha ^{qji}}$.

${\displaystyle (AA^{*})_{ik}=\sum _{j=0}^{n-1}\alpha ^{j(i+qk)}=n\delta _{i,-qk}}$

by a similar geometric series argument as above. We may remove the ${\displaystyle n}$ by normalizing so that ${\displaystyle U={\frac {1}{\sqrt {n}}}A}$ and ${\displaystyle (UU^{*})_{ik}=\delta _{i,-qk}}$. Thus ${\displaystyle U}$ is unitary iff ${\displaystyle q\equiv -1\,({\text{mod}}\,n)}$. Recall that since we have an ${\displaystyle n^{th}}$ root of unity, ${\displaystyle n|q^{2}-1}$. This means that ${\displaystyle q^{2}-1\equiv (q+1)(q-1)\equiv 0\,({\text{mod}}\,n)}$. Note if ${\displaystyle q}$ was not a perfect square to begin with, then ${\displaystyle n|q-1}$ and so ${\displaystyle q\equiv 1\,({\text{mod}}\,n)}$.

For example, when ${\displaystyle p=3,n=5}$ we need to extend to ${\displaystyle q^{2}=3^{4}}$ to get a 5th root of unity. ${\displaystyle q=9\equiv -1\,({\text{mod}}\,5)}$.

For a nonexample, when ${\displaystyle p=3,n=8}$ we extend to ${\displaystyle F_{3^{2}}}$ to get an 8th root of unity. ${\displaystyle q^{2}=9}$, so ${\displaystyle q\equiv 3\,({\text{mod}}\,8)}$, and in this case ${\displaystyle q+1\not \equiv 0}$ and ${\displaystyle q-1\not \equiv 0}$. ${\displaystyle UU^{*}}$ is a square root of the identity, so ${\displaystyle U}$ is not unitary.

#### Eigenvalues of the DFT matrix

When ${\displaystyle p\nmid n}$, we have an ${\displaystyle n^{th}}$ root of unity ${\displaystyle \alpha }$ in the splitting field ${\displaystyle F_{q}\cong F_{p}[x]/(x^{n}-1)}$. Note that the characteristic polynomial of the above DFT matrix may not split over ${\displaystyle F_{q}}$. The DFT matrix is order 4. We may need to go to a further extension ${\displaystyle F_{q'}}$, the splitting extension of the characteristic polynomial of the DFT matrix, which at least contains fourth roots of unity. If ${\displaystyle a}$ is a generator of the multiplicative group of ${\displaystyle F_{q'}}$, then the eigenvalues are ${\displaystyle \{\pm 1,\pm a^{(q'-1)/4}\}}$, in exact analogy with the complex case. They occur with some nonnegative multiplicity.

### Number-theoretic transform

The number-theoretic transform (NTT)[4] is obtained by specializing the discrete Fourier transform to ${\displaystyle F={\mathbb {Z} }/p}$, the integers modulo a prime p. This is a finite field, and primitive nth roots of unity exist whenever n divides ${\displaystyle p-1}$, so we have ${\displaystyle p=\xi n+1}$ for a positive integer ξ. Specifically, let ${\displaystyle \omega }$ be a primitive ${\displaystyle (p-1)}$th root of unity, then an nth root of unity ${\displaystyle \alpha }$ can be found by letting ${\displaystyle \alpha =\omega ^{\xi }}$.

e.g. for ${\displaystyle p=5}$, ${\displaystyle \alpha =2}$

{\displaystyle {\begin{aligned}2^{1}&=2{\pmod {5}}\\2^{2}&=4{\pmod {5}}\\2^{3}&=3{\pmod {5}}\\2^{4}&=1{\pmod {5}}\end{aligned}}}

when ${\displaystyle N=4}$

${\displaystyle {\begin{bmatrix}F(0)\\F(1)\\F(2)\\F(3)\end{bmatrix}}={\begin{bmatrix}1&1&1&1\\1&2&4&3\\1&4&1&4\\1&3&4&2\end{bmatrix}}{\begin{bmatrix}f(0)\\f(1)\\f(2)\\f(3)\end{bmatrix}}}$

The number theoretic transform may be meaningful in the ring ${\displaystyle \mathbb {Z} /m}$, even when the modulus m is not prime, provided a principal root of order n exists. Special cases of the number theoretic transform such as the Fermat Number Transform (m = 2k+1), used by the Schönhage–Strassen algorithm, or Mersenne Number Transform[5] (m = 2k − 1) use a composite modulus.

### Discrete weighted transform

The discrete weighted transform (DWT) is a variation on the discrete Fourier transform over arbitrary rings involving weighting the input before transforming it by multiplying elementwise by a weight vector, then weighting the result by another vector.[6] The Irrational base discrete weighted transform is a special case of this.

## Properties

Most of the important attributes of the complex DFT, including the inverse transform, the convolution theorem, and most fast Fourier transform (FFT) algorithms, depend only on the property that the kernel of the transform is a principal root of unity. These properties also hold, with identical proofs, over arbitrary rings. In the case of fields, this analogy can be formalized by the field with one element, considering any field with a primitive nth root of unity as an algebra over the extension field ${\displaystyle \mathbf {F} _{1^{n}}.}$[clarification needed]

In particular, the applicability of ${\displaystyle O(n\log n)}$ fast Fourier transform algorithms to compute the NTT, combined with the convolution theorem, mean that the number-theoretic transform gives an efficient way to compute exact convolutions of integer sequences. While the complex DFT can perform the same task, it is susceptible to round-off error in finite-precision floating point arithmetic; the NTT has no round-off because it deals purely with fixed-size integers that can be exactly represented.

## Fast algorithms

For the implementation of a "fast" algorithm (similar to how FFT computes the DFT), it is often desirable that the transform length is also highly composite, e.g., a power of two. However, there are specialized fast Fourier transform algorithms for finite fields, such as Wang and Zhu's algorithm,[7] that are efficient regardless of whether the transform length factors.