Visual the qubit state after amplitude encoding

I trying to visualize qubits state after amplitude encoding.

I have the following code which takes the 8 feature [1/2, 1/2, 1/2, 1/2,1/2, 1/2,1/2,1/2] and encodes into 3 qubits.

I now get the output [0.35355339+0.j 0.35355339+0.j 0.35355339+0.j 0.35355339+0.j 0.35355339+0.j 0.35355339+0.j 0.35355339+0.j 0.35355339+0.j].

How to get individual qubits state from overall state, so I can visualize it using Qiskit.

import pennylane as qml
import numpy as np

dev = qml.device('default.qubit', wires=3)

@qml.qnode(dev)
def circuit(f=None):
qml.AmplitudeEmbedding(features=f, wires=range(3))
return qml.expval(qml.PauliZ(0))

feature_vector= [1/2, 1/2, 1/2, 1/2,1/2, 1/2,1/2,1/2]

normalized_feature_vector = feature_vector / np.linalg.norm(feature_vector)
circuit(normalized_feature_vector)

print(dev.state)


Your qubits are in an equal superposition of all possible states.

$$|\psi\rangle = \frac{1}{2\sqrt{2}}(|000\rangle+|001\rangle+|010\rangle+|011\rangle+|100\rangle+|101\rangle+|110\rangle+|111\rangle)\,,$$

$$\therefore |\psi\rangle =\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) \otimes\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) \otimes\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) \,.$$

Hence, all your individual qubits are in the $$|+\rangle$$ state.

Qiskit has some functions that can be used to visualize multi-qubit state. So, there is no need to get the state of individual qubits.

For example, you can use plot_state_qsphere

from qiskit.visualization import plot_state_qsphere

plot_state_qsphere(psi)


Here, psi is the state

psi = [0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j]


The result:

For more details about Q-sphere see here

Another option is to use plot_bloch_multivector

from qiskit.visualization import plot_bloch_multivector

plot_bloch_multivector(psi)


The result: