004-001-position-momentum-and-heisenberg.ipynb

In [90]:
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 degree
from sympy.abc import a, b, x, y, z, t, alpha, n, theta, h, f, lamda, i, k, w, u, d, beta, r, psi, o, l, c, gamma, phi, j, p
In [91]:
dotDummy = Dummy('.')
ketX = XKet()
ketY = Ket(y)
identity = symbols('I')
a_i, a_1, a_2, a_3, a_j = symbols('a_i a_1 a_2 a_3 a_j', complex = True)
b_j, b_1, b_2, b_3 = symbols('b_j b_1 b_2 b_3', complex = True)
psi_1, psi_2, psi_3, psi_j, psi_i = symbols('psi_1 psi_2 psi_3 psi_j psi_i')
phi_1, phi_2, phi_3, phi_j, phi_i = symbols('phi_1 phi_2 phi_3 phi_j phi_i')
ketPsi = Ket(psi)
ketX_1 = Ket('x_1')
ketX_2 = Ket('x_2')
ketX_i = Ket('x_i')
ketX_j = Ket('x_j')
braPsi = Bra(psi)
braX_1 = Bra('x_1')
braX_2 = Bra('x_2')
braX_i = Bra('x_i')
braX_j = Bra('x_j')
x_i = symbols('x_i')
prob = Function('P')
ketPhi = Ket(phi)
braPhi = Bra(phi)
braX_j = Bra('x_j')
ketU = Ket(u)
ketD = Ket(d)
braU = Bra(u)
braD = Bra(d)
ketR = Ket(r)
H = HermitianOperator('H')
X = HermitianOperator('X')
uFunc = Function('u')(x)
vFunc = Function('v')(x)
K = HermitianOperator('K')
blankSpace = Dummy(' ')
momentumOperator = HermitianOperator('P')
positionOperator = HermitianOperator('x')
M1 = Operator('M_1')
M2 = Operator('M_2')
ketA = Ket('a')
ketB = Ket('b')
In [92]:
ketXExpanded = Matrix([[1],[0]])
display(ketXExpanded)
ketYExpanded = Matrix([[0],[1]])
display(ketYExpanded)
$\displaystyle \left[\begin{matrix}1\\0\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}0\\1\end{matrix}\right]$
In [93]:
ket45 = Ket(45*degree)
display(ket45)
ket45Expanded = ketXExpanded/sqrt(2) + ketYExpanded/sqrt(2)
display(ket45Expanded)
$\displaystyle {\left|45 ^\circ\right\rangle }$
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]$
In [94]:
valOfKet45 = Eq(ket45,
               Eq(ket45Expanded,
                    Add(Mul(ket45Expanded[0],
                            ketX,
                            evaluate = False),
                        Mul(ket45Expanded[1],
                            ketY,
                            evaluate = False),
                        evaluate = False),
                  evaluate = False),  
               evaluate = False)
display(valOfKet45)
$\displaystyle {\left|45 ^\circ\right\rangle } = \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right] = \frac{\sqrt{2}}{2} {\left|y\right\rangle } + \frac{\sqrt{2}}{2} {\left|x\right\rangle }$
In [95]:
valOfKetPsi = Eq(ketPsi,
                 a_1 * ketX_1 + a_2 * ketX_2,
                 evaluate = False)
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = a_{1} {\left|x_{1}\right\rangle } + a_{2} {\left|x_{2}\right\rangle }$
In [96]:
valOfKetPsi = Eq(ketPsi,
                 Sum(a_i * ketX_i, (i, 1, n)),
                 evaluate = False)
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = \sum_{i=1}^{n} a_{i} {\left|x_{i}\right\rangle }$
In [97]:
valOfKetPsiExpanded = Eq(Eq(ketPsi,
                    Matrix([[a_1], [a_2], [a_3], [dotDummy], [dotDummy], [dotDummy]]),
                    evaluate = False),
                 Matrix([[psi_1], [psi_2], [psi_3], [dotDummy], [dotDummy], [dotDummy]]),
                 evaluate = False)
