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
pi=3.14159265359 | |
def cos(T): | |
T=T%(2*pi) | |
c=1 | |
t=1 | |
for j in range(1,16): | |
t=-t*T**2/(2*j*(2*j-1)) | |
c+=t | |
return c | |
def sin(T): |
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
class QuantumCircuit: | |
def __init__(c,n): | |
c.n=n | |
c.data = [] | |
def x(c,q): | |
c.data.append(('r',pi,q)) | |
def rx(c,T,q): | |
c.data.append(('r',T,q)) | |
def h(c,q): | |
c.data.append(('h',q)) |
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
def execute(c,shots=1024,output='counts'): | |
p2s=['I','X','Y','Z']*(c.n==2)+['']*(c.n==1) | |
def j(p1,p2,q): | |
return (p1+p2)*(q==1)+(p2+p1)*(q==0) |
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 PIL import Image | |
import time | |
dark = 10 | |
while True: | |
# get new this | |
left = {} |
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
Copyright IBM - Research 2020 | |
Apache 2.0 |
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 secrets | |
import numpy as np | |
samples = 1000000 | |
zs = 0 | |
os = 0 | |
number_list = [] | |
for _ in range(samples): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
This code is licensed under the Apache License, Version 2.0. You may | |
obtain a copy of this license in the LICENSE.txt file in the root directory | |
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | |
Any modifications or derivative works of this code must retain this | |
copyright notice, and modified files need to carry a notice indicating | |
that they have been altered from the originals. |
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 | |
fromm qiskit.quantum_info import Densitymatrix | |
from qiskit.providers.aer.utils import insert_noise | |
# make a circuit (her with 2 qubits) | |
circ = QuantumCircuit(2) | |
# add a noise model to make it noisy | |
noise_circ = insert_noise(circuit, noise_model, transpile=True) |