# One qubit as a Universal Approximant

Adrián Pérez-Salinas  Barcelona Supercomputing Center, Barcelona 08034, Spain
Departament de Física Quàntica i Astrofísica and Institut de Ciències del
Cosmos, Universitat de Barcelona, Barcelona 08028, Spain  David López-Núñez
Barcelona Supercomputing Center, Barcelona 08034, Spain  Institut de Física
d’Altes Energies, The Barcelona Institute of Science and Technology,
Bellaterra 08193, Spain  Departament de Física Quàntica i Astrofísica and
Institut de Ciències del Cosmos, Universitat de Barcelona, Barcelona 08028,
Spain  Artur García-Sáez  Barcelona Supercomputing Center, Barcelona 08034,
Spain  Qilimanjaro Quantum Tech, Barcelona 08007, Spain  P. Forn-Díaz
Institut de Física d’Altes Energies, The Barcelona Institute of Science and
Technology, Bellaterra 08193, Spain  Qilimanjaro Quantum Tech, Barcelona
08007, Spain  José I. Latorre  Qilimanjaro Quantum Tech, Barcelona 08007,
Spain  Center for Quantum Technologies, Singapore 117543, Singapore  Quantum
Research Centre, Technology Innovation Institute, P.O.Box: 9639, Abu Dhabi,
United Arab Emirates

###### Abstract

A single-qubit circuit can approximate any bounded complex function stored in
the degrees of freedom defining its quantum gates. The single-qubit
approximant presented in this work is operated through a series of gates that
take as their parameterization the independent variable of the target function
and an additional set of adjustable parameters. The independent variable is
re-uploaded in every gate while the parameters are optimized for each target
function. The output state of this quantum circuit becomes more accurate as
the number of re-uploadings of the independent variable increases, i. e., as
more layers of gates parameterized with the independent variable are applied.
In this work, we provide two different proofs of this claim related to both
Fourier series and the Universal Approximation Theorem for Neural Networks,
and we benchmark both methods against their classical counterparts. We further
implement a single-qubit approximant in a real superconducting qubit device,
demonstrating how the ability to describe a set of functions improves with the
depth of the quantum circuit. This work shows the robustness of the re-
uploading technique on Quantum Machine Learning.

##  I Introduction

A quantum computer can be viewed as a machine that receives inputs and
delivers outputs through the read-out of qubits. The design of the sequence of
quantum gates forming the circuit will determine the kind of processing
performed. A fundamental question to pose is whether a quantum circuit can
deliver any possible functionality and, if so, what number of qubits and depth
are required to achieve a given accuracy.

This problem is reminiscent of a series of classical theorems that establish
that a given function can be re-expressed as a linear combination of other
specific functions [1, 2, 3, 4]. In particular, in classical machine learning
the Universal Approximation Theorem (UAT) [3] proves that a neural network
with a unique intermediate hidden layer can converge to approximate any
continuous function. The accuracy of the approximation increases with the
number of neurons in the intermediate layer. It is important to notice that
each of these neurons is fed with the original data of the problem. The query
complexity of the process increases linearly with the number of neurons. This
observation is critical to find out an equivalent result in a quantum
formulation in order to support progress in quantum machine learning [5, 6, 7,
8, 9, 10, 11, 12, 13]. Previous works have already made relevant contributions
in this area [14, 15], in particular assessing the universal expressive power
of quantum circuits.

In this paper, we present two independent proofs that any bounded complex
function can be approximated in a convergent way by a quantum circuit acting
on one qubit, constituting a single-qubit universal approximant. This
demonstrates the precise representation power of a single-qubit circuit, which
increases as more layers are added. The essential element of the present
construction is the re-uploading of the input variables along the action of
the quantum gates [5]. Thus, in analogy to neural networks, query complexity
is attached to accuracy. The first way to prove this result is to make contact
with harmonic analysis. This is a natural step as single-qubit gates are
expandable in Fourier series that can be rearranged to fit existing theorems.
The second method is analogous to the UAT using a translation into quantum
circuits. A series of specific gates leads to an output state that
approximates functions uniformly. In both cases, the quantum theorems inherit
the applicability and characteristics of their classical counterparts.

The practical way to approximate any function with a quantum circuit requires
finding an explicit set of parameters to define the unitary gates. This can be
accomplished in a variational way. Compared to Fourier series, this approach
brings more power to a quantum computer in practise. The possibility of taking
angles which are free of being multiples of a given basic frequency provides a
larger representation capability to a quantum circuit. However, this is
analogue to neural networks with weights which are not constrained to take
specific values.

We provide numerical benchmarks of these theorems computed via classical
simulation of quantum computers. Our simulations show how an increasing query
complexity can improve the accuracy of the approximation of a number of test
functions. The way a single-qubit circuit can approximate any function in an
experimental setup by using a superconducting qubit is explicitly illustrated.
Experimental results confirms the trend of simulations up to a point where the
accumulation of errors dominates the experiment.

This procedure of storing complex functions in single-qubit circuits acquires
its importance when addressing Machine-Learning problems. The goal of any
Machine Learning model is to extract and generalize the hidden features of
some training dataset in order to predict the behaviour of unseen data. That
is, the model must learn some unknown function from sampling data while the
structure of such function remains covert. The proofs given in this work
ensure that this kind of models can learn any function underlying the training
data. In addition, the processing of data in Machine Learning models must be
performed in a linear way to avoid the emergence of biases, as it is done in
this case. Essentially, the theoretical work proposed in this work aims to
play for quantum circuits the same role UAT plays for Neural Networks.

It is worth mentioning that, even though one can store a complex function in a
single-qubit circuit, retrieving that information from the quantum state is
costly and requires a large amount of measurements. Instead, this algorithm
should be regarded as a subroutine to be included in a more complex
computation. For instance, this subroutine could play the role of a classifier
[5] or an approximant of unknown functions [6]. These works also suggest the
use of similar approaches extended to circuits with many qubits.

This article is organized as follows. In Sec. II we introduce the idea of a
single-qubit approximant and present two theorems on its universality. Sec.
III is devoted to the numerical benchmarks to test the approximation
algorithms. The experimental implementation using a superconducting qubit is
described in Sec. IV. Results are presented in Sec. V. We leave conclusions
for Sec. VI. More details on the results of this work can be found in the
appendix.

##  II Universality of the single-qubit approximant

In this section, we propose an encoding of mathematical functions as the
degrees of freedom of a single qubit state. We also define two different
circuit architectures that approximate those functions and present theorems
supporting this claim.

Figure 1: Scheme for the hybrid algorithm. The gates $U(x,\vec{\theta}_{i})$
define the operation performed by the quantum circuit. All $\vec{\theta}_{i}$
are independent of each other. Using the measured output state, a loss
function $\mathcal{L}$ is constructed using these measurements. A classical
optimizer looks for the set of parameters minimizing $\mathcal{L}$.

###  II.1 Set-up of the problem

The most general representation of a single-qubit quantum state stores a
single complex number. That is,

$\ket{\psi}=\sqrt{1-f^{2}}\ket{0}+fe^{i\phi}\ket{1},$ (1)

with $f,\phi$ real numbers and $f\in[0,1]$, $\phi\in[0,2\pi)$. Our aim is to
encode a complex function within the values ($f,\phi$) by defining them as
$f:\mathbb{R}^{m}\rightarrow[0,1]$ and
$\phi:\mathbb{R}^{m}\rightarrow[0,2\pi)$. To do so, we design a circuit
$\mathcal{U}_{f,\phi}(x)$ such that its output state approximates the desired
complex function as

$\bra{1}\mathcal{U}^{(k),s}_{f,\phi}\ket{0}\rightarrow f(x)e^{i\phi(x)}$ (2)

Note that building an approximation to a bounded complex function is enough to
address any bounded complex function by a simple shifting and re-scaling. In
addition, approximating a complex function includes real-valued functions by
either setting $\phi(x)=0$ or relating the real-valued function to the modulus
of other complex functions.

######  Definition 1.

The $k$-th approximating circuit is defined as

$\mathcal{U}^{(k),s}_{f,\phi}=\prod_{i=1}^{k}U^{s}(x,\vec{\theta}_{i}),$ (3)

where $U^{s}(x,\vec{\theta})$ is a fundamental gate depending on $x$ and a set
of parameters $\vec{\theta}$. $s$ stands for the type of single-qubit gate
used in this work.

The models chosen in our construction will be made explicit later, including
the exact definition of the so-called fundamental gate. The expected behavior
of this quantity $\mathcal{U}^{(k),s}_{f,\phi}$ is that the approximation from
Eq. (2) will improve as the number $k$ increases, that is, as the independent
variable is re-uploaded multiple times. As we shall see, the appropriate
choice of these parameters $\vec{\theta}_{i}$ enables a systematic
approximation of any functionality. Equivalently, the optimal values of
$\vec{\theta}_{i}$ depend on $f(x)$ and $\phi(x)$.

