Introduction

Topological superconductors harbor Majorana zero modes (MZMs), which have been proposed as a promising platform for the realization of fault-tolerant quantum computing due to their non-Abelian braiding statistics and robustness against disorder and decoherence effects1,2,3. Magnet-superconductor hybrid (MSH) systems, consisting of magnetic adatoms placed on the surface of s-wave superconductors, have been shown to be a suitable material platform for the design of topological superconducting phases, providing strong evidence for the existence of MZMs in one-4,5,6,7 and two-dimensional8,9,10,11 systems. To theoretically test the feasibility of MZMs for the implementation of topologically protected quantum algorithms in MSH systems, it is necessary to translate established quantum algorithms12,13,14,15,16 into braiding protocols for Majorana zero modes17, and successfully simulate these in real time and space. While this has been achieved for the Clifford gates—the fundamental building blocks of topologically protected quantum algorithms—in N = 2 qubit systems on various material platforms17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, the crucial extension to more complex quantum algorithms and larger (N > 2) qubit systems has not yet been achieved. Of particular interest here is the question of whether Majorana-based quantum algorithms can be employed to solve the Bernstein-Vazirani (BV) problem13,14, requiring that a hidden number s, encoded into an oracle function Us, can be read out from the final state of an N-qubit system after a single query of the oracle. While experimental attempts to implement the BV algorithm in non-topological systems33,34,35,36,37,38 have been reported, no demonstration of its feasibility and scalability in topologically protected, MZM-based systems, has been provided to-date.

In this article, we demonstrate the successful solution of the BV problem by simulating a Majorana-based, fault-tolerant quantum algorithm from initialization to read-out in an N = 3 qubit MSH system. To this end, we combine the proposal for MZM braiding via the manipulation of the magnetic structure in MSH systems—motivated by electron-spin resonance-scanning tunneling microscopy (ESR-STM) experiments, demonstrating that individual spins in small magnetic clusters can be flipped39,40,41,42—with theoretical advances in simulating time-dependent phenomena in superconductors23,24,32. This combination enables us to simulate the MZM-based quantum algorithm to solve the BV problem and compute its success probabilities on experimentally relevant time and length scales. We show how the choice of a network architecture allows us to initialize the system in various pure N-qubit many-body states, both in the even- and odd-parity sectors. Moreover, we demonstrate that the hidden number s can be experimentally read out from the spatial form of the charge density after fusing MZM pairs at the conclusion of the BV algorithm. Finally, we visualize the entire BV algorithm in time and space by using the time-, energy-, and spatially-resolved non-equilibrium density of states, Nneq43, to image the MZM world lines. Our results establish for the first time the feasibility of implementing topologically protected quantum algorithms in MSH systems, providing an important step towards the realization of topological quantum computing.

Results

Theoretical methods

As a platform for the implementation of the BV algorithm, we use MSH structures, consisting of a network of magnetic adatoms placed on the surface of a two-dimensional (2D) superconductor, which are described by the Hamiltonian

$$\begin{array}{rcl}{\mathcal{H}}&=&-{t}_{e}\sum\limits_{{\bf{r}},{{\bf{r}}}^{{\prime} },\beta }{c}_{{\bf{r}},\beta }^{\dagger }{c}_{{{\bf{r}}}^{{\prime} },\beta }-\mu \sum\limits_{{\bf{r}},\beta }{c}_{{\bf{r}},\beta }^{\dagger }{c}_{{\bf{r}},\beta }\\ &&+{\rm{i}}\alpha \sum\limits_{{\bf{r}},{\boldsymbol{\delta }},\beta ,\gamma }{c}_{{\bf{r}},\beta }^{\dagger }{\left({\boldsymbol{\delta }}\times {\boldsymbol{\sigma }}\right)}_{\beta ,\gamma }^{z}{c}_{{\bf{r}}+{\boldsymbol{\delta }},\gamma }\\ &&+\Delta \sum\limits_{{\bf{r}}}\left({c}_{{\bf{r}},\uparrow }^{\dagger }{c}_{{\bf{r}},\downarrow }^{\dagger }+{c}_{{\bf{r}},\downarrow }{c}_{{\bf{r}},\uparrow }\right)\\ &&+J\sum\limits_{{\bf{R}},\beta ,\gamma }{c}_{{\bf{R}},\beta }^{\dagger }{\left[{{\bf{S}}}_{{\bf{R}}}(t)\cdot {\boldsymbol{\sigma }}\right]}_{\beta ,\gamma }{c}_{{\bf{R}},\gamma }.\end{array}$$
(1)

Here, \({c}_{{\bf{r}},\beta }^{\dagger }\) creates an electron with spin β at site r, -te denotes the nearest-neighbor hopping parameter on a 2D square lattice, μ is the chemical potential, α is the Rashba spin-orbit coupling between nearest-neighbor sites r and r + δ, Δ is the s-wave superconducting order parameter, J is the magnetic exchange coupling between the magnetic adatom with spin SR at site R and the conduction electrons, and \({\boldsymbol{\sigma }}={({\sigma }_{x},{\sigma }_{y},{\sigma }_{z})}^{T}\) is the vector of Pauli matrices. As the hard superconducting gap suppresses Kondo screening44,45, we consider the magnetic adatoms as classical spins, whose orientation at a time t is given by SR(t).

