{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 1:INTERFERENCE AND DIFFRACTION OF LIGHT"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.1, Page number 1.35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The fringe width beta= 0.2945 mm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "D=1                    #Distance in metre\n",
    "lamda=589*10**-9       #nm to metres\n",
    "d=2*10**-3             #mm to metre\n",
    "\n",
    "#Calculation\n",
    "beta=(D*lamda)/d\n",
    "\n",
    "#Result\n",
    "print\"The fringe width beta=\",round(beta*10**3,4),\"mm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.2, Page number 1.35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Thickness of glass plate= 3.27 micron.\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "N=3               #position\n",
    "lamda=5450*10**-10      #Wawelength in Armstrong to metre\n",
    "mu=1.5\n",
    "\n",
    "#Calculation\n",
    "t=(N*lamda)/(mu-1)\n",
    "\n",
    "#Result\n",
    "print\"Thickness of glass plate=\",round(t*10**6,2),\"micron.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.3, Page number 1.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of lines n the grating= 9539.0\n",
      "#Answer varies due to rounding of number\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "w=0.02      \n",
    "n=1\n",
    "lamda=6.56*10**-7\n",
    "theta=(18+(14/60))*math.pi/180\n",
    "\n",
    "#Calculation\n",
    "N=(w*math.sin(theta))/(n*lamda)\n",
    "\n",
    "#Result\n",
    "print\"Total number of lines n the grating=\",round(N)\n",
    "print\"#Answer varies due to rounding of number\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.4, Page number 1.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t= 11.786 micron\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=5893*10**-10           #Angstroms to mts\n",
    "x=4*10**-2\n",
    "beta=1*10**-3\n",
    "\n",
    "#Calculation\n",
    "t=(lamda*x)/(2*beta)\n",
    "\n",
    "#Result\n",
    "print\"t=\",round(t*10**6,3),\"micron\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.6, Page number 1.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The minimum thickness of coating,t= 996.4 Angstroms\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=5500\n",
    "nf=1.38\n",
    "\n",
    "#Calculation\n",
    "t=lamda/(4*nf)\n",
    "\n",
    "#Result\n",
    "print\"The minimum thickness of coating,t=\",round(t,1),\"Angstroms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.7, Page number 1.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wavelength,lamda= 5448.0 *10**-10 m\n",
      "#Answer varies due to rounding of number\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "beta=0.00227     #distance between adjascent green lines\n",
    "D=2.5             \n",
    "d=0.0006        #distance between narrow slits\n",
    "\n",
    "#Calculation\n",
    "lamda=(beta*d)/D\n",
    "\n",
    "#Result\n",
    "print\"Wavelength,lamda=\",round(lamda*10**10),\"*10**-10 m\"\n",
    "print\"#Answer varies due to rounding of number\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.8, Page number 1.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Smallest thickness of plate,t= 3927.0 *10**-10 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=5890*10**-10\n",
    "mu=1.5\n",
    "theta=60*math.pi/180     #Converting in to degrees\n",
    "\n",
    "#Calculation\n",
    "cos=math.cos(theta)\n",
    "t=(lamda)/(2*mu*(math.cos(theta)))\n",
    "         \n",
    "#Result\n",
    "print\"Smallest thickness of plate,t=\",round(t*10**10),\"*10**-10 m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.9, Page number 1.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Refractive index,mu = 1.31\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "R=1\n",
    "n=5\n",
    "lamda=5.895*10**-7\n",
    "dn=0.003\n",
    "\n",
    "#Calculation\n",
    "mu=(4*R*n*lamda)/(dn**2)\n",
    "\n",
    "#Result\n",
    "print\"Refractive index,mu =\",mu "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "##Example number 1.10, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "N = 327.4\n",
      "The number of rulings needed is 328. This is the minimum requirement.\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=5893;\n",
    "n=3\n",
    "d_lamda=6\n",
    "\n",
    "#Calculation\n",
    "N=(lamda)/(n*d_lamda)\n",
    "\n",
    "#Result\n",
    "print\"N =\",round(N,1)\n",
    "print\"The number of rulings needed is 328. This is the minimum requirement.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "##Example number 1.11, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Smallest angular separation of two stars = 2.642 *10**-7 radian\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=5.5*10**-7\n",
    "d=2.54\n",
    "x=1.22\n",
    "#Calculation\n",
    "dtheta=(x*lamda)/d\n",
    "\n",
    "#Result\n",
    "print\"Smallest angular separation of two stars =\",round(dtheta*10**7,3),\"*10**-7 radian\" "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example number 1.12, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Slit width value, a= 13000.0 Angstroms = 1.3 micron\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "lamda=6500\n",
    "theta=30*math.pi/180\n",
    "\n",
    "#Calculation\n",
    "a=lamda/math.sin(theta)\n",
    "\n",
    "#Result\n",
    "print\"Slit width value, a=\",a,\"Angstroms =\",round(a*10**-4,1),\"micron\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.13, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "r= 2.0 /1\n",
      "Hence the ratio of the amplitudes= 2:1\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a2=1\n",
    "a1=2*a2\n",
    "#Calculation\n",
    "r=a1/a2\n",
    "\n",
    "#Result\n",
    "print\"r=\",r,\"/1\"   #r = r/1 = r:1\n",
    "print\"Hence the ratio of the amplitudes= 2:1\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.14, Page number 1.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a= 2.0 *10**-4 m = 0.2 mm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "theta=5*10**-3/2\n",
    "lamda=5*10**-7\n",
    "\n",
    "#Calculation\n",
    "a=(lamda)/theta\n",
    "\n",
    "print\"a=\",round(a*10**4),\"*10**-4 m\",\"=\",a*10**3,\"mm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.15, Page number 1.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mu-1= 0.4\n",
      "Refractive index, mu= 1.4\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "N=20\n",
    "lamda=5000*10**-10       #Angstroms to meters\n",
    "t=2.5*10**-5\n",
    "\n",
    "#Calculation\n",
    "mu_1=(N*lamda)/t\n",
    "mu=1+(mu_1)\n",
    "\n",
    "#Result\n",
    "print\"mu-1=\",mu_1\n",
    "print\"Refractive index, mu=\",mu"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 1.16, Page number 1.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Maximum number of orders= 3.0\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "theta=90*math.pi/180    #theta=90 degrees to get maximum number of orders assume\n",
    "lamda=5890*10**-10\n",
    "aplusb=2*10**-6       #micro mts to mts \n",
    "\n",
    "#Calculation\n",
    "n=(aplusb*math.sin(theta))/lamda\n",
    "\n",
    "#Result\n",
    "print\"Maximum number of orders=\",round(n)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}