{
 "metadata": {
  "name": "Chapter2",
  "signature": "sha256:be87f6a340484dd1a4e5b8f9343e232694681e2bed2590e22d8288691c17dddf"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2:The Special Theory of Relativity"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1, Page 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of varible\n",
      "v1=60.0; v2=40.0      #Velocities of cars wrt to observer in km/hr\n",
      "\n",
      "#calculation\n",
      "vr=v1-v2;         #relative velocity\n",
      "\n",
      "#result\n",
      "print\"The value of relative velocity in km/h. is\",round(vr,3);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of relative velocity in km/h. is 20.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2, Page 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import atan, pi\n",
      "import numpy as np\n",
      "Va_w=[320.0,0.0]; Vw_g=[0.0, 65.0];            #Vp/q=[X Y]=>velocity of object p wrt q along X(east) and Y(north) directions.\n",
      "\n",
      "#calculation\n",
      "Va_g=Va_w + Vw_g;                    #net velocity\n",
      "k=np.linalg.norm(Va_g)                       #magnitude\n",
      "s=atan(Va_g[3]/Va_g[0])*180.0/pi;    #angle in rad*180/pi for conversion to degrees\n",
      "\n",
      "#result\n",
      "print \"the velocity in x direction in Km/h is\", Va_w[0],\"in y direction in km/h is\",Vw_g[1]\n",
      "print\"The magnitude of velocity Va/g(airplane wrt ground) in Km/h is\",round(k,3),\" at \",round(s,3),\" degrees north of east.\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The magnitude of velocity Va/g(airplane wrt ground) in Km/h is 326.535  at  11.482  degrees north of east.\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4, Page 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "Lo=100.0*(10**3);c=3.0*(10**8); #Given values//all the quantities are converted to SI units \n",
      "d=2.2*(10**-6);      #time between its birth and decay\n",
      "\n",
      "#calculation\n",
      "t=Lo/c             #where Lo is the distance from top of atmosphere to the Earth. c is the velocity of light. t is the time taken\n",
      "u=sqrt(1-((d/t)**2));   # using time dilation fromula for finding u where u is the minimum velocity in terms of c;\n",
      "\n",
      "#result\n",
      "print\"Hence the minimum speed required in c is\",round(u,6);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hence the minimum speed required in c is 0.999978\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5, Page 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#intiation of variable\n",
      "from math import sqrt\n",
      "Lo=100.0*(10**3);  #Lo is converted to Km\n",
      "u=0.999978;      #//u/c is taken as u since u is represented in terms of c. \n",
      "\n",
      "#calculation\n",
      "L=Lo*(sqrt(1-u**2)); # from the length contraction formula\n",
      "\n",
      "#result\n",
      "print\"Hence the apparent thickness of the Earth's surface in metres. is\",round(L,3)\n",
      "print\"answer is slightly different in the book\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hence the apparent thickness of the Earth's surface in metres. is 663.321\n",
        "answer is slightly different in the book\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6, Page 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "L=65.0; c=3*10**8;u=0.8*c;      \n",
      "\n",
      "#calculation\n",
      "t=L/u ;          #The value of time taken as measured by the observer\n",
      "\n",
      "#result\n",
      "print\"The time for rocket to pass a point as measured by O in musec is \",round(t*10**6,3);         #The value of time taken as measured by the observer\n",
      "\n",
      "#partb\n",
      "Do=65.0;                             #given length\n",
      "Lo= L/sqrt(1-(u/c)**2);                 #contracted length of rocket\n",
      "\n",
      "#result\n",
      "print\"Actual length according to O is \",round(Lo,3);\n",
      "\n",
      "#partc\n",
      "D=Do*(sqrt(1-(u/c)**2));       #contracted length of platform.\n",
      "\n",
      "#result\n",
      "print\"Contracted length according to O'' is\",round(D,3);\n",
      "\n",
      "#partd\n",
      "t1=Lo/u;                    #time needed to pass according to O'.\n",
      "print \"Time taken according to O is \",t1\n",
      "\n",
      "#part 3\n",
      "t2=(Lo-D)/u;                   #time intervals between the two instances\n",
      "print\"Time taken according to O'' is \",t2;\n",
      "print'The value of t1 and t2 does not match with textbook exactly';"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time for rocket to pass a point as measured by O in musec is  0.271\n",
        "Actual length according to O is  108.333\n",
        "Contracted length according to O'' is 39.0\n",
        "Time taken according to O is  4.51388888889e-07\n",
        "Time taken according to O'' is  2.88888888889e-07\n",
        "The value of t1 and t2 did not match\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7, Page 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "v1=0.6; u=0.8; c=1.0; # all the values are measured in terms of c hence c=1\n",
      "\n",
      "#calculation\n",
      "v= (v1+u)/(1+(v1*u/c**2));\n",
      "\n",
      "#result\n",
      "print \"The speed of missile as measured by an observer on earth in c is\",round(v,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of missile as measured by an observer on earth in c is 0.946\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8, Page 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "w1=600.0;w2=434.0;  # w1=recorded wavelength;w2=actual wavelength\n",
      "               # c/w1 = c/w2 *(sqrt(1-u/c)/(1+u/c))\n",
      "    \n",
      "#calculation\n",
      "k=w2/w1;\n",
      "x=(1-k**2)/(1+k**2);         #solving for u/c\n",
      "\n",
      "#result\n",
      "print\"The speed of galaxy wrt earth in c is\",round(x,3);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of galaxy wrt earth in c is 0.313\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9, Page 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "v1x=0.6;v1y=0.0;v2x=0.0;v2y=.8;c=1.0;     # all the velocities are taken wrt c\n",
      "v21x=(v2x-v1x)/(1-(v1x*v2x/c**2));   #using lorentz velocity transformation\n",
      "v21y=(v2y*(sqrt(1-(v1x*c)**2)/c**2))/(1-v1y*v2y/c**2) \n",
      "\n",
      "#result\n",
      "print\"The velocity of rocket 2 wrt rocket 1 along x and y directions is\",round(v21x,3),\" c &\", round(v21y,3),\"c respectively\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of rocket 2 wrt rocket 1 along x and y directions is -0.6  c & 0.64 c respectively\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10, Page 40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "u=0.8*c;L=65.0;c=3.0*10**8;            #all values are in terms of c\n",
      "t=u*L/(c**2*(sqrt(1-((u/c)**2))));  #from the equation 2.31 \n",
      "\n",
      "#result\n",
      "print\"The time interval between the events is\",t, \"sec which equals\",round(t*10**6,3),\"musec.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The time interval between the events is 2.88888888889e-07 sec which equals 0.289 musec.\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11, Page 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "m=1.67*10**-27;c= 3*10**8;v=0.86*c;      #all the given values and constants\n",
      "\n",
      "#calculation\n",
      "p=m*v/(sqrt(1-((v/c)**2)));            # in terms of Kgm/sec\n",
      "\n",
      "#result\n",
      "print\"The value of momentum was found out to be in Kg-m/sec.\\n\",p;\n",
      "\n",
      "#part 2\n",
      "c=938.0;v=0.86*c;mc2=938.0                 # all the energies in MeV where mc2= value of m*c^2\n",
      "pc=(mc2*(v/c))/(sqrt(1-((v/c)**2)));    #expressing in terms of Mev\n",
      "\n",
      "#result\n",
      "print\"The value of momentum was found out to be in Mev.\",round(pc,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of momentum was found out to be in Kg-m/sec.\n",
        "8.44336739668e-19\n",
        "The value of momentum was found out to be in Mev. 1580.814\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.12, Page 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "pc=1580.0; mc2=938.0;E0=938.0;    # all the energies in MeV mc2=m*c^2 and pc=p*c\n",
      "\n",
      "#result\n",
      "E=sqrt(pc**2+mc2**2); \n",
      "K=E-E0;                      #value of possible kinetic energy\n",
      "\n",
      "#result\n",
      "print\"The relativistic total energy in MeV. is\",round(E,3);         #value of Energy E\n",
      "print\"The kinetic energy of the proton in MeV.\",round(K,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The relativistic total energy in MeV. is 1837.456\n",
        "The kinetic energy of the proton in MeV. 899.456\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.13, Page 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "E=10.51; mc2=0.511; #all the values are in MeV\n",
      "\n",
      "#calculation\n",
      "p=sqrt(E**2-mc2**2);   #momentum of the electron\n",
      "v=sqrt(1-(mc2/E)**2);  #velocity in terms of c\n",
      "\n",
      "#result\n",
      "print\"The momentum of electron in MeV/c is\",round(p,3); \n",
      "print\"The velocity of electron in c is\",round(v,5);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The momentum of electron in MeV/c is 10.498\n",
        "The velocity of electron in c is 0.99882\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.14, Page 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "k=50;mc2=0.511*10**-3;c=3.0*10**8; # all the values of energy are in GeV and c is in SI units\n",
      "\n",
      "#calculation\n",
      "v=sqrt(1-(1/(1+(k/mc2))**2));   #speed of the electron in terms of c\n",
      "k=c-(v*c);                       #difference in velocities\n",
      "\n",
      "#result\n",
      "print\"Speed of the electron as a fraction of c*10^-12 is.\",round(v*10**12,3); # v=(v*10^12)*10^-12; so as to obtain desired accuracy in the result\n",
      "print\"The difference in velocities in cm/s.\",round(k*10**2,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Speed of the electron as a  fraction of c*10^-12 is. 9.99999999948e+11\n",
        "The difference in velocities in cm/s. 1.567\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.15, Page 48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt, pi\n",
      "r=1.5*10**11; I=1.4*10**3;     #radius and intensity of sun\n",
      "\n",
      "#calculation\n",
      "s=4*pi*r**2                 #surface area of the sun\n",
      "Pr=s*I                     # Power radiated in J/sec\n",
      "c=3.0*10**8;                #velocity of light\n",
      "m=Pr/c**2                  #rate of decrease of mass\n",
      "m=round(m,2)\n",
      "\n",
      "#result\n",
      "print\"The rate of decrease in mass of the sun in kg/sec. is %.1e\" %m;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rate of decrease in mass of the sun in kg/sec. is 4.4e+09\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.16, Page 48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import pi, sqrt\n",
      "K=325; mkc2=498;  #kinetic energy and rest mass energy of kaons\n",
      "mpic=140.0; #given value\n",
      "\n",
      "#calculation\n",
      "Ek=K+mkc2; \n",
      "pkc=sqrt(Ek**2-mkc2**2); \n",
      "#consider the law of conservation of energy which yields Ek=sqrt(p1c^2+mpic^2)+sqrt(p2c^2+mpic^2)\n",
      "#The above equations (4th degree,hence no direct methods)can be solved by assuming the value of p2c=0.\n",
      "p1c=sqrt(Ek**2-(2*mpic*Ek));\n",
      "#consider the law of conservation of momentum. which gives p1c+p2c=pkc implies\n",
      "p2c=pkc-p1c;\n",
      "k1=(sqrt(p1c**2+(mpic**2))-mpic); #corresponding kinetic energies\n",
      "k2=(sqrt((p2c**2)+(mpic**2))-mpic);\n",
      "\n",
      "#result\n",
      "print\"The corresponding kinetic energies of the pions are\", k1,\" MeV and\",round(k2,3),\" MeV.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The corresponding kinetic energies of the pions are 543.0  MeV and 0.627  MeV.\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.17, Page 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initiation of variable\n",
      "from math import sqrt\n",
      "mpc2=938.0;c=3.0*10**8;  #mpc2=mp*c^2,mp=mass of proton\n",
      "\n",
      "#calculation\n",
      "Et=4*mpc2;          #final total energy\n",
      "E1=Et/2;E2=E1;       #applying conservation of momentum and energy\n",
      "v2=c*sqrt(1-(mpc2/E1)**2);    #lorentz transformation\n",
      "u=v2;v=(v2+u)/(1+(u*v2/c**2)); \n",
      "E=mpc2/(sqrt(1-(v/c)**2));\n",
      "K=E-mpc2;\n",
      "\n",
      "#result\n",
      "print\"The threshold kinetic energy in Gev\",round(K/10**3,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The threshold kinetic energy in Gev 5.628\n"
       ]
      }
     ],
     "prompt_number": 50
    }
   ],
   "metadata": {}
  }
 ]
}