Below we choose parameters such that (i) the MSH network is topological when the magnetic adatom moments possess a ferromagnetic (FM) out-of plane alignment, but is trivial when the moments exhibit an antiferromagnetic (AFM) in-plane order, and (ii) the MZM localization length is significantly smaller than the network size we can consider computationally. To move the MZMs in space, we rotate the magnetic moments between the FM and AFM alignments, with the MZMs being always located at the end of the topological (FM) regions. This rotation of magnetic moments, which in principle can be achieved using ESR-STM techniques39,40,41,42 (for a detailed discussion, see ref. 32), is characterized by a rotation time TR to rotate a single moment by π/2 between in- and out-of-plane alignment. To ensure the adiabaticity of the entire BV algorithm, we choose a rotation time TRt where Δt is the topological gap in the system (for details, see “Methods” section). Below, all times are given in units of τe = /te.

For an N qubit system, the BV algorithm13,14 encodes a hidden number s = 0, . . . , 2N−1 in an oracle function Us, which is translated into a specific braiding protocol of the MZMs. The time evolution of the entire system’s many-body wave-function \(\left\vert \Psi (t)\right\rangle\) under the braiding protocol is computed using a recently developed non-equilibrium formalism23,32 (for details, see “Methods” section). Starting point for all our simulations is the topologically trivial, even-parity ground state of the system, \(\left\vert GS\right\rangle\), in which all spins of the MSH network are aligned AFM in-plane; thus \(\left\vert \Psi (t=0)\right\rangle =\left\vert GS\right\rangle\). By changing the spin orientation in certain segments of the network from in-plane AFM to out-of-plane FM, the system becomes topological and is initialized into one of the 2N pure (many-body) qubit states \(\left\vert n\right\rangle\) at time t = ti. The application of the BV algorithm, as reflected in the braiding protocol, then yields \({{\rm{BV}}}_{s}\left\vert n\right\rangle =\left\vert n\oplus s\right\rangle\). To evaluate the success of the BV algorithm, we define the time-dependent transition probability pn(t) = Ψ(t)n2. Thus, pn(ti) = 1 describes the successful initialization of the system into a desired initial state \(\left\vert n\right\rangle\), and pns(tc) = Ψ(tc)ns2 = Ψ(tc)BVsn2 = 1 reflects a perfect implementation of the BV algorithm which concludes at time t = tc. While a classical computer requires N queries of the oracle to find the hidden number s with absolute certainty, a quantum computer requires a single query, being able to obtain s from a comparison of the initial \(\left\vert n\right\rangle\) and final \(\left\vert n\oplus s\right\rangle\) states. As we show below, the read-out of these states can be experimentally achieved by measuring the local charge density (for details, see “Methods” section)

$$\rho ({\bf{r}},\sigma ,t)=-e\left\langle \Psi (t)\right\vert {c}_{{\bf{r}},\sigma }^{\dagger }{c}_{{\bf{r}},\sigma }\left\vert \Psi (t)\right\rangle$$
(2)

after fusion of MZM pairs, as it directly reflects a pair’s occupation, and thus allows to uniquely identify all 2N many-body states of an N qubit system.

Finally, we visualize the entire BV algorithm from initialization to fusion using the energy-, time-, and spatially-resolved non-equilibrium density of states Nneq(r, σ, t, ω), which is proportional43 to the time-dependent differential conductance dI(V, r, t)/dV measured in STM experiments (for details, see “Methods” section).

To identify a hidden number s using the Bernstein–Vazirani algorithm, one proceeds in three steps: (i) initialization of the system in a many-body state \(\left\vert n\right\rangle\), (ii) execution of the BV algorithm as represented by a MZM braiding protocol, (iii) read-out of the final state \(\left\vert n\oplus s\right\rangle\). Below, we will discuss each step separately to elucidate how the system’s architecture affects its initialization and the implementation of the BV algorithm.

Gate architecture

While T-structures (see Fig. 1a) have previously been discussed as the basic computing architecture18, it was recently proposed that more compact, folded MSH networks (see Fig. 1b, c) provide several advantages as they enable additional braiding operations and the use of spatial symmetries to efficiently implement quantum gates32. Below, we therefore consider the network architectures shown in Fig. 1b, c for the simulation of the BV algorithm in N = 2 and 3 qubit systems, respectively. These structures can be generalized to large N qubit systems by using the unit cell structure shown in Fig. 1d as the building block.

Fig. 1: Gate architecture and initialization.
figure 1

ac MSH architectures for the simulation of the Bernstein-Vazirani algorithm. Spin orientations are represented by white arrows (white dots representing an out-of-plane orientation), and the zero-energy Nneq (color scale) reveals the existence of MZMs at the end of the topological (FM) rungs. d Unit cell (shown in full color, adjacent unit cells are shown in opaque) to generalize the MSH architecture to a (large) N qubit system. e Nneq for several times during the initialization process along a single rung in the MSH structure. Initialized state \(\left\vert n\right\rangle\) as a function of the chemical potential for the f N = 2 and g N = 3 qubit systems. Parameters are (μ, α, Δ, JS) = (−3.93, 0.45, 1.2, 2.6)te, Γ = 0.03te with an execution time of 4000τe for the initialization process.

Initialization