In general, the set of parameters for a given gate $\vec{\theta}_{i}$ is
composed of a set of angles. The quest for the optimal set of parameters
$\\{\vec{\theta}_{1},\vec{\theta}_{2},\ldots,\vec{\theta}_{k}\\}$ is driven by
optimizing a particular loss function $\mathcal{L}(\theta;f,\phi,x)$. This
loss function must be designed in such a way that Eq. (2) becomes an equality
as $\mathcal{L}\rightarrow 0$. The optimal parameters are then

$\\{\vec{\theta}_{1},\vec{\theta}_{2},\ldots,\vec{\theta}_{k}\\}={\rm
argmin}_{\theta}\mathcal{L}(\theta;f,\phi,x).$ (4)

Therefore, the proposed quantum procedure for storing functions within the
output state of a given circuit belongs to the class of hybrid quantum-
classical variational algorithms. Variational algorithms are quantum
algorithms whose global structure is defined, but the exact gates are not [16,
17]. A scheme of the proposed algorithm is depicted in Fig. 1.

###  II.2 Two theorems on universality

We complete the structure of the algorithm presented above with the design of
the single-qubit gates $U^{s}$ aforementioned in Definition 1. In the
following, we present two sets of single-qubit gates to construct quantum
circuits that represent arbitrary complex functions. Each set is based on
known results from the theory of function approximations, namely Fourier
series [1, 2] and Universal Approximation Theorem (UAT) [3, 4], respectively.
The range of applicability of these theorems for quantum circuits and the
conditions for universality are thus inherited from their classical
counterparts.

#### Quantum Fourier series

Fourier series as a constructive method permits expressing a great range of
target functions defined within an interval as a sum of a set of known
functions.

######  Theorem 1.

Fourier series [1, 2, 18, 19]
Let $z$ be any function $z:\mathbb{R}\rightarrow\mathbb{C}$ with a finite
number of finite discontinuities integrable within an interval
$[a,b]\in\mathbb{R}$ of length $P$. Then

$z_{N}(x)=\sum_{n=-N}^{N}c_{n}e^{i\frac{2\pi nx}{P}},$ (5)

where

$c_{n}=\frac{1}{P}\int_{P}z(x)e^{-i\frac{2\pi nx}{P}}dx,$ (6)

approximates $z(x)$ as

$\lim_{N\rightarrow\infty}z_{N}(x)=z(x).$ (7)

Now we present an extension of Fourier series to a quantum circuit as
explicited in Def. 1. First, we define the Fourier gate $U^{\mathcal{F}}$:

######  Definition 2.

Let the fundamental Fourier gate $U^{\mathcal{F}}$ be

$U^{\mathcal{F}}(x;\underbrace{\omega,\alpha,\beta,\varphi,\lambda}_{\vec{\theta}})=R_{z}\left(\alpha+\beta\right)R_{y}(2\lambda)\times\\\
R_{z}\left(\alpha-\beta\right)R_{z}(2\omega x)R_{y}(2\varphi),$ (8)

with $\alpha,\beta,\varphi,\lambda,\omega\in\mathbb{R}$.

Intuitively, $\alpha,\beta,\varphi,\lambda$ are related to the coefficients of
a single Fourier step, while $\omega$ may be identified as the corresponding
frequency. The relationship between these parameters and the original Fourier
coefficients is explicitly shown in Appendix A.1.

######  Theorem 2.

Quantum Fourier series
Let $f,\phi$ be any pair of functions $f:\mathbb{R}\rightarrow[0,1]$ and
$\phi:\mathbb{R}\rightarrow[0,2\pi)$ , such that $z(x)=f(x)e^{i\phi(x)}$ is a
complex function with a finite number of finite discontinuities integrable
within an interval $[a,b]\in\mathbb{R}$ of length $P$. Then, there exists a
set of parameters
$\\{\vec{\theta}_{1},\vec{\theta}_{2},\ldots,\vec{\theta}_{N}\\}$ such that

$\bra{1}\prod_{i=1}^{N}U^{\mathcal{F}}(x,\vec{\theta}_{i})\ket{0}=z_{N}(x),$
(9)

with $z_{N}(x)$ the $N$-terms Fourier series.

When the building blocks are the $U^{\mathcal{F}}(x,\theta_{i})$ defined in
Eq. (8), the unitary operation as defined in Eq.(3) generates a total unitary
gate that outputs a $N$-term Fourier series when applied to an initial state
$\ket{0}$. Taking $\ket{0}$ as the initial state implies no loss of
generality, since we can transform $\ket{0}$ into any other initial state by
adjusting the first $U^{\mathcal{F}}$. The Fourier series behavior is only
achieved if all $\\{\vec{\theta}_{i}\\}$ take specific values leading to a
final result that exactly matches the Fourier coefficients. However, since
this procedure relies on quantum-classical variational methods, we will look
for the optimal parameters by means of a classical optimizer. This freedom
gives room to configurations surpassing the performance of the standard
Fourier series, especially for shallow circuits. However, the recipe to
construct the Fourier series by performing well-defined calculations is
instead lost. For details on the proof of this theorem we refer the reader to
Appendix A.1.

#### Quantum UAT

The Universal Approximation Theorem (UAT) demonstrates that any continuous
function of a $m$-dimensional variable can be uniformly approximated as a sum
of a specific set of functions with adjustable parameters. The first
formulation restricted the functions to be sigmoidal functions [3]. Later
works extended the result to any non-constant bounded continuous function [4].
This theorem is directly applied to neural networks containing one hidden
layer.

######  Theorem 3.

Universal Approximation Theorem [3, 4, 20] Let $I_{m}$ denote the
$m$-dimensional cube $[0,1]^{m}$. The space of continuous functions on $I_{m}$
is denoted by $C(I_{m})$, and we use $|\cdot|$ to denote the uniform norm of
any function in $C(I_{m})$. Let $\sigma:\mathbb{R}\rightarrow\mathbb{R}$ be
any non-constant bounded continuous function. Given a function $f\in C(I_{m})$
there exists an integer $N$ and a function

$G(\vec{x})=\sum_{n=1}^{N}\alpha_{n}\sigma(\vec{w}_{n}\cdot\vec{x}+b_{n}),$
(10)

such that

$|G(\vec{x})-f(\vec{x})|<\varepsilon,\qquad\forall\vec{x}\in I_{m},$ (11)

for $\vec{w}_{n}\in\mathbb{R}^{m}$ and $b_{n},\alpha_{n}\in\mathbb{R}$ for any
$\varepsilon>0$.

This theorem is an existence theorem, and thus it does not specify how many
terms from Eq. (10) are needed to achieve an accuracy $\varepsilon$. Note that
the UAT can be immediately applied to complex functions by substituting the
real-valued function $\sigma(\cdot)$ with some complex-valued function. In
particular, it works if $\sigma(\cdot)\rightarrow e^{i(\cdot)}$. A proof is
shown in Appendix B.

We can now translate the UAT to the proposed quantum circuit by defining the
fundamental single-qubit gate.

######  Definition 3.

Let the fundamental UAT gate $U^{\rm UAT}$ be

$U^{\rm
UAT}(\vec{x};\underbrace{\vec{\omega},\alpha,\varphi}_{\vec{\theta}})=R_{y}(2\varphi)R_{z}(2\vec{\omega}\cdot\vec{x}+2\alpha),$
(12)

with
$\\{\vec{\omega},\alpha,\varphi\\}\in\\{\mathbb{R}^{m},\mathbb{R},\mathbb{R}\\}$.

Intuitively, $\vec{\omega}$ and $\alpha$ are equivalent to the weights and
bias in a neural network, while $\varphi$ plays the role of the coefficient.

######  Theorem 4.

Quantum UAT
Let $f,\phi$ be any pair of functions $f:I_{m}\rightarrow[0,1]$ and
$\phi:I_{m}\rightarrow[0,2\pi)$ , such that
$z(\vec{x})=f(\vec{x})e^{i\phi(\vec{x})}$ is a complex continuous function on
$I_{m}$, with $I_{m}=[0,1]^{m}$. Then there is an integer $N$ and a set of
parameters $\\{\vec{\theta}_{1},\vec{\theta}_{2},\ldots,\vec{\theta}_{N}\\}$
such that

$\left|f(\vec{x})e^{i\phi(\vec{x})}-\bra{1}\prod_{i=1}^{N}U^{\rm
UAT}(\vec{x},\vec{\theta}_{i})\ket{0}\right|<\epsilon,$ (13)

for any $\epsilon>0$.

This theorem is analogous to the classical one, and one can arrive at its
proof by following the steps developed in Ref. [3]. All theorems supporting
the original formulation of the UAT also hold for the quantum version. For
more details on the demonstration of the quantum UAT, we refer the reader to
Appendix A.2.

#### Differences between approaches

