## How quantum and evolutionary algorithms can help each other: two examples

Shailendra Bhandari 1,2,3,* , Stefano Nichele 1,2,3,4 , Sergiy Denysov 1,3 , and Pedro G. Lind 1,2,3,5

1 Department of Computer Science, OsloMet - Oslo Metropolitan University, P .O. Box 4 St. Olavs plass, N-0130 Oslo, Norway

- 2 OsloMet Artificial Intelligence Lab, Pilestredet 52, N-0166 Oslo, Norway
- 3 NordSTAR - Nordic Center for Sustainable and Trustworthy AI Research, Pilestredet 52, N-0166 Oslo, Norway
- 4 Department of Computer Science and Communication, Østfold University College, B R A Veien 4, N-1757 Halden,
- Norway
- 5 Simula Research Laboratory, Numerical Analysis and Scientific Computing, Oslo, 0164, Norway
- * shailendra.bhandari@oslomet.no

## ABSTRACT

We investigate the potential of bio-inspired evolutionary algorithms for designing quantum circuits with specific goals, focusing on two particular tasks. The first one is motivated by the ideas of Artificial Life that are used to reproduce stochastic cellular automata with given rules. We test the robustness of quantum implementations of the cellular automata for different numbers of quantum gates The second task deals with the sampling of quantum circuits that generate highly entangled quantum states, which constitute an important resource for quantum computing. In particular, an evolutionary algorithm is employed to optimize circuits with respect to a fitness function defined with the Mayer-Wallach entanglement measure. We demonstrate that, by balancing the mutation rate between exploration and exploitation, we can find entangling quantum circuits for up to five qubits. We also discuss the trade-off between the number of gates in quantum circuits and the computational costs of finding the gate arrangements leading to a strongly entangled state. Our findings provide additional insight into the trade-off between the complexity of a circuit and its performance, which is an important factor in the design of quantum circuits.

Keywords: Quantum Computing, Quantum Circuits, Evolutionary Algorithms

## 1 Introduction

Quantum computing utilizes principles of quantum mechanics to perform certain computations faster and on/and larger scales than classical computers are capable of 1 . Quantum bits, or qubits, are key building blocks of quantum computers that enable the latter to be so advantageous in solving complex problems 1 . The intersection of quantum computing and artificial intelligence (AI) is currently an area of active research that has the potential to revolutionize various fields and industry sectors. Quantum Machine Learning (ML) algorithms and, in particular, evolutionary algorithms, belong to one of the research directions that are actively explored now 2-4 . It is expected that the new results will help to speed up the optimization process further and improve the overall performance of computational algorithms. In particular, Evolutionary Quantum Computation (EQC) is an emerging approach that blends evolutionary algorithms and quantum computing to solve complex optimization problems 5-7 .

The aim of this work is twofold. First, we would like to show how quantum algorithms can be used to solve specific problems related to the engineering of evolutionary algorithms. Next, in a complimentary manner, we want to illustrate how evolutionary algorithms can be used to design quantum circuits fulfilling specific requirements. In particular, we will address the problem of designing quantum circuits that process initial product states into highly entangled states.

Entanglement, one of the key concepts of quantum physics, also plays a crucial role in quantum information processing 8 . The term 'entangled state' refers to a state of several quantum objects that are intrinsically correlated with each other, in a way different from all possible classical correlations 9 . F.e., when two qubits are entangled, changes in the state of one qubit affect the state of the other one. There are several measures proposed to quantify the strength of these essentially quantum correlations, and so a quantitative definition of the word 'highly,' strictly speaking, depends on the chosen measure. Highly entangled quantum systems are usually difficult to simulate on classical computers 10,11 , and this fact has significant implications for quantum information processing technologies. Metaphorically speaking, highly entangled qubit states serve as fuel to quantum information processing and without them, the latter loses its superiority with respect to the classical processing 12 . To create a highly entangled state out of a non-entangled one is not an easy task. And even if we have managed to prepare a maximally entangled state, it can become less entangled just because the quantum system prepared in this state is interacting with the environment 13-15 . All real quantum systems suffer from this interaction whose action is conventionally described with the term "decoherence". Therefore, it is important to keep the time during which decoherence strikes the system as short as possible. Practically, this means to minimize the computation time. In addition, every time a quantum gate (that is a transformation of the state of a system of qubits) is implemented, an additional error occurs due to the non-ideal character of the implementation. After passing through many gates, the state is no longer reliable in the sense that it is very different from what it has to be according to the corresponding quantum program. Thus, the more complicated the quantum circuit is (in terms of the number of gates it consists of), the stronger the joint action of decoherence and accumulated implementation errors 16 . As has been mentioned above, not all entangled states are equal in their 'strength'. This means that we need to quantify and measure the amount of entanglement between different qubits. This brings another challenge, because, in a generic quantum system, the quantification of entanglement is a non-trivial task 17 .

Our study addresses two specific problems, which are discussed in Section 2. The first problem, addressed in Subsection 2.1, involves realizing classical stochastic cellular automata using quantum circuits. This approach is innovative as it leverages quantum mechanics to enhance the modeling of complex systems, a topic of extensive interest in prior research 18 . The second problem, discussed in Subsection 2.2, focuses on designing quantum circuits that generate highly entangled multi-qubit states. This is, up to our knowledge, a new application of evolutionary algorithms: to optimize entanglement in quantum circuits. To this end we use the Meyer-Wallach entanglement measure as the fitness function. In Section 3 we summarize the results and discuss further perspective. Finally, in Section 4, we describe the methods used and highlight the relevant concepts.

## 2 Results

## 2.1 Realizing stochastic cellular automata with quantum circuits

In this part, we use an evolutionary algorithm to realize cellular automata (CA) for specific rules, deterministic and stochastic. The CAs are realized with quantum circuits and measurements. The circuits are constructed by assembling gates from a fixed set of five gates. Our approach involves a mutation-based evolutionary algorithm, enabling the optimization of gate types and their placements.

Initially, a predetermined number of chromosomes is generated, corresponding to the number of quantum gates per circuit. Through iterative refinement, the genetic algorithm evolves the existing chromosomes into new variations, singling out the fittest chromosome within each generation to serve as the parent for the subsequent generation. The assessment of the performance of the derived quantum circuits revolves around the measurement of the first qubit, q 0. This assessment entails comparing the measured probability of an initial state, computed from the population, with the corresponding target probability. To quantify the difference between two sets of probability distributions, we use the Kullback-Leibler divergence (KL) as a fitness function. The KL-fitness score measures the discrepancy between the distributions of the output states and the target states. In our case, these distributions are discrete, each corresponding to the eight different initial states of the three qubits. If the distributions completely match, the fitness function value is zero. A decreasing fitness value close to zero indicates an increase in the efficiency of the circuits.

The resulting quantum circuits are evaluated through measurements, thereby demonstrating the algorithm's efficacy. For more details, see Supplementary Note I.

We consider three different types of quantum CAs, starting with a stochastic critical cellular automaton, followed by more general stochastic CA (random updates) and a few deterministic rules, namely, rule 90 and 110 19 . The updates for each type of CA are shown in Table 1. To enhance the robustness of our method, we limit the number of chromosomes by Nc = 20

Table 1. The deterministic and stochastic CAs considered in this paper. For stochastic cases, the values indicate the probability of an update of value 1 for the middle cells in the neighborhood of the triad. For the deterministic cases, the values indicate the exact update imposed.

| Neighbors   |   Sto. CA Prob. |   Rule90 |   Rule110 |   Rand. Prob. 1 |   Rand. Prob. 2 |   Rand. Prob. 3 |
|-------------|-----------------|----------|-----------|-----------------|-----------------|-----------------|
| [0, 0, 0]   |        0.394221 |        0 |         0 |          0.6364 |          0.4778 |          0.1988 |
| [0, 0, 1]   |        0.094721 |        1 |         1 |          0.6603 |          0.5604 |          0.4701 |
| [0, 1, 0]   |        0.239492 |        0 |         1 |          0.5261 |          0.8528 |          0.9836 |
| [0, 1, 1]   |        0.408455 |        1 |         1 |          0.1748 |          0.4818 |          0.7115 |
| [1, 0, 0]   |        0        |        1 |         0 |          0.882  |          0.3143 |          0.6616 |
| [1, 0, 1]   |        0.730203 |        0 |         1 |          0.3371 |          0.3464 |          0.1218 |
| [1, 1, 0]   |        0.915034 |        1 |         1 |          0.034  |          0.0678 |          0.1328 |
| [1, 1, 1]   |        1        |        0 |         0 |          0.4444 |          0.9124 |          0.7306 |

Figure 1. (Left) The fitness scores as a function of the number of generations, for different number of gates . (Right) The number of gates vs. the best fitness scores. The fitness scores of each gate for the box plots are the best fitness scores per run and the fitness scores for the lower two plots are the average fitness scores of 50 runs.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-4721486b-34fe-4f4f-90e3-ef9e45676918.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-43761c54-4a44-4bda-b459-01202a840fb4.jpg)

Figure 2. (Left) The fitness scores as a function of the number of generations, for different mutation rates . (Right) Mutation rates vs. the best fitness scores. The fitness scores of each gate are the average fitness scores of 50 runs.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-9321bc81-6074-4462-8b61-badedf873925.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-6f8a6056-8f39-432b-acc9-327b9e69caaa.jpg)

