1
$\begingroup$

Qubit in polar form $$\left|\psi\right\rangle=\cos(\theta/2)\left|0\right\rangle+\sin(\theta/2)\left|1\right\rangle $$

Now lets say i want to keep $\cos(\theta/2) = 50.400 $ degrees angle and $\sin(\theta/2) = 35.80 $ degrees angle into a qubit using qiskit? or how can i convert these angles into a gate so that state zero $\left|0\right\rangle$ which is default input in qiskit to get to desired state $\left|\psi\right\rangle=50.400\left|0\right\rangle+35.80\left|1\right\rangle $ using the angles

$\endgroup$
2
  • 2
    $\begingroup$ $cos(\theta) \leq 1 $ for all $\theta$. Similar with $\sin(\theta)$. $\endgroup$
    – KAJ226
    Apr 22, 2021 at 22:41
  • $\begingroup$ if you want to specify your $\theta$ in term of degree, just make a conversion from degree to radian. $\endgroup$
    – KAJ226
    Apr 22, 2021 at 22:43

1 Answer 1

3
$\begingroup$

The first thing I will mention is that the target state you specified,

$$|\psi\rangle = 50.40|0\rangle + 35.80|1\rangle$$

is not a valid quantum state, because the probabilities do not add up to one.

$$|50.40|^2 + |35.80|^2 = 3821.80 \neq 1 $$

However, we can normalize your equation,

$$|\psi\rangle = \frac{50.40}{\sqrt{3821.80}}|0\rangle + \frac{35.80}{\sqrt{3821.80}}|1\rangle$$

which is a valid quantum state. Now, starting over with the general state representation,

$$|\psi\rangle = \cos{(\theta/2)}|0\rangle + \sin{(\theta/2)}|1\rangle$$

where $0 \leq \theta \leq \pi$. To solve for $\theta$ we do,

$$\cos{(\theta/2)} = \frac{50.40}{\sqrt{3821.80}}$$ $$\theta = 2 * \cos^{-1}{\bigg(\frac{50.40}{\sqrt{3821.80}}\bigg)} = 1.23523 \text{ radians}$$

We know that action of a quantum gate is found by multiplying the matrix representing the gate with the vector which represents the quantum state.

$$|\psi'\rangle = U|\psi\rangle$$

A general unitary must be able to take the $|0\rangle$ to the above state. Such a unitary is

$$ U = \begin{pmatrix} \cos{(\theta/2)} & -e^{i \lambda}\sin{(\theta/2)} \\ e^{i \phi}\sin{(\theta/2)} & e^{i\lambda + i\phi}\cos{(\theta/2)} \end{pmatrix} $$

where $0 \leq \phi < 2\pi$, and $0 \leq \lambda < 2\pi$. In Qiskit you have access to this general unitary using the $u$ gate:

$$u(\theta, \phi, \lambda) = U(\theta, \phi, \lambda)$$

To get our desired state, we will plug in $\phi = \lambda = 0$, and $\theta = 1.23523$:

from qiskit import QuantumCircuit, QuantumRegister, assemble, Aer
from qiskit.visualization import plot_histogram

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.u(1.23523,0,0,q)

svsim = Aer.get_backend('statevector_simulator'). # Tell Qiskit how to simulate our circuit
qobj = assemble(qc) # Create a Qobj from the circuit for the simulator to run
result = svsim.run(qobj).result() # Do the simulation and return the result
out_state = result.get_statevector()

>>> print(out_state) # Display the output state vector
[0.81526191+0.j 0.57909241+0.j]

$\cos{(\theta/2)} = \frac{50.40}{\sqrt{3821.80}} \simeq 0.815$ and $\sin{(\theta/2)} = \frac{35.80}{\sqrt{3821.80}} \simeq 0.579$, which agrees with the results of the Qiskit Aer simulator. To visualize the probability distribution of your constructed state, you can run the following:

counts = result.get_counts()
plot_histogram(counts)

Good luck!

$\endgroup$
5
  • 1
    $\begingroup$ Thank You for responding. Can you tell me how we will get $\theta = 1.2353$? can I go back to my original $\psi$ form the output state vector(I can right)? $\endgroup$
    – John Jones
    Apr 23, 2021 at 15:49
  • $\begingroup$ Just edited my answer to explain how you calculate $\theta$. Which original $\psi$ are you referring to? If you are trying to reach the state $|\psi\rangle = 50.40|0\rangle + 35.80|1\rangle$, the answer is that it is not possible, because it is unnormalized. All physically realizable quantum states must satisfy $|\psi|^2 = 1$. For information on probability and normalization, I recommend "An Introduction to Quantum Mechanics" by David Griffiths, Sections 1.1 - 1.4. $\endgroup$
    – ryanhill1
    Apr 23, 2021 at 19:54
  • $\begingroup$ Thank You for the explanation. I am looking to go back to normalized one, If I pass the output state to through the same gate again? one more question sorry but can i use normalized complex numbers in place of 50.40 and 35.80, follow the same procedure? $\endgroup$
    – John Jones
    Apr 23, 2021 at 20:04
  • $\begingroup$ The output state is the normalized state $|\psi\rangle = \frac{50.40}{\sqrt{3821.80}}|0\rangle + \frac{35.80}{\sqrt{3821.80}}|1\rangle$. If you were add a second qc.u(1.23523,0,0,q) gate to the circuit, you would reach a completely different state. However, if you were to add a qc.u(-1.23523,0,0,q) gate, you would arrive back at the state $|\psi\rangle = |0\rangle$. And yes, you can use any combination of real and/or complex numbers and follow the same procedure, so long as $|\psi|^2 = 1$. $\endgroup$
    – ryanhill1
    Apr 23, 2021 at 20:37
  • $\begingroup$ Can I teleport the normalized $|\psi\rangle$ and see the state of the vector after teleporting? I have have been posting these question before ? great full if you help me with this. $\endgroup$
    – John Jones
    Apr 23, 2021 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.