{
 "metadata": {
  "name": "",
  "signature": "sha256:18ac31f959977ef2080ed3a1b1a6990ce93e604dcfb0f72ab45c0c28a2428e0e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Quantum Mechanics and Quantum Computing"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.1, Page number 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "c=3*10**8             #velocity of light in m/s\n",
      "h=6.626*10**-34       #planks constant \n",
      "m=1.67*10**-27        #mass of proton\n",
      "\n",
      "#Calculation\n",
      "v=c/10                #velocity of proton\n",
      "lamda=h/(m*v)          #de Broglie wave length\n",
      "\n",
      "#Result\n",
      "print(\"the de Broglie wavelength in m is \",lamda);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('the de Broglie wavelength in m is ', 1.3225548902195607e-14)\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.2, Page number 42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "  \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V=400;   #potential in Volts\n",
      "\n",
      "#Calculation\n",
      "lamda=12.56/math.sqrt(V);   #de Broglie wavelength\n",
      "\n",
      "#Result\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamda);\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in Armstrong is', 0.628)\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.3, Page number 42\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "m=1.674*10**(-27);    #mass of neutron in kg\n",
      "h=6.626*10**(-34);\n",
      "E=0.025;   #kinetic energy in eV\n",
      "\n",
      "#Calculation\n",
      "Ej=E*1.6*10**-19;   #kinetic energy in J\n",
      "lamda=h/math.sqrt(2*m*Ej);   #de Broglie wavelength\n",
      "lamdaA=lamda*10**10;   #converting wavelength from m to Armstrong\n",
      "lamdaA=math.ceil(lamdaA*10**3)/10**3;   #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The de Broglie wavelength in metres is\",lamda);\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamdaA);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in metres is', 1.81062582829353e-10)\n",
        "('The de Broglie wavelength in Armstrong is', 1.811)\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.4, Page number 42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V=1600;   #potential in Volts\n",
      "\n",
      "#Calculation\n",
      "lamda=12.56/math.sqrt(V);   #de Broglie wavelength\n",
      "lamda=math.ceil(lamda*10**2)/10**2;   #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamda);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in Armstrong is', 0.32)\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.5, Page number 42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "deltax=0.2;   #distance in armstrong\n",
      "h=6.626*10**(-34);\n",
      "\n",
      "#Calculation\n",
      "delta_xm=deltax*10**-10;    #distance in m\n",
      "delta_p=h/(2*math.pi*delta_xm);\n",
      "\n",
      "#Result\n",
      "print(\"The uncertainity in momentum of electron in kg m/sec is\",delta_p);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The uncertainity in momentum of electron in kg m/sec is', 5.2728032646344916e-24)\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.6, Page number 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1=1;\n",
      "n2=1;\n",
      "n3=1;    #values in lowest energy\n",
      "h=6.62*10**(-34);\n",
      "M=9.1*10**-31;   #mass in kg\n",
      "L=0.1;   #side in nm\n",
      "\n",
      "#Calculation\n",
      "L=L*10**-9;    #side in m\n",
      "n=(n1**2)+(n2**2)+(n3**2);\n",
      "E1=(n*h**2)/(8*M*L**2);    #energy in j\n",
      "E1eV=E1/(1.6*10**-19);    #energy in eV\n",
      "E1eV=math.ceil(E1eV*10)/10;   #rounding off to 1 decimals\n",
      "\n",
      "#Result\n",
      "print(\"lowest energy of electron in Joule is\",E1);\n",
      "print(\"lowest energy of electron is eV\",E1eV);\n",
      "\n",
      "#answer for lowest energy in eV given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('lowest energy of electron in Joule is', 1.8059505494505486e-17)\n",
        "('lowest energy of electron is eV', 112.9)\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.7, Page number 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "M=9.1*10**(-31);    #mass of electron in kg\n",
      "h=6.66*10**(-34);\n",
      "E=2000;   #kinetic energy in eV\n",
      "\n",
      "#Calculation\n",
      "Ej=E*1.6*10**-19;   #kinetic energy in J\n",
      "lamda=h/math.sqrt(2*M*Ej);   #de Broglie wavelength\n",
      "lamdaA=lamda*10**9;   #converting wavelength from m to nm\n",
      "lamdaA=math.ceil(lamdaA*10**3)/10**3;   #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The de Broglie wavelength in nm is\",lamdaA);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in nm is', 0.028)\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.8, Page number 43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n=1;   #for minimum energy\n",
      "h=6.626*10**(-34);\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "L=4*10**-10;   #size in m\n",
      "\n",
      "#Calculation\n",
      "E1=(n*h**2)/(8*m*L**2);    #energy in j\n",
      "\n",
      "#Result\n",
      "print(\"lowest energy of electron in Joule is\",E1);\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('lowest energy of electron in Joule is', 3.7692201236263733e-19)\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.9, Page number 44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "h=6.626*10**(-34);\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "lamda=1.66*10**-10;   #wavelength in m\n",
      "\n",
      "#Calculation\n",
      "v=h/(m*lamda);    #velocity in m/sec\n",
      "v_km=v*10**-3;    #velocity in km/sec\n",
      "E=(1/2)*m*v**2;    #kinetic energy in joule\n",
      "EeV=E/(1.6*10**-19);    #energy in eV\n",
      "EeV=math.ceil(EeV*10**3)/10**3;   #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print(\"velocity of electron in m/sec is\",round(v));\n",
      "print(\"velocity of electron in km/sec is\",round(v_km));\n",
      "print(\"kinetic energy of electron in Joule is\",E);\n",
      "print(\"kinetic energy of electron in eV is\",EeV);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('velocity of electron in m/sec is', 4386337.0)\n",
        "('velocity of electron in km/sec is', 4386.0)\n",
        "('kinetic energy of electron in Joule is', 8.754176510091736e-18)\n",
        "('kinetic energy of electron in eV is', 54.714)\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.10, Page number 44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "V=15;   #potential in kV\n",
      "\n",
      "#Calculation\n",
      "v=V*10**3;    #potential in V\n",
      "lamda=12.26/math.sqrt(v);    #de Broglie wavelength\n",
      "lamda=math.ceil(lamda*10**2)/10**2      #rounding off to 2 decimals\n",
      "\n",
      "#result\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamda);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in Armstrong is', 0.11)\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.11, Page number 44\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Calculation\n",
      "m=1.675*10**-27;    #mass of neutron in kg\n",
      "h=6.626*10**-34;\n",
      "E=10;   #kinetic energy in keV\n",
      "\n",
      "#Calculation\n",
      "EeV=E*10**3;    #Energy in eV\n",
      "Ej=EeV*1.6*10**-19;   #kinetic energy in J\n",
      "v=math.sqrt(2*Ej/m);  #velocity in m/s\n",
      "lamda=h/(m*v);    #de broglie wavelength in m\n",
      "lamda_A=lamda*10**10;   #de broglie wavelength in armstrong\n",
      "lamda_A=math.ceil(lamda_A*10**4)/10**4      #rounding off to 4 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The velocity in m/sec is\",round(v));\n",
      "print(\"The de Broglie wavelength in metres is\",lamda);\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamda_A);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The velocity in m/sec is', 1382189.0)\n",
        "('The de Broglie wavelength in metres is', 2.861996093951046e-13)\n",
        "('The de Broglie wavelength in Armstrong is', 0.0029)\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.12, Page number 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "m=9.1*10**-31;    #mass of electron in kg\n",
      "h=6.6*10**-34;\n",
      "E=2;   #kinetic energy in keV\n",
      "\n",
      "#Calculation\n",
      "EeV=E*10**3;    #Energy in eV\n",
      "Ej=EeV*1.6*10**-19;   #kinetic energy in J\n",
      "p=math.sqrt(2*m*Ej);   #momentum\n",
      "lamda=h/p;    #de broglie wavelength in m\n",
      "lamda_A=lamda*10**10;   #de broglie wavelength in armstrong\n",
      "lamda_A=math.ceil(lamda_A*10**4)/10**4      #rounding off to 4 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The de Broglie wavelength in metres is\",lamda);\n",
      "print(\"The de Broglie wavelength in Armstrong is\",lamda_A);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in metres is', 2.7348483695436575e-11)\n",
        "('The de Broglie wavelength in Armstrong is', 0.2735)\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.13, Page number 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "m=1.676*10**-27;    #mass of neutron in kg\n",
      "h=6.62*10**-34;\n",
      "E=0.025;   #kinetic energy in eV\n",
      "\n",
      "#Calculation\n",
      "Ej=E*1.6*10**-19;   #kinetic energy in J\n",
      "v=math.sqrt(2*Ej/m);   #velocity in m/s\n",
      "lamda=h/(m*v);    #wavelength in m\n",
      "lamda_A=lamda*10**10;   #de broglie wavelength in armstrong\n",
      "lamda_A=math.ceil(lamda_A*10**5)/10**5      #rounding off to 5 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The neutrons wavelength in metres is\",lamda);\n",
      "print(\"The wavelength in Armstrong is\",lamda_A);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The neutrons wavelength in metres is', 1.8079065940980725e-10)\n",
        "('The wavelength in Armstrong is', 1.80791)\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.14, Page number 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "V=10;   #potential in kV\n",
      "\n",
      "#Calculation\n",
      "V=V*10**3;   #potential in V\n",
      "lamda=12.26/math.sqrt(V);    #wavelength\n",
      "\n",
      "#Result\n",
      "print(\"The wavelength in Armstrong is\",lamda);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The wavelength in Armstrong is', 0.1226)\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.15, Page number 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "\n",
      "#Varialble decleration\n",
      "h=6.626*10**-34;\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "l=1;    #width in armstrong\n",
      "\n",
      "#Calculation\n",
      "L=l*10**-10;   #width in m\n",
      "#permitted electron energies En=(n**2*h**2)/(8*m*L**2)\n",
      "#let X = h**2/(8*m*L**2)\n",
      "X = h**2/(8*m*L**2);    #energy in J\n",
      "XeV=X/(1.6*10**-19);   #energy in eV\n",
      "#in the 1st level n1=1\n",
      "n1=1;\n",
      "E1=(n1**2)*XeV;    #energy in eV\n",
      "\n",
      "#in second level n2=2\n",
      "n2=2;\n",
      "E2=(n2**2)*XeV;    #energy in eV\n",
      "#in third level n3=\n",
      "n3=3;\n",
      "E3=(n3**2)*XeV;    #energy in eV\n",
      "\n",
      "#Result\n",
      "print(\"minimum energy the electron can have in eV is\",round(E1));\n",
      "print(\"other values of energy are in eV and in eV\",round(E2),round(E3));\n",
      "\n",
      "#answers given in the book are wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('minimum energy the electron can have in eV is', 38.0)\n",
        "('other values of energy are in eV and in eV', 151.0, 339.0)\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.16, Page number 46\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "n=1;   #lowest state\n",
      "L=10;    #width in armstrong\n",
      "\n",
      "#Calculation\n",
      "L=L*10**-10;    #width in m\n",
      "x=L/2;\n",
      "delta_x=1;    #interval in armstrong\n",
      "delta_x=delta_x*10**-10;    #interval in m\n",
      "psi1=(math.sqrt(2/L))*math.sin(math.pi*x/L);\n",
      "A=psi1**2;\n",
      "p=A*delta_x;\n",
      "p=math.ceil(p*10)/10;   #de broglie wavelength in armstrong\n",
      "\n",
      "#Result\n",
      "print(\"probability of finding the particle is \",p);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('probability of finding the particle is ', 0.2)\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.17, Page number 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "d=970;   #density of Na in kg/m^3\n",
      "n=6.02*10**26;\n",
      "h=6.62*10**(-34);\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "w=23;   #atomic weight\n",
      "\n",
      "#Calculation\n",
      "N=(d*n)/w;   #number of atoms per m^3\n",
      "A=(h**2)/(8*m);\n",
      "B=(3*N)/math.pi;\n",
      "Ef=A*B**(2/3);\n",
      "EfeV=Ef/(1.6*10**-19);\n",
      "EfeV=math.ceil(EfeV*10**2)/10**2           #rounding of to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"fermi energy of Na in eV is\",EfeV);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('fermi energy of Na in eV is', 3.16)\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.18, Page number 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "n1=1;\n",
      "n2=1;\n",
      "n3=1;    #values in lowest energy\n",
      "h=6.62*10**(-34);\n",
      "m=9.1*10**-31;  #mass in kg\n",
      "L=0.1;   #side in nm\n",
      "\n",
      "#Calculation\n",
      "L=L*10**-9;    #side in m\n",
      "n=(n1**2)+(n2**2)+(n3**2);\n",
      "E1=(n*h**2)/(8*m*L**2);    #energy in j\n",
      "E1eV=E1/(1.6*10**-19);    #energy in eV\n",
      "E1eV=math.ceil(E1eV*10**1)/10**1      #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"lowest energy of electron in Joule is\",E1);\n",
      "print(\"lowest energy of electron in eV is\",E1eV);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('lowest energy of electron in Joule is', 1.8059505494505486e-17)\n",
        "('lowest energy of electron in eV is', 112.9)\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.19, Page number 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "mn=1.676*10**-27;   #mass of neutron in kg\n",
      "me=9.1*10**-31;    #mass of electron in kg\n",
      "h=6.62*10**-34;\n",
      "c=3*10**8;         #velocity of light in m/sec\n",
      "\n",
      "#Calculation\n",
      "En=2*me*c**2;\n",
      "lamda=h/math.sqrt(2*mn*En);   #wavelength in m\n",
      "lamda_A=lamda*10**10;    #converting lamda from m to A\n",
      "lamda_A=math.ceil(lamda_A*10**6)/10**6      #rounding off to 6 decimals\n",
      "\n",
      "#Result\n",
      "print(\"The de broglie wavelength in Angstrom is\",lamda_A);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de broglie wavelength in Angstrom is', 0.000283)\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.20, Page number 47   ***************************************************************************"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "n2=2;    #second quantum state\n",
      "n4=4;    #fourth quantum state\n",
      "h=6.626*10**-34;\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "a=2;   #potential box length in armstrong\n",
      "\n",
      "#Calculation\n",
      "a=a*10**-10;    #length in m\n",
      "A=n2**2*h**2;\n",
      "B=8*m*a**2;\n",
      "E2=A/B;    #energy in j\n",
      "E2eV=E2/(1.6*10**-19);    #energy in eV\n",
      "C=n4**2*h**2;\n",
      "E4=C/B;    #energy in j\n",
      "E4eV=E4/(1.6*10**-19);    #energy in eV\n",
      "\n",
      "#Result\n",
      "print(\"energy corresponding to second quantum state in Joule is\",E2);\n",
      "print(\"energy corresponding to second quantum state in eV is\",E2eV);\n",
      "print(\"energy corresponding to fourth quantum state in Joule is\",E4);\n",
      "print(\"energy corresponding to fourth quantum state in eV is\",E4eV);\n",
      "\n",
      "\n",
      "#answers given in the book are wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('energy corresponding to second quantum state in Joule is', 6.030752197802197e-18)\n",
        "('energy corresponding to second quantum state in eV is', 37.69220123626373)\n",
        "('energy corresponding to fourth quantum state in Joule is', 2.412300879120879e-17)\n",
        "('energy corresponding to fourth quantum state in eV is', 150.7688049450549)\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.21, Page number 48 ***********"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "V=344;   #accelerated voltage in V\n",
      "n=1;    #first reflection\n",
      "theta=60;   #glancing angle in degrees\n",
      "\n",
      "#Calculation\n",
      "lamda=12.27/math.sqrt(V);\n",
      "d=(n*lamda)/(2*math.sin(theta));\n",
      "\n",
      "#Result\n",
      "print(\"The spacing of the crystal in Angstrom is\",lamda);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The spacing of the crystal in Angstrom is', 0.6615540636030947)\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.22, Page number 49 *************"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "n2=2;    #second quantum state\n",
      "n3=3;    #fourth quantum state\n",
      "h=6.626*10**-34;\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "a=1*10**-10;    #width of potential well in m\n",
      "\n",
      "#Calculation\n",
      "B=8*m*a**2;\n",
      "E1=h**2/B;   #ground state energy\n",
      "E1eV=E1/(1.6*10**-19);    #energy in eV\n",
      "A=n2**2*h**2;\n",
      "E2=A/B;    #energy in j\n",
      "E2eV=E2/(1.6*10**-19);    #energy in eV\n",
      "C=n3**2*h**2;\n",
      "E3=C/B;    #energy in j\n",
      "E3eV=E3/(1.6*10**-19);    #energy in eV\n",
      "E1=math.ceil(E1*10**3)/10**3      #rounding off to 3 decimals\n",
      "E1eV=math.ceil(E1eV*10**3)/10**3      #rounding off to 3 decimals\n",
      "E2eV=math.ceil(E2eV*10**3)/10**3      #rounding off to 3 decimals\n",
      "E3eV=math.ceil(E3eV*10**3)/10**3      #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print(\"ground state energy in Joule is\",E1);\n",
      "print(\"ground state energy in eV is\",E1eV);\n",
      "print(\"first energy state in eV is\",E2eV);\n",
      "print(\"second energy state in eV is\",E3eV);\n",
      "\n",
      "#answers given in the book are wrong by one decimal"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('ground state energy in Joule is', 0.001)\n",
        "('ground state energy in eV is', 37.693)\n",
        "('first energy state in eV is', 150.769)\n",
        "('second energy state in eV is', 339.23)\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.23, Page number 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "n3=3;    #fourth quantum state\n",
      "h=6.626*10**-34;\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "\n",
      "\n",
      "#ground state energy E1 = h**2/(8*m*a**2)\n",
      "#second excited state E3 = (9*h**2)/(8*m*a**2)\n",
      "#required energy E = E3-E1\n",
      "#E = (9*h**2)/(8*m*a**2) - h**2/(8*m*a**2)\n",
      "#E = (h**2/(8*m*a**2))*(9-1)\n",
      "#therefore E = (8*h**2)/(8*m*a**2)\n",
      "#hence E = (h**2)/(m*a**2)\n",
      "\n",
      "#Result \n",
      "# the required energy is E = (h**2)/(m*a**2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.24, Page number 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "delta_x=10**-8;   #length of box in m\n",
      "h=6.626*10**-34;\n",
      "m=9.1*10**-31;   #mass in kg\n",
      "\n",
      "#Calculation\n",
      "delta_v=h/(m*delta_x);    #uncertainity in m/sec\n",
      "delta_vk=delta_v*10**-3;   #uncertainity in km/sec\n",
      "delta_vk=math.ceil(delta_vk*10**2)/10**2      #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"minimum uncertainity in velocity in m/sec is\",round(delta_v));\n",
      "print(\"minimum uncertainity in velocity in km/sec is\",delta_vk);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('minimum uncertainity in velocity in m/sec is', 72813.0)\n",
        "('minimum uncertainity in velocity in km/sec is', 72.82)\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.25, Page number 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "  \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "mp=1.6*10**-27;   #mass of proton in kg\n",
      "me=9.1*10**-31;    #mass of electron in kg\n",
      "h=6.626*10**(-34);\n",
      "c=3*10**10;    #velocity of light in m/sec\n",
      "\n",
      "#Calculation\n",
      "Ep=me*c**2;\n",
      "lamda=h/math.sqrt(2*mp*Ep);   #wavelength in m\n",
      "lamda_A=lamda*10**10;    #converting lamda from m to A\n",
      "\n",
      "#Result\n",
      "print(\"The de broglie wavelength in Angstrom is\",lamda_A);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de broglie wavelength in Angstrom is', 4.092931643497047e-06)\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 1.26, Page number 51 *************************************************"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#import module\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable decleration\n",
      "m=1.675*10**(-27);    #mass of neutron in kg\n",
      "h=6.626*10**(-34);\n",
      "n=1;   #diffractive order\n",
      "d=0.314;   #spacing in nm\n",
      "E=0.04;   #kinetic energy in eV\n",
      "\n",
      "#Calculation\n",
      "d=d*10**-9;   #spacing in m\n",
      "Ej=E*1.6*10**-19;   #kinetic energy in J\n",
      "lamda=h/math.sqrt(2*m*Ej);   #de Broglie wavelength\n",
      "lamdaA=lamda*10**9;   #converting wavelength from m to nm\n",
      "theta=math.asin((n*lamda)/(2*d));\n",
      "print(\"The de Broglie wavelength in metres is\",lamda);\n",
      "print(\"The de Broglie wavelength in nm is\",lamdaA);\n",
      "print(\"glancing angle in degrees is\",theta);\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('The de Broglie wavelength in metres is', 1.4309980469755228e-10)\n",
        "('The de Broglie wavelength in nm is', 0.1430998046975523)\n",
        "('glancing angle in degrees is', 0.2298853909391574)\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}