# From the final quantum state to the quantum circuit composition

When I build a quantum circuit and my initial state is the one composed only by zeros ($$|000\ldots 0\rangle$$), I have a final state $$|\psi\rangle$$ that is the result of the application of the quantum circuit to $$|000\ldots 0\rangle$$.

My question is: if I have the final state $$|\psi\rangle$$ (or something similar, like the probability related to each element of the computational basis) and I know that my initial state is $$|000\ldots 0\rangle$$, is there a way (exact, variational, etc.) to find one of the quantum circuit that applied to $$|000\ldots 0\rangle$$ give me $$|\psi\rangle$$?

• Do you want an analytical algorithm or do you want to use some software e.g. Qiskit? Nov 24 at 17:30
• @Mauricio if there is some documentation about the algorithm used by the software (e.g. qiskit libraries) for me is ok. If it's a black box it would not be really helpful since I would like to know if it is efficient with respect to the number of qubit or not. Nov 24 at 18:10
• The paper Synthesis of Quantum Logic Circuits may be what you are looking for Nov 24 at 18:42

If you initial state is $$| 0\dots0\rangle$$ and your final state is $$|\psi\rangle$$, than it is trivial to come up with some unitary matrix $$U$$, which preforms such transformation (it's first column will be equal to the coeficients of $$|\psi\rangle$$ in computational basis).

Later $$U$$ can be decomposed in no more than $$n$$ unitary matrices $$U'_i$$, each of which acts non-trivially only on two basis vectors.

Each $$U'_i$$ can be decomposed in no more than $$n$$ matrices $$U''_i$$, each of which acts non-trivially only on two qubits. (see the Gray's encoding)

$$U''_i$$ is a tensor product of $$n-2$$ identity matrices and an arbitrary two-qubit gate.

It can be proven that an arbitrary two qubit gate can be constructed with CNOT and arbitrary one-qubit gates.

Any arbitrary one-qubit gate is rotation on the Bloch sphere. It can be approximated with only H, S and T gates.

Disclaimer: I should mention that it is not an optimal solution, for arbitrary $$U$$ this can lead to $$O(2^n)$$ number of gates.

• Thank you, what's the state of the art for decomposition of unitaries? Are there algorithms that in some cases do It efficiently? Nov 26 at 17:38
• For arbitrary unitaries this is (AFAIK) the state of the art. It is a interesting question, what constrains should we apply to unitary matrix, so it is possible to decompose it effectively. Nov 27 at 8:44