{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 6: Special Theory of Relativity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 3, Page number 235"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fringe shift is 0.2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "l=5;         #length(m)\n",
    "v=3*10**4;      #velocity(m/sec)\n",
    "c=3*10**8;      #velocity of light(m/sec)\n",
    "lamda=5000*10**-10;     #wavelength(m)\n",
    "\n",
    "#Calculation\n",
    "S=2*l*v**2/(c**2*lamda);     #fringe shift\n",
    "\n",
    "#Result\n",
    "print \"fringe shift is\",S"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4, Page number 235"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "coordinates w.r.t moving observer are (x1,y1,z1,t1)=( 800 100 100 0 )\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "x=1000;       #x-coordinate(m)\n",
    "c=3*10**8;    #velocity of light(m/sec)\n",
    "t=2*10**-6;   #time(s)\n",
    "v1=0.6*c;\n",
    "y1=y=100;     #y-coordinate(m)\n",
    "z1=z=100;     #z-coordinate(m)\n",
    "\n",
    "#Calculation\n",
    "x1=(x-(v1*t))/math.sqrt(1-((v1/c)**2));    #coordinate along x-axis\n",
    "t1=(t-(x*v1/c**2))/math.sqrt(1-((v1/c)**2));    #time\n",
    "\n",
    "#Result\n",
    "print \"coordinates w.r.t moving observer are (x1,y1,z1,t1)=(\",int(x1),int(y1),int(z1),int(t1),\")\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 5, Page number 236"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "decay time is 3.83 micro s\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "delta_t=2.3;      #time(micro s)\n",
    "c=1;              #assume\n",
    "v=0.8*c;          #velocity\n",
    "\n",
    "#Calculation\n",
    "delta_t1=delta_t/math.sqrt(1-(v**2/c**2));     #decay time(micro s)\n",
    "\n",
    "#Result\n",
    "print \"decay time is\",round(delta_t1,2),\"micro s\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 6, Page number 236"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "space shuttle velocity is 0.515 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "delta_t=24;      #time(hours)\n",
    "delta_t1=28;     #decay time(hours)\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(1-(delta_t/delta_t1)**2);      #space shuttle velocity(c)\n",
    "\n",
    "#Result\n",
    "print \"space shuttle velocity is\",round(v,3),\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 7, Page number 236"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "observed displacement is 375.0 m\n",
      "relative displacement is 433.01 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "delta_t=2.5*10**-6;      #time(s)\n",
    "c=3*10**8;              #velocity of light\n",
    "v=c/2;          #velocity\n",
    "\n",
    "#Calculation\n",
    "delta_t1=delta_t/math.sqrt(1-(v**2/c**2));     #decay time(s)\n",
    "x=v*delta_t;                                   #observed displacement(m)\n",
    "x1=v*delta_t1;                                 #relative displacement(m)\n",
    "\n",
    "#Result\n",
    "print \"observed displacement is\",x,\"m\"\n",
    "print \"relative displacement is\",round(x1,2),\"m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 8, Page number 237"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "relative decay in earth diameter is 6.4 *10**-5 m\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "R=6400;     #radius(km)\n",
    "c=3*10**8;     #velocity of light(m/sec)\n",
    "v=30*10**3;    #orbital velocity(m/sec)\n",
    "\n",
    "#Calculation\n",
    "d=2*R;      #diameter(km)\n",
    "d1=d*math.sqrt(1-(v**2/c**2));        \n",
    "delta_d=d-d1;                         #relative decay in earth diameter(m)\n",
    "\n",
    "#Result\n",
    "print \"relative decay in earth diameter is\",round(delta_d*10**5,1),\"*10**-5 m\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 9, Page number 237"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity is 0.28 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "L=1;       #length(m)\n",
    "L1=0.96;   #recorded length(m)\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(1-(L1/L)**2);      #velocity(c)\n",
    "\n",
    "#Result\n",
    "print \"velocity is\",v,\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10, Page number 237"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in area is 0.0063 sq m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "R=0.1;     #radius(m)\n",
    "c=1;       #assume\n",
    "v=0.6*c;   #velocity\n",
    "\n",
    "#Calculation\n",
    "A=math.pi*R**2;      #area(sq m)\n",
    "R1=R*math.sqrt(1-(v**2/c**2));    \n",
    "A1=math.pi*R*R1;     #plate area in ellipse shape(sq m)  \n",
    "deltaA=A-A1;         #change in area(sq m)\n",
    "\n",
    "#Result\n",
    "print \"change in area is\",round(deltaA,4),\"sq m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 11, Page number 238"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in length is 28.0 cm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "c=1;           #assume\n",
    "v=0.8*c;       #velocity\n",
    "theta=30*math.pi/180;     #angle(rad)\n",
    "L=1;           #length(m)\n",
    "\n",
    "#Calculation\n",
    "Ix=L*math.cos(theta)*math.sqrt(1-(v**2/c**2));\n",
    "Iy=L*math.sin(theta);\n",
    "L1=math.sqrt((Ix**2)+(Iy**2));       #changed length(m)\n",
    "delta_L=L-L1;                        #change in length(m)\n",
    "\n",
    "#Result\n",
    "print \"change in length is\",round(delta_L*100),\"cm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 12, Page number 238"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of bacteria grown is 16\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "delta_t=10;      #time(days)\n",
    "c=1;             #assume\n",
    "v=0.99*c;        #velocity\n",
    "d=280;           #number of days  \n",
    "\n",
    "#Calculation\n",
    "delta_t1=delta_t/math.sqrt(1-(v**2/c**2));     #decay time(days)\n",
    "x=d/int(delta_t1);                             #number of folds\n",
    "n=1*2**x;                                      #number of bacteria grown \n",
    "\n",
    "#Result\n",
    "print \"number of bacteria grown is\",int(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 13, Page number 239"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "relative velocity of B w.r.t A is 0.538 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "c=1;          #assume\n",
    "u1=c/3;       #velocity\n",
    "v=c/4;        #velocity\n",
    "\n",
    "#Calculation\n",
    "u=(u1+v)/(1+(u1*v/c**2));     #relative velocity of B w.r.t A(c)\n",
    "\n",
    "#Result\n",
    "print \"relative velocity of B w.r.t A is\",round(u,3),\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 14, Page number 239"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "relative velocity is 0.9286 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "c=1;          #assume\n",
    "u1=0.8*c;       #velocity\n",
    "v=0.5*c;        #velocity\n",
    "\n",
    "#Calculation\n",
    "u=(u1+v)/(1+(u1*v/c**2));     #relative velocity(c)\n",
    "\n",
    "#Result\n",
    "print \"relative velocity is\",round(u,4),\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 16, Page number 239"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity is 0.866 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=1;        #assume\n",
    "m=2*m0;\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(1-(m0/m)**2);      #velocity(c)\n",
    "\n",
    "#Result\n",
    "print \"velocity is\",round(v,3),\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 17, Page number 240"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity is 0.9428 c\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=1;        #assume\n",
    "m=3*m0;\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(1-(m0/m)**2);      #velocity(c)\n",
    "\n",
    "#Result\n",
    "print \"velocity is\",round(v,4),\"c\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 19, Page number 240"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rest energy is 9 *10**17 J\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=10;        #mass(kg)\n",
    "c=3*10**8;    #velocity of light(m/s)\n",
    "\n",
    "#Calculation\n",
    "E=m0*c**2;    #rest energy(J)\n",
    "\n",
    "#Result\n",
    "print \"rest energy is\",int(E/10**17),\"*10**17 J\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 20, Page number 240"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "kinetic energy is 0.1266 MeV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=9*10**-31;          #mass of electron(g)\n",
    "c=3*10**8;             #velocity of light(m/sec) \n",
    "v=0.6*c;              #velocity of electron(m/sec)\n",
    "e=1.6*10**-19;         #conversion factor\n",
    "\n",
    "#Calculation\n",
    "KE=m0*c**2*((1/math.sqrt(1-(v**2/c**2)))-1);         #kinetic energy(J)\n",
    "KE=KE/e;               #kinetic energy(eV)       \n",
    "\n",
    "#Result\n",
    "print \"kinetic energy is\",round(KE/10**6,4),\"MeV\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 21, Page number 241"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss in mass is 1.8667 *10**-13 kg\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m=50;         #mass(gm)\n",
    "L=80*4.2;     #latent heat(cal/gm)\n",
    "c=3*10**8;    #velocity of light(m/sec)\n",
    "\n",
    "#Calculation\n",
    "Q=m*L;             #heat loss(J)\n",
    "delta_m=Q/c**2;    #loss in mass(kg)\n",
    "\n",
    "#Result\n",
    "print \"loss in mass is\",round(delta_m*10**13,4),\"*10**-13 kg\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 22, Page number 241"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "frequency of photon is 1.237 *10**20 Hz\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=9.1*10**-31;          #mass of photon(g)\n",
    "c=3*10**8;               #velocity of light(m/sec) \n",
    "h=6.62*10**-34;          #planck's constant(Jsec)\n",
    "\n",
    "#Calculation\n",
    "new=m0*c**2/h;           #frequency of photon(Hz)\n",
    "\n",
    "#Result\n",
    "print \"frequency of photon is\",round(new/10**20,3),\"*10**20 Hz\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 23, Page number 241"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "kinetic energy of electron is 0.506 MeV\n",
      "kinetic energy of positron is 0.394 MeV\n",
      "answer for kinetic energy of positron given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "m0=9*10**-31;          #mass of photon(g)\n",
    "c=3*10**8;             #velocity of light(m/sec) \n",
    "e=1.6*10**-19;         #conversion factor\n",
    "E=1.8;                 #energy(MeV)\n",
    "\n",
    "#Calculation\n",
    "E0=m0*c**2/(e*10**6);  #kinetic energy of electron(MeV) \n",
    "k=(E/2)-E0;            #kinetic energy of positron(MeV) \n",
    "\n",
    "#Result\n",
    "print \"kinetic energy of electron is\",round(E0,3),\"MeV\"\n",
    "print \"kinetic energy of positron is\",round(k,3),\"MeV\"\n",
    "print \"answer for kinetic energy of positron given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 24, Page number 242"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "binding energy is 106.9 MeV\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Z=7;       #atomic number of nitrogen\n",
    "N=7;       \n",
    "mp=1.0086;   #mass of proton(amu)\n",
    "mn=1.0078;   #mass of nucleus(amu)\n",
    "amu=931.5;   #energy(MeV)\n",
    "A=14;    #atomic mass \n",
    "\n",
    "#Calculation\n",
    "EB=((Z*mp)+(N*mn)-A)*amu;     #binding energy(MeV)\n",
    "\n",
    "#Result\n",
    "print \"binding energy is\",round(EB,1),\"MeV\""
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
