| name | relativity |
| description | Special and general relativity including Lorentz transformations, spacetime diagrams, relativistic mechanics, black holes, and gravitational waves for physics applications. |
| category | physics |
| tags | ["physics","relativity","special-relativity","general-relativity","spacetime","black-holes","gravitational-waves"] |
| difficulty | advanced |
| author | neuralblitz |
Relativity
What I do
I provide comprehensive expertise in relativity, the theoretical framework describing space, time, and gravitation. I enable you to apply special relativity (Lorentz transformations, relativistic mechanics, E=mc²) and general relativity (curved spacetime, Einstein's equations, black holes, gravitational waves). My knowledge spans from Einstein's postulates to modern applications in GPS, cosmology, gravitational wave astronomy, and high-energy physics.
When to use me
Use relativity when you need to: analyze high-speed particle dynamics, compute time dilation and length contraction effects, design or analyze GPS satellite systems, study black hole physics and event horizons, understand gravitational lensing and time delay, detect and interpret gravitational waves, model cosmology and cosmic expansion, or apply four-vectors and tensors in physics calculations.
Core Concepts
- Lorentz Transformations: Coordinate transformations between inertial frames preserving the spacetime interval.
- Spacetime Interval: s² = c²t² - x² - y² - z², invariant under Lorentz transformations.
- Time Dilation and Length Contraction: Moving clocks run slow; moving objects contract in direction of motion.
- Relativistic Velocity Addition: Velocities don't add linearly; formula prevents exceeding c.
- Energy-Momentum Relation: E² = (pc)² + (mc²)² with mass-energy equivalence E = mc².
- Four-Vectors and Tensor Formalism: Relativistic quantities transforming as 4-vectors (position, velocity, momentum).
- Einstein's Field Equations: G_μν = 8πG/c⁴ T_μν relating spacetime curvature to matter-energy.
- Schwarzschild Metric: Exact solution for spherical mass describing black holes and gravitational fields.
- Gravitational Time Dilation: Clocks in gravitational potential run slower (GPS corrections).
- Gravitational Waves: Ripples in spacetime from accelerating masses, detected by LIGO/Virgo.
Code Examples
Special Relativity
import numpy as np
def lorentz_gamma(v, c=3e8):
"""γ = 1/√(1 - v²/c²)"""
beta = v / c
if beta >= 1:
raise ValueError("v must be less than c")
return 1 / np.sqrt(1 - beta**2)
def time_dilation(t, v, c=3e8):
"""Δt' = γΔt (moving clocks run slow)"""
return lorentz_gamma(v, c) * t
def length_contraction(L, v, c=3e8):
"""L' = L/γ (moving objects contract)"""
return L / lorentz_gamma(v, c)
def velocity_addition(v, u, c=3e8):
"""Relativistic velocity addition."""
return (v + u) / (1 + v*u/c**2)
v = 0.8 * 3e8
c = 3e8
gamma = lorentz_gamma(v, c)
t_proper = 1
t_lab = time_dilation(t_proper, v, c)
L_proper = 10
L_lab = length_contraction(L_proper, v, c)
print("Special relativity effects:")
print()
()
()
v1 = * c
v2 = * c
v_total = velocity_addition(v1, v2, c)
()
():
gamma = lorentz_gamma(v, c)
source_approaching:
f * np.sqrt(( + v/c) / ( - v/c))
:
f * np.sqrt(( - v/c) / ( + v/c))
f_source =
v_c [, , , ]:
f_observed = doppler_shift(f_source, v_c * c, source_approaching=)
()
():
c =
gamma = lorentz_gamma(v_frac, c)
t_earth = d / v_frac
t_ship = d / (v_frac * gamma)
t_earth, t_ship
distance =
v_frac [, , , ]:
t_earth, t_ship = interstellar_travel(distance, v_frac)
()
()
Relativistic Mechanics
import numpy as np
def relativistic_energy(m, v, c=3e8):
"""E = γmc²"""
gamma = lorentz_gamma(v, c)
return gamma * m * c**2
def kinetic_energy(m, v, c=3e8):
"""T = (γ - 1)mc²"""
gamma = lorentz_gamma(v, c)
return (gamma - 1) * m * c**2
def momentum(m, v, c=3e8):
"""p = γmv"""
return lorentz_gamma(v, c) * m * v
def energy_momentum_relation(E, p, m, c=3e8):
"""E² = (pc)² + (mc²)²"""
return np.sqrt((p*c)**2 + (m*c**2)**2)
m_e = 9.11e-31
c = 3e8
E_rest = m_e * c**2
v = 0.99 * c
gamma = lorentz_gamma(v, c)
E_total = relativistic_energy(m_e, v, c)
K = kinetic_energy(m_e, v, c)
p = momentum(m_e, v, c)
print("Relativistic electron (v = 0.99c):")
print(f" γ = {gamma:.2f}")
print(f" Rest energy: {E_rest/:f} erg = keV = MeV")
()
()
()
v_frac [, , , ]:
K_classical = * m_e * (v_frac * c)**
K_relativistic = kinetic_energy(m_e, v_frac * c, c)
()
()
()
()
():
gamma = lorentz_gamma(v, c)
E = gamma * m * c**
p = gamma * m * v
np.array([E/c, p[], p[], p[]])
():
h =
c =
h * c / wavelength
():
h =
h / wavelength
lambda_green =
E_photon = photon_energy(lambda_green)
p_photon = photon_momentum(lambda_green)
()
()
()
General Relativity Basics
import numpy as np
def schwarzschild_radius(M):
"""Event horizon radius: r_s = 2GM/c²"""
G = 6.674e-11
c = 3e8
return 2 * G * M / c**2
def schwarzschild_metric(t, r, theta, phi, M):
"""
Schwarzschild metric components.
ds² = -(1-r_s/r)c²dt² + (1-r_s/r)⁻¹dr² + r²dΩ²
"""
rs = schwarzschild_radius(M)
g_tt = -(1 - rs/r) * c**2
g_rr = 1 / (1 - rs/r)
g_thth = r**2
g_phph = r**2 * np.sin(theta)**2
return g_tt, g_rr, g_thth, g_phph
M_sun = 1.989e30
rs_sun = schwarzschild_radius(M_sun)
rs_earth = schwarzschild_radius(5.97e24)
print("Schwarzschild radius:")
print(f" Sun: r_s = {rs_sun:.0f} m = {rs_sun/3e6:.2f} km (actual radius: 696,000 km!)")
print(f" Earth: r_s = {rs_earth:.0f} m = {rs_earth:.2f} mm")
M_sgrA = 4.154e6 * M_sun
rs_sgrA = schwarzschild_radius(M_sgrA)
print()
():
rs = schwarzschild_radius(M)
np.sqrt( - rs / r)
M_earth =
r_gps =
r_surface =
v_gps =
gamma_sr = lorentz_gamma(v_gps)
t_dilation_gr = gravitational_time_dilation(r_gps, M_earth)
()
()
()
()
()
():
rs = schwarzschild_radius(M)
c * np.sqrt(rs / ( * r))
r_ratio [, , ]:
r = r_ratio * rs_sun
v = schwarzschild_orbital_velocity(r, M_sun)
()
r_isco = * schwarzschild_radius(M_sun)
()
()
Gravitational Waves
import numpy as np
def gravitational_wave_strain(m1, m2, r, frequency, c=3e8, G=6.674e-11):
"""
Characteristic strain from binary merger.
h ~ 4G² m1 m2 / (c⁴ r d) × (πf)²/³
"""
M_chirp = (m1 * m2)**(3/5) / (m1 + m2)**(1/5)
return 4 * (G * M_chirp / c**2)**(5/3) * (np.pi * frequency / c)**(2/3) / r
def merger_time(m1, m2, a0, e0=0):
"""
Time to merger due to gravitational radiation.
t_merge ~ (5/256) c⁵ a⁴ / (G³ m1 m2 (m1+m2))
"""
G = 6.674e-11
c = 3e8
return 5 * c**5 * a0**4 / (256 * G**3 * m1 * m2 * (m1 + m2))
m1 = 36 * 1.989e30
m2 = 29 * 1.989e30
d = 410e6 * 9.46e15
f = 35
h = gravitational_wave_strain(m1, m2, d, f)
print("Gravitational wave strain (GW150914-like):")
print(f" m₁ = 36 M☉, m₂ = 29 M☉, distance = 410 Mpc")
print()
m1 = m2 = *
d = *
f =
h_ns = gravitational_wave_strain(m1, m2, d, f)
()
()
()
():
detector == :
/ np.sqrt(f/)
frequencies = np.logspace(, , )
()
()
()
():
* G** * m1** * m2** * (m1 + m2) / ( * c** * a**)
M_sun =
L_gw = gw_luminosity(*M_sun, *M_sun, )
L_sun =
()
()
()
()
Cosmology
import numpy as np
def hubble_distance(H0):
"""d_H = c/H₀"""
c = 3e5
return c / H0
def hubble_time(H0):
"""t_H = 1/H₀ (age of universe for empty model)"""
return 1 / H0
def luminosity_distance(d, z):
"""d_L = (1+z)d for small z."""
return d * (1 + z)
H0 = 70
c = 299792.458
d_H = c / H0
print("Cosmological parameters:")
print(f" H₀ = {H0} km/s/Mpc")
print(f" Hubble distance: {d_H:.0f} Mpc")
print(f" Hubble time: {1/H0 * 9.78e9:.1f} billion years")
def redshift_to_distance(z, H0=70, Omega_m=0.3, Omega_Lambda=0.7):
"""Approximate luminosity distance."""
d_L = c * z / H0 * ( + z * ( - z) / )
d_L
z [, , , , ]:
d = redshift_to_distance(z)
()
():
age_present =
age_present / ( + z) * ( + * z)
()
z [, , , , ]:
t = universe_age(z)
()
():
G =
H0_si = H0 * /
* H0_si** / ( * np.pi * G)
rho_c = critical_density(H0)
()
()
()
():
c =
c / H0 * np.arccosh(/Omega_Lambda)**(-) * / np.sqrt(Omega_Lambda)
d_horizon = event_horizon(H0)
()
()
()
Best Practices
- Use consistent units throughout relativistic calculations (natural units with c=1 often simplify algebra).
- Always specify which frame you're working in when calculating time dilation, length contraction, or Doppler shifts.
- For GPS and precision timing applications, account for both special and general relativistic corrections.
- In general relativity, remember that coordinates don't have direct physical meaning; compute observable quantities using proper time and distances.
- When calculating gravitational wave strains, distinguish between characteristic strain and amplitude at the detector.
- Use the quadrupole formula for gravitational radiation; monopole and dipole radiation are forbidden by conservation laws.
- For cosmology, be clear about which distance measure you're using (comoving, proper, luminosity, angular diameter).
- In numerical relativity, use gauge conditions that avoid coordinate singularities (e.g., 1+log slicing, harmonic gauge).
- For black hole physics, distinguish between the event horizon (global property) and apparent horizon (local, coordinate-dependent).
- When comparing theory with observations, account for redshift of source when interpreting measured quantities.