{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 26 : Relativity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example1 Page No: 855"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Period of the pendulum w.r.t to observer = 9.61 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt\n",
    "Tp=3 #proper time in sec\n",
    "c=3*10**8 #velocity of light in m/sec\n",
    "v=0.95*c\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "T=gamma*Tp\n",
    "print \"Period of the pendulum w.r.t to observer = %.2f \"%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example2 Page No: 857"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Length of spaceship measured by moving observer = 16.93 meters\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "Lp=120 # length of space ship in meters\n",
    "c=3*10**8 #velocity of light in m/sec\n",
    "v=0.99*c\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "L=Lp/gamma\n",
    "print \"Length of spaceship measured by moving observer = %0.2f meters\"%L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example3 Page No: 859"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Distance from spaceship to the groung measured by an observer in spaceship = 105.75 meters\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "Lp=435 # length of space ship in meters\n",
    "c=3*10**8 #velocity of light in m/sec\n",
    "v=0.970*c\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "L=Lp/gamma\n",
    "print \"Distance from spaceship to the groung measured by an observer in spaceship = %0.2f meters\"%L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example4 Page No: 861"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The observer sees the horizontal dimension of the spaceship gets contracted to a length of 16.24 meters\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "c=3*10**8 #velocity of light in m/sec\n",
    "#when the spaceship is at rest\n",
    "x=52 # diatance in x direction  in meters\n",
    "y=25 #measurement in y direction\n",
    "v=0.95*c\n",
    "#when the spaceship moves to an observer at rest only x dimension looks contracted\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "L=x/gamma\n",
    "print \"The observer sees the horizontal dimension of the spaceship gets contracted to a length of %0.2f meters\"%L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example5 Page No: 862"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "relativistic momentum = 3.10e-22 kg.m/s\n",
      "classical momentum = 2.05e-22 kg.m/s\n",
      "the relativistic result is 51 percent greater than classical result\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "c=3*10**8 #velocity of light in m/sec\n",
    "m=9.11*10**-31 #mass of electron in kg\n",
    "v=0.75*c\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "#relativistic momentum\n",
    "p=m*v*gamma\n",
    "print \"relativistic momentum = %0.2e kg.m/s\"%p\n",
    "#classical approach\n",
    "P=m*v\n",
    "print \"classical momentum = %0.2e kg.m/s\"%P\n",
    "Z=(p-P)*100/P\n",
    "print \"the relativistic result is %d percent greater than classical result\"%Z"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example6 Page No: 864"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "velocity of light w.r.t stationary observer = 3.00e+08 m/sec\n"
     ]
    }
   ],
   "source": [
    "c=3*10**8 #velocity of light in m/sec\n",
    "Vmo=0.80*c # velocity of motocycle w.r.t stationary observer \n",
    "Vlm=c # velocity of motocycle w.r.t motorcycle\n",
    "#velocity of light w.r.t stationary observer \n",
    "Vlo=(Vlm+Vmo)/(1+(Vlm*Vmo)/c**2)\n",
    "print \"velocity of light w.r.t stationary observer = %0.2e m/sec\"%Vlo"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example7 Page No: 865"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The energy equivalent of baseball = 4.50e+16 joules\n"
     ]
    }
   ],
   "source": [
    "c=3*10**8 #velocity of light in m/sec\n",
    "m=0.50 #mass of baseball in kg\n",
    "E=m*c**2\n",
    "print \"The energy equivalent of baseball = %0.2e joules\"%E"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 Page No: 866"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total energy of an electron = 0.97 Mev\n",
      "Kinetic energy of electron = 0.46 Mev\n"
     ]
    }
   ],
   "source": [
    "c=3*10**8 #velocity of light in m/sec\n",
    "m=0.511 #rest energy of electron in Mev\n",
    "v=0.85*c\n",
    "gamma=1/sqrt(1-(v**2/c**2))\n",
    "E=(m)*gamma\n",
    "print \"total energy of an electron = %0.2f Mev\"%E\n",
    "K=E-m\n",
    "print \"Kinetic energy of electron = %0.2f Mev\"%K"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9 Page No: 867"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a) Kinetic energy released in fission = 200.62 Mev\n",
      " Speed of Barium fragment = 1.66e+07 Mev\n",
      " Speed of krypton fragment = 2.05e+07 Mev\n"
     ]
    }
   ],
   "source": [
    "m_n=1.008665 #mass of neutron in amu\n",
    "m_U=235.043924 #atomic mass of uranium in amu\n",
    "m_Ba=140.903496 #atomic mass of barium in amu\n",
    "m_Kr=91.907720 #atomic mass of krypton in amu\n",
    "c=3*10**8 # velocity of light in m/s\n",
    "#a) Kinetic energy released in fission of uranium\n",
    "KE_final_=((m_n+m_U)-(m_Ba+m_Kr+(3*m_n)))*c**2\n",
    "#1 amu = 931.494 Mev/c**2\n",
    "KE_final=KE_final_*931.494/c**2\n",
    "print \"a) Kinetic energy released in fission = %0.2f Mev\"%KE_final\n",
    "#b) velocities of barium and krypton\n",
    "#E=mc2/sqrt(1-v2/c2)\n",
    "KE_Ba=KE_final\n",
    "m_Ba_=m_Ba*931.494/c**2 # mass of barium in Mev\n",
    "E_Ba=KE_Ba+m_Ba_*c**2\n",
    "V_Ba=(sqrt(1-(((m_Ba_*c**2)**2)/E_Ba**2)))*c\n",
    "print \" Speed of Barium fragment = %0.2e Mev\"%V_Ba\n",
    "KE_Kr=KE_final\n",
    "m_Kr_=m_Kr*931.494/c**2 # mass of krypton in Mev\n",
    "E_Kr=KE_Kr+m_Kr_*c**2\n",
    "V_Kr=(sqrt(1-((m_Kr_*c**2)**2)/E_Kr**2))*c\n",
    "print \" Speed of krypton fragment = %0.2e Mev\"%V_Kr\n",
    "#The difference in answer is because of round off"
   ]
  }
 ],
 "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
}
