1 Introduction

The fast implementation of large Fourier transforms is very important for many technological applications. Roughly speaking in this paper we express the Fourier transform in a Hilbert space of large dimension, as a combination of many Fourier transforms in Hilbert spaces of small dimension. This is a fast Fourier transform, because performing many ‘small’ Fourier transforms instead of one ‘large’ Fourier transform, is computationally beneficial. The ‘small’ Fourier transforms can be performed in a classical computer or as quantum Fourier transforms in a quantum computer. In the latter case, we will also have an additional well known reduction of the computational time by quantum Fourier transform circuits (e.g., [1, 2]). Our methodology (and the associated reduction of computational time) is applicable to the calculation of other quantities also, like the Wigner and Weyl functions.

Two important approaches are the Cooley-Tukey formalism [3, 4], and the Good formalism [5,6,7] which is based on the Chinese remainder theorem. There are also many variations of these schemes (reviewed in [8,9,10]). In this paper we study the implementation of fast Fourier transforms in quantum systems with large dimension of the Hilbert space. We also study the fast calculation of the Wigner and Weyl functions. This is an important application of the physics of quantum systems with finite -dimensional Hilbert space(e.g. [11]).

We consider a finite quantum system \(\Sigma (D)\) with variables in \({{\mathbb {Z}}}(D)\) (the ring of integers modulo d) where D is an odd integer. This system is described by the D-dimensional Hilbert space H(D). There are well known technical differences between quantum systems with odd dimension D and even dimension D (e.g., [12,13,14]). In this paper we consider systems with odd dimension D. We discuss the fast implementation of the Fourier transform F in \(\Sigma (D)\), using two methods described briefly below.

1.1 First method for the case \(D=d^n\) with d an odd integer

The fast implementation of the Fourier transform F in \(\Sigma (D)\), is using a sequence of n Fourier transforms (together with some other transforms) in a multipartite system \(\Sigma _n(d)\) comprised of n components each of which is described with variables in \({{\mathbb {Z}}}(d)\). Positions and momenta in \(\Sigma _n(d)\) take values in \([{{\mathbb {Z}}}(d)]^n={{\mathbb {Z}}}(d)\times ...{{\mathbb {Z}}}(d)\) and the corresponding Hilbert space is \({\mathfrak H}_A=H(d)\otimes ...\otimes H(d)\). The Hilbert spaces H(D) and \({\mathfrak H}_A\) are isomorphic (they have the same dimension), and in this sense \(\Sigma (D)\) and \(\Sigma _n(d)\) are two different descriptions of the same system. However, Fourier transforms and other phase space methods are different in these two cases [15].

Mathematically, this approach is inspired by the Cooley-Tukey formalism [3] for fast Fourier transforms (see also [8,9,10]), and is used here in a quantum context. But we note that the most popular Cooley-Tukey algorithm is for \(D=2^n\), whilst in our approach D is a power of an odd number.

A quantum circuit for the implementation of this fast Fourier transform is given in Fig. 1. In some special cases, the various operations can be performed in parallel (parallel computing).

Fig. 1
figure 1

Circuit for the fast calculation of the Fourier transform F, using Eqs. (31)–(34). Here \(D=d^n\)

Fig. 2
figure 2

\(\frac{T(D)}{D^2}\) for the ‘normal’ Fourier transform of a random vector (Eq. (38)), as a function of \(D=d^2\) where \(d=51,53,...,101\) is an odd integer. The result is a horizontal line, and this confirms that the computational time for the normal Fourier transform is \({{\mathcal {O}}}(D^2)\). The Fourier transform of different random vectors give similar results

Fig. 3
figure 3

\(\frac{T_f(D)}{D\log D}\) for the fast Fourier transform of a random vector(Eqs. (39) and (40)), as a function of \(D=d^2\) where \(d=51,53,...,101\) is an odd integer. The result is a slightly ascending line, and this confirms that a lower bound for the computational time for the fast Fourier transform is approximately \({{\mathcal {O}}}(D\log D)\). The Fourier transform of different random vectors give similar results

Fig. 4
figure 4

The CPU times T(D) and \(T_f(D)\) for the normal Fourier transform (Eq. (38)) and the fast Fourier transform (Eqs. (39), (40)) correspondingly, of a random vector, as a function of \(D=d^2\) where \(d=51,53,...,101\) is an odd integer. It is seen that \(T_f(D)\) is much smaller than T(D). Different random vectors give similar results

Fig. 5
figure 5

Circuit for the fast implementation of the Fourier transformf using Eqs. (58)–(60). Here \(D=d_0...d_{n-1}\) with coprime \(d_0,...,d_{n-1}\). The constants \({\mathfrak b}_\nu \) are defined in Eq. (9)

Fig. 6
figure 6

\(\frac{T(D)}{D^2}\) for the ‘normal’ Fourier transform of a random vector (Eq. (38)), as a function of \(D=d_1d_2\) where \(d_1=53\) and \(d_2=55,57,...,101\) (the \(d_1,d_2\) are coprime). The result is a horizontal line, and this confirms that the computational time for the normal Fourier transform is \({{\mathcal {O}}}(D^2)\). The Fourier transform of different random vectors give similar results

Fig. 7
figure 7

\(\frac{T_f(D)}{D\log D}\) for the fast Fourier transform of a random vector(Eqs. (39) and (40)), as a function of \(D=d_1d_2\) where \(d_1=53\) and and \(d_2=55,57,...,101\) (the \(d_1,d_2\) are coprime). The result is approximately a horizontal line, and this confirms that the computational time for the fast Fourier transform is approximately \({{\mathcal {O}}}(D\log D)\). The Fourier transform of different random vectors give similar results

Fig. 8
figure 8

The CPU times T(D) and \(T_f(D)\) for the normal Fourier transform (Eq. (38)) and the fast Fourier transform (Eqs. (39) and (40)) correspondingly, of a random vector, as a function of \(D=d_1d_2\) where \(d_1=53\) and and \(d_2=55,57,...,101\) (the \(d_1,d_2\) are coprime). It is seen that \(T_f(D)\) is much smaller than T(D). Different random vectors give similar results

Fig. 9
figure 9

Circuit for the fast calculation of the Weyl function, using Eqs. (67)–(69). Here \(D=d_0...d_{n-1}\) with coprime \(d_0,...,d_{n-1}\). The constants \({\mathfrak b}_\nu \) are defined in Eq. (9)

We discuss the complexity of this method and show that the computational time is reduced from \(\mathcal{O}(D^2)\) to \(\mathcal{O}(D\log D)\). We also present numerical work that supports this.

A limitation of the method is the fact that the ring \({{\mathbb {Z}}}(D)\) (with \(D=d^n\)) is not isomorphic to the ring \([{{\mathbb {Z}}}(d)]^n\). Although there is a bijective map between them, sum and products do not correspond to sums and products (Sect. 2.A). The implications of this are discussed in Sect. 4.C. For example, this method cannot be used in Eq. (63) below, for the fast calculation of the Wigner and Weyl functions.

1.2 Second method for the case \(D=d_0...d_{n-1}\) with \(d_0,...,d_{n-1}\) odd integers coprime to each other