display(valOfKetPsiExpanded)
$\displaystyle {\left|\psi\right\rangle } = \left[\begin{matrix}a_{1}\\a_{2}\\a_{3}\\.\\.\\.\end{matrix}\right] = \left[\begin{matrix}\psi_{1}\\\psi_{2}\\\psi_{3}\\.\\.\\.\end{matrix}\right]$
In [98]:
ProbOfX_i = Eq(Eq(prob(x_i), Abs(a_i)**2), Mul(a_i, conjugate(a_i)), evaluate = False)
display(ProbOfX_i)
$\displaystyle P{\left(x_{i} \right)} = \left|{a_{i}}\right|^{2} = a_{i} \overline{a_{i}}$
In [99]:
valOfKetPhi = Eq(ketPhi,
                 Sum(b_j * ketX_j, (j, 1, n)),
                 evaluate = False)
display(valOfKetPhi)
$\displaystyle {\left|\phi\right\rangle } = \sum_{j=1}^{n} b_{j} {\left|x_{j}\right\rangle }$
In [100]:
valOfBraPhi = Eq(braPhi,
                 Sum(conjugate(b_j) * braX_j, (j, 1, n)),
                 evaluate = False)
display(valOfBraPhi)
$\displaystyle {\left\langle \phi\right|} = \sum_{j=1}^{n} \overline{b_{j}} {\left\langle x_{j}\right|}$
In [101]:
InnerProductOfPhi_Psi = Eq(InnerProduct(braPhi, ketPsi),
                 Mul(valOfBraPhi.rhs, valOfKetPsi.rhs),
                 evaluate = False)
display(InnerProductOfPhi_Psi)
$\displaystyle \left\langle \phi \right. {\left|\psi\right\rangle } = \left(\sum_{j=1}^{n} \overline{b_{j}} {\left\langle x_{j}\right|}\right) \sum_{i=1}^{n} a_{i} {\left|x_{i}\right\rangle }$
In [102]:
InnerProductOfPhi_Psi = Eq(InnerProduct(braPhi, ketPsi),
                           Sum(conjugate(b_j) *  a_i * InnerProduct(braX_j, ketX_i), (i, 1, n), (j, 1, n)),
                           evaluate = False)
display(InnerProductOfPhi_Psi)
$\displaystyle \left\langle \phi \right. {\left|\psi\right\rangle } = \sum_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} a_{i} \overline{b_{j}} \left\langle x_{j} \right. {\left|x_{i}\right\rangle }$
In [103]:
ketUExpanded = Matrix([[1],[0]])
display(ketUExpanded)
braUExpanded = conjugate(ketUExpanded.T)
display(braUExpanded)
ketDExpanded = Matrix([[0],[1]])
display(ketDExpanded)
braDExpanded = conjugate(ketDExpanded.T)
display(braDExpanded)
$\displaystyle \left[\begin{matrix}1\\0\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}1 & 0\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}0\\1\end{matrix}\right]$
$\displaystyle \left[\begin{matrix}0 & 1\end{matrix}\right]$
In [104]:
ketRExpanded = Matrix([[1/sqrt(2)],[1/sqrt(2)]])
display(ketRExpanded)
$\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]$
In [105]:
valOfKetR = Eq(ketR,
                    Add(Mul(ketRExpanded[0], ketU, evaluate = False),  Mul(ketRExpanded[1], ketD, evaluate = False), evaluate = False),
                  evaluate = False)
display(valOfKetR)
$\displaystyle {\left|r\right\rangle } = \frac{\sqrt{2}}{2} {\left|d\right\rangle } + \frac{\sqrt{2}}{2} {\left|u\right\rangle }$
In [106]:
innerprodOfU_R = Eq(Eq(Abs(InnerProduct(braU, ketR), evaluate = False)**2,
                      Abs(MatMul(braUExpanded, ketRExpanded), evaluate = False)**2,
                      evaluate = False), 
                   (Abs(braUExpanded * ketRExpanded)**2).simplify(), 
                   evaluate = False)