The quantum universality theorems proposed here inherit the range of
applicability, advantages and limitations of their classical counterparts. The
Fourier approach is guaranteed to work for all integrable functions with a
finite number of finite discontinuities. This range of functions includes –but
is not limited to– continuous functions. The UAT only gives support to
continuous functions, which is useful from a practical perspective, but less
robust than the Fourier series.

The Fourier theorem holds for functions depending on a single variable.
However, the extension to multi-dimensional spaces is complicated and requires
a space of parameters whose size increases exponentially with the number of
dimensions [2]. However, in the UAT case the use of multi-variable $\vec{x}$
arises naturally by adjusting the dimension of the weights.

##  III Numerical experiments

In this section, we numerically explore how the theorems explained in Sec. II
perform in practice. We present two different kinds of benchmarks for real and
complex functions, respectively. These benchmarks collect results using both
$U^{\mathcal{F}}$ and $U^{\rm UAT}$ gates. Benchmarks are performed using
simulations that include no decoherence, but do contain sampling uncertainty.
We present simulations with up to 6 layers.

The aim of this benchmark is to compare the results of quantum and classical
methods. The classical Fourier representation can be obtained by following
Theorem 1. In the UAT case, we follow the description from Theorem 3 with
$\sigma(\cdot)$ being a cosine for real functions and $e^{i(\cdot)}$ for
complex functions. The parameters are found by employing specific classical
optimization methods. For the quantum UAT case we take $H\ket{0}=\ket{+}$ as
the initial state.

All simulations are performed using the framework QIBO [21]. The code
computing the numerical experiments as well as the final results can be found
on GitHub [22].

####  $Z$ benchmark for real functions

For the first benchmark we consider a single-variable, real-valued function
$-1\leq f(x)\leq 1$ related to the observable $\langle Z\rangle\sim f(x)$. The
quantum state we want to represent is then

$\ket{\psi(x)}_{Z}=\sqrt{\frac{1+f(x)}{2}}\ket{0}+e^{i\phi}\sqrt{\frac{1-f(x)}{2}}\ket{1},$
(14)

where $\phi$ is a phase that in general may be $x$-dependent, but it is
assumed constant at this stage. The $\chi^{2}$ function that drives the
optimization is then

$\chi^{2}=\frac{1}{M}\sum_{j=1}^{M}\left(\langle
Z(x_{j})\rangle-f(x_{j})\right)^{2},$ (15)

where $M$ is the total number of samples of $x$.

The $Z$ benchmark is first tested against four different functions of interest

$\displaystyle{\rm ReLU}(x)$ $\displaystyle=$ $\displaystyle\max(0,x),$ (16)
$\displaystyle\tanh(ax)$ $\displaystyle\;{\rm for}\;$ $\displaystyle a=5,$
(17) $\displaystyle{\rm step}(x)$ $\displaystyle=$ $\displaystyle x/|x|;\quad
0\;{\rm if}\;x=0,$ (18) $\displaystyle{\rm poly}(x)$ $\displaystyle=$
$\displaystyle|3x^{3}(1-x^{4})|.$ (19)

All functions are conveniently rescaled to fit the limits $-1\leq f(x)\leq 1$.
In all cases, $x\in[-1,1]$. The ${\rm ReLU}(\cdot)$ and $\tanh(\cdot)$
functions are chosen given the central role they play in the field of Machine
Learning. ${\rm step}(\cdot)$ presents a discontinuity, which implies a
challenge in the approximation. ${\rm poly}(\cdot)$ is chosen as it contains
wavy features arising from non-trigonometric functions.

Next, we test our approach against four functions of two variables in order to
check how the quality of the approximations evolves as more dimensions are
added to the problem. Those are known 2D functions named adjiman, brent,
himmelblau, threehump [23]. These functions are chosen as representatives of a
variety of difficulties the algorithm needs to overcome. In the 2D case, the
functions are conveniently rescaled to fit the limits $-1\leq f(x)\leq 1$ and
$(x,y)\in[-5,5]^{2}$. A definition of these functions can be found in Appendix
C.

In this benchmark, both the UAT and Fourier quantum and classical methods are
considered for the one-dimensional functions. However, 2D functions are only
tested for UAT methods since the theorems from Sec. II do not support
multidimensional Fourier series.

####  $X-Y$ benchmark for complex functions

In order to test the performarnce of the presented algorithm for fitting
complex functions, we propose a tomography-like benchmark. Since complex
functions have real and imaginary parts, one needs to measure at least two
observables in the qubit space. In this case, we chose the observables to be
$\langle X\rangle$ and $\langle Y\rangle$ for the real and imaginary parts,
that is $\langle X\rangle+i\langle Y\rangle\sim f(x)e^{ig(x)}$. The quantum
state that permits this identification is

$\ket{\psi(x)}_{XY}=\sqrt{\frac{1+\sqrt{1-f(x)}}{2}}\ket{0}\\\
+e^{ig(x)}\sqrt{\frac{1-\sqrt{1-f(x)}}{2}}\ket{1}.$ (20)

It is then possible to construct a $\chi^{2}$ function as

$\chi^{2}=\frac{1}{M}\sum_{j=1}^{M}\left|\langle X(x)\rangle+i\langle
Y(x)\rangle-f(x)e^{ig(x)}\right|^{2}.$ (21)

For the $X-Y$ benchmark we test the algorithm against all possible
combinations of real and imaginary parts of the functions defined in Eqs.
(16)–(19), conveniently renormalized to ensure that $\langle
X\rangle^{2}+\langle Y\rangle^{2}\leq 1$.

###  III.1 Optimization techniques

An optimization process is required to find the optimal gate parameters. For
the classical methods, we use standard optimization techniques [24]. Since the
number of parameters we deal with in this problem is relatively low compared
to the parameter space obtained for instance in Deep Learning, the BFGS and
L-BFGS algorithms [25, 26] as implemented by scipy [27] are used. These
algorithms belong to the class of gradient-based optimizers.

For quantum methods, optimization brings more problems that are yet to be
solved. In particular, the landscape of the loss function in the parameter
space remains unknown, and thus it is hard to infer what kind of classical
optimizers perform well for each particular problem. For this reason we look
for the best-fit parameters using the aforementioned L-BFGS algorithm and the
genetic option CMA [28, 29]. Genetic algorithms explore vast regions of the
parameter space and do not depend on gradients. However, they usually require
more function evaluations to converge to the minimum. In this case it is not
possible to guarantee that the solution found by any optimization algorithm is
the global minimum of our loss function.

##  IV Experimental implementation of the Approximation Theorems

Figure 2: Fittings for four real-valued functions using the $Z$ benchmark with
five layers. Blue triangles represent classical models, namely Fourier and
UAT, while red dots represent its quantum counterparts computed using a
classical simulator. Green squares are the experimental execution of the
optimized quantum model using a superconducting qubit. The target function is
plotted in black for comparison. The analysis for experimental errors is
plotted for the ${\rm ReLU}$ function and the UAT model.

Figure 3: Fittings for the 2D function Himmelblau properly normalized using
the $Z$ benchmark for five layers. The blue plot represents the classical UAT
model, while the red plot represents its quantum counterpart simulated. The
green plot is the experimental execution of the optimized quantum model. The
target function is painted in black. In all drawings, the lines corresponds to
the same levels in the $Z$ axis.

We implement the single-qubit universal approximant in a superconducting qubit
circuit cooled to the base temperature of a dilution refrigerator (20mK). The
qubit is a 3D transmon geometry [30] located inside an aluminum three-
dimensional cavity. The cavity bare frequency, $\omega_{c}=2\pi\times 7.89$
GHz, is greatly detuned from the qubit frequency, $\omega_{q}=2\pi\times 4.81$
GHz. Hence, there is a qubit state-dependent dispersive shift on the cavity
resonance, $2|\chi|=2\pi\times 1.5$MHz. The qubit anharmonicity is
$\alpha=-2\pi\times 324$ MHz and the qubit relaxation and spin-echo decay
times are, respectively, $T_{1}=15.6~{}\mu s$ and $T_{2Echo}=12.0~{}\mu s$.
These time scales exceed the operation times needed to implement the algorithm
up to 6 layers by 2 orders of magnitude. Additional information on the
experimental methods can be found in App. D.

In order to implement the gate sequences defined in the previous section we
follow the correspondence between logical and physical gates as shown in Fig.
10c in App. D. The phase of each pulse is selected at the pulse generator to
modify the rotation axis, producing either X or Y rotations as required. The Z
rotations are, in turn, virtual [31]. The microwave pulses incorporate a DRAG
correction [32, 33] which leads to an error per gate $\epsilon=0.01$ found
with randomized benchmarking [34]. Randomized benchmarking measures errors in
Clifford gates and not arbitrary angle rotations, which are instead used in
this experiment, yet offers a reasonable estimate on the overall fidelity of
our gates. The gate error observed is probably limited due to a non-ideal
filtering of the measurement lines in the fridge. In order to achieve better
qubit state readout visibility and shorter operation times, a reset protocol
is applied prior to the main sequence [35].

