import math
#Variable declaration
H0 = 22; # Value of Hubble constant, km/s per million ly
parsec = 3.26; # The value of 1 parsec, light years
#Calculations&Result
print "The value of Hubble constant = %d km/s per Mpc"%math.ceil(H0*parsec)
#Variable declaration
M = 1; # Let the current mass of the universe be unity
m_u = 1; # Mass equivalent of 1 amu, u
N_n = 2; # Number of neutrons in helium
N_p = 2; # Number of protons in helium
#Calculations
M_p = 0.75*M*m_u; # Total mass of protons
M_He = 0.25*M*m_u; # Total mass of helium
N_fp = M_p/M_He*(N_n + N_p); # Total number of free protons for every He-4
N_P = N_fp + N_p; # Total number of protons per He-4
ratio = N_P/N_n; # Current ratio of protons to the neutrons in the universe
#Result
print "The current ratio of protons to the neutrons in the universe = %d"%ratio
import math
#Variable declaration
m_n = 939.566; # Rest mass of the neutron, MeV/c^2
m_p = 938.272; # Rest mass of the proton, MeV/c^2
e = 1.6e-019; # Energy equivalent of 1 eV, J
c = 1; # For simplicity assume speed of light of light to be unity
T = 1e+010; # Temperature of the universe, K
#Calculations
delta_m = m_n - m_p; # Mass difference between a proton and a neutron, MeV/c^2
k = 1.38e-023; # Boltzmann constant, J/k
# As from Maxwell-Boltzmann distribution from thermodynamics, N = exp(-m*c^2/(k*T)), so
ratio = math.exp(delta_m*c**2*1e+006*e/(k*T)); # Ratio of protons to neutrons in the universe at 10 billion kelvin
#Result
print "The ratio of protons to neutrons in the universe at 10 billion kelvin = %3.1f"%ratio
import math
#Variable declaration
M = 1.99e+030; # Mass of the sun, kg
G = 6.67e-011; # Universal gravitational constant, N-Sq.m/kg^2
k = 1.38e-023; # Boltzmann constant, J/K
R = 6.96e+008; # Radius of the sun, m
m = 1.67e-027; # Rest mass of the proton, kg
#Calculations
PE = 3./5*(G*M**2/R); # Self potential energy of the sun, J
# As KE = 1./3*(M/m_p)*m_p*v**2, solving for v
v = math.sqrt(2*PE/M); # Velocity of a proton inside the sun, m/s
# From kinetic theory of gases, v = sqrt(3*k*T/m), solving for T
T = m*v**2/(3*k); # The mean temperature of the sun, K
#Result
print "The mean temperature of the sun = %1.0e K"%T
import math
#Variable declaration
M_sun = 1.99e+030; # Mass of the sun, kg
m_n = 1.675e-027; # Rest mass of the neutron, kg
h = 6.62e-034; # Planck's constant, Js
#Calculations
h_bar = h/(2*math.pi); # Planck's constant, Js
G = 6.67e-011; # Universal gravitational constant, N-Sq.m/kg^2
N = 2*M_sun/m_n; # Number of neutrons in the neutron star
V = (6.5*h_bar**2/(N**(1./3)*m_n**3*G))**3; # Volume of the neutron star, metre cube
R = (3./(4*math.pi)*V)**(1./3); # The radius of neutron star, m
#Result
print "The radius of the neutron star of 2 solar masses = %d km"%math.ceil(R/1e+003)
#Variable declaration
c = 1; # For simplicity assume speed of light to be unity, m/s
d = 1.6e+005; # Distance of the supernova 1987A from the earth, ly
m = 16; # Mass of heavier neutrino, eV/c^2;
E = 20e+006; # Energy of the neutrino, eV
#Calculations
delta_t = d/(2*c)*(m/E)**2; # Difference between the travel times of the lighter and the massive neutrinos, y
#Result
print "The difference between the travel times of the lighter and the massive neutrinos = %3.1f s"%(delta_t*(365.25*24*60*60))
import math
#Variable declaration
c = 3.00e+008; # Speed of light, m/s
H = 22; # Hubble constant, km/s per million ly
G = 6.67e-011; # Universal gravitational constant, N-Sq.m/kg^2
#Calculations
rho_c = 3/(8*math.pi)*H**2/G*1e+003/(c*365.25*24*60*60*1e+006)**2; # The critical density of the universe, g/cc
#Result
print "The critical density of the universe = %3.1e g/cc"%rho_c
#Variable declaration
H0 = 71; # Hubble constant, km/s per Mpc
#Calculations
tau = 1./H0*1e+006*3.26*9.46e+012/3.16e+007; # The upper limit of the age of the universe, y
#Result
print "The upper limit of the age of the universe = %4.2e y"%tau