General Relativity

Einstein's Masterpiece: Gravity is the curvature of spacetime. Mass-energy tells spacetime how to curve, and spacetime tells mass-energy how to move.

Chapter 2: Tensor Analysis

Tensors are the natural mathematical objects that transform properly under coordinate changes. They form the language of general relativity, expressing physical laws in coordinate-independent form.

What is a Tensor?

A tensor of type (r, s) is a multilinear map that takes r covectors and s vectors as inputs and produces a real number. In component form:

\( T^{\mu_1...\mu_r}_{\;\;\;\;\;\;\;\nu_1...\nu_s} \)

r contravariant indices (upper), s covariant indices (lower)

Transformation Law

Under coordinate transformation xμ → xμ', tensor components transform as:

\( T'^{\mu'}_{\;\;\nu'} = \frac{\partial x^{\mu'}}{\partial x^\mu} \frac{\partial x^\nu}{\partial x^{\nu'}} T^{\mu}_{\;\;\nu} \)

Important Tensor Types

Scalars (0,0)

Invariant quantities: proper time τ, rest mass m, spacetime interval ds²

Vectors (1,0) and Covectors (0,1)

Vectors: \( V^\mu = (V^0, V^1, V^2, V^3) \) — tangent to curves

Covectors: \( \omega_\mu = (\omega_0, \omega_1, \omega_2, \omega_3) \) — gradients of functions

The Metric Tensor (0,2)

\( g_{\mu\nu} \) — defines distances, angles, and raises/lowers indices

The Riemann Tensor (1,3)

\( R^\rho_{\;\sigma\mu\nu} \) — encodes spacetime curvature

Tensor Operations

Addition

\( (A + B)^{\mu\nu} = A^{\mu\nu} + B^{\mu\nu} \)

Same type tensors only

Tensor Product

\( (A \otimes B)^{\mu\nu} = A^\mu B^\nu \)

Creates higher-rank tensor

Contraction

\( A^\mu_{\;\mu} = \sum_\mu A^\mu_{\;\mu} \)

Reduces rank by 2

Index Raising/Lowering

\( V_\mu = g_{\mu\nu}V^\nu \)

Uses metric tensor

Python: Tensor Transformations

Python
tensor_transform.py94 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

Fortran: Tensor Contraction

Fortran + Python: Tensor Operations

Python

Compiles Fortran tensor code and visualizes components as heatmaps

tensor_plot.py123 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

Einstein Summation Convention

Repeated indices (one up, one down) are implicitly summed over:

\( A^\mu B_\mu \equiv \sum_{\mu=0}^{3} A^\mu B_\mu = A^0 B_0 + A^1 B_1 + A^2 B_2 + A^3 B_3 \)

This convention eliminates cumbersome summation symbols and makes equations more readable. Free indices must match on both sides of an equation.