The initialization of the system into a many-body qubit eigenstate \(\left\vert n\right\rangle\) starts from the even-parity ground state of the trivial phase, denoted by \(\left\vert GS\right\rangle\), in which the spins possess an AFM in-plane alignment. To initialize the system in a topological many-body state, we create three (four) topological rungs in the MSH network of Fig. 1b (Fig. 1c), each of which exhibits two MZMs at its ends, by rotating the spins consecutively to an out-of-plane FM alignment, starting in the center of the rung. The non-equilibrium density of states for one of the rungs for several times during this initialization process is shown in Fig. 1e. The resulting many-body eigenstate of the MSH network in the Fock notation is denoted by \(\left\vert n\right\rangle ={\left\vert {l}_{1}{l}_{2}...\right\rangle }_{F}\), with li {0, 1} describing the occupation of the MZM pair on the ith rung, and depends not only on the system’s chemical potential, μ, but also on the specific MSH architecture as shown in Fig. 1f, g for the N = 2 and N = 3 qubit architecture, respectively. While the initialization in all cases starts from \(\left\vert GS\right\rangle\), an occupation of an individual Majorana pair different from zero occurs when the ferromagnetic moment of the initialized topological rung is sufficiently strong to break a Cooper pair, resulting in a local phase transition that changes the parity of the superconducting ground state (for further details, see Supplementary Note 1). This is similar to the local phase transition that an s-wave superconductor undergoes when the scattering strength of a single44,46,47,48 or multiple magnetic impurities49,50 exceeds a critical value. Due to the spatial symmetry of the N = 3 qubit system (Fig. 1c), two of the four rungs simultaneously undergo a phase transition and thus change their occupation in the initialization process, implying that the possible many-body states after initialization are always in the even-parity sector. In contrast, for the N = 2 qubit system (Fig. 1b), only two of the three rungs possess the same spatial symmetry, and hence the many-body states after initialization can either be in the even- or odd-parity sector, depending on whether an even (0 or 2) or odd (1 or 3) number of rungs undergoes the phase transition. Thus, by starting from a single trivial state \(\left\vert GS\right\rangle\) and utilizing the spatial symmetry of the MSH architecture, one can initialize the system into specific topological many-body states \(\left\vert n\right\rangle\), both in the even- and odd-parity sectors.

BV algorithm

The BV algorithm is decomposed into a Hadamard gate that creates a superposition of all qubit states, an Oracle function that encodes the hidden number s, and a second Hadamard gate that reverses the superposition of qubit states (see Fig. 2a). We generalize the Hadamard gate for an N qubit system with 2N + 2 MZMs by employing \(N\sqrt{X}\) gates as sketched in Fig. 2b (see Supplementary Note 2). Here, the \(\sqrt{X}\)-gate (\(\sqrt{Z}\)-gate) represents a braid of two MZMs from adjacent pairs (the same pair). This N-qubit generalized Hadamard gate results in an equal-weight superposition of all 2N pure N-qubit states involving complex phases (see Supplementary Note 2) and is thus non-Hermitian HH. We therefore need to employ H as the second Hadamard gate in the BV algorithm, which is realized by inverting the directions of the MZM braids in H. We note that this generalization of the Hadamard gate not only significantly reduces the number of required braiding operations and allows for their simultaneous execution, but also realizes a unique generalization to N ≥ 2 qubit systems, in contrast to previous proposals using combinations of \(\sqrt{X}\)- and \(\sqrt{Z}\)-gates3,17 (see Supplementary Note 2). Finally, we note that the braiding protocol for the oracle function Us satisfies the generalized form \({U}_{s}\left\vert n\right\rangle ={(-1)}^{{\bf n}\cdot \hat{A}\cdot {\bf s}}\left\vert n\right\rangle\), where the matrix \(\hat{A}\) is determined by the specific realization of the Hadamard gate (for details, see Supplementary Note 2).

Fig. 2: Bernstein–Vazirani algorithm.
figure 2

a Schematic of the Bernstein-Vazirani algorithm for N qubits (with 2N + 2 MZMs). Braiding protocol for b the N-qubit generalized Hadamard gate using \(N\sqrt{X}\)-gates, and c the oracle function Us for N = 2, 3 qubits using Z-gates. Real space braiding processes for d the generalized Hadamard gate for an N = 2 qubit system, and e the oracle function for an N = 3 qubit system with s {001, 010, 100, 111}. Time-dependent transition probabilities for the f N = 2 qubit system with s = 11, and the g N = 3 qubit system with s = 001, starting from the initialization time ti. Parameters are μ = −3.913te (−3.93te), (α, Δ, JS) = (0.45, 1.2, 2.6)te with execution times of 2200τe (3200τe) for the generalized Hadamard gate and 1980τe (2460τe) for the oracle for the N = 2 (N = 3) qubit system.

The folded MSH networks shown in Fig. 1b, c (in contrast to the conventional T-structure) allow for an efficient implementation of the MZM braiding protocols shown in Fig. 2b, c. In particular, the generalized Hadamard gate for the N = 2 qubit system can be implemented by rotating 4 MZMs by 180 clockwise (see Fig. 2d)—thus simultaneously realizing two \(\sqrt{X}\) gates—while the Z-gates for the oracle are implemented by moving an MZM pair along a plaquette (see Fig. 2e). Both of these implementations allow for faster execution times as they preserve the distance between the MZMs.

The mapping \({{\rm{BV}}}_{s}\left\vert n\right\rangle =\left\vert n\oplus s\right\rangle\) holds both in the Fock (occupation) notation (\({\left\vert ...\right\rangle }_{F}\)), as well as in the logical qubit state notation (\({\left\vert ...\right\rangle }_{q}\)), with the value of s given in the respective notation. However, there exists some freedom in choosing the translation between these two notations. Here, in the even-parity sector for N = 3, we set \({\left\vert 0000\right\rangle }_{F}={\left\vert 000\right\rangle }_{q}\), and a value of “1” in the ith position of s is assigned when a Z-gate is performed on the ith pair of MZMs (unless otherwise stated, s is given in the logical qubit notation below). This completely determines the mapping between these two notations shown in Table 1 (for additional details, and the mapping for the N = 2 qubit systems, see Supplementary Note 2).

