In [3]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
delta_x = 2.45e+03; # Space difference, m
delta_t = 5.35e-06; # Time difference, s
#Calculations
v = 0.855*c; # Speed of frame S_prime, m/s
delta_x_prime = 1/sqrt(1-v**2/c**2)*(delta_x - v*(delta_t))*1e-03; # Distance between two flashes as measured in S_prime frame, km
delta_t_prime = 1/sqrt(1-v**2/c**2)*(delta_t - v/c**2*delta_x)*1e+006; # Time between two flashes as measured in S_prime
#Results
print "The distance between two flashes as measured in S_prime frame = %4.2f km"%delta_x_prime
print "The time between two flashes as measured in S_prime frame = %4.2f micro-second"%delta_t_prime
```

In [8]:

```
from sympy import *
c = Symbol('c')
#Variable declaration
c = 1; # Speed of light in vacuum, m/s
u_x_prime = c; # Velocity of photon as measured in S_prime frame, m/s
v = c; # Velocity of frame S_prime relative to S frame, m/s
#Calculations
u_x = (u_x_prime + v)/(1+v*u_x_prime/c**2);
if u_x == 1:
ux = 'c';
else:
ux = string(u_x)+'c';
#Result
print "The speed of one photon as observed by the other is %c"%ux
```

In [3]:

```
import math
#Variable declaration
a = 1; # For simplicity assume length of semi minor axis to be unity, m
c = 3e+08; # Speed of light, m/s
#Calculations
#From equation 1-v^2/c^2=1/4, we derive the following expression
v = math.sqrt(3*c**2/4) # Velocity at which surface area of lamina reduces to half in S-frame, m/s
print "The velocity at which surface area of lamina reduces to half in S-frame = %4.2e m/s"%v
```

In [13]:

```
#Variable declaration
m0 = 1; # For simplicity assume the rest mass of stick to be unity, kg
m = 1.5*m0; # Mass of the moving stick, kg
L0 = 1; # Assume resting length of the stick to be unity, m
#Calculations
# As m = m0/sqrt(1-v^2/c^2) = m0*gama, solving for gama
gama = m/m0; # Relativistic factor
L = L0/gama; # Contracted length of the metre stick, m
#Result
print "The contracted length of the metre stick = %4.2f m"%L
```

In [14]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
tau0 = 2e-008; # Mean lifetime of meson at rest, m/s
#Calculations
v = 0.8*c; # Velocity of moving meason, m/s
tau = tau0/sqrt(1-v**2/c**2); # Mean lifetime of meson in motion, m/s
#Result
print "The mean lifetime of meson in motion = %4.2e s"%tau
```

In [8]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
delta_t0 = 59; # Reading of the moving clock for each hour, min
delta_t = 60; # Reading of the stationary clock for each hour, min
#Calculations
# As from Time Dilation, delta_t = delta_t0/sqrt(1-v^2/c^2), solving for v
v = sqrt(((delta_t**2-delta_t0**2)*c**2)/delta_t**2)
#Result
print "The speed at which the moving clock ticks slow = %4.2e m/s"%v
```

In [17]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
tau0 = 2.5e-008; # Mean lifetime of meson at rest, m/s
#Calculations
v = 0.8*c; # Velocity of moving meason, m/s
tau = tau0/sqrt(1-v**2/c**2); # Mean lifetime of meson in motion, m/s
N0 = 1; # Assume initial flux of meson beam to be unity, watt/Sq.m
N = N0*exp(-2); # Meson flux after time t, watt/Sq.m
# As N = N0*e^(-t/tau), which on comparing gives
t = 2*tau; # Time during which the meson beam flux reduces, s
d = 0.8*c*t; # The distance that the meson beam can travel before reduction in its flux, m
#Result
print "The distance that the meson beam can travel before reduction in its flux = %2d m"%d
```

In [14]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
E0 = 1; # Rest energy of particle, unit
#Calculations
E = 3*E0; # Energy of relativistically moving particle, unit
# E = m*c^2 and E0 = m0*c^2
# With m = m0/sqrt(1-v^2/c^2), we have
v = c*sqrt(1-(E0/E)**2); # Velocity of the moving particle, m/s
#Result
print "The velocity of the moving particle = %4.2e m/s"%v
#answer differs due to rounding-off errors
```

In [19]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
m0 = 9.1e-031; # Rest mass of electron, kg
#Calculations
m = 11*m0; # Mass of relativistically moving electron, kg
E_k = (m-m0)*c**2/(1.6e-019*1e+06); # Kinetic energy of moving electron, MeV
# As m = m0/sqrt(1-v^2/c^2), solving for v
v = c*sqrt(1-(m0/m)**2); # The velocity of the moving electron, m/s
p = m*v; # Momentum of moving electron, kg-m/s
#Results
print "The kinetic energy of moving electron = %4.2f MeV"%E_k
print "The momentum of moving electron = %4.2e kg-m/s"%p
```

In [20]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, m/s
E0 = 0.5; # Rest energy of the electron, MeV
#Calculations
v1 = 0.6*c; # Initial velocity of the electron, m/s
v2 = 0.8*c; # Final velocity of the electron, m/s
W = (1/sqrt(1-v2**2/c**2)-1/sqrt(1-v1**2/c**2))*E0; # The amount of work to be done to increase the speed of the electron, MeV
#Result
print "The amount of work to be done to increase the speed of an electron = %4.2e J"%(W*1e+06*1.6e-019)
```

In [15]:

```
from math import *
#Variable declaration
c = 1; # Assume speed of light in vacuum to be unity, unit
m0 = 1; # For simplicity assume rest mass of the particle to be unity, unit
#Calculations
v = c/sqrt(2); # Given speed of the particle, m/s
gama = 1/sqrt(1-v**2/c**2); # Relativistic factor
m = gama*m0; # The relativistic mass of the particle, unit
p = m*v; # The relativistic momentum of the particle, unit
E = m*c**2; # The relativistic total eneryg of the particle, unit
E_k = (m-m0)*c**2; # The relativistic kinetic energy of the particle, unit
#Results
print "The relativistic mass of the particle = %5.3fm"%m
print "The relativistic momentum of the particle = %1.0gm0c"%p
print "The relativistic total energy of the particle = %5.3fm0c^2"%E
print "The relativistic kinetic energy of the particle = %5.3fm0c^2"%E_k
```

In [23]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, unit
m0 = 9.1e-031; # Rest mass of the electron, kg
m = 1.67e-027; # Rest mass of the proton, kg
#Calculations
# As m = m0/sqrt(1-v^2/c^2), solving for v
v = c*sqrt(1-(m0/m)**2); # Velocity of the electron, m/s
#Result
print "The velocity of the electron to have its mass equal to mass of the proton = %5.3e m/s"%v
```

In [24]:

```
from math import *
#Variable declaration
c = 3e+008; # Speed of light in vacuum, unit
m0 = 9.1e-031; # Rest mass of the electron, kg
E_k = 0.1*1e+006*1.6e-019; # Kinetic energy of the electron, J
#Calculations&Results
v = sqrt(2*E_k/m0); # Classical speed of the electron, m/s
print "The classical speed of the electron = %5.3e m/s"%v
# As E_k = (m-m0)*c^2 = (1/sqrt(1-v^2/c^2)-1)*m0*c^2, solving for v
v = c*sqrt(1-(m0*c**2/(E_k+m0*c**2))**2); # Relativistic speed of the electron, m/s
print "The relativistic speed of the electron = %5.3e m/s"%v
```