# Why does applying a Hadamard gate three times to $|0\rangle$ result in a tiny imaginary component in the $|1\rangle$ amplitude?

I'm using qiskit with the online IBM Quantum Lab and when I run the following code

from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_bloch_multivector

qc = QuantumCircuit(1)

qc.h(0)
qc.h(0)
qc.h(0)

out = execute(qc,Aer.get_backend('statevector_simulator')).result().get_statevector()
print(out)
plot_bloch_multivector(out)


... it results in the following state vector for the qubit:

[0.70710678+0.00000000e+00j 0.70710678+1.57009246e-16j]

As you can see there's a very small imaginary component in the |1> amplitude.

These imaginary values pop up often with qiskit, such as:

qc.x(0)
qc.h(0)
--> [ 0.70710678+0.00000000e+00j -0.70710678+8.65956056e-17j]


or even very small non-imaginary numbers, such as:

qc.x(0)
qc.h(0)
qc.h(0)
--> [6.123234e-17+0.00000000e+00j 1.000000e+00-2.22044605e-16j]


Is this something unique to quantum mechanics/computing that actually has practical consequences when doing computation, or perhaps simply a quirk of Python's scientific notation implementation.

• These are just precision errors. The calculations are using doubles, and $\frac{1}{\sqrt{2}}$ has no exact representation as a double. Apr 29 at 17:33