According to Wikipedia, the formula for gravitational time dilation in the vicinity of a charged mass is:

$$\varsigma = \sqrt{|g^{t t}|} = \sqrt{\frac{r^2}{Q^2+(r-2 M) r}}$$

However, if I plug in $M=$Earth, $r=$Earth, $Q=0$, I get an imaginary number. Just in case I've made a silly mistake, this is, I think, the same formula in swift:

let r = 6e6 // meters
let Q = 0.0 // Coulombs
let M = 5.9e24 // kg

func σ(r: Double, Q: Double, M: Double) -> Double {
    let r² = r*r
    let Q² = Q*Q

    let σ = sqrt( r² / (Q² + (r-(2*M))*r) )
    // here, r² / (Q² + (r-(2*M))*r) = -5.084745762711864e-19

    return σ

print( σ(r: r, Q: Q, M: M) ) // prints "-nan"

This is clearly wrong, so what's the error?

  • 1
    $\begingroup$ If you are using SI units, you will need to include factors of $c$ and $G$ to get the dimensions of $M$ correct. Otherwise expressions like $r - 2 M$ make no sense. $\endgroup$ – Clara Diaz Sanchez Dec 20 '19 at 10:18
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because it's about debugging code and not physics concepts. $\endgroup$ – Kyle Kanos Dec 20 '19 at 11:26
  • $\begingroup$ @KyleKanos having seen what Clara and John have written, I believe my error is definitely about the physics concepts. I didn't realise I'd made the elementary mistake of forgetting units, which would've made the absence of c and G in the equation clear. $\endgroup$ – BenRW Dec 20 '19 at 13:25

In general relativity we often work with geometrical units in which $c = G = 1$ as this greatly simplifies the equations, and this is the form of the equation you are using. To calculate the time dilation you need to put back in the factors of $c$ and $G$.

The Reissner-Nordstrom metric is:

$$ c^2d\tau^2=c^2\left(1-\frac{r_s}{r}+\frac{r_q^2}{r^2}\right)dt^2 - \left(1-\frac{r_s}{r}+\frac{r_q^2}{r^2}\right)^{-1}dr^2 - r^2d\Omega^2 $$


$$ r_s = \frac{2GM}{c^2} $$


$$ r_q^2 = \frac{Q^2G}{4 \pi \epsilon_0 c^4} $$

In this equation $\tau$ is the time measured by the observer near the black hole and $t$ is the time measured by the observer far from the black hole, so the time dilation factor is $t/\tau$. For stationary observers $dr = d\Omega = 0$ so the equation simplifies to:

$$ \frac{dt}{d\tau} = \left(1-\frac{r_s}{r}+\frac{r_q^2}{r^2}\right)^{-1/2} = \left(1-\frac{2GM}{c^2r}+\frac{GQ^2}{4\pi\epsilon_0c^4r^2}\right)^{-1/2} $$

And this is the equation you need.

  • $\begingroup$ Well, that was an embarrassing thing for me to forget. Thank you for the helpful explanation. $\endgroup$ – BenRW Dec 20 '19 at 13:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.