Solving the Schrodinger Equation for Quantum Computing

bunchberry
5 min readAug 18, 2024

--

In quantum computing, you apply logic gates to qubits and you compute how the state vector ψ of the system changes. In the mathematics, these changes happen in jumps: the moment the logic gate is applied, you immediately compute what its result would be. However, what if you wanted to compute a continuous evolution between the non-application and the full application of a logic gate to see how ψ continuously evolves form one state to the next? This can be useful for certain visualizations where you do not want to see sudden jumps but a nice smooth transition between states.

This is where the time-dependent Schrodinger equation comes in.

One thing we can immediately do is simplify it. We do not need to worry about ℏ. That is a physical quantity and as an abstract visualization, we don’t need to worry about the actual physics. We can thus set ℏ to 1 in order to get rid of it. Next, we can divide both sides by 𝑖.

The value 1/𝑖 is actually the same as just -𝑖. So we can substitute in for -𝑖.

Notice how the equation is of the form below.

You can conveniently solve differential equations in this form just by substituting them using the expression below.

Hence, if we apply the substitution to the Schrodinger equation thus far, we get the equation shown below.

If you are familiar with quantum computing, you may recognize this form. Whenever you have some unitary matrix U multiplied by |ψ⟩ in the form U|ψ⟩, this is how you apply a logic gate in quantum computing. In this case, U=e^(-𝑖Ĥt). Thus, one can think of that e^(-𝑖Ĥt) as a special kind of unitary logic gate known as the time evolution operator. What kind of logic gate is that?

In order to actually solve for U, In we need know what the value of Ĥ is. This is known as a Hamiltonian. It is related to the total energy of a system. “Energy” is again another physical concept. Not something needed in quantum computing. We do need a Hamiltonian, however, so how do we acquire it? Well, we can just rearrange the equation so that it is expressed in terms of Ĥ.

Take the log of both sides.

Now, we can divide both sides by 𝑖.

Recall that 1/𝑖 = -𝑖, so this offers a nice simplification as the two negatives will cancel out.

What is the value of t? Well, t has to do with how many intervals of time pass as your system evolves. For simplicity, let’s just set the time interval to 1, and thus we can drop t from the equation and flip the equation around.

Now we have a definition for the Hamiltonian. But what even is the Hamiltonian? Notice how the Hamiltonian is defined in terms of a unitary logic gate U. This is something we need to compute based on the logic gate we wish to apply to our qubit. For example, U could be a Hadamard gate, or any gate we wish to view its continuous evolution.

After you compute the Hamiltonian for your specific logic gate you are applying to the qubit, you can then plug the Hamiltonian into the exponent of the solved Schrodinger equation. Recall that I said that e^(-𝑖Ĥt) is kind of like a special logic gate. When t=0, then e^(-𝑖Ĥt)=I: the same as the identity matrix. When t=1, then e^(-𝑖Ĥt)=U: the same as the logic gate in which we computed the Hamiltonian for.

Hence, at t=0, it functions as a logic gate that does nothing, and thus the initial state of the qubit is not altered at all: the logic gate has yet to be applied. At t=1, it functions as the same as the logic gate we are applying to the qubit: the logic gate has been fully applied. At all time intervals in between t=0 and t=1, these all act as smooth gradations between the non-application and the full application of the logic gate.

Below is a demonstration of this in Octave (similar to MATLAB but better) applying the Hadamard gate continuously to a qubit.

octave> S = [1; 0]
S =
1
0
octave> H = (1/sqrt(2)) * [1, 1; 1, -1]
H =
0.7071 0.7071
0.7071 -0.7071
octave> Hh = i * logm(H)
Hh =
-0.4601 - 0.0000i 1.1107 + 0.0000i
1.1107 + 0.0000i -2.6815 - 0.0000i
octave> expm(-i * Hh * 0) * S
ans =
1
0
octave> expm(-i * Hh * 0.5) * S
ans =
0.8536 + 0.1464i
0.3536 - 0.3536i
octave> expm(-i * Hh * 1) * S
ans =
0.7071 - 0.0000i
0.7071 - 0.0000i

Recall that we simplified the equation for the Hamiltonian by setting t=1. If we did not do this simplification, we would have had to divide both sides by t.

If we set t=2 for example when computing the Hamiltonian, then when we evolve the qubit using the solved Schrodinger equation, then e^(-𝑖Ĥt) will not equal U until t=2.

You could substitute U for any logic gate and always compute a continuous evolution between the non-application and the full application of any logic gate with all the continuous gradations in between of the state vector.

The neat thing is that you don’t have to do this at runtime. You can compute all your Hamiltonians for all your logic gates ahead of time. You could even precompute the different “steps” for e^(-𝑖Ĥt), such as precomputing 30 steps if the transition happens for a second then you have what is necessary to apply a 30 fps smooth transition.

--

--

bunchberry

Professional software developer (B.S CompSci), quantum computing enthusiast.