# Multi-dimensional Fourier series with quantum circuits

Berta Casas<EMAIL_ADDRESS>Barcelona Supercomputing Center, Plaça Eusebi
Güell, 1-3, 08034 Barcelona, Spain.  Alba Cervera-Lierta<EMAIL_ADDRESS>Barcelona Supercomputing Center, Plaça Eusebi Güell, 1-3, 08034 Barcelona,
Spain.

###### Abstract

Quantum Machine Learning is the field that aims to integrate Machine Learning
with quantum computation. Recently, some works have shown that we can
naturally generate one-dimensional Fourier series with a quantum supervised
learning model. However, models used for multi-dimensional functions have not
been explored with the same level of detail. In this work, we study quantum
strategies for fitting arbitrary multi-dimensional functions using different
types of circuit ansatzes that generate multi-dimensional Fourier series. We
found that the degrees of freedom required for fitting such functions grow
faster than the available degrees in the Hilbert space generated by the
circuit. These results exhibit that, for these types of problems, the model
does not have enough freedom to achieve any arbitrary Fourier series. Our work
contributes to the study of multi-feature quantum machine learning algorithms
with classical data and concludes that new encoding strategies beyond Fourier
series formalism can be more convenient.

##  I Introduction

Machine Learning (ML) is a well-established field that aims to develop the
necessary tools to extract knowledge from big data batches by drawing
inferences from its patterns. The development of computational paradigms such
as quantum computation opens the path to explore the use of quantum devices to
perform ML tasks, which raises the question of whether Quantum Machine
Learning (QML) algorithms can offer an advantage compared to classical ones.

QML explores the use of quantum computing devices to implement ML algorithms
[1]. In some of these algorithms, in particular, in the supervised learning
ones, data stored in a classical register needs to be mapped into a quantum
state to be later processed by the quantum circuit. The parameters of the
circuit are optimized by minimizing a cost function that compares some
expectation values obtained from the circuit with the true data labels.
Several proposals exist to embed data into quantum circuits [2, 3, 4].
Particularly, the re-uploading strategy has been applied to several problems,
such as classification [2] or function fitting [5].

It has been shown that partial Fourier series emerge as the output of these
models when using the re-uploading protocol [6]. Fourier series are universal
to represent any square-integrable function in a given interval. This result
has attracted the attention of recent QML works that use classical data [7, 8,
9, 10]. However, many applications that might require QML require multi-
dimensional data sets [11]. Although several works discuss the generalization
of this model to multi-dimensional data, there needs to be a more thoughtful
analysis of the implementation and scaling of the model with the data
dimensions. The relevance of studying this problem lies in the expressibility
of the QML models (the type of functions that they can learn), which can help
us understand the capacity and limitations of such models.

The current state of the art in experimental quantum computation, the so-
called Noisy Intermediate-Scale Quantum (NISQ) era [12], presents a few qubit
devices with limited coherence times that impose restrictions on the circuit
depth and the fidelity of quantum operations. A family of algorithms suitable
for these devices are Variational Quantum Algorithms (VQA) [13, 14], from
which the aforementioned supervised QML algorithms are part. Variational
algorithms present certain noise resilience due to their hybridization with a
classical optimization subroutine that fine-tunes the circuit parameters.
However, the low number of qubits in these NISQ devices limits the size of the
Hilbert space available to perform quantum computational tasks. A way to
circumnavigate this issue is to increase the Hilbert space by exploiting the
higher local dimensions of each quantum information unit. Indeed, all quantum
systems naturally contain more than two levels, which makes translating a
qubit quantum device into a qudit system with $d$ dimensions technically
feasible, despite being experimentally challenging. Thus, increasing the
Hilbert space from $2^{n}$ to $d^{n}$ for $n$ quantum information units might
prove valuable in the near term [15, 16, 17, 18, 19, 20].

This work analyzes the multi-dimensional Fourier series representation of QML
circuits fed with classical data using a general formalism for qubits and
beyond (qudits). We show how the quantum circuit requirements scale with the
dimension of qudits and data when using the well-established data re-uploading
strategy. Furthermore, we provide three types of circuit ansatz to generate
these functions and examine the constraints to ensure a proper fitting of a
general series. We show that while the proposed encoding strategies generate
multi-dimensional Fourier series, the scaling of the degrees of freedom
required to fit a general function grows faster than the Hilbert space of the
Parameterized Quantum Circuit (PQC) space. We also present alternative
strategies that might be more suitable to fit multi-feature data, although
they depart from Fourier series formalism.

This work is organized as follows: In Section II, we review the formalism of
the one-dimensional Fourier series, and in Section III, we extend it to the
multi-dimensional case. Furthermore, we discuss the degrees of freedom
requirements, implementations and analysis of the models. In Section IV, we
propose a different encoding ansatz that offers an alternative to multi-
feature QML problems. Finally, the conclusions are presented in Section V.

##  II One-dimensional Fourier series with quantum circuits

Figure 1: Schematic representation of a quantum supervised learning model,
which pertains to the family of Variational Quantum Algorithm (VQA). The
picture divides the quantum and the classical part (dashed line boxes). The
quantum part is composed of a quantum circuit with a given unitary $U$ that
depends on the data point $\vec{x}$ and the trainable parameters
$\vec{\theta}$. The classical part consists of building an expectation value
of a given observable $\mathcal{M}$, introducing it into a cost function (in
our case, tailored for the classification of a target function $f(\vec{x})$)
and optimize it with respect to the parameters via a classical subroutine.

This section reviews the quantum supervised learning model for fitting one-
dimensional functions with the re-uploading strategy. We use a VQA fed with
classical data, as we present in Fig. 1. Using a train data set $\\{x\\}$ with
corresponding function images $f({x})$, we generate a quantum circuit for each
data point by using encoding gates $S(x)$ and parameterized gates
$A{(\vec{\theta}})$, which act as trainable gates. By measuring the
expectation value of some operator $\mathcal{M}$, we obtain a Fourier series
in the $\\{x\\}$ domain. After optimizing the parameters $\vec{\theta}$, we
introduce test data points into the circuit to obtain a function prediction.

A widely used technique to define a PQC ansatz consists of defining a layer: a
subcircuit composed of encoding and processing quantum gates. This structure
is repeated $L$ times along the circuit [2, 21] (see Fig. 2). We define the
general circuit layer $l$ with the data re-uploading encoding as

$U_{0}\equiv A(\vec{\theta_{0}}),\quad U_{l}\equiv A(\vec{\theta_{l})}S(x),$
(1)

where $A(\vec{\theta_{l})}$ and $A(\vec{\theta_{0}})$ are general $n$ qudit
unitary gates, with free parameters $\vec{\theta}$, that act as processing
step. For the encoding gate, a unitary gate $S(x)=e^{ixH}$ is used, where $H$
is an arbitrary encoding Hamiltonian, and $x$ is the data point considered. We
assume that $H$ is diagonal since its single value decomposition is
$S(x)=V^{\dagger}e^{ix\Sigma}V$, where $V$ is a unitary gate that can be re-
absorbed by the processing gate $A({\vec{\theta_{l})}}$, and $\Sigma$ is a
diagonal matrix with the eigenvalues of $H$ (see App. A for the detailed
derivation). The circuit layer can be interpreted as a quantum analogy of a
neuron from a classical neural network because both structures are repeatedly
fed with data. This is why these models are sometimes called quantum neural
networks. The aforementioned quantum circuit ansatz has been used in prior
works to prove that we obtain a one-dimensional truncated Fourier series as
output of these models [6, 5].

Figure 2: General structure of a data re-uploading procedure. The 0th layer is
used to generate an initial superposition. The other layers contain an
encoding gate $S(x)$ and a processing gate $A(\vec{\theta}_{l})$, containing
parameters which are optimized.

######  Definition 1.

One-dimensional truncated Fourier series. A truncated Fourier series is an
expansion of a periodic real-valued function that can be expressed as a sum of
sines and cosines. In the exponential form, it takes the following structure:

$f(x)=\sum_{\omega=-D}^{D}c_{\omega}e^{ix\frac{\pi}{K}\omega},$ (2)

where $K$ is a half of the function period, $D=\text{max}(\Omega)$ is the
Fourier series degree and $\omega\in\mathbb{N}$ are the multiples of the
fundamental frequency $\frac{\pi}{T}$. The frequency spectrum is given by
$\Omega=\\{\omega\frac{\pi}{K}\\}_{\omega}$. The coefficients
$c_{\omega}\in\mathbb{C}$, fulfill the condition $c_{\omega}=c^{*}_{-\omega}$.
A Fourier series with enough degree $D$ can approximate any continuous and
square-integrable function.

By computing the expectation value of an observable $\mathcal{M}$ in the
output state of the PQC, we obtain an approximation of $f(x)$. For simplicity,
when we use more than one qudit in the PQC, we measure only one of them since
it does not affect the structure of the model. Then,
$\mathcal{M}=\mathbf{M}\otimes\mathbb{I}\otimes...\mathbb{I}$, where
$\mathbf{M}$ a single-qudit observable. We obtain (see App. A for the details)

