# How to calculate the sum of $\sum\limits_{j}{\langle A|{{B}_{j}}\rangle |{{C}_{j}}\rangle }$ with quantum circuits?

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?

• Are $A, B_j$ and $C_j$ Statevectors in Qiskit? How is the question related to Qiskit? Please provide a more elaborate formulation. Jun 8 at 16:23
• Yes, these are three state vectors of the same dimension, but they are not equal Jun 9 at 12:58

1. You can compute the inner product $$\langle A |B_j\rangle$$ with inner() method of Statevector. Just type A.inner(B).
2. You can multiply a Statevector with a scalar. So you can write $$\langle A |B_j\rangle |C\rangle$$ like A.inner(B)*C, since the inner product of two states is a scalar.
3. You add can Statevector as well, so summing over j should be straightforward.
4. 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 your Statevector is normalized with is_valid() method.