The fast implementation of the Fourier transform F, is using a multipartite system \(\Sigma (d_0,...,d_{n-1})\) comprised of n components, which are described with variables in \({{\mathbb {Z}}}(d_0),...,{{\mathbb {Z}}}(d_{n-1})\). Positions and momenta in \(\Sigma (d_0,...,d_{n-1})\) take values in \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) and the corresponding Hilbert space is \({\mathfrak H}_B=H(d_0)\otimes ...\otimes H(d_{n-1})\). The Hilbert spaces H(D) and \({\mathfrak H}_B\) are isomorphic (they have the same dimension), and in this sense \(\Sigma (D)\) and \(\Sigma (d_0,...,d_{n-1})\) are two different descriptions of the same system.

Mathematically, this approach is inspired by the Good formalism [5,6,7] for fast Fourier transforms (see also [8,9,10]), which in turn is based on the Chinese remainder theorem, and is used here in a quantum context. A quantum circuit for the implementation of this fast Fourier transform is given in Fig. 5.

The complexity of the method is discussed, and it is shown that the computational time is reduced from \(\mathcal{O}(D^2)\) to \(\mathcal{O}(D\log D)\). This is supported with numerical work.

A strength of the method is the fact that the ring \({{\mathbb {Z}}}(D)\) is isomorphic to the ring \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) (Sect. 2.B). Because of this the method is used for the fact calculation of Wigner and Weyl functions in Sect. 6.

1.3 Contents

The work is complementary to the work on quantum Fourier transforms. It reduces a large Fourier transform to many small Fourier transforms, and this reduces the computational time. The small Fourier transforms can be preformed with a classical computer, or (if available) with a quantum computer so that we have the additional (and well known) advantages of quantum Fourier transforms [1, 2].

In Sect. 2 we discuss the number theory related to the two methods. In Sect. 3 we consider a quantum system \(\Sigma (D)\) with variables in \({{\mathbb {Z}}}(D)\) where D is an odd integer, described by the D-dimensional Hilbert space H(D). In Sect. 4 we present the first method for the case where \(D=d^n\). In Sect. 5 we present the second method for the case where \(D=d_0...d_{n-1}\) with \(d_0,...,d_{n-1}\) odd integers coprime to each other. In Sect. 6 we use the second method for the fast calculation of the Wigner and Weyl functions. We conclude in Sect. 7 with a discussion of our results.

2 Number theory for the two fast Fourier transforms

2.1 A bijective map between the non-isomorphic rings \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\) when \(D=d^n\)

\({{\mathbb {Z}}}(D)\) is the ring of integers modulo D, where D is an odd integer. We take \(D=d^n\) (where d is an odd integer) and consider a bijective map between \([{{\mathbb {Z}}}(d)]^n={{\mathbb {Z}}}(d)\times ...\times {{\mathbb {Z}}}(d)\) and \({{\mathbb {Z}}}(D)\). We use upper case letters for elements in \({{\mathbb {Z}}}(D)\), and lower case letters for elements in \({{\mathbb {Z}}}(d)\). We also take \(j_r\in {{\mathbb {Z}}}(d)\) and \(J\in {{\mathbb {Z}}}(D)\) in the ‘periods’

$$\begin{aligned} \left[ -\frac{d-1}{2}, \frac{d-1}{2}\right] ;\;\;\; \left[ -\frac{D-1}{2}, \frac{D-1}{2}\right] , \end{aligned}$$
(1)

correspondingly.

We introduce the following bijective map between the sets \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\)

$$\begin{aligned} (j_0,...,j_{n-1})\;\leftrightarrow \;J=j_0+j_1d+...+j_{n-1}d^{n-1}. \end{aligned}$$
(2)

Given J, we can find the \(j_0,...,j_{n-1}\) as the remainders in the following sequence of divisions:

  • We divide J by d and we get \(j_1+j_2d+...j_{n-1}d^{n-2}\) and remainder \(j_0\).

  • We divide \(j_1+j_2d+...j_{n-1}d^{n-2}\) by d and we get \(j_2+j_3d+...j_{n-1}d^{n-3}\) and remainder \(j_1\).

  • e.t.c.

We note that the \([{{\mathbb {Z}}}(d)]^n\) as a ring (with addition and multiplication componentwise), is not isomorphic to the ring \({{\mathbb {Z}}}(D)\) because addition and multiplication is different [15]. Indeed

$$\begin{aligned} (j_0,...,j_{n-1})+(k_0,...,k_{n-1})=(j_0+k_0,...,j_{n-1}+k_{n-1}) \end{aligned}$$
(3)

does not correspond to \(J+K\). The sum in \({{\mathbb {Z}}}(D)\) has the ‘carry’ rule and the r-component might be \(j_r+k_r+1\) rather than \(j_r+k_r\). In contrast, there is no ‘carry’ rule in \([{{\mathbb {Z}}}(d)]^n\). Also the multiplication in \({{\mathbb {Z}}}(D)\)

$$\begin{aligned} JK=j_0k_0+d(j_1k_0+k_1j_0)+...+d^{n-1}(j_0k_{n-1}+...+j_{n-1}k_0), \end{aligned}$$
(4)

does not correspond to the componentwise multiplication in \([{{\mathbb {Z}}}(d)]^n\)

$$\begin{aligned} (j_0,...,j_{n-1})\cdot (k_0,...,k_{n-1})=(j_0k_0,...,j_{n-1}k_{n-1}). \end{aligned}$$
(5)

Due to the non-isomorphism of the rings \({{\mathbb {Z}}}(D)\) and \([{{\mathbb {Z}}}(d)]^n\), there is a limitation (see subsection 4.C) of the corresponding fast Fourier transform method in Sect. 4.

We use the notation

$$\begin{aligned} \omega _r(s)=\exp \left( i\frac{2\pi s}{r}\right) . \end{aligned}$$
(6)

For later use, we use Eq. (4) and we get

$$\begin{aligned} \omega _D(JK)=\omega _{d^n}(j_0k_0)\omega _{d^{n-1}}(j_1k_0+k_1j_0)...\omega _d(j_0k_{n-1}+...+j_{n-1}k_0). \end{aligned}$$
(7)

Example 2.1

We consider the bijective map between the sets \([{{\mathbb {Z}}}(3)]^2\) and \({{\mathbb {Z}}}(9)\):

$$\begin{aligned} (j_0,j_1)\;\leftrightarrow \;J=j_0+3j_1;\;\;\;j_\nu =-1,0,1;\;\;\;J=-4,...,4. \end{aligned}$$
(8)

Then (1, 1) corresponds to \(4\in {{\mathbb {Z}}}(9)\). Addition in \([{{\mathbb {Z}}}(3)]^2\) gives \((1,1)+(1,1)=(-1,-1)\) which corresponds to \(-4\in {{\mathbb {Z}}}(9)\). The corresponding addition in \({{\mathbb {Z}}}(9)\) gives \(4+4=-1\).

2.2 The isomorphic rings \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) and \({{\mathbb {Z}}}(D)\) when \(D=d_0...d_{n-1}\) and the \(d_0,...,d_{n-1}\) are coprime

A different method for Fast Fourier transforms is the Good method [5,6,7] which is based on the Chinese remainder theorem. In a quantum context it has been used in [11, 16].

If \(d_0,...,d_{n-1}\) are coprime, then the ring \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) is isomorphic to \({{\mathbb {Z}}}(D)\) where \( D=d_0\times ...\times d_{n-1}\). We first define the integers

$$\begin{aligned} {\mathfrak a}_\nu =\frac{D}{d_\nu };\;\;\;{\mathfrak a}_\nu {\mathfrak b}_\nu =1 (\textrm{mod}\; d_\nu ) \end{aligned}$$
(9)

\({\mathfrak b}_\nu \) is the inverse of \({\mathfrak a}_\nu \) within \({{\mathbb {Z}}}(d_\nu )\), and it exists because the \({\mathfrak a}_\nu , d_\nu \) are coprime. We also define the \({\mathfrak c}_\nu ={\mathfrak a}_\nu {\mathfrak b}_\nu \) as an element of \({{\mathbb {Z}}}(D)\), which is an integer multiple of \(d_\nu \) plus one (\(Nd_\nu +1\)).

Lemma 2.2

$$\begin{aligned} {\mathfrak a}_\nu {\mathfrak a}_\mu ={\mathfrak a}_\nu ^2\delta _{\mu \nu }(\textrm{mod}\;D);\;\;\;{\mathfrak c}_\nu {\mathfrak c}_\mu ={\mathfrak c}_\nu \delta _{\mu \nu }(\textrm{mod}\;D);\;\;\; {\mathfrak a}_\nu {\mathfrak c}_\mu ={\mathfrak a}_\nu \delta _{\mu \nu }(\textrm{mod}\;D). \end{aligned}$$
(10)

Proof

In the first relation, for \(\nu \ne \mu \) we get a multiple of D, which is \(0(\textrm{mod}\; D\)).

In the second relation, we get

$$\begin{aligned} {\mathfrak c}_\nu {\mathfrak c}_\mu=\,& {} {\mathfrak a}_\nu {\mathfrak b}_\nu {\mathfrak a}_\mu {\mathfrak b}_\mu =({\mathfrak a}_\nu {\mathfrak b}_\nu )^2 \delta _{\nu \mu }= {\mathfrak c}_\nu ^2\delta _{\nu \mu }={\mathfrak c}_\nu (N d_\nu +1)\delta _{\nu \mu }={\mathfrak c}_\nu \delta _{\nu \mu }+N{\mathfrak b}_\nu ({\mathfrak a}_\nu d_\nu ) \nonumber \\ {}=\, & {} {\mathfrak c}_\nu \delta _{\nu \mu }+N{\mathfrak b}_\nu D={\mathfrak c}_\nu \delta _{\nu \mu }\;(\textrm{mod}\;D). \end{aligned}$$
(11)

In the third relation, we get

$$\begin{aligned} {\mathfrak a}_\nu {\mathfrak c}_\mu= & {} {\mathfrak a}_\nu {\mathfrak a}_\mu {\mathfrak b}_\mu ={\mathfrak a}_\nu ^2 {\mathfrak b}_\nu \delta _{\nu \mu }= {\mathfrak a}_\nu {\mathfrak c}_\nu \delta _{\nu \mu }={\mathfrak a}_\nu (N d_\nu +1)\delta _{\nu \mu }={\mathfrak a}_\nu \delta _{\nu \mu }+ND \nonumber \\ {}= & {} {\mathfrak c}_\nu \delta _{\nu \mu }\;(\textrm{mod}\;D). \end{aligned}$$
(12)

\(\hfill\square \)

We define a bijective map between \({{\mathbb {Z}}}(d_1)\times ...\times {{\mathbb {Z}}}(d_n)\) and \({{\mathbb {Z}}}(D)\) as follows:

$$\begin{aligned} (j_0,...,j_{n-1})\;\leftrightarrow \;J;\;\;\;j_\nu =J{(\mathrm mod}\;d_\nu )\in {{\mathbb {Z}}}(d_\nu );\;\;\;J=\sum j_\nu {\mathfrak c}_\nu \in {{\mathbb {Z}}}(D). \end{aligned}$$
(13)

The Chinese remainder theorem ensures that this map is bijective. Using Eq. (12), we prove that

$$\begin{aligned}{} & {} (j_0+j_0',...,j_{n-1}+j_{n-1}')\;\leftrightarrow \;J+J';\nonumber \\{} & {} (j_0j_0',...,j_{n-1}j_{n-1}')\;\leftrightarrow \;JJ'. \end{aligned}$$
(14)

and therefore the ring \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) is isomorphic to \({{\mathbb {Z}}}(D)\).

We also define a different bijective map

$$\begin{aligned} ({\widehat{j}}_0,...,{\widehat{j}}_{n-1})\;\leftrightarrow \;J;\;\;\;{\widehat{j}}_\nu =J{\mathfrak b}_\nu {(\mathrm mod}\;d_\nu )\in {{\mathbb {Z}}}(d_\nu );\;\;\;J=\sum {\widehat{j}}_\nu {\mathfrak a}_\nu \in {{\mathbb {Z}}}(D). \end{aligned}$$
(15)

From Eqs. (13) and (15) we find the relationship between \(j_\nu \) and \({\widehat{j}}_\nu \):

$$\begin{aligned} {\widehat{j}}_\nu =j_\nu {\mathfrak b}_\nu {(\mathrm mod}\;d_\nu );\;\;\;j_\nu ={\widehat{j}}_\nu {\mathfrak a}_\nu {(\mathrm mod}\;d_\nu ). \end{aligned}$$
(16)

Using Eqs. (12), (13) and (15) we prove that

$$\begin{aligned} JK={\widehat{j}}_0k_0{\mathfrak a}_0+...+{\widehat{j}}_{n-1} k_{n-1}{\mathfrak a}_{n-1}. \end{aligned}$$
(17)

It then follows the important relation:

$$\begin{aligned} \omega _D(JK)= \,& {} \omega _{d_0}({\widehat{j}}_0k_0)...\omega _{d_{n-1}}({\widehat{j}}_{n-1}k_{n-1})\nonumber \\= \,& {} \omega _{d_0}(j_0{\mathfrak b}_0k_0)...\omega _{d_{n-1}}(j_{n-1}{\mathfrak b}_{n-1}k_{n-1}) \end{aligned}$$
(18)

Example 2.3

Let \(d_0=3\) and \(d_1=5\). Then \(D=15\) and

$$\begin{aligned}{} & {} {\mathfrak a}_0=5;\;\;\;{\mathfrak b}_0=2;\;\;\;{\mathfrak c}_0=10\nonumber \\{} & {} {\mathfrak a}_1=3;\;\;\;{\mathfrak b}_1=2;\;\;\;{\mathfrak c}_1=6. \end{aligned}$$
(19)

Then

$$\begin{aligned} J=10j_0+6j_1=5{\widehat{j}}_0+3{\widehat{j}}_1 \end{aligned}$$
(20)

As an example, we take \(J=11\) and we find the corresponding \((j_0,j_1)=(2,1)\) and \(({\widehat{j}}_0,{\widehat{j}}_1)=(4,2)\). We confirm Eq. (16):

$$\begin{aligned}{} & {} j_0 {\mathfrak b}_0 =2\times 2=4={\widehat{j}}_0;\;\;\;j_1 {\mathfrak b}_1 =1\times 2={\widehat{j}}_1\nonumber \\{} & {} {\widehat{j}}_0 {\mathfrak a}_0=4\times 5=2 {(\mathrm mod}\;3)=j_0;\;\;\;{\widehat{j}}_1 {\mathfrak a}_1=2\times 3=1 {(\mathrm mod}\;5)=j_1. \end{aligned}$$
(21)

3 A quantum system \(\Sigma (D)\) with variables in \({{\mathbb {Z}}}(D)\)

We consider a quantum system \(\Sigma (D)\) with variables in the ring \({{\mathbb {Z}}}(D)\), where D is an odd integer. H(D) is the D-dimensional Hilbert space describing this system.