##  V Results

Figure 4: Values of $\chi^{2}$ for the $Z$ benchmark in all four test
functions using classical computation (blue scatter), classical simulation of
the quantum algorithm (red scatter) and experimental implementation with a
superconducting qubit (green scatter). Fourier models are depicted with
triangles, while UAT models are represented by crosses. Figure 5: Values of
$\chi^{2}$ for the $Z$ benchmark in all four test 2D functions using classical
computation (blue scatter), classical simulation of the quantum algorithm (red
scatter) and experimental implementation with a superconducting qubit (green
scatter). Only UAT models are considered.

In all results presented in this section we provide three different final
values. First, we use the Fourier and the UAT classical methods to approximate
a target function. The Fourier method is obtained following the constructive
recipe of Th. 1. The UAT is applied using a single-hidden-layer Neural
Network. Second, we approximate the same function using the quantum procedures
defined in this work, simulating the wave function evolution with classical
methods. In both cases, we retain the best outcome obtained with different
initial conditions used in the optimization step. Finally, we use the
parameters obtained using the simulation of the quantum procedure to execute
that circuit in the actual superconducting quantum device. A specific set of
$x$ values for the ${\rm ReLU}$ function from Eq. (16) can be found in App. D.
The theoretical optimal parameters may be, in principle, different than the
experimental ones. Hence, an optimization performed directly on the
experimental parameters could improve the final results [36].

We show in Fig. 3 the resulting fit for all four single-variable real-valued
functions from Eqs. (16)–(19). In this case the $Z$ benchmark with 5 layers is
considered. A classical approximation (blue), a quantum exact simulation (red)
and its experimental implementation (green) are depicted. All methods follow
the overall shape of the target function. Classical Fourier approximations
return less accurate predictions on the value of $f(x)$ due to the periodic
nature of the model. The quantum Fourier and both classical and quantum UAT
models return better results for all values of $x$. This behaviour is observed
in all benchmarks. The experimental results retain the qualitative properties
of the exact models, although a loss in performance is visible. In addition,
an analysis of experimental uncertainties is also depicted at the UAT ${\rm
ReLU}$ plot from Fig. 3.

Figure 3 depicts the approximations obtained for the ${\rm Himmelblau(x,y)}$
function comparing the target function and all different methods considered.
Figure 5 summarizes the values of $\chi^{2}$ for all 2D-functions taken into
account in this work.

All different executions capture the overall shape of the function, but some
differences exist in the different plots. Classical simulations return values
for $Z<-1,Z>1$, and thus lead to three minima in this case. On the other hand,
the quantum simulation cannot clearly distinguish those minima. The
experimental execution presents sharp contours because of the inherent noise
and sampling uncertainty.

Figure 4 shows a summary of the values of $\chi^{2}$ for classical and their
analogous quantum simulated models and their experimental validation. In the
case of classical and simulated quantum models a general trend towards better
approximations –implying lower values of $\chi^{2}$– is observed with an
increasing numbers of layers.

The simulated Fourier model performs better than its classical counterpart.
This is due to the fact that a classical Fourier series does not contain
tunable parameters, while its quantum version does. However, the result from
the classical Fourier series constitutes a lower bound for any approximation
method based on optimization since at least the quality of the Fourier series
is guaranteed.

In the UAT case of Fig. 4, no approach returns better results. The classical
algorithm performs better in the ${\rm poly}(x)$ case, but the results with
the simulated quantum method improve the classical ones in the $\tanh(5x)$
case. Both models present similar trends as the number of layers increases.

Despite the fact that the Fourier model contains more parameters than the UAT
model, the latter performs better as seen in Fig. 4. Therefore, the UAT method
seems more appropriate for the functions used here.

The experimental realization of the quantum approximation models suffers from
circuit noise and sampling uncertainties, and therefore degrades the quantity
$\chi^{2}$. This is more prominent as more layers are added to the model. As a
direct consequence, the approximation of the quantum model to the target
function loses accuracy. The inherent sampling uncertainty sets a lower bound
in the value of $\chi^{2}$ obtained through experiments.

In general, Fig. 4 supports the claim that every layer grants the model more
flexibility, and thus enhances the capability of fitting the target function.
This flexibility is given by the number of re-uploadings of the independent
variable and not by the amount of parameters. In addition, having too many
parameters likely hinders the optimization procedure.

Figure 6: Fittings for the complex function $f(x)=\tanh(5x)+i{\rm ReLU}(x)$
properly normalized using the $X-Y$ benchmark for five layers. Blue triangles
represent a classical model, while red dots represent its quantum counterparts
computed using a classical simulator. Green squares are the experimental
execution of the optimized quantum model using a superconducting qubit. The
target function is plotted in black for comparison.

Figure 7: Values of $\chi^{2}$ for the X-Y benchmark in all possible
combinations for real and imaginary parts of the four test functions from Eqs.
(16) to (19) using classical computation (blue scatter), classical simulation
of the quantum algorithm (red scatter), and experimental implementation with a
superconducting qubit (green scatter). Fourier models are depicted with
triangles, while UAT models are represented by crosses.

The values of $\chi^{2}$ in Fig. 5 measure the accuracy of the approximations.
As before, we see that a larger number of layers provides better
approximations to the target function. In agreement to the one-dimensional $Z$
benchmark, the scaling is similar for both quantum and classical methods.

A complex function in the $X-Y$ benchmark is depicted in Fig. 7. In that case,
the $X$ measurement leads to $\tanh(5x)$ while the imaginary part contains
${\rm ReLU}(x)$. All the observations made for the $Z$ benchmark hold in this
case.

Fig. 7 shows values of $\chi^{2}$ for all possible combinations of real and
imaginary parts using the functions described in Eqs.(16)–(19), being the real
and imaginary parts. In this case, it is possible to see a common advantage
for the quantum models. In particular, the functions $\tanh(5x)$ and ${\rm
ReLU}(x)$ work better in any combination. This reflects the behaviour already
observed in Fig. 4, where these functions present better performance than the
other functions considered.

##  VI Conclusions

We have shown that a single-qubit circuit has enough flexibility to encode any
complex function $z(x)$ in the degrees of freedom of each quantum gate. This
universal representation is achieved by acting with a quantum circuit on a
single-qubit gate that depends on input variables as well as additional
parameters that are fixed by Machine Learning techniques.

This result guarantees that a single-qubit circuit, as defined in this work,
is able to store two different and independent real functions. These functions
are not restricted to be single-variable, as there exists no limitation to the
dimensionality of its independent variable. Our present results provide the
highest degree of compression of data in a single-qubit state, since there are
no more degrees of freedom available in a qubit.

The proof for universality was shown following two different approaches,
leading to two sets of single-qubit gates. In the first method, we found a
link between quantum circuits and Fourier series. We have defined a quantum
gate tuned by five parameters such that the row of $N$ gates applied to an
initial state provides a final state where an $N$-term Fourier series is
encoded. For the second method, a single-qubit quantum gate is applied
multiple times to yield a final state whose form is compatible with the
Universal Approximation Theorem. The input state does not compromise the
validity of the approximation theorems but it affects the parameters defining
the circuit.

We also provide numerical evidence on the flexibility and approximation
capabilities of these quantum circuits. The benchmarks have been obtained
using simulations and classical minimizers to find optimal parameters for a
set of test functions. We have included as benchmarks 1D and 2D real functions
and 1D complex functions. The final results have also been compared to its
classical counterparts. In all cases, it is possible to see an equivalent
scaling for both classical and quantum methods. This ensures numerically that
the quantum procedure is comparable to the standard classical ones.

Experimental results implemented using a superconducting trasmon qubit confirm
the same trend obtained with the classical simulations. The finite qubit
coherence does not seem to impact the results significantly in the gate sets
applied.

It is known that no single-qubit algorithm can bring quantum advantage since
it is efficiently simulable by classical computers. The approach here
presented can instead be included as a sub-task of a larger routine. Achieving
a quantum advantage requires extending the approach to multi-qubit circuits.
For instance, one can implement the gate set defined in this work to apply on
several different qubits, and then add entangling gates, see [5, 6]. Whether
this extension to multi-qubit circuits is more flexible than the approach of
this work remains unclear. Thus, the present work can serve as a starting
point for studying the representation capability of quantum systems beyond one
qubit (see also [14]).

## Acknowledgements

