Created
May 17, 2020 20:29
-
-
Save sgmenda/b4d1f219ef7ae50a6749b691084c91b2 to your computer and use it in GitHub Desktop.
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 sympy | |
from sympy import I, sqrt, exp, pi | |
from sympy.physics.quantum import qapply | |
from sympy.physics.quantum import Ket, Bra | |
from sympy.physics.quantum import InnerProduct, OuterProduct | |
from sympy.physics.quantum.qubit import Qubit | |
from sympy.physics.quantum.dagger import Dagger | |
def inner_product(a,b): | |
k0 = Qubit(0) | |
k1 = Qubit(1) | |
ketpsi = a*k0 + b*k1 | |
brapsi = Dagger(ketpsi) | |
ip = brapsi * ketpsi | |
return qapply(ip) | |
def ket_ip(a0,a1,b0,b1): | |
k0 = Qubit(0) | |
k1 = Qubit(1) | |
ketpsi1 = a0*k0 + a1*k1 | |
ketpsi2 = b0*k0 + b1*k1 | |
brapsi1 = Dagger(ketpsi1) | |
ip = brapsi1 * ketpsi2 | |
return qapply(ip) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment