Code: Select all
RY(θ) = | cos(θ/2) -sin(θ/2) |
| sin(θ/2) cos(θ/2) |
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)
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.