We thank Martin Weides and Marco Pfirrman at Glasgow University for
fabricating the superconducting transmon qubit device used in this work at the
Karlsruhe Institute of Technology (KIT), and Prof. Sergio O. Valenzuela from
the Catalan Institute of Nanoscience and Nanotechnology (ICN2) for granting
access to the dilution refrigerator during the initial stages of the
measurements. We also thank the rest of the IFAE QCT group and the Qilimanjaro
team for their contribution setting up the new laboratory space where part of
the experiment was conducted. We acknowledge financial support from Secretaria
d’Universitats i Recerca del Departament d’Empresa i Coneixement de la
Generalitat de Catalunya, co-funded by the European Union Regional Development
Fund within the ERDF Operational Program of Catalunya (project QuantumCat,
ref. 001-P-001644). A.G-S received funding from the European Union’s Horizon
2020 research and innovation programme under grant agreement No 951911
(AI4Media). P. F.-D. acknowledges support from ”la Caixa” Foundation - Junior
leader fellowship (ID100010434-LCF/BQ/PR19/11700009), Ministry of Economy and
Competitiveness and Agencia Estatal de Investigación (FIS2017-89860-P;
SEV-2016-0588; PCI2019-111838-2), and European Commission (FET-Open AVaQus GA
899561; QuantERA). IFAE is partially funded by the CERCA program of the
Generalitat de Catalunya.

## References

  * Dirichlet [1829] P. G. L. Dirichlet, Sur la convergence des séries trigonométriques qui servent à représenter une fonction arbitraire entre des limites données, Journal für die reine und angewandte Mathematik 4, 157 (1829).
  * Riemann [1867] B. Riemann, Über die darstellbarkeit einer function durch eine trigonometrische reihe, Abhandlungen der Königlichen Gesellschaft der Wissenschaften zu Göttingen 13 (1867).
  * Cybenko [1989] G. Cybenko, Approximation by superpositions of a sigmoidal function, Mathematics of Control, Signals, and Systems 2, 303 (1989).
  * Hornik [1991] K. Hornik, Approximation capabilities of multilayer feedforward networks, Neural Networks 4, 251 (1991).
  * 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).
  * Pérez-Salinas  _et al._ [2021] A. Pérez-Salinas, J. Cruz-Martinez, A. A. Alhajri, and S. Carrazza, Determining the proton content with a quantum computer, Physical Review D 103, 10.1103/physrevd.103.034027 (2021).
  * Bravo-Prieto [2021] C. Bravo-Prieto, Quantum autoencoders with enhanced data encoding, Machine Learning: Science and Technology 2, 035028 (2021).
  * Mitarai  _et al._ [2018] K. Mitarai, M. Negoro, M. Kitagawa, and K. Fujii, Quantum circuit learning, Physical Review A 98 (2018).
  * Zhu  _et al._ [2019] D. Zhu, N. M. Linke, M. Benedetti, K. A. Landsman, N. H. Nguyen, C. H. Alderete, A. Perdomo-Ortiz, N. Korda, A. Garfoot, C. Brecque, L. Egan, O. Perdomo, and C. Monroe, Training of quantum circuits on a hybrid quantum computer, Science Advances 5, eaaw9918 (2019).
  * Lloyd  _et al._ [2020] S. Lloyd, M. Schuld, A. Ijaz, J. Izaac, and N. Killoran, Quantum embeddings for machine learning (2020), arXiv:2001.03622 [quant-ph] .
  * Liu  _et al._ [2020] Y. Liu, S. Arunachalam, and K. Temme, A rigorous and robust quantum speed-up in supervised machine learning (2020), arXiv:2010.02174 [quant-ph] .
  * Rebentrost  _et al._ [2014] P. Rebentrost, M. Mohseni, and S. Lloyd, Quantum support vector machine for big data classification, Physical Review Letters 113 (2014).
  * Lloyd  _et al._ [2013] S. Lloyd, M. Mohseni, and P. Rebentrost, Quantum algorithms for supervised and unsupervised machine learning (2013), arXiv:1307.0411 [quant-ph] .
  * 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).
  * Goto  _et al._ [2020] T. Goto, Q. H. Tran, and K. Nakajima, Universal approximation property of quantum feature map (2020), arXiv:2009.00298 [quant-ph] .
  * Peruzzo  _et al._ [2014] A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L. O’Brien, A variational eigenvalue solver on a photonic quantum processor, Nature Communications 5 (2014).
  * Farhi  _et al._ [2014] E. Farhi, J. Goldstone, and S. Gutmann, A quantum approximate optimization algorithm (2014), arXiv:1411.4028 [quant-ph] .
  * Carleson [1966] L. Carleson, On convergence and growth of partial sums of fourier series, Acta Math. 116, 135 (1966).
  * Turán [1970] P. Turán, Über die fouriersche reihe, in  _Leopold Fejér Gesammelte Arbeiten I_ (Birkhäuser Basel, 1970) pp. 302–317.
  * Leshno  _et al._ [1993] M. Leshno, V. Y. Lin, A. Pinkus, and S. Schocken, Multilayer feedforward networks with a nonpolynomial activation function can approximate any function, Neural Networks 6, 861 (1993).
  * Efthymiou  _et al._ [2020] S. Efthymiou, S. Ramos-Calderer, C. Bravo-Prieto, A. Pérez-Salinas, D. García-Martín, A. Garcia-Saez, J. I. Latorre, and S. Carrazza, Qibo: a framework for quantum simulation with hardware acceleration (2020), arXiv:2009.01845 [quant-ph] .
  * Pérez-Salinas [2021] A. Pérez-Salinas, Universal-Approximator, https://github.com/UB-Quantic/Universal-Approximator (2021).
  * Ardeh [2016] M. A. Ardeh, Benchmarkfcns toolbox (2016).
  * Pedregosa  _et al._ [2011] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay, Scikit-learn: Machine learning in Python, Journal of Machine Learning Research 12, 2825 (2011).
  * bfg [2006] _Numerical Optimization_ (Springer New York, 2006).
  * Byrd  _et al._ [1995] R. H. Byrd, P. Lu, J. Nocedal, and C. Zhu, A limited memory algorithm for bound constrained optimization, SIAM Journal on Scientific Computing 16, 1190 (1995).
  * Virtanen  _et al._ [2020] P. Virtanen _et al._ , SciPy 1.0: fundamental algorithms for scientific computing in python, Nature Methods 17, 261 (2020).
  * [28] N. Hansen, The CMA evolution strategy: A comparing review, in  _Towards a New Evolutionary Computation_ (Springer Berlin Heidelberg) pp. 75–102.
  * Niko  _et al._ [2020] Niko, Youhei Akimoto, Yoshihikoueno, D. Brockhoff, M. Chan, and ARF1, Cma-es/pycma: r3.0.3 (2020).
  * Paik  _et al._ [2011] H. Paik, D. I. Schuster, L. S. Bishop, G. Kirchmair, G. Catelani, A. P. Sears, B. R. Johnson, M. J. Reagor, L. Frunzio, L. I. Glazman, S. M. Girvin, M. H. Devoret, and R. J. Schoelkopf, Observation of high coherence in josephson junction qubits measured in a three-dimensional circuit qed architecture, Phys. Rev. Lett. 107, 240501 (2011).
  * McKay  _et al._ [2017] D. C. McKay, C. J. Wood, S. Sheldon, J. M. Chow, and J. M. Gambetta, Efficient $z$ gates for quantum computing, Phys. Rev. A 96, 022330 (2017).
  * Motzoi  _et al._ [2009] F. Motzoi, J. M. Gambetta, P. Rebentrost, and F. K. Wilhelm, Simple pulses for elimination of leakage in weakly nonlinear qubits, Phys. Rev. Lett. 103, 110501 (2009).
  * Chow  _et al._ [2010] J. M. Chow, L. DiCarlo, J. M. Gambetta, F. Motzoi, L. Frunzio, S. M. Girvin, and R. J. Schoelkopf, Optimized driving of superconducting artificial atoms for improved single-qubit gates, Phys. Rev. A 82, 040305 (2010).
  * Magesan  _et al._ [2011] E. Magesan, J. M. Gambetta, and J. Emerson, Scalable and robust randomized benchmarking of quantum processes, Phys. Rev. Lett. 106, 180504 (2011).
  * Geerlings  _et al._ [2013] K. Geerlings, Z. Leghtas, I. M. Pop, S. Shankar, L. Frunzio, R. J. Schoelkopf, M. Mirrahimi, and M. H. Devoret, Demonstrating a driven reset protocol for a superconducting qubit, Phys. Rev. Lett. 110, 120501 (2013).
  * [36] A direct optimization of the experimental parameters from the universal approximant using the qubit is currently being carried out and will be reported in future work.
  * Ash [1972] R. B. Ash,  _Real Analysis and Probability_ (Elsevier, 1972).
  * Hahn [1927] H. Hahn, Über lineare gleichungssysteme in linearen räumen., Journal für die reine und angewandte Mathematik 157, 214 (1927).
  * Banach [1929] S. Banach, Sur les fonctionnelles linéaires ii, Studia Mathematica 1, 223 (1929).
  * Riesz [1914] F. Riesz, Démonstration nouvelle d’un théorème concernant les opérations fonctionnelles linéaires, in  _Annales scientifiques de l’École Normale Supérieure_ , Vol. 31 (1914) pp. 9–14.
  * Weir [1974] A. J. Weir,  _General integration and measure_ , Vol. 2 (CUP Archive, 1974).

