This file contains 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
```python | |
import numpy as np | |
from qutip import * | |
# Definir los estados de la base | |
up = basis(2, 0) | |
down = basis(2, 1) | |
# Definir los operadores de Pauli | |
sigma_x = sigmax() |
This file contains 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, Aer, execute | |
from qiskit.aqua import QuantumInstance | |
from qiskit.aqua.algorithms import Shor | |
number_to_factor = 15 | |
backend = Aer.get_backend('qasm_simulator') | |
quantum_instance = QuantumInstance(backend) | |
shor = Shor(quantum_instance=quantum_instance) |
This file contains 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, execute, Aer | |
def deutsch_jozsa_oracle(n): | |
oracle_qc = QuantumCircuit(n+1) | |
b_str = format(7, f'0{n}b') | |
for qubit_idx in range(n): | |
if b_str[qubit_idx] == '1': | |
oracle_qc.x(qubit_idx) | |
oracle_qc.x(n) | |
for qubit_idx in range(n): |
This file contains 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
open Microsoft.Quantum.Diagnostics; | |
operation DeutschJozsaAlgorithm (f : ((Qubit[], Qubit) => Unit is Adj)) : Bool { | |
using (register = Qubit[2]) { | |
// Prepare the initial state. | |
H(register[0]); | |
X(register[1]); | |
H(register[1]); | |
// Apply the oracle. |
This file contains 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
open Microsoft.Quantum.Diagnostics; | |
open Microsoft.Quantum.Search; | |
operation GroverSearchStructured() : Unit { | |
// Define the list to search. | |
let markedElements = [(0, 1), (1, 0), (1, 1)]; | |
// Define the number of qubits needed to represent the list. | |
let nQubits = 2; |
This file contains 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
open Microsoft.Quantum.Diagnostics; | |
open Microsoft.Quantum.Search; | |
operation GroverSearch() : Unit { | |
// Define the list to search. | |
let markedElements = [1, 3]; | |
// Define the number of qubits needed to represent the list. | |
let nQubits = 2; |
This file contains 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
open Microsoft.Quantum.Chemistry; | |
operation HydrogenMolecule() : Unit { | |
// Define the molecular Hamiltonian. | |
let hamiltonian = Hydrogen(); | |
// Allocate qubits. | |
using (qubits = Qubit[hamiltonian.NSpinOrbitals]) { | |
// Prepare the initial state. | |
PrepareAndMeasureGroundState(hamiltonian, qubits); |
This file contains 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
open Microsoft.Quantum.Primitive; | |
operation SimpleQuantumProgram() : Unit { | |
// Allocate two qubits. | |
using (qubits = Qubit[2]) { | |
// Apply a Hadamard gate to the first qubit. | |
H(qubits[0]); | |
// Apply a CNOT gate between the first and second qubits. | |
CNOT(qubits[0], qubits[1]); |
This file contains 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
import numpy as np | |
from qiskit import QuantumCircuit, Aer, execute | |
def grovers_algorithm(): | |
# Definir el número de qubits y el número de iteraciones | |
n = 2 | |
iterations = 2 | |
# Inicializar los qubits y el oráculo | |
qc = QuantumCircuit(n + 1, n) |
This file contains 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, Aer, execute | |
from qiskit.aqua import QuantumInstance | |
from qiskit.aqua.algorithms import Shor | |
n = 15 | |
a = 2 | |
backend = Aer.get_backend('qasm_simulator') | |
quantum_instance = QuantumInstance(backend, shots=1024) |
OlderNewer