{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1:Relativity"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1,Page no:9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Varible declaration\n",
      "t0= 3600  # time interval on Earth, seconds\n",
      "t= 3601.0  #time interval for spacecraft as measured from Earth, seconds\n",
      "\n",
      "#Calculation\n",
      "c= 2.998 *(10**8)  #speed of light, m/s\n",
      "v=c*math.sqrt((1-((t0/t)**2)))  #relative velocity of spacecraft, m/s\n",
      "\n",
      "#Result\n",
      "print\"The speed of the Spacecraft relative to Earth is:%.2g \"%v,\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The speed of the Spacecraft relative to Earth is:7.1e+06  m/s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2,Page no:13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varible declaration\t\n",
      "fg= 5.6*(10**14)  #frequency of green color, Hz\n",
      "fr= 4.8*(10**14)  #frequency of red color, Hz\n",
      "c= 3.0*(10**8)  #velocity of light, m/s\n",
      "\n",
      "#Calculation\n",
      "v= c*((fg**2 - fr**2)/(fg**2 + fr**2))  #longitudinal speed of observer, m/s\n",
      "v= v*3.6  #convert to km/h\n",
      "R= 1.0  #rate at which fine is to be imposed per km/h, $\n",
      "l= 80.0  #speed limit upto which no fine is to be imposed, km/h\n",
      "fine= v-l  # fine to be imposed,  $\n",
      "\n",
      "#Result\n",
      "print\"The fine imposed is:\",fine,\"$\\n\"\n",
      "\n",
      "print\"NOTE:Approx value of v is taken in book as 1.65*10^8,which is very less precise.\\nTherefore,chnge in final answer\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fine imposed is: 165176390.588 $\n",
        "\n",
        "NOTE:Approx value of v is taken in book as 1.65*10^8,which is very less precise.\n",
        "Therefore,chnge in final answer\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3,Page no:14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Varible declaration\n",
      "v= 6.12*(10**7)  #receding velocity with respect to Earth, m/s\n",
      "c= 3.0*(10**8)  #velocity of light, m/s\n",
      "L0= 500.0  #initial wavelength of spectral line, nm\n",
      "\n",
      "#Calculation\n",
      "L= L0*math.sqrt(((1+(v/c))/(1-(v/c))))  #final wavelength of spectral light, nm\n",
      "Ls= L-L0  #shift in wavelength, nm\n",
      "\n",
      "#Varible declaration\n",
      "print\"Shift in Green spectral line is: \",round(Ls),\"nm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Shift in Green spectral line is:  115.0 nm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4,Page no:19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Varible declaration\n",
      "StartingAge= 20  #starting age for both Dick and Jane\n",
      "c= 3*(10**8)  #velocity of light, m/s\n",
      "v= 0.8*c  #rate of separation of Dick and Jane, m/s\n",
      "t0= 1  #interval for emission of signals, yr\n",
      "\n",
      "#Calculation\n",
      "t1= t0*((1+v/c)/(1-v/c))  #interval for reception of signals on outward journey, yr\n",
      "t1= t0*(math.sqrt((1+v/c)/(1-v/c)))  #interval for reception of signals on outward journey, yr\n",
      "t2= t0*(math.sqrt((1-v/c)/(1+v/c)))  #interval for reception of signals on return trip, yr\n",
      "#Dick's frame of reference\n",
      "Tout1= 15  #duration of outward trip, yr\n",
      "Tin1= 15  #duration of return trip, yr\n",
      "JaneAge= StartingAge+(Tout1/t1)+(Tin1/t2)  #Jane's age according to Dick\n",
      "#Jane's frame of reference\n",
      "Tout2= 25  #duration of outward trip, yr\n",
      "d= 20  #delay in transmission of signal to Jane, caused by distance of the star, yr\n",
      "Tin2= 5  #duration of return trip\n",
      "DickAge= StartingAge+((Tout2+d)/t1)+(Tin2/t2)  #Dick's age according to JAne\n",
      "\n",
      "#Result\n",
      "print\"According to Dick, age of Jane is:\",JaneAge,\"years\"\n",
      "print\"According to Jane, age of Dick is:\",DickAge,\"years\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "According to Dick, age of Jane is: 70.0 years\n",
        "According to Jane, age of Dick is: 50.0 years\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6,Page no:27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Varible declaration\n",
      "mf= 1  #mass of each entity, kg\n",
      "c= 3*(10**8)  #velocity of light, m/s\n",
      "v= 0.6*c  #velocity of fragments relative to original body, m/s\n",
      "\n",
      "#Calculation\n",
      "E0= 2*((mf*(c**2))/math.sqrt(1-((v/c)**2)))  #Total energy of fragments\n",
      "m= E0/(c**2)  #mass of original body, kg\n",
      "\n",
      "#Result\n",
      "print\"The total mass of the stationary body is: \",m,\"kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The total mass of the stationary body is:  2.5 kg\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7,Page no:28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Varible declaration\n",
      "r=1.4  # Rate of arrival of Solar Energy at erath, kW per square meter\n",
      "R=1.5*(10**11)  #Radius of Earth, m\n",
      "\n",
      "#Calculation\n",
      "P=r*(4*math.pi*(R**2))  #Total power recieved by Earth, kW\n",
      "P= P*(10**3)  #W\n",
      "C= 3*(10**8)  #Velocity of light, m/s\n",
      "E=P  #Energy lost by Sun, J\n",
      "m= E/(C**2)  #Mass of Sun lost per second as energy, kg\n",
      "\n",
      "#Result\n",
      "print\"Mass lost by sun per second, is:%.2g\"%m,\"kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass lost by sun per second, is:4.4e+09 kg\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8,Page no:32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Varible declaration\n",
      "c= 3*(10**8)  #Velocity of light, m/s\n",
      "me= 0.511/(c**2)  #mass of electron, MeV\n",
      "mp=0  #mass of proton, MeV\n",
      "p= 2.000/c  #momenta for both particles, MeV\n",
      " \n",
      "#Calculation    \n",
      "##Using Eq. 1.24 and 1.25, Page 31 \n",
      "Ee=math.sqrt(((me**2)*(c**4))+((p**2)*(c**2)))  #Total energy of electron, MeV\n",
      "Ep= p*c  #Total energy of proton, MeV\n",
      "\n",
      "#Result\n",
      "print\"Total energy of Electron is: \",round(Ee,3),\"MeV\"\n",
      "print\"Total energy of Photon is: \",Ep,\"MeV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total energy of Electron is:  2.064 MeV\n",
        "Total energy of Photon is:  2.0 MeV\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11,Page no:44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Varible declaration \n",
      "c=3*(10**8)  #velocity of light, m/s\n",
      "VaE= 0.90*c  #velocity of spacecraft alpha w.r.t Earth, m/s\n",
      "VbA= 0.50*c  #velocity of spacecraft beta w.r.t. Alpha, m/s\n",
      "\n",
      "#Calculation\n",
      "VbE= (VaE+VbA)/(1+((VaE*VbA)/(c**2)))  #velocity of beta w.r.t Earth, m/s\n",
      "VbE=VbE/c  #Converting to percent of c\n",
      "\n",
      "#Result\n",
      "print\"The required velocity of spacecraft Beta w.r.t. Earth  is:\",round(VbE,2),\"c\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required velocity of spacecraft Beta w.r.t. Earth  is: 0.97 c\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}