001-001-dirac-notation-and-photon-polarisation.ipynb

In [1]:
from sympy.physics.quantum import *
from sympy.physics.quantum.cartesian import *
from sympy.physics.quantum.operator import *
from sympy.physics.quantum.state import *
from sympy import *
from sympy.core.relational import *
from sympy.physics.units import *
from sympy.abc import a, b, x, y, z, t, alpha, n, theta, h, f, lamda
In [2]:
dotSym = Symbol('.')
display(dotSym)
$\displaystyle .$
In [3]:
a_1, a_2, a_3, a_n_1, a_n = symbols('a_1 a_2 a_3 a_n-1 a_n')
display(a_1, a_2, a_3, a_n_1, a_n) 
$\displaystyle a_{1}$
$\displaystyle a_{2}$
$\displaystyle a_{3}$
$\displaystyle a_{n-1}$
$\displaystyle a_{n}$
In [4]:
b_1, b_2, b_3 = symbols('b_1 b_2 b_3')
display(b_1, b_2, b_3)
$\displaystyle b_{1}$
$\displaystyle b_{2}$
$\displaystyle b_{3}$
In [5]:
c_1, c_2, c_3 = symbols('c_1 c_2 c_3')
display(c_1, c_2, c_3)
$\displaystyle c_{1}$
$\displaystyle c_{2}$
$\displaystyle c_{3}$
In [6]:
ketA = Ket('a')
display(ketA)
$\displaystyle {\left|a\right\rangle }$
In [7]:
ketAExpanded = Matrix((a_1, a_2, a_3, dotSym,  dotSym, dotSym, a_n_1, a_n ))
display(ketAExpanded)
$\displaystyle \left[\begin{matrix}a_{1}\\a_{2}\\a_{3}\\.\\.\\.\\a_{n-1}\\a_{n}\end{matrix}\right]$
In [8]:
braA = Bra('a')
display(braA)
$\displaystyle {\left\langle a\right|}$
In [9]:
braAExpanded = Dagger(ketAExpanded)
display(braAExpanded)
$\displaystyle \left[\begin{matrix}\overline{a_{1}} & \overline{a_{2}} & \overline{a_{3}} & \overline{.} & \overline{.} & \overline{.} & \overline{a_{n-1}} & \overline{a_{n}}\end{matrix}\right]$
In [10]:
comp = Eq(z, x + I*y)
display(comp)
$\displaystyle z = x + i y$
In [11]:
iValue = Eq(I, sqrt(-1, evaluate = False), evaluate = False)
display(iValue)
$\displaystyle i = \sqrt{-1}$
In [12]:
modOfZ = Eq(Abs(z)**2, x**2 + y**2)
display(modOfZ)
$\displaystyle \left|{z}\right|^{2} = x^{2} + y^{2}$
In [ ]:
 
In [13]:
display(conjugate(z))
display(conjugate( x + I*y))

compconj = Eq(conjugate(z),conjugate( x + I*y))
display(compconj)
$\displaystyle \overline{z}$
$\displaystyle \overline{x} - i \overline{y}$
$\displaystyle \overline{z} = \overline{x} - i \overline{y}$
In [14]:
zxzconj = (x + I*y) * conjugate(x + I*y)
display(zxzconj)
$\displaystyle \left(x + i y\right) \left(\overline{x} - i \overline{y}\right)$
In [15]:
ketB = Ket('b')
ketC = Ket('c')
In [16]:
ketAExpanded = Matrix((a_1, a_2, a_3))
display(ketAExpanded)
ketBExpanded = Matrix((b_1, b_2, b_3))
display(ketBExpanded)
ketCExpanded = Matrix((c_1, c_2, c_3))
display(ketCExpanded)
$\displaystyle \left[\begin{matrix}a_{1}\\a_{2}\\a_{3}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}b_{1}\\b_{2}\\b_{3}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}c_{1}\\c_{2}\\c_{3}\end{matrix}\right]$
In [17]:
braB = Bra('b')
display(braB)
braC = Bra('c')
display(braC)
$\displaystyle {\left\langle b\right|}$
$\displaystyle {\left\langle c\right|}$
In [18]:
braAExpanded = Dagger(Matrix((a_1, a_2, a_3)))
display(braAExpanded)

braBExpanded = Dagger(Matrix((b_1, b_2, b_3)))
display(braBExpanded)

