{'fraction_non_alphanumeric': 0.04054985604801103, 'fraction_numerical': 0.02043712744819756, 'mean_word_length': 4.035116374030216, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Quantum circuit for three-qubit random states

We explicitly construct a quantum circuit which exactly generates random three-qubit states. The optimal circuit consists of three CNOT gates and fifteen single qubit elementary rotations, parametrized by fourteen independent angles. The explicit distribution of these angles is derived, showing that the joint distribution is a product of independent distributions of individual angles apart from four angles.


I. INTRODUCTION
Quantum information science (see e.g. [1] and references therein) has received an increased attention in recent years due to the understanding that it enables to perform procedures not possible by purely classical resources. Experimental techniques to manipulate increasingly complex quantum systems are also rapidly progressing. One of the central issues is on the one hand to control and manipulate delicate complex quantum states in an efficient manner, but on the other hand at the same time to prevent all uncontrollable influences from the environment. In order to tackle such problems, one has to understand the structure and properties of quantum states. This can be done either through studies of particular states in a particular setting, or through focusing on the properties of the most generic states.
Random quantum states, that is states distributed according to the unitarily invariant Fubini-Study measure, are good candidates for describing generic states. Indeed, they are typical in the sense that statistical properties of states from a given Hilbert space are well described by those of random quantum states. Also, they describe eigenstates of sufficiently complex quantum systems [2] as well as time evolved states after sufficiently long evolution. Not least, because random quantum states possess a large amount of entanglement they are useful in certain quantum information processes like quantum dense coding and remote state preparation [3,4]. They can be used to produce random unitaries needed in noise estimation [5] and twirling operations [6]. In addition, as random states are closely connected to the unitarily invariant Haar measure of unitary matrices, the unitary invariance makes theoretical treatment of such states simpler.
Producing such states therefore enables to make available a useful quantum resource, and in addition to span the space of quantum states in a well-defined sense. Therefore several works have recently explored different procedures to achieve this goal. It is known that generating random states distributed according to the exact invariant measure requires a number of gates exponential in the number of qubits. A more efficient but approximate way to generate random states uses pseudo-random quantum circuits in which gates are randomly drawn from a universal set of gates. As the number of applied gates increases the resulting measure gets increasingly close to the asymptotic invariant measure [7]. Some bipartite properties of random states can be reproduced in a number of steps that is smaller than exponential in the number of qubits. Polynomial convergence bounds have been derived analytically for bipartite entanglement [8,9,10] for a number of pseudo-random protocols. On the numerical side, different properties of circuits generating random states have been studied [11]. In order to quantify how well a given pseudo-random scheme reproduces the unitarily invariant distribution, one can study averages of low-order polynomials in matrix elements [12]. In particular, one can define a state or a unitary k-design, for which moments up to order k agree with the Haar distribution [13,14]. Although exact state k-designs can be built for all k (see references in [14]) they are in general inefficient. In contrast, efficient approximate k-designs can be constructed for arbitrary k (for the specific case of 2-design see [9]).
The pseudo-random circuit approach can yield only pseudo-random states, which do not reproduce exactly the unitarily invariant distribution. The method has been shown to be useful for large number of qubits, where exact methods are clearly inefficient. However, for systems with few qubits, the question of asymptotic complexity is not relevant. It is thus of interest to study specifically these systems and to find the most efficient way -in terms of number of gates -to generate random states distributed according to the unitarily invariant measure. This question is not just of academic interest since, as mentioned, few-qubit random unitaries are needed for e.g. noise estimation or twirling operations. Optimal circuits for small number of qubits could also be used as a basic building block of pseudo-random circuits for larger number qubits, which might lead to faster convergence. In addition, systems of few qubits are becoming available experimentally, and it is important to propose algorithms that could be implemented on such small quantum processors, and which use as little quantum gates as possible. Indeed, quantum gates, and especially two-qubit gates, are a scarce resource in real systems which should be carefully optimized.
In this paper we therefore follow a different strategy from the more generally adopted approach of using pseudo-random circuits to generate pseudo-random states, and try and construct exact algorithms generating random states for systems of three qubits. In the language of k-designs such algorithms are exact ∞-designs. We present a circuit composed of one-qubit and twoqubit gates which produces exact random states in an optimal way, in the sense of using the smallest possible number of CNOT gates. The circuit uses in total 3 CNOT gates and 15 one-qubit elementary rotations. Our procedure uses results recently obtained [15] which described optimal procedures to transform a three-qubit state into another. Our circuit needs 14 random numbers which should be classically drawn and used as parameters for performing the one-qubit gates. The probability distribution of these parameters is derived, showing that it factorizes into a product of 10 independent distributions of one parameter and a joint distribution of the 4 remaining ones, each of these distributions being explicitly given. Since we had to devise specific methods to compute these distributions, we explain the derivation in some details, as these methods can be useful in other contexts.
After presenting the main idea of the calculation in Section II, we start by treating the simple case of twoqubit states in Section III. We then turn to the threequbit case and first show factorization of the probability distribution for a certain subset of the parameters (Section IV), the remaining parameters being treated in Section V. The full probability distribution for three qubits is summarized in Section VI.

II. THE QUANTUM CIRCUIT
Formally, a quantum state |ψ can be considered as an element of the complex projective space P N −1 , with N = 2 n the Hilbert space dimension for n qubits [16]. The natural Riemannian metric on P N −1 is the Fubini-Study metric, induced by the unitarily invariant Haar measure on U (N ). It is the only metric invariant under unitary transformations. To parametrize P N −1 one needs 2N − 1 independent real parameters. Such parametrizations are well-known, for instance using Hurwitz parametrization of U (N ) [17]. However, they do not easily translate into one and two-qubit operations, as desired in quantum information. In Ref. [15], optimal quantum circuits transforming the three-qubit state |000 into an arbitrary quantum state were discussed. In the case of three qubits, a generic state can be parametrized up to a global phase by 14 parameters. The quantum circuit requiring the smallest amount of CNOT gates has three CNOTs and 15 one-qubit gates depending on 14 independent rotation angles. From [15] it is possible (see Appendix) to extract the circuit depicted in Fig. 1, expressed as a series of CNOT gates and single qubit rotations, where Z-rotation is Z θ = exp (−iσ z θ) and Yrotation is Y θ = exp (−iσ y θ) with σ y,z the Pauli matrices. The circuit allows to go from |000 to any quantum state (up to an irrelevant global phase). It therefore provides a parametrization of a quantum state |ψ by angles θ 1 , . . . , θ 14 .
In order to generate random vectors distributed according to the Fubini-Study measure, it would of course be possible to use e. g. Hurwitz parametrization to generate classically a random state, and then use the procedure described in [15] to find out the consecutive steps that allow to construct this particular vector from |000 . However this procedure requires application of a specific algorithm for each realization of the random vector. Instead, our aim here is to directly find the distribution of the θ i such that the resulting |ψ is distributed according to the Fubini-Study measure. This is equivalent to calculating the invariant measure associated with the parametrization provided by Fig. 1 in terms of the angles θ 1 , . . . , θ 14 . Geometrically, the Fubini-Study distance D FS is the angle between two normalized states, cos (D FS ) = | ψ|φ |. The metric induced by this distance is obtained by taking |φ = |ψ + |dψ , getting where , is the usual Hermitian scalar product on C N [18]. If a state |ψ is parametrized by some parameters θ 1 , θ 2 , . . . then the Riemannian metric tensor g ij is such that ds 2 = g ij dθ i dθ j and the volume form at each point of the coordinate patch, directly giving the invariant measure, is then given by dv = det(g) dθ i . Thus the joint distribution P (θ) of the θ i is simply obtained by calculating the determinant of the metric tensor given by (1) with the parametrization |ψ = |ψ(θ) , θ = (θ 1 , . . . , θ 14 ). Unfortunately the calculation of such a 14 × 14 determinant for n = 3 qubits is intractable and one has to resort to other means. Let us first consider the easier case of n = 2 qubits, where by contrast the calculation can be performed directly.

III. A SIMPLE EXAMPLE: THE TWO-QUBIT CASE
A normalized random 2-qubit state |ψ depends, up to a global phase, on 6 independent real parameters. A circuit producing |ψ from an initial state |00 is depicted in Fig. 2. One can easily calculate the parametrization of the final state |ψ(θ 1 , . . . , θ 6 ) in terms of all six angles, thus directly obtaining the metric tensor g ij from (1). Square root of the determinant of g then gives an unnormalized probability distribution of the angles as (see also [19]). Several observations can be made about this distribution. First, the three rotations applied on the first qubit (top wire in Fig. 2) after the CNOT gate represent a random SU(2) rotation, for which the Yrotation angle is distributed as P (θ 3 ) ∼ | sin 2θ 3 | and the Z-rotation angles are uniformly distributed [17]. Secondly, angle θ 1 gives the eigenvalue of the reduced density matrix, λ = sin 2 θ 1 , for which the distribution is well known, see, e.g., [20]. The third observation is that, remarkably, the joint distribution (2) of all 6 angles factorizes into 6 independent one-angle distributions.

IV. FACTORIZATION OF THE THREE-QUBIT DISTRIBUTION FOR ANGLES θ7 TO θ14
Let us now turn to our main issue, which is the distribution of angles in the three-qubit case. In order to have an indication whether the distribution of an angle θ i factorizes, we numerically computed the determinant det(g) of the metric tensor as a function of θ i with the other angles fixed. We also numerically computed the marginal distribution of θ i by using the procedure given in the appendix to find the angles corresponding to a sample of uniformly distributed random vectors. If the distribution for a given angle θ i factorizes, these two numerically computed functions should match (up to a constant factor). This is what we observed for all angles but four of them (angles θ 3 to θ 6 ).
In order to turn this numerical observation into a rigorous proof, we are going to show in this section that the distributions for angles θ 7 to θ 14 indeed factorize. In the next section we will complete the proof by dealing with the cases θ 1 to θ 6 . The explicit analytical expression of the probability distribution for individual angles will be given in Section VI.
Let us denote by C the circuit of Fig. 1 and by C(θ) the unitary operator corresponding to it, so that |ψ(θ) = C(θ)|000 . Because circuits C span the whole space of 3-qubit states, any unitary 3-qubit transformation V maps parameters θ to new parametersθ such that V |ψ(θ) = |ψ(θ) . We denote byC the circuit parametrized by anglesθ corresponding to performing C followed by V . It is associated with the unitary operator C(θ) such that C(θ)|000 = V C(θ)|000 . Unitary invariance of the measure implies for P (θ) that with J the Jacobian of the transformation θ →θ and |.| denotes the determinant. Note that Eq. (3) is not a simple change of variables, as the same function P appears on both sides of the equation. The Jacobian matrix J for transformation V from angles θ toθ, V |ψ(θ) = |ψ(θ) , tells how much do the anglesθ of |ψ(θ) change if we vary angles θ in |ψ(θ) keeping transformation matrix V fixed. Choosing V that sets some angles θ j in circuitC to a fixed value, say zero, and at the same time showing that |J | depends only on these angles θ j , would prove factorization of P (θ) with respect to angles θ j through Eq. 3.

A. Gates 7-12 and 14
The simplest case is that of gates at the end of the circuit C of Fig. 1, e.g., gate Y θ14 . For V we take Yrotation by angle −u on the third qubit, V = Y −u . It defines a mapping θ →θ such thatθ i = θ i for i ≤ 13 andθ 14 = θ 14 − u. Matrix elements of the Jacobian, i.e. partial derivatives J jk = ∂θ j /∂θ k , are equal to the Kronecker symbol δ jk . The Jacobian is equal to an identity matrix and its determinant is one. Equation (3) taken at u = θ 14 then gives P (θ 1 , . . . , θ 13 , 0) = P (θ 1 , . . . , θ 13 , θ 14 ), from which one concludes that the distribution for θ 14 factorizes and is in fact uniform (unless noted otherwise P 's are not normalized). The same argument holds for the two other rotations by angles θ 12 and θ 9 applied at the end of each qubit wire.
Proceeding to angle θ 8 one could use V = Y −u8 Z −u9 applied on the first qubit and show that the Jacobian depends only on θ 8 and θ 9 , while at u 8 = θ 8 and u 9 = θ 9 one getsθ 8 =θ 9 = 0, from which factorization of θ 8 would follow from Eq. 3. There is however a simpler way. Observe that the three single-qubit gates with angles θ 7 , θ 8 and θ 9 on the first qubit span the whole SU(2) group. Therefore, for any one-qubit unitary V , gates V Z θ9 Y θ8 Z θ7 can be rewritten as Zθ 9 Yθ 8 Zθ 7 , without affecting other θ's. The distribution of these three angles must therefore be the same as the distribution of corresponding SU(2) parameters. Note that the same argument can be applied in the 2-qubit case of Section III. As a consequence, the distribution of angles for gates Z − Y − Z at the end of the circuit should be the same in both cases, that is the distribution of θ 7 is uniform while that of θ 8 is proportional to | sin 2θ 8 |. Similarly, one can show that the distribution for the angles θ 10 to θ 12 is the same as for angles θ 7 to θ 9 .

B. Gate 13
As opposed to gates 10-12, for gate 13 we can not use the analogy with the 2-qubit circuit (Fig.2) because the two gates 13 and 14 on the third qubit do not span the whole SU(2) group. Therefore a different argument should be used. In what follows we show that the joint distribution for angles θ 13 and θ 14 can be factorized out of the full distribution. Since it has been shown in Subsection IV A that angle θ 14 factorizes, this will prove that the distribution for θ 13 also factorizes.

V. JOINT THREE-QUBIT PROBABILITY DISTRIBUTION FOR ANGLES θ1 TO θ6
In the preceding section, we have shown that the distribution for angles θ 7 to θ 14 factorizes. As was mentioned, numerical observations indicated us that the distribution for angles θ 1 and θ 2 should also factorize, but that it is not the case for the joint distribution of θ 3 , . . . , θ 6 .
As we were not able to directly prove by the same methods as above that the distributions for θ 1 and θ 2 factorize, we use a different strategy. Namely, we first assume that this factorization is true, then we compute the distributions under this assumption, and the knowledge of the answer allows us to prove a posteriori that it is indeed the correct probability distribution.
If the factorization holds, the distribution for θ 1 and θ 2 is easily calculated from the matrix g using symbolic manipulation software, by replacing angles θ j , j ≥ 3, in g by suitably chosen simple values, so that the 14 × 14 determinant giving the volume form can now be handled. This yields, up to a normalization constant, P 1 (θ 1 ) = cos 5 θ 1 sin 9 θ 1 (10) P 2 (θ 2 ) = cos 5 2θ 2 sin 3 2θ 2 .
The joint distribution of θ 3 , . . . , θ 6 can not be further factorized, and requires heavy calculations. Indeed, even replacing all angles but θ 3 , ..., θ 6 by numerical values the determinant det(g) of the metric tensor given by (1) still depends on 4 variables, which is too much for it to be evaluated by standard software. We thus proceed as follows. First one can show that det(g) can be put under the form det(g) = a pqrs cos(2pθ 3 + 2qθ 4 +2rθ 5 + 2sθ 6 ), (12) with the sums running over all q, r but only even values of p and s. Because of the parity of cos, there are M = 8509 independent coefficients a pqrs . Evaluating numerically the determinant at M random values of the angles one gets an M × M linear system that can be solved numerically. If the values of the coefficients of the matrix g ij are multiplied by a factor 4, then one is ensured (from inspection of det(g)) that the a pqrs are rationals of the form k/2 9 , k ∈ Z. This allows to deduce their exact value from the numerical result. We are left with 6998 nonzero terms in det(g), and terms with odd q or r do not exist. We then suppose that det(g) can be expanded as This assumption is validated a posteriori, since a solution of the form (13) can indeed be found. There are 4851 coefficients b pqrs , which can be obtained by identifying term by term coefficients in the expansion of ( det(g)) 2 and det(g). We have to solve a system of quadratic equations Gathering together terms (±p, ±q, ±r, ±s) one can simplify the sum (13) to a sum of 96 terms of the form c pqrs cos(pθ 3 ) cos(qθ 4 ) cos(rθ 5 ) sin(sθ 6 ). Expanding this expression in powers of cos(2θ 5 ) and sin(2θ 5 ) and simplifying separately each coefficient we finally get P (θ 3 , θ 4 , θ 5 , θ 6 ) = sin 2θ 5 sin 4θ 3 sin 2 ϕ 1 cos ϕ 2 , (15) where α|β = cos ϕ 1 and β|β = cos ϕ 2 with |α , |β given by Eq. (7). Recall that |β is the bit-flip transform of |β , |β = σ x |β . Note that sin 2θ 3 = α|β . Angles where c i = cos 2θ i and s i = sin 2θ i . We do not have a general argument to explain this remarkable expression of the distribution in terms of the scalar products of |α , |β and |β .
To complete the proof for the joint distribution P (θ 1 , . . . , θ 6 ) it remains to be checked that the determinant of the metric tensor g with angles θ 7 to θ 14 replaced by constants is indeed proportional to P 1 (θ 1 )P 2 (θ 2 )P (θ 3 , θ 4 , θ 5 , θ 6 ). This a posteriori verification is easier to handle symbolically than the full a priori calculation of the 14 × 14 determinant. Indeed, the determinant can first be reduced to an 8 × 8 determinant by Gauss-Jordan elimination. The remaining determinant can be expanded as a trigonometric polynomial. Although symbolic manipulation software do not allow to simplify the coefficients of this polynomial, they are able to check that these coefficients match those of the expected distribution. We proved in that way that the difference between the determinant det(g) and our expression is identically zero. This gives a computerassisted but rigorous proof for the distribution of angles θ 1 to θ 6 .

VII. CONCLUSION
In this work, we constructed a quantum circuit for generating three-qubit states distributed according to the unitarily invariant measure. The construction is exact and optimal in the sense of having the smallest possible number of CNOT gates. The procedure requires a set of 14 random numbers classically drawn, which will be the angles of the one-qubit rotations, and whose distribution has been explicitly given. Remarkably, we have shown that the distribution of angles factorizes, apart from that of four angles. The circuit can be used as a three-qubit random state generator, thus producing at will typical states on three qubits. It could be also used as a building block for pseudo-random circuits in order to produce pseudo-random quantum states on an arbitrary number of qubits. At last, it gives an example of a quantum algorithm producing interesting results which could be implemented on a few-qubit platform, using only 18 quantum gates, of which 15 are one-qubit elementary rotations much less demanding experimentally.
We thank the French ANR (project INFOSYSQQ) and the IST-FET program of the EC(project EUROSQIP) for funding. MŽ would like to acknowledge support by Slovenian Research Agency, grant J1-7437, and hospitality of Laboratoire de Physique Théorique, Toulouse, where this work has been started.

APPENDIX: THE PARAMETRIZATION CORRESPONDING TO THE THREE-QUBIT CIRCUIT
In this Appendix, we explain how to obtain the angles θ i of the circuit (Fig. 1) for a given |ψ , based on the discussion in [15]. This justifies the use of these angles as a parametrization of the quantum states. We start from a state |ψ , and transform it by the inverse of the different gates of Fig. 1 to end up with |000 , specifying how the angles θ i are obtained in turn. More details can be found in [15]. A generic three-qubit state |ψ can be written in a canonical form as a sum of two (not normalized) product terms [21], where |ω i are one-qubit states, |ω ⊥ 1 is a one-qubit state orthogonal to |ω 1 and |ξ 23 is a two-qubit state of the second and third qubits. The angle θ 9 is chosen such that the Z-rotation of angle −θ 9 eliminates a relative phase between the coefficients of the expansion of |ω 1 into |0 and |1 . (Note that because we are using the circuit in the reverse direction the angles of rotations have opposite signs). A subsequent Y-rotation with angle −θ 8 results in the transformation |ω 1 → |0 (up to a global phase). Similarly, rotations of angles −θ 12 and −θ 11 rotate |ω 2 into |0 . After applying rotations of angles −θ 8 , −θ 9 , −θ 11 and −θ 12 the state has become of the form |ψ ′ = |00γ + |1 (|0γ 1 + |1γ 2 ) (up to normalization). Two rotations on the third qubit of angles −θ 13 and −θ 14 are now chosen so as to rotate |γ 1 into some new state |γ ′ while |γ 2 is rotated, up to normalization, into σ x |γ ′ . It was shown in [15] that this can always be done by writing the normalized |γ 1,2 as |γ 1,2 = cos φ 1,2 |0 + e iξ1,2 sin φ 1,2 |1 , and then θ 14 is a solution of − tan (2θ 14 ) = cos 2φ 1 + cos 2φ 2 sin 2φ 1 cos ξ 1 + sin 2φ 2 cos ξ 2 , (A.2) while θ 13 = −(δ 1 + δ 2 )/4, where δ's are relative phases in Y −θ14 |γ 1,2 = e iδ1,2 cos κ|0 + sin κ|1 . Acting with a CNOT 23 gate on the resulting state one obtains a quantum state for the three qubits of the form |ψ ′′ = |00χ 1 + |1ω 4 χ 2 , with χ 2 = γ ′ . The Z-rotation angle −θ 10 on the second qubit is now determined so as to eliminate a relative phase between the expansion coefficients of |ω 4 , making them real up to a global phase. On the third qubit we now apply three rotations of angles −θ 4 , −θ 5 , and −θ 6 to bring |χ 1 to |χ ′ and |χ 2 into σ x |χ ′ , eliminating also a relative phase. Then a CNOT 13 is applied. At this point (after the second CNOT in Fig. 1, counting from right, but without the θ 7 rotation), the state has become of the form |ψ ′′′ = cos θ 1 |00ω 6 + e iτ sin θ 1 |1ω 5 ω 6 , where the one-qubit states |ω 5 and |ω 6 are normalized and real. With θ 7 we now eliminate the relative phase τ , and with an Y-rotation of angle −θ 3 the third qubit is brought to the state |0 . Then the combination of two Y-rotation of angles θ 2 and −θ 2 with a CNOT 12 brings the second qubit to |0 , and the last rotation of angle −θ 1 on the first qubit yields the final state |000 . Note that in the circuit of Fig. 1 the two Z-rotations of angles θ 7 and θ 10 commute with CNOT gates if they act on the control qubit. This is the reason why the rotation of angle θ 7 can be applied at any point between θ 1 and θ 8 and, similarly, θ 10 can be applied at any point between θ 2 and θ 11 .