This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit_ibm_provider import IBMProvider | |
| provider = IBMProvider() | |
| backends = provider.backends() | |
| simulator_backend = provider.get_backend('ibmq_qasm_simulator') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit import Aer | |
| simulator = Aer.get_backend('aer_simulator') | |
| circ = ... | |
| result = simulator.run(circ).result() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit_dynamics import Solver, Signal | |
| solver = Solver(static_hamiltonian=..., | |
| hamiltonian_operators = [...], | |
| hamiltonian_signals = [Signal(envelope=1., carrier_freq=nu_d)]) | |
| sol = solver.solve(t_span = [0., ...], y0 = Statevector(...), t_eval = np.linspace(...)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit_optimization.algorithms import MinimumEigenOptimizer | |
| from qiskit_optimization.translators import from_docplex_mp | |
| from qiskit.algorithms import QAOA | |
| from qiskit.algorithms.optimizers import SPSA | |
| model = Model() | |
| model.maximize(...) | |
| qaoa = QAOA(optimizer=SPSA(maxiter=250), reps=5, quantum_instance=...) | |
| algorithm = MinimumEigenOptimizer(qaoa) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit.algorithms import AmplitudeEstimation | |
| from qiskit_finance.applications import FixedIncomePricing | |
| problem = FixedIncomePricing(...).to_estimation_problem() | |
| algo = AmplitudeEstimation(num_eval_qubits=num_eval_qubits, quantum_instance=...) | |
| result = algo.estimate(problem) | |
| print(f"Estimated value:\t{fixed_income.interpret(result):.4f}") | |
| print(f"Probability: \t{result.max_probability:.4f}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit.algorithms.optimizers import COBYLA | |
| from qiskit.circuit.library import TwoLocal, ZZFeatureMap | |
| from qiskit_machine_learning.algorithms import VQC | |
| from qiskit_machine_learning.datasets import ad_hoc_data | |
| feature_dim, training_size, test_size = ... | |
| training_features, training_labels, test_features, test_labels = \ | |
| ad_hoc_data(training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit.algorithms import VQE | |
| from qiskit.circuit.library import TwoLocal | |
| from qiskit_nature.drivers.second_quantization import PySCFDriver | |
| from qiskit_nature.problems.second_quantization.electronic import ElectronicStructureProblem | |
| from qiskit.algorithms.optimizers import L_BFGS_B | |
| from qiskit_nature.mappers.second_quantization import ParityMapper | |
| from qiskit_nature.converters.second_quantization import QubitConverter | |
| from qiskit_nature.circuit.library import HartreeFock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit import QuantumCircuit, transpile | |
| from qiskit.providers.basicaer import QasmSimulatorPy | |
| qc = QuantumCircuit(2, 2) | |
| qc.h(0) | |
| qc.cx(0, 1) | |
| qc.measure([0,1], [0,1]) | |
| backend_sim = QasmSimulatorPy() | |
| transpiled_qc = transpile(qc, backend_sim) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit_experiments.library.calibration import RoughXSXAmplitudeCal | |
| from qiskit_experiments.calibration_management.calibrations import Calibrations | |
| provider = ... | |
| backend = provider.get_backend('ibmq_armonk') | |
| qubit = 0 | |
| cals = Calibrations.from_backend(backend) | |
| rabi = RoughXSXAmplitudeCal(qubit, cals, backend=backend) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from qiskit.opflow import Zero, One, H, CX, I | |
| print(((~One^2) @ (CX.eval('01'))).eval()) | |
| print(((H^5) @ ((CX^2)^I) @ (I^(CX^2)))**2) | |
| print((((H^5) @ ((CX^2)^I) @ (I^(CX^2)))**2) @ (Minus^5)) | |
| print(((H^I^I)@(X^I^I)@Zero)) | |
| # (1+0j) | |
| # βββββ βββββ | |
| # q_0: βββ βββ€ H βββββββββ βββ€ H ββββββ |
NewerOlder