repo
stringclasses
900 values
file
stringclasses
754 values
content
stringlengths
4
215k
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 2 qubits # The default initial state of qubits will be |0> or [1,0] qc = QuantumCircuit(2) #Applying the CZ gate qc.cz(0,1) #Draw the circuit qc.draw('mpl') ...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 2 qubits # The default initial state of qubits will be |0> or [1,0] qc = QuantumCircuit(2) #Applying the hadarmad gate to target qc.h(1) #apply the cx gate to bot...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply pauli x-gate on the qubit qc.x(0) #Apply the hadamard gat...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit qc = QuantumCircuit(1) qc.x(0) qc.h(0) qc.z(0) qc.h(0) # qc.draw() qc.draw('mpl') backend = Aer.get_backend('statevector_simulator') ...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1,1) #Apply the Pauli X-gate on the qubit to make the input as |1> #qc...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 3 qubits # The default initial state of qubits will be |0> or [1,0] qc = QuantumCircuit(3) #Applying hadamard gate to all the qubits qc.h(0) qc.h(1) qc.h(2) #...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 2 qubits # The default initial state of qubits will be |0> or [1,0] qc = QuantumCircuit(2) #Applying the x gate to second qubit qc.x(1) #Draw the circuit # qc....
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with 2 qubits # The default initial state of qubits will be |0> or [1,0] qc = QuantumCircuit(2) #Applying hadamard gate to first qubit, then x gate to second qc.h(0) q...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) # declare the intial sate as [0,1] or |1> #initial_state = [0,1] #...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply the Pauli X-gate on the qubit qc.x(0) #Draw the circuit # qc.draw() qc.draw('mpl') #Get th...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply the Pauli X-gate on the qubit to make the input to y gate as ...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply the Pauli X-gate on the qubit to make the input to y gate as ...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram from numpy import pi # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply the Pauli X-gate on the qubit to make t...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram from numpy import pi # Create a quantum circuit with a single qubit # The default initial state of qubit will be |0> or [1,0] qc = QuantumCircuit(1) #Apply the s gate and sdg gate to obtain ident...
https://github.com/minnukota381/Quantum-Computing-Qiskit
minnukota381
from qiskit import * from qiskit.visualization import plot_histogram import numpy as np # creating a constant oracle, input has no effect on the ouput # Create a quantum circuit with 2 qubits. One as input and other as output constant_oracle = QuantumCircuit(2) # get a random number from 0 or 1 output = np.r...
https://github.com/KPRoche/quantum-raspberry-tie
KPRoche
#---------------------------------------------------------------------- # QuantumRaspberryTie.qk1_local # by KPRoche (Kevin P. Roche) (c) 2017,2018,2019,2020,2021,2022.2024 # # NEW RELEASE # April 2024 to accomodate the official release of Qiskit 1.0 # using new QiskitRuntime libraries and ...
https://github.com/kvillegas33/Heisenberg_model-Qiskit
kvillegas33
# Here we are importing all packages from qiskit from qiskit import * from qiskit.circuit import Parameter from math import pi # define the number of qubits num_q = 3 theta = Parameter('θ') # Here create the quantum circuit qc = QuantumCircuit(num_q) # Here we apply the Rz gate to the ith-qubit for i in r...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
import math from typing import List, Union, Tuple import numpy as np from qiskit import QuantumCircuit, QuantumRegister from qiskit.circuit import Gate from qiskit.circuit.library import RYGate, RZGate from scipy import sparse from scipy.sparse.linalg import norm from dc_qiskit_algorithms import UniformRota...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# -*- coding: utf-8 -*- # This code is part of Qiskit. # # (C) Copyright IBM 2018, 2019. # # 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....
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2021 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed t...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/carstenblank/dc-qiskit-algorithms
carstenblank
# Copyright 2018 Carsten Blank # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
https://github.com/qiskit-community/qiskit-benchmarks
qiskit-community
import sys import site import os import importlib import json from datetime import datetime from pprint import pprint from itertools import chain from dataclasses import dataclass, asdict from json import dumps, load, JSONEncoder from contextlib import suppress import yaml import pkg_resources import imp...
https://github.com/qiskit-community/qiskit-benchmarks
qiskit-community
from qiskit import * from qiskit.transpiler.pass_manager_config import PassManagerConfig from qiskit.transpiler import CouplingMap qr = QuantumRegister(3) circuit1 = QuantumCircuit(qr, name='circuit1') circuit1.h(qr) circuit1.cx(qr[0], qr[1]) circuit1.h(qr[0]) circuit1.cx(qr[0], qr[1]) qr = QuantumRegister...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
import numpy as np from qiskit import * import matplotlib qr = QuantumRegister(2) #measurements from quantum bits = use classical register cr = ClassicalRegister(2) circuit = QuantumCircuit(qr, cr) circuit.draw() # adding quantum gates to create entanglement (Hadamart gate) circuit.h(qr[0]) %ma...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
# We import the necessary functions from Qiskit from qiskit.visualization import plot_bloch_multivector, plot_state_qsphere, visualize_transition from qiskit import QuantumCircuit, Aer, execute # We create a quantum circuit with one qubit qc = QuantumCircuit(1) # We execute the quantum circuit on a statevector...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
# We import necessary libraries from Qiskit from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram # We create a quantum circuit with two qubits and two classical bits qc = QuantumCircuit(2, 2) # We apply the CX gate with the first qubit as control and the second qubit ...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
# We import necessary libraries from Qiskit from qiskit import QuantumCircuit, Aer, execute # We create a quantum circuit with one qubit coin_flip_circuit = QuantumCircuit(1, 1) # We apply the H-gate (Hadamard gate) to create a superposition coin_flip_circuit.h(0) # We measure the qubit coin_flip_circuit.m...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram, visualize_transition qc = QuantumCircuit(1,1) qc.h(0) visualize_transition(qc) qc.measure(0,0) qc.draw(output='mpl') simulator = Aer.get_backend('qasm_simulator') result = execute(qc, backend=simulator...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
# We import the necessary functions from Qiskit from qiskit.visualization import plot_bloch_multivector, visualize_transition from qiskit import QuantumCircuit, Aer, execute from math import pi # We create a quantum circuit with one qubit qc = QuantumCircuit(1) # We execute the quantum circuit on a statevecto...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram, visualize_transition quantum_bit = 1 classical_bit = 1 circ = QuantumCircuit(quantum_bit, classical_bit) circ.x(0) circ.draw(output='mpl') visualize_transition(circ) circ.measure(0, 0) simulator = Aer.g...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit from qiskit.visualization import visualize_transition qc = QuantumCircuit(1) qc.y(0) qc.draw('mpl') visualize_transition(qc) qc1 = QuantumCircuit(1) qc1.x(0) qc1.y(0) qc1.draw('mpl') visualize_transition(qc1)
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit from qiskit.visualization import visualize_transition qc = QuantumCircuit(1) qc.z(0) qc.draw('mpl') visualize_transition(qc) qc1 = QuantumCircuit(1) qc1.x(0) qc1.z(0) qc1.draw('mpl') visualize_transition(qc1)
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit, execute, Aer from qiskit.visualization import plot_histogram, plot_state_qsphere # We create a quantum circuit with 2 qubits and 2 classical bits qc1 = QuantumCircuit(2, 2) # We apply the Hadamard gate to the first qubit qc1.h(0) # We apply the CNOT gate to the first and s...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
#Assign these values as per your requirements. global min_qubits,max_qubits,skip_qubits,max_circuits,num_shots,Noise_Inclusion min_qubits=3 max_qubits=31 skip_qubits=1 max_circuits=2 num_shots=1000 method=1 #Use method=2 for another approach of Benchmarking (default->1) num_resets = 2 # Variable for number of...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer from qiskit.visualization import plot_state_qsphere, plot_histogram # We create a Quantum Register with 3 qubits. q = QuantumRegister(3, 'qubit') # We create a Classical Register with 3 bits. c = ClassicalRegister(3, 'Classical...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
import sys sys.path.append('../') from circuits import sampleCircuitA, sampleCircuitB1, sampleCircuitB2,\ sampleCircuitB3, sampleCircuitC, sampleCircuitD, sampleCircuitE,\ sampleCircuitF from entanglement import Ent import warnings warnings.filterwarnings('ignore') labels = [ 'Circuit A', 'Ci...
https://github.com/ahkatlio/QHSO_Basics_of_Qiskit
ahkatlio
import numpy as np import matplotlib.pyplot as plt # Constants electron_wavelength = 0.1 # De Broglie wavelength of electrons slit_width = 0.1 # Width of each slit screen_distance = 2.0 # Distance from the slits to the screen screen_width = 2.0 # Width of the screen screen_resolution = 800 # Number of pix...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
import numpy as np import pytest from qiskit import Aer from qiskit.algorithms.gradients import ReverseEstimatorGradient from qiskit.circuit.library import TwoLocal from qiskit.primitives import Estimator from qiskit.quantum_info import SparsePauliOp np.random.seed(0) max_parallel_threads = 12 gpu = Fals...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
import numpy as np # Import Qiskit from qiskit import QuantumCircuit, transpile from qiskit_qulacs import QulacsProvider from qiskit_qulacs.qulacs_backend import QulacsBackend from qiskit.visualization import plot_histogram, plot_state_city import qiskit.quantum_info as qi seed = 42 np.random.seed(seed) ...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
import numpy as np from qiskit.circuit.library import IQP from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager from qiskit.quantum_info import SparsePauliOp, random_hermitian n_qubits = 4 mat = np.real(random_hermitian(n_qubits, seed=1234)) circuit = IQP(mat) observable = SparsePaul...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Variational Quantum Eigensolver (VQE) tutorial.""" from IPython.display import clear_output import matplotlib.pyplot as plt import numpy as np from qiskit_nature.units import DistanceUnit from qiskit_nature.second_q.drivers import PySCFDriver from qiskit_nature.second_q.mappers import JordanWignerMapper f...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Util functions for provider""" import re import warnings from math import log2 from typing import Any, Dict, Iterable, List, Set, Tuple import numpy as np import psutil from qiskit import QuantumCircuit from qiskit.circuit import Parameter, ParameterExpression from qiskit.circuit import library as lib ...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""QulacsBackend class.""" import copy import time import uuid from collections import Counter from typing import List, Union import numpy as np from qiskit import QuantumCircuit from qiskit.providers import BackendV1 as Backend from qiskit.providers import JobStatus, Options from qiskit.providers.models ...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Tests for the Adapter class.""" from unittest import TestCase import numpy as np import pytest import qiskit.circuit.library as lib from ddt import data, ddt from qiskit import QuantumCircuit, QuantumRegister, transpile from qiskit.circuit import Parameter, ParameterVector from qiskit.circuit.library imp...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Tests for qulacs backend.""" from unittest import TestCase import numpy as np from qiskit import QuantumCircuit, transpile from qiskit.circuit.random import random_circuit from qiskit.result import Result from qiskit_aer import Aer from qiskit_qulacs.qulacs_backend import QulacsBackend from tests.utils...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Test Qulacs Estimator Gradients""" from unittest import TestCase import numpy as np import pytest from ddt import data, ddt from qiskit import QuantumCircuit, transpile from qiskit.circuit import Parameter, ParameterVector from qiskit.circuit.library import EfficientSU2 from qiskit.circuit.library.standa...
https://github.com/Gopal-Dahale/qiskit-qulacs
Gopal-Dahale
"""Tests for qulacs sampler.""" from unittest import TestCase import numpy as np from qiskit import QuantumCircuit from qiskit.circuit import Parameter from qiskit.circuit.library import RealAmplitudes, UnitaryGate from qiskit.primitives import SamplerResult from qiskit.providers import JobStatus from qis...
https://github.com/LSEG-API-Samples/Article.EikonAPI.Python.OptionPricingUsingQiskitAndEikonDataAPI
LSEG-API-Samples
import warnings warnings.filterwarnings("ignore") import qiskit.tools.jupyter %qiskit_version_table import eikon as ek print("Eikon version: ", ek.__version__) import numpy as np import pandas as pd import datetime import matplotlib.pyplot as plt import seaborn as sns import qiskit from qiskit import A...
https://github.com/LSEG-API-Samples/Article.EikonAPI.Python.OptionPricingUsingQiskitAndEikonDataAPI
LSEG-API-Samples
# ! pip install qiskit qiskit-finance==0.2.1 import warnings warnings.filterwarnings("ignore") import qiskit.tools.jupyter %qiskit_version_table from qiskit import IBMQ IBMQ.save_account('MY_API_TOKEN', overwrite=True) # ! pip install eikon import eikon as ek print("Eikon version: ", ek.__version__) ...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 5 16:33:48 2022 @author: pejmanjouzdani """ # from SimulateMQITE.log_config import logger import numpy as np import pandas as pd from qiskit import QuantumCircuit, transpile from qiskit import Aer class AmplitudeClass: ...
https://github.com/JouziP/MQITE
JouziP
# -*- coding: utf-8 -*- # This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # 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....
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 6 12:18:27 2022 @author: pejmanjouzdani """ import numpy as np from qiskit.circuit.exceptions import CircuitError from qiskit import QuantumCircuit def getQCirc(circ_U, Q): ############# # Qiskit error if not isinst...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 6 12:15:52 2022 @author: pejmanjouzdani """ import numpy as np from qiskit import QuantumCircuit ################################################################ ################################################################ def ...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 5 17:10:42 2022 @author: pejmanjouzdani """ import numpy as np import pandas as pd from BasicFunctions.functions import getState def getStateVectorValuesOfAmpl( j_list, circ_uhu, significant_figures, machine_precision): ...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 6 12:26:49 2022 @author: pejmanjouzdani """ from qiskit import QuantumCircuit def getUQUCirc(circ_U, circ_Q): circ_UQU = QuantumCircuit.copy(circ_Q) ## QU|0> circ_UQU = circ_UQU.compose(QuantumCircuit.copy(circ_U.inverse())...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 4 17:53:16 2022 @author: pejmanjouzdani """ import logging from time import time class TestCirc: def __init__(self, func, FLAG=False): self.func = func self.func.name = func.__name__ self.FLAG...
https://github.com/JouziP/MQITE
JouziP
# -*- coding: utf-8 -*- # This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # 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....
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 13 12:40:38 2022 @author: pejmanjouzdani """ # # from SimulateMQITE.log_config import logger import pandas as pd import numpy as np from qiskit import QuantumCircuit from MultiQubitGate.functions import multiqubit from BasicFun...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 13 14:39:39 2022 @author: pejmanjouzdani """ import numpy as np import pandas as pd from qiskit import QuantumCircuit, transpile from qiskit import Aer # from Amplitude.AmplitudeFunctions.getAmplitudes import getAmplitudes # f...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 8 18:22:28 2022 Created on Thu Oct 13 10:29:00 2022 @author: pej """ import numpy as np import pandas as pd from qiskit import QuantumCircuit from MultiQubitGate.functions import multiqubit from BasicFunctions.f...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 6 11:35:58 2022 @author: pejmanjouzdani """ import numpy as np from qiskit import QuantumCircuit from BasicFunctions.functions import getBinary def getImagPart_base_circ(nspins, circ_U , Q, j_ref, gamma = np.pi/10): ...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 8 18:22:28 2022 Created on Thu Oct 13 10:29:00 2022 @author: pej """ import numpy as np import pandas as pd from qiskit import QuantumCircuit from MultiQubitGate.functions import multiqubit from BasicFunctions.f...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 6 12:00:14 2022 @author: pejmanjouzdani """ import numpy as np from qiskit import QuantumCircuit from BasicFunctions.functions import getBinary def getRealPart_base_circ(nspins, circ_U , Q, j_ref, gamma = np.pi/10): ...
https://github.com/JouziP/MQITE
JouziP
from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram # simulate in statevector_simulator def simulateStatevector(circuit): backend = Aer.get_backend('statevector_simulator') result = execute(circuit.remove_final_measurements(inplace=False), backend, shots=1).r...
https://github.com/JouziP/MQITE
JouziP
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 2 14:12:30 2022 @author: pejmanjouzdani """ import numpy as np import pandas as pd from qiskit import QuantumCircuit from BasicFunctions.functions import timing, getBinary, getGateStats from MultiQubitGate.functions imp...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # A quantum circuit is composed by quantum and classical bits. # # here are the objects that we use to create a quantum circuit in qiskit from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit # we use a quantum register to keep our quantum bits. qreg = QuantumRegister(1) # in this example ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# we import all necessary methods and objects from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from random import randrange # we will use 10 quantum bits and 10 classical bits qreg3 = QuantumRegister(10) creg3 = ClassicalRegister(10) mycircuit3 = QuantumCircuit(qreg3,creg3)...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your solution is here # from random import randrange def experiment(n): num_tails = 0 num_heads = 0 for i in range(n): if(randrange(2) == 0): # 0 is the head num_heads += 1 else: num_tails += 1 return num_heads, num_tails num_heads1000, num_ta...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
from random import randrange for experiment in [100,1000,10000,100000]: heads = tails = 0 for i in range(experiment): if randrange(2) == 0: heads = heads + 1 else: tails = tails + 1 print("experiment:",experiment) print("the ratio of #heads/#tails is",(heads/tails),"heads =",hea...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # OUR SOLUTION # # initial case # We assume that the probability of getting head is 1 at the beginning, # because Asja will start with one euro. prob_head = 1 prob_tail = 0 # # first coin-flip # # if the last result was head new_prob_head_from_head = prob_head * 0.6 new_prob_tail_from_head = p...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # We copy and paste the previous code # # initial case # We assume that the probability of getting head is 1 at the beginning, # becasue Asja will start with one euro. prob_head = 1 prob_tail = 0 number_of_iterations = 10 for i in range(number_of_iterations): # if the last result was head ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your code is here # prob_dict = dict() prob_6 = 1/(7+5+4+2+6+1) prob_5 = 6/(7+5+4+2+6+1) prob_4 = 2/(7+5+4+2+6+1) prob_3 = 4/(7+5+4+2+6+1) prob_2 = 5/(7+5+4+2+6+1) prob_1 = 7/(7+5+4+2+6+1) prob_dict['6'] = prob_6 prob_dict['5'] = prob_5 prob_dict['4'] = prob_4 prob_dict['3'] = prob_3 prob_dict['2'] =...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# all portions are stored in a list all_portions = [7,5,4,2,6,1]; # let's calculate the total portion total_portion = 0 for i in range(6): total_portion = total_portion + all_portions[i] print("total portion is",total_portion) # find the weight of one portion one_portion = 1/total_portion print("the...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your solution is here # import numpy as np random_arr = np.random.randn(3,3) random_arr = np.abs(random_arr) sum_elements = np.sum(random_arr) random_arr = random_arr / sum_elements print(random_arr) print("verify the probabilistic state from sum of elements: " + str(np.sum(random_arr))) # # your so...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# let's start with a zero matrix A = [ [0,0,0], [0,0,0], [0,0,0] ] # we will randomly pick the entries and then make normalization for each column # it will be easier to iteratively construct the columns # you may notice that each column is a probabilistic state from random import randrange no...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
import matplotlib.pyplot as plt import numpy as np x = np.arange(-3*np.pi,3*np.pi,0.1) # start,stop,step y = np.sin(x) yaxis = 0 plt.axes() plt.plot(x,y,xaxis) plt.show()
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # define a quantum register with one qubit qreg1 = QuantumRegister(1) # define a classical register with one bit # it stores the measurement result of the quantum...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # define a quantum register with one qubit qreg3 = QuantumRegister(1) # define a classical register with one bit # it stores the measurement result of the quantum...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your solution is here #
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your code is here # (you may find the values by hand (in mind) as well) # import numpy as np v = np.array([0, -0.1, 0.3, 0.4, 0.5]) v_square = v ** 2 print(v_square) a = 1 - np.sum(v_square[1:]) a = np.sqrt(a) print("a: "+ str(a)) u = np.array([1/np.sqrt(2), -1/np.sqrt(3)]) u_square = u ** 2 print(...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# vector |v> print("vector |v>") values = [-0.1, -0.3, 0.4, 0.5] total = 0 # summation of squares for i in range(len(values)): total += values[i]**2; # add the square of each value print("total is ",total) print("the missing part is",1-total) print("so, the value of 'a' can be",(1-total)**0.5,"or",-(1...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# # your solution is here # # Find expression to create the states def expression(a, b, c): return (1/(a**(0.5) - (b + 2 * (c)**(0.5))**(0.5))) # Construct the quantum state quantum_state = [expression(3, 5, 6), expression(3, 7, 12), expression(5, 13, 40), expression(7, 15, 26)] # Verify validity of t...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
def square_roots(a,b,c): # we iteratively calculate the expression with many square roots # we start with c and continue with b and a result = c**0.5 # square root of c result = 2 * result # 2*sqrt(c) result = result + b # b + 2*sqrt(c) result = result**0.5 # square root result = a**0...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # we use four pairs of two qubits in order to see all results at once # the first pair -> qubits with indices 0 and 1 # the second pair -> qubits with indices 2 and 3...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # import randrange for random choices from random import randrange n = 5 m = 4 states_of_qubits = [] # we trace the state of each qubit also by ourselves qreg1...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer all_pairs = ['00','01','10','11'] for pair in all_pairs: # create a quantum curcuit with two qubits: Asja's and Balvis' qubits. # both are initially set ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer all_pairs = ['00','01','10','11'] for pair in all_pairs: # create a quantum curcuit with two qubits: Asja's and Balvis' qubits. # both are initially set ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import the drawing methods from matplotlib.pyplot import plot, figure # draw a figure figure(figsize=(6,6), dpi=60) # draw the origin plot(0,0,'ro') # a point in red color # draw the quantum states as points (in blue color) plot(1,0,'bo') plot(0,1,'bo') plot(-1,0,'bo') plot(0,-1,'bo') # import the ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# randomly create a 2-dimensional quantum state from random import randrange def random_quantum_state(): first_entry = randrange(101) first_entry = first_entry/100 first_entry = first_entry**0.5 if randrange(2) == 0: first_entry = -1 * first_entry second_entry = 1 - (first_entry**2...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
%run qlatvia.py draw_qubit() draw_quantum_state(3/5,4/5,"|v>") %run qlatvia.py draw_qubit() draw_quantum_state(3/5,4/5,"|v>") from matplotlib.pyplot import arrow, text, gca # the projection on |0>-axis arrow(0,0,3/5,0,color="blue",linewidth=1.5) arrow(0,4/5,3/5,0,color="blue",linestyle='dotted') ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# randomly create a 2-dimensional quantum state from random import randrange def random_quantum_state(): first_entry = randrange(101) first_entry = first_entry/100 first_entry = first_entry**0.5 if randrange(2) == 0: first_entry = -1 * first_entry second_entry = 1 - (first_entry**2...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# %%writefile FILENAME.py # your function is here from math import cos, sin, pi from random import randrange def random_quantum_state2(): # # your codes are here # # randomly create quantum states angle_random = randrange(361) # get the angles cos, sin angle_random_radian = (2 * ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# randomly create a 2-dimensional quantum state from math import cos, sin, pi from random import randrange def random_quantum_state2(): angle_degree = randrange(360) angle_radian = 2*pi*angle/360 return [cos(angle_radian),sin(angle_radian)] # include our predefined functions %run qlatvia.py # d...