# example 1
import math
#to calculate length of the bar measured by the ststionary observer
lo =1 #length in metre
v=0.75*3*10**8 #speed (m/s)
c=3*10**8 #light speed(m/s)
l=lo*math.sqrt(1-(v**2/c**2))
print "\n the length of bar in is",round(l,2),"m"
# example 2
import math
#to calculate velocity of rocket
#lo be the length at rest
l=99.0/100 #length is 99 per cent of its length at rest is l=(99/100)lo
c=3*10**8 #light speed(m/s)
v=c*math.sqrt(1-l**2) #formula is v=c math.sqrt(1-(l/lo)**2)
print"\n velocity of rocket is v=","{:.2e}".format(v),"m/s"
import math
#to percentage contraction of a rod
c=3*10**8 #light speed(m/s)
v=0.8*c #velocity(m/s)
#let lo be the length of the rod in the frame in which it is at rest
#s' is the frame which is moving with a speed 0.8c in a direction making an angle 60 with x-axis
#components of lo along perpendicular to the direction of motion are lo cos60 and lo sin60 respectively
l1=math.cos(math.pi/3)*math.sqrt(1-(v/c)**2) #length of the rod alond the direction of motion =lo math.cos(pi/3)math.sqrt(1-(v/c)**2)
l2=math.sin(math.pi/3) #length of the rod perpendicular to the direction of motion =lo sin60
l=math.sqrt(l1**2+l2**2) # length of the moving rod
per=(1-l)*100/1
print "percentage contraction of a rod is",round(per,2),"%"
# example 7
import math
#to calculate velocity of the circular lamina
c=3*10**8 #light speed (m/s)
#R'=R/2 (radius)
#R'=R math.sqrt(1-(v/c)**2)
v=(math.sqrt(3)/2)*c
print "velocity of the circular lamina relative to frame s is v=","{:.3e}".format(v),"m/s"
#answer is given in terms of c in the textbook
# example 8
import math
#to calculate speed of the clock
#clock should record l=59 minutes for each hour recorded by clocks stationary with respect to the observer
l=59.0
lo=60
c=3*10**8 #light speed (m/s)
v=math.sqrt(c**2*(1-l**2/lo**2))
print "speed of the clock is =","{:.2e}".format(v),"m/s"
import math
#to calculate distance travelled by the beam
deltat0=2.5*10**-8 #proper half life of pi mesons in (s)
c=3*10**8 #light speed (m/s)
v=0.8*c #mesons velocity (m/s)
deltat=deltat0/math.sqrt(1-(v/c)**2) #half life (s)
#No=initial flux ,N=flux after time t
#N=N0 e**(-t/T)
#N=N0/e**2 (given)=No e(-t/T)
#t=2 deltat
d=2*deltat*v #d=vt
print "distance travelled by the beam is d=",d,"m"
#answer is given in the textbook=19.96 m
import math
#to calculate distance travelled by the particle
deltat0=2*10**-8 #proper half life to of the particle in (s)
c=3*10**8 #light speed (m/s)
v=0.96*c #speed of the particle (m/s)
deltat=(deltat0)/(math.sqrt(1-(v/c)**2)) #half life in the laboratory frame t in (s)
#t=deltat (flux of the beam falls to (1/2) times initial flux)
d=v*deltat #d=vt
print "distance travelled by the particle in this time is d=",round(d,2),"m"
#answer is given wrong in the textbook =20.45 m
import math
#to calculate speed
deltat0=1440 #proper time interval measured by an observer moving with the clock (min)
deltat=1444 #time interval measured by a stationary observer (min)
c=3*10**8 #light speed (m/s)
v=c*math.sqrt(1-(deltat0/deltat)**2)
print " moving clock appears to lose 4min in 24 hours from the stationary observer is v=","{:.1e}".format(v),"m/s"
#answer is given wrong in the book =2.32*10**7 m/s
import math
#to calculate velocity of beta particle
c=3*10**8 #light velocity(m/s)
u1=0.9*c #velocity of the beta particle relative to the atom in the direction of motion
v=0.25*c #velocity of the radioactive atom relative to an experimenter
u=(u1+v)/(1+u1*v/c**2)
print " velocity of the beta particle as observed by the experimenter is u=","{:.2e}".format(u),"m/s"
#answer is given in terms of c in the book =0.94c
import math
#to calculate velocity
c=3*10**8 # light velocity
v=0.75*c #speed of A
ux=-0.85*c #speed of B
ux1=(ux-v)/(1-ux*v/c**2)
print"\n the velocity of B with respect to A (m/s) is","{:.2e}".format(ux1),"m/s"
#answer is given in terms of c in the book=-0.9771c
import math
#to calculate velocity in the laboratory frame
c=3*10**8 #light speed (m/s)
v=0.8*c #velocity relative to laboratory along positive direction of x-axis
#given that u'=3 i+4 j+12 k (m/s)
ux1=3 #in (m/s)
uy1=4 #in (m/s)
uz1=12 #in (m/s)
ux=(ux1+v)/(1+v*ux1/c**2)
uy=(uy1*math.sqrt(1-(v/c)**2))/(1+v*ux1/c**2)
uz=(uz1*math.sqrt(1-(v/c)**2))/(1+v*ux1/c**2)
print "u=ux i+uy j+uz k"
print "where"
print "ux=","{:.1e}".format(ux),"m/s"
print "uy=",round(uy,1),"m/s"
print "uz=",round(uz,1),"m/s"
import math
# to calculate velocity of the particle
c=3*10**8 #light speed (m/s)
v=0.4*c #velocity of frame s' relative to s along axis x
ux=0.8*c*(1/2.0) #component of velocity u(=0.8 c) of the particle along x axis ux=0.8 c cos60
uy=0.8*c*sin (math.pi/3) #component of the velocity u of the particle along y axis
ux1=(ux-v)/(1-ux*v/c**2)
uy1=uy*math.sqrt(1-(v/c)**2)/(1-(ux*v/c**2))
print "resultant velocity as observed by a person in frame s1 is u1=ux1 i+uy1 j"
print "where"
print "ux1=",ux1/c,"m/s"
print "uy1=",round(uy1/c,3),"c m/s"
#answer is given in terms of c in the book i.e. uy1=0.756c m/s
import math
#to calculate mass, momentum,total energy,kinetic energy
c=3*10**8 #light speed (m/s)
v=c/sqrt (2) #velocity (m/s)
#let mo be the rest mass of the particle
#relativistic mass m of the particle is m=mo/math.sqrt(1-(v/c)**2)
m=1/sqrt (1-v**2/c**2) #in kg
print "mass m=",round(m,2)," mo"
#momentum p of the particle is p=mv
p=m*v #in kg-m/s
print "momentum p=","{:.1e}".format(p)," mo"
#total energy E of the particle
E=m*c**2 #in J
print "energy E=","{:.2e}".format(E)," mo"
#kinetic energy K=E-mo c**2
K=E-c**2 #in J
print "kinetic energy K=","{:.2e}".format(K)," mo"
#answer is given in terms of m0 and c in the book
import math
#to calculate velocity of the parcticle
c=3*10**8 #light speed(m/s)
# we know that E(energy)=mc**2
# mo=rest mass
#E=3 moc**2=mc**2 or m=3 mo (given that total energy of the particle is thrice its rest energy)
m=3.0 # relativistic mass
#formula is v=c math.sqrt(1-(mo/m)**2)
v=math.sqrt(c**2*(1-(1/m)**2))
print "velocity of the particle is v=","{:.3e}".format(v),"m/s"
import math
#to calculate mass(m),speed(v) of an electron
K=1.5*10**6*1.6*10**-19 #kinetic energy(J)
m0=9.11*10**-31 #rest mass of an electron(kg)
c=3*10**8 # velocity of light in vacuum(m/s)
m=(K/c**2)+m0 #relativistic kinetic energy(k=(m-mo)c**2)
print "mass is m=","{:.2e}".format(m),"kg "
v=c*math.sqrt(1-m0**2/m**2)
print "speed of an electron is v=","{:.1e}".format(v),"m/s"
import math
#to calculate work to be done
E=0.5*10**6 #rest energy of electron (MeV) E=m0*c**2
v1=0.6*3*10**8 #speed of electron in (m/s)
v2=0.8*3*10**8
c=3*10**8 #speed of light in (m/s)
K1=E*((1/math.sqrt(1-v1**2/c**2))-1) #kinetic energy in (eV)
K2=E*((1/math.sqrt(1-v2**2/c**2))-1)
w=(K2-K1)*1.6*10**-19
print "amount of work to be done is w=","{:.2e}".format(w),"J"
import math
#to calculate speed
c=3*10**8 #light speed (m/s)
m=2.25 #mass m of a body be 2.25 times its rest mass mo i.e. m=2.25m0
#formula is v=c math.sqrt(1-(m0/m)**2)
v=c*math.sqrt(1-(1/m)**2)
print " speed is v=","{:.2e}".format(v),"m/s"
import math
#to calculate speed of the rocket
m0=50 #weight of man on the earth(kg)
m=50.5 #weight of man in rocket ship (kg)
c=3*10**8 #speed of light(m/s)
v=c*math.sqrt(1-m0**2/m**2)
print "speed of the rocket is v=","{:.2e}".format(v),"m/s"
#to calculate speed of electron
m0=9.11*10**-31 #mass of electron =rest mass of proton
m=1.67*10**-27
v=c*math.sqrt(1-m0**2/m**2)
print "speed of an electron is v=","{:.2e}".format(v),"m/s"
import math
#to calculate velocity
c=3*10**8 #light speed (m/s)
#K(kinetic energy)=(m-mo(rest mass))c**2
#it can also be written as mc**2=K+m0c**2
#given that K=2m0c**2(rest mass energy)
#m=3m0
m=3.0 #relativistic mass
#formula is v=c math.sqrt(1-(m0/m)**2)
v=c*math.sqrt(1-(1/m)**2)
print "velocity of a body is v=","{:.3e}".format(v),"m/s"
import math
#to calculate kinetic energy ,momentum of electron
m0=9.11*10**-31 #its rest mass (kg)
c=3*10**8 #light velocity in (m/s)
m=11*m0 #mass of moving electron is 11 times its rest mass
K=(m-m0)*c**2/(1.6*10**-19) # kinetic energy
print "kinetic energy is K=","{:.2e}".format(K),"eV"
v=c*math.sqrt(1-(m0/m)**2) #velocity(m/s)
p=m*v #momentum
print "momentum is p=","{:.2e}".format(p),"kg m/s"
import math
#to calculate proton gain in mass
c=3*10**8 #light speed(m/s)
K=500*10**6*1.6*10**-19 #kinetic energy (J)
deltam=K/c**2
print "proton gain in mass is delm=","{:.2e}".format(deltam),"kg"
#answer is given wrong in the book=8.89*10**28 kg
import math
#to calculate speed of 0.1MeV electron
E=0.512*10**6 #rest mass energy E=m0*c**2
c=3*10**8 #velocity of light (m/s)
K=0.1*10**6 #kinetic energy (MeV)
v=c*math.sqrt(1-(E/(K+E))**2)
print "speed of electron is v=","{:.3e}".format(v),"m/s"
#to calculate mass and speed of 2MeV electron
E=2*10**6*1.6*10**-19 #in (J)
m=E/c**2
print "mass is m=","{:.2e}".format(m),"kg"
m0=9.11*10**-31 #electron mass (kg)
v=c*math.sqrt(1-m0**2/m**2)
print "speed is v=","{:.2e}".format(v),"m/s"