This OCaml code computes the Kerr−Newman metric as given here.
 code id Wiki id meaning bSI 3 physical constants in SI units gu Same units geometrized c c speed of light bG G gravitational constant ke 1/4πε0c4 Coulomb’s constant bM M Mass of BH bQ Q charge on BH bJ J angular momentum dtau2 dτ τ is proper time, measured locally. dtau2 is a function of coordinates and differential vector. rs rs Schwarzschild radius rQ2 rQ2 a squared measure of the charge. a α common subexpression r r Schwarzschild radius, the r coordinate. th θ Latitude = (90−180*θ/π)°, a coordinate dt dt delta t where t is the coordinate time. dr dr delta r dth dθ delta θ dp dφ delta longitude. Longitude = 180*φ/π. rh2 ρ2 common subexpression del Δ common subexpression
t, r, φ and θ are the coördinates.
θ is actually 0 and π at the poles and π/2 at the equator. It determines the latitude.

Three physical constants play a role here, c, bG and ke. These constants can be expressed in either SI units of geometrized units.

Three constants describe the particular black hole: M, Q and J.

The function dtau2 is of the relevant coordinates, r and th, and the differential vector, (dt, dr, dth, dp), separating the two events whose distance the metric defines.

### Cartesian Coordinates

This to compute r2 from x, y, z and a.

The plan:

• Choose a random point by its polar coordinates,
• choose a random small 4D displacement,
• use dtau2 to compute length of displacement,
• Transform polar coordinates via p2C to Cartesian,
• Compute covariant tensor with gC,
• Compute length of displacement via ds2 = gijdxidxj,
• Compare computed lengths.

### Elephant

The Elephant in the room is whether these solutions satisfy Einstein’s equations.
start? Start!