Let \(|X;J\rangle \) where \(J\in {{\mathbb {Z}}}(D)\) be an orthonormal basis in H(D). The X in the notation is not a variable, it simply indicates ‘position states’. The finite Fourier transform F is given by [17]

$$\begin{aligned}{} & {} F=\frac{1}{\sqrt{D}}\sum _{J,K}\omega _D(JK) |X;J\rangle \langle X;K|;\;\;\;A,J,K\in {{\mathbb {Z}}}(D)\nonumber \\{} & {} F^4=\textbf{1};\;\;\;FF^{\dagger }=\textbf{1}. \end{aligned}$$
(22)

We act with \(F^\dagger \) on position states and get the dual basis

$$\begin{aligned}{} & {} |P;J\rangle =F^\dagger |X;J\rangle =\frac{1}{\sqrt{D}}\sum _K\omega _D(-JK)|X;K\rangle . \end{aligned}$$
(23)

The P in the notation is not a variable, it simply indicates ‘momentum states’. A state \(|s\rangle \) in H(D) can be written as

$$\begin{aligned}{} & {} |s\rangle =\sum s(J)|X;J\rangle =\sum {{\widetilde{s}}}(J)|P;J\rangle \nonumber \\{} & {} {{\widetilde{s}}}(J)=\frac{1}{\sqrt{D}}\sum _K\omega _D(JK)s(K) \end{aligned}$$
(24)

Below we study the fast implementation of this Fourier transform.

4 The case \(D=d^n\)

4.1 A multipartite system \(\Sigma _n(d)\) with variables in \([{{\mathbb {Z}}}(d)]^n\)

We consider a multipartite system \(\Sigma _n(d)\) comprised of n components each of which is described with variables in \({{\mathbb {Z}}}(d)\). Positions and momenta take values in \([{{\mathbb {Z}}}(d)]^n\). This system is described with the \(d^n\)-dimensional Hilbert space \({\mathfrak H}_A=H(d)\otimes ...\otimes H(d)\). We consider the basis

$$\begin{aligned} |X;j_0,...,j_{n-1}\rangle =|X;j_0\rangle \otimes ...\otimes |X;j_{n-1}\rangle ;\;\;\;j_r\in {{\mathbb {Z}}}(d). \end{aligned}$$
(25)

An arbitrary state is written as

$$\begin{aligned} |s\rangle =\sum s(j_0,...,j_{n-1})|X;j_0,...,j_{n-1}\rangle ;\;\;\;\sum |s(j_0,...,j_{n-1})|^2=1. \end{aligned}$$
(26)

Fourier transforms are defined as:

$$\begin{aligned}{} & {} {\mathfrak F}_A=\mathcal{F}\otimes ...\otimes \mathcal{F};\;\;\;\mathcal{F}=\frac{1}{\sqrt{d}}\sum _{j,k}\omega _d(jk) |X;j\rangle \langle X;k|\nonumber \\{} & {} {\mathfrak F}_A^4=\textbf{1};\;\;\;{\mathfrak F}_A{\mathfrak F}_A^{\dagger }=\textbf{1};\;\;\;j,k\in {{\mathbb {Z}}}(d). \end{aligned}$$
(27)

We assume that \(D=d^n\) and compare and contrast the systems \(\Sigma _n(d)\) and \(\Sigma (D)\). Then \({\mathfrak H}_A\) is isomorphic to H(D) (because they both have the same dimension), and therefore \(\Sigma (D)\) and \(\Sigma _n(d)\) are two different descriptions of the same system. However as discussed in ref [15], Fourier transforms and phase space methods (displacement operators, Wigner and Weyl functions, etc) are different in \(\Sigma (D)\) and \(\Sigma _n(d)\) (F is different from \({\mathfrak F}_A\)). This is because in these techniques we use addition and multiplication and as we explained above, the rings \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\) are not isomorphic to each other. Furthermore (proposition 4.4 in ref [15]), depending on the dn, the Fourier transforms in \(\Sigma _n(d)\) and \(\Sigma (D)\) are unitarily inequivalent or unitarily equivalent.

Below we explain how the equivalent of the Fourier transform F in \(\Sigma (D)\), is a sequence of transformations in \(\Sigma _n(d)\) that involve Fourier transforms in the various components together with some other transformations. The latter is a fast Fourier transform in a quantum context.

4.2 Fast Fourier transform F in \(\Sigma (D)\) as a sequence of transformations in \(\Sigma _n(d)\) with \(D=d^n\)

We use the following dual notation for functions and states in \(\Sigma (D)\), based on the bijective map in Eq. (2):

$$\begin{aligned} s(K)=s( k_0,...,k_{n-1}). \end{aligned}$$
(28)

The matrix elements of the Fourier transform F in \(\Sigma (D)\) (Eq. (22)) as:

$$\begin{aligned}{} & {} F(j_0,...,j_{n-1}|k_0,...,k_{n-1})=\langle j_0,...,j_{n-1}|F|k_0,...,k_{n-1}\rangle \nonumber \\{} & {} =\frac{1}{\sqrt{d^n}}\omega _{d^n}[j_0k_0+d(j_1k_0+k_1j_0)+...+d^{n-1}(j_0k_{n-1}+...+j_{n-1}k_0)]\nonumber \\{} & {} =\mathcal{A}(k_{n-1})\mathcal{A}(k_{n-2})\mathcal{A}(k_{n-3})... \mathcal{A}(k_0) \end{aligned}$$
(29)

where

$$\begin{aligned}{} & {} \mathcal{A}(k_{n-1})=\frac{1}{\sqrt{d}}\omega _d(j_0k_{n-1})\nonumber \\{} & {} \mathcal{A}(k_{n-2})=\frac{1}{\sqrt{d}}\omega _{d}(j_1k_{n-2}) \omega _{d^2}(j_0k_{n-2})\nonumber \\{} & {} \mathcal{A}(k_{n-3})=\frac{1}{\sqrt{d}}\omega _{d}(j_2k_{n-3})\omega _{d^2}(j_1k_{n-3}) \omega _{d^3}(j_0k_{n-3})\nonumber \\{} & {} ......\nonumber \\{} & {} \mathcal{A}(k_0)=\frac{1}{\sqrt{d}}\omega _{d}(j_{n-1}k_{0})\omega _{d^2}(j_{n-2}k_0).... \omega _{d^n}(j_0k_0) \end{aligned}$$
(30)

