RY rotation on a qubit

Questions related to Qiskit
Post Reply
quantumadmin
Site Admin
Posts: 236
Joined: Mon Jul 17, 2023 2:19 pm

RY rotation on a qubit

Post by quantumadmin »

The RY gate (Rotation about the Y-axis) is a single-qubit gate in quantum computing that performs a rotation around the Y-axis of the Bloch sphere. It is represented by the following unitary matrix:

Code: Select all

RY(θ) = | cos(θ/2)  -sin(θ/2) |
        | sin(θ/2)   cos(θ/2) |
In Qiskit, you can implement the RY gate using the ry method of the QuantumCircuit class. Here's an example of how to apply an RY rotation of angle θ to a qubit:

Code: Select all

from qiskit import QuantumCircuit, Aer, execute
import numpy as np

# Create a quantum circuit with one qubit
qc = QuantumCircuit(1)

# Apply an RY rotation with angle θ
theta = np.pi / 4  # Angle of the rotation
qc.ry(theta, 0)

# Simulate the circuit
simulator = Aer.get_backend('statevector_simulator')
job = execute(qc, simulator)
result = job.result()
statevector = result.get_statevector()

print("Final state vector after RY rotation:")
print(statevector)
In this example, we create a quantum circuit with one qubit and apply an RY rotation gate to it. The ry method takes two arguments: the angle of rotation (θ) and the qubit index (0 in this case).

The above code simulates the state vector after applying the RY rotation. If you want to observe the measurement outcomes after applying the RY gate, you can add a measurement to the qubit and run the circuit on a simulator or a real quantum device.

Remember that the RY gate is a fundamental building block for quantum circuits and is used in various quantum algorithms and operations. It plays a crucial role in manipulating qubit states in quantum computations.
Post Reply