Table 1 Correspondence between states in the Fock occupation notation \({\left\vert ...\right\rangle }_{F}\) and the logical qubit notation \({\left\vert ...\right\rangle }_{q}\)

To test the braiding protocol in Fig. 2 for the simulation of the BV algorithm, we consider two cases: (i) an N = 2 qubit system, initialized into the odd-parity state \(\left\vert n\right\rangle ={\left\vert 111\right\rangle }_{F}={\left\vert 11\right\rangle }_{q}\) and s = 11, and (ii) an N = 3 qubit system initialized into the even-parity state \(\left\vert n\right\rangle ={\left\vert 0110\right\rangle }_{F}={\left\vert 011\right\rangle }_{q}\) and s = 001; the corresponding time-dependent probabilities pn(t) and pns(t) for these two cases are shown in Fig. 2f, g, respectively. Starting from \(\left\vert GS\right\rangle\), we obtain for both cases pn(ti) = 1 (within numerical uncertainty), implying that the system is initialized into the desired state at t = ti. The two peaks in the probabilities (see black arrows) denote the times right after the first generalized Hadamard gate is completed (and the superposition of all N-qubit states is achieved), and right before the second generalized Hadamard gate begins. The expected value for the probabilities at these times is \(| \left\langle n\right\vert H\left\vert n\right\rangle {| }^{2}=1/{2}^{N}\) (see horizontal dashed line), in good agreement with our results. After the completion of the BV algorithm at t = tc , we obtain pns(tc) = 0.997 and pns(tc) = 0.998 for the cases shown in Fig. 2f, g, respectively. Since these probabilities, as well as those for all other values of s (see Supplementary Note 3) are within the error correction threshold51,52, our results establish the first successful simulation of the BV algorithm in MSH systems. Note that the small reduction of the success probabilities from unity arises from the weak, but non-zero hybridization between the MZMs32, referred to as Pauli errors, which can be corrected using the approaches discussed in ref. 53.

Fusion and read-out

The experimental read-out of the final state \(\left\vert n\oplus s\right\rangle\) can be achieved by measuring the charge density arising from the fusion of MZM pairs, as it directly reflects their occupation based on the fusion rule γ × γ = 1 + ψ, where γ represents the MZMs, 1 the vacuum, and ψ the electron3. After the completion of the BV algorithm, fusion is achieved by rotating the spins in the topological rungs to an AFM in-plane alignment, starting from the ends of the topological rungs and continuing towards their centers, as schematically shown in Fig. 3a. In Figs. 3b–d, we present spatial plots of the charge density difference, Δρ(r, tf) = ρ(r, tf) − ρGS(r), after the completion of the fusion process at t = tf. By subtracting the charge density ρGS of the ground state \(\left\vert GS\right\rangle\), we can immediately read out the hidden number \(\left\vert s\right\rangle\) in the Fock basis (and then convert it to the logical basis using Table 1), by assigning a value of 1 (0) to each MZM pair whose fusion results in a non-zero (zero) residual charge. For example, the BV algorithm for s = 001 results in a charge density after fusion (see Fig. 3b) that is nonzero on rungs 1 and 2, and vanishing on rungs 3 and 4, thus yielding \(\left\vert s\right\rangle ={\left\vert 1100\right\rangle }_{F}={\left\vert 001\right\rangle }_{q}\) (see Table 1), as expected. Similarly, we can identify \(\left\vert s\right\rangle\) from the charge density on each rung for s = 010 (Fig. 3c) and s = 100 (Fig. 3d). A plot of the time-dependent charge density difference along rung 1 is shown in the inset of Figs. 3b; it demonstrates that the charge remains localized after the completion of the fusion process, as the fusion point is also an intersection point of three rungs, which traps the charge and thus facilitates its experimental detection (in contrast to MZM fusion along a rung with no intersection point for the N = 2 qubit system, see Fig. 2d and Supplementary Note 4). We thus demonstrated that the hidden number s can be read-out experimentally by measuring the charge density after fusion.

Fig. 3: Read-out of the final state.
figure 3

a Spatial plot of Nneq during the fusion process for the N = 3 qubit system. bd Spatial form of the charge density difference, Δρ(r), after the completion of the fusion process for b s = 001, c s = 010, and d s = 100. Inset of b shows the time dependence of Δρ(r) along rung 1. e Majorana world lines for the N = 3 qubit system from initialization to readout, with the real space projection axis shown as a dashed yellow line in a. Vertical dotted lines indicate the start and end times for the generalized Hadamard gates and the oracle. Parameters are (μ, α, Δ, JS) = (− 3.93, 0.45, 1.2, 2.6)te, Γ = 0.03te with execution times of 3200τe for the generalized Hadamard gate, 2460τe for the oracle, and 4800τe for the initialization and fusion.

Spatial imaging of Majorana world lines