##  Appendix A Proof of universality theorems

We prove here the results claimed in Theorems 2 and 4.

###  A.1 Demonstration for the quantum Fourier series

The quantum circuit proposed in Theorem 2 fulfills the requirement that every
new gate plays the role of a new step in the original Fourier series. The
proof is based on an inductive procedure and can be then decomposed in two
steps. First, we show that the first gate of the circuit is equivalent to the
$0$-th constant Fourier term. Then, we show that if there are $N$ gates in a
row forming a $N$-term Fourier series, then adding a new gate provides a
$(N+1)$-terms Fourier series.

Let the fundamental gate $U^{\mathcal{F}}(x,\vec{\theta})$ gate defined in Eq.
(8) be

$U^{\mathcal{F}}(x;\vec{\theta})=U^{\mathcal{F}}(x;\omega,\alpha,\beta,\varphi,\lambda)=R_{z}\left(\alpha+\beta\right)R_{y}(2\lambda)R_{z}\left(\alpha-\beta\right)R_{z}(2\omega
x)R_{y}(2\varphi)=\\\ =\begin{pmatrix}\cos\lambda\cos\varphi
e^{i\alpha}e^{i\omega x}-\sin\lambda\sin\varphi e^{i\beta}e^{-i\omega
x}&-\cos\lambda\sin\varphi e^{i\alpha}e^{i\omega x}-\sin\lambda\cos\varphi
e^{i\beta}e^{-i\omega x}\\\ \sin\lambda\cos\varphi e^{-i\beta}e^{i\omega
x}+\cos\lambda\sin\varphi e^{-i\alpha}e^{-i\omega x}&-\sin\lambda\sin\varphi
e^{-i\beta}e^{i\omega x}+\cos\lambda\cos\varphi e^{-i\alpha}e^{-i\omega x}\\\
\end{pmatrix},$ (22)

It is possible to recast the above choice of fundamental gate using the
following redefinition of parameters,

$\displaystyle a_{+}=\cos\lambda\cos\varphi e^{i\alpha},$ (23) $\displaystyle
a_{-}=-\sin\lambda\sin\varphi e^{i\beta},$ (24) $\displaystyle
b_{+}=-\cos\lambda\sin\varphi e^{i\alpha},$ (25) $\displaystyle
b_{-}=-\sin\lambda\cos\varphi e^{i\beta}.$ (26)

A more compact representation of the fundamental gate follows

######  Lemma 1.

The fundamental gate can be expressed as

$\small U^{\mathcal{F}}(x;\omega,\alpha,\beta,\varphi,\lambda)=\\\
\begin{pmatrix}a_{+}e^{i\omega x}+a_{-}e^{-i\omega x}&b_{+}e^{i\omega
x}+b_{-}e^{-i\omega x}\\\ -b_{-}^{*}e^{i\omega x}-b_{+}^{*}e^{-i\omega
x}&a_{-}^{*}e^{i\omega x}+a_{+}^{*}e^{-i\omega x}\\\ \end{pmatrix},$ (27)

as can be verified by simple substitution from Definition 2.

Note that this expression corresponds to a unitary matrix, due to the
relations involved in the definition of the coefficients $a_{\pm}$ and
$b_{\pm}$. Note also that a unitary matrix has three degrees of freedom, which
are here fixed by 5 parameters. An intuition behind the role of these
parameters is that $\alpha,\beta,\varphi,\lambda$ are related to the
coefficients of one Fourier step, that is $a_{\pm},b_{\pm}$, while $\omega$
can be identified with the corresponding frequency.

A total circuit can be constructed by multiplying $k$ fundamental gates to
obtain $\mathcal{U}^{(k),s}_{f,\phi}$ as in Definition 1. Starting with this
composite gate, we can now proof the main Fourier approximation theorem.

######  Theorem 5.

There exists a series of $k$ single-qubit gates forming a $k$-th approximant
circuit that delivers a unitary operation where all its coefficients are
written as Fourier series.

###### Proof.

The proof of this constructive theorem consists in making contact with
harmonic analysis and proceeds by induction.

i) The first circuit consists only of one fundamental gate, chosen with
frequency $\omega=0$, that is

$U_{0}^{\mathcal{F}}=\begin{pmatrix}A_{0}&B_{0}\\\
-B_{0}^{*}&A_{0}^{*}\end{pmatrix},$ (28)

This, indeed corresponds to the first constant term of Fourier series.

ii) We now assume that the $N$-th approximant circuit takes the form

$\small\prod_{i=0}^{N}U_{i}^{\mathcal{F}}=\begin{pmatrix}\sum_{n=-N}^{N}A_{n}e^{i\Omega_{n}x}&\sum_{n=-N}^{N}B_{n}e^{i\Omega_{n}x}\\\
-\sum_{n=-N}^{N}B_{n}^{*}e^{-i\Omega_{n}x}&\sum_{n=-N}^{N}A_{n}^{*}e^{-i\Omega_{n}x}\end{pmatrix}.$
(29)

where the frequencies are $(\Omega_{n}\pm\omega)$. The result of adding a new
fundamental gate corresponds to

$\small\prod_{i=0}^{N+1}U_{i}^{\mathcal{F}}=\begin{pmatrix}\sum_{n=-N-1}^{N+1}\tilde{A}_{n}e^{i\tilde{\Omega}_{n}x}&\sum_{n=-N-1}^{N+1}\tilde{B}_{n}e^{i\tilde{\Omega}_{n}x}\\\
-\sum_{n=-N-1}^{N+1}\tilde{B}_{n}^{*}e^{-i\tilde{\Omega}_{n}x}&\sum_{n=-N-1}^{N+1}\tilde{A}_{n}^{*}e^{-i\tilde{\Omega}_{n}x}\end{pmatrix}$
(30)

where we need to fix the new coefficients $\tilde{\Omega}_{n}$ and frequencies
in terms of the old ones $\Omega_{n}$ and the new single gate frequency
$\omega$ added to the circuit. It is easy to see that the addition of a gate
changes the frequency in one unit, that is,
$\tilde{\Omega}=\Omega_{n}\pm\omega$. Then, the general structure of the
series can be adapted to a Fourier expansion by choosing

$\Omega_{n}=(2n+1)\frac{\pi}{2}.$ (31)

After fixing the values that the frequencies must take, it is straightforward
to re-arrange terms in the matrix and reach

$\displaystyle\tilde{A}_{0}$ $\displaystyle=$ $\displaystyle
A_{0}a_{-}-B_{0}^{*}b_{-}$ (32) $\displaystyle\tilde{A}_{\pm n}$
$\displaystyle=$ $\displaystyle A_{\pm n}a_{-}-B_{\mp n}^{*}b_{-}$ (33)
$\displaystyle+$ $\displaystyle A_{\pm(n-1)}a_{+}-B^{*}_{\mp(n-1)}b_{+}$
$\displaystyle\tilde{A}_{\pm(N+1)}$ $\displaystyle=$ $\displaystyle A_{\pm
N}a_{+}-B^{*}_{\mp N}b_{+}$ (34) $\displaystyle\tilde{B}_{0}$ $\displaystyle=$
$\displaystyle B_{0}a_{-}+A^{*}_{0}b_{-}$ (35) $\displaystyle\tilde{B}_{\pm
n}$ $\displaystyle=$ $\displaystyle B_{\pm n}a_{-}+A^{*}_{\mp n}b_{-}$ (36)
$\displaystyle+$ $\displaystyle B_{\pm(n-1)}a_{+}+A^{*}_{\mp(n-1)}b_{+}$
$\displaystyle\tilde{B}_{\pm(N+1)}$ $\displaystyle=$ $\displaystyle A^{*}_{\mp
N}a_{+}+A^{*}_{\mp N}b_{+}$ (37)

This provides the explicit connection between approximant circuits and Fourier
expansions for the coefficients of the global unitary matrix.

∎

The above constructive theorem is sufficient to prove that the output
probability of a series of approximant circuits can reproduce any
functionality.

###  A.2 Demonstration for the quantum UAT

An alternative manner to design a single-qubit universal approximant is
related to the equivalent Universal Approximation Theorem broadly used in
Neural Networks [3]. The idea is to start from a different fundamental gate.

Let the fundamental gate $U^{\rm UAT}(\vec{x};\vec{\theta})$ defined in Eq.
(12) be explicitly

$U^{\rm
UAT}(x;\vec{\omega},\alpha,\varphi)=R_{z}(2\left(\vec{\omega}\cdot\vec{x}+\alpha\right))R_{y}(2\varphi)=\begin{pmatrix}\cos(\varphi)e^{i(\vec{\omega}\cdot\vec{x}+\alpha)}&-\sin(\varphi)e^{i(\vec{\omega}\cdot\vec{x}+\alpha)}\\\
\sin(\varphi)e^{-i(\vec{\omega}\cdot\vec{x}+\alpha)}&\cos(\varphi)e^{-i(\vec{\omega}\cdot\vec{x}+\alpha)}\end{pmatrix},$
(38)