display(innerprodOfU_R)
$\displaystyle \left|{\left\langle u \right. {\left|r\right\rangle }}\right|^{2} = \left|{\left[\begin{matrix}1 & 0\end{matrix}\right] \left[\begin{matrix}\frac{\sqrt{2}}{2}\\\frac{\sqrt{2}}{2}\end{matrix}\right]}\right|^{2} = \left[\begin{matrix}\frac{1}{2}\end{matrix}\right]$
In [107]:
valOfKetPsi = Eq(ketPsi,
                 Sum(a_i * ketX_i, (i, 1, n)),
                 evaluate = False)
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = \sum_{i=1}^{n} a_{i} {\left|x_{i}\right\rangle }$
In [108]:
innerprodOfX_i_Psi = Eq(InnerProduct(braX_j, ketPsi), Mul(braX_j, valOfKetPsi.rhs))
display(innerprodOfX_i_Psi)
$\displaystyle \left\langle x_{j} \right. {\left|\psi\right\rangle } = {\left\langle x_{j}\right|} \sum_{i=1}^{n} a_{i} {\left|x_{i}\right\rangle }$
In [109]:
innerprodOfX_i_Psi = Eq(InnerProduct(braX_j, ketPsi), Sum(a_i * InnerProduct(braX_j, ketX_i), (i, 1, n), (j, 1, n)))
display(innerprodOfX_i_Psi)
$\displaystyle \left\langle x_{j} \right. {\left|\psi\right\rangle } = \sum_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} a_{i} \left\langle x_{j} \right. {\left|x_{i}\right\rangle }$
In [110]:
innerprodOfX_i_Psi = Eq(Eq(InnerProduct(braX_j, ketPsi), Sum(a_j, (j, 1, n))), psi_j)
display(innerprodOfX_i_Psi)
$\displaystyle \left\langle x_{j} \right. {\left|\psi\right\rangle } = \sum_{j=1}^{n} a_{j} = \psi_{j}$
In [111]:
identityExpanded = Identity(3).as_explicit()
In [112]:
valOfIdentity = Eq(identity, identityExpanded, evaluate = False)
display(valOfIdentity)
$\displaystyle I = \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$
In [113]:
prodOfIdentity_KetPsi = Eq(identity * ketPsi, ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle I {\left|\psi\right\rangle } = {\left|\psi\right\rangle }$
In [114]:
identityExpanded = Identity(2).as_explicit()
ketPsiExpanded = Matrix([[a],[b]])
In [115]:
prodOfiExpanded_ketPsiExpanded = Eq(MatMul(identityExpanded, ketPsiExpanded), ketPsiExpanded)
display(prodOfiExpanded_ketPsiExpanded)
$\displaystyle \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right] \left[\begin{matrix}a\\b\end{matrix}\right] = \left[\begin{matrix}a\\b\end{matrix}\right]$
In [116]:
innerprodOfU_U = Eq(InnerProduct(braU,
                                 ketU),
                    (Abs(braUExpanded * ketUExpanded)**2)[0],
                    evaluate = False)
display(innerprodOfU_U)
$\displaystyle \left\langle u \right. {\left|u\right\rangle } = 1$
In [117]:
outerprodOfU_U = Eq(Eq(OuterProduct(ketU,
                                    braU),
                       MatMul(ketUExpanded,
                              braUExpanded),
                       evaluate = False),
                    ketUExpanded * braUExpanded,
                    evaluate = False)
display(outerprodOfU_U)
$\displaystyle {\left|u\right\rangle }{\left\langle u\right|} = \left[\begin{matrix}1\\0\end{matrix}\right] \left[\begin{matrix}1 & 0\end{matrix}\right] = \left[\begin{matrix}1 & 0\\0 & 0\end{matrix}\right]$
In [118]:
outerprodOfD_D = Eq(Eq(OuterProduct(ketD,
                                    braD),
                       MatMul(ketDExpanded,
                              braDExpanded),
                       evaluate = False),
                    ketDExpanded * braDExpanded,
                    evaluate = False)