We visualize the entire BV algorithm from initialization to fusion via the energy-, time- and spatially-resolved non-equilibrium density of states Nneq(r, σ, t, ω)43 (for details, see “Methods” section). The full time dependence of the spatially resolved zero-energy Nneq for the cases of Fig. 2f, g is provided in Supplementary Movies 1 and 2, respectively (see also Supplementary Figs. 4 and 5 in Supplementary Note 5), demonstrating, as expected, that at any time, the MZMs are localized near the edges of the topological regions. By projecting Nneq onto the real space axis shown in Fig. 3a, we image the Majorana world lines, visualizing the entire BV algorithm in time and space, as shown in Fig. 3e (a full 3D rendering of the world lines for the cases of Fig. 2f, g is shown in Supplementary Movies 3 and 4, respectively). To provide insight into the actual timescale for the execution of the BV algorithm, we note that while the experimentally observed topological gaps vary substantially between different MSH systems54, the largest reported value to date is approximately 1.5 meV55. By equating this value to the topological gap in our system, we obtain an execution time of the BV algorithm of approximately 1.6 ns (see upper x-axis in Fig. 3e). This time scale is significantly smaller than the coherence time T2 ≈ 300 ns realized in ESR-STM experiments42, which sets the upper time limit for a successful execution of the algorithm.

Detecting faulty implementations

The question naturally arises to what extent faulty implementations of the BV algorithm with pns(tc) < 1 can be experimentally detected. To investigate this question, we consider two faulty scenarios: (I) we detune the generalized Hadamard gate, by changing its execution time such that, while the BV algorithm is still adiabatic, the state created after the application of the generalized Hadamard gate is not an equal superposition of pure qubit states (see Supplementary Note 2), and (II) by significantly reducing the execution time of the entire BV algorithm by a factor of 5, which leads to excitations between the MZMs and bulk states and thus renders the BV algorithm non-adiabatic. The time-dependent probabilities for both scenarios with s = 001 are shown in Fig. 4a, b, respectively, revealing significantly reduced success probability of pns(tc) = 0.78 (scenario I) and pns(tc) = 0.0167 (scenario II). These are directly reflected in the spatial form of Δρ: while for the perfect, adiabatic BV algorithm for s = 001, a non-zero charge distribution after fusion exists only on rungs 1 and 2 (see Fig. 3b), the imperfect scenarios I and II now also yield non-zero charges on rungs 3 and 4 (see Fig. 4c, d, respectively). In addition, for scenario II, a non-zero Δρ(r) emerges even away from the fusion point, thus discriminating it not only from the perfect case, but also from scenario I. Moreover, scenarios I and II can also be distinguished using the time- and energy-dependent Nneq (see Fig. 4e, f), at a specific site in the MSH network indicated by the yellow dot in Fig. 4c. In both cases, the MZM moves through this site during the BV algorithm, with the maximum intensity indicated by a dashed white line. However, for the adiabatic scenario I, the MZM remains well separated from the bulk states, while for the non-adiabatic scenario II, a hybridization between the MZM and the bulk states is clearly visible (see white dashed line in Fig. 4f). We thus conclude that the form of Δρ as well as that of Nneq distinguishes not only the faulty implementation of the BV algorithm from a perfect one, but also identifies the origin of the faulty realization—detuning versus non-adiabaticity.

Fig. 4: Faulty implementations of the BV algorithm.
figure 4

Time-dependent transition probabilities for s=111 and a a detuned generalized Hadamard gate (scenario I), and b a non-adiabatic implementation with a significantly reduced execution time of the BV algorithm (scenario II). Δρ(r) after completion of the fusion process for s = 100 and c scenario I, and d scenario II. Energy-resolved non-equilibrium local density of states at the site marked by the yellow dot in c for e scenario I and f scenario II, showing the movement of one of the Majorana zero modes through this site. Parameters are (μ, α, Δ, JS) = (−3.93, 0.45, 1.2, 2.6)te, Γ = 0.01te and execution times of 36800τe (640.0τe) for the generalized Hadamard gate, 2460τe (496τe) for the oracle, and 4800τe(960τe) for the initialization and fusion processes for scenario I (II). For scenario I, the detuning was achieved by choosing TR, ΔTR = (1600, 320)τe, in contrast to the perfect generalized Hadamard gate used for the results shown in Fig.3 with TR, ΔTR = (1000, 20)τe.

Discussion

We have demonstrated the successful simulation of the topologically protected BV algorithm from initialization to read-out in 2D MSH systems using Majorana zero modes. We showed that starting from the ground state of the topologically trivial system, it is possible to initialize the system into various topological even- and odd-parity states through the interplay of the MSH architecture and the system’s chemical potential. We demonstrated how the hidden number s in the logical qubit bases can be straightforwardly encoded in the braiding protocol representing the oracle, allowing us to arrive at an efficient translation between the Majorana-based Fock notation and the logical qubit notation for the many-body states. We proposed a new approach to efficiently and uniquely generalize the Hadamard gate to N≥2 qubit systems using simultaneously executed \(\sqrt{X}\)-gates, thus ensuring that the execution time of the Hadamard gate is independent of N. We also showed that after the conclusion of the BV algorithm and the fusion of the MZM pairs, the hidden number s can be read out from the spatial form of the excess charge density, Δρ. We demonstrated that the entire BV algorithm is visualized in time and space via the non-equilibrium density of states, Nneq, which allowed us to directly image the Majorana world lines. Finally, we showed that the form of Δρ and Nneq allows us to discriminate between perfect and faulty implementations of the BV algorithm, and identify the origin of the latter. Our results thus provide the proof of concept that topologically protected, complex quantum algorithms can be successfully simulated in MSH structures.

While experimental challenges and approaches to the implementation of the above braiding scheme have been discussed before32, several theoretical questions remain open and need to be addressed in the future. Of particular importance here are the effects of decoherence, noise, and quasi-particle poisoning—i.e., the presence of unpaired electrons—on the successful simulation of the algorithm. Our preliminary work on single X- and Z-gates has shown that in MSH systems, the effect of quasi-particle poisoning is negligible if the braiding process is conducted in the adiabatic limit. A further discussion of this and other pertinent issues is reserved for future work.

