How to calculate the sum of $\sum\limits_{j}{\langle A|{{B}_{j}}\rangle |{{C}_{j}}\rangle }$ with quantum circuits by qiskit, where $\sum\limits_j \langle A| B_j\rangle |C_j \rangle$, $A,B_j,$ and $C_j$ are three quantum states of the same dimension?
-
1$\begingroup$ Are $A, B_j$ and $C_j$ Statevectors in Qiskit? How is the question related to Qiskit? Please provide a more elaborate formulation. $\endgroup$– Peter IvashkovJun 8 at 16:23
-
$\begingroup$ Yes, these are three state vectors of the same dimension, but they are not equal $\endgroup$– R-X ZhaoJun 9 at 12:58
1 Answer
Here is one way to do it:
- You can compute the inner product $\langle A |B_j\rangle$ with
inner()
method ofStatevector
. Just typeA.inner(B)
. - You can multiply a
Statevector
with a scalar. So you can write $\langle A |B_j\rangle |C\rangle$ likeA.inner(B)*C
, since the inner product of two states is a scalar. - You add can
Statevector
as well, so summing overj
should be straightforward. - Notice though, that a valid
Statevector
must have a norm 1. That is,S.inner(S)
must be equal 1. Adding or multiplying with a scalar doesn't, in general, preserve the norm. You can check if yourStatevector
is normalized withis_valid(
) method.
-
$\begingroup$ Sorry this is not what I want, I want to implement each step of the above formula on a quantum computer, instead of the classical computer sharing too many problems for the quantum computer $\endgroup$– R-X ZhaoJun 10 at 6:55