braCExpanded = Dagger(Matrix((c_1, c_2, c_3)))
display(braCExpanded)
$\displaystyle \left[\begin{matrix}\overline{a_{1}} & \overline{a_{2}} & \overline{a_{3}}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}\overline{b_{1}} & \overline{b_{2}} & \overline{b_{3}}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}\overline{c_{1}} & \overline{c_{2}} & \overline{c_{3}}\end{matrix}\right]$
addOfKets = Eq(ketA + ketB, ketC) display(addOfKets)
In [19]:
addOfKetsExpanded = Eq(ketAExpanded + ketBExpanded, ketCExpanded)
display(addOfKetsExpanded)
$\displaystyle \left[\begin{matrix}a_{1} + b_{1}\\a_{2} + b_{2}\\a_{3} + b_{3}\end{matrix}\right] = \left[\begin{matrix}c_{1}\\c_{2}\\c_{3}\end{matrix}\right]$
In [20]:
mulOfKets = Eq(alpha * ketA, ketC)
display(mulOfKets)
$\displaystyle \alpha {\left|a\right\rangle } = {\left|c\right\rangle }$
In [21]:
mulOfKetsExpanded = Eq(alpha * ketAExpanded, ketCExpanded)
display(mulOfKetsExpanded)
$\displaystyle \left[\begin{matrix}a_{1} \alpha\\a_{2} \alpha\\a_{3} \alpha\end{matrix}\right] = \left[\begin{matrix}c_{1}\\c_{2}\\c_{3}\end{matrix}\right]$
In [22]:
inprodOfAB = InnerProduct(braA, ketB)
display(inprodOfAB)
$\displaystyle \left\langle a \right. {\left|b\right\rangle }$
In [23]:
inprodOfABExpanded = braAExpanded * ketBExpanded
display(inprodOfABExpanded)
$\displaystyle \left[\begin{matrix}b_{1} \overline{a_{1}} + b_{2} \overline{a_{2}} + b_{3} \overline{a_{3}}\end{matrix}\right]$
In [24]:
inprodOfAB = Eq(InnerProduct(braA, ketB), inprodOfABExpanded, evaluate = False)
display(inprodOfAB)
$\displaystyle \left\langle a \right. {\left|b\right\rangle } = \left[\begin{matrix}b_{1} \overline{a_{1}} + b_{2} \overline{a_{2}} + b_{3} \overline{a_{3}}\end{matrix}\right]$
In [25]:
inprodOfBA = InnerProduct(braB, ketA)
display(inprodOfBA)
$\displaystyle \left\langle b \right. {\left|a\right\rangle }$
In [26]:
inprodOfBAExpanded = braBExpanded * ketAExpanded
display(inprodOfBAExpanded)
$\displaystyle \left[\begin{matrix}a_{1} \overline{b_{1}} + a_{2} \overline{b_{2}} + a_{3} \overline{b_{3}}\end{matrix}\right]$
In [27]:
inprodOfBA = Eq(InnerProduct(braB, ketA), inprodOfBAExpanded, evaluate = False)
display(inprodOfBA)
$\displaystyle \left\langle b \right. {\left|a\right\rangle } = \left[\begin{matrix}a_{1} \overline{b_{1}} + a_{2} \overline{b_{2}} + a_{3} \overline{b_{3}}\end{matrix}\right]$
In [28]:
inprodOfBAconj = Eq(conjugate(InnerProduct(braB, ketA)), conjugate(inprodOfBAExpanded), evaluate = False)
display(inprodOfBAconj)
$\displaystyle \left\langle a \right. {\left|b\right\rangle } = \left[\begin{matrix}b_{1} \overline{a_{1}} + b_{2} \overline{a_{2}} + b_{3} \overline{a_{3}}\end{matrix}\right]$
In [29]:
display(inprodOfBAconj == inprodOfAB)
True
In [30]:
M = MatrixSymbol('M', 3, 3)
display(M)
$\displaystyle M$
In [31]:
MExpanded = Matrix(M)
display(MExpanded)
$\displaystyle \left[\begin{array}{ccc}M_{0, 0} & M_{0, 1} & M_{0, 2}\\M_{1, 0} & M_{1, 1} & M_{1, 2}\\M_{2, 0} & M_{2, 1} & M_{2, 2}\end{array}\right]$
In [32]:
MExpandedConj = conjugate(MExpanded)
display(MExpandedConj)
$\displaystyle \left[\begin{matrix}\overline{M_{0, 0}} & \overline{M_{0, 1}} & \overline{M_{0, 2}}\\\overline{M_{1, 0}} & \overline{M_{1, 1}} & \overline{M_{1, 2}}\\\overline{M_{2, 0}} & \overline{M_{2, 1}} & \overline{M_{2, 2}}\end{matrix}\right]$
In [33]:
MExpandedTranspose = transpose(MExpanded)
display(MExpandedTranspose)
$\displaystyle \left[\begin{matrix}M_{0, 0} & M_{1, 0} & M_{2, 0}\\M_{0, 1} & M_{1, 1} & M_{2, 1}\\M_{0, 2} & M_{1, 2} & M_{2, 2}\end{matrix}\right]$
In [34]:
MExpandedDagger = Dagger(MExpanded)
display(MExpandedDagger)
$\displaystyle \left[\begin{matrix}\overline{M_{0, 0}} & \overline{M_{1, 0}} & \overline{M_{2, 0}}\\\overline{M_{0, 1}} & \overline{M_{1, 1}} & \overline{M_{2, 1}}\\\overline{M_{0, 2}} & \overline{M_{1, 2}} & \overline{M_{2, 2}}\end{matrix}\right]$
In [35]:
M = Matrix([[1, 1 + I],[1 - I, 3]])
display(M)
$\displaystyle \left[\begin{matrix}1 & 1 + i\\1 - i & 3\end{matrix}\right]$
In [36]:
MDagger = Dagger(Matrix([[1, 1 + I],[1 - I, 3]]))
display(MDagger)
$\displaystyle \left[\begin{matrix}1 & 1 + i\\1 - i & 3\end{matrix}\right]$
In [37]:
display(M == MDagger)
True
In [38]:
M = MatrixSymbol('M', 2, 2)
display(M)
$\displaystyle M$
In [39]:
MExpanded = Matrix(M)
display(MExpanded)
$\displaystyle \left[\begin{array}{cc}M_{0, 0} & M_{0, 1}\\M_{1, 0} & M_{1, 1}\end{array}\right]$
In [40]:
ketAExpanded = Matrix(ketAExpanded[:2])
display(ketAExpanded)
$\displaystyle \left[\begin{matrix}a_{1}\\a_{2}\end{matrix}\right]$
In [41]:
M = symbols('M')
In [42]:
prodOfMKetA = Eq((M * ketA), MExpanded * ketAExpanded, evaluate = False)
display(prodOfMKetA)
$\displaystyle M {\left|a\right\rangle } = \left[\begin{matrix}a_{1} M_{0, 0} + a_{2} M_{0, 1}\\a_{1} M_{1, 0} + a_{2} M_{1, 1}\end{matrix}\right]$
In [43]:
M = MatrixSymbol('M', 2, 2)
display(M)
$\displaystyle M$
In [44]:
i = MatrixSymbol('I', 3, 3)
iExpanded = Identity(3).as_explicit()
In [45]:
iMatrix = Eq(i, iExpanded, evaluate = False)
display(iMatrix)
$\displaystyle I = \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
In [46]:
U = MatrixSymbol('U', n, n)
In [47]:
term1 = U * Dagger(U) 
term2 = iExpanded
term3 = Eq(term1, term2, evaluate = False)
display(term1)
display(term2)
display(term3)