A total circuit can be constructed by multiplying $k$ fundamental gates to
obtain $\mathcal{U}^{(k),{\rm UAT}}_{f,\phi}$ as in Definition 1. We can now
prove the quantum UAT using this fundamental gate.

######  Theorem 6.

There exists a series of $k$ single-qubit gates forming a $k$-th approximant
circuit that delivers a unitary operation where all its coefficients are
written as an approximation as defined by Theorem 3, UAT.

###### Proof.

Let us take the $U^{\rm UAT}$ defined in Eq. (38).

$R_{z}(2\vec{\omega}\cdot\vec{x}+2\alpha)R_{y}(2\varphi)=\\\
\begin{pmatrix}\cos(\varphi)e^{i(\vec{\omega}\cdot\vec{x}+\alpha)}&-\sin(\varphi)e^{i(\vec{\omega}\cdot\vec{x}+\alpha)}\\\
\sin(\varphi)e^{-i(\vec{\omega}\cdot\vec{x}+\alpha)}&\cos(\varphi)e^{-i(\vec{\omega}\cdot\vec{x}+\alpha)}\end{pmatrix}$

By direct inspection it is straigthforward to check that every entry in this
matrix can be understood as one term of $\bar{f}_{N}$ in Eq. (10). From this
definition we can infer the recursive rule that defines all steps. If

$\displaystyle A_{N}=\bra{0}\prod_{n=1}^{N}U_{n}^{UAT}\ket{0}$ (39)
$\displaystyle B_{N}=\bra{1}\prod_{n=1}^{N}U_{n}^{UAT}\ket{0}$ (40)

then the updating rule is

$\displaystyle\begin{split}A_{N+1}=A_{N}\cos(\varphi_{N+1})e^{i\vec{\omega}_{N+1}\cdot\vec{x}}e^{i\alpha_{N+1}}-\\\
B_{N}\sin(\varphi_{N+1})e^{i\vec{\omega}_{N+1}\cdot\vec{x}}e^{i\alpha_{N+1}}\end{split}$
(41)
$\displaystyle\begin{split}B_{N+1}=A_{N}\sin(\varphi_{N+1})e^{-i\vec{\omega}_{N+1}\cdot\vec{x}}e^{\alpha_{N+1}}+\\\
B_{N}\cos(\varphi_{N+1})e^{-i\vec{\omega}_{N+1}\cdot\vec{x}}e^{i\alpha_{N+1}}\end{split}$
(42)

Having this updating rule in mind, it is possible to write

$B_{N}=\sum_{m=0}^{2^{N-1}}c_{m}(\varphi_{1},\ldots,\varphi_{N})e^{i\delta_{m}(\alpha_{1},\ldots,\alpha_{N})}e^{i\vec{w}_{m}(\vec{\omega}_{1},\ldots,\vec{\omega}_{N})\cdot\vec{x}},$
(43)

where the inner dependencies of $c_{m}$ are products of sines and cosines of
$\varphi_{n}$, and those of $\delta_{m}$ and $\vec{w}_{m}$ are linear
combinations of $\alpha_{n}$ and $\omega_{n}$.

Let us proceed now as in the proof of the UAT in Ref. [3]. Let us take $S$ as
the set of functions of the form $B_{N}(\vec{x})$, and $C^{\mathbb{C}}(I_{m})$
the set of continuous complex-valued functions in $I_{m}$, defined as in
Theorem 3. We assume that $S\subset C^{\mathbb{C}}(I_{m})$, and $S\neq
C^{\mathbb{C}}(I_{n})$. We can now apply the Theorem 7, known as Hahn-Banach
theorem. This theorem allows to state that there exists a linear functional
$L$ acting on $C^{\mathbb{C}}(I_{n})$ such that

$L(S)=L(\bar{S})=0,\qquad L\neq 0.$ (44)

Notice that this theorem is applicable as there are no restriction in working
only with real numbers.

We call now Theorem 8, known as Riesz representation theorem. We can write the
functional $L$ as

$L(h)=\int_{I_{n}}h(x)d\mu(x)$ (45)

for $\mu\in M(I_{n})$ non-null and $\forall\,h\in C^{\mathbb{C}}(I_{n})$. In
particular,

$L(h)=A_{N}(\vec{x})d\mu(\vec{x})=0,$ (46)

and thus

$\int_{I_{n}}e^{i\vec{v_{m}}(\omega_{1},\ldots,\omega_{N})\cdot\vec{x}}d\mu(\vec{x})=0.$
(47)

This is the usual Fourier transform of $\mu$. We can conclude by calling
Theorem 9, Lebesgue Bounded Convergence theorem, that if the
$\mathcal{FT}(\mu)=0$, then $\mu=0$, and we come into a contradiction with the
only assumption we made.

The measure of all half-planes being 0 implies that $\mu=0$. Let us fix
$\vec{w}$, and for a bounded measurabe function $h$ we define the linear
functional

$F(h)=\int_{I_{n}}h(\vec{w}\cdot\vec{x})d\mu(x),$ (48)

which is bounded on $L^{\infty}(\mathbb{R})$ since $\mu$ is a finite signed
measure. Let $h$ be an indicator of the half planes $h(u)=1$ if $u\geq-b$ and
$h(u)=0$ otherwise, then

$F(h)=\int_{I_{n}}h(\vec{w}\cdot\vec{x})d\mu(x)=\mu(\Pi_{\vec{w},b})+\mu(H_{\vec{w},b})=0.$
(49)

By linearity, $F(h)=0$ for any simple function, such as sum of indicator
functions of intervales [37].

In particular, for the bounded measurable functions
$s(u)=\sin(\vec{w}\cdot\vec{x}),c(u)=\cos(\vec{w}\cdot\vec{x})$ we can write

$F(c+is)=\int_{I_{n}}\exp{i\vec{w}\cdot\vec{x}}d\mu(\vec{x})=0.$ (50)

The Fourier Transform of this $F$ is null, thus $\mu=0$.

∎

For the sake of completeness, we cover now the three theorems required for the
proof.

######  Theorem 7.

: Hahn-Banach [38, 39]

Set $\mathbb{K}=\mathbb{R}{\;\rm or\;}\mathbb{C}$. Let $V$ be a
$\mathbb{K}-$vector space with a seminorm $p:V\rightarrow\mathbb{R}$. If
$\varphi:U\rightarrow\mathbb{K}$ is a $\mathbb{K}-$linear functional on a
$\mathbb{K}-$linear subspace $U\subset V$ such that

$|\varphi(x)|\leq p(x)\qquad\forall x\in U,$ (51)

then there exists a linear extension $\psi:V\rightarrow\mathbb{K}$ of
$\varphi$ to the whole space $V$ such that

$\displaystyle\psi(x)=\varphi(x)\qquad\forall x\in U$ (52)
$\displaystyle|\psi(x)|\leq p(x)\qquad\forall x\in V$ (53)

######  Theorem 8.

: Riesz Representation [40]

Let $X$ be a locally compact Hausdorff space. For any positive linear
functional $\psi$ on $C(X)$, there exists a uniruq regular Borel measure $\mu$
such that

$\forall f\in C_{c}(X):\qquad\psi(f)=\int_{X}f(x)d\mu(x)$ (54)

######  Theorem 9.

: Lebesgue Bounded Convergence [41]
Let $\\{f_{n}\\}$ be a sequence of complex-valued measurable functions on a
measure space $(S,\Sigma,\mu)$. Suppose that $\\{f_{n}\\}$ converges pointwise
to a function $f$ and is dominated by some integrable function $g(x)$ in the
sense

$|f_{n}(x)|\leq g(x),\qquad\int_{S}|g|d\mu<\infty$ (55)

then

$\lim_{n\rightarrow\infty}\int_{S}f_{n}d\mu=\int_{S}fd\mu$ (56)

###  A.3 Link to output of quantum circuits

Last sections were devoted to prove that specific series of circuits return
functionalities able to represent a wide range of functions. In this last step
we relate previous results to the output of quantum circuits.

######  Theorem 10.

The computational basis output of a single-qubit quantum circuit can provide a
convergent approximattion to any desired function.

###### Proof.

The output of a $k$-th approximant circuit can be cast a an approximation
expansion of an arbitrary function. It is sufficient to initalize a register
in the $|0\rangle$ state and measure the output in the computational basis. It
follows

$\bra{1}\prod_{i=0}^{N}U_{i}^{s}\ket{0}=z_{N}(x)$ (57)

where $z_{N}(x)$ can take different forms.

If the fundamental gate is $U^{\mathcal{F}}$, then the output is the truncated
Fourier series

$z_{N}(x)=\sum_{n=-N}^{N}B_{n}e^{i2\pi nx},$ (58)

where $B_{n}$ are free complex coefficients. This result holds for single-
variable functions.

If the fundamental gate is $U^{\rm UAT}$, then the output is a function

