I am an electrical engineer and am learning about quantum computing. I am writing a simulator in Python to help with the learning process.
The code that I have can simulate up to 10 qubits. I have (so far) implemented the CNOT gate along with most of the single qubit gates.
My computed final state vectors match with those from the IBM Quantum Composer, so I am encouraged that I'm on the right track.
Quantum Composer shows the amount of entanglement for each qubit in a circuit, and this is the part that I'm having a lot of difficulty figuring out. IBM has given clues to how they do it, but it's very confusing to me due to my lack of education in this subject. See the first image below for their description.
I am able to create the density matrix for my system, and from my reading it seems that partial traces of the density matrix are key to finding the per-qubit entanglement values.
For the circuit show below, IBM shows that qubits 0,2 and 3 are "maximally entangled" with values of 0.5 (shown on the right with the three smaller black circles), while qubit 1 has no entanglement with its value of 1.0 (the larger circle).
Could someone either describe the steps to find the per-qubit entanglement values or point me in the proper direction?
Thank you very much.
The four images below:
IBM's definition of measure of entanglement.
Circuit for three entangled qubits and one with no entanglement.
State vector for this circuit.
Probability amplitudes vs basis state (in a bar graph).