chromosomes and the number of generations by Ng = 500. Simulations are then performed for Nic = 50 randomly chosen initial conditions. This approach builds upon our previous experiment, where we set Nc = 20 chromosomes, Ng = 150 generations, and Nic = 20 initial conditions were used 18 .

The authors in 20 have evolved a stochastic cellular automata model to reach criticality, a property of dynamical systems that allows them to do robust computations. For each triad pattern, a probability has been calculated through a genetic algorithm for the central cell to have state 1. These probabilities are shown in Table 1, second column.

We start by considering the number of gates used, evolving quantum CAs with 3, 5, 10, 15, and 20 gates and 50 runs. The mutation probability is fixed at 10 percent. The results are presented in Figure 1. They show that the best fitness score per run improves with increasing the number of gates up to 15 gates, after which a gradual increase is observed until the limit of 20 gates. Therefore, for experiments 2 and 3, 15 gates are used. Furthermore, the results of experiments indicate that, while fitness scores initially improve with an increasing number of gates, the rate of progress diminishes as the number of gates continues to increase.

Next, we explore how the fitness changes with the value of the mutation probability. The goal here is to test the impact of the mutation on the fitness function of the different generations. We fixed the number of gates to 15 and used different mutation probabilities, 5%, 10%, 20%, 30%, and 50%.

Figure 2 illustrates the impact of different mutation rates on the KL-fitness score. The left panel of figure 2 shows that all mutation rates result in a decrease in fitness scores over generations, indicating improvement. However, mutation rates of 5%, 10%, and 20% stabilize more consistently compared to higher rates. The right panel box plots show that while higher mutation rates (30%, 50%) lead to decreased fitness scores, they introduce greater variability and less stability. These results highlight that while higher mutation rates can still improve circuit efficiency, the optimal balance between exploration and stability is achieved at a 20% mutation rate.

Figure 3. (Left) Fitness scores for different sets of probabilities against the number of generations for the KL-fitness function. (Right) Best fitness scores per run for KL-fitness function for different sets of probabilities. The fitness scores of each gate are the average fitness scores of 50 runs.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-2def8dcc-6fc7-4bb2-a37c-3a4b1cf097fa.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-4065e1f3-6df2-4dfd-8853-5d61617f9708.jpg)

We now test the above approach with generic deterministic and stochastic cellular CAs. We fixed parameters, by utilizing 15 gates and a 10% mutation probability. Specifically, we examine the application of our methodology to Rule 90 and Rule 110 (deterministic rules with fixed probabilities of 0 or 1 for the eight neighborhoods), as well as to eight randomly generated probabilities, each repeated three times, serving as target probabilities. The corresponding target probabilities for each experimental condition are detailed in Table 1, while the ensuing outcomes are visually represented in Figure 3. This comprehensive analysis showcases the versatility and effectiveness of our approach across a spectrum of rule types and probabilistic settings.

The fitness scores obtained for the deterministic CAs, Rule 90 and Rule 110, are remarkably good, as shown in Figure 3 (left). This highlights the efficiency of our approach to the synthesis of quantum circuits for deterministic CAs. Notably, the outcomes stemming from the stochastic CA approach, characterized by the incorporation of randomly generated probabilities over three separate iterations, exhibit some promise. The optimal fitness scores attained for Random1, Random2, and Random3 are 0.3364, 0.1681, and 0.0014, respectively. It is worth mentioning that while Random1 achieves a commendable fitness score of 0.3364, indicating its promising performance, there is potential for further refinement of the evolutionary process to reduce any existing disparities. A comprehensive evaluation of the fitness scores across different probability sets, as presented in Figure 3 (right), to the number of generations, provides valuable insights into the performance trends for the deterministic CA models (Rule 90 and Rule 110), as well as the stochastic CA model utilizing randomly generated probabilities over three iterations (Random1, Random2, and Random3), all conducted with an initial set of 50 run conditions.

Figure 4 (Left) illustrates the fitness scores corresponding to the diverse CA rules. The best fitness score of 0.294 was achieved by the critical CA. Notably, for two deterministic CA rules, namely Rule 90 and Rule 110, the fitness scores approximate zero, reflecting a deliberate pursuit of minimizing the absolute disparity between initial and final states. This trend aligns logically with the deterministic nature of these CA rules, where probability values exclusively assume binary states of 0 or 1. In contrast, the scenario changes when dealing with randomly generated stochastic CA rules. In this context, the fitness scores demonstrate variability across three distinct randomly assigned probabilities. Intriguingly, among these variations, Random 3 emerges as the front-runner, boasting the most favorable fitness scores. Remarkably, all three sets of randomly generated probabilities exhibit fitness values superior to that of the critical stochastic CA value. Nevertheless, to unravel the underlying mechanisms driving these observed phenomena, a comprehensive exploration beckons. This entails conducting a more extensive array of experiments, encompassing increased generations and a higher replication count. The intricate interplay of factors contributing to fitness score disparities between distinct randomly generated probabilities necessitates a more exhaustive investigation.

In Figure 4 (Right), we show the circuit that significantly outperforms the average outcomes of runs associated with the critical stochastic cellular automaton. Impressively, this particular realization achieved a fitness score of 0.294, as evaluated by the KL fitness function outlined in Equation (1).

## 2.2 Designing entangling quantum circuits

In this section, we present the results obtained with an evolutionary algorithm as a tool to create a circuit that entangles qubits. The strength of the entanglement is quantified with the Mayer-Wallach measure which plays the role of a fitness function. We consider systems of 3, 4, and 5 qubits, and the performance of the algorithm is explored by varying mutation rates and numbers

Best Fitness Scores Among 50 Runs

Figure 4. (Top) Comparison of the best fitness scores across all 50 runs over 500 generations for different CA rules. (Bottom) Visualization of the optimal quantum circuit: Achieving a fitness score of 0.294 using KL fitness function for Critical Stochastic Cellular Automaton. The circuit, composed of 15 gates with a 10% mutation probability, represents the most exceptional outcome within the study, underscoring the success of our approach in circuit optimization.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-faab18d0-c8e2-4add-aed6-136ecf194b0c.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-aa0269c7-9e8f-4564-9add-2dea96dfed19.jpg)

of gates. We ran experiments for 500 generations, repeating it 50 times. The outcomes are shown as the average fitness along with the standard error, and the best fitness achieved, also with its standard error.

## 2.2.1 Three-qubit circuits

We start with a three-qubit case.

Figure 5 presents the evolutionary optimization of a three-qubit quantum circuit across 500 generations, highlighting both average and peak fitness scores. We use three different mutation rates, 5%, 10%, and 15%, and limit the number of gates in the circuits to 3, 5, 8, 10, and 12. The best fitness scores obtained for all mutation rates approached unity, indicating that the resulting circuits are indeed highly entangling.

Since the best fitness scores for the quantum circuits approached unity, evolutionary algorithms indeed serve as a toolbox of methods to design highly entangling three-qubit circuits. For a three-qubit system (three lists of integer gates for each qubit), a mutation probability of 1/9 (11.11%) is needed to replace at least one individual population consisting of nine integer lists. Therefore, a 10% mutation rate, which can at least replace one individual population in each generation can be considered an optimal probability for the mutation rate. Experimentally, the optimal mutation rate was found to be 10%, which struck a balance between exploring different solutions in the search space and exploiting the best solutions as shown in Figure 5 (Top: right). In addition, a lower mutation rate is capable of striking a balance between exploration and exploitation, leading to a higher average fitness score across all runs. However, the mutation rate of 10% is more effective in building and generating the circuit that performs best in each run due to the higher degree of exploration it allows for the entanglement.

We also varied the of gates in the quantum circuit in the range from 3 to 12 keeping the optimal mutation rate at 10%. The result is the fitness score decreased as the number of gates in the circuit increased as shown in Figure 5 (Bottom: Left). These results suggest that as the quantum circuit becomes more complex with an increasing number of gates, the entanglement

Figure 5. Top: Evolutionary optimization of three-qubit quantum circuits with three gates using the Meyer-Wallach entanglement measure 21 as the fitness function. (left) Plots show mean and best fitness across generations for different mutation rates: 5%, including a third-order polynomial fit to the mean fitness. (right) Best fitness comparison with varying mutation rates and gate numbers. Bottom: (left) Fitness outcomes for different gate numbers at a constant 10% mutation probability, averaged over 50 runs with standard error bars. (right) An example circuit achieves a high fitness score of 0.999 with only three gates and 10% mutation probability.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-1ccfbe63-0f3f-4788-bcb3-be4a55f485a5.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-96130ff6-9503-40c4-bb6d-dfe6eb5700d6.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-fea38175-a8a4-4485-9b09-02d31fffcfb9.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-87413371-8c59-477c-a811-47cba5a1bf0c.jpg)

capability of the circuit is reduced, indicating that the circuit is less efficient at performing the desired task. This suggests that there may be a trade-off between circuit complexity and performance. Therefore choosing the optimal number of gates can provide the best balance between the complexity of the quantum circuit and the performance.

The best three-qubit entangling circuit with three gates is shown in Figure 5 (Bottom: right). It corresponds to the fitness score of 0.999. Similarly, a three-qubit quantum circuit with 12 gates also achieved a fitness value of 0.999. In Supplementary Note II, the detailed analyses of the state vector and reduced density matrices from optimal circuits in a 500-generation are presented. Table 1 in Supplementary Note shows these details for the state vector probability of the respective density matrices. The methodologies used for calculating the probabilities of quantum states and the reduced density matrices for the three-qubit circuits, along with an assessment of their entanglement using the Mayer-Wallach entanglement measure, are given in Supplementary Note III.

## 2.2.2 Four and five-qubit circuits

In this section, we extended the designing of quantum circuits to advance our findings to include both four and five-qubit systems. The findings are shown in Figures 6 and 7 for four and five qubit quantum circuits, respectively. Notably, Figures (Top: Left) 6 and 7 show the mean fitness (illustrated by a green line) alongside its standard error (denoted by a shaded area), in addition to the average of the best fitness (represented by a red line) and its standard error (also shaded). A third-order polynomial fit applied to the mean fitness is shown by a blue dashed line. These figures representations demonstrate that the average fitness score approximates 0.6, while the mean of the highest fitness score approaches 0.8.

Further experiment with an optimal mutation probability of 10% and 5% for four and five qubit circuits, respectively, was conducted focusing on circuits with varying numbers of gates as shown in Figures (Top: right) 6 and 7. Through an analysis of mutation rates of 3%, 5%, and 15%, we found that increasing the mutation rate beyond 5% results in a decrease in the

Figure 6. Top: (left) Four-qubit quantum circuits with four gates and a 10% mutation probability. The mean fitness (green line) and its shaded standard error, along with the mean of the best fitness (red line) and its shaded standard error, plotted against the number of generations. (right) Comparison of the best fitness generated for five different numbers of gate sets in a four-qubit circuit using a 10% mutation rate and 20 chromosomes. Bottom: Evolutionary generation of four-gate four-qubit circuits with MW-entanglement fitness scores using a 10% mutation probability with a fitness score of 0.9996.

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-7ffc57fb-d221-44cd-b5f9-aa8b83dded99.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-0c1453cd-7869-463a-ac3b-f80ae1a25fc8.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-e599d73c-d7ff-4785-965c-33838ee01c70.jpg)

average fitness value. This indicates that excessive randomness in the evolutionary process can have a negative impact on circuit performance. However, it was also observed that the average of the best fitness value was not affected by higher mutation rates. This highlights the importance of selecting an appropriate mutation rate for obtaining the quantum circuits of maximal entanglement.

The visualization of the quantum circuit with four and five qubits incorporating four and five gates, respectively, achieving a fitness score of 0.999, is shown in Figures (Bottom) 6 and 7. Additionally, the five-qubit quantum circuit with 12 gates yielded a fitness score of 0.199, signifying a decrement in entanglement capabilities with an increase in the number of gates. Detailed outcomes for the most entangled four and five-qubit quantum circuits, including the state vector and reduced density matrices, are elaborated in Section II of the Supplementary Note. These results pertain to the optimal five-qubit circuit identified across 500 generations, encompassing circuits with both five and twelve gates, as illustrated in Tables 2 and 3 (Section II of the Supplementary Note).

## 2.2.3 The von Neumann Entropy as a Fitness Function

In our experimental setup, we also incorporated von Neumann entropy within an evolutionary algorithm framework. The algorithm was configured for a three-qubit system equipped with ten gates, operating at a mutation rate of 10%. This procedure was iteratively performed across 50 cycles, spanning 500 generations, with each generation consisting of 20 chromosomes. The results of this implementation, illustrating the effectiveness of von Neumann entropy in the optimization process, are graphically represented in Figure 8.

The theoretical maximum entropy for such a system is 2.999. Nevertheless, when implementing von Neumann entropy entanglement as a fitness function in the evolutionary algorithm, we obtained a maximum entropy value of 1.05557. This

Figure 7. Evolutionary optimization of five-qubit quantum circuits: Top: (left) Five gates with 3% mutation, (right) Five gates with 5% mutation, and (Bottom) Varying gate numbers with 5% mutation. The plots showcase mean and best fitness scores (green and red lines, respectively) with standard error against the number of generations. The blue dashed lines represent third-order polynomial fits to the mean fitness. Bottom: fitness scores for circuits with five gates (score: 0.999).

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-a97b894e-2faa-40e7-9332-ec1d9d41a0d0.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-675f464d-1e42-450d-b0d1-0c20ee71c9ed.jpg)

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-1dabe941-642c-4f54-8d05-bdf6e92b21f0.jpg)

result has significant implications for the entanglement within the system. The quantification of entanglement can be achieved through the computation of von Neumann entropy for the reduced density matrix of any given subsystem.

Our findings indicate that the implementation of von Neumann entropy in the three-qubit system successfully detected the presence of entanglement within the evolved three-qubit quantum circuit. This is consistent with the understanding that the entropy of entanglement is the von Neumann entropy of the reduced density matrix for any of the subsystems.

## 3 Discussion and conclusions

In this study, we explore the two examples of evolutionary algorithms in two distinct yet interconnected areas of quantum computing. Initially, we introduce a framework for generating quantum circuits that replicate specific cellular automata rules using genetic algorithms 18 . The implementation code is available at GitHub repository https://github.com/ Overskott/Quevo . This framework effectively evolves quantum circuits for various CA rules, from deterministic to stochastic types. We improved our original framework by increasing the number of generations and runs, enhancing performance and more consistent fitness function outcomes. This initial investigation set the stage for more nuanced applications of evolutionary algorithms in quantum circuit design, suggesting future research paths.

To conclude, building upon this groundwork, we have demonstrated the effectiveness of evolutionary algorithms in generating highly entangled quantum circuits, emphasizing their role in calculating reduced density matrices for three-, four-, and five-qubit systems. These circuits displayed a significant degree of entanglement, measured by the Mayer-Wallach entanglement measure. By tracing out all other qubits, the study illustrated how reduced density matrices could reveal detailed information about the circuit's entanglement. In this context, the algorithm's role was to optimize quantum gates and their connectivity, leading to the creation of quantum circuits.

Figure 8. Evolutionary optimization of three-qubit quantum circuits with 10% mutation probability and ten gates, using von Neumann entanglement entropy as the fitness function. The plot shows the mean fitness (green line) and its shaded standard error, as well as the mean of the best fitness (magenta line) and its shaded standard error, against the number of generations. The blue dashed line represents the third-order polynomial fit to the mean fitness. The maximum fitness score obtained was 1.05557

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00448v1-figure-1c7664b8-f337-4008-a925-6b7d3a066361.jpg)

This contribution is, as far as we have checked, novel in its approach to optimizing quantum circuits for entanglement. Moreover, the simulator provided by Qiskit enabled the evaluation of these circuits, gates, and connections, showcasing the potential of this approach in solving complex entanglement optimization problems. Furthermore, we highlighted the importance of circuit depth in determining the entanglement capability of a quantum circuit, and we found that increasing the circuit depth decreases its entanglement capability.

Another important conclusion is that, an optimal mutation rate was identified for quantum circuits with different qubits and gates, marking a significant stride in optimizing quantum circuits for entanglement generation. To note that the KLfitness score measures the discrepancy between the distributions of the output states and the target states. In our case, these distributions are discrete, each corresponding to the eight different initial states of the three qubits. If the distributions completely match the fitness function, the KL-value is zero. A decreasing fitness value close to zero indicates an increase in the efficiency/entanglement of the circuits. Our findings show that with mutation rates up to 20%, the optimization process effectively explores the solution space, leading to better circuit designs with lower fitness scores. However, mutation rates beyond 20% introduce excessive randomness, which disrupts the optimization process and results in higher fitness scores, indicating less efficient/entangled circuits. All mutation rates result in a decrease in fitness scores over generations, indicating improvement. However, mutation rates of 5%, 10%, and 20% stabilize more consistently compared to higher rates. The right panel box plots show that while higher mutation rates (30%, 50%) lead to decreased fitness scores, they introduce greater variability and less stability. These results highlight that while higher mutation rates can still improve circuit efficiency, the optimal balance between exploration and stability during the "evolution" of the algorithm is achieved at a 20% mutation rate.

Finally, some last points for discussion. This paper opens avenues for future investigations into advanced evolutionary algorithms and alternative fitness functions, such as Von Neumann entropy 22 and Schmidt measures 23,24 , to maximize entanglement in more complex quantum circuits. Future work could explore the scalability of these methods to larger quantum circuits, composed by more than five qubits. The fitness function here introduced, measuring the entanglement between qubits could be extended to multi-dimensional optimization scheme, incorporating also measures of error and noise in quantum circuits. Moreover, it would also be of interest to adapt the method here proposed and integrate it in hybrid optimization approaches. Future research could explore the maximization of entanglement in quantum circuits, drawing inspiration from recent advancements in benchmarking highly entangled states on a 60-atom analog quantum simulator 25 and leveraging non-locality as a resource in quantum computing demonstrated by loophole-free Bell inequality violations with superconducting circuits 25 . All in all, applying optimized quantum circuits to real-world problems in quantum cryptography 26,27 , quantum simulation 27,28 , and quantum machine learning 29 , as well as testing them on actual quantum hardware, could further demonstrate their practical utility and effectiveness 28 .

## 4 Methods

Our study implements two distinct methods for designing quantum circuits. The first method utilizes cellular automata rules combined with the KL fitness function. Here we advanced the original framework from Ref. 18 for generating quantum

circuits that replicate quantum circuits with evolutionary algorithms. Upon this groundwork the second method focuses on designing quantum circuits for maximum entanglement, using the Mayer-Wallach measure and von Neumann entropy for entanglement evaluation. The comprehensive details regarding the implementation of evolutionary quantum algorithms for both methodologies are thoroughly delineated in Supplementary Note I.

## 4.1 Evolutionary algorithms: Mutations and fitness function

The evolutionary algorithm initiates with a specific assigned number of chromosomes, each populated with a set number of quantum gates within the circuit. This initial population is then subject to evolution, where the fittest chromosomes are identified, iteratively refining the existing ones, and introducing the best-fit chromosome at the forefront of each new generation. This evolutionary cycle continued for a predetermined number of generations, with each generation's best chromosome becoming the parent for the next. Throughout this process, the chromosomes are subjected to mutations to enhance the optimization. The mutation process is introduced in two different forms: either by swapping existing gates in the chromosome with randomly selected ones from the gate pool, or by entirely replacing the chromosome to identify the best four parental candidates suitable for the next generation. The mutation process is controlled by a set of probabilities. The four best chromosomes are preserved as "elites" without changes, whereas the remaining chromosomes are selected for evolution based on their fitness, with selection changes directly linked to their performance.

In this context, we considered one-dimensional CAs where each of the cells can be in one of two possible states, 0 or 1 (Boolean CA), The evolution of these CA is governed by a set of rules, precisely 256 possible ones, that determine how the state of a cell updates at each step based on the states of its immediate neighbors. The rules correspond to each of the eight possible configurations of a cell and its two immediate neighbors, namely [0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], and [1, 1, 1]. The rule dictates the next state of the central cell in these configurations. Table 1 shows the matching in all cases considered in this paper.

To evaluate the performance of the quantum circuits, we measure only the first qubit (q0) and consider the fitness function as the Kullback-Leibler (KL) divergence, which measures the difference between two probability distributions and has been used in other works 30,31 as a fitness function:

$$D _ { \mathcal { K L } } ( P | | Q ) = \sum _ { \omega \in \Omega } P ( \omega ) l o g \left ( \frac { P ( \omega ) } { Q ( \omega ) } \right ).$$

In our case, the distributions are discrete, and each one has eight different values related to the eight different initial states of the three qubits. If the distributions are a perfect match, then the fitness function is zero.

## 4.2 Assessing entanglement in basic quantum states of qubits

Consider, for the start, the state of a system of two-qubit configurations of a quantum system. The most general form of a state for such a system can be written as:

$$| \psi \rangle = \alpha _ { 0 0 } | 0 0 \rangle + \alpha _ { 0 1 } | 0 1 \rangle + \alpha _ { 0 0 } | 1 0 \rangle + \alpha _ { 1 1 } | 1 1 \rangle$$

where α 00, α 01, α 10, and α 11 are complex amplitudes of the corresponding basis states. The normalization of the basis state is

$$| \alpha _ { 0 0 } | ^ { 2 } + | \alpha _ { 0 1 } | ^ { 2 } + | \alpha _ { 1 0 } | ^ { 2 } + | \alpha _ { 1 1 } | ^ { 2 } = \sum _ { X \in \{ 0, 1 \} ^ { 2 } } | \alpha _ { X } | ^ { 2 } = 1,$$

where X ∈ { 0 1 , } 2 means all binary combinations of length 2. For a two-qubit state, there is one fully entangled state given by 10,32

$$| \nu \rangle = \frac { 1 } { \sqrt { 2 } } \left ( | 0 0 \rangle + | 1 1 \rangle \right ).$$

This state exemplifies quantum entanglement where the measurement outcome of one qubit directly determines the outcome of the other, showcasing the non-classical correlation inherent in quantum systems 1 . To contrast, consider the following non-entangled state:

$$| \nu \rangle = \frac { 1 } { 2 } | 0 0 \rangle + \frac { 1 } { 2 } | 0 1 \rangle + \frac { 1 } { 2 } | 1 0 \rangle + \frac { 1 } { 2 } | 1 1 \rangle \,.$$

In this state, when measuring one qubit, there is no certainty about the state of the other qubit. Namely, there is a probability of 1 / 2 that the other qubit is in state 0 and probability 1 / 2 that it is in state 1.

In general, suppose we have two quantum systems Q 1 and Q 2. These systems are said to be entangled if the values of certain properties of system Q 1 (accessed with measurement) are correlated with the values that those properties will assume for system Q 2. The simplest forms of entangled state are known as the Bell states 33 , which enable tasks such as quantum cryptography 34 , super-dense coding 35 , teleportation 36 , and entanglement swapping 37 .

The descriptors, expressibility, and entangling capability have been used to study the capabilities of the parametrized quantum circuit by quantifying its deviation from random circuits to approach the research question of how much generalization is effective enough in a quantum circuit for a given task 38 . The expressibility of a quantum circuit is the ability to generate pure states that are well representative of the Hilbert space 39 . In a single qubit, the expressibility corresponds to the circuit's ability to explore the Bloch sphere. Sim et al. 38 propose to quantify the ability of the quantum circuit to generate a pure state as a representative of Hilbert space by comparing the true distribution of the fidelities corresponding to the parameterized quantum circuit (PQC), to the distribution of fidelities from the ensemble of Haar random states.

For example, the measure of expressibility can be calculated by taking the Kullback-Leibner divergence between the estimated fidelity distribution and that of the Haar-distributed ensemble 39 . In this paper, we considered two measures, the Meyer-Wallach (MW) 40 and the entanglement entropy (EE) 41-43 . The Meyer-Wallach entanglement measure is popular because of its scalability and ease of computation. It considers a pure state of n qubits if the form 21 :

$$Q ( | \Psi \rangle ) = \frac { 4 } { n } \sum _ { j = 1 } ^ { n } D ( | a ^ { k } \rangle, | a ^ { k } \rangle ) \,,$$

where | ˆ u k ⟩ and | ˆ v k ⟩ denote non-normalized vectors belonging to the complex vector space C 2n -2 , where n denoting the number of qubits in the quantum system. These vectors are obtained by projecting the pure state | ψ ⟩ of the n -qubit system onto the local basis states of the k th qubit, where k ∈ 1 2 , , ..., n . The symbol "ˆ" above the vectors signifies their non-normalized status. The function D u k ( | ˆ ⟩ , | ˆ v k ⟩ ) measures a distance between the two vectors | ˆ u k ⟩ and | ˆ v k ⟩ , measured through the generalized cross-product:

$$D ( | a ^ { k } \rangle, | \hat { r } ^ { k } ) ) = \sum _ { i < j } | a ^ { k } _ { i } \hat { v } ^ { k } _ { j } - \hat { u } ^ { k } _ { j } \hat { v } ^ { k } _ { i } | ^ { 2 }.$$

Since the purity of the state of qubit k is given by Tr [ ρ 2 k ] = ⟨ ˆ x k | ˆ x k ⟩ 2 + ⟨ ˆ y k | ˆ y k ⟩ 2 , we obtain 21

$$D ( | \dot { k } ^ { k } \rangle, | \dot { k } ^ { k } ) ) = \sum _ { i < j } | \dot { a } _ { i } ^ { k } \dot { v } _ { j } ^ { k } - \dot { a } _ { j } ^ { k } \dot { v } _ { i } ^ { k } | ^ { 2 }$$

It is because generalized cross product under logical unitaries, D u k ( | ˆ ⟩ , | ˆ v k ⟩ ) = D x k ( | ˆ ⟩ , | ˆ y k ⟩ ) in relation to the norm of an anti-symmetric tensor Mk = | ˆ x k ⟩⟨ ˆ y ∗ k | - | ˆ y k ⟩⟨ ˆ x ∗ k | . Therefore, one arrives at an entanglement measure given by:

$$Q ( | \nu ) ) = 2 \left ( 1 - \frac { 1 } { n } \sum _ { k = 0 } ^ { n - 1 } T r | \rho _ { k } ^ { 2 } | \right ),$$

which is the usual definition of the Meyer-Wallach measure. A detailed derivation and discussion of this measure, especially its implications for both pure and mixed states, are provided in Supplementary Note IV.

The entanglement entropy quantifies the quantum entanglement among two subsystems within a larger quantum system. Specifically, for a pure bipartite quantum state of the mixed system, it is feasible to derive a reduced density matrix that characterizes the state of one of the subsystems 42 . The entropy of entanglement is defined as the von Neumann entropy of the reduced density matrix for either of the subsystems 41 . The von Neumann entropy quantifies the uncertainty or randomness in a quantum state and measures the degree of entanglement between the subsystems 42 . If the entropy of entanglement is non-zero, it implies that the subsystem is in a mixed state, and consequently, the two subsystems are entangled 41 . Therefore, the entropy of entanglement offers a useful method for quantifying the degree of entanglement between the subsystems of a composite quantum system.

The von Neumann entropy of entanglement is mathematically defined as the von Neumann entropy of the reduced density matrix for a subsystem within a composite quantum system 43 , namely

$$S ( \rho _ { A } ) = - \text{Tr} ( \rho _ { A } \log _ { 2 } \rho _ { A } ) \,,$$

where Tr represents the trace operation, and log 2 denotes the base-2 logarithm. The von Neumann entropy of entanglement provides a measure of the uncertainty or randomness in the state of subsystem A . Thus, it serves as an indicator of the degree

of entanglement between the subsystems 44 . When dealing with a composite quantum system that's in a mixed state, the von Neumann entropy of entanglement measures the least amount of entanglement present across all possible pure-state decompositions of the mixed state. This method allows for measuring entanglement in a mixed state by considering the representation of the composite system that has minimal entanglement.

In what concerns implementation, we have used the mathematical formulations presented in Equations (9) and (10) in a framework previously developed ( https://github.com/Overskott/Quevo ). It is further aligned with the methodologies outlined in Ref. 18 . The evolutionary algorithms (EAs) have emerged as a promising tool for quantum circuit design 6,7,45 . So our implementation of EAs for quantum circuit design aims to maximize entanglement using two specified methods. The framework employs an evolutionary algorithm to automatically generate quantum circuits that satisfy defined properties specified through a fitness function. The evolution properties can be controlled by tuning parameters such as initial population, number of generations, probability of mutation operator, number of gates in the circuit, and the chosen fitness function. Details of the implementation process are available in Supplementary Note III.

## 5 Data availability

The datasets used and/or analyzed during the current study are available in the QUEVO1 repository, https://github. com/shailendrabhandari/QUEVO1 .

## References

- 1. Nielsen, M. A. &amp; Chuang, I. L. Quantum Computation and Quantum Information: 10th Anniversary Edition (Cambridge University Press, 2010).
- 2. Biamonte, J. et al. Quantum machine learning. Nature 549 , 195-202, DOI: 10.1038/nature23474 (2017).
- 3. Schuld, M., Sinayskiy, I. &amp; Petruccione, F. An introduction to quantum machine learning. Contemp. Phys. 56 , 172-185, DOI: 10.1080/00107514.2014.964942 (2014).
- 4. Tacchino, F., Macchiavello, C., Gerace, D. &amp; Bajoni, D. An artificial neuron implemented on an actual quantum processor. npj Quantum Inf. 5 , 1-8, DOI: 10.1038/s41534-019-0140-4 (2019).
- 5. Sünkel, L., Martyniuk, D., Mattern, D., Jung, J. &amp; Paschke, A. Ga4qco: Genetic algorithm for quantum circuit optimization, DOI: 10.48550/ARXIV.2302.01303 (2023).
- 6. Brown, J., Paternostro, M. &amp; Ferraro, A. Optimal quantum control via genetic algorithms for quantum state engineering in driven-resonator mediated networks. Quantum Sci. Technol. 8 , 025004, DOI: 10.1088/2058-9565/acb2f2 (2023).
- 7. Ballinas, E. &amp; Montiel, O. Hybrid quantum genetic algorithm with adaptive rotation angle for the 0-1 knapsack problem in the ibm qiskit simulator. Soft Comput. DOI: 10.1007/s00500-022-07460-7 (2022).
- 8. Wong, B. On quantum entanglement. Int. J. Autom. Control. Syst. 5 , 1-7 (2019).
- 9. Han, K.-H. &amp; Kim, J.-H. Quantum-inspired evolutionary algorithm for a class of combinatorial optimization. Evol. Comput. IEEE Transactions on 6 , 580 - 593, DOI: 10.1109/TEVC.2002.804320 (2003).
- 10. Vidal, G. Efficient classical simulation of slightly entangled quantum computations. Phys. Rev. Lett. 91 , 147902, DOI: 10.1103/PhysRevLett.91.147902 (2003).
- 11. Verstraete, F., Murg, V. &amp; Cirac, J. Matrix product states, projected entangled pair states, and variational renormalization group methods for quantum spin systems. Adv. Phys. 57 , 143-224, DOI: 10.1080/14789940801912366 (2008).
- 12. Cervera-Lierta, A., Latorre, J. I. &amp; Goyeneche, D. Quantum circuits for maximally entangled states. Phys. Rev. A 100 , 022342, DOI: 10.1103/PhysRevA.100.022342 (2019).
- 13. Shukla, C., Banerjee, A. &amp; Pathak, A. Protocols and quantum circuits for implementing entanglement concentration in cat state, ghz-like state and 9 families of 4-qubit entangled states. Quantum Inf. Process. 14 , DOI: 10.1007/s11128-015-0948-6 (2014).
- 14. Acampora, G. &amp; Vitiello, A. Implementing evolutionary optimization on actual quantum processors. Inf. Sci. 575 , 542-562, DOI: https://doi.org/10.1016/j.ins.2021.06.049 (2021).
- 15. Amal, R. S. &amp; Ivan, J. S. A quantum genetic algorithm for optimization problems on the Bloch sphere. Quantum Inf. Process. 21 , 1-29, DOI: 10.1007/s11128-021-03368-7 (2022).
- 16. Sutor, R. Dancing with Qubits: How Quantum Computing Works and how it Can Change the World . Expert Insight (Packt Publishing, 2019).

- 17. Friis, N. et al. Entanglement certification from theory to experiment. Nat Rev Phys 1 , 72-87, DOI: 10.1038/ s42254-018-0003-5 (2019).
- 18. Bhandari, S. et al. Evolving quantum circuits to implement stochastic and deterministic cellular automata rules. In International Conference on Cellular Automata for Research and Industry , 119-129, DOI: https://doi.org/10.1007/ 978-3-031-14926-9\_11 (Springer, 2022).
- 19. Wolfram, S. Cellular automata as models of complexity. Nat. (London) 311 , 419-424, DOI: https://doi.org/10.1038/ 311419a0 (1984).
- 20. Pontes-Filho, S. et al. A neuro-inspired general framework for the evolution of stochastic dynamical systems: Cellular automata, random Boolean networks and echo state networks towards criticality. Cogn. Neurodynamics 14 , 657-674, DOI: 10.1007/s11571-020-09600-x (2020).
- 21. Brennen, G. K. An observable measure of entanglement for pure states of multi-qubit systems (2003). quant-ph/0305094.
- 22. Mendes-Santos, T., Giudici, G., Fazio, R. &amp; Dalmonte, M. Measuring von neumann entanglement entropies without wave functions. New J. Phys. 22 , 013044, DOI: 10.1088/1367-2630/ab6875 (2020).
- 23. Eisert, J. &amp; Briegel, H. J. Schmidt measure as a tool for quantifying multiparticle entanglement. Phys. Rev. A 64 , DOI: 10.1103/physreva.64.022306 (2001).
- 24. Eisert, J. &amp; Gross, D. Multi-particle entanglement, DOI: 10.48550/ARXIV.QUANT-PH/0505149 (2005).
- 25. Storz, S., Schär, J., Kulikov, A. et al. Loophole-free bell inequality violation with superconducting circuits. Nature 617 , 265-270, DOI: 10.1038/s41586-023-05885-0 (2023).
- 26. Nadlinger, D. P., Drmota, P., Nichol, B. C. et al. Experimental quantum key distribution certified by bell's theorem. Nature 607 , 682-686, DOI: 10.1038/s41586-022-04941-5 (2022).
- 27. Saarinen, M.-J. &amp; Smith-Tone, D. (eds.) Post-Quantum Cryptography , vol. 14771 of Lecture Notes in Computer Science (Springer Cham, 2024), 1 edn.
- 28. Shaw, A., Chen, Z., Choi, J. et al. Benchmarking highly entangled states on a 60-atom analogue quantum simulator. Nature 628 , 71-77, DOI: 10.1038/s41586-024-07173-x (2024).
- 29. Schatzki, L., Arrasmith, A., Coles, P. J. &amp; Cerezo, M. Entangled datasets for quantum machine learning. ArXiv abs/2109.03400 (2021).
- 30. Martín, F., Moreno, L., Garrido, S. &amp; Blanco, D. Kullback-leibler divergence-based differential evolution markov chain filter for global localization of mobile robots. Sensors 15 , 23431-23458, DOI: 10.3390/s150923431 (2015).
- 31. Lucas, S. M. &amp; Volz, V. Tile pattern kl-divergence for analysing and evolving game levels. Proc. Genet. Evol. Comput. Conf. DOI: 10.1145/3321707.3321781 (2019).
- 32. F. Verstraete, V. M. &amp; Cirac, J. Matrix product states, projected entangled pair states, and variational renormalization group methods for quantum spin systems. Adv. Phys. 57 , 143-224, DOI: 10.1080/14789940801912366 (2008). https: //doi.org/10.1080/14789940801912366.
- 33. Weinfurter, H. Experimental bell-state analysis. Europhys. Lett. 25 , 559, DOI: 10.1209/0295-5075/25/8/001 (1994).
- 34. Gisin, N., Ribordy, G., Tittel, W. &amp; Zbinden, H. Quantum cryptography. Rev. Mod. Phys. 74 , 145-195, DOI: 10.1103/ RevModPhys.74.145 (2002).
- 35. Harrow, A., Hayden, P. &amp; Leung, D. Superdense coding of quantum states. Phys. Rev. Lett. 92 , 187901, DOI: 10.1103/ PhysRevLett.92.187901 (2004).
- 36. Bennett, C. H. et al. Teleporting an unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels. Phys. Rev. Lett. 70 , 1895-1899, DOI: 10.1103/PhysRevLett.70.1895 (1993).
- 37. Mooney, G. J., Hill, C. D. &amp; Hollenberg, L. C. Entanglement in a 20-Qubit Superconducting Quantum Computer. Sci. Reports 9 , 1-8, DOI: 10.1038/s41598-019-49805-7 (2019).
- 38. Sim, S., Johnson, P. D. &amp; Aspuru-Guzik, A. Expressibility and entangling capability of parameterized quantum circuits for hybrid quantum classical algorithms. Adv. Quantum Technol. 2 , 1900070, DOI: 10.1002/qute.201900070 (2019).
- 39. ˙ yczkowski, K. &amp; Sommers, H.-J. Z Average fidelity between random quantum states. Phys. Rev. A 71 , 032313, DOI: 10.1103/PhysRevA.71.032313 (2005).
- 40. Meyer, D. A. &amp; Wallach, N. R. Global entanglement in multiparticle systems. J. Math. Phys. 43 , 4273-4278, DOI: 10.1063/1.1497700 (2002).

- 41. Eisert, J., Cramer, M. &amp; Plenio, M. B. Colloquium: Area laws for the entanglement entropy. Rev. Mod. Phys. 82 , 277-306, DOI: 10.1103/revmodphys.82.277 (2010).
- 42. Nielsen, M. A. &amp; Chuang, I. L. Quantum Computation and Quantum Information (Cambridge University Press, Cambridge, 2002).
- 43. Longo, R. &amp; Xu, F. Von neumann entropy in QFT. Commun. Math. Phys. 381 , 1031-1054, DOI: 10.1007/ s00220-020-03702-7 (2020).
- 44. Bennett, C. H., DiVincenzo, D. P., Smolin, J. A. &amp; Wootters, W. K. Mixed-state entanglement and quantum error correction. Phys. Rev. A 54 , 3824-3851, DOI: 10.1103/PhysRevA.54.3824 (1996).
- 45. Sünkel, L., Martyniuk, D., Mattern, D., Jung, J. &amp; Paschke, A. Ga4qco: Genetic algorithm for quantum circuit optimization, DOI: 10.48550/ARXIV.2302.01303 (2023). 2302.01303.
- 46. Benenti, G., Casati, G. &amp; Strini, G. Principles of Quantum Computation and Information (WORLD SCIENTIFIC, 2007). https://www.worldscientific.com/doi/pdf/10.1142/5838.

## Acknowledgements

We extend our gratitude to Sebastian T. Overskott for making the Quevo framework available, which we have adapted for the entanglement assessment in our study.

## Author contributions statement

S.B. conducted the experiments and performed the simulations. All authors have analyzed the results and written the manuscript. S.N., S.D., and P.G.L. have revised the text and P.G.L. coordinated the overall project.

## Supplementary Note I: Implementation of an evolutionary quantum algorithm

Our approach was implemented in Python and resulted in a Python module called QUEVO. This module consists of three classes: Chromosome Generation , , and Circuit . The Chromosome and the Generation classes are part of the genetic algorithm, while the Circuit class is responsible for generating and simulating quantum circuits.

The Chromosome class is the core of the genetic algorithm used for generating quantum circuits. It handles the integer representation of the gates and their connections. The class contains a list of integers and functions to generate and mutate the list. It also handles the initialization of the population and the evolution of the population into a new one. Mutations in the Chromosome class can occur in two different ways: replacing gates from the pool of gates in the chromosome with a randomly generated new one or replacing the chromosome to generate the four best parents. The class is also responsible for checking the chromosome for gates that connect multiple qubits. If the gate has an invalid connection, meaning that it is connected to itself through the randomly generated integers, the class generates a valid configuration randomly.

The Generation class is another important class in the QUEVO module, responsible for managing the population of chromosomes. It is a collection of chromosomes that undergo evolution for a specified number of generations. After each evolution step, changes in the chromosomes in the generation occur by selecting a fixed number of chromosomes as elite and allowing the rest of them to evolve further. In each evolution step, the chromosomes are evaluated with the fitness function, and the fittest chromosomes become the parents for the next generation. The rest of the chromosomes are reset for the initial chromosomes. The Generation class stores a generation of chromosomes, the fitness associated with each chromosome, methods for running and retrieving fitness for two different fitness functions, and functions for printing. It provides methods for performing selection, crossover, and mutation to generate a new population of chromosomes.

The Circuit class within the QUEVO module, which utilizes IBM's Qiskit ( https://qiskit.org/ ), plays a crucial role in generating and managing quantum circuits. It is designed to create Qiskit quantum circuits from string representations, simulate these circuits, perform measurements, and visualize the results. Operated on the Qiskit AER simulator, this class yields results in a dictionary format. It can also emulate an IBMQ backend through the AER simulator, allowing the simulator to use custom quantum gates, basis gates, and coupling maps specific to that backend.

Qiskit, a Python package provided by IBM, is integral to creating and simulating quantum circuits in QUEVO. It offers tools for writing quantum programs and can simulate quantum circuits locally or run them on actual quantum computers via the cloud. To ensure seamless integration and operation of Qiskit within the QUEVO framework, a dedicated Python virtual environment is recommended, preferably set up using Anaconda.

The compute\_MW\_entanglement method implements the Mayer-Wallach measure of entanglement, as a fitness function of the EA. This method processes a state vector representing a quantum circuit's state, converting it into a 2 n x 2 n tensor, where n is the circuit's qubit count. The entanglement for each qubit k is determined by tracing out all other qubits,

Table 2. Final results for maximally entangled states with three qubits: (Left) Reduced density matrices for 3-gate and 12-gate three-qubit quantum circuits; (Right) Probabilities of quantum states for three-qubit circuits with three and twelve gates.

| ( k )   | 3 Gates ( ρ k )                                                           | 12 Gates ( ρ k )                   |                                      |
|---------|---------------------------------------------------------------------------|------------------------------------|--------------------------------------|
| k 0     | [ 0 . 32 + 0 . i 0 . 14 - 0 . 08 i 0 . 14 + 0 . 08 i 0 . 23 + 0 . i ]     | [ 0 . 52 + 0 . i 0 . 35 - 0 . 09 i | 0 . 35 + 0 . 098 i 0 . 269 + 0 . i ] |
| k 1     | [ 0 . 21 + 0 . i - 0 . 06 - 0 . 15 i - 0 . 06 + 0 . 15 i 0 . 34 + 0 . i ] | [ 0 . 56 + 0 . i 0 . 13 + 0 . 08 i | 0 . 13 - 0 . 09 i 0 . 09 + 0 . i ]   |
| k 2     | [ 0 . 43 + 0 . i 0 . 024 - 0 . 04 i 0 . 02 + 0 . 04 i 0 . 12 + 0 . i ]    | [ 0 . 52 + 0 . i - 0 . 19 - 0 . i  | - 0 . 19 + 0 . 11 i 0 . 14 + 0 . i ] |

|   State |   Prob.3 Gates |   Prob.12 Gates |
|---------|----------------|-----------------|
|     000 |         0.099  |        0.394637 |
|     001 |         0.0553 |        0.065579 |
|     010 |         0.207  |        0.002211 |
|     011 |         0.1875 |        0.1659   |
|     100 |         0.2479 |        0.267396 |
|     101 |         0.0322 |        0.007403 |
|     110 |         0.1009 |        0.027074 |
|     111 |         0.0701 |        0.069654 |

summing the squared eigenvalues of their respective reduced density matrices. The results are then normalized by 1 -1 n , ensuring values fall between 0 and 1. More information and method usage are detailed in the QUEVO1 GitHub repository, accessible at https://github.com/shailendrabhandari/QUEVO1 . Besides the well-known Mayer-Wallach measure, we evaluate the entanglement properties of quantum states using the von Neumann entropy as fitness functions. EA creates random density matrices from complex state vectors and calculates the von Neumann entropy based on their eigenvalues. This dual approach in measuring entanglement with Mayer-Wallach and von Neumann entropy enhances the quantum circuits' entanglement characteristics, optimized via quantum evolutionary algorithms.

## Supplementary Note II: State vector probabilities and density matrices for multi-qubit circuits

In quantum systems, probabilities of states are derived from state vector coefficients within the wave function, typically complex numbers of the form a + bi . The probability P for a state with coefficient c = a + bi is given by:

$$P = | c | ^ { 2 } = a ^ { 2 } + b ^ { 2 },$$

where a represents the real part and b the imaginary part of the coefficient. Following the computation of reduced density matrices for all qubits, the entanglement of the circuit is assessed using the Meyer-Wallach entanglement measure.

This appendix explicitly presents maximally entangled states for three, four, and five qubits. Results are systematically organized in tables, each corresponding to distinct quantum circuit configurations. Table 2 illustrates the outcomes for a three-qubit system, with reduced density matrices for circuits comprising 3 and 12 gates (Left), and their associated quantum state probabilities (Right). Table 3 explores a four-qubit system, detailing both reduced density matrices and state probabilities for four-gate circuits. Finally, Table 4 showcases results for a five-qubit system, encompassing reduced density matrices for circuits with five and twelve gates (Top), alongside the state probabilities (Bottom). These tables collectively provide a comprehensive view of quantum state entanglement across varying circuit complexities and gate counts.

## Supplementary Note III: Reduced density matrix as a tool for understanding the purity of a state

The density matrix is a representation of a quantum state that can describe both pure states and mixed states. While the state-vector representation is only suitable for describing pure states, the density matrix can also be used to represent mixed states, which are probabilistic mixtures of pure states. A mixed state can be expressed as a sum of outer products of pure states, each term weighted by a probability. In the density matrix formalism, a mixed state is represented by a Hermitian matrix with non-negative eigenvalues that sum up to one. The density operator representation is an alternative way to express pure quantum states using a matrix formalism. It is defined as:

$$\rho \equiv | \psi \rangle \langle \psi |,$$

| Qubit ( k )   | Reduced Density Matrix ( ρ k )                | Reduced Density Matrix ( ρ k )                |
|---------------|-----------------------------------------------|-----------------------------------------------|
| k 0           | [ 0 . 19027 + 0 . i - 0 . 07902 + 0 . 1034 i  | - 0 . 079000 - 0 . 1031 i 0 . 3575 + 0 . i ]  |
| k 1           | [ 0 . 26918 + 0 . i - 0 . 02213 - 0 . 04859 i | - 0 . 02213 + 0 . 04809 i 0 . 23655 + 0 . j ] |
| k 2           | [ 0 . 20785 + 0 . i - 0 . 02507 + 0 . 06311 i | - 0 . 025037 - 0 . 0631 i 0 . 30635 + 0 . i ] |
| k 3           | [ 0 . 11746 + 0 . i - 0 . 01649 + 0 . 11099 i | - 0 . 01629 - 0 . 11099 i 0 . 46981 + 0 . i ] |

|   State |   Real Part |   Imag. Part |   Probability |
|---------|-------------|--------------|---------------|
|    0000 |    -0.1152  |      0.01557 |       0.01351 |
|    0001 |    -0.1877  |     -0.18186 |       0.0683  |
|    0010 |     0.09023 |      0.11352 |       0.02103 |
|    0011 |     0.37234 |      0.00525 |       0.13866 |
|    0100 |     0.17358 |      0.08707 |       0.03771 |
|    0101 |    -0.02481 |      0.129   |       0.01726 |
|    0110 |     0.14681 |      0.28129 |       0.10068 |
|    0111 |    -0.08074 |      0.11239 |       0.01915 |
|    1000 |    -0.11697 |      0.00246 |       0.01369 |
|    1001 |     0.22572 |      0.3339  |       0.16244 |
|    1010 |    -0.07017 |      0.06416 |       0.00904 |
|    1011 |    -0.10372 |      0.28073 |       0.08957 |
|    1100 |    -0.19159 |      0.13664 |       0.05538 |
|    1101 |     0.03911 |     -0.28446 |       0.08245 |
|    1110 |     0.24894 |      0.10368 |       0.07272 |
|    1111 |    -0.26709 |      0.16429 |       0.09833 |

Table 3. Final outcomes demonstrating maximally entangled states in a four-qubit system: (Left) Reduced density matrices for four-gate quantum circuits; (Right) Probabilities of quantum states for four qubit circuits with four gates.

| ( k )   | 5 Gates ( ρ k )                      |                                      | 12 Gates ( ρ k )                      |                                      |
|---------|--------------------------------------|--------------------------------------|---------------------------------------|--------------------------------------|
| k 0     | [ 0 . 26 + 0 . i 0 . 06 - 0 . 04 i   | 0 . 06 + 0 . 04 i 0 . 24 + 0 . i ]   | [ 0 . 42 + 0 . i - 0 . 02 - 0 . 02 i  | - 0 . 01 + 0 . 02 i 0 . 12 + 0 . i ] |
| k 1     | [ 0 . 17 + 0 . i - 0 . 07 + 0 . 02 i | - 0 . 07 - 0 . 02 i 0 . 35 + 0 . i ] | [ 0 . 14 + 0 . i - 0 . 07 + 0 . 025 i | - 0 . 07 - 0 . 02 i 0 . 40 + 0 . i ] |
| k 2     | [ 0 . 17 + 0 . i 0 . 03 - 0 . 02 i   | 0 . 03 + 0 . 02 i 0 . 34 + 0 . i ]   | [ 0 . 43 + 0 . i - 0 . 08 + 0 . 04 i  | - 0 . 08 - 0 . 04 i 0 . 13 + 0 . i ] |
| k 3     | [ 0 . 09 + 0 . i - 0 . 01 - 0 . 04 i | - 0 . 01 + 0 . 04 i 0 . 47 + 0 . i ] | [ 0 . 27 + 0 . i - 0 . 06 - 0 . 08 i  | - 0 . 07 + 0 . 08 i 0 . 24 + 0 . i ] |
| k 4     | [ 0 . 23 + 0 . i - 0 . 13 + 0 . 09 i | - 0 . 13 - 0 . 09 i 0 . 32 + 0 . i ] | [ 0 . 38 + 0 . i - 0 . 01 - 0 . 012 i | - 0 . 01 + 0 . 01 i 0 . 14 + 0 . i ] |

| State                                                                                           | Prob. 5 Gates                                                                                                                   | Prob. 12 Gates                                                                                                                  | State                                                                                           | Prob. 5 Gates                                                                                                                   | Prob. 12 Gates                                                                                                                  |
|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 | 0.00951 0.02023 0.01381 0.02924 0.01295 0.01313 0.02475 0.04909 0.01619 0.02338 0.01261 0.05647 0.01677 0.00801 0.17413 0.02745 | 0.00397 0.04046 0.06053 0.04221 0.05451 0.00470 0.00025 0.02533 0.19855 0.01998 0.02199 0.07690 0.06047 0.00635 0.03243 0.00311 | 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111 | 0.00030 0.00382 0.00464 0.07066 0.00216 0.03519 0.05050 0.06792 0.06648 0.00260 0.01035 0.07818 0.01954 0.06265 0.01923 0.00029 | 0.02975 0.01760 0.02113 0.02118 0.00176 0.00101 0.03929 0.00579 0.00968 0.01616 0.06754 0.00342 0.00957 0.03323 0.00157 0.06759 |

16/18

Table 4. Final outcomes demonstrating maximally entangled states in a five-qubit system: (Top) Reduced density matrices for

where | ψ ⟩ is the state vector representing the pure quantum state. The expression | ψ ⟩⟨ ψ | represents the outer product of the state | ψ ⟩ with itself,

$$\rho = \begin{bmatrix} \alpha _ { 0 } \\ \alpha _ { 1 } \\ \vdots \\ \alpha _ { N } \end{bmatrix} [ \alpha _ { 0 } ^ { * } \ \alpha _ { 1 } ^ { * } \ \dots \ \alpha _ { N } ^ { * } ] = \begin{bmatrix} | \alpha _ { 0 } | ^ { 2 } & \alpha _ { 0 } \alpha _ { 1 } ^ { * } & \dots & \alpha _ { 0 } \alpha _ { N } ^ { * } \\ \alpha _ { 1 } \alpha _ { 0 } ^ { * } & | \alpha _ { 1 } | ^ { 2 } & \dots & \alpha _ { 1 } \alpha _ { N } ^ { * } \\ \vdots & \vdots & \ddots & \vdots \\ \alpha _ { N } \alpha _ { 0 } ^ { * } & \alpha _ { N } \alpha _ { 1 } ^ { * } & \dots & | \alpha _ { N } | ^ { 2 } \end{bmatrix}.$$

The density operator has several important properties. It is Hermitian, which means that it is equal to its conjugate transpose. It has a trace equal to one, reflecting the fact that it represents a pure state. Furthermore, it also satisfies the property, ρ 2 = ρ , indicating the state is pure. In other words, the density matrix characterizes the pure state. To illustrate this, let us consider an example of a two-qubit, maximally-entangled pure state | ψ AB ⟩ , which can be expressed as:

$$| \psi _ { A B } \rangle = \frac { 1 } { \sqrt { 2 } } \left ( | 0 0 \right ) + | 1 1 \rangle \right ) = \frac { 1 } { \sqrt { 2 } } \left [ \begin{matrix} 1 \\ 0 \\ 1 \end{matrix} \right ].$$

Using the density operator representation, we can express this state as:

$$\rho _ { A B } = \left ( \frac { 1 } { \sqrt { 2 } } \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} \right ) \left ( \frac { 1 } { \sqrt { 2 } } \begin{bmatrix} 1 & 0 & 0 & 1 \end{bmatrix} \right ) = \frac { 1 } { 2 } \begin{bmatrix} 1 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{bmatrix}.$$

This matrix satisfies the properties of a density operator, namely, it is Hermitian, positive semi-definite, and has a trace equal to one. The density operator representation provides a compact and convenient way to represent pure states in a matrix formalism, which can be useful for calculations and quantum information processing tasks.

The reduced density matrix ρ A describes the state of subsystem A after tracing out the degrees of freedom of subsystem B . It is obtained by performing a partial trace of the density matrix ρ AB over subsystem B 46 :

$$\rho _ { A } = \mathrm T r _ { B } ( \rho _ { A B } ) = \sum _ { i = 1 } ^ { d _ { B } } \langle i | \rho _ { A B } | i \rangle$$

where dB is the dimension of the Hilbert space of subsystem B , and | ⟩ i denotes a basis state of subsystem B .

The reduced density matrix ρ A inherits some of the properties of the original density matrix ρ AB . For example, it is Hermitian, positive semi-definite, and has a trace equal to one. However, it is generally not pure, even if the original state ρ AB is pure. This is because entanglement between subsystems cannot be removed by taking a partial trace.

