My understanding, for instance from this youtube video, is the following:
Assuming a state $\psi = \alpha |0\rangle + \beta |1\rangle$, where $\alpha$ and $\beta$ can be complex. I believe any state is always normalized, so that $|\alpha|^2 + |\beta|^2 = 1$. The probabilities can be calculated as follows: $P_0 = |\alpha|^2$ and $P_1 = |\beta|^2$.
I am currently switching from Qiskit to Cirq. In Cirq, I simulate a simple 3-qubit circuit (see code below). I get the following state:
[0.34538722-0.7061969j 0.29214734-0.14894447j 0.29214737-0.14894448j
0.13474798+0.02354215j 0.29214734-0.14894444j 0.13474798+0.02354215j
0.134748 +0.02354216j 0.03903516+0.04161799j]
When adding all the squares of the real components, I end up with 0.4313373551216718. This is confusing me, as this appears to be non-normalized.
My question: Why does this not add up to 1?
Minimal example:
import cirq
import sympy
import numpy as np
import math
# qubits
q = cirq.GridQubit.rect(1, 3)
q_pi = np.pi/4 # quarter_py
# Create a circuit on these qubits using the parameters you created above.
circuit = cirq.Circuit(
cirq.rx(0.1).on(q[0]), cirq.rx(0.1).on(q[1]), cirq.rx(0.1).on(q[2]),
cirq.ry(q_pi).on(q[0]), cirq.ry(q_pi).on(q[1]), cirq.ry(q_pi).on(q[2]),
cirq.rz(q_pi).on(q[0]), cirq.rz(q_pi).on(q[1]), cirq.rz(q_pi).on(q[2]))
simulator = cirq.Simulator()
results = simulator.simulate(program=circuit, param_resolver=resolver, qubit_order=q).final_state
print(results)
print(np.sum([math.pow(x.real,2) for x in results]))