# How do I Initiate with my own alpha and beta values instead of starting form qubit in state zero in IBM Q?

Let's say I have normalized values of $$\alpha$$ and $$\beta$$ as

$$\alpha =(0.27524094128159016+0.8257228238447705j)$$

$$\beta =(-0.22019275302527214+0.4403855060505443j)$$

How do I initialize my circuit starting from these values instead of qubit q[0] to be in state $$|0\rangle$$.

• Welcome to QCSE! Could you explain what $\alpha$ and $\beta$ are and what is q[0]? Also note that you can use mathjax to improve rendering of mathematical formulas. – Adam Zalcman Feb 28 at 4:17
• Thank you for responding. let's say a qubit = alpha(ket_zero) + beta(ket_one) alpha and beta are probabilities of finding qubits in state zero or state one. in IBM Q they are initializing with qubit bit in state zero if we add Hadamard gate then we can convert a qubit into a superposition(will have equal probabilities). I would like to have those probabilities as alpha and beta which i mentioned earlier. – bhagi radh Feb 28 at 4:37

If you want to start at a specific initial state, you can use qiskit initialize function to help you. For example,

from qiskit import QuantumCircuit
num_qubits = 1
vector = [-0.22019275302527214, 0.4403855060505443j]
initial_state = vector/np.linalg.norm(vector)
circuit = QuantumCircuit(num_qubits,num_qubits)
circuit.initialize(initial_state, 0)
print(circuit)

┌───────────────────────────────┐
q_0: ┤ initialize(-0.44721,0.89443j) ├
└───────────────────────────────┘
c: 1/═════════════════════════════════



Once you do this, you can perform gate operations as normal... for example:

circuit.h(0)
circuit.ry(1.5,0)
print(circuit)

┌───────────────────────────────┐┌───┐┌─────────┐
q_0: ┤ initialize(-0.44721,0.89443j) ├┤ H ├┤ RY(1.5) ├
└───────────────────────────────┘└───┘└─────────┘
c: 1/═════════════════════════════════════════════════



If you want the QASM code as commented then you can do it as follow:

qasm_circuit = circuit.decompose().decompose().decompose()
print(qasm_circuit)
print(qasm_circuit.qasm())

┌────────────┐┌──────────┐┌────────────┐┌────────────┐
q_0: ─|0>─┤ RY(2.2143) ├┤ U1(-π/2) ├┤ U(π/2,0,π) ├┤ U(1.5,0,0) ├
└────────────┘└──────────┘└────────────┘└────────────┘
c: 1/═══════════════════════════════════════════════════════════

OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg c[1];
reset q[0];
ry(2.2142974) q[0];
u1(-pi/2) q[0];
u(pi/2,0,pi) q[0];
u(1.5,0,0) q[0];