Using this we implement the Fourier transform in Eq. (24), as a sequence of transforms in the system \(\Sigma _n(d)\). It involves the following steps (shown also in the quantum circuit in Fig. 1):

  • A Fourier transform of \(s(K)=s(k_0,...,k_{n-1})\) with \(\omega _d(j_0k_{n-1})\) that involves summation over \(k_{n-1}\):

    $$\begin{aligned} s_1(j_0|k_0,..,k_{n-2})=\frac{1}{\sqrt{d}}\sum _{k_{n-1}}\omega _d(j_0k_{n-1})s(k_0,...,k_{n-1}) \end{aligned}$$
    (31)
  • We first multiply \(s_1(j_0|k_0,..,k_{n-2})\) by \(\omega _{d^2}(j_0k_{n-2})\) (this is the analogue of ‘twiddle factors’ [18] in the present context). Then we perform a Fourier transform of \(\omega _{d^2}(j_0k_{n-2})s_1(j_0|k_0,..,k_{n-2})\) with \(\omega _{d}(j_1k_{n-2})\), that involves summation over \(k_{n-2}\):

    $$\begin{aligned} s_2(j_0,j_1|k_0,..,k_{n-3})= & {} \frac{1}{\sqrt{d}}\sum _{k_{n-2}}\omega _{d}(j_1k_{n-2}) [\omega _{d^2}(j_0k_{n-2})s_1(j_0|k_0,..,k_{n-2})] \end{aligned}$$
    (32)
  • We first multiply \(s_2(j_0,j_1|k_0,..,k_{n-2})\) by \(\omega _{d^2}(j_1k_{n-3})\omega _{d^3}(j_0k_{n-3})\). Then we perform a Fourier transform of \(\omega _{d^2}(j_1k_{n-3})\omega _{d^3}(j_0k_{n-3})s_2(j_0,j_1|k_0,..,k_{n-2})\) with \(\omega _{d}(j_2k_{n-3})\), that involves summation over \(k_{n-3}\):

    $$\begin{aligned} s_3(j_0,j_1,j_2|k_0,..,k_{n-4})= & {} \frac{1}{\sqrt{d}}\sum _{k_{n-3}}\omega _{d}(j_2k_{n-3}) [\omega _{d^2}(j_1k_{n-3})\omega _{d^3}(j_0k_{n-3})s_2(j_0,j_1|k_0,..,k_{n-2})] \end{aligned}$$
    (33)
  • We continue in this way and the n-step is a Fourier transform with \(\omega _{d}(j_{n-1}k_{0})\) that involves summation over \(k_{0}\):

    $$\begin{aligned} {{\widetilde{s}}}(J)= {{\widetilde{s}}}(j_0,...,j_{n-1})= & {} \frac{1}{\sqrt{d}}\sum _{k_0}\omega _{d}(j_{n-1}k_{0})[\omega _{d^2}(j_{n-2}k_0).... \omega _{d^n}(j_0k_0)s_{n-1}(j_0,...,j_{n-2}|k_0)] \end{aligned}$$
    (34)

We note that:

  • $$\begin{aligned} \sum |s(k_0,...,k_{n-1})|^2=\sum |s_1(j_0|k_0,..,k_{n-2})|^2=...=\sum |{{\widetilde{s}}}(j_0,...,j_{n-1})|^2=1. \end{aligned}$$
    (35)
  • Starting from \(s_r(j_0,...,j_{r-1}|k_0,..,k_{n-r-1})\) with a series of inverse Fourier transforms we get the original wavefunction \(s(k_0,...,k_{n-1})\). For example from \({{\widetilde{s}}}(j_0,...,j_{n-1})\) we go to \(s_{n-1}(j_0,...,j_{n-2}|k_0)]\) as follows:

    $$\begin{aligned} s_{n-1}(j_0,...,j_{n-2}|k_0)]=[\omega _{d^2}(-j_{n-2}k_0).... \omega _{d^n}(-j_0k_0)]\frac{1}{\sqrt{d}}\sum _{j_0}\omega _{d}(-j_{n-1}k_{0}) {{\widetilde{s}}}(j_0,...,j_{n-1}) \end{aligned}$$
    (36)

    In a similar way we go backwards in all above steps. Therefore all the \(s_r(j_0,...,j_{r-1}|k_0,..,k_{n-r-1})\) contain the same information as the original wavefunction \(s(k_0,...,k_{n-1})\).

Example 4.1

For \(n=2\), Eq. (29) becomes

$$\begin{aligned} {F}(j_0,j_1|k_0,k_1)=\frac{1}{\sqrt{d^2}}\omega _{d^2}[j_0k_0+d(j_1k_0+k_1j_0)]. \end{aligned}$$
(37)

Acting on a vector \(s(K)=s(k_0,k_1)\) we get

$$\begin{aligned} {{\widetilde{s}}}(J)= {{\widetilde{s}}}(j_0,j_1)=\frac{1}{\sqrt{d^2}}\sum _{k_0,k_1}\omega _{d^2}[j_0k_0+d(j_1k_0+k_1j_0)]s(k_0,k_1). \end{aligned}$$
(38)

In this case the fast Fourier transform given above becomes

$$\begin{aligned} {{\widetilde{s}}}(J)= {{\widetilde{s}}}(j_0,j_1)=\frac{1}{\sqrt{d}}\sum _{k_0}\omega _{d}(j_1k_{0})[\omega _{d^2}(j_{0}k_0)s_{1}(j_0|k_0)] \end{aligned}$$
(39)

with

$$\begin{aligned} s_1(j_0|k_0)= & {} \frac{1}{\sqrt{d}}\sum _{k_{1}}\omega _d(j_0k_1)s(k_0,k_1) \end{aligned}$$
(40)

4.3 Limitation of the method

We have calculated the Fourier transform of the function \(s(K)=s( k_0,...,k_{n-1})\). For other functions it is not easy to apply this method. For example in the Weyl function in Eq. (63) below, we want to calculate the Fourier transform of the function \(s(K)s^*(B+K)\). Because the rings \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\) (with \(D=d^n\)) are not isomorphic to each other, if

$$\begin{aligned}{} & {} (k_0,...,k_{d-1})\;\leftrightarrow \;K=k_0+k_1d+...+k_{n-1}d^{n-1}\nonumber \\{} & {} (b_0,...,b_{d-1})\;\leftrightarrow \;B=b_0+b_1d+...+b_{n-1}d^{n-1}. \end{aligned}$$
(41)

the \((k_0+b_0,...,k_{n-1}+b_{n-1})\) does not correspond to \(K+B\). It is then difficult to apply directly the above formalism to Eq. (63) for the fast calculation of the Weyl and Wigner functions.

In general, this fast Fourier transform is not directly applicable to functions which involve various sums and products of the variables. The fact that the rings \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\) are not isomorphic to each other, limits the practical use of the method.

4.4 Parallelism in the special case of factorisable states

We consider the factorisable state

$$\begin{aligned} s(K)=s(k_0,...,k_{n-1})=g_0(k_0)g_1(k_1)...g_{n-1}(k_{n-1});\;\;\;\sum _{k_\nu }|g_\nu (k_\nu )|^2=1. \end{aligned}$$
(42)

In this case

$$\begin{aligned}{} & {} s_1(j_0|k_0,..,k_{n-2})=g_0(k_0)...g_{n-2}(k_{n-2}){{\widetilde{g}}}_{n-1}(j_0)\nonumber \\{} & {} {{\widetilde{g}}}_{n-1}(j_0)=\frac{1}{\sqrt{d}}\sum _{k_{n-1}}\omega _d(j_0k_{n-1})g_{n-1}(k_{n-1}) \end{aligned}$$
(43)

Also

$$\begin{aligned}{} & {} s_2(j_0,j_1|k_0,..,k_{n-3})=g_0(k_0)...g_{n-3}(k_{n-3}){{\widetilde{G}}}_{n-2}(j_0,j_1){{\widetilde{g}}}_{n-1}(j_0)\nonumber \\{} & {} {{\widetilde{G}}}_{n-2}(j_0,j_1)= \frac{1}{\sqrt{d}}\sum _{k_{n-2}}\omega _{d}(j_1k_{n-2}) [\omega _{d^2}(j_0k_{n-2})g_{n-2}(k_{n-2})] \end{aligned}$$
(44)

Also

