用IBM Quantum网站编程完成以下要求Program Practice Complete the following programimport numpy a s npfrom numpy import pi# Impo r ting s tanda rd Qi s ki t l i b r a r i e sfrom q i s k i t import QuantumCircuit
import numpy as np from numpy import pi
Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, assemble, Aer from qiskit import IBMQ, execute from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector from qiskit.visualization import plot_histogram from qiskit_textbook.problems import dj_problem_oracle
1. The goal is to reach the state |1>
def lab1_ex1(): qc = QuantumCircuit(1) qc.x(0) # Apply X gate to qubit 0 return qc
state = Statevector.from_instruction(lab1_ex1()) plot_bloch_multivector(state)
2. The goal is to reach the state |+> = sqrt(1/2) (|0> + |1>)
def lab1_ex2(): qc = QuantumCircuit(1) qc.h(0) # Apply Hadamard gate to qubit 0 return qc
state = Statevector.from_instruction(lab1_ex2()) plot_bloch_multivector(state)
3. Construct the Bell state |Ψ+> = sqrt(1/2) (|01> + |10>)
def lab1_ex5(): qc = QuantumCircuit(2, 2) qc.h(0) # Apply Hadamard gate to qubit 0 qc.cx(0, 1) # Apply CNOT gate with control qubit 0 and target qubit 1 return qc
qc = lab1_ex5() qc.draw() # we draw the circui
原文地址: https://www.cveoy.top/t/topic/iBKR 著作权归作者所有。请勿转载和采集!