display(term1 == term2)
$\displaystyle U U^{\dagger}$
$\displaystyle \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
$\displaystyle U U^{\dagger} = \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
False
In [48]:
prodOfUUDagger =  Eq(U * Dagger(U), iExpanded, evaluate = False)
display(prodOfUUDagger)
$\displaystyle U U^{\dagger} = \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
In [49]:
U = UnitaryOperator('U')
display(U)
$\displaystyle U$
In [50]:
U * Dagger(U)
Out[50]:
$\displaystyle 1$
In [51]:
Identity(3).as_explicit()
Out[51]:
$\displaystyle \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
In [52]:
U * Dagger(U) == Identity(3).as_explicit()
Out[52]:
False
In [53]:
M = MatrixSymbol('M', 2, 2)
display(M)
$\displaystyle M$
In [54]:
MExpanded = Matrix(M)
display(MExpanded)
$\displaystyle \left[\begin{array}{cc}M_{0, 0} & M_{0, 1}\\M_{1, 0} & M_{1, 1}\end{array}\right]$
In [55]:
Det = symbols('Det')
In [56]:
detOfM = Eq(Determinant(M), Determinant(MExpanded), evaluate = False)
display(detOfM)
$\displaystyle \left|{M}\right| = \left|{\left[\begin{matrix}M_{0, 0} & M_{0, 1}\\M_{1, 0} & M_{1, 1}\end{matrix}\right]}\right|$
In [57]:
i = MatrixSymbol('I', 2, 2)
iExpanded = Identity(2).as_explicit()
In [58]:
detOfI = Eq(Eq(Determinant(i), Determinant(iExpanded)), iExpanded.det(), evaluate = False)
display(detOfI)
$\displaystyle \left|{I}\right| = \left|{\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right]}\right| = 1$
In [59]:
traceOfM = Eq(Eq(Trace(i), Trace(MExpanded)), trace(MExpanded), evaluate = False)
display(traceOfM)
$\displaystyle \operatorname{tr}\left(I \right) = \operatorname{tr}\left(\left[\begin{matrix}M_{0, 0} & M_{0, 1}\\M_{1, 0} & M_{1, 1}\end{matrix}\right] \right) = M_{0, 0} + M_{1, 1}$
In [60]:
H = HermitianOperator('H')
lambdaA = symbols('lambda_a')
lambdaB = symbols('lambda_b')
In [61]:
mostImportantEqOfA = Eq(H * ketA, lambdaA * ketA)
display(mostImportantEqOfA)
$\displaystyle H {\left|a\right\rangle } = \lambda_{a} {\left|a\right\rangle }$
In [62]:
mostImportantEqOfB = Eq(H * ketB, lambdaB * ketB)
display(mostImportantEqOfB)
$\displaystyle H {\left|b\right\rangle } = \lambda_{b} {\left|b\right\rangle }$
In [63]:
probabilityOfPolorisation = cos(theta)**2
display(probabilityOfPolorisation)
$\displaystyle \cos^{2}{\left(\theta \right)}$
In [64]:
intensity, eField = symbols('I E')
In [65]:
intensityOfRadiation = Eq(intensity, eField**2) 
display(intensityOfRadiation)
$\displaystyle I = E^{2}$
In [66]:
eFieldExpanded = Eq(eField, h*f)
display(eFieldExpanded)
$\displaystyle E = f h$
In [67]:
ketX = XKet()
ketY = Ket(y)
braX = XBra()
braY = Bra(y)
In [68]:
ketXExpanded = Matrix([[1],[0]])
display(ketXExpanded)
braXExpanded = conjugate(ketXExpanded.T)
display(braXExpanded)
$\displaystyle \left[\begin{matrix}1\\0\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}1 & 0\end{matrix}\right]$
In [69]:
valOfKetX = Eq(ketX, ketXExpanded, evaluate = False)
display(valOfKetX)
valOfBraX = Eq(braX, braXExpanded, evaluate = False)
display(valOfBraX)
$\displaystyle {\left|x\right\rangle } = \left[\begin{matrix}1\\0\end{matrix}\right]$
$\displaystyle {\left\langle x\right|} = \left[\begin{matrix}1 & 0\end{matrix}\right]$
In [70]:
ketYExpanded = Matrix([[0],[1]])
display(ketYExpanded)
braYExpanded = conjugate(ketYExpanded.T)
display(braYExpanded)
$\displaystyle \left[\begin{matrix}0\\1\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}0 & 1\end{matrix}\right]$
In [71]:
valOfKetY = Eq(ketY, ketYExpanded, evaluate = False)
display(valOfKetY)
valOfBraY = Eq(braY, braYExpanded, evaluate = False)
display(valOfBraY)
$\displaystyle {\left|y\right\rangle } = \left[\begin{matrix}0\\1\end{matrix}\right]$
$\displaystyle {\left\langle y\right|} = \left[\begin{matrix}0 & 1\end{matrix}\right]$
In [72]:
absOfXY = Eq(Abs(InnerProduct(braX, ketY), evaluate = False)**2, Abs(InnerProduct(braX, ketY))**2)
display(absOfXY)
$\displaystyle \left|{\left\langle x \right. {\left|y\right\rangle }}\right|^{2} = \left\langle y \right. {\left|x\right\rangle } \left\langle x \right. {\left|y\right\rangle }$
In [73]:
innerprodOfXY = Eq(Eq(Abs(InnerProduct(braX, ketY))**2,
                      Abs(MatMul(braXExpanded, ketYExpanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(braXExpanded * ketYExpanded)**2, 
                   evaluate = False)
display(innerprodOfXY)
$\displaystyle \left\langle y \right. {\left|x\right\rangle } \left\langle x \right. {\left|y\right\rangle } = \left|{\left[\begin{matrix}1 & 0\end{matrix}\right] \left[\begin{matrix}0\\1\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}0\end{matrix}\right]$
In [74]:
innerprodOfXX = Eq(Eq(Abs(InnerProduct(braX, ketX))**2,
                      Abs(MatMul(braXExpanded, ketXExpanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(braXExpanded * ketXExpanded)**2, 
                   evaluate = False)
display(innerprodOfXX)
$\displaystyle \left|{\left\langle x \right. {\left|x\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}1 & 0\end{matrix}\right] \left[\begin{matrix}1\\0\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}1\end{matrix}\right]$
In [75]:
innerprodOfYY = Eq(Eq(Abs(InnerProduct(braY, ketY))**2,
                      Abs(MatMul(braYExpanded, ketYExpanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(braYExpanded * ketYExpanded)**2, 
                   evaluate = False)
display(innerprodOfYY)
$\displaystyle \left|{\left\langle y \right. {\left|y\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}0 & 1\end{matrix}\right] \left[\begin{matrix}0\\1\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}1\end{matrix}\right]$
In [76]:
HPlus = HermitianOperator('H_+')
In [77]:
HPlusExpanded = Matrix([[1, 0],[0, -1]])
display(HPlusExpanded)
$\displaystyle \left[\begin{matrix}1 & 0\\0 & -1\end{matrix}\right]$
In [78]:
measurement1 = Eq(HPlus * ketX, lamda * ketX)
display(measurement1)
$\displaystyle H_{+} {\left|x\right\rangle } = \lambda {\left|x\right\rangle }$
In [79]:
measurement1solve = Eq(HPlusExpanded * ketXExpanded, lamda * ketX, evaluate = False)
display(measurement1solve)
$\displaystyle \left[\begin{matrix}1\\0\end{matrix}\right] = \lambda {\left|x\right\rangle }$
In [80]:
valOfLambdaViaM1 = Eq(lamda, 1)
display(valOfLambdaViaM1)
$\displaystyle \lambda = 1$
In [81]:
measurement2 = Eq(HPlus * ketY, lamda * ketY)
display(measurement2)
$\displaystyle H_{+} {\left|y\right\rangle } = \lambda {\left|y\right\rangle }$
In [82]:
measurement2solve = Eq(HPlusExpanded * ketYExpanded, lamda * ketY, evaluate = False)
display(measurement2solve)
$\displaystyle \left[\begin{matrix}0\\-1\end{matrix}\right] = \lambda {\left|y\right\rangle }$
In [83]:
valOfLambdaViaM2 = Eq(lamda, -1)
display(valOfLambdaViaM2)
$\displaystyle \lambda = -1$
In [84]:
ket45 = Ket(45*degree)
display(ket45)
bra45 = Bra(45*degree)
display(bra45)
$\displaystyle {\left|45 ^\circ\right\rangle }$
$\displaystyle {\left\langle 45 ^\circ\right|}$
In [85]:
ket45Expanded = ketXExpanded + ketYExpanded
display(ket45Expanded)
bra45Expanded = ket45Expanded.T
display(bra45Expanded)
$\displaystyle \left[\begin{matrix}1\\1\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}1 & 1\end{matrix}\right]$
In [86]:
valOfKet45 = Eq(Eq(ket45,
                      ketX + ketY,
                      evaluate = False), 
                   ket45Expanded,
                   evaluate = False)
display(valOfKet45)
$\displaystyle {\left|45 ^\circ\right\rangle } = {\left|y\right\rangle } + {\left|x\right\rangle } = \left[\begin{matrix}1\\1\end{matrix}\right]$
In [87]:
innerprodOf4545 = Eq(Eq(Abs(InnerProduct(bra45, ket45), evaluate = False)**2,
                      Abs(MatMul(bra45Expanded, ket45Expanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(bra45Expanded * ket45Expanded)**2, 
                   evaluate = False)
display(innerprodOf4545)
$\displaystyle \left|{\left\langle 45 ^\circ \right. {\left|45 ^\circ\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}1 & 1\end{matrix}\right] \left[\begin{matrix}1\\1\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}4\end{matrix}\right]$
In [88]:
ket45Expanded = ketXExpanded/sqrt(2) + ketYExpanded/sqrt(2)
display(ket45Expanded)
bra45Expanded = conjugate(ket45Expanded.T)
display(bra45Expanded)
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\end{matrix}\right]$
In [89]:
innerprodOf4545 = Eq(Eq(Abs(InnerProduct(bra45, ket45), evaluate = False)**2,
                      Abs(MatMul(bra45Expanded, ket45Expanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(bra45Expanded * ket45Expanded)**2, 
                   evaluate = False)
display(innerprodOf4545)
$\displaystyle \left|{\left\langle 45 ^\circ \right. {\left|45 ^\circ\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\end{matrix}\right] \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}1\end{matrix}\right]$
In [90]:
ket135 = Ket(135*degree)
display(ket135)
bra135 = Bra(135*degree)
display(bra135)
$\displaystyle {\left|135 ^\circ\right\rangle }$
$\displaystyle {\left\langle 135 ^\circ\right|}$
In [91]:
ket135Expanded = ketXExpanded/sqrt(2) - ketYExpanded/sqrt(2)
display(ket135Expanded)
bra135Expanded = conjugate(ket135Expanded.T)
display(bra135Expanded)
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2}\\- \frac{\sqrt{2}}{2}\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2} & - \frac{\sqrt{2}}{2}\end{matrix}\right]$
In [92]:
innerprodOf13545 = Eq(Eq(Abs(InnerProduct(bra135, ket45), evaluate = False)**2,
                      Abs(MatMul(bra135Expanded, ket45Expanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(bra135Expanded * ket45Expanded)**2, 
                   evaluate = False)
display(innerprodOf13545)
$\displaystyle \left|{\left\langle 135 ^\circ \right. {\left|45 ^\circ\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}\frac{\sqrt{2}}{2} & - \frac{\sqrt{2}}{2}\end{matrix}\right] \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}0\end{matrix}\right]$
In [93]:
innerprodOf45Y = Eq(Eq(Abs(InnerProduct(bra45, ketY), evaluate = False)**2,
                      Abs(MatMul(bra45Expanded, ketYExpanded), evaluate = False)**2,
                      evaluate = False), 
                   Abs(bra45Expanded * ketYExpanded)**2, 
                   evaluate = False)
display(innerprodOf45Y)
$\displaystyle \left|{\left\langle 45 ^\circ \right. {\left|y\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\end{matrix}\right] \left[\begin{matrix}0\\1\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}\frac{1}{2}\end{matrix}\right]$
In [94]:
# cross = symbols(r'\times')
HCross = HermitianOperator(r'H_\times')
In [95]:
HCrossExpanded = Matrix([[0, 1],[1, 0]])
display(HCrossExpanded)
$\displaystyle \left[\begin{matrix}0 & 1\\1 & 0\end{matrix}\right]$
In [96]:
measurement1 = Eq(HCross * ket45, lamda * ket45)
display(measurement1)
$\displaystyle H_\times {\left|45 ^\circ\right\rangle } = \lambda {\left|45 ^\circ\right\rangle }$
In [97]:
measurement1solve = Eq(HCrossExpanded * ket45Expanded, lamda * ket45, evaluate = False)
display(measurement1solve)
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right] = \lambda {\left|45 ^\circ\right\rangle }$
In [98]:
valOfLambdaViaM1 = Eq(lamda, 1)
display(valOfLambdaViaM1)
$\displaystyle \lambda = 1$
In [99]:
measurement2 = Eq(HCross * ket135, lamda * ket135)
display(measurement2)
$\displaystyle H_\times {\left|135 ^\circ\right\rangle } = \lambda {\left|135 ^\circ\right\rangle }$
In [100]:
measurement2solve = Eq(HCrossExpanded * ket135Expanded, lamda * ket135, evaluate = False)
display(measurement2solve)
$\displaystyle \left[\begin{matrix}- \frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right] = \lambda {\left|135 ^\circ\right\rangle }$
In [101]:
valOfLambdaViaM2 = Eq(lamda, -1)
display(valOfLambdaViaM2)
$\displaystyle \lambda = -1$
In [ ]:
 

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing