{'fraction_non_alphanumeric': 0.0364963503649635, 'fraction_numerical': 0.007020317076572597, 'mean_word_length': 4.328214020312113, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Imitating quantum mechanics: qubit-based model for simulation

We present an approach to simulating quantum computation based on a classical model that directly imitates discrete quantum systems. Qubits are represented as harmonic functions in a 2D vector space. Multiplication of qubit representations of different frequencies results in exponential growth of the state space similar to the tensor-product composition of qubit spaces in quantum mechanics. Individual qubits remain accessible in a composite system, which is represented as a complex function of a single variable, though entanglement imposes a demand on resources that scales exponentially with the number of entangled qubits. We carry out a simulation of Shor's algorithm and discuss a simpler implementation in this classical model.


I. INTRODUCTION
Quantum computation promises exponential speed-up over classical computation for certain problems, such as period finding and quantum simulation. Traditional classical simulation of a composite quantum system requires updating each of the 2 N amplitudes characterizing the state of N qubits, according to a Hamiltonian made up of 2 N × 2 N elements.
The exponential growth of the state space with N imposes a severe burden on resources for this type of simulation. Finding classes of quantum computations that can be simulated efficiently is an active field of research [1].
In quantum mechanics, the qubits that comprise a composite system remain accessible, and it is through interactions with individual and pairs of qubits that computation is implemented. For example, a single-qubit transformation affects all 2 N computational basis states of an N-qubit system. It therefore seems that one of the features of quantum systems that enables more efficient computing is the ability to harness the degrees of freedom of a 2 N D vector space by interacting with only N qubits.
Here we present a classical model of discrete quantum systems that is based on representing individual qubits and transformations applied to them. This enables us to address specific qubits in a composite system, the state of which is represented as a complex function of a single variable, and thereby directly replicate the steps in an algorithm as they would be implemented in a quantum system. While the resources required to carry out a computation exactly are comparable to other methods, this model may be compatible with new approximations that would enable simulating more qubits than currently is feasible. Furthermore, the approach of building a classical model based on imitating quantum systems could offer an opportunity to gain insight into the difference in computational power of classical and quantum architectures.

II. REVIEW OF QUANTUM COMPUTATION
A qubit can be realized with any two-state quantum system that can be prepared in a general superposition of basis states of a 2D, complex vector space. For multiple uncoupled qubits, the state of the composite system is given by the tensor product of the individual states, and the number of computational basis states grows exponentially with the num-ber of qubits. For example, the state of an N-qubit system, with each qubit in an equal superposition of computational basis states |0 and |1 , is given by the state vector, Application of a unitary operation to a qubit that is part of a composite system, which constitutes a step in an algorithm, affects all states in the superposition simultaneously, illustrating the massive parallelism inherent in quantum computation.
Any quantum algorithm can be approximated arbitrarily closely using just single qubit operations and a generic two-qubit interaction, such as the controlled-NOT (CNOT) gate [2].
The effects of these operations can be visualized as rotations and inversions of the 2 Ndimensional quantum-computer state vector. The state in Eq. (1), constructed as a product of individual qubit states, is a special case. Almost all of the states the system can occupy in its vector space will be non-separable, implying that entanglement is required for general computation.
Qubits and operations on them are subject to perturbations from the environment and experimental imperfections. In general, it is believed that errors due to decoherence grow exponentially with the number of qubits in a system [3]. Realizable quantum computation relies on the ability to diminish the effects of these errors-quantum error correction and faulttolerant quantum computation exploit entanglement and the discrete nature of quantum systems to make this possible.
This brief introduction to the fundamental elements of quantum computation emphasizes the role played by the mathematical structure of the single-and multiple-qubit vector spaces.
Quantum systems require this mathematical description, and our classical model is developed according to this description by building into it the same state-space structure. The result is a new method of simulation and an architecture that may offer insight into the fundamental advantages of quantum systems for computing.

III. INDIVIDUAL QUBITS
For the representation of a qubit we use a harmonic function with frequency ω. Orthogonal functions sin(ωt) and cos(ωt) serve as convenient basis states and span a 2D vector space. We assign these basis functions the role of the computational basis states of a qubit, Applying a general unitary transformation U to a qubit ψ, requires isolating the coefficients α and β; each coefficient can then be multiplied by the corresponding transformed basis function, yielding the transformed state: Orthogonality of the basis functions makes it straightforward to isolate the coefficients by taking the inner product of the corresponding function with ψ(t): A general transformation is illustrated in Fig. 1(a).
The modulus squared of the coefficient, or amplitude, of a basis function gives the corresponding "measurement probability". The function representing a qubit can be replaced with one or the other basis function according to these probabilities in order to represent the measurement process. The ability to determine both measurement probabilities for a given state eliminates the need to introduce and carry along normalization coefficients-the relative probabilities can be determined at the time of measurement.

A. 2 N D Vector Space
This model can be extended to composite systems by using a different frequency for the basis functions for each two-state system, creating a new 2D vector space for each qubit. The mapping of quantum states to functions for composite systems becomes |0 n ⇐⇒ sin(ω n t) |1 n ⇐⇒ cos(ω n t), n = 0, 1, ..., N − 1, where n refers to the nth qubit and N is the total number in the system.
This is analogous to the tensor-product state for a composite quantum system in Eq. (1), with the mapping Here, b n is the binary value representing the state of the nth qubit of a quantum system, h n is the basis function (sine or cosine) representing the nth qubit in our model, and H N,j (t) is the jth of the 2 N combinations of products of h n .
The functions H N (t) that naturally arise when representing composite systems look like N-qubit computational basis states, and we would like to determine whether they too span a state space that grows exponentially with qubit number. This will be the case if all of the 2 N functions are orthogonal. It is easy to see by expanding the products of harmonic functions in terms of sum and difference frequencies that, for N qubits, the H N (t) are comprised of The Ω l are all multiples of a fundamental frequency given by the greatest common divisor of the qubit frequencies, . The orthogonality of the individual Fourier components can be shown to lead to orthogonality of the H N (t) for few qubits; the three-qubit case is demonstrated in Appendix A.

Orthogonality of the H N (t)
To demonstrate orthogonality in the general case when the 2 N −1 Fourier frequencies are unique, we consider the inner product between two N-qubit functions H N, where factors for a given qubit have been grouped together [5]. Each product h j,n (ω n t)h k,n (ω n t) can be written as a function of frequency 2ω n , as either 1 2 sin(2ω n t) or 1 2 (1 ± cos(2ω n t)). The integrand in Eq. (9) can then be seen to consist of three types of terms. First, there will always be a term that is a product of a function for each qubit, . This can be written as a sum of Fourier components with frequencies that are twice those of the H N (t) and are, therefore, also multiples of Ω fund . Because integration of a harmonic function over an integral multiple of its period yields zero, this term's contribution to the inner product H N,j (t) · H N,k (t) vanishes.
Second, there can be terms that only include factors for some qubits, such as Fourier frequencies for these terms are also multiples of Ω fund -the fundamental frequency is the greatest common divisor of the set of all qubit frequencies, and necessarily divides any subset of them. These terms therefore also vanish when integrated over an interval of 2π/Ω fund .
Finally, the integrand in Eq. (9) can have a term of unity (times 1/2 N ). This only occurs when all qubit functions are the same for H N,j (t) and H N,

Redundant Frequencies
This argument is only valid if all of the Fourier frequencies Ω l are unique. If there are at least two combinations of qubit frequencies that give the same Fourier frequency, we can write N n=1 σ n,l ω n = N n=1 σ n,m ω n , for Ω l = Ω m . Terms that enter this equation with the same sign for each Fourier frequency cancel, and the remaining terms give ω a + ω b + . . . = ω α + ω β + . . ., where the frequencies have been arranged so that all signs are positive. When considering all inner products H N,j (t)·H N,k (t), all possible combinations of harmonic factors in the integrand in Eq. (9) will arise; for some inner product, there will be a term in the integrand like h(2ω a t)h(2ω b t) . . . h(2ω α t)h(2ω β t) . . ., with Fourier frequencies that include For the case(s) in which this frequency is the argument of a cosine, the constant term results in a nonzero integral, and the different H N (t) in this case are not orthogonal.
Therefore, for sets of qubit frequencies {ω n } that result in 2 N −1 unique Fourier frequencies, the functions H N (t) that naturally arise when representing composite systems are orthogonal and span a 2 N -dimensional space. Unique Fourier frequencies can be ensured by using a qubit-frequency definition such as ω n = ω/2 n−1 .

B. Linear Operations
In quantum computation, single-qubit operations along with a generic two-qubit interaction, such as a CNOT gate, are universal. The general approach to implementing operations in our model of composite quantum systems is the same as for a single qubit-we need to isolate the factor multiplying each basis function sin(ω n t) or cos(ω n t) for a particular qubit.
In this case, these factors will be expressions involving other qubit basis functions. Once isolated, they can be multiplied by the transformed basis functions and these recombined to generate the transformed composite function.
Consider a general Ψ N (t), similar to Eq. (7) but with arbitrary coefficients for the H N (t).
We can write Ψ N as a sum of two parts, one with terms that include cos(ω n t) and one with terms that include sin(ω n t): The H (n) k,N (t) are products of harmonic functions, where h is cosine or sine, and a k , b k are coefficients for the cos(ω n t), sin(ω n t) terms. F  s (t) are the functions that we need to be able to isolate to apply a linear transformation to qubit n; determining these functions can be considered to be "addressing qubit n." For small N, a procedure similar to the one for a single qubit can be adapted. Multiplication of Ψ N by the relevant basis function for the qubit leads to a different spectrum for terms containing that basis function. These different frequencies could be selected from the terms containing the orthogonal basis function, enabling the qubit to be addressed. As the qubit number grows, however, the number and density of frequencies grow dramatically, making this process unfeasible.
A more general procedure can be used which determines F (n) c F (n) s exactly using the orthogonality of the H N (t). An inner product can be imposed between Ψ N and a projector that forces all of the terms with one basis function for qubit n to vanish while preserving the others. The construction of the projector for a given system is straightforward.
A linear combination of all of the H N (t) for a system of N qubits can be generated by putting each qubit into an equal superposition of basis functions as in Eq. (7). We define a similar function, the generator for qubit n, as the product of equal superpositions of computational basis states for all qubits in the system except qubit n: G (n) N (t) = sin(ω 1 t) + cos(ω 1 t) sin(ω 2 t) + cos(ω 2 t) . . . sin(ω n−1 t) + cos(ω n−1 t) sin(ω n+1 t) + cos(ω n+1 t) . . . sin(ω N t) + cos(ω N t) .
If this is multiplied by cos(ω n t) sin(ω n t) , the resulting function's inner product with Ψ N (t) gives the sum of the amplitudes of the terms in F (n) s (t) , but the functional form is lost. We can salvage the functional dependence by transferring it to a second variable introduced to exactly replicate the dependence on t: When this generator is multiplied by cos(ω n t) (sin(ω n t)), we get the projector for Taking the inner product of Ψ N (t) and P This is an exact technique for addressing a qubit that is part of a composite system. The rest of the procedure for applying a transformation follows as in the single-qubit case and is illustrated in Fig. 1(b).
Iteration of this technique of addressing qubits allows for multiple-qubit gates. For example, for a controlled-NOT gate with qubit n 1 as the control and n 2 as the target, the gate would begin with determination of F Gates involving more than two qubits can be implemented by further iteration.
The measurement probability for a basis function is determined by π/Ω fund 0 F (n) * (t) · F (n) (t) dt [6]. Due to the orthogonality of the H N (t), all cross terms in the inner product vanish and the result is the sum of the moduli squared of the amplitudes of all of the terms containing the corresponding basis function.

C. Scaling of Required Resources
The state of a general composite system can be represented as where ψ represents an individual, unentangled qubit, and Ψ characterizes N e entangled qubits. While unentangled qubits can be stored and processed individually and with little overhead, the resources required to exactly represent entangled qubits scale exponentially with N e [7]. The qubit frequencies and the maximum Fourier frequency can be kept finite, but the fundamental frequency decreases at least exponentially with number. The interval over which Ψ needs to be defined is given by the integration interval required for addressing a qubit. In Eq. (14), the integration limit of π/Ω fund yields exact values for the F (n) ; coupled with the necessary resolution imposed by the highest Fourier frequency, on order of Ω max /Ω fund points are required to define Ψ.
We can consider the impact on addressing a qubit-both for a unitary transformation and for measurement-of simply truncating all of the functions that arise in a calculation.
For unitary transformations, we determine the accuracy of F (n) c (τ, t) and F (n) s (τ, t), the functions determined by integrating Eq. (14) to τ rather than to π/Ω fund , by comparing s (τ, t) sin(ω n t) to Ψ(t). We define a parameter δ (n) (τ ) to represent the error in F (n) (τ, t): c (x, t)Ψ(t) dt cos(ω n x) whereΨ is Ψ normalized over the interval 0 to τ , and N(τ ) is the normalization constant for F (n) c (τ, t) cos(ω n t) + F (n) s (τ, t) sin(ω n t) over the same interval. In Fig. 2(a) we plot δ(τ ) for the state Ψ(t) = Ne n=1 cos(ω n t) + Ne n=1 sin(ω n t), with ω n = ω/2 n−1 and N e = 5 through 9. We evaluate δ for the case of addressing the first qubit. The s , which is exact for an integration limit of π/Ω fund , abruptly becomes less precise as the integration interval is reduced. Any calculation involving many gates will likely require a value for δ on the steep part of the curve, imposing an integration interval that scales exponentially with N e .
To assess the effect of truncation on measurement probabilities, we truncate the integrals used to determine F (n) c and F (n) s as above, and then integrate the square of each. We look at the ratio of the truncated probability to measure sine versus cosine as a function of integration time: This ratio is plotted in Fig. 2(b) for the same state used above, for which the actual ratio is one. The graph shows that reaching the actual ratio of P s to P c also scales exponentially with N e . However, precise values for measurement probabilities are often not needed and useful qualitative information can be obtained for integration intervals that are shorter than π/Ω fund . For instance, for this example the curves indicate that for integration limits beyond π/(4 Ω fund ), the ratio r is about 0.25, of the same order as the actual value. The qubits involved in implementing this algorithm are divided into two registers, the states of which are treated as integers according to the states of the associated qubits.
The first step in the procedure is to prepare the first register in a superposition of all computational basis states, by applying a Hadamard transform to each of the N 1 qubits in the register [9]. A gate U applied to both registers produces the entangled state If the second register is measured, it collapses to |a x 0 (mod N) for some x 0 . The first register ends up in a superposition of all states |x ′ for which a x ′ (mod N) = a x 0 (mod N), leaving the system in the state Application of the QFT to the first register imposes interference that results in a superposition of states |x that are close to integral multiples of the inverse period,x ≈x κ = κ(2 N 1 /p), for integer κ. Measurement yields an integer close to one of thex κ , and after several iterations the period p can be determined.
The minimum number of qubits required for each register is N 1 = log 2 N 2 and N 2 = log 2 N.
This ensures that the second register is large enough to represent p, which satisfies p ≤ N, and that the first register is large enough to give a unique value for p from the QFT (see reference [8]). We apply our model to the factorization of N = 21 using a = 2, the first integer co-prime with 21. This requires 14 qubits, nine for the first register and five for the second; the alogorithm for our example is illustrated in Fig. 3. The qubits are labeled 1 through 14, with the convention that qubit 1 (14) is the most (least) significant qubit for the first (second) register. Qubit n is represented using the frequency ω n = ω/2 n−1 , and the function Ψ representing the state of the system is defined with a resolution of 1/ω over an interval of 2π/Ω fund = 2π(2 nmax−1 ) [10]. In Fig. 4 we show the function representing the state of the system at various stages in the calculation, as denoted by the dashed lines in Fig. 3(a).
We implement U by generating the output state, shown in Fig. 4(b), by summing all functions representing |x |a x (mod N) over x = 0 to x = 2 14 − 1 [11]. From here, we measure

B. Simplifications in a Classical Model
There is a dramatic simplification to the factoring algorithm when using a classical model for simulation. The need for the QFT stems from the fact that, in a quantum system, measurement of the state in Eq. (19) results in one of the states in the superposition, with no opportunity to learn the others. Repetition of the algorithm to that point likely results in a different x 0 , preventing the period from being learned in successive iterations. In a classical system, the state in Eq. (19) can be measured as many times as necessary to determine the period p. If we apply this simplified scheme to the state Ψ in Fig. 4(c), we find equal probability for any x ′ satisfying 2 x ′ (mod 21) = 16; the first eight peaks are shown in Fig. 5(e). In addition to avoiding all of the gates required for the QFT, no imaginary numbers are required, and most importantly, we save on qubits. The first register, whose size for Shor's algorithm is dictated by the QFT stage, in this case only needs enough qubits to represent p, and p ≤ N. This provides a savings on order of log 2 N qubits compared to the quantum case. Applying this simplified factoring algorithm to N = 21 would require only 10 qubits, five for each register.

VI. CONCLUSION
We have presented a classical, qubit-based model of discrete quantum systems that offers a new framework for simulating quantum computations by providing access to individual qubits and their interactions. The dimension of the state space for a composite system grows exponentially with qubit number, and individual qubits continue to be accessible.
Application to Shor's algorithm highlights the features of the model in action. The resources required for implementation scale exponentially with the number of entangled qubits, yet it is possible to save on qubits in a classical model.
The H N (t) can be Fourier decomposed by expanding the products of harmonics h n in terms of sum and difference frequencies.
In this case and for small numbers of qubits, all of the different inner products can be verified to be zero, and H N,j · H N,j = (π/4 Ω fund ).