$\small
z_{N}(\vec{x})=\sum_{m=0}^{2^{N-1}}c_{m}(\varphi_{1},\ldots,\varphi_{N})e^{i\delta_{m}(\alpha_{1},\ldots,\alpha_{N})}e^{i\vec{w}_{m}(\vec{\omega}_{1},\ldots,\vec{\omega}_{N})\cdot\vec{x}},$
(59)

according to Eq. (43). This result holds for single- and multi-variable
functions.

According to theorems 5 and 6, both expressions can approximate any desired
function.

∎

##  Appendix B UAT for complex functions

In this Appendix we show that the standard formulation of the UAT supports the
approximation of complex function using $e^{i(\cdot)}$ as the activation
function.

Let us follow the approximations according to the UAT of the function

$z(\vec{x})=a(\vec{x})+ib(\vec{x}),$ (60)

using trigonometric functions as $\sigma(\cdot)$,

$\displaystyle
a(x)=\sum_{j=1}^{N}\alpha_{i}\cos(\vec{w}_{j}\cdot\vec{x}+a_{j})$ (61)
$\displaystyle
b(x)=\sum_{j=1}^{N}\beta_{i}\sin(\vec{v}_{j}\cdot\vec{x}+b_{j}).$ (62)

Then

$z(x)=\sum_{j=1}^{N}\alpha_{i}\cos(\vec{w}_{j}\cdot\vec{x}+a_{j})+\\\
i\sum_{j=1}^{N}\beta_{i}\sin(\vec{v}_{j}\cdot\vec{x}+b_{j}),$ (63)

and this equation is can be rearranged as

$z(x)=\sum_{j=1}^{N}\frac{\alpha_{j}}{2}\left(e^{i(\vec{w}_{j}\cdot\vec{x}+a_{j})}+e^{-i(\vec{w}_{j}\cdot\vec{x}+a_{j})}\right)+\\\
\frac{\beta_{j}}{2}\left(e^{i(\vec{v}_{j}\cdot\vec{x}+b_{j})}-e^{-i(\vec{v}_{j}\cdot\vec{x}+b_{j})}\right),$
(64)

what encourages the UAT formulation for complex functions as an analogous to
Eq. (10)

$G(\vec{x})=\sum_{n=1}^{N}\gamma_{n}e^{i\delta_{n}}e^{i\vec{u}_{n}\cdot\vec{x}}.$
(65)

##  Appendix C 2D functions for benchmark

The definitions used for the 2-dimensional functions [23] that serve for
benchmarking our proposed algorithms are define as

${\rm Himmelblau}(x,y)=\\\ =(x^{2}+y-11)^{2}+(x+y^{2}-7)^{2},$ (66)

${\rm Brent}(x,y)=\\\
=\left(\frac{x}{2}\right)^{2}+\left(\frac{y}{2}\right)^{2}+e^{-\left(\left(\frac{x}{2}-5\right)^{2}+\left(\frac{y}{2}-5\right)^{2})\right)},$
(67)

${\rm Threehump}(x,y)=\\\
=2\left(\frac{2x}{5}\right)^{2}-1.05\left(\frac{2x}{5}\right)^{4}+\frac{1}{6}\left(\frac{2x}{5}\right)^{6}+\\\
+\left(\frac{2x}{5}\right)\left(\frac{2y}{5}\right)+\left(\frac{2y}{5}\right)^{2},$
(68)

${\rm Adjiman}(x,y)=\cos(x)\sin(y)-\frac{x}{y^{2}+1},$ (69)

where a normalization to $-1\leq f(x,y)\leq 1$ is applied after this
definition. A graphical representation of these functions is depicted in Fig.
LABEL:fig:2d_functions.

##  Appendix D Experimental methods

Optimal | $p_{1}$ | $p_{2}$ | $p_{3}$ | $p_{4}$ | $p_{5}$ | $p_{6}$ | $p_{7}$ | $p_{8}$ | $p_{9}$ | $p_{10}$ | $p_{11}$ | $p_{12}$
---|---|---|---|---|---|---|---|---|---|---|---|---
parameters | -2.501 | 1.685 | 1.757 | 2.105 | 3.822 | -1.788 | -1.507 | -4.640 | 0.430 | 1.875 | 5.038 | -1.906
Rotational | $Z_{1}$ | $Y_{1}$ | $Z_{2}$ | $Y_{2}$ | $Z_{3}$ | $Y_{3}$ | $Z_{4}$ | $Y_{4}$
angles∗ | $p_{1}+p_{2}x$ | $p_{3}$ | $p_{4}+p_{5}x$ | $p_{6}$ | $p_{7}+p_{8}x$ | $p_{3}$ | $p_{10}+p_{11}x$ | $p_{12}$
$x=-0.5$ | 2.939 | 1.757 | 0.194 | 4.495 | 0.813 | 0.430 | 5.639 | 4.377
$x=0$ | 3.782 | 1.757 | 2.105 | 4.495 | 4.776 | 0.430 | 1.875 | 4.377
$x=1$ | 5.467 | 1.757 | 5.927 | 4.495 | 0.136 | 0.430 | 0.630 | 4.377
∗ Angles between $0$ and $2\pi$ |  |  |  |

Table 1: Optimal parameters and angles obtained for ${\rm ReLU}(x)$ and 4
layers. Above the 12 parameters that define the rotational angles obtained
through simulations. Below the corresponding angles of the 8 rotations for
three different values of $x$. Note that Y rotations are not $x$-dependent,
hence they are equal for all three $x$ values. Figure 9: Complete pulse
sequence. First, the reset protocol is performed which corresponds to two
pulses at the cavity and the qubit frequencies, respectively. Note that the
qubit pulse is of considerably lower amplitude than the cavity pulse. Also,
both pulses have a longer duration than the qubit rotation sequence (timings
not to scale). The “Y” pulses are shown to have different amplitudes to
determine each rotation angle. Finally, the readout corresponds to a pulse at
the cavity frequency which is later read out by a digitizing card.

Figure 10: a) $T_{1}$ measurement with exponential fit. b) Spin-echo
measurement, $T_{2E}$, with exponential fit. c) Sequence performed in the
experiment. Blue boxes represent actual pulses. Logical Y and Z rotations are
explicitly shown below the blue boxes [31]. Note that Z pulses do not
correspond to any microwave pulse, instead subsequent pulses change rotation
axis, indicated by a prime, $Y_{N}^{(N)}$.

The experiment was realized in a dilution fridge with a base temperature of
approximately $20$ mK. The qubit rotation pulses were defined by an arbitrary
waveform generator (AWG) and then upconverted with a microwave signal
generator to the gigahertz frequency range before being sent to the
qubit/cavity system. The signal was low-pass filtered and attenuated by a
total of 50dB before reaching the aluminum cavity. The input port of the
cavity was undercoupled while the output port was overcoupled in order to
maximize the readout signal amplitude. The outgoing signal was amplified by a
cryogenic low noise amplifier and a second amplification stage at room
temperature. The downconversion is performed with the same microwave generator
as used in the upconversion of the measurement pulse, guaranteeing phase
coherence in the downconversion process. The signal is read out in a
digitizer, with a FPGA that demodulates and averages the results before
sending the data to the main measurement computer.

Figure 11: Randomized benchmarking of the DRAG corrected pulses. The fit
corresponds to the expression $Ap^{n}+B$, where $A$ and $B$ have dimensions of
voltage, $n$ is the number of Clifford gates, and $p$ is the fidelity per
gate. $\epsilon=1-p$ is the error per gate.

Figure 9 shows the total pulse sequence, which includes preparation and
measurement pulses in addition to the pulse sequence shown in the main text.
The Y rotations are performed through microwave pulses at the qubit frequency
while the Z rotations, as already stated, are phase changes in subsequent
pulses. An example of the rotation angles for the ${\rm ReLU}(x)$ function in
the 4-layer case is shown in Table 1. The readout consists of a cavity tone at
the frequency of the cavity for the qubit in the $\ket{0}$ state. High/low
transmission corresponds to the qubit being in the ground/excited state,
assuming the system does not escape from the computational basis. Each data
point requires around $50000$ measurements in order to average out the
amplifier noise. A reset protocol that drives the qubit into the ground state
is implemented prior to each individual sequence. This has two benefits. The
first one allows us to start with a qubit state nearly polarized into the
ground state. A second benefit is the reduction in the overall duration of the
experiment, since the waiting time between individual measurements is not
limited by the qubit relaxation time.

Both qubit and cavity pulses are generated at $70$ MHz and then upconverted to
the gigahertz range. The qubit pulses are Gaussian pulses with a total
duration of $21$ ns. A proper DRAG correction is performed with a resulting
error per gate of $\epsilon=0.01$ as shown in Fig. 11. The cavity pulse has a
total length of around $2~{}\mu$s. The reset protocol consists of a pulse
driving the qubit and a pulse driving the cavity mode, with a total duration
of around $2~{}\mu$s.