$$\begin{aligned}{} & {} s_3(j_0,j_1,j_2|k_0,..,k_{n-4})=g_0(k_0)...g_{n-4}(k_{n-4}){{\widetilde{G}}}_{n-3}(j_0,j_1,j_2){{\widetilde{G}}}_{n-2}(j_0,j_1){{\widetilde{g}}}_{n-1}(j_0)\nonumber \\{} & {} {{\widetilde{G}}}_{n-3}(j_0,j_1,j_2)= \frac{1}{\sqrt{d}}\sum _{k_{n-3}}\omega _{d}(j_2k_{n-3}) [\omega _{d^2}(j_1k_{n-3})\omega _{d^3}(j_0k_{n-3})g_{n-3}(k_{n-3})] \end{aligned}$$
(45)

etc. The last one is

$$\begin{aligned}{} & {} {{\widetilde{s}}}(j_0,...,j_{n-1})={{\widetilde{G}}}_0(j_0,...,j_{n-1}){{\widetilde{G}}}_1(j_0,...,j_{n-2})...{{\widetilde{G}}}_{n-2}(j_0,j_1){{\widetilde{g}}}_{n-1}(j_0)\nonumber \\{} & {} {{\widetilde{G}}}_0(j_0,...,j_{n-1})=\frac{1}{\sqrt{d}}\sum _{k_0}\omega _{d}(j_{n-1}k_{0})[\omega _{d^2}(j_{n-2}k_0).... \omega _{d^n}(j_0k_0)g_0(k_0)] \end{aligned}$$
(46)

We note that for factorisable functions, we can calculate independently each of the n factors \({{\widetilde{G}}}_0(j_0,...,j_{n-1}), {{\widetilde{G}}}_1(j_0,...,j_{n-2}),...,{{\widetilde{g}}}_{n-1}(j_0)\) and multiply them at the end. Therefore this scheme is suitable for parallel computation. The calculation in the previous subsection for general functions, needs to be done sequentially.

Example 4.2

For \(n=2\) we consider the factorisable state

$$\begin{aligned} s(K)= s(k_0,k_1)=g_0(k_0)g_1(k_1) \end{aligned}$$
(47)

In this case

$$\begin{aligned}{} & {} {{\widetilde{s}}}(J)={{\widetilde{s}}}(j_0,j_1)={{\widetilde{G}}}_0(j_0,j_1){{\widetilde{g}}}_{1}(j_0)\nonumber \\{} & {} {{\widetilde{g}}}_{1}(j_0)=\frac{1}{\sqrt{d}}\sum _{k_1}\omega _d(j_0k_1)g_1(k_1)\nonumber \\{} & {} {{\widetilde{G}}}_0(j_0,j_1)=\frac{1}{\sqrt{d}}\sum _{k_0}\omega _{d}(j_{1}k_{0})[\omega _{d^2}(j_{0}k_0)g_0(k_0)] \end{aligned}$$
(48)

The two factors \({{\widetilde{G}}}_0(j_0,j_1)\) and \({{\widetilde{g}}}_{1}(j_0)\) can be calculated in parallel.

Remark 4.3

The ‘parallel formalism’ of this section is limited to special cases where we know that the factorisation in Eq.(42) holds. Given \(s(K)=s(k_0,...k_{n-1})\), we give a necessary (but not sufficient) condition for the factorisation to hold.

We define the

$$\begin{aligned} |g(k_\nu )|^2= \sum _{\ne k_\nu }|s(k_0,...k_{n-1})|^2. \end{aligned}$$
(49)

Here we have a summation over all indices, except one. A necessary (but not sufficient) condition for Eq. (42) to hold, is that

$$\begin{aligned} |s(k_0,...k_{n-1})|=|g(k_0)|...|g(k_{n-1})| \end{aligned}$$
(50)

4.5 Time complexity of the Fourier transform: counting the number of multiplications

The estimate of the computational time is usually based on the number of multiplications, because they require more computational time than additions. It is easily seen that the number of multiplications for ‘normal’ Fourier transform is \({{\mathcal {O}}}(D^2)\) (it is a multiplication of a \(D\times D\) matrix with a D-dimensional vector). For the fast Fourier transform it is known that a lower bound for the computational time is \({{\mathcal {O}}}(D\log D)\), and we now give an approximate estimate for this.

In the fast transform in Sect. 4.2, the first step in Eq. (31) is a Fourier transform in a d-dimensional space and it requires \(d^2\) multiplications. This needs to be repeated for all values of the \(n-1\) variables \(k_0,..,k_{n-2}\) which take d values each, therefore the number of multiplications is \(d^2d^{n-1}=Dd\). The second step in Eq. (32) involves another Dd multiplications (plus some extra multiplications which we ignore because we are interested in a lower limit). In this way we find that a lower bound for the number of multiplications is

$$\begin{aligned} Dnd\ge Dn\log d=D\log D. \end{aligned}$$
(51)

Many authors pointed out that this is a lower bound and that ‘real’ numerical fast Fourier transforms take a bit more time than that.

We consider a Hilbert space H(D) with \(D=d^2\), where d that takes all the odd values 51, ...., 101. Using a random vector \(s(K)=s(k_0,k_1)\) (produced by qiskit [19]), we calculated \({{\widetilde{s}}}(J)={{\widetilde{s}}}(j_0,j_1)\) using both Eq. (38) (that involves the multiplication of a \(D\times D\) matrix times a D-dimensional vector) and also the fast Fourier transform in Eqs(39), (40). We call T(D) the computational time for the calculation of all components \({{\widetilde{s}}}(j_0,j_1)\) with the ‘normal’ Fourier transform in Eq.(38), and \(T_f(D)\) the computational time for the calculation with the fast Fourier transform in Eqs(39), (40). In Figs. 2 and 3 we plot

$$\begin{aligned} \frac{T(D)}{D^2};\;\; \frac{T_f(D)}{D\log D};\;\;\;D=d^2. \end{aligned}$$
(52)

The result for \(\frac{T(D)}{D^2}\) in Fig. 2 is a horizontal line and this confirms that the computational time for the normal Fourier transform is \({{\mathcal {O}}}(D^2)\).

The result for \(\frac{T_f(D)}{D\log D}\) in Fig. 3 is a slightly ascending line and this confirms that a good lower bound for the computational time of the fast Fourier transform is approximately \({{\mathcal {O}}}(D\log D)\).

In Fig. 4 we compare T(D) with \(T_f(D)\). It is seen that \(T_f(D)\) is much smaller than T(D). We checked that the Fourier transform of different random vectors give similar results.

5 The case \(D=d_0...d_{n-1}\) with coprime \(d_0,...,d_{n-1}\)

5.1 A multipartite system \(\Sigma (d_0,...,d_{n-1})\) with variables in \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\).

In this section \(D=d_0...d_{n-1}\) with \(d_0,...,d_{n-1}\) odd integers coprime to each other. We consider a multipartite system \(\Sigma (d_0,...,d_{n-1})\) comprised of n components, which are described with variables in \({{\mathbb {Z}}}(d_0),...,{{\mathbb {Z}}}(d_{n-1})\). Positions and momenta in the multipartite system take values in \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) and the corresponding Hilbert space is \({\mathfrak H}_B=H(d_0)\otimes ...\otimes H(d_{n-1})\). The Hilbert spaces H(D) and \({\mathfrak H}_B\) are isomorphic (they have the same dimension), and therefore \(\Sigma (D)\) and \(\Sigma (d_0,...,d_{n-1})\) are two different descriptions of the same system.

We consider the basis

$$\begin{aligned} |X;j_0,...,j_{n-1}\rangle =|X;j_0\rangle \otimes ...\otimes |X;j_{n-1}\rangle ;\;\;\;j_\nu \in {{\mathbb {Z}}}(d_\nu ). \end{aligned}$$
(53)

An arbitrary state is written as

$$\begin{aligned} |s\rangle =\sum s(j_0,...,j_{n-1})|X;j_0,...,j_{n-1}\rangle ;\;\;\;\sum |s(j_0,...,j_{n-1})|^2=1. \end{aligned}$$
(54)

Fourier transforms in \(\Sigma (d_0,...,d_{n-1})\) are defined as:

$$\begin{aligned}{} & {} {\mathfrak F}_B=\mathcal{F}_0\otimes ...\otimes \mathcal{F}_{n-1};\;\;\;\mathcal{F}_\nu =\frac{1}{\sqrt{d}}\sum _{j_\nu ,k_\nu }\omega _{d_{\nu }}(j_{\nu } k_{\nu }) |X;j_{\nu }\rangle \langle X;k_{\nu }|\nonumber \\{} & {} {\mathfrak F}_B^4=\textbf{1};\;\;\;{\mathfrak F}_B{\mathfrak F}_B^{\dagger }=\textbf{1};\;\;\;j_\nu ,k_\nu \in {{\mathbb {Z}}}(d_\nu ). \end{aligned}$$
(55)

Clearly F is very different from \({\mathfrak F}_B\).

5.2 Fast Fourier transform F in \(\Sigma (D)\) as a sequence of transformations in \(\Sigma (d_0,...,d_{n-1})\) with \(D=d_0...d_{n-1}\)

We use the following dual notation for all functions and states in \(\Sigma (D)\), based on the bijective map in Eq. (13):

$$\begin{aligned} s(K)=s(k_0,...,k_{n-1});\;\;\;k_\nu \in {{\mathbb {Z}}}(d_\nu ). \end{aligned}$$
(56)

Using Eq. (18) we express the matrix elements of the Fourier transform F in \(\Sigma (D)\) (Eq. (22)) as:

$$\begin{aligned}{} & {} F(j_0,...,j_{n-1}|k_0,...,k_{n-1})=\langle j_0,...,j_{n-1}|F|k_0,...,k_{n-1}\rangle \nonumber \\{} & {} =\left[ \frac{1}{\sqrt{d_0}}\omega _{d_0}( j_0{\mathfrak b}_0 k_0)\right] ...\left[ \frac{1}{\sqrt{d_{n-1}}}\omega _{d_{n-1}}( j _{n-1}{\mathfrak b}_{n-1} k_{n-1})\right] \end{aligned}$$
(57)

The constants \({\mathfrak b}_\nu \) have been defined in Eq. (9). Using this we implement the Fourier transform in Eq. (24), as a sequence of transforms in the system \(\Sigma (d_0,...,d_{n-1})\). It involves the following steps (shown also in the quantum circuit in Fig. 5):

  • A Fourier transform of \(s(K)=s(k_0,...,k_{n-1})\) with \(\omega _{d_{n-1}}( j _{n-1}{\mathfrak b}_{n-1} k_{n-1})\) (we note here the constant \({\mathfrak b}_{n-1}\)) and summation over \(k_{n-1}\):

    $$\begin{aligned} s_1(j_{n-1}|k_0,..,k_{n-2})=\frac{1}{\sqrt{d_{n-1}}}\sum _{k_{n-1}}\omega _{d_{n-1}}( j _{n-1}{\mathfrak b}_{n-1} k_{n-1})s(k_0,...,k_{n-1}) \end{aligned}$$
    (58)
  • A Fourier transform of \(s_1(j_{n-1}|k_0,...,k_{n-2})\) with \(\omega _{d_{n-2}}( j _{n-2}{\mathfrak b}_{n-2} k_{n-2})\) (we note here the constant \({\mathfrak b}_{n-2}\)) and summation over \(k_{n-2}\):

    $$\begin{aligned} s_2(j_{n-2}, j_{n-1}|k_0,..,k_{n-3})=\frac{1}{\sqrt{d_{n-2}}}\sum _{k_{n-2}}\omega _{d_{n-2}}( j _{n-2}{\mathfrak b}_{n-2} k_{n-2}) s_1(j_{n-1}|k_0,..,k_{n-2}), \end{aligned}$$
    (59)

    etc. The last step is

  • $$\begin{aligned} {{\widetilde{s}}}(J)={{\widetilde{s}}}(j_0,...,j_{n-1})=\frac{1}{\sqrt{d_0}}\sum _{k_0}\omega _{d_0}( j _0{\mathfrak b}_0 k_0)s_{n-1}(j_1,...,j_{n-1}|k_0) \end{aligned}$$
    (60)

    Similarly to the previous method, for factorisable functions these n steps can be done in parallel. But for general functions, they need to be done sequentially.

5.3 Time complexity of the Fourier transform: counting the number of multiplications

We first give an approximate estimate that a lower bound for the computational time in the present scheme, is \({{\mathcal {O}}}(D\log D)\).

In the fast transform in Sect.5.2, the first step in Eq. (58) is a Fourier transform in a \(d_{n-1}\)-dimensional space and it requires \(d_{n-1}^2\) multiplications. This needs to be repeated for all values of the \(n-1\) variables \(k_0,..,k_{n-2}\), therefore the number of multiplications is \(d_1...d_{n-2}d_{n-1}^2=Dd_{n-1}\). The second step in Eq. (59) involves another \(Dd_{n-2}\) multiplications. In this way we find that a lower bound for the number of multiplications is

$$\begin{aligned} D(d_0+...+d_{n-1})\ge D(\log d_0+...+\log d_{n-1})=D\log D. \end{aligned}$$
(61)

We consider Hilbert spaces \(H(d_1d_2)\) where \(d_1=53\) and \(d_2\) takes the odd values 55, 57, ...., 101. Since 53 is a prime number the \(d_1, d_2\) are coprime. As in Sect. 4.5 we used a random vector \(s(K)=s(k_0,k_1)\) (produced by qiskit [19]), we calculated \({{\widetilde{s}}}(J)={{\widetilde{s}}}(j_0,j_1)\). In Figs. 6 and 7 we plot

$$\begin{aligned} \frac{T(D)}{D^2};\;\; \frac{T_f(D)}{D\log D};\;\;\;D=d_1d_2. \end{aligned}$$
(62)

The result for \(\frac{T(D)}{D^2}\) in Fig. 6 is a horizontal line and this confirms that the computational time for the normal Fourier transform is \({{\mathcal {O}}}(D^2)\). The result for \(\frac{T_f(D)}{D\log D}\) in Fig. 7 is also a horizontal line and this confirms that a good lower bound for the computational time of the fast Fourier transform is approximately \({{\mathcal {O}}}(D\log D)\).

In Fig. 8 we compare T(D) with \(T_f(D)\). It is seen that \(T_f(D)\) is much smaller than T(D). We checked that the Fourier transform of different random vectors give similar results.

6 Fast Wigner and Weyl functions using the second method

Phase space methods for the system \(\Sigma (D)\) (Wigner and Weyl functions, etc) rely heavily on Fourier transforms. Therefore fast Fourier transforms can be used for the fast calculation of various quantities within the phase space formalism.

As an example, we consider the Weyl function \({\widetilde{W}}(A,B)\) and the Wigner function W(AB) for the state \(|s\rangle =\sum _Ks(K)|X; K\rangle \) of the system \(\Sigma (D)\). They are given by the following Fourier transforms(e.g., [20]):

$$\begin{aligned}{} & {} {\widetilde{W}}(A,B)=\omega _D(2^{-1}AB)\sum _K \omega _D(AK)s(K)s^*(B+K);\;\;\;A,B\in {{\mathbb {Z}}}(D)\nonumber \\{} & {} W(A,B)=\omega _D(2AB)\sum _K \omega _D(-2AK)s(K)s^*(2B-K) \end{aligned}$$
(63)

The \(2^{-1}=\frac{D+1}{2}(\textrm{mod}\;D)\) for odd D.

We explained in Sect. 4.3 that the first method for fast Fourier transforms (in the case \(D=d^n\)) is not directly applicable to Eq. (63), for the fast calculation of these functions. This is related to the fact that the rings \([{{\mathbb {Z}}}(d)]^n\) and \({{\mathbb {Z}}}(D)\) (with \(D=d^n\)) are not isomorphic to each other.

The second method for fast Fourier transforms (in the case \(D=d_0...d_{n-1}\) with coprime \(d_0,...,d_{n-1}\)) is directly applicable in the fast calculation of the Weyl and Wigner functions. We present in detail the fast Weyl function. We use the bijective map in Eq. (13), and express KB as

$$\begin{aligned}{} & {} K\leftrightarrow (k_0,...,k_{n-1});\;\;\;k_\nu \in {{\mathbb {Z}}}(d_\nu )\nonumber \\{} & {} B\leftrightarrow (b_0,...,b_{n-1});\;\;\;b_\nu \in {{\mathbb {Z}}}(d_\nu )\nonumber \\{} & {} A\leftrightarrow (a_0,...,a_{n-1});\;\;\;a_\nu \in {{\mathbb {Z}}}(d_\nu ) \end{aligned}$$
(64)

The rings \({{\mathbb {Z}}}(D)\) and \({{\mathbb {Z}}}(d_0)\times ...\times {{\mathbb {Z}}}(d_{n-1})\) are isomorphic and therefore

$$\begin{aligned} K+B\leftrightarrow (k_0+b_0,...,k_{n-1}+b_{n-1}). \end{aligned}$$
(65)

Consequently

$$\begin{aligned} s(K)s^*(B+K)=s(k_0,...,k_{n-1})s^*(k_0+b_0,...,k_{n-1}+b_{n-1}). \end{aligned}$$
(66)

We now give briefly the basic steps for the fast Weyl function (shown also in the quantum circuit in Fig 9).

  • A Fourier transform of \(s(\{k_{r}\})s^*(\{k_r+b_r\})\) with \(\omega _{d_{n-1}}( a_{n-1}{\mathfrak b}_{n-1} k_{n-1})\) (we note here the constant \({\mathfrak b}_{n-1}\)) and summation over \(k_{n-1}\):

    $$\begin{aligned} {{\widetilde{W}}}_1(a_{n-1}|k_0,..,k_{n-2}|\{b_r\})=\sum _{k_{n-1}}\omega _{d_{n-1}}( a_{n-1}{\mathfrak b}_{n-1} k_{n-1})s(\{k_r\})s^*(\{k_r+b_r\}). \end{aligned}$$
    (67)
  • A Fourier transform of \( {{\widetilde{W}}}_1(a_{n-1}|k_0,..,k_{n-2}|\{b_r\})\) with \(\omega _{d_{n-2}}( a _{n-2}{\mathfrak b}_{n-2} k_{n-2})\) (we note here the constant \({\mathfrak b}_{n-2}\)) and summation over \(k_{n-2}\):

    $$\begin{aligned} {{\widetilde{W}}}_2(a_{n-2}, a_{n-1}|k_0,..,k_{n-3}|\{b_r\})=\sum _{k_{n-2}}\omega _{d_{n-2}}( a_{n-2}{\mathfrak b}_{n-2} k_{n-2}) {{\widetilde{W}}}_1(a_{n-1}|k_0,..,k_{n-2}|\{b_r\}), \end{aligned}$$
    (68)

    etc. The last step is

  • $$\begin{aligned} {{\widetilde{W}}}(A,B)={{\widetilde{W}}}(\{a_r,b_r\})=\omega _D(2^{-1}AB)\sum _{k_0}\omega _{d_0}( a_0{\mathfrak b}_0 k_0){{\widetilde{W}}}_{n-1}(a_1,..., a_{n-1}|k_0|\{b_r\}). \end{aligned}$$
    (69)

    Similarly to the previous methods, for factorisable functions \(s(k_0,...,k_{n-1})\) these n steps can be done in parallel. But for general functions, they need to be done sequentially.

Analogous algorithm can be given for the Wigner function.

We note that the Fourier transform requires \(\mathcal{O}(D^2)\) multiplications, but it needs to be performed for all values of AB. Therefore the complexity of the calculation of the Wigner or Weyl function is \(\mathcal{O}(D^4)\), and with the fast Fourier transforms discussed above it is reduced to \(\mathcal{O}(D^3\log D)\).

As an example we consider the case \(D=21\times 23=3\times 7\times 23\) and calculated the Weyl function of a random vector (produced by qiskit [19]) with the normal Fourier transform and with the fast method given above. We found numerically that the ratio of the corresponding computational times is \(T/T_f=14.7\) (with the \(D=21\times 23\) factorisation), and \(T/T_f=17.6\) (with the \(D=3\times 7\times 23\) factorisation).

7 Discussion

We have presented a fast implementation of the Fourier transform F in a large quantum system. This replaces the large Fourier transform with many small Fourier transforms. The small Fourier transforms can be performed classically or (if available) in a quantum computer in which case we have the well known additional advantages of quantum Fourier transforms. We used two methods.

The first method is for the case \(D=d^n\) with d an odd integer. This is based on the bijective map between the sets \({{\mathbb {Z}}}(D)\) and \([{{\mathbb {Z}}}(d)]^n\) in Eq. (2). The algorithm is described in Eqs. (31)–(34) and the relevant quantum circuit is shown in Fig. 1.

The complexity (based on the number of multiplications) of the normal Fourier transform is \(\mathcal{O}(D^2)\) and of the fast Fourier transform \(\mathcal{O}(D\log D)\). This has been supported with numerical work shown in Figs 2 and 3. As expected the fast Fourier transform is much faster than the normal Fourier transform (Fig. 3). A limitation of the method is the fact that the ring \({{\mathbb {Z}}}(D)\) (with \(D=d^n\)) is not isomorphic to the ring \([{{\mathbb {Z}}}(d)]^n\). Consequently, this method cannot be used with Eq. (63) for the fast calculation of the Wigner and Weyl functions.

The second method is for the case \(D=d_0...d_{n-1}\) with \(d_0,...,d_{n-1}\) odd integers coprime to each other. This is based on the bijective map between the rings \({{\mathbb {Z}}}(D)\) and \({{\mathbb {Z}}}(d_0),...,{{\mathbb {Z}}}(d_{n-1})\) in Eq. (13). These two rings are isomorphic. The algorithm is described in Eqs. (58)–(60) and the relevant quantum circuit is shown in Fig. 5. Numerical work shown in Figs. 6 and 7 confirm that the complexity of the normal Fourier transform is \(\mathcal{O}(D^2)\) and of the fast Fourier transform \(\mathcal{O}(D\log D)\). Figure 8 shows that the fast Fourier transform requires much less computational time than the Normal Fourier Transform.

This second method can be used with Eq. (63) for the fast calculation of the Wigner and Weyl functions. The algorithm for the Weyl function is given in Eqs. (67)–(69) and the relevant quantum circuit is shown in Fig. 9.