Methods

Creation of the topological computation basis

The Hamiltonian in Eq. (1) can be rewritten in the Bogoliubov-de Gennes (BdG) form

$${\mathcal{H}} = \frac{1}{2} \sum\limits_{i,j} \left( c_i^\dagger, c_i \right) \underbrace{ \left(\begin{array}{ll} H_{ij} (t) & {\Delta}_{ij} \\ {\Delta}^{*}_{ji} & -H^{*}_{ij} (t) \end{array}\right)}_{=H_{\mathrm{BdG}}} \left(\begin{array}{l} c_j \\ c_j^\dagger \end{array}\right) ,$$
(3)

where HBdG possesses a particle-hole symmetry, which can be expressed as \({H}_{{\rm{BdG}}}=-{\tau }_{x}{H}_{{\rm{BdG}}}^{* }{\tau }_{x}\) with τx being the Pauli X-matrix in particle-hole space. At t = 0, the Bogoliubov transformation

$$\left(\begin{array}{l}{c}_{j}\\ {c}_{j}^{\dagger }\end{array}\right)=\sum _{n}\left(\begin{array}{ll}{U}_{jn}&{V}_{jn}^{* }\\ {V}_{jn}&{U}_{jn}^{* }\end{array}\right)\left(\begin{array}{l}{d}_{n}\\ {d}_{n}^{\dagger }\end{array}\right)$$
(4)

diagonalizes the Hamiltonian

$${\mathcal{H}}=\sum _{n}{E}_{n}\left({d}_{n}^{\dagger}{d}_{n}-\frac{1}{2}\right),$$
(5)

with En ≥ 0. The ground state \(\left\vert \Omega \right\rangle\) of the system is the quasiparticle vacuum defined via \({d}_{n}\left\vert \Omega \right\rangle =0\forall n\). We construct it from the vacuum of the c-operators \(\left\vert 0\right\rangle\)18,56 via

$$\left\vert \Omega \right\rangle =\frac{1}{\sqrt{{\mathcal{N}}}}\prod _{n}{d}_{n}\left\vert 0\right\rangle ,$$
(6)

where the normalization is given by \({\mathcal{N}}=| {{\det }}(\hat{V})|\), where \({[\hat{V}]}_{jn}={V}_{jn}\) in Eq. (4). As the Hamiltonian considered here conserves fermion parity, we restrict ourselves to either the even or the odd parity sector, i.e. \(P={\sum }_{n}\langle {d}_{n}^{\dagger }{d}_{n}\rangle =0\,{\rm{or}}\,1\,{\rm{mod}}\,2\). The states in our topological computation basis with N qubits, i.e. N + 1 Majorana pairs, are thus

$$\begin{array}{r}{\left\vert {n}_{1}\cdots {n}_{N}{n}_{N+1}\right\rangle }_{F}=\mathop{\prod }\limits_{j=1}^{N}{\left({d}_{j}^{\dagger }\right)}^{{n}_{j}}{\left({d}_{N+1}^{\dagger }\right)}^{{\bigoplus }_{j = 1}^{N}{n}_{j}\oplus P}\left\vert \Omega \right\rangle .\end{array}$$
(7)

Here, \({d}_{j}^{\dagger }\) creates an electron in the jth Majorana pair (i.e., this pair becomes occupied), and the occupation of the (N+1)'th Majorana pair is chosen such that the fermion parity P of all 2N states is fixed to be either even (P = 0) or odd (P = 1). Which one of the Majorana pairs is chosen as the parity-conserving one is arbitrary.

Time evolution of states

The time-evolved quasiparticle operators are given by

$${d}_{n}(t)={\mathcal{U}}(t){d}_{n}{{\mathcal{U}}}^{\dagger }(t)$$
(8)

with the time-evolution operator

$${\mathcal{U}}(t)={\mathcal{T}}\exp \left(-\frac{{\rm{i}}}{\hslash }\mathop{\int}\nolimits_{0}^{t}{\rm{d}}{t}^{{\prime} }{\mathcal{H}}({t}^{{\prime} })\right).$$
(9)

Using the time-dependent BdG equations, the time-evolved quasiparticle operators are given by

$$\left(\begin{array}{l}{d}_{n}^{\dagger }(t),{d}_{n}(t)\end{array}\right)=\sum _{i}\left(\begin{array}{l}{c}_{i}^{\dagger },{c}_{i}\end{array}\right)\left(\begin{array}{ll}{U}_{in}(t)&{V}_{in}^{* }(t)\\ {V}_{in}(t)&{U}_{in}^{* }(t)\end{array}\right),$$
(10)

where

$$\left(\begin{array}{ll} {\hat{U}}(t) & {\hat{V}}^*(t) \\ {\hat{V}}(t) & {\hat{U}}^*(t) \end{array}\right) = \underbrace{{\mathcal{T}}\exp\left[ -\frac{{\mathrm{i}}}{\hbar} \, \int_0^t dt^{\prime} H_{{\rm{BdG}}}(t^{\prime}) \right]}_{=U_{\mathrm{BdG}}} \left(\begin{array}{ll} {\hat{U}}(0) & {\hat{V}}^*(0) \\ {\hat{V}}(0) & {\hat{U}}^*(0) \end{array}\right),$$
(11)

with the elements of the matrices \(\hat{U},\hat{V}\) given by \({[\hat{U}]}_{in}={U}_{in}\) and \({[\hat{V}]}_{in}={V}_{in}\) in Eq. (10). As such, we can write the time-evolved quasiparticle vacuum as

$$\left\vert \Omega (t)\right\rangle =\frac{{e}^{{\rm{i}}\alpha (t)}}{\sqrt{{\mathcal{N}}(t)}}\prod _{k}{d}_{k}(t)\left\vert 0\right\rangle \,,$$
(12)

with the normalization \({\mathcal{N}}(t)=| \det (V(t))|\). The phase α stems from the time evolution of the true vacuum. However, this phase is gauged away in our gauge-invariant formulation of physical quantities, such as the transition probabilities. Hence, the time-evolved states in our logical basis are given by

$$\begin{array}{l}{\left\vert {n}_{1}\cdots {n}_{N}{n}_{N+1}\right\rangle }_{F}(t)\\=\mathop{\prod }\limits_{j=1}^{N}{\left({d}_{j}^{\dagger }(t)\right)}^{{n}_{j}}{\left({d}_{N+1}^{\dagger }(t)\right)}^{{\bigoplus }_{j = 1}^{N}{n}_{j}\oplus P}\left\vert \Omega (t)\right\rangle \,.\end{array}$$
(13)

Transition probabilities

The probability for transitions between states \(\left\vert \psi (t)\right\rangle ={\left\vert {n}_{1}\cdots {n}_{N}{n}_{N+1}\right\rangle }_{F}(t)\) and \(\left\vert {\psi }^{{\prime} }(0)\right\rangle ={\left\vert {n}_{1}^{{\prime} }\cdots {n}_{N}^{{\prime} }{n}_{N+1}^{{\prime} }\right\rangle }_{F}(0)\) takes the form

$$\begin{array}{r}| \left\langle {\psi }^{{\prime} }(0)| \psi (t)\right\rangle {|}^{2}={\left| {(-1)}^{s}\frac{{e}^{{\rm{i}}\alpha (t)}}{\sqrt{{\mathcal{N}}{\mathcal{N}}(t)}}\langle 0| \prod\limits_{l}{d}_{l}^{\dagger }\mathop{\prod }\limits_{j = 1}^{N}{\left({d}_{j}\right)}^{{n}_{j}^{{\prime} }}{\left({d}_{N+1}\right)}^{{\bigoplus }_{j = 1}^{N}{n}_{j}^{{\prime} }\oplus P}\mathop{\prod }\limits_{j = 1}^{N}{\left({d}_{j}^{\dagger }(t)\right)}^{{n}_{j}}{\left({d}_{N+1}^{\dagger }(t)\right)}^{{\bigoplus }_{j = 1}^{N}{n}_{j}\oplus P}\prod\limits_{l}{d}_{l}(t)|0\rangle \right| }^{2}.\end{array}$$
(14)

This probability can be computed using the Onishi Formula56,57 and the Bogoliubov transformations from Eqs. (4) and (10) via

$$\left\langle {\psi }^{{\prime} }(0)| \psi (t)\right\rangle ={{\det }}{\left[{\hat{U}}_{{\psi }^{{\prime} }}^{\dagger }{\hat{U}}_{\psi }(t)+{\hat{V}}_{{\psi }^{{\prime} }}^{\dagger }{\hat{V}}_{\psi }(t)\right]}^{\frac{1}{2}}.$$
(15)

Charge density

The electronic charge density at site r for spin σ in the state \(\left\vert \psi \right\rangle\) is given by ρ(r, σ) = −enr,σ , where

$${n}_{{\bf{r}},\sigma }=\langle \psi | {c}_{{\bf{r}},\sigma }^{\dagger }{c}_{{\bf{r}},\sigma }| \psi \rangle .$$
(16)

Numbering the sites and other degrees of freedom from 1 to ND, we define the spinors

$$\Psi =\left(\begin{array}{l}{c}_{1}\\ \vdots \\ {c}_{{N}_{{\rm{D}}}}\\ {c}_{1}^{\dagger }\\ \vdots \\ {c}_{{N}_{{\rm{D}}}}^{\dagger }\end{array}\right)\quad {\rm{and}}\quad \Phi =\left(\begin{array}{l}{d}_{1}\\ \vdots \\ {d}_{{N}_{{\rm{D}}}}\\ {d}_{1}^{\dagger }\\ \vdots \\ {d}_{{N}_{{\rm{D}}}}^{\dagger }\end{array}\right),$$
(17)

which are related via the Bogoliubov-de Gennes transformation as

$$\Psi =M\,\Phi\,\ \ {\rm{with}} \ \ M=\left(\begin{array}{ll}\hat{U}&{\hat{V}}^{* }\\ \hat{V}&{\hat{U}}^{* }\end{array}\right)$$
(18)

where the elements of the matrices \(\hat{U}\), \(\hat{V}\) are given by \({[\hat{U}]}_{in}={U}_{in}\) and \({[\hat{V}]}_{in}={V}_{in}\) in Eq. (10). We have for the ground state \(\left\vert \Omega \right\rangle\)

$$\left\langle \Omega | \Phi {\Phi }^{\dagger }| \Omega \right\rangle =\left(\begin{array}{ll}{I}_{N_D\times N_D}&0\\ 0&0\\ \end{array}\right)\,,$$
(19)

and thus

