# Which gate combination should I use? [closed]

From my circuits in ibm q the final output is given by only a single qbit Which gives state |ψ⟩

Tell me a combination of gates to do the following

If |ψ⟩ = |0⟩ Then output |0⟩

If |ψ⟩=α|0⟩+β|1⟩ Then output |1⟩

If |ψ⟩=|1⟩ Then output |1⟩

As you've specified it, given a state $$|\psi\rangle$$, there is no deterministic strategy that can fulfil all three conditions that you specify.

However, you imply that what you actually have is a unitary procedure $$U$$ to create $$U|0\rangle=|\psi\rangle$$. This means that you can, in fact, do what you ask. It's called amplitude amplification. Basically, the Grover iterator that you need is $$U^\dagger ZUZ,$$ where $$Z$$ is the standard Pauli Z matrix. You haven't specified if $$\alpha$$ is a known or unknown parameter. If it's known, you just need to run the thing $$R$$ times where $$(2R+1)\theta\approx\pi/2$$ and $$\sin\theta=\beta$$ to at least get close. If you don't know $$\alpha$$, there's a version of the protocol which includes phase estimation, which helps you do the job.

In first and last case you don't need to apply any gate directly measure the qubit you will get desire answer but in the second case you can't get |1⟩ state because your |ψ⟩ is in superposition of |0⟩, |1⟩. If you try to measure the |ψ⟩ you will get $$|0\rangle$$ with probability $$|\alpha|^2$$ and $$|1\rangle$$ with probability $$|\beta|^2$$. The code below shows your second case.

import qiskit as q
from qiskit.visualization import plot_histogram

circuit = q.QuantumCircuit(2,1)
circuit.h(0)
circuit.measure(,)
job = execute(circuit, backend = Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
counts = result.get_counts(circuit)
print(counts)
circuit.draw()
plot_histogram([counts], legend=['Device'])


or you can do it like this with little manipulation.

import qiskit as q
from qiskit.visualization import plot_histogram

circuit = q.QuantumCircuit(2,1)
circuit.x(0)
circuit.h(0)
circuit.h(0)
circuit.measure(,)
job = execute(circuit, backend = Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
counts = result.get_counts(circuit)
print(counts)
circuit.draw()
plot_histogram([counts], legend=['Device'])