from __future__ import division
from math import sqrt
Tp=3 #proper time in sec
c=3*10**8 #velocity of light in m/sec
v=0.95*c
gamma=1/sqrt(1-(v**2/c**2))
T=gamma*Tp
print "Period of the pendulum w.r.t to observer = %.2f "%T
from math import sqrt
Lp=120 # length of space ship in meters
c=3*10**8 #velocity of light in m/sec
v=0.99*c
gamma=1/sqrt(1-(v**2/c**2))
L=Lp/gamma
print "Length of spaceship measured by moving observer = %0.2f meters"%L
from math import sqrt
Lp=435 # length of space ship in meters
c=3*10**8 #velocity of light in m/sec
v=0.970*c
gamma=1/sqrt(1-(v**2/c**2))
L=Lp/gamma
print "Distance from spaceship to the groung measured by an observer in spaceship = %0.2f meters"%L
from math import sqrt
c=3*10**8 #velocity of light in m/sec
#when the spaceship is at rest
x=52 # diatance in x direction in meters
y=25 #measurement in y direction
v=0.95*c
#when the spaceship moves to an observer at rest only x dimension looks contracted
gamma=1/sqrt(1-(v**2/c**2))
L=x/gamma
print "The observer sees the horizontal dimension of the spaceship gets contracted to a length of %0.2f meters"%L
from math import sqrt
c=3*10**8 #velocity of light in m/sec
m=9.11*10**-31 #mass of electron in kg
v=0.75*c
gamma=1/sqrt(1-(v**2/c**2))
#relativistic momentum
p=m*v*gamma
print "relativistic momentum = %0.2e kg.m/s"%p
#classical approach
P=m*v
print "classical momentum = %0.2e kg.m/s"%P
Z=(p-P)*100/P
print "the relativistic result is %d percent greater than classical result"%Z
c=3*10**8 #velocity of light in m/sec
Vmo=0.80*c # velocity of motocycle w.r.t stationary observer
Vlm=c # velocity of motocycle w.r.t motorcycle
#velocity of light w.r.t stationary observer
Vlo=(Vlm+Vmo)/(1+(Vlm*Vmo)/c**2)
print "velocity of light w.r.t stationary observer = %0.2e m/sec"%Vlo
c=3*10**8 #velocity of light in m/sec
m=0.50 #mass of baseball in kg
E=m*c**2
print "The energy equivalent of baseball = %0.2e joules"%E
c=3*10**8 #velocity of light in m/sec
m=0.511 #rest energy of electron in Mev
v=0.85*c
gamma=1/sqrt(1-(v**2/c**2))
E=(m)*gamma
print "total energy of an electron = %0.2f Mev"%E
K=E-m
print "Kinetic energy of electron = %0.2f Mev"%K
m_n=1.008665 #mass of neutron in amu
m_U=235.043924 #atomic mass of uranium in amu
m_Ba=140.903496 #atomic mass of barium in amu
m_Kr=91.907720 #atomic mass of krypton in amu
c=3*10**8 # velocity of light in m/s
#a) Kinetic energy released in fission of uranium
KE_final_=((m_n+m_U)-(m_Ba+m_Kr+(3*m_n)))*c**2
#1 amu = 931.494 Mev/c**2
KE_final=KE_final_*931.494/c**2
print "a) Kinetic energy released in fission = %0.2f Mev"%KE_final
#b) velocities of barium and krypton
#E=mc2/sqrt(1-v2/c2)
KE_Ba=KE_final
m_Ba_=m_Ba*931.494/c**2 # mass of barium in Mev
E_Ba=KE_Ba+m_Ba_*c**2
V_Ba=(sqrt(1-(((m_Ba_*c**2)**2)/E_Ba**2)))*c
print " Speed of Barium fragment = %0.2e Mev"%V_Ba
KE_Kr=KE_final
m_Kr_=m_Kr*931.494/c**2 # mass of krypton in Mev
E_Kr=KE_Kr+m_Kr_*c**2
V_Kr=(sqrt(1-((m_Kr_*c**2)**2)/E_Kr**2))*c
print " Speed of krypton fragment = %0.2e Mev"%V_Kr
#The difference in answer is because of round off