$\langle\mathcal{M}(x)\rangle=\sum_{\omega\in\Omega_{\textbf{kk'}}}c_{\omega}\
e^{ix\omega},$ (3)

with

$c_{\omega}=\sum_{\begin{subarray}{c}\mathbf{k,k^{\prime}}=1\\\
\Omega_{\textbf{kk'}}=\omega\end{subarray}}^{N}\left(\sum_{i=1}^{N}\mathcal{M}_{i}A_{ik_{L}}^{(L)}A_{ik^{\prime}_{L}}^{*(L)}\right)\\\
\times
A_{k_{1}1}^{(0)}A_{k^{\prime}_{1}1}^{*(0)}\prod_{p=2}^{L}A_{k_{p}k_{p-1}}^{(p-1)}A_{k^{\prime}_{p}k^{\prime}_{p-1}}^{*(p-1)},$
(4)

where $N=d^{n}$ is the dimension of the Hilbert space of $n$ qudits with local
dimension $d$, $L$ is the number of layers, and $\mathcal{M}_{i}$ are the
eigenvalues of the observable, which we assume to be diagonal. We use the
multi-index notation $\textbf{k}\equiv\\{k_{1},k_{2},...k_{L}\\}\in[N]^{L}$,
with $k_{i}\in\\{1,..N\\}$. Also, we introduce the multi-index sum defined by
$\Lambda_{\textbf{k}}=(\lambda_{k_{1}}+\lambda_{k_{2}}+...\lambda_{k_{L}})$,
where $\lambda_{k_{i}}$ is an eigenvalue of the encoding Hamiltonian $H$ in
the layer $i$. With this, the frequency spectrum of the model is given by

$\begin{split}&\Omega_{\textbf{kk'}}\equiv\\{\Lambda_{\mathbf{k}}-\Lambda_{\mathbf{k^{\prime}}}\\}=\\\
&\\{\left(\lambda_{k_{1}}+\lambda_{k_{2}}+\cdots+\lambda_{k_{L}}\right)-\left(\lambda_{k^{\prime}_{1}}+\lambda_{k^{\prime}_{2}}+\cdots+\lambda_{k^{\prime}_{L}}\right)\\},\end{split}$
(5)

The frequency spectrum is fully characterized by the eigenvalues of the
encoding Hamiltonian, and the coefficients rely on the trainable gates and
their parameters. Notice that all combinations of the multi-indices k and k’
that generate a frequency $\Omega_{\textbf{kk'}}=\omega$ give us a different
contribution to the coefficient $c_{\omega}$.

So far, this model accepts a general encoding Hamiltonian $H$, but let us take
the following choice for practical purposes: using a Hamiltonian with the
$N$-dimensional spin $S_{z}$ eigenvalues, which we name the “spin-like”
encoding. For one qubit we use $H=\frac{1}{2}\sigma_{z}$, with eigenvalues
$\pm 1/2$; for one qutrit, the analogous Hamiltonian of a spin-1 Hamiltonian,
which eigenvalues are $\pm 1,0$, etc. We use a global $S_{z}$ Hamiltonian
tailored to the dimension of the quantum circuit $N=d^{n}$. For example, for a
system of two qubits ($N=2^{2}=4$), $H$ is the spin-3/2 Hamiltonian, which
acts on the whole circuit instead of using
$H=\frac{1}{2}\sigma_{z}\otimes\frac{1}{2}\sigma_{z}$. This encoding will be
the same used with a ququart, a qudit of $d=4$ (with the same value of $N$ as
for two qubits). Using this particular encoding, the positive frequency
spectrum (emerging from Eq. (5)) is $\Omega=\\{0,\cdots,(N-1)L-1,(N-1)L\\}$,
where $L$ is the number of layers in the circuit. The negative frequencies are
also included in the spectrum, which is symmetric by its construction. For
simplicity, from now on, we drop the label for multi-indices in the frequency
spectrum: $\Omega\equiv\Omega_{\textbf{kk'}}$. The degree of the Fourier
series, with this particular encoding, is given by

$D=(N-1)L.$ (6)

The spectrum generated with the “spin-like” encoding only contains integer
frequencies. For instance, if the function we are fitting requires semi-
integer or real frequencies a proper approximation cannot be achieved,
regardless of the number of layers used. We can tackle this issue by
introducing a re-scaling parameter $\eta$ into the encoding gate:
$S(x)=e^{ix\eta H}$. This parameter is optimized together with the rest of the
free parameters of the circuit, as we explain in App. C. With this re-scaling
factor, the whole Fourier series spectrum is multiplied by $\eta$, and the
degree of the Fourier sereis becomes $D=\eta(N-1)L$. We can introduce more
fine-tuning in the frequency spectrum by using a different $\eta_{i}$ for each
encoding gate in the circuit layers. This extension is closer to the original
idea from the data re-uploading work [2]. Thus, the available frequency
spectrum is strictly related to the encoding strategy. For example, in Ref.
[8] the authors explain a method for generating exponentially more frequencies
using the re-scaling factors.

##  III Multi-dimensional Fourier series with quantum circuits

In this section, we present different ansatzes that generate multi-dimensional
Fourier series and explore the scaling of the QML models performance with the
dimensions of the input data. To do it, we study the expressibility of the
multi-dimensional Fourier model, meaning the type of functions that the model
can generate. Hence, we expand the function fitting formalism to multi-
dimensional data, opening the possibility to explore more complex problems
with these quantum models.

######  Definition 2.

Multi-dimensional truncated Fourier series. The generalization of a one-
dimensional truncated Fourier series to $M$-dimensional data is given by

$f(\vec{x})=\sum_{\omega_{1},\omega_{2},...,\omega_{M}=-D}^{D}c_{\vec{\omega}}e^{i\vec{x}\cdot\vec{\omega}},$
(7)

where $D=\text{max}(\omega_{1},\omega_{2},...,\omega_{M})$ is the degree of
the Fourier series. The data
$\vec{x}=(x_{1},x_{2},...,x_{M})\in\mathbb{R}^{M}$ and the frequencies
$\vec{\omega}=(\omega_{1},\omega_{2},...,\omega_{M})\in\mathbb{Z}^{M}$ are
represented by $M-$dimensional vectors, and $\vec{x}\cdot\vec{\omega}$ is the
scalar product. The coefficients
$c_{\omega_{1},\omega_{1},...,\omega_{M}}\in\mathbb{C}$ fulfill the relation
$c_{\omega_{1},\omega_{1},...,\omega_{M}}=c_{-\omega_{1},-\omega_{1},...,-\omega_{M}}^{*}$.

The $M$-dimensional Fourier series contains substantially more coefficients
than a series with only one dimension. For a given degree $D\in\mathbb{N}$,
the number of independent coefficients $c_{\vec{\omega}}$ is

$N_{c}=\frac{(2D+1)^{M}-1}{2}+1.$ (8)

As an example, for degree $D=1$ and data-dimension $M=2$, according to Eq.
(8), we have $5$ coefficients: $c_{00},c_{01},c_{10},c_{11},c_{-11}$, while
the other ones are constrained by
$c_{\omega_{1}\omega_{2}}=c_{-\omega_{1}-\omega_{2}}^{*}$. The degrees of
freedom $\nu$ (abbreviated as d.o.f.) of the Fourier series are the number of
independent variables needed to fully characterize a set of coefficients of a
series with given degree $D$. They account for the real and imaginary parts of
each coefficient, except the one associated with the zero frequency, which
only contains a real part. Therefore, the d.o.f. of an $M$-dimensional Fourier
series are given by

$\nu\equiv 2N_{c}-1=\big{(}2D+1)^{M}.$ (9)

Depending on the circuit ansatz, the number of layers required to achieve
enough freedom to represent an arbitrary series will vary. In the following
subsection, we propose three strategies: the Line, Parallel, and Mixed Ansatz.
We assume that the processing gates are general unitary transformations in all
models. Hence, the number of parameters they contain is $N^{2}-1$, determined
by the dimension of SU$(N)$, with $N=d^{n}$ being the dimension of the quantum
circuit.

###  III.1 Line ansatz

The Line Ansatz (LA) encodes all data dimensions in a single qudit. The
structure of the model is shown in Fig. 3 (a). Each layer $L^{(l)}$ of the LA
encodes $M$ data features as

$L^{(l)}(\vec{x},\vec{\theta})_{\text{LA}}\equiv\prod_{m=1}^{M}S(x_{m})A_{m}^{(l)}(\vec{\theta}_{l,m}),$
(10)

where $M$ is the dimension of the data point, $x_{m}$ the data features and
$\vec{\theta}_{l,m}$ are the processing parameters corresponding to feature
$m$ from layer $l$. After the encoding step, the processing gate is applied to
avoid the collapse of the data in a single variable (see App. D for details).
The number of parameters to be optimized in the LA ansatz is given by

$N_{p}^{(LA)}=(ML+1)(N^{2}-1).$ (11)

As mentioned above, $N=d$ is the dimension of the circuit and the dimension of
the encoding gate $S(x)$. Thus, the parameters grow linearly with the number
of layers $L$ and the data dimension $M$, and quadratically with the circuit
dimension $N$.

Figure 3: Quantum circuit ansatzes of the models. The Line ansatz (a) encodes
each data feature in a single qudit. Thus the circuit depth grows linearly
with the total number of features $M$. The Parallel ansatz (b) encodes the $M$
features in $M$ qudits instead. Finally, the Mixed ansatz (c) combines the two
approaches by distributing the features encoding between $p<M$ qudits and uses
more gates to introduce several features in each layer. Figure 4: Comparison
of the degrees of freedom condition for a two-dimensional Fourier series for
the Line (first column) and Parallel (second column) ansatzes using qubits
(first row) and qutrits (second row). The dashed line indicates the degrees of
freedom $\nu$ of the Fourier series generated by the model in front of its
degree $D$. The solid line shows the number of trainable parameters $N_{p}$ in
the circuit ansatzes with $L=D/(d-1)$ layers that generates a Fourier series
of degree $D$. The Parallel Ansatz fulfils the degrees of freedom condition
for higher-degree Fourier series compared to the Line Ansatz, being the gap
wider when using qutrits. In particular, the condition for the Parallel Ansatz
is fulfilled until $D=3$ and $D=10$ for qubits and qutrits, respectively.

###  III.2 Parallel ansatz

The parallel ansatz (PA) encodes each data feature in a different qudit with a
single-qudit gate, therefore, we require $n=M$ qudits to encode all $M$ data
features. The encoding is followed by a processing $M-$qudit gate, as shown in
Fig. 3 (b). We define each layer as

$L^{(l)}(\vec{x},\vec{\theta})_{\text{PA}}\equiv\left(\bigotimes_{m=1}^{M}S(x_{m})\right)A^{(l)}(\vec{\theta_{l}}),$
(12)

where $A^{(l)}(\vec{\theta_{l}})$ is a $N\times N$ general processing unitary,
with $N=d^{M}$. This ansatz contains a total number of parameters

$N_{p}^{(PA)}=(d^{2M}-1)(L+1),$ (13)

which grows exponentially with the number of features $M$.

If single-qudit gates are used in the processing steps instead of general
multi-qudit gates, then a product of $M$ one-dimensional Fourier series is
generated. Therefore, entanglement must be included in the processing gates to
obtain a genuine multi-dimensional series (see App. E for more details).

###  III.3 Mixed ansatz

Finally, we consider a mix between the two ansatzes previously discussed,
named the Mixed Ansatz (MA). It divides the data features into different
batches and uses $p$ qudits for different sets (see Fig. 3 (c)). Taking $p\leq
M$ qudits, the data features are distributed in $p$ qudits, as in the PA, and
more encoding layers can be used for each qudit if required, as in the LA. For
$p=1$, MA behaves like LA, and for $p=M$ it behaves like PA. More formally, we
define a layer of the MA as

$L^{(l)}(\vec{x},\vec{\theta})_{\text{MA}}\equiv\prod_{k=1}^{\lceil
M/p\rceil}\left(\bigotimes_{m=1}^{p}S(x_{m})\right)A_{k}^{(l)}(\vec{\theta_{l,k}}),$
(14)

and the number of parameters in this model is given by

$N_{p}=(d^{2p}-1)(\lceil M/p\rceil L+1).$ (15)

If $M/p$ is not an integer, we use a fewer encoding gates on the layers’ last
encoding block.

Figure 5: Simulation the Line and Parallel ansatzes for fitting a Fourier
series of degree $D=2$. The target function in the trigonometric form is given
by $f(x_{1},x_{2})=-0.02+0.04\cos(2x_{1}+x_{2})+0.25\sin x_{1}-0.3\cos
2x_{2}-0.1\sin(x_{1}-x_{2})$. We use the Nelder-Mead method as a classical
optimization subroutine with $500$ training and $1500$ testing data points. In
the Line ansatz, we use one qubit and $L=2$. The accuracy obtained is
$38.53\%$ and, as we can see, the model does not capture the structure of the
target function. In the Parallel ansatz, we use two qubits and $L=2$. The
accuracy obtained is $95.63\%$, and the predicted and target functions have a
similar structure. In this regime, the Line ansatz model does not fulfil the
d.o.f. condition, while the Parallel does. This is reflected in the accuracy
of the simulations.

###  III.4 Comparison

To compare the models, we assume that all use singe-qudit encoding gates,
although its extension to multi-qudit gates is straightforward (equivalent to
finding an information unit of dimension $\bar{d}=d^{n}$). The degree of the
Fourier series generated by all ansatzes becomes

$D=(d-1)L,$ (16)

where $d$ is the dimension of the qudit used in the model, regardless of how
many of them we use. For the derivation and more details of the ansatzes, see
App. D, E, and F. By establishing the dimension of the qudit $d$ and the
number of layers $L$, we fix the Fourier series frequency spectrum $\Omega$
and their degree $D$. Once this is fixed, we know how many coefficients
$N_{c}$ we require to characterize a general Fourier series, which at the same
time give us the d.o.f. of the output series. Then, we study if we can fully
characterize the Fourier series coefficients by comparing the d.o.f. $\nu$
with the number of independent parameters $N_{p}$ in the quantum circuit. The
ansatz is required to contain, at least, $\nu$ free parameters to generate any
series coefficient, resulting in a condition $N_{p}\geq\nu$. When this
condition is not accomplished, the model is not general enough to approximate
multi-dimensional Fourier series with an arbitrarily large degree. However,
having $\nu>N_{p}$ does not necessarily guarantee that we can fit a general
series since the coefficient equations are highly coupled and non-linear (Eq.
(4)), although one might expect that, in general, $\nu>N_{p}$ is enough to
approximate a given series. Our goal is to establish a lower bound in the
worst-case scenario in terms of the circuit ansatz requirements to fit a
general multi-dimensional Fourier series.

The one-dimensional feature model is the reduction of all three ansatzes with
one-feature data and one qudit. In this model, the d.o.f. are
$\nu=2(D+1)=2(L(d-1)+1)$, and the number of free parameters
$N_{p}=(L+1)(d^{2}-1)$. Both quantities grow linearly with the number of
layers, and $N_{p}>N_{c}$ $\forall L$ and $\forall d$, meaning that we fulfill
the d.o.f. requirements in all cases. For $M-$dimensional data models, the
d.o.f. grow polynomialy with the number of layers, $\nu\sim L^{M}$, while the
number of parameters grows proportionally to the layers used $N_{p}\sim L$,
regardless of the data dimension. Therefore, at some point, the d.o.f. will
exceed the number of free parameters of the model. Consequently, the models
are not general enough for fitting multi-dimensional Fourier series with
arbitrarily large degree. With that thought, we study to what degree the
series can be fitted and how that relies on the prefactors in $N_{p}$, which
further depend on $M$ and $d$.

In Fig. 4, we compare the Line and Parallel model with two-dimensional data
for qubit and qutrit circuit ansatzes. With the LA, we accomplish this
requirement up to a series of degree $D=d-1$. On the other hand, the PA with
the qubit and qutrit model fulfills the condition up to degree $D=3$ and
$D=10$, respectively.

To sum up, the problem is that we do not have enough free parametrization in
the Hilbert space of the PQC to accomplish the d.o.f. that multi-dimensional
Fourier series require. One may think that the problem can be solved by using
more layers, which introduce more trainable parameters to fit the desired set
of coefficients. However, introducing more layers also increases the degree
$D$ of the output Fourier series. This function now contains more
coefficients, which increase the d.o.f. needed to fit it properly. Therefore,
using more layers does not solve the problem because the required d.o.f. grow
faster than the parameters in the model when we increase the number of layers.

Fig. 5 depicts the results of simulation for models fitting a two-dimensional
Fourier series of degree $D=2$ with the Line and Parallel ansatzes. Since for
the two-dimensional data the LA does not accomplish the d.o.f. condition, the
simulation does not find suitable parameters to fit the coefficients. On the
contrary, the parallel model approximates with high accuracy the target
function with only two layers, because meets the d.o.f. requirements. For more
details on two and three dimensional models see Ref. [22]. They discuss the
effect of different quantum circuit elements on the expressibility of the
considered QML models, also finding that more parametrization leads to more
expressive models.

Taking a circuit ansatz of higher dimension $N=d^{n}$ could be more convenient
since there are more combinations of the multi-indices of the trainable gates
(which run from $1$ to $N$) that give rise to the same frequency. Therefore,
the coefficient of the series has more contributions of the different multi-
indices (see App. B for more details). Besides this, in all models, the use of
higher-dimensional systems provides a larger parametrizable Hilbert space
(growth in $N_{p}$) and the capacity to generate a higher degree Fourier
series $D$ with the same number of layers. Therefore, using higher-dimensional
qudits is a potential solution to overcome resource demands.

##  IV Beyond Fourier Series

The previous sections’ encoding strategy relies on using the same encoding
gate, $S(x)$, for all data features. In this section, we explore an encoding
with non-commuting gates for each feature, meaning $[S_{1}(x),S_{2}(x)]\neq
0$. For example, in the two-dimensional qubit case we could use
$S_{1}(x_{1})=R_{y}(x_{1})$ and $S_{2}(x_{2})=R_{z}(x_{1})$. Since $S_{1}$ and
$S_{2}$ do not commute, the single value decomposition of the encoding gate is
given by

$S_{1}(x_{1})S_{2}(x_{2})=V^{\dagger}(x_{1},x_{2})\Sigma V(x_{1},x_{2}).$ (17)

In contrast to the decomposition obtained with a diagonal encoding, the
eigenstates of the encoding gates depend on the data. When the trainable gates
absorb $V(\vec{x})$ and $V^{\dagger}(\vec{x})$, they add a data dependency
$\vec{x}$ in the coefficients of the series
$c_{\vec{\omega}}=c_{\vec{\omega}}(\vec{x})$, which alters the natural
structure of the Fourier series, obtaining a function of the form

$\langle\mathcal{M}(\vec{x})\rangle=\sum_{\vec{\omega}=-D}^{D}c_{\vec{\omega}}(\vec{x})\hskip
2.84544pte^{i\vec{x}\cdot\vec{w}},$ (18)

where $\vec{\omega}$ is a $M-$dimensional vector containing the frequencies of
each dimension. Consequently, this type of encoding does not lead to a Fourier
series. This strategy is used in several works [2, 23] for problems such as
classification (with high accuracy results). Consequently, quantum neural
networks with data re-uploading structures do not always generate Fourier
series. The output model is strongly related to the encoding circuit ansatz we
use, which opens the possibility of finding more sophisticated encoding
strategies for higher-dimensional data sets that exploit other types of
correlations while being efficient in terms of free parameters and circuit
depth.

##  V Conclusions

In this work, we have explored how to generate multi-dimensional Fourier
series with parameterized quantum circuits. These series emerge naturally from
the expectation values of quantum operators with a particular data encoding.
The family of $M-$dimensional Fourier series of degree $D$ is determined by
the number of layers used and the dimension of the qudits in the circuit. The
elements of the trainable gates define the Fourier coefficients. We have
compared the degrees of freedom of a general Fourier series of a given degree
with the number of free parameters in the circuit, which we define as the
d.o.f. condition.

For one-dimensional data, the d.o.f. requirement is always accomplished. For
high-dimensional data, the d.o.f. grow faster than the number of free
parameters available in the models. Therefore, the models need to be revised
to fit general multi-dimensional functions. Besides this, with multi-qudit
models, we can approximate functions of a higher degree, which can be used as
a suitable approximation for some problems.

Current quantum computers can use higher energy states to perform high-
dimensional quantum computation. Besides this, the use of a general formalism
for qudits is motivated by the possibility of exploring larger Hilbert spaces
(with more extensive parametrization), which gives more freedom when fitting
the desired set of coefficients.

Besides extending a well-known QML formalism to multi-dimensional datasets,
this work aims to establish a trade-off between the number of qudits, circuit
depth (measured with the number of layers of the circuit), data dimension, and
local qudit dimension. The minimum number of parameters needed to characterize
the multi-variable functions grows exponentially with the data dimensions,
resulting in poor scaling. Other methods, such as using non-commuting gates to
embed the data features, should be explored, although some may depart from the
Fourier series formalism. We hope this work contributes to the effort of
understanding QML with classical multi-dimensional data and to the further
exploration of more sophisticated embedding strategies.

## Code and data availability

All code used in this work can be found on the GitHub repository
https://github.com/bsc-quantic/fourier.

## Acknowledgements

This work has been financially supported by the Ministry of Economic Affairs
and Digital Transformation of the Spanish Government through the QUANTUM ENIA
project call – Quantum Spain project, and by the European Union through the
Recovery, Transformation and Resilience Plan – NextGenerationEU within the
framework of the Digital Spain 2026 Agenda. Also, we acknowledge the BSC’s
Quantic group members for the suggestions and discussions provided.

## References

  * Biamonte  _et al._ [2017] J. Biamonte, P. Wittek, N. Pancotti, P. Rebentrost, N. Wiebe, and S. Lloyd, Quantum machine learning, Nature 549, 195 (2017).
  * Pérez-Salinas  _et al._ [2020] A. Pérez-Salinas, A. Cervera-Lierta, E. Gil-Fuster, and J. I. Latorre, Data re-uploading for a universal quantum classifier, Quantum 4, 226 (2020).
  * Lloyd  _et al._ [2020] S. Lloyd, M. Schuld, A. Ijaz, J. Izaac, and N. Killoran, Quantum embeddings for machine learning, arXiv 10.48550/ARXIV.2001.03622 (2020).
  * Goto  _et al._ [2021] T. Goto, Q. H. Tran, and K. Nakajima, Universal approximation property of quantum machine learning models in quantum-enhanced feature spaces, Physical Review Letters 127, 10.1103/physrevlett.127.090506 (2021).
  * Vidal and Theis [2020] F. J. G. Vidal and D. O. Theis, Input redundancy for parameterized quantum circuits, Frontiers in Physics 8, 10.3389/fphy.2020.00297 (2020).
  * Schuld  _et al._ [2021] M. Schuld, R. Sweke, and J. J. Meyer, Effect of data encoding on the expressive power of variational quantum-machine-learning models, Physical Review A 103, 10.1103/physreva.103.032430 (2021).
  * Heimann  _et al._ [2022] D. Heimann, G. Schönhoff, and F. Kirchner, Learning capability of parametrized quantum circuits, arXiv 10.48550/ARXIV.2209.10345 (2022).
  * Shin  _et al._ [2023] S. Shin, Y. S. Teo, and H. Jeong, Exponential data encoding for quantum supervised learning, Physical Review A 107, 10.1103/physreva.107.012422 (2023).
  * Daskin [2022] A. Daskin, A walk through of time series analysis on quantum computers, arXiv 10.48550/ARXIV.2205.00986 (2022).
  * Yu  _et al._ [2022] Z. Yu, H. Yao, M. Li, and X. Wang, Power and limitations of single-qubit native quantum neural networks, arXiv 10.48550/ARXIV.2205.07848 (2022).
  * Woźniak  _et al._ [2023] K. A. Woźniak, V. Belis, E. Puljak, P. Barkoutsos, G. Dissertori, and et. al., Quantum anomaly detection in the latent space of proton collision events at the lhc (2023).
  * Preskill [2018] J. Preskill, Quantum Computing in the NISQ era and beyond, Quantum 2, 79 (2018).
  * Bharti  _et al._ [2022] K. Bharti, A. Cervera-Lierta, T. H. Kyaw, T. Haug, S. Alperin-Lea, and et al. , Noisy intermediate-scale quantum algorithms, Reviews of Modern Physics 94, 10.1103/revmodphys.94.015004 (2022).
  * Cerezo  _et al._ [2021] M. Cerezo, A. Arrasmith, R. Babbush, S. C. Benjamin, S. Endo, and et al., Variational quantum algorithms, Nature Reviews Physics 3, 625 (2021).
  * Blok  _et al._ [2021] M. Blok, V. Ramasesh, T. Schuster, K. O’Brien, J. Kreikebaum, and et. al., Quantum information scrambling on a superconducting qutrit processor, Physical Review X 11, 10.1103/physrevx.11.021010 (2021).
  * Cervera-Lierta  _et al._ [2022] A. Cervera-Lierta, M. Krenn, A. Aspuru-Guzik, and A. Galda, Experimental high-dimensional Greenberger-Horne-Zeilinger entanglement with superconducting transmon qutrits, Physical Review Applied 17, 10.1103/physrevapplied.17.024062 (2022).
  * Erhard  _et al._ [2020] M. Erhard, M. Krenn, and A. Zeilinger, Advances in high-dimensional quantum entanglement, Nature Reviews Physics 2, 365 (2020).
  * Castro  _et al._ [2022] A. Castro, A. G. Carrizo, S. Roca, D. Zueco, and F. Luis, Optimal control of molecular spin qudits, Physical Review Applied 17, 10.1103/physrevapplied.17.064028 (2022).
  * Jenkins  _et al._ [2017] M. D. Jenkins, Y. Duan, B. Diosdado, J. J. García-Ripoll, A. Gaita-Ariño, and et al., Coherent manipulation of three-qubit states in a molecular single-ion magnet, Phys. Rev. B 95, 064423 (2017).
  * Caves and Milburn [2000] C. M. Caves and G. J. Milburn, Qutrit entanglement, Optics Communications 179, 439 (2000).
  * Pérez-Salinas  _et al._ [2021] A. Pérez-Salinas, D. López-Núñez, A. García-Sáez, P. Forn-Díaz, and J. I. Latorre, One qubit as a universal approximant, Physical Review A 104, 10.1103/physreva.104.012405 (2021).
  * Gratsea and Huembeli [2022] A. Gratsea and P. Huembeli, The effect of the processing and measurement operators on the expressive power of quantum models, arXiv 10.48550/ARXIV.2211.03101 (2022).
  * Easom-Mccaldin  _et al._ [2021] P. Easom-Mccaldin, A. Bouridane, A. Belatreche, and R. Jiang, On depth, robustness and performance using the data re-uploading single-qubit classifier, IEEE Access 9, 65127 (2021).

##  Appendix A Data re-uploading for one-dimensional Fourier series

This section explains how we generate one-dimensional Fourier series with a
circuit of $n$ qudits of dimension $d$. For processing gate a general unitary
is taken, of total dimension $N=d^{n}$ ($n$ qudits of dimension $d$):

$A^{(l)}=\left(\begin{array}[]{ccc}A_{11}^{(l)}&\cdots&A_{1N}^{(l)}\\\
\vdots&\ddots&\vdots\\\ A_{N1}^{(l)}&\cdots&A_{NN}^{(l)}\end{array}\right).$
(19)

In contrast to the processing, the encoding gates are the same in all layers.
Let’s assume the following single-qudit encoding gate:

$S(x)=e^{ixH},$ (20)

where $H$ is a $N\times N$ Hermitian operator and $x$ is a one-dimensional
data point from the function we want to represent. We assume that the encoding
Hamiltonian $H$ is diagonal because, when taking the Singular Value
Decomposition, $H=V^{\dagger}\Sigma V$, where $V$ and $V^{\dagger}$ are
unitary matrices and $\Sigma$ is a diagonal matrix formed with the eigenvalues
of $H$, the encoding gate becomes

$S(x)=e^{-ixV\Sigma V^{\dagger}}=\sum_{m=0}^{\infty}\frac{1}{m!}(-ixV\Sigma
V^{\dagger})^{m}=1+\sum_{m=1}^{\infty}\frac{1}{m!}V(-ix\Sigma)^{m}V^{\dagger}=Ve^{-ix\Sigma}V^{\dagger}=VR(x)V^{\dagger}.$
(21)

where we take into consideration that $V^{\dagger}V=\mathbb{I}$ and
$\Sigma=\text{diag}(\lambda_{1},...,\lambda_{N})$. The resulting diagonal
encoding gate is

$R(x)=\text{diag}\left(e^{ix\lambda_{1}},\cdots,e^{ix\lambda_{N}}\right).$
(22)

Therefore, we assume, without loss of generality, a diagonal encoding matrix,
since $V$ and $V^{\dagger}$ gates are re-absorbed in the definition of the
general processing gates $A^{(l)}$. With this assumption, each layer $l$ is
composed of the product

$L^{(l)}=A^{(l)}R(x)\qquad L^{(0)}=A^{(0)},$ (23)

which matrix elements are

$L_{ij}^{(l)}=\sum_{k=1}^{N}A_{ik}^{(l)}R_{kj}=A_{ij}^{(l)}e^{ix\lambda_{j}},\qquad
L_{ij}^{(0)}=A_{ij}^{(0)}.$ (24)

In general, for $L$ layers, the unitary transformation of the whole circuit is
expressed as

$U_{ij}=\sum_{k_{1},\cdots,k_{L}=1}^{N}A^{(L)}_{ik_{L}}e^{-ix\lambda_{k_{L}}}A^{(L-1)}_{k_{L}k_{L-1}}...A^{(1)}_{k_{2}k_{1}}e^{-ix\lambda_{k_{1}}}A^{(0)}_{k_{1}k_{0}}.$
(25)

The initial state of the circuit is the zero state of dimension $N$. Therefore
$|0\rangle=(1,0,\cdots,0)^{T}$. Thus, the state generated by the circuit
becomes:

$\displaystyle|\psi\rangle$ $\displaystyle=$ $\displaystyle
U|0\rangle^{\otimes n}$ (26) $\displaystyle\psi_{i}$ $\displaystyle=$
$\displaystyle U_{ij}\delta_{j1}=U_{i1}.$ (27)

Putting it all together, we obtain

$\begin{split}\psi_{i}=\sum_{k_{1},\cdots,k_{L}=1}^{N}e^{-ix(\lambda_{k_{1}}+...+\lambda_{k_{L}})}A^{(L)}_{ik_{L}}A^{(L-1)}_{k_{L}k_{L-1}}...A^{(1)}_{k_{2}k_{1}}A^{(0)}_{k_{1}1},\end{split}$
(28)

By introducing the multi-index notation
$\textbf{k}\equiv\\{k_{1},...,k_{L}\\}\in[N]^{L}$ and the multi-index sum
$\Lambda_{\textbf{k}}=\lambda_{k_{1}}+...+\lambda_{k_{L}}$,we re-express the
$i$-vector state:

$\psi_{i}=\sum_{\textbf{k}\in[N]^{L}}e^{-ix\Lambda_{k}}A^{(L)}_{ik_{L}}A^{(L-1)}_{k_{L}k_{L-1}}...A^{(1)}_{k_{2}k_{1}}A^{(0)}_{k_{1}1}.$
(29)

Each multi-index k is a possible combination of $L$ indices and each run from
$1$ to $N$. The multi-index sum
$\Lambda_{\textbf{k}}=\lambda_{k_{1}}+...+\lambda_{k_{L}}$ is a sum that has
$|\textbf{k}|=N^{L}$ possible values, given by all the possible combinations
of $\lambda_{k_{i}}$.

Now we compute the expectation value of a given observable $\mathcal{M}$ in
this state. The observable can be diagonal by the same argument used for the
encoding gate $S(x)$, explained above. The eigenvalues of any observable are
real, so $\mathcal{M}_{ii}^{*}=\mathcal{M}_{ii}\equiv\mathcal{M}_{i}$. All
together,

$\langle\mathcal{M}\rangle=\langle\psi|\mathcal{M}|\psi\rangle=\sum_{i=1}^{N}U_{i1}^{*}M_{i}U_{i1}=\sum_{\begin{subarray}{c}k_{1},\cdots,k_{L}=1\\\
k^{\prime}_{1},\cdots,k^{\prime}_{L}=1\end{subarray}}^{N}e^{ix\left(\Lambda_{\mathbf{k}}-\Lambda_{\mathbf{k^{\prime}}}\right)}\
\left(\sum_{i=1}^{N}M_{i}A_{ik_{L}}^{(L)}A_{ik^{\prime}_{L}}^{*(L)}\right)A_{k_{1}1}^{(0)}A_{k^{\prime}_{1}1}^{*(0)}\prod_{p=2}^{L}A_{k_{p}k_{p-1}}^{(p-1)}A_{k^{\prime}_{p}k^{\prime}_{p-1}}^{*(p-1)}.$
(30)

For each set of $\mathbf{k}$ and $\mathbf{k^{\prime}}$ parameters, we generate
a particular frequency
$\Omega_{kk^{\prime}}=\Lambda_{\mathbf{k}}-\Lambda_{\mathbf{k^{\prime}}}$.
Notice that different $\mathbf{k,k^{\prime}}$ choices can give the same
frequency. Also, to obtain the opposite sign value $-\Omega_{kk^{\prime}}$,
one needs to exchange the $\mathbf{k}$ and $\mathbf{k^{\prime}}$ indices.
Therefore, we can group the coefficients that generate the same frequencies
from the above expression:

$\langle\mathcal{M}\rangle=\sum_{\omega\geq
0}\sum_{\begin{subarray}{c}\mathbf{k,k^{\prime}}=1\\\
\Omega_{kk^{\prime}}=\omega\end{subarray}}^{N}e^{ix\omega}\
\left(\sum_{i=1}^{N}M_{i}A_{ik_{L}}^{(L)}A_{ik^{\prime}_{L}}^{*(L)}\right)A_{k_{1}1}^{(0)}A_{k^{\prime}_{1}1}^{*(0)}\prod_{p=2}^{L}A_{k_{p}k_{p-1}}^{(p-1)}A_{k^{\prime}_{p}k^{\prime}_{p-1}}^{*(p-1)}\\\
+e^{-ix\omega}\
\left(\sum_{i=1}^{N}M_{i}A_{ik^{\prime}_{L}}^{(L)}A_{ik_{L}}^{*(L)}\right)A_{k^{\prime}_{1}1}^{(0)}A_{k_{1}1}^{*(0)}\prod_{p=2}^{L}A_{k^{\prime}_{p}k^{\prime}_{p-1}}^{(p-1)}A_{k_{p}k_{p-1}}^{*(p-1)}.$
(31)

Thus, we generate a Fourier series with coefficients

$c_{\omega}=\sum_{\begin{subarray}{c}\mathbf{k,k^{\prime}}=1\\\
\Omega_{kk^{\prime}}=\omega\end{subarray}}^{N}\left(\sum_{i=1}^{N}M_{i}A_{ik_{L}}^{(L)}A_{ik^{\prime}_{L}}^{*(L)}\right)A_{k_{1}1}^{(0)}A_{k^{\prime}_{1}1}^{*(0)}\prod_{p=2}^{L}A_{k_{p}k_{p-1}}^{(p-1)}A_{k^{\prime}_{p}k^{\prime}_{p-1}}^{*(p-1)},$
(32)

and $c_{-\omega}=c_{\omega}^{*}$, with a frequency spectrum

$\Omega_{\textbf{kk'}}=\\{\Lambda_{\textbf{k}}-\Lambda_{\textbf{k'}}\\}=\\{(\lambda_{k_{1}}+\cdots+\lambda_{k_{L}})-(\lambda_{k^{\prime}_{1}}+\cdots+\lambda_{k^{\prime}_{L}})\\}.$
(33)

Notice that the frequency spectrum is directly related to the eigenvalues of
the encoding Hamiltonian, while the coefficients depend on the elements of the
trainable parameters.

##  Appendix B Matrix elements combinations to generate Fourier coefficients

All the terms that constitute a given coefficient with associated frequency
$\omega$ have in common that
$\Lambda_{\textbf{k}}-\Lambda_{\textbf{k'}}=\omega$ (see Eq. (32)). In this
appendix, we explore how many combinations of the multi-indices k, k’ give us
the same frequency $\omega$, what we call the number of contributions to the
coefficient ($s_{\omega}$). In some occasions, this is also called the
degeneracy of the frequency. Having more terms that contribute to the same
coefficient may be beneficial since we can have more parameters yielding the
same coefficient. The number of contributions does not affect the discussion
about the degrees of freedom.

The frequencies are generated according to Eq. (33). For one qudit model and
with the “spin-like” encoding discussed in Sec. II, the frequencies are
generated by subtracting $L$ eigenvalues to $L$ eigenvalues, and each of them
can take $N$ values. In total we have $|\omega|=N^{2L}$ possible eigenvalues
combinations. However, some subtraction results with the same frequency
$\omega$. The number of combinations that gives rise to the same frequency is
given by

$s_{\omega}=\binom{2L}{L-\omega}_{N-1}.$ (34)

As expected, the number of combinations depends on the number of layers, the
frequency considered and the dimension of the model. The symmetry in the
generation of the frequencies is reflected by $s_{\omega}=s_{-\omega}$. The
sum of all combinations gives back $|\omega|$, the eigenvalues combinations.
$\sum_{\omega\in\Omega}s_{\omega}=d^{2L}=|\omega|$. For qubits ($N=2$), the
distribution of combinations becomes a binomial distribution:

$s_{\omega}^{N=2}=\binom{2L}{L-\omega}_{1}=\frac{2L!}{(L-\omega)!(L+\omega)!}.$
(35)

For qutrits ($N=3$), we have a trinomial distribution:

$s_{\omega}^{N=3}=\binom{2L}{\omega}_{2}=\sum_{\begin{subarray}{c}0\leq\mu,\nu\leq
2L\\\ \mu+2\nu=2L+\omega\end{subarray}}\frac{2L!}{\mu!\nu!(2L-\mu-\nu)!}.$
(36)

For ququarts, a quadrinomial distribution, etc. By using higher-dimensional
systems, the number of total combinations grows exponentially with the number
of layers used.

For example, let us consider a model with one qubit and $L=2$. The frequency
spectrum is given by
$\Omega=\\{\lambda_{k_{1}}+\lambda_{k_{2}}-(\lambda_{k^{\prime}_{1}}+\lambda_{k^{\prime}_{2}})\\}$.
The eigenvalues are $\lambda_{k_{i}}=\pm 1/2$ and we can combine them in
$|\omega|=d^{2L}=2^{4}=16$ ways to obtain one of the frequencies
$\Omega=\\{-2,-1,0,1,2\\}$. In Tab. 1, we show the distribution of
combinations to obtain these frequencies. As we can see, it fulfils
$s_{-2}+s_{-1}+s_{0}+s_{1}+s_{2}=16$.

$\omega=0$ | $\omega=1$ | $\omega=2$ |
---|---|---|---
$\frac{1}{2}+\frac{1}{2}-\bigg{(}\frac{1}{2}+\frac{1}{2}\bigg{)}$ | $\frac{1}{2}+\frac{1}{2}-\bigg{(}-\frac{1}{2}+\frac{1}{2}\bigg{)}$ | $\frac{1}{2}+\frac{1}{2}-\bigg{(}-\frac{1}{2}-\frac{1}{2}\bigg{)}$ |
$\frac{1}{2}-\frac{1}{2}-\bigg{(}\frac{1}{2}-\frac{1}{2}\bigg{)}$ | $\frac{1}{2}+\frac{1}{2}-\bigg{(}+\frac{1}{2}-\frac{1}{2}\bigg{)}$ |  |
$\frac{1}{2}-\frac{1}{2}-\bigg{(}-\frac{1}{2}+\frac{1}{2}\bigg{)}$ | $\frac{1}{2}-\frac{1}{2}-\bigg{(}-\frac{1}{2}-\frac{1}{2}\bigg{)}$ |  |
$-\frac{1}{2}+\frac{1}{2}-\bigg{(}-\frac{1}{2}+\frac{1}{2}\bigg{)}$ | $-\frac{1}{2}+\frac{1}{2}-\bigg{(}-\frac{1}{2}-\frac{1}{2}\bigg{)}$ |  |
$-\frac{1}{2}+\frac{1}{2}-\bigg{(}+\frac{1}{2}-\frac{1}{2}\bigg{)}$ |  |  |
$-\frac{1}{2}-\frac{1}{2}-\bigg{(}-\frac{1}{2}-\frac{1}{2}\bigg{)}$ |  |  |
$\boldsymbol{s_{0}=6}$ | $\boldsymbol{s_{1}=4}$ | $\boldsymbol{s_{2}=1}$ |
Table 1: Example of the number of combinations of the positive frequencies in
the single-qubit model with $2$ layers and encoding gate $S(x)=e^{ixH}$ with
$H=\sigma_{z}/2$. The combinations of the negative frequencies are obtained by
swapping the eigenvalues, giving rise to the same combination value
($s_{\omega}=s_{-\omega}$).

We can easily generalize this for the $M-$dimensional models. The discussion
is valid for the Line, Parallel, and Mixed ansatz. We have coefficients
associated with $M$ frequencies in such models:
$c_{\omega_{1},...,\omega_{M}}$. Hence, the possible combinations of the
coefficients depend on the combinations of every single frequency
$\omega_{i}$,

$s_{\vec{\omega}}=s_{\omega_{1}}s_{\omega_{2}}...s_{\omega_{M}},$ (37)

where $s_{\omega_{i}}$ with $i\in\\{1,...,M\\}$ is the degeneracy of the one-
dimensional model given in Eq. (34). The more terms are contributing to the
sum of a coefficient, the more likely is to exist more than one set of
parameters that contributes to the same coefficient.

##  Appendix C Re-scaling factor

In this section, we discuss why it is relevant to introduce a re-scaling
factor in quantum methods for function fitting, which can be extended to other
methods. For simplicity, we first discuss the re-scaling strategy for the one-
dimensional case and then generalize it to the multi-dimensional model.

The non-negative frequency spectrum generated by the one-qudit models with the
“spin-like” encoding (without the re-scaling factor) is given by

$\Omega=\\{(d-1)L,(d-1)L-1,...,0\\}.$ (38)

Suppose we want to fit a $M-$dimensional function that can be approximated
with a Fourier series of degree $D^{\prime}$. We fit the function with at
least $L=D^{\prime}/(d-1)$ layers, under the condition of the degrees of
freedom (see section III). Nevertheless, we can find cases in which there is
no number of layers such that $D^{\prime}=(d-1)L$. For instance, with the
“spin-like” encoding, we generate integer frequencies without the possibility
of generating semi-integer or float frequencies, regardless of the number of
layers used. If the target function contains a non-integer frequency, the
model cannot generate the proper functions and the model’s training fails. We
overcome this inconvenience by introducing a re-scaling $\eta$.

Let’s study the case of fitting a function
$f(x)=0.2(1+\cos{\frac{x}{2}}+\sin{\frac{x}{2}}+\cos{x}+\sin{x})$, which is
decomposed in a Fourier series with frequencies $\Omega^{\prime}=\\{0,\pm
1/2,\pm 1\\}$. With one layer, the qubit model generates the frequency
$\omega=0$ and $\omega=\pm 1$, but it cannot generate the semi-integer ones.
Consequently, it fails to fit this function. A solution to avoid this is
introducing a re-scaling factor $\eta$ in the Hamiltonian $H$ of the encoding
gates, such that $S(x)=e^{ix\eta H}=e^{ixH^{\prime}}$. Now, all the
eigenvalues of the Hamiltonian become $\eta\lambda_{i}$, leading us to a
different frequency spectrum

$\Omega_{\eta}=\eta\Omega.$ (39)

The re-scaling factor $\eta$ is optimized by the classical subroutine and all
the other trainable parameters. In the example considered, the optimization
subroutine ideally finds $\eta=\pm\frac{1}{2}$. With this, we change the
eigenvalues of the encoding Hamiltonian to $\lambda^{\prime}=\\{-1/4,1/4\\}$.
Consequently, the frequency spectrum becomes $\Omega_{\eta=1/2}=\\{\pm
L/2,\pm(L-1)/2,...,0\\}$. With two layers, we have the desired frequencies
present in the target function. A simulation with this example is shown in
Fig. 6.

Figure 6: Simulations of a one-dimensional Fourier serie with one qubit and
two layers. The target function is
$f(x)=0.2(1+\cos{\frac{x}{2}}+\sin{\frac{x}{2}}+\cos{x}+\sin{x})$ and the
trainable gates are
$A^{(i)}(\vec{\theta}_{i})=R_{y}(\theta^{(1)}_{i})R_{z}(\theta^{(2)}_{i})$ in
both cases. The solid line is the target function, while the dots correspond
to the output of different quantum models. The blue dots use an encoding gate
$R_{z}(x)$ and the orange ones use $R_{z}(\eta x)$, where $\eta$ is the re-
scaling factor. The optimization subroutine finds $\eta\simeq\frac{1}{2}$.

To have a more flexible model in terms of the frequencies, one can introduce
different re-scaling parameters in all $L$ processing gates to be optimized
together with the rest of the model’s parameters (see Ref.[2] for a similar
proposal for classification problems). By doing this, we can match the target
function frequencies with more freedom. The accessible frequencies for the
model become

$\Omega_{\vec{\eta}}=\\{\eta_{1}(\lambda_{k_{1}}-\lambda_{k^{\prime}_{1}})+...+\eta_{L}(\lambda_{k_{L}}-\lambda_{k^{\prime}_{L}})\\}.$
(40)

The Fourier series now has non-equispaced and real frequencies that can
capture better the target function structure. We obtain any desired frequency
present in the target with enough layers by optimizing the right parameters.

The re-scaling proposal can be easily generalized to $M-$dimensional models by
introducing more re-scaling parameters: $S(\vec{\eta}\cdot\vec{x})$, where
$\vec{\eta}=(\eta_{1},\eta_{2},...,\eta_{M})$ and
$\vec{x}=(x_{1},x_{2},...,x_{M})$ are $M-$dimensional vectors. In this way, we
modify the frequency associated with each dimension.

This method requires a small amount of classical pre-processing. Instead of
generating a unitary transformation with parameter $\theta=x$, we have to
generate a $\theta=\eta_{i}x$ transformation. In exchange for this, we obtain
flexibility to fit functions with unknown frequencies.

##  Appendix D Fourier series with the Line Ansatz

In this appendix, we explore the Line Ansatz (LA) for a qudit of arbitrary
dimension $d$. We show the exact form of the parameterized states after the
quantum circuit and the expectation value of an observable in this state (the
output of the quantum model). We also include a slight variation of the LA
that does not contain the processing gates between each data dimension. We
show why this formalism does not fit multi-dimensional functions in general.

We study the state after the quantum circuit of the LA model (see Fig. 3 (a)
for the quantum circuit). We consider the “spin-like” encoding discussed in
the main article for all data features, having the same frequency spectrum in
all dimensions. The quantum state is given by

$\psi_{i}=\sum_{\begin{subarray}{c}j_{1},..,j_{L}\\\ k_{1},..,k_{L}\\\
t_{1},...,t_{L}\\\
\vdots\end{subarray}}^{d}A^{(L)}_{M_{it_{L}}}e^{ix_{M}\lambda{t_{L}}}...A^{(L)}_{1_{k_{L}j_{L}}}e^{ix_{1}\lambda{j_{L}}}...A^{(1)}_{M_{j_{2}t_{1}}}e^{ix_{M}\lambda{t_{1}}}...A^{(1)}_{1_{k_{1}j_{1}}}e^{ix_{1}\lambda{j_{1}}}A^{(0)}_{j_{1}1},$
(41)

where $\lambda_{j_{i}}$ are the eigenvalues of the single-qudit encoding
Hamiltonian $H$, with $i\in\\{1,\cdots,d\\}$. In the symbol for a trainable
gate $A^{(l)}_{m_{i,j}}$, $l$ indicates the layer, $m$ the position of the
gate in the layer, and $i,j$ are the indices of the matrices. Note that each
eigenvalue on the exponentials, introduced by the encoding gates $S(x_{i})$,
has a different index. This is crucial for having a non-related dependency in
each dimension and it occurs because of the intermediate trainable gates
between each encoding gate. For the sake of simplicity, from now on, we assume
that the $M$ processing gates of any layer $l$ have the same structure but
taking into consideration that they have different parameters:
$A_{1}^{(l)}\sim A_{2}^{(l)}\sim...\sim A_{M}^{(l)}\equiv A^{(l)}$. With the
multi-index notation $\textbf{j}=\\{j_{1},j_{2},...,j_{L}\\}$ and re-grouping
terms we write

$\psi_{i}=\sum_{\textbf{j},\textbf{k},...\textbf{t}}^{d}e^{ix_{1}(\lambda_{j_{L}}+...+\lambda_{j_{1}})}...e^{ix_{M}(\lambda_{t_{L}}+...+\lambda_{t_{1}})}A^{(L)}_{{it_{L}}}...A^{(L)}_{{k_{L}j_{L}}}..A^{(1)}_{{j_{2}t_{1}}}...A^{(1)}_{{k_{1}j_{1}}}A^{(0)}_{j_{1}1}.$
(42)

Finally, we define the multi-index sum:
$\Lambda_{\textbf{j}}=\lambda_{j_{1}}+\lambda_{j_{2}}+...+\lambda_{j_{L}}$,
simplifying the previous expression

$\psi_{i}=\sum_{\textbf{j},\textbf{k},...\textbf{t}}^{d}e^{i(x_{1}\Lambda_{\textbf{j}}+...+x_{M}\Lambda_{\textbf{t}})}A^{(L)}_{{it_{L}}}...A^{(L)}_{{k_{L}j_{L}}}..A^{(1)}_{{j_{2}t_{1}}}...A^{(1)}_{{k_{1}j_{1}}}A^{(0)}_{j_{1}1}.$
(43)

After this, we compute the expectation value of the observable $\mathcal{M}$.
Without loss of generality, we assume that
$\mathcal{M}_{ij}=\mathcal{M}_{ii}=\mathcal{M}_{i}$

$\begin{split}\langle\mathcal{M}\rangle=\sum_{\begin{subarray}{c}\textbf{j,
j'},...\textbf{t, t'}\in[N]^{L}\\\
\omega_{1}=\omega_{1}^{\prime},...,\omega_{M}=\omega_{M}^{\prime}\end{subarray}}^{d}\sum_{i}^{N}&e^{ix_{1}(\Lambda_{\textbf{j}}-\Lambda_{\textbf{j'}})}...e^{ix_{M}(\Lambda\textbf{t}-\Lambda_{\textbf{t'}})}A^{(0)*}_{j^{\prime}_{1}1}A^{(1)*}_{{k^{\prime}_{1}j^{\prime}_{1}}}...A^{(1)*}_{{j^{\prime}_{2}t^{\prime}_{1}}}...A^{(L)*}_{{k^{\prime}_{L}j^{\prime}_{L}}}...A^{(L)*}_{{it^{\prime}_{L}}}\mathcal{M}_{i}\\\
&\times
A^{(L)}_{{it_{L}}}...A^{(L)}_{{k_{L}j_{L}}}...A^{(1)}_{{j_{2}t_{1}}}...A^{(1)}_{{k_{1}j_{1}}}A^{(0)}_{j_{1}1}.\end{split}$
(44)

As we can observe, the expectation value has the structure of a multi-
dimensional Fourier series:

$\langle\mathcal{M}\rangle=\sum_{\vec{\omega}\in\vec{\Omega}}c_{\vec{\omega}}e^{i\vec{x}\cdot\vec{\omega}}.$
(45)

Each data dimension has its frequency spectrum, resulting in a $M-$dimensional
vector of frequencies:

$\vec{\Omega}^{(LA)}=\big{(}\\{\Lambda_{\textbf{j}}-\Lambda_{\textbf{j'}}\\},...,\\{\Lambda_{\textbf{t}}-\Lambda_{\textbf{t'}}\\}\big{)}.$
(46)

The set of coefficients

$c_{\vec{\omega}}=\sum_{\begin{subarray}{c}\Lambda_{\textbf{j}}-\Lambda_{\textbf{j'}}=\omega_{1}\\\
\vdots\\\
\Lambda_{\textbf{t}}-\Lambda_{\textbf{t'}}=\omega_{M}\end{subarray}}A^{(0)*}_{j^{\prime}_{1}1}A^{(1)*}_{{k^{\prime}_{1}j^{\prime}_{1}}}...A^{(1)*}_{{j^{\prime}_{2}t^{\prime}_{1}}}...A^{(L)*}_{{k^{\prime}_{L}j^{\prime}_{L}}}...A^{(L)*}_{{it^{\prime}_{L}}}O_{i}A^{(L)}_{{it_{L}}}...A^{(L)}_{{k_{L}j_{L}}}...A^{(1)}_{{j_{2}t_{1}}}...A^{(1)}_{{k_{1}j_{1}}}A^{(0)}_{j_{1}1},$
(47)

also fulfill that
$c_{\omega_{1},\omega_{2},\cdots,\omega_{M}}=c_{-\omega_{1},-\omega_{2},\cdots,-\omega_{M}}^{*}$.

Now, we provide an alternative ansatz in which data of all dimensions is
uploaded without a processing gate separating the different dimensions.
Considering this, the ansatz is composed of the following layers

$L_{0}=A^{(0)}\hskip 42.67912ptL_{i}=S(x_{1})S(x_{2})...S(x_{M})A^{(i)}.$ (48)

The problem with this ansatz is that, by using the same $S(x_{i})$ for all
encoding gates, these gates become $S(x_{1})S(x_{2})\cdots
S(x_{M})=S(x_{1}+x_{2}+...+x_{M})$. Hence, all data dimensions are mapped to a
single dimension in the following way: $\bar{x}=x_{1}+...+x_{M}$. In other
words, the $M-$dimensional data collapses in a one-dimensional space. For
example, the data we introduce for $M=2$ with a qubit circuit is
$\bar{x}=x_{1}+x_{2}$. The model cannot distinguish the data points $x_{1}=1$,
$x_{2}=0$, and $x_{1}=0$, $x_{2}=1$. Consequently, the results obtained by the
model for fitting a two-dimensional function have a similar structure to the
function $f(x_{1}+x_{2})$ (depicted in Fig. 7). For this reason, we need to
introduce a trainable gate in the middle of the encoding gate to separate the
data dependency. In section IV, we propose a model that uses non-commuting
gates for encoding data in different dimensions. This problem is avoided,
although it does not generate a Fourier series.

Figure 7: Fitting of a Fourier two-dimensional series with
$S(\vec{x})=R_{z}(x_{1})R_{z}(x_{2})$ and $10$ layers. The target function is
$f(x_{1},x_{2})=\frac{1}{12}(1+\cos x_{1}+\cos x_{2})$. The classical
optimization method is the Nelder-Mead. We use $500$ training points and
$1500$ test points. The predicted functions do not result to be like the
target. Instead, it presents a structure similar to $f(x_{1}+x_{2})$.

##  Appendix E Fourier series with the Parallel Ansatz

This section explaines more in deetail the Parallel Ansatz (PA) and studies
its performance. With this ansatz, we take advantage of larger Hilbert spaces
for operations with the trainable gates, which determine the coefficients of
the Fourier series. First, each data dimension is encoded in a different
qudit. Then, we present the resulting state after the parameterized quantum
circuit and the expectation value of an arbitrary observable $\mathcal{M}$ in
this state. We also provide a variation of this ansatz that does not use
entanglement in the trainable gates and we discuss the differences between the
two models.

Following the circuit of the PA in Fig. 3 (b), the $M-$qudit state after the
circuit is given by

$\psi_{i}=\sum_{j_{1},...,j_{L}=1}^{N=d^{M}}A^{(L)}_{ij_{L}}e^{i(x_{1}\lambda_{j_{L}}^{(1)}+...+x_{M}\lambda_{j_{L}}^{(M)})}...A^{(1)}_{j_{2}j_{1}}e^{i(x_{1}\lambda_{j_{1}}^{(1)}+...+x_{M}\lambda_{j_{1}}^{(M)})}A^{(0)}_{j_{1}1}.$
(49)

Now the indices run from $1$ to $N=d^{M}$, being $M=n$, the number of qudits,
and $d$ its dimension. The encoding gate is $S(\vec{x})=S(x_{1})\otimes
S(x_{2})\otimes...\otimes S(x_{M})=e^{ix_{1}H}\otimes
e^{ix_{2}H}...e^{ix_{M}H}$, which can be rewritten as
$S(\vec{x})=e^{i(x_{1}H^{(1)}+x_{2}H^{(2)}+...+x_{M}H^{(M)})}$, with

$H^{(i)}=\underbrace{\mathbb{I}}_{1}\otimes\underbrace{\mathbb{I}}_{2}\otimes\cdots\otimes\underbrace{H}_{i}\otimes\cdots\otimes\underbrace{\mathbb{I}}_{M}.$
(50)

All the Hamiltonians are built by the tensor product of $n-1$ identities
except in the $i$ position where we have the single-qudit Hamiltonian. This
gives a Hamiltonian of dimension $N=d^{M}$, which has the $d$ eigenvalues
$\lambda_{i}$ of the single-qudit Hamiltonian distributed along the $N=d^{M}$
possible positions on the diagonal. For example, a qubit model with two-
dimensional data ($M=2$) and the “spin-like” encoding ($H=\sigma_{z}/2$) has
the following encoding gate: $S(x_{1},x_{2})=e^{ix_{1}H}\otimes
e^{ix_{2}H}=e^{i(x_{1}H^{(1)}+x_{2}H^{(2)})}$. The eigenvalues of the two
Hamiltonians are:
$\lambda^{(1)}=\\{-\frac{1}{2},-\frac{1}{2},+\frac{1}{2},+\frac{1}{2}\\}$, and
$\lambda^{(2)}=\\{-\frac{1}{2},+\frac{1}{2},-\frac{1}{2},+\frac{1}{2}\\}$.
Therefore, the eigenvalues of $\sigma_{z}/2$ are maintained but distributed
differently. Continuing with the quantum state, we group the different
eigenvalues with the multi-index sum notation, i.e.,
$\Lambda^{(i)}_{\textbf{j}}=\lambda^{(i)}_{j_{1}}+\lambda^{(i)}_{j_{2}}+...+\lambda^{(i)}_{j_{L}}$,
we rewrite the final state as

$\psi_{i}=\sum_{\textbf{j}}^{N=d^{n}}e^{i(x_{1}\Lambda^{(1)}_{\textbf{j}}+...+x_{M}\Lambda^{(M)}_{\textbf{j}})}A^{(L)}_{ij_{L}}...A^{(1)}_{j_{2}j_{1}}A^{(0)}_{j_{1}1}.$
(51)

All data dimensions in the exponential are multiplied by a multi-index sum
with the same index, which may cut some freedom in fitting a Fourier series.
Although having the same index, they are non-equally distributed. With this,
the model has enough freedom to have an independent frequency spectrum in each
dimension. Finally, the expectation value of the observable is given by

$\begin{split}\langle\mathcal{M}\rangle=\sum_{\textbf{j,j'}=1=1}^{N}\sum_{i=1}^{N}e^{i[x_{1}(\Lambda_{\textbf{j}}^{(1)}-\Lambda_{\textbf{j'}}^{(1)})+...+x_{M}(\Lambda_{\textbf{j}}^{(M)}-\Lambda_{\textbf{j'}}^{(M)})]}A^{(0)*}_{j^{\prime}_{1}1}A^{(1)*}_{j^{\prime}_{2}j^{\prime}_{1}}...A^{(L)*}_{ij^{\prime}_{L}}M_{i}A^{(L)*}_{ij_{L}}...A^{(1)}_{j_{2}j_{1}}A^{(0)}_{j_{1}1},\end{split}$
(52)

which has the structure of a multi-dimensional Fourier series. The observable
$\mathcal{M}$ acts on $n$ qudits, but we propose to measure only one qudit,
for example, the first one. Then the observable becomes
$\mathcal{M}=\mathbf{M}\otimes\mathbb{I}\otimes...\otimes\mathbb{I}$, where
$\mathbf{M}$ is a single-qudit observable. This does not affect the models’
structure. The frequency spectrum obtained is

$\vec{\Omega}^{(PA)}=(\\{\Lambda_{\textbf{j}}^{(1)}-\Lambda_{\textbf{j'}}^{(1)}\\},...,\\{\Lambda_{\textbf{j}}^{(M)}-\Lambda_{\textbf{j'}}^{(M)}\\}).$
(53)

Therefore, the PA’s output has a multi-dimensional Fourier series structure.

Now we explore a variation of the PA. The circuit ansatz we consider is the
same, but instead of using processing gates $A^{(i)}$ as multi-qudit gates, we
only use single-qudit gates, meaning that we need to eliminate any entangling
gate. In this way, we explore the outcome of the model working with each qudit
separately. Now we measure an observable acting in all qudits because they do
not interact and consequently do not share any correlation. The state after
the circuit with the ansatz considered is

$\ket{\psi}=A^{(0)}S(\vec{x})A^{(1)}...S(\vec{x})A^{(L)}=\ket{\psi_{1}}\otimes\ket{\psi_{2}}\otimes...\otimes\ket{\psi_{M}}.$
(54)

where $A^{(i)}=A^{(i)}_{1}\otimes A^{(i)}\otimes...\otimes A^{(i)}_{M}$, and
$S(\vec{x})=S(x_{1})\otimes S(x_{2})\otimes...\otimes S(x_{M})$. Hence, if we
choose to measure an observable
$\mathcal{M}=\sigma_{z}\otimes\sigma_{z}\otimes....\otimes\sigma_{z}$, the
result is

$\begin{split}\langle\mathcal{M}\rangle(\vec{x})=\bra{\psi_{1}}\sigma_{z}\ket{\psi_{1}}\bra{\psi_{2}}\sigma_{z}\ket{\psi_{2}}&...\bra{\psi_{M}}\sigma_{z}\ket{\psi_{M}}=\sum_{\omega_{1}}c_{\omega_{1}}^{(1)}e^{ix_{1}\omega_{1}}\sum_{\omega_{2}}c_{\omega_{2}}^{(2)}e^{ix_{1}\omega_{2}}...\sum_{\omega_{M}}c_{\omega_{M}}^{(M)}e^{ix_{1}\omega_{M}}\\\
=&\sum_{\vec{\omega}}c_{\omega_{1}}^{(1)}c_{\omega_{2}}^{(2)}...c_{\omega_{M}}^{(M)}e^{i(x_{1}\omega_{1}+x_{2}\omega_{2}+...+x_{M}\omega_{M})},\end{split}$
(55)

where we have used the results of the one-dimensional Fourier series discussed
in App. A. We obtain a multiplication of $M$ one-dimensional Fourier series.
In this case, however, we do not have all the free coefficients because
$c_{\vec{\omega}}\neq
c_{\omega_{1}}^{(1)}c_{\omega_{2}}^{(2)}...c_{\omega_{M}}^{(M)}$. For example,
for $M=2$ we have $5$ free coefficients: $c_{00},c_{01},c_{10},c_{11}$,
$c_{1-1}$ but in this variation of the model we have $4$ free coefficients:
$c_{0}^{(1)},c_{0}^{(2)},c_{1}^{(1)},c_{1}^{(2)}$, since the other ones are
constrained by $c_{\omega_{i}}^{(i)}=c_{-\omega_{i}}^{(i)*}$. The output of
this model is still a Fourier series, but not the most general one. Regardless
of this, the possibility of finding applications for some problems is not
discarded, as the question remains open.

##  Appendix F Fourier series with the Mixed Ansatz

In this section, we explore the last ansatz considered. The circuit in Fig. 3
(c) is called the Mixed Ansatz (MA) because it combines elements of the LA and
the PA: various data dimensions are encoded in the same qudit as in the LA,
but also other qudits are used to encode them, like in the PA. The idea of
this model is to take advantage of the hardware requirements of the current
quantum devices. For instance, if we have a chip with $4$ qubits and $8$ data
features, we introduce $2$ dimensions in each qubit.

Let us consider a MA circuit of $p$ qudits and a $M-$dimensional data set. In
the ideal case, we encode $M/p$ data dimensions in every qudit. Of course,
$M/p$ will not always be an integer. In such cases, we use fewer encoding
gates in the last layer. Since we are encoding different data features in the
same qudit, we need extra processing gates between these dimensions, like in
the LA. All the trainable gates are $p$-dimensional qudit gates since we
encode data in this number of qudits. The quantum state after the circuit is
given by

$\begin{split}\psi_{i}=\sum_{\begin{subarray}{c}j_{1},..,j_{L}\\\
k_{1},..,k_{L}\\\ t_{1},...,t_{L}\\\
\vdots\end{subarray}}^{N=d^{p}}&A^{(L)}_{{M/p}_{it_{L}}}e^{i(x_{M-(p-1)}\lambda_{t_{L}}^{(1)}+...+x_{M}\lambda_{t_{L}}^{(p)})}...A^{(L)}_{1_{k_{L}j_{L}}}e^{i(x_{1}\lambda_{j_{L}}^{(1)}+...x_{p}\lambda_{j_{L}}^{(p)})}...\\\
&\times
A^{(1)}_{{M/p}_{j_{2}t_{1}}}e^{i(x_{M-(p-1)}\lambda_{t_{1}}^{(1)}+...+x_{M}\lambda_{t_{1}}^{(p)})}...A^{(1)}_{1_{k_{1}j_{1}}}e^{i(x_{1}\lambda_{j_{1}}^{(1)}+...+x_{p}\lambda_{j_{1}}^{(p)})}A^{(0)}_{j_{1}1}.\end{split}$
(56)

This equation has a different distribution of eigenvalues: $\lambda^{(i)}$
with $i\in\\{1,...,p\\}$ because we have $p$ qudits. The different
distribution comes from the tensor product of the identity in all the $p$
qudits and the encoding Hamiltonian in the $i-$th qudit (see Eq. (50)). By
introducing the multi-index and multi-sum notation that we have explored in
this work, we reduce the expression to

$\psi_{i}=\sum_{\textbf{j},\textbf{k},\textbf{t},...}^{N=d^{p}}e^{i(x_{1}\Lambda_{\textbf{j}}^{(1)}+...+x_{p}\Lambda_{\textbf{j}}^{(p)}+...+x_{M-(p-1)}\Lambda_{\textbf{t}}^{(1)}+...+x_{M}\Lambda_{\textbf{t}}^{(p)})}A^{(L)}_{{M/p}_{it_{L}}}...A^{(L)}_{1_{k_{L}j_{L}}}...\\\
A^{(1)}_{{M/p}_{j_{2}t_{1}}}...A^{(1)}_{1_{k_{1}j_{1}}}A^{(0)}_{j_{1}1},$ (57)

where $\textbf{j}=\\{j_{1},j_{2},...,j_{L}\\}$ and
$\Lambda_{\textbf{j}}^{(i)}=\lambda_{j_{1}}^{(i)}+\lambda_{j_{2}}^{(i)}+...+\lambda_{j_{L}}^{(i)}$.
The expectation value of an observable $\mathcal{M}$ in this quantum state is
given by

$\begin{split}\langle\mathcal{M}\rangle=\sum_{\textbf{j},\textbf{j'},\textbf{k},\textbf{k'},\textbf{t},\textbf{t'}...}^{N=d^{p}}\sum_{i=1}^{N}e^{i[x_{1}(\Lambda_{\textbf{j}}^{(1)}-\Lambda_{\textbf{j}^{\prime}}^{(1)})+...+x_{p}(\Lambda_{\textbf{j}}^{(p)}-\Lambda_{\textbf{j'}}^{(p)})+...+x_{M-(p-1)}(\Lambda_{\textbf{t}}^{(1)}-\Lambda_{\textbf{t'}}^{(1)})+...+x_{M}(\Lambda_{\textbf{t}}^{(p)}-\Lambda_{\textbf{t'}}^{(p)})]}A^{(0)*}_{j^{\prime}_{1}1}A^{(1)*}_{1_{k^{\prime}_{1}j^{\prime}_{1}}}...\\\
\times
A^{(1)*}_{{M/p}_{j^{\prime}_{2}t^{\prime}_{1}}}...A^{(L)*}_{1_{k^{\prime}_{L}j^{\prime}_{L}}}...A^{(L)*}_{{M/p}_{it^{\prime}_{L}}}\mathcal{M}_{i}A^{(L)}_{{M/p}_{it_{L}}}...A^{(L)}_{1_{k_{L}j_{L}}}...A^{(1)}_{{M/p}_{j_{2}t_{1}}}...A^{(1)}_{1_{k_{1}j_{1}}}A^{(0)}_{j_{1}1}.\end{split}$
(58)

In terms of the eigenvalues, we see combined features of the two models:
having a different distribution of eigenvalues with the same index (in the
data dimensions processed at the same level of depth) and having different
index with the same distribution of eigenvalues (the data-features processed
in the same qudit). Therefore, this model also generates a multi-dimensional
Fourier series.

##  Appendix G Practical case: fitting 4-dimensional data

Figure 8: Graphic representation of the degrees of freedom and the free
parameters with respect to the number of layers for the Line, Parallel, and
Mixed ansatzes models with $4-$dimensional data. The upper plot depicts
results for qubits and the lower for qutrits. The y-axis is logarithmic and
represents the number of coefficients or parameters and the x-axis is the
number of layers in the models. The only model that accomplishes the d.o.f.
condition is the PA and the results are improved when we use qutrits. With
qubits, the condition is satisfied until the Fourier series of degree
$D=(d-1)L=2$ and $D=4$ for qutrits.

In this appendix, we fit a 4-dimensional Fourier series of degree $D$ with the
three ansatzes described in this work: the LA, PA, and MA. We compare which
models are more convenient for fitting higher-degree Fourier series. The
general target function is given by

$f(x_{1},x_{2},x_{3},x_{4})=f(\vec{x})=\sum_{\vec{\omega}=-D}^{D}c_{\vec{\omega}}e^{i\vec{x}\cdot\vec{\omega}},$
(59)

where $\vec{\omega}=(\omega_{1},\omega_{2},\omega_{3},\omega_{4})$ describes
the frequency in each dimension. The number of free coefficients $N_{c}$ in
the 4-dimensional Fourier series is determined by the degree of the series:

$N_{c}=\frac{(2D+1)^{4}-1}{2}+1,$ (60)

since half of them are constrained by
$c_{\vec{\omega}}=c_{-\vec{\omega}}^{*}$, except $c_{\vec{0}}$. At the same
time, the degree of the Fourier series generated by the model is determined by
the qudit used and the number of layers of the model: $D=(d-1)L$. Hence,
$N_{c}$ depends on $d$, and $L$. We know that $\nu\equiv 2N_{c}-1$ is the
number of degrees of freedom required for the model to fit the general Fourier
series. The number of free parameters of the different models for
$4-$dimensional data is given by

$\begin{split}N_{p}^{(LA)}&=(4L+1)(d^{2}-1),\\\
N_{p}^{(PA)}&=(L+1)(d^{8}-1),\\\ N_{p}^{(MA)}&=(2L+1)(d^{4}-1),\end{split}$
(61)

where for the MA we use two qudits, therefore $p=2$. With this, we determine
graphically the Fourier series degree that accomplishes the d.o.f. condition.
This is shown in Fig. 8 for qubit and qutrit models. As we can notice, for
$4-$dimensional data, both the LA nor the MA do not accomplish the d.o.f.
condition for any number of layers. This means we do not have enough free
parameters in the model for fitting an arbitrary Fourier series. With the PA
model, the condition is satisfied until $L=2$, meaning that we achieve Fourier
series of degree $D=2(d-1)$, having degree $2$ for the qubit model and $4$ for
the qutrit. Hence, this model can give limited approximations to some
functions.