display(outerprodOfD_D)
$\displaystyle {\left|d\right\rangle }{\left\langle d\right|} = \left[\begin{matrix}0\\1\end{matrix}\right] \left[\begin{matrix}0 & 1\end{matrix}\right] = \left[\begin{matrix}0 & 0\\0 & 1\end{matrix}\right]$
In [119]:
AddOfOuterprodOfD_D_OuterprodOfU_U = Eq(Eq(Eq(MatAdd(ketUExpanded * braUExpanded,
                                                     ketDExpanded * braDExpanded,
                                                     evaluate = False),
                                              ketUExpanded * braUExpanded + ketDExpanded * braDExpanded),
                                           identity),
                                        Sum(ketX_i*braX_i,
                                            (i, 1, n)),
                                        evaluate = False)
display(AddOfOuterprodOfD_D_OuterprodOfU_U)
$\displaystyle \left[\begin{matrix}0 & 0\\0 & 1\end{matrix}\right] + \left[\begin{matrix}1 & 0\\0 & 0\end{matrix}\right] = \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right] = I = \sum_{i=1}^{n} {\left|x_{i}\right\rangle }{\left\langle x_{i}\right|}$
In [120]:
valOfIdentity  = Eq(identity, Sum(ketX_i*braX_i,(i, 1, n)),evaluate = False)
display(valOfIdentity)
$\displaystyle I = \sum_{i=1}^{n} {\left|x_{i}\right\rangle }{\left\langle x_{i}\right|}$
In [121]:
prodOfIdentity_KetPsi = Eq(identity * ketPsi, ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle I {\left|\psi\right\rangle } = {\left|\psi\right\rangle }$
In [122]:
prodOfIdentity_KetPsi = Eq(Sum(ketX_i * InnerProduct(braX_i, ketPsi),(i, 1, n)), ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle \sum_{i=1}^{n} \left\langle x_{i} \right. {\left|\psi\right\rangle } {\left|x_{i}\right\rangle } = {\left|\psi\right\rangle }$
In [123]:
prodOfIdentity_KetPsi = Eq(Sum(ketX_i * braX_i * Sum(a_j * ketX_j,
                                                     (j, 1, n)),
                               (i, 1, n)),
                           ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle \sum_{i=1}^{n} {\left|x_{i}\right\rangle }{\left\langle x_{i}\right|} \sum_{j=1}^{n} a_{j} {\left|x_{j}\right\rangle } = {\left|\psi\right\rangle }$
In [124]:
prodOfIdentity_KetPsi = Eq(Sum(ketX_i * a_j * InnerProduct(braX_i,
                                                           ketX_j),
                               (i, 1, n),
                               (j, 1, n)),
                           ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle \sum_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} a_{j} \left\langle x_{i} \right. {\left|x_{j}\right\rangle } {\left|x_{i}\right\rangle } = {\left|\psi\right\rangle }$
In [125]:
prodOfIdentity_KetPsi = Eq(Sum(ketX_i * a_j,
                               (i, 1, n),
                               (j, 1, n)),
                           ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle \sum_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} a_{j} {\left|x_{i}\right\rangle } = {\left|\psi\right\rangle }$
In [126]:
prodOfIdentity_KetPsi = Eq(Sum(ketX_j * a_j,
                               (j, 1, n)),
                           ketPsi)
display(prodOfIdentity_KetPsi)
$\displaystyle \sum_{j=1}^{n} a_{j} {\left|x_{j}\right\rangle } = {\left|\psi\right\rangle }$
In [127]:
prodOfH_KetPsi = Eq(H * ketPsi, lamda * ketPsi)
display(prodOfH_KetPsi)
$\displaystyle H {\left|\psi\right\rangle } = \lambda {\left|\psi\right\rangle }$
In [128]:
prodOfH_KetPsi = Eq(braPsi * H * ketPsi, braPsi * lamda * ketPsi)
display(prodOfH_KetPsi)
$\displaystyle {\left\langle \psi\right|} H {\left|\psi\right\rangle } = \lambda {\left\langle \psi\right|} {\left|\psi\right\rangle }$
In [129]:
prodOfH_KetPsi = Eq(lamda * InnerProduct(braPsi, ketPsi), lamda)
display(prodOfH_KetPsi)
$\displaystyle \lambda \left\langle \psi \right. {\left|\psi\right\rangle } = \lambda$
In [130]:
prodOfKetPhi_H_KetPsi = braPhi * H * ketPsi
display(prodOfKetPhi_H_KetPsi)
$\displaystyle {\left\langle \phi\right|} H {\left|\psi\right\rangle }$
In [131]:
prodOfH_KetPsi = Eq(conjugate(braPhi * H * ketPsi), braPsi * Dagger(H) * ketPhi)
display(prodOfH_KetPsi)
$\displaystyle \overline{{\left\langle \phi\right|}} \overline{H} \overline{{\left|\psi\right\rangle }} = {\left\langle \psi\right|} H {\left|\phi\right\rangle }$
In [132]:
prodOfX_Psi = Eq(X * ketPsi, x * ketPsi)
display(prodOfX_Psi)
$\displaystyle X {\left|\psi\right\rangle } = x {\left|\psi\right\rangle }$
In [133]:
valOfKetPsi = Eq(Eq(ketPsi,
                    Sum(a_i * ketX_i, (i, 1, n)),
                    evaluate = False),
                 Integral(a_i, (x, -oo, oo)),
                 evaluate = False)
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = \sum_{i=1}^{n} a_{i} {\left|x_{i}\right\rangle } = \int\limits_{-\infty}^{\infty} a_{i}\, dx$
In [134]:
InnerProductOfPhi_Psi = Eq(Eq(InnerProduct(braPhi, ketPsi),
                              Sum(conjugate(phi_j) *  psi_j, (j, 1, n)),
                              evaluate = False), 
                           Integral(conjugate(phi_j) *  psi_j, (x, -oo, oo)),
                           evaluate = False)
display(InnerProductOfPhi_Psi)
$\displaystyle \left\langle \phi \right. {\left|\psi\right\rangle } = \sum_{j=1}^{n} \psi_{j} \overline{\phi_{j}} = \int\limits_{-\infty}^{\infty} \psi_{j} \overline{\phi_{j}}\, dx$
In [135]:
display(uFunc)
display(vFunc)
$\displaystyle u{\left(x \right)}$
$\displaystyle v{\left(x \right)}$
In [136]:
diffByParts = Eq(Derivative(uFunc * vFunc, x), Derivative(uFunc * vFunc, x).doit())
display(diffByParts)
$\displaystyle \frac{d}{d x} u{\left(x \right)} v{\left(x \right)} = u{\left(x \right)} \frac{d}{d x} v{\left(x \right)} + v{\left(x \right)} \frac{d}{d x} u{\left(x \right)}$
In [137]:
intergrateByParts = Eq(Integral(Derivative(vFunc * uFunc,
                                           x),
                                (x, -oo, oo)),
                       Integral(Derivative(uFunc * vFunc, 
                                           x).doit(), 
                                (x, oo, -oo)).expand())
display(intergrateByParts)
$\displaystyle \int\limits_{-\infty}^{\infty} \frac{d}{d x} u{\left(x \right)} v{\left(x \right)}\, dx = \int\limits_{\infty}^{-\infty} u{\left(x \right)} \frac{d}{d x} v{\left(x \right)}\, dx + \int\limits_{\infty}^{-\infty} v{\left(x \right)} \frac{d}{d x} u{\left(x \right)}\, dx$
In [138]:
intergrateByParts = Eq(Integral(Derivative(vFunc,
                                           x) * uFunc,
                                (x, -oo, oo)),
                       integrate(Derivative(uFunc * vFunc
                                           , x),
                                (x, -oo, oo)) - Integral(Derivative(uFunc,
                                                                    x) * vFunc,
                                                         (x, -oo, oo)))
display(intergrateByParts)
$\displaystyle \int\limits_{-\infty}^{\infty} u{\left(x \right)} \frac{d}{d x} v{\left(x \right)}\, dx = - \int\limits_{-\infty}^{\infty} v{\left(x \right)} \frac{d}{d x} u{\left(x \right)}\, dx + \int\limits_{-\infty}^{\infty} \frac{d}{d x} u{\left(x \right)} v{\left(x \right)}\, dx$
In [139]:
valOfUFunc = Eq(uFunc, psi)
display(valOfUFunc)
$\displaystyle u{\left(x \right)} = \psi$
In [140]:
valOfVFunc = Eq(vFunc, conjugate(psi))
display(valOfVFunc)
$\displaystyle v{\left(x \right)} = \overline{\psi}$
In [141]:
intergrateByParts = Piecewise((Eq(Integral(Derivative(vFunc,
                                           x) * uFunc,
                                (x, -oo, oo)), 
                       - Integral(Derivative(uFunc,
                                             x) * vFunc,
                                  (x, -oo, oo))),
                               Eq((uFunc, vFunc),
                                  (psi, conjugate(psi)),
                                  evaluate = False)))
display(intergrateByParts)
$\displaystyle \begin{cases} \int\limits_{-\infty}^{\infty} u{\left(x \right)} \frac{d}{d x} v{\left(x \right)}\, dx = - \int\limits_{-\infty}^{\infty} v{\left(x \right)} \frac{d}{d x} u{\left(x \right)}\, dx & \text{for}\: \left( \psi, \ \overline{\psi}\right) = \left( u{\left(x \right)}, \ v{\left(x \right)}\right) \end{cases}$
In [142]:
prodOfH_KetPsi = Eq(H * ketPsi, -I * Derivative(ketPsi, x))
display(prodOfH_KetPsi)
$\displaystyle H {\left|\psi\right\rangle } = - i \frac{d}{d x} {\left|\psi\right\rangle }$
In [143]:
prodOfH_KetPhi = Eq(H * ketPhi, -I * Derivative(ketPhi, x))
display(prodOfH_KetPhi)
$\displaystyle H {\left|\phi\right\rangle } = - i \frac{d}{d x} {\left|\phi\right\rangle }$
In [144]:
proofOfHermitian = Eq(braPsi * H * ketPhi, conjugate(braPhi * H * ketPhi))
display(proofOfHermitian)
$\displaystyle {\left\langle \psi\right|} H {\left|\phi\right\rangle } = \overline{{\left\langle \phi\right|}} \overline{H} \overline{{\left|\phi\right\rangle }}$
In [145]:
proofOfHermitian = Eq(braPsi * -I * Derivative(ketPhi, x), conjugate(braPhi * -I * Derivative(ketPsi, x)))
display(proofOfHermitian)
$\displaystyle - i {\left\langle \psi\right|} \frac{d}{d x} {\left|\phi\right\rangle } = i \overline{{\left\langle \phi\right|}} \overline{\frac{d}{d x} {\left|\psi\right\rangle }}$
In [146]:
valOfBraPsi = Eq(braPsi,
                 Integral(conjugate(psi), (x, -oo, oo)),
                 evaluate = False)
display(valOfBraPsi)
$\displaystyle {\left\langle \psi\right|} = \int\limits_{-\infty}^{\infty} \overline{\psi}\, dx$
In [147]:
valOfBraPhi = Eq(braPhi,
                 Integral(conjugate(phi), (x, -oo, oo)),
                 evaluate = False)
display(valOfBraPhi)
$\displaystyle {\left\langle \phi\right|} = \int\limits_{-\infty}^{\infty} \overline{\phi}\, dx$
In [148]:
proofOfHermitian = Eq(-I * Integral(conjugate(psi) * Derivative(phi, x), x),
                      conjugate(-I * Integral(conjugate(phi) *  Derivative(psi, x), x)))
display(proofOfHermitian)
$\displaystyle - i \int \overline{\psi} \frac{d}{d x} \phi\, dx = i \overline{\int \overline{\phi} \frac{d}{d x} \psi\, dx}$
In [149]:
proofOfHermitian = Eq(-I * Integral(conjugate(psi) * Derivative(phi, x), x),
                      conjugate(I * Integral(psi *  Derivative(conjugate(phi), x), x)))
display(proofOfHermitian)
$\displaystyle - i \int \overline{\psi} \frac{d}{d x} \phi\, dx = - i \overline{\int \psi \frac{d}{d x} \overline{\phi}\, dx}$
In [150]:
valOfK = Eq(K, -I * Derivative(blankSpace, x))
display(valOfK)
$\displaystyle K = - i \frac{d}{d x} $
In [151]:
prodOfK_KetPsi = Eq(K * ketPsi, k * ketPsi)
display(prodOfK_KetPsi)
$\displaystyle K {\left|\psi\right\rangle } = k {\left|\psi\right\rangle }$
In [152]:
prodOfK_KetPsi = Eq(-I * Derivative(ketPsi, x), k * ketPsi)
display(prodOfK_KetPsi)
$\displaystyle - i \frac{d}{d x} {\left|\psi\right\rangle } = k {\left|\psi\right\rangle }$
In [153]:
prodOfK_KetPsi = Eq(Derivative(ketPsi, x), I * k * ketPsi)
display(prodOfK_KetPsi)
$\displaystyle \frac{d}{d x} {\left|\psi\right\rangle } = i k {\left|\psi\right\rangle }$
In [154]:
valOfKetPsi = Eq(ketPsi, exp(I*k*x))
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = e^{i k x}$
In [155]:
valOfKetPsi = Eq(Eq(ketPsi, exp(I*k*x)), cos(k*x) + I * sin(k*x), evaluate = False)
display(valOfKetPsi)
$\displaystyle {\left|\psi\right\rangle } = e^{i k x} = i \sin{\left(k x \right)} + \cos{\left(k x \right)}$
In [156]:
valOfk = Eq(k, 2*pi/lamda)
display(valOfk)
$\displaystyle k = \frac{2 \pi}{\lambda}$
In [157]:
deBroglieEq = Eq(lamda, h/p)
display(deBroglieEq)
$\displaystyle \lambda = \frac{h}{p}$
In [158]:
valOfk = Eq(k, 2*pi/lamda).subs(lamda, deBroglieEq.rhs).subs(2*pi/h, 1/hbar)
display(valOfk)
$\displaystyle k = \frac{p}{\hbar}$
In [159]:
waveFunc = Eq(ketPsi, exp(I*k*x)).subs(k, valOfk.rhs)
display(waveFunc)
$\displaystyle {\left|\psi\right\rangle } = e^{\frac{i p x}{\hbar}}$
In [160]:
diffOfWaveFunc = Eq(Derivative(ketPsi, x), Derivative(waveFunc.rhs, x).doit().subs(waveFunc.rhs, ketPsi))
display(diffOfWaveFunc)
$\displaystyle \frac{d}{d x} {\left|\psi\right\rangle } = \frac{i p {\left|\psi\right\rangle }}{\hbar}$
In [161]:
diffOfWaveFunc = Eq(Derivative(ketPsi, x) * hbar / I,
                    Derivative(waveFunc.rhs, x).doit().subs(waveFunc.rhs, ketPsi) * hbar / I)
display(diffOfWaveFunc)
$\displaystyle - \hbar i \frac{d}{d x} {\left|\psi\right\rangle } = p {\left|\psi\right\rangle }$
In [162]:
prodOfMomentumOperator_KetPsi = Eq(momentumOperator * ketPsi, p * ketPsi)
display(prodOfMomentumOperator_KetPsi)
$\displaystyle P {\left|\psi\right\rangle } = p {\left|\psi\right\rangle }$
In [163]:
valOfmomentumOperator = Eq(momentumOperator, diffOfWaveFunc.lhs.subs(ketPsi, blankSpace))
display(valOfmomentumOperator)
$\displaystyle P = - \hbar i \frac{d}{d x} $
In [164]:
measurement1 = Eq(M1 * ketA, alpha * ketA)
display(measurement1)
$\displaystyle M_{1} {\left|a\right\rangle } = \alpha {\left|a\right\rangle }$
In [165]:
measurement2 = Eq(M2 * ketA, beta * ketA)
display(measurement2)
$\displaystyle M_{2} {\left|a\right\rangle } = \beta {\left|a\right\rangle }$
In [166]:
CommutativeEq = Eq(M1 * M2 * ketA, M2 * M1 * ketA)
display(CommutativeEq)
$\displaystyle M_{1} M_{2} {\left|a\right\rangle } = M_{2} M_{1} {\left|a\right\rangle }$
In [167]:
CommutativeEqSimply = Eq((M1 * M2 -  M2 * M1) * ketA, 0)
display(CommutativeEqSimply)
$\displaystyle \left(M_{1} M_{2} - M_{2} M_{1}\right) {\left|a\right\rangle } = 0$
In [168]:
commutatorOfM1_M2 = Eq(Commutator(M1, M2), 0)
display(commutatorOfM1_M2)
$\displaystyle \left[M_{1},M_{2}\right] = 0$
In [169]:
commutatorOfMomentumOperator_positionOperator = Eq(Commutator(momentumOperator, positionOperator), 0)
display(commutatorOfMomentumOperator_positionOperator)
$\displaystyle \left[P,x\right] = 0$
In [170]:
CommutativeEqOfMomentumOperator_positionOperator = Eq(Mul(Add(Mul(positionOperator,
                                                                  momentumOperator),
                                                              - Mul(momentumOperator,
                                                                    positionOperator)),
                                                          ketPsi),
                                                      Add(Mul(positionOperator,
                                                              valOfmomentumOperator.rhs.subs(blankSpace, ketPsi)),
                                                          - valOfmomentumOperator.rhs.subs(blankSpace, positionOperator * ketPsi)))
display(CommutativeEqOfMomentumOperator_positionOperator)
$\displaystyle \left(- P x + x P\right) {\left|\psi\right\rangle } = \hbar i \frac{\partial}{\partial x} x {\left|\psi\right\rangle } - \hbar i x \frac{d}{d x} {\left|\psi\right\rangle }$
In [171]:
CommutativeEqOfMomentumOperator_positionOperator = Eq(Mul(Add(Mul(positionOperator,
                                                                  momentumOperator),
                                                              - Mul(momentumOperator,
                                                                    positionOperator)),
                                                          ketPsi),
                                                      Add(Mul(positionOperator,
                                                              valOfmomentumOperator.rhs.subs(blankSpace, ketPsi)),
                                                          - I*hbar*Add(Derivative(positionOperator, x) * ketPsi,
                                                                       positionOperator * Derivative(ketPsi, x))))
display(CommutativeEqOfMomentumOperator_positionOperator)
$\displaystyle \left(- P x + x P\right) {\left|\psi\right\rangle } = - \hbar i \left(\frac{d}{d x} x {\left|\psi\right\rangle } + x \frac{d}{d x} {\left|\psi\right\rangle }\right) - \hbar i x \frac{d}{d x} {\left|\psi\right\rangle }$
In [172]:
CommutativeEqOfMomentumOperator_positionOperator = Eq(Mul(Add(Mul(positionOperator,
                                                                  momentumOperator),
                                                              - Mul(momentumOperator,
                                                                    positionOperator)),
                                                          ketPsi),
                                                      I*hbar*Derivative(positionOperator, x) * ketPsi)
                                                                       
display(CommutativeEqOfMomentumOperator_positionOperator)
$\displaystyle \left(- P x + x P\right) {\left|\psi\right\rangle } = \hbar i \frac{d}{d x} x {\left|\psi\right\rangle }$
In [173]:
CommutativeEqOfMomentumOperator_positionOperator = Eq(Mul(Add(Mul(positionOperator,
                                                                  momentumOperator),
                                                              - Mul(momentumOperator,
                                                                    positionOperator)),
                                                          ketPsi),
                                                      I * hbar * ketPsi)
                                                                       
display(CommutativeEqOfMomentumOperator_positionOperator)
$\displaystyle \left(- P x + x P\right) {\left|\psi\right\rangle } = \hbar i {\left|\psi\right\rangle }$
In [174]:
CommutativeEqOfMomentumOperator_positionOperator = Unequality(Eq(Add(Mul(positionOperator,
                                                                         momentumOperator),
                                                                     - Mul(momentumOperator,
                                                                           positionOperator)),
                                                                 I * hbar), 
                                                             0, evaluate = False)
                                                                       
display(CommutativeEqOfMomentumOperator_positionOperator)
$\displaystyle - P x + x P = \hbar i \neq 0$
In [ ]:
 
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