$$\begin{array}{ll}\left\langle \Omega | \Psi {\Psi }^{\dagger }| \Omega \right\rangle\,=\,\left\langle \Omega | M\Phi {\Phi }^{\dagger }{M}^{\dagger }| \Omega \right\rangle =M\left\langle \Omega | \Phi {\Phi }^{\dagger }| \Omega \right\rangle {M}^{\dagger }\\\qquad\quad\qquad\quad=\left(\begin{array}{ll}\hat{U}\,{\hat{V}}^{* }\\\hat{V}\,{\hat{U}}^{* }\end{array}\right)\left(\begin{array}{ll}{I}_{{N}_{{\rm{D}}}\times {N}_{{\rm{D}}}}\,\;0\\ 0\qquad\quad0\\ \end{array}\right)\left(\begin{array}{ll}{\hat{U}}^{\dagger }\,{\hat{V}}^{\dagger }\\ {\hat{V}}^{T}\,{\hat{U}}^{T}\end{array}\right)\\\qquad\qquad\qquad=\left(\begin{array}{ll}\hat{U}{\hat{U}}^{\dagger }\,\hat{U}{\hat{V}}^{\dagger }\\ \hat{V}{\hat{U}}^{\dagger }\,\hat{V}{\hat{V}}^{\dagger }\end{array}\right)\,.\end{array}$$
(20)

The charge density is then given by the ND diagonal elements of the lower right block of this matrix, and thus

$${n}_{i}={\left(\hat{V}{\hat{V}}^{\dagger }\right)}_{ii}.$$
(21)

The time-evolved charge density is obtained by using the time-evolved Bogoliubov-de Gennes equations, and the resulting time-evolved matrix M(t)

$$\Psi (t)={\mathcal{U}}(t)\Psi {{\mathcal{U}}}^{\dagger }(t)={U}_{{\rm{BdG}}}\Psi ={U}_{{\rm{BdG}}}M\Phi =M(t)\Phi \,.$$
(22)

The time-dependent charge density is then obtained from

$${n}_{i}(t)={\left(\hat{V}(t){\hat{V}}^{\dagger }(t)\right)}_{ii},$$
(23)

as

$$\rho ({\bf{r}},\sigma ,t)=-e{\left(\hat{V}(t){\hat{V}}^{\dagger }(t)\right)}_{({\bf{r}},\sigma ),({\bf{r}},\sigma )}.$$
(24)

Time dependence of spin rotations

The rotation of the spins in the network is governed by two time scales during each step of the algorithm: a rotation time TR to rotate one individual spin by a polar angle of π/2, and a delay time ΔTR before the next spin starts rotating. We use spherical coordinates to describe each spin’s orientation in space, such that

$${{\bf{S}}}_{{\bf{R}}}(t)=\left(\begin{array}{c}\cos \left(\phi \left({\bf{R}},t\right) \right) \cdot \sin \left(\theta \left({\bf{R}},t\right)\right) \\ \sin \left(\phi \left({\bf{R}},t\right) \right) \cdot \sin \left(\theta \left({\bf{R}},t\right)\right) \\ \cos \left(\theta \left({\bf{R}},t\right)\right)\\ \end{array}\right)\,.$$
(25)

Therein, we use the function

$$s(t,{t}_{0})=\left\{\begin{array}{ll}0,\quad &t < {t}_{0}\\ {\sin }^{2}\left(\frac{\pi }{2}\frac{t-{t}_{0}}{{T}_{{\rm{R}}}}\right),\quad &{t}_{0}\le t\le {t}_{0}+{T}_{{\rm{R}}}\\ 1,\quad &t > {t}_{0}+{T}_{{\rm{R}}}\end{array}\right.$$
(26)

so that the transition from 0 to π/2 for the polar angle is executed smoothly. For instance, the initialization of the spins Si on one rung of length 2L + 3, numbered from 0 to 2L + 2, from in-plane antiferromagnetic alignment to out-of-plane ferromagnetic alignment is executed by the following time dependence of the polar angles

$${\theta }_{i}(t)=\left\{\begin{array}{ll}{(-1)}^{i}\frac{\pi }{2}[1-s(t,\Delta {T}_{R}\cdot (L+1-i))],\quad &0\le i\le L+1\\ {(-1)}^{i}\frac{\pi }{2}[1-s(t,\Delta {T}_{R}\cdot (i-L-1))],\quad &L+2\le i\le 2L+2\end{array}\right.,$$
(27)

which rotates the center spin out-of-plane first, followed by the next two adjacent spins after the delay time ΔTR, and so forth until all spins are rotated out-of-plane. The azimuthal angle ϕ is chosen for each spin such that its in-plane orientation is perpendicular to the direction of the network chain at that site, i.e., for a horizontal segment \(\phi =\frac{\pi }{2}\), for a vertical segment ϕ = 0. All other parts of the processes are executed with similar rotation protocols.

Non-equilibrium local density of states

The time-dependent processes discussed in the main text can be experimentally visualized by measuring the time-dependent differential conductance dI(V, r, t)/dV in scanning tunneling microscopy (STM) experiments. We previously showed that, in analogy to the equilibrium case, this quantity is proportional to the non-equilibrium density of states defined as \({N}_{neq}({\bf{r}},\sigma ,t,\omega )=-\frac{1}{\pi }{\rm{Im}}{G}^{r}({\bf{r}},{\bf{r}},\sigma ,t,\omega )\)43. Here, the time- and frequency-dependent retarded Green's function \({\hat{G}}^{r}\) is calculated from the differential equation

$$\left[{\rm{i}}\frac{d}{dt}+\omega +{\rm{i}}\Gamma -\hat{H}(t)\right]{\hat{G}}^{r}\left(t,\omega \right)=\hat{1}.$$
(28)