# How to calculate parameters of U3 gate from a certain quantum state?

I'm trying to do Quantum PCA but I came across a problem. I now have a quantum state, say $$\frac{|00\rangle+|01\rangle+|11\rangle}{\sqrt{3}}$$ and I want to know how to prepare it from two $$|0\rangle$$ qubits. I mean, I wonder how can I calculate the parameters ($$\theta, \phi, \lambda$$) of unitary gates? I really do appreicate it if you can help me!

• Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
– Community Bot
Commented May 18, 2022 at 16:51
• U3 gates are single qubit gates. For the state that you are trying to create, you need two qubit gates (as shown by @Andrés Ruiz) in addition to single qubit gates. If you want to create a single unitary gate you can use a single 4x4 matrix, but that will have more than just 3 parameters. Commented May 18, 2022 at 21:40

You can initialize the state of a quantum circuit using the initialize method of the QuantumCircuit class. Here is the documentation:

https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.initialize.html#qiskit.circuit.QuantumCircuit.initialize

One you have initialize your state, you can see the angles and gates inside the initialization gate using the decompose method. Its documentation can be found in the next page:

https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.decompose.html#qiskit.circuit.QuantumCircuit.decompose

A small code that initialize your state $$\frac{|00\rangle+|01\rangle+|11\rangle}{\sqrt{3}}$$ and decompose the circuit so you can see the basic 2 and 1 qubit gates with their angles is posted below:

import numpy as np

from qiskit.circuit import QuantumCircuit
from qiskit.circuit import QuantumRegister

psi_0 = [1, 1, 0, 1]

psi_0 = psi_0/np.linalg.norm(psi_0)

nbqbits = 2

qr = QuantumRegister(nbqbits)
qc = QuantumCircuit(qr)

qc.initialize(psi_0)

d_c = qc.decompose().decompose().decompose().decompose()

d_c.draw('mpl')


You should obtain the next image:

If you want to know about how they implement the initialize method, I think they used this article:

https://arxiv.org/abs/quant-ph/0406176v5