Tr B in Equation (16) is an operation known as the partial trace and is used to extract the state of a subsystem of a composite system from its overall density matrix. The partial trace over subsystem B of a tensor product of two operators | ξ u ⟩⟨ ξ v | and | χ u ⟩⟨ χ v | is given by:

$$T r _ { B } ( | \xi _ { u } \rangle \langle \xi _ { v } | \otimes | \chi _ { u } \rangle \langle \chi _ { v } | ) \equiv | \xi _ { u } \rangle \langle \xi _ { v } | \, T r ( | \chi _ { u } \rangle \langle \chi _ { v } | )$$

where | ξ u ⟩ and | ξ v ⟩ are arbitrary states in the subspace of A , and | χ u ⟩ and | χ v ⟩ arbitrary states in the subspace of B . Tr is the standard trace operation, which for two arbitrary states Tr ( | χ u ⟩⟨ χ v | ) = ⟨ χ v | χ u ⟩ . Similarly, the reduced density matrix of subsystem B can be obtained by taking the partial trace over subsystem A of the tensor product of two operators:

Tr

A

(

|

ξ

u

⟩⟨

ξ

v

| ⊗ |

χ

u

⟩⟨

χ

v

|

)

≡

Tr

(

|

ξ

u

⟩⟨

ξ

v

|

)

