{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Algebra: Quantum Mechanics\n", "\n", "Reference: http://qutip.org/docs/latest/index.html" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from qutip import *\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "import numpy.linalg as LA\n", "from scipy.linalg import expm\n", "%matplotlib inline\n", "sns.set()" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "#!pip install qutip" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Some Facts from Quantum Physics:\n", "\n", "1. Web function $\\psi(x)$ is projection of abstract quantum state $|\\psi \\rangle $ (in a certain representation) to a position space (representation) basis $|x \\rangle$. Where, $|x\\rangle$ is a continuous basis with orthogonality relation $\\langle x^{'}|x\\rangle = \\delta(x,x^{'})$.\n", "\n", "$$ \\psi(x) = \\langle x|\\psi \\rangle$$\n", "\n", "2. Web function $\\phi(p)$ is projection of abstract quantum state $|\\psi \\rangle $ in a certain representation to a momentum space (representation) basis $|p \\rangle$. Where, $|p\\rangle$ is a continuous basis with orthogonality relation $\\langle p^{'}|p\\rangle = \\delta(p,p^{'})$.\n", "\n", "$$\\phi(p) = \\langle p|\\phi \\rangle$$\n", "\n", "\n", "\n", "3. Spherical Harmonics $Y_{l,m}(\\theta,\\phi)$ is projection of abstract quantum state $| l,m \\rangle$ (in angular momnetum representation) to a position space (representation) basis $|\\theta, \\phi \\rangle$.\n", "\n", "$$Y_{l,m}(\\theta,\\phi) = \\langle \\theta,\\phi|l,m \\rangle$$\n", "\n", "4. An unitary operator $U$ can be constructed from exponentiation of Hermitian Operator $H$. \n", "$$U = exp(-i\\alpha H)$$\n", "One application of this approach is defining Rotation matrix $R$ in Hilbert space by implementation of angular momentum Operator (e.g., $L_x, L_y, L_z$) as generator of rotation in specific irreducible subspace (e.g.,l=0,l=1,l=2...) of the Hilbert space. A general rotation in Hilbert space is infinite dimentional rotation matrix. In eigen basis of anfgular momentum ($L^{2}, L_z$), this matrix appears as block diagonal matrix with block representing rotation in specific irriducible sub-space.\n", "\n", "\n", "5. In hydrogen like system with spinless particle, operator hamiltonian $H$, square of Angular momentum $L^{2}$ and z-omponent of $L$ operator($L_z$) commute with eachother which means these operators are simultaneously diagonalized. The benefit of of this relation is that once we are able to find eigen basis of $L_z$ operator, we get the eigen basis of Hamiltonian as well. The eighen states of hamiltonian represents the energy level of the system." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Hydrogen Atom: Angular Momentum and Spherical Harmonics\n", "\n", "The matrix element of general angular momnetum operators $J,J_z,J_+,J_-$ are as follows:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![img](https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTRMh9_FL09_N_ftKHwlFvsrwyJQv_wgu_hVg&usqp=CAU)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One can write a python function to provide a matrix element for an arbitrary operators $J,J_z,J_+,J_-$ , but we dont have to work hard now python package ```qutip``` provides us these operators as quantum object ```Quobj``` (of kind operators). We will try to play around with some of them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----------" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Spin Angular Momentum $s = 1/2, ms = -1/2, 1/2$\n", "Matrix size = 2x2" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0\\\\1.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[0. 1.]\n", " [1. 0.]]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sigmax()" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([[0.+0.j, 1.+0.j],\n", " [1.+0.j, 0.+0.j]]), array([[0.+0.j, 0.-1.j],\n", " [0.+1.j, 0.+0.j]]), array([[ 1.+0.j, 0.+0.j],\n", " [ 0.+0.j, -1.+0.j]]))" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sx = np.array(sigmax())\n", "sy = np.array(sigmay())\n", "sz = np.array(sigmaz())\n", "sx,sy,sz" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([[1.+0.j, 0.+0.j],\n", " [0.+0.j, 1.+0.j]]), array([[1.+0.j, 0.+0.j],\n", " [0.+0.j, 1.+0.j]]), array([[1.+0.j, 0.+0.j],\n", " [0.+0.j, 1.+0.j]]))" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.dot(sx,sx), np.dot(sy,sy), np.dot(sz,sz)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "-----------\n", "\n", "#### Experiment 1 :\n", "\n", "- A generic rotation $ U_n(\\theta) = e^{-i \\theta n.\\sigma} = e^{-i (\\theta_x \\sigma_x + \\theta_y \\sigma_y + \\theta_z \\sigma_z)} $\n", "\n", "Note: $ U_n(\\theta) = e^{-i \\theta n.\\sigma} \\neq e^{-i (\\theta_x \\sigma_x)} e^{-i (\\theta_y \\sigma_y)} e^{-i(\\theta_z \\sigma_z)} $ since pauli matrices are non-commuting.\n", "\n", "- Generic quantum state in ($s =1/2$) subspace: $|\\psi \\rangle = \\alpha |\\psi_{1/2}\\rangle + \\beta |\\psi_{-1/2}\\rangle$\n", "\n", "[Non-commuting Matrix exponentials](https://math.stackexchange.com/questions/588007/non-commuting-matrix-exponentials/590120)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---------" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us tast above fact by evaluating generic rotation operator $U_n$ around a arbitrary axix $n$ (i.e., $e^{-i (\\theta_x \\sigma_x + \\theta_y \\sigma_y + \\theta_z \\sigma_z)})$ as ```U_direct``` and the product of individual rotation operator (i.e., $ e^{-i (\\theta_x \\sigma_x)} e^{-i (\\theta_y \\sigma_y)} e^{-i(\\theta_z \\sigma_z)}$) as ```U_prod``` in the code cells below. We will clearly see that thes two terms are not equal verifying relation $e^{-i \\theta n.\\sigma} \\neq e^{-i (\\theta_x \\sigma_x)} e^{-i (\\theta_y \\sigma_y)} e^{-i(\\theta_z \\sigma_z)}$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Calculate $e^{-i (\\theta_x \\sigma_x + \\theta_y \\sigma_y + \\theta_z \\sigma_z)})$ as ```U_direct```" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0.89894119-0.25291945j, -0.25291945-0.25291945j],\n", " [ 0.25291945-0.25291945j, 0.89894119+0.25291945j]])" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "U_direct = expm(-1j*((np.pi/12)*sx + (np.pi/12)*sy + (np.pi/12)*sz))\n", "U_direct" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Calculate $e^{-i (\\theta_x \\sigma_x)} e^{-i (\\theta_y \\sigma_y)} e^{-i(\\theta_z \\sigma_z)}$ as product of three individual rotation as ```U_prod```" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([[0.92387953-0.38268343j, 0. +0.j ],\n", " [0. +0.j , 0.92387953+0.38268343j]]),\n", " array([[0.96592583+0.j , 0. -0.25881905j],\n", " [0. -0.25881905j, 0.96592583+0.j ]]),\n", " array([[ 0.95105652+0.j, -0.30901699+0.j],\n", " [ 0.30901699+0.j, 0.95105652+0.j]]))" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Ux = expm(-1j*np.pi/12*sx)\n", "Uy = expm(-1j*np.pi/10*sy)\n", "Uz = expm(-1j*np.pi/8*sz)\n", "Uz,Ux,Uy" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0.81811516-0.42544356j, -0.18156837-0.34164059j],\n", " [ 0.18156837-0.34164059j, 0.81811516+0.42544356j]])" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "U_prod = np.dot(Ux,np.dot(Uy,Uz))\n", "U_prod" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Are ```U_direct``` and ```U_prod``` same Operators?\n", "Why? \n", "\n", "We can see these two operators are not same by implement them in same initial state ```psi0``` vector and observe the final states are not same." ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.70710678, 0.70710678])" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "psi0 = 1/np.sqrt(2)*np.array([1,1])\n", "psi0" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([0.45680635-3.57682117e-01j, 0.81448847+8.32667268e-17j]),\n", " array([0.45010655-0.5424104j , 0.706883 +0.05925765j]))" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.dot(U_direct,psi0), np.dot(U_prod,psi0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- In fact, both of them are Unitary operators with determinant 1" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((0.9999999999999999+1.1102230246251564e-16j), (1.0000000000000002+0j))" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LA.det(U_direct), LA.det(U_prod)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Angular Momentum $l =1, m = -1,0,1$\n", "Matrix size = 3x3" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True\n", " Qobj data =\n", " [[0. 0.70710678 0. ]\n", " [0.70710678 0. 0.70710678]\n", " [0. 0.70710678 0. ]],\n", " Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True\n", " Qobj data =\n", " [[0.+0.j 0.-0.70710678j 0.+0.j ]\n", " [0.+0.70710678j 0.+0.j 0.-0.70710678j]\n", " [0.+0.j 0.+0.70710678j 0.+0.j ]],\n", " Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True\n", " Qobj data =\n", " [[ 1. 0. 0.]\n", " [ 0. 0. 0.]\n", " [ 0. 0. -1.]])" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jmat(1)" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [], "source": [ "LX = np.array(jmat(1,'x'))\n", "LY = np.array(jmat(1,'y'))\n", "LZ = np.array(jmat(1,'z'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Do $L_x, L_y$ commute?" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[False, True, True],\n", " [ True, False, True],\n", " [ True, True, False]])" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.dot(LX,LY) == np.dot(LY,LX)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- What is matrix element of $L^{2}$ ?" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[2.+0.j, 0.+0.j, 0.+0.j],\n", " [0.+0.j, 2.+0.j, 0.+0.j],\n", " [0.+0.j, 0.+0.j, 2.+0.j]])" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L_square = (np.dot(LX,LX) + np.dot(LY,LY) +np.dot(LZ,LZ))\n", "L_square" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "-------" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Experiment 2\n", "\n", "- Rotaion $ R(\\theta) = e^{-i \\theta n.L} = e^{-i (\\theta_x L_x + \\theta_y L_y + \\theta_z L_z)} $\n", "\n", "- Generic quantum state in ($l =0$) subspace: $|\\psi \\rangle = \\alpha |\\psi_{10}\\rangle + \\beta |\\psi_{11} \\rangle + \\gamma |\\psi_{1-1} \\rangle$\n", "\n", "Let us find rotation matrix for subspace (l=1) with different values of $\\theta_x, \\theta_y, \\theta_z$" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [], "source": [ "Rx = expm(-(1.0j)*0.1*LX)\n", "Ry = expm(-(1.0j)*0.2*LY)\n", "Rz = expm(-(1.0j)*0.3*LZ)\n", "R_prod = np.dot(Rx,np.dot(Ry,Rz))\n", "R_direct = expm(-(1.0j)*(0.1*LX + 0.2*LY + 0.3*LZ))" ] }, { "cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([[ 0.94049792-3.01310652e-01j, -0.14048043-6.91857281e-02j,\n", " 0.00420456+1.16811741e-02j],\n", " [ 0.11267399-1.08747365e-01j, 0.97517033+6.69983947e-18j,\n", " -0.11267399-1.08747365e-01j],\n", " [ 0.00420456-1.16811741e-02j, 0.14048043-6.91857281e-02j,\n", " 0.94049792+3.01310652e-01j]]),\n", " array([[ 0.94316771-2.93048837e-01j, -0.14862798-4.81054052e-02j,\n", " 0.00741291+9.88387642e-03j],\n", " [ 0.12766111-9.00391414e-02j, 0.97529031-1.50304582e-18j,\n", " -0.12766111-9.00391414e-02j],\n", " [ 0.00741291-9.88387642e-03j, 0.14862798-4.81054052e-02j,\n", " 0.94316771+2.93048837e-01j]]))" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R_prod, R_direct" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Mini Assignment:**\n", "- Roate a random vector $|\\psi \\rangle $,i.e. ($|\\psi \\rangle = \\alpha |\\psi_{10}\\rangle + \\beta |\\psi_{11} \\rangle + \\gamma |\\psi_{1-1} \\rangle)$ by implementing ```R_prod``` and ``` R_direct``` calculated above and compere the final state vectors." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Angular Momentum plus Spin: $l = 3/2, m = -3/2,-1/2,1/2,3/2$\n", "Matrix size = 4x4" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 0.866 & 0.0 & 0.0\\\\0.866 & 0.0 & 1.0 & 0.0\\\\0.0 & 1.0 & 0.0 & 0.866\\\\0.0 & 0.0 & 0.866 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\n", "Qobj data =\n", "[[0. 0.8660254 0. 0. ]\n", " [0.8660254 0. 1. 0. ]\n", " [0. 1. 0. 0.8660254]\n", " [0. 0. 0.8660254 0. ]]" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jmat(3/2,'x')" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & -0.866j & 0.0 & 0.0\\\\0.866j & 0.0 & -1.0j & 0.0\\\\0.0 & 1.0j & 0.0 & -0.866j\\\\0.0 & 0.0 & 0.866j & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\n", "Qobj data =\n", "[[0.+0.j 0.-0.8660254j 0.+0.j 0.+0.j ]\n", " [0.+0.8660254j 0.+0.j 0.-1.j 0.+0.j ]\n", " [0.+0.j 0.+1.j 0.+0.j 0.-0.8660254j]\n", " [0.+0.j 0.+0.j 0.+0.8660254j 0.+0.j ]]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jmat(3/2,'y')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Summary: Rotation in Hilbert Space \n", "\n", "Structure of a general [rotation matrix (R) in Hilbert space](https://www2.ph.ed.ac.uk/~ldeldebb/docs/QM2/chap4.pdf)\n", "\n", "j = 1/2,1,3/2,2,5/2,3,...\n", "\n", "- A general rotation matrix ($R$) in hilbert space of basis $|l,m\\rangle$ appears as block diagonal matrix, wher every block represents the rotation with specific subspaces called irriducible subspace.\n", "- In the same basis $|l,m\\rangle$ Hamiltonian Matrix $H$, $J^2$ and $J_z$ are simultaneously diagonalized." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![img](https://physicscourses.colorado.edu/phys5250/phys5250_fa19/images/block-diag.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "-----------" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Quantum Harmonic Oscillator" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & -0.707j & 0.0 & 0.0 & 0.0\\\\0.707j & 0.0 & -1.0j & 0.0 & 0.0\\\\0.0 & 1.0j & 0.0 & -1.225j & 0.0\\\\0.0 & 0.0 & 1.225j & 0.0 & -1.414j\\\\0.0 & 0.0 & 0.0 & 1.414j & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True\n", "Qobj data =\n", "[[0.+0.j 0.-0.70710678j 0.+0.j 0.+0.j\n", " 0.+0.j ]\n", " [0.+0.70710678j 0.+0.j 0.-1.j 0.+0.j\n", " 0.+0.j ]\n", " [0.+0.j 0.+1.j 0.+0.j 0.-1.22474487j\n", " 0.+0.j ]\n", " [0.+0.j 0.+0.j 0.+1.22474487j 0.+0.j\n", " 0.-1.41421356j]\n", " [0.+0.j 0.+0.j 0.+0.j 0.+1.41421356j\n", " 0.+0.j ]]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "momentum(5)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 0.707 & 0.0 & 0.0 & 0.0\\\\0.707 & 0.0 & 1.0 & 0.0 & 0.0\\\\0.0 & 1.0 & 0.0 & 1.225 & 0.0\\\\0.0 & 0.0 & 1.225 & 0.0 & 1.414\\\\0.0 & 0.0 & 0.0 & 1.414 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True\n", "Qobj data =\n", "[[0. 0.70710678 0. 0. 0. ]\n", " [0.70710678 0. 1. 0. 0. ]\n", " [0. 1. 0. 1.22474487 0. ]\n", " [0. 0. 1.22474487 0. 1.41421356]\n", " [0. 0. 0. 1.41421356 0. ]]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "position(5)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 0.0 & 0.0 & 0.0\\\\1.0 & 0.0 & 0.0 & 0.0\\\\0.0 & 1.414 & 0.0 & 0.0\\\\0.0 & 0.0 & 1.732 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = False\n", "Qobj data =\n", "[[0. 0. 0. 0. ]\n", " [1. 0. 0. 0. ]\n", " [0. 1.41421356 0. 0. ]\n", " [0. 0. 1.73205081 0. ]]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create(4)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0 & 0.0 & 0.0 & 0.0\\\\0.0 & 0.0 & 1.414 & 0.0 & 0.0\\\\0.0 & 0.0 & 0.0 & 1.732 & 0.0\\\\0.0 & 0.0 & 0.0 & 0.0 & 2.0\\\\0.0 & 0.0 & 0.0 & 0.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = False\n", "Qobj data =\n", "[[0. 1. 0. 0. 0. ]\n", " [0. 0. 1.41421356 0. 0. ]\n", " [0. 0. 0. 1.73205081 0. ]\n", " [0. 0. 0. 0. 2. ]\n", " [0. 0. 0. 0. 0. ]]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "destroy(5)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 0.0 & 0.0 & 0.0\\\\0.0 & 1.0 & 0.0 & 0.0\\\\0.0 & 0.0 & 2.0 & 0.0\\\\0.0 & 0.0 & 0.0 & 3.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\n", "Qobj data =\n", "[[0. 0. 0. 0.]\n", " [0. 1. 0. 0.]\n", " [0. 0. 2. 0.]\n", " [0. 0. 0. 3.]]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "num(4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3. Random Matrices" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Random hermitian matrix" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}-0.501 & (-0.172+0.146j) & 0.0 & (-0.060+0.697j)\\\\(-0.172-0.146j) & 0.169 & (-0.305+0.588j) & (0.044+0.641j)\\\\0.0 & (-0.305-0.588j) & 0.0 & (-0.458-0.087j)\\\\(-0.060-0.697j) & (0.044-0.641j) & (-0.458+0.087j) & 0.756\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = True\n", "Qobj data =\n", "[[-0.50113582+0.j -0.17222998+0.14571042j 0. +0.j\n", " -0.06039662+0.6965142j ]\n", " [-0.17222998-0.14571042j 0.1689534 +0.j -0.30474969+0.58835929j\n", " 0.04412378+0.64077284j]\n", " [ 0. +0.j -0.30474969-0.58835929j 0. +0.j\n", " -0.45812567-0.08748371j]\n", " [-0.06039662-0.6965142j 0.04412378-0.64077284j -0.45812567+0.08748371j\n", " 0.75578241+0.j ]]" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rand_herm(4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Random Unitary Matrix" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}(0.332-0.610j) & (-0.248+0.007j) & (-0.332-0.267j) & (0.468-0.235j)\\\\(-0.062-0.085j) & (0.838-0.353j) & (-0.312-0.253j) & (3.589\\times10^{-05}-0.034j)\\\\(-0.032-0.481j) & (0.145-0.293j) & (0.790+0.106j) & (0.020-0.156j)\\\\(-0.427+0.302j) & (0.069+0.006j) & (0.109+0.097j) & (0.834-0.066j)\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[4], [4]], shape = (4, 4), type = oper, isherm = False\n", "Qobj data =\n", "[[ 3.32426091e-01-0.61008781j -2.48216764e-01+0.00742287j\n", " -3.32218003e-01-0.26721645j 4.67803649e-01-0.23453233j]\n", " [-6.18056368e-02-0.08520346j 8.37959790e-01-0.35291461j\n", " -3.11514724e-01-0.25291069j 3.58896057e-05-0.03449434j]\n", " [-3.17360027e-02-0.48099205j 1.44640852e-01-0.29316018j\n", " 7.90378747e-01+0.10591817j 2.00616601e-02-0.15638388j]\n", " [-4.27155409e-01+0.30229774j 6.86551818e-02+0.00553252j\n", " 1.09189564e-01+0.0968594j 8.34155661e-01-0.06550129j]]" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rand_unitary(4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Mini Assignment:\n", "1. Generate a random Hermitian matrix $H$ of size 10 by 10.\n", "3. Diagonalize the Hermitian Operator $H$ and find eigne values and eigen vectors.\n", "2. Create a Unitary operator $U$ by exponentiating the Hermitian matrix i.e. $U = e^{-i \\alpha H}$.\n", "3. Apply operator $U$ over eigen vectors of operator $H$. Does this operation preserve the norm of eigen vectors?\n", "3. Check that $U$ is unitary or not.\n", "4. What is the determinant of $U$?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reference\n", "1. [Rotation](https://www2.ph.ed.ac.uk/~ldeldebb/docs/QM2/chap4.pdf)\n", "2. [Spherical Harmonics](https://en.wikipedia.org/wiki/Spherical_harmonics)\n", "3. [Angular Momentum](https://theory.physics.manchester.ac.uk/~xian/qm/chapter2.pdf)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "widgets": { "state": {}, "version": "1.1.2" } }, "nbformat": 4, "nbformat_minor": 2 }