|

χ

u

⟩⟨

χ

v

|

.

(18)

As an example, let's reconsider the pure entangled state:

$$| \psi _ { A B } \rangle = \frac { 1 } { \sqrt { 2 } } \left ( | 0 _ { A } 0 _ { B } \rangle + | 1 _ { A } 1 _ { B } \rangle \right ).$$

This system is then composed of single-qubit subsystem A with basis vectors {| ξ 1 ⟩ | , ξ 2 ⟩} = {| 0 A ⟩ | , 1 A ⟩} , and single-qubit subsystem B with basis vectors {| χ 1 ⟩ | , χ 2 ⟩} = {| 0 B ⟩ | , 1 B ⟩} . We know that this system is not separable (i.e., | χ AB ⟩ ̸ = | χ A ⟩⊗| χ B ⟩ ); however, by using the reduced density matrix, we can find a full description for subsystems A and B as follows.

The density matrix of our state | ψ AB ⟩ can be expressed in terms of outer products of the basis vectors as ρ AB = 1 2 [ | 0 A 0 B ⟩⟨ 0 A 0 B | + | 0 A 0 B ⟩⟨ 1 A 1 B | + | 1 A 1 B ⟩⟨ 0 A 0 B | + | 1 A 1 B ⟩⟨ 1 A 1 B | ] . To calculate the reduced density matrix for, let's say, subsystem B , we have:

$$\text{system } \mathfrak { B }, \, \text{we have} \colon \\ \rho _ { B } & = \text{Tr} _ { A } ( \rho _ { A B } ) \\ & = \frac { 1 } { 2 } \left [ \text{Tr} _ { A } ( | 0 _ { A } 0 _ { B } \rangle \langle 0 _ { A } 0 _ { B } | ) + \text{Tr} _ { A } ( | 0 _ { A } 0 _ { B } \rangle \langle 1 _ { A } 1 _ { B } | ) + \text{Tr} _ { A } ( | 1 _ { A } 1 _ { B } \rangle \langle 0 _ { A } 0 _ { B } | ) + \text{Tr} _ { A } ( | 1 _ { A } 1 _ { B } \rangle \langle 1 _ { A } 1 _ { B } | ) \right ] \\ & = \frac { 1 } { 2 } \left [ \text{Tr} ( | 0 _ { A } \rangle \langle 0 _ { A } | ) | 0 _ { B } \rangle \langle 0 _ { B } | + \text{Tr} ( | 0 _ { A } \rangle \langle 1 _ { A } | ) | 0 _ { B } \rangle \langle 1 _ { B } | + \text{Tr} ( | 1 _ { A } \rangle \langle 1 _ { A } | ) | 1 _ { B } \rangle \langle 1 _ { B } | \right ] \\ & = \frac { 1 } { 2 } \left [ \left ( 0 _ { A } | 0 _ { A } \rangle | 0 _ { B } \rangle \langle 0 _ { B } | + \langle 1 _ { A } | 0 _ { A } \rangle | 0 _ { B } \rangle \langle 1 _ { B } | + \langle 0 _ { A } | 1 _ { A } \rangle | 1 _ { B } \rangle \langle 0 _ { B } | + \langle 1 _ { A } | 1 _ { B } \rangle \langle 1 _ { B } | \right ] \\ & = \frac { 1 } { 2 } \left [ | 0 _ { B } \rangle \langle 0 _ { B } | + | 1 _ { B } \rangle \langle 1 _ { B } | \right ]. \\ & \text{Starting with an entangled pure state } | \psi _ { A B } \rangle, \, \text{the reduced density matrix } \rho _ { B } \, \text{of subsystem } B \, \text{ emerges as a mixed state}$$

Starting with an entangled pure state | ψ AB ⟩ , the reduced density matrix ρ B of subsystem B emerges as a mixed state. This matrix ρ B statistically represents subsystem B by averaging out measurements from subsystem A . Tracing out A yields ρ B , reflecting the probability distribution of B . This approach is crucial for analyzing entangled states in complex systems, allowing insight into individual subsystems within entanglements. Key concepts and details about density matrices are sourced from 42,46 , especially the section "The density matrix and mixed states" ( https://qiskit.org/textbook/ ch-quantum-hardware/density-matrix.html#4.-The-Reduced-Density-Matrix--)

## Supplementary Note IV: Evaluation of quantum purity and the Meyer-Wallach entanglement measure

In this appendix, a comprehensive derivation and analysis of the quantum purity of a state is provided, particularly focusing on its relation to the Meyer-Wallach measure. If the state | ψ ⟩ is pure, then its density matrix is given by ρ = | ψ ⟩⟨ ψ | , and its purity yields:

$$T r [ \rho ^ { 2 } ] = T r [ \left ( \left | \left | \psi \right \rangle \left \langle \psi \right | \right ) \left \langle \psi \right \rangle \left \langle \psi \right | \right ) ] = T r [ \left | \psi \right \rangle \left \langle \psi \right | \psi \right \rangle \left \langle \psi \right | ] = T r [ \left | \psi \right \rangle \left \langle \psi \right | ] = 1.$$

The given equation is an expression for the quantum purity of a state | ψ ⟩ , denoted by Q ( | ψ ⟩ ) . The purity is a measure of how pure or mixed a quantum state is, and it is defined as the trace of the square of the density matrix ρ that represents the state. For a pure state, the expression 1 -1 n ∑ n -1 k = 0 Tr [ ρ 2 k ] is equal to zero. For a mixed state, the density matrix can be written as a convex combination of pure states, ρ = ∑ i pi | ψ i ⟩⟨ ψ i | , where pi are probabilities and ∑ i pi = 1. The purity of such a mixed state can not exceed 1, as one can conclude from:

̸

̸

̸

$$\text{state can not exceed } 1, \, & \text{as one can conclude from} \colon \\ \text{Tr} [ \rho ^ { 2 } ] & = \text{Tr} \left [ \left ( \sum _ { i } p _ { i } | \psi _ { i } \rangle \, \langle \psi _ { i } | \right ) \left ( \sum _ { j } p _ { j } | \psi _ { j } \rangle \, \langle \psi _ { j } | \right ) \right ] \\ & = \sum _ { i } p _ { i } ^ { 2 } \text{Tr} [ | \psi _ { i } \rangle \, \langle \psi _ { i } | ] + \sum _ { i \neq j } p _ { i } p _ { j } \text{Tr} [ | \psi _ { i } \rangle \, \langle \psi _ { j } | \, | \psi _ { j } \rangle \, \langle \psi _ { i } | ] \\ & = \sum _ { i } p _ { i } ^ { 2 } + \sum _ { i \neq j } p _ { i } p _ { j } | \, \langle \psi _ { i } | \psi _ { j } \rangle \, | ^ { 2 } \\ & \leq \sum _ { i } p _ { i } ^ { 2 } + \sum _ { i \neq j } p _ { i } p _ { j } = \left ( \sum _ { i } p _ { i } \right ) ^ { 2 } = 1 \,. \\ \text{Therefore, the purity of a mixed state is always less than or equal to one}$$

Therefore, the purity of a mixed state is always less than or equal to one. Using this result, we can see that the expression 1 -1 n ∑ n -1 k = 0 Tr [ ρ 2 k ] is a measure of how mixed the state is. If the state is pure, then this expression is zero, and if the state is entangled/mixed, then this expression is positive.
Shailendra Bhandari Stefano Nichele Sergiy Denysov Pedro G. Lind
How quantum and evolutionary algorithms can help each other: two examples
We investigate the potential of bio-inspired evolutionary algorithms for
designing quantum circuits with specific goals, focusing on two particular
tasks. The first one is motivated by the ideas of Artificial Life that are used
to reproduce stochastic cellular automata with given rules. We test the
robustness of quantum implementations of the cellular automata for different
numbers of quantum gates The second task deals with the sampling of quantum
circuits that generate highly entangled quantum states, which constitute an
important resource for quantum computing. In particular, an evolutionary
algorithm is employed to optimize circuits with respect to a fitness function
defined with the Mayer-Wallach entanglement measure. We demonstrate that, by
balancing the mutation rate between exploration and exploitation, we can find
entangling quantum circuits for up to five qubits. We also discuss the
trade-off between the number of gates in quantum circuits and the computational
costs of finding the gate arrangements leading to a strongly entangled state.
Our findings provide additional insight into the trade-off between the
complexity of a circuit and its performance, which is an important factor in
the design of quantum circuits.