# Solving Einstein equation to get Kottler solution¶

This Jupyter/SageMath notebook is relative to the lectures Geometry and physics of black holes. It involves computations based on differential geometry tools developed through the SageManifolds project.

In :
version()

Out:
'SageMath version 9.5.beta5, Release Date: 2021-10-28'

First we set up the notebook to display mathematical objects using LaTeX formatting:

In :
%display latex


## Spacetime¶

We declare the spacetime manifold $M$:

In :
M = Manifold(4, 'M')
print(M)

4-dimensional differentiable manifold M


We declare the chart of spherical coordinates $(t,r,\theta,\phi)$:

In :
X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
X

Out:
$\newcommand{\Bold}{\mathbf{#1}}\left(M,(t, r, {\theta}, {\phi})\right)$

The static and spherically symmetric metric ansatz, with the unknown functions $A(r)$ and $B(r)$:

In :
g = M.lorentzian_metric('g')
A = function('A')
B = function('B')
g[0,0] = -A(r)
g[1,1] = B(r)
g[2,2] = r^2
g[3,3] = (r*sin(th))^2
g.display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}g = -A\left(r\right) \mathrm{d} t\otimes \mathrm{d} t + B\left(r\right) \mathrm{d} r\otimes \mathrm{d} r + r^{2} \mathrm{d} {\theta}\otimes \mathrm{d} {\theta} + r^{2} \sin\left({\theta}\right)^{2} \mathrm{d} {\phi}\otimes \mathrm{d} {\phi}$

The Christoffel symbols of $g$, with respect to the default chart:

In :
g.christoffel_symbols_display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}\begin{array}{lcl} \Gamma_{ \phantom{\, t} \, t \, r }^{ \, t \phantom{\, t} \phantom{\, r} } & = & \frac{\frac{\partial\,A}{\partial r}}{2 \, A\left(r\right)} \\ \Gamma_{ \phantom{\, r} \, t \, t }^{ \, r \phantom{\, t} \phantom{\, t} } & = & \frac{\frac{\partial\,A}{\partial r}}{2 \, B\left(r\right)} \\ \Gamma_{ \phantom{\, r} \, r \, r }^{ \, r \phantom{\, r} \phantom{\, r} } & = & \frac{\frac{\partial\,B}{\partial r}}{2 \, B\left(r\right)} \\ \Gamma_{ \phantom{\, r} \, {\theta} \, {\theta} }^{ \, r \phantom{\, {\theta}} \phantom{\, {\theta}} } & = & -\frac{r}{B\left(r\right)} \\ \Gamma_{ \phantom{\, r} \, {\phi} \, {\phi} }^{ \, r \phantom{\, {\phi}} \phantom{\, {\phi}} } & = & -\frac{r \sin\left({\theta}\right)^{2}}{B\left(r\right)} \\ \Gamma_{ \phantom{\, {\theta}} \, r \, {\theta} }^{ \, {\theta} \phantom{\, r} \phantom{\, {\theta}} } & = & \frac{1}{r} \\ \Gamma_{ \phantom{\, {\theta}} \, {\phi} \, {\phi} }^{ \, {\theta} \phantom{\, {\phi}} \phantom{\, {\phi}} } & = & -\cos\left({\theta}\right) \sin\left({\theta}\right) \\ \Gamma_{ \phantom{\, {\phi}} \, r \, {\phi} }^{ \, {\phi} \phantom{\, r} \phantom{\, {\phi}} } & = & \frac{1}{r} \\ \Gamma_{ \phantom{\, {\phi}} \, {\theta} \, {\phi} }^{ \, {\phi} \phantom{\, {\theta}} \phantom{\, {\phi}} } & = & \frac{\cos\left({\theta}\right)}{\sin\left({\theta}\right)} \end{array}$

## Einstein equation¶

The cosmological constant:

In :
Lamb = var('Lamb', latex_name=r'\Lambda')
Lamb

Out:
$\newcommand{\Bold}{\mathbf{#1}}{\Lambda}$

The Einstein equation:

In :
EE = g.ricci() - 1/2*g.ricci_scalar()*g + Lamb*g
EE.set_name('E')
print(EE)

Field of symmetric bilinear forms E on the 4-dimensional differentiable manifold M

In :
EE.display_comp()

Out:
$\newcommand{\Bold}{\mathbf{#1}}\begin{array}{lcl} E_{ \, t \, t }^{ \phantom{\, t}\phantom{\, t} } & = & -\frac{{\left({\Lambda} r^{2} - 1\right)} A\left(r\right) B\left(r\right)^{2} - r A\left(r\right) \frac{\partial\,B}{\partial r} + A\left(r\right) B\left(r\right)}{r^{2} B\left(r\right)^{2}} \\ E_{ \, r \, r }^{ \phantom{\, r}\phantom{\, r} } & = & \frac{{\left({\Lambda} r^{2} - 1\right)} A\left(r\right) B\left(r\right) + r \frac{\partial\,A}{\partial r} + A\left(r\right)}{r^{2} A\left(r\right)} \\ E_{ \, {\theta} \, {\theta} }^{ \phantom{\, {\theta}}\phantom{\, {\theta}} } & = & \frac{4 \, {\Lambda} r^{2} A\left(r\right)^{2} B\left(r\right)^{2} - r^{2} B\left(r\right) \left(\frac{\partial\,A}{\partial r}\right)^{2} + 2 \, r^{2} A\left(r\right) B\left(r\right) \frac{\partial^2\,A}{\partial r ^ 2} + 2 \, r A\left(r\right) B\left(r\right) \frac{\partial\,A}{\partial r} - {\left(r^{2} A\left(r\right) \frac{\partial\,A}{\partial r} + 2 \, r A\left(r\right)^{2}\right)} \frac{\partial\,B}{\partial r}}{4 \, A\left(r\right)^{2} B\left(r\right)^{2}} \\ E_{ \, {\phi} \, {\phi} }^{ \phantom{\, {\phi}}\phantom{\, {\phi}} } & = & \frac{{\left(4 \, {\Lambda} r^{2} A\left(r\right)^{2} B\left(r\right)^{2} - r^{2} B\left(r\right) \left(\frac{\partial\,A}{\partial r}\right)^{2} + 2 \, r^{2} A\left(r\right) B\left(r\right) \frac{\partial^2\,A}{\partial r ^ 2} + 2 \, r A\left(r\right) B\left(r\right) \frac{\partial\,A}{\partial r} - {\left(r^{2} A\left(r\right) \frac{\partial\,A}{\partial r} + 2 \, r A\left(r\right)^{2}\right)} \frac{\partial\,B}{\partial r}\right)} \sin\left({\theta}\right)^{2}}{4 \, A\left(r\right)^{2} B\left(r\right)^{2}} \end{array}$

### Simplifying and rearranging the equations¶

In :
eq0 = EE[0,0]*r^2*B(r)^2/A(r); eq0

Out:
$\newcommand{\Bold}{\mathbf{#1}}-\frac{{\left({\Lambda} r^{2} - 1\right)} A\left(r\right) B\left(r\right)^{2} - r A\left(r\right) \frac{\partial\,B}{\partial r} + A\left(r\right) B\left(r\right)}{A\left(r\right)}$
In :
eq1 = EE[1,1]*r^2*A(r); eq1

Out:
$\newcommand{\Bold}{\mathbf{#1}}{\left({\Lambda} r^{2} - 1\right)} A\left(r\right) B\left(r\right) + r \frac{\partial\,A}{\partial r} + A\left(r\right)$
In :
eq2 = EE[2,2]*4*A(r)^2*B(r)^2; eq2

Out:
$\newcommand{\Bold}{\mathbf{#1}}4 \, {\Lambda} r^{2} A\left(r\right)^{2} B\left(r\right)^{2} - r^{2} B\left(r\right) \left(\frac{\partial\,A}{\partial r}\right)^{2} + 2 \, r^{2} A\left(r\right) B\left(r\right) \frac{\partial^2\,A}{\partial r ^ 2} + 2 \, r A\left(r\right) B\left(r\right) \frac{\partial\,A}{\partial r} - {\left(r^{2} A\left(r\right) \frac{\partial\,A}{\partial r} + 2 \, r A\left(r\right)^{2}\right)} \frac{\partial\,B}{\partial r}$
In :
eq3 = EE[3,3]*4*A(r)^2*B(r)^2/sin(th)^2; eq3

Out:
$\newcommand{\Bold}{\mathbf{#1}}4 \, {\Lambda} r^{2} A\left(r\right)^{2} B\left(r\right)^{2} - r^{2} B\left(r\right) \left(\frac{\partial\,A}{\partial r}\right)^{2} + 2 \, r^{2} A\left(r\right) B\left(r\right) \frac{\partial^2\,A}{\partial r ^ 2} + 2 \, r A\left(r\right) B\left(r\right) \frac{\partial\,A}{\partial r} - {\left(r^{2} A\left(r\right) \frac{\partial\,A}{\partial r} + 2 \, r A\left(r\right)^{2}\right)} \frac{\partial\,B}{\partial r}$
In :
eq3 == eq2

Out:
$\newcommand{\Bold}{\mathbf{#1}}\mathrm{True}$

## Solving Einstein equation¶

The following combination of eq0 and eq1 is particularly simple:

In :
eq4 = (eq0*A(r) + eq1*B(r))/r; eq4

Out:
$\newcommand{\Bold}{\mathbf{#1}}\frac{r B\left(r\right) \frac{\partial\,A}{\partial r} + r A\left(r\right) \frac{\partial\,B}{\partial r}}{r}$

The solution is $A(r)B(r)=C$, where $C$ is a constant:

In :
s = desolve(eq4.expr() == 0, B(r), ivar=r)
s

Out:
$\newcommand{\Bold}{\mathbf{#1}}\frac{C}{A\left(r\right)}$

Let us rename the constant to $\alpha$:

In :
var('alpha', latex_name=r'\alpha')
B_sol(r) = s.subs(_C=alpha); B_sol

Out:
$\newcommand{\Bold}{\mathbf{#1}}r \ {\mapsto}\ \frac{{\alpha}}{A\left(r\right)}$

We replace $B(r)$ by the above value in the remaining equations:

In :
eq5 = X.function(eq1.expr().substitute_function(B, B_sol)); eq5

Out:
$\newcommand{\Bold}{\mathbf{#1}}{\left({\Lambda} r^{2} - 1\right)} {\alpha} + r \frac{\partial\,A}{\partial r} + A\left(r\right)$
In :
eq6 = X.function(eq2.expr().substitute_function(B, B_sol)); eq6

Out:
$\newcommand{\Bold}{\mathbf{#1}}4 \, {\Lambda} {\alpha}^{2} r^{2} - \frac{{\alpha} r^{2} \left(\frac{\partial\,A}{\partial r}\right)^{2}}{A\left(r\right)} + 2 \, {\alpha} r^{2} \frac{\partial^2\,A}{\partial r ^ 2} + 2 \, {\alpha} r \frac{\partial\,A}{\partial r} + \frac{{\left(r^{2} A\left(r\right) \frac{\partial\,A}{\partial r} + 2 \, r A\left(r\right)^{2}\right)} {\alpha} \frac{\partial\,A}{\partial r}}{A\left(r\right)^{2}}$

Let us solve eq5 for $A(r)$. Note that we are using eq5.expr() to get a symbolic expression, as expected by the function desolve, while eq5 is a coordinate function.

In :
s = desolve(eq5.expr() == 0, A(r), ivar=r)
s.expand()

Out:
$\newcommand{\Bold}{\mathbf{#1}}-\frac{1}{3} \, {\Lambda} {\alpha} r^{2} + {\alpha} + \frac{C}{r}$

We rename the constant $C$ to $-2m$ and set the value of constant $\alpha$ to $1$:

In :
var('m')
A_sol(r) = s.subs(_C=-2*m, alpha=1).expand()
A_sol

Out:
$\newcommand{\Bold}{\mathbf{#1}}r \ {\mapsto}\ -\frac{1}{3} \, {\Lambda} r^{2} - \frac{2 \, m}{r} + 1$

Let us check that eq6 is fulfilled by the found value of $A(r)$:

In :
eq6.expr().substitute_function(A, A_sol).subs(alpha=1).simplify_full()

Out:
$\newcommand{\Bold}{\mathbf{#1}}0$

### Final expression of the metric¶

We have got the Kottler metric:

In :
g[0,0] = -A_sol(r)
g[1,1] = 1/A_sol(r)
g.display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}g = \left( \frac{1}{3} \, {\Lambda} r^{2} + \frac{2 \, m}{r} - 1 \right) \mathrm{d} t\otimes \mathrm{d} t + \left( -\frac{3}{{\Lambda} r^{2} + \frac{6 \, m}{r} - 3} \right) \mathrm{d} r\otimes \mathrm{d} r + r^{2} \mathrm{d} {\theta}\otimes \mathrm{d} {\theta} + r^{2} \sin\left({\theta}\right)^{2} \mathrm{d} {\phi}\otimes \mathrm{d} {\phi}$

which reduces to Schwarzschild metric as soon as the cosmological constant vanishes.

In :
g.christoffel_symbols_display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}\begin{array}{lcl} \Gamma_{ \phantom{\, t} \, t \, r }^{ \, t \phantom{\, t} \phantom{\, r} } & = & \frac{{\Lambda} r^{3} - 3 \, m}{{\Lambda} r^{4} + 6 \, m r - 3 \, r^{2}} \\ \Gamma_{ \phantom{\, r} \, t \, t }^{ \, r \phantom{\, t} \phantom{\, t} } & = & \frac{{\Lambda}^{2} r^{6} + 3 \, {\Lambda} m r^{3} - 3 \, {\Lambda} r^{4} - 18 \, m^{2} + 9 \, m r}{9 \, r^{3}} \\ \Gamma_{ \phantom{\, r} \, r \, r }^{ \, r \phantom{\, r} \phantom{\, r} } & = & -\frac{{\Lambda} r^{3} - 3 \, m}{{\Lambda} r^{4} + 6 \, m r - 3 \, r^{2}} \\ \Gamma_{ \phantom{\, r} \, {\theta} \, {\theta} }^{ \, r \phantom{\, {\theta}} \phantom{\, {\theta}} } & = & \frac{1}{3} \, {\Lambda} r^{3} + 2 \, m - r \\ \Gamma_{ \phantom{\, r} \, {\phi} \, {\phi} }^{ \, r \phantom{\, {\phi}} \phantom{\, {\phi}} } & = & \frac{1}{3} \, {\left({\Lambda} r^{3} + 6 \, m - 3 \, r\right)} \sin\left({\theta}\right)^{2} \\ \Gamma_{ \phantom{\, {\theta}} \, r \, {\theta} }^{ \, {\theta} \phantom{\, r} \phantom{\, {\theta}} } & = & \frac{1}{r} \\ \Gamma_{ \phantom{\, {\theta}} \, {\phi} \, {\phi} }^{ \, {\theta} \phantom{\, {\phi}} \phantom{\, {\phi}} } & = & -\cos\left({\theta}\right) \sin\left({\theta}\right) \\ \Gamma_{ \phantom{\, {\phi}} \, r \, {\phi} }^{ \, {\phi} \phantom{\, r} \phantom{\, {\phi}} } & = & \frac{1}{r} \\ \Gamma_{ \phantom{\, {\phi}} \, {\theta} \, {\phi} }^{ \, {\phi} \phantom{\, {\theta}} \phantom{\, {\phi}} } & = & \frac{\cos\left({\theta}\right)}{\sin\left({\theta}\right)} \end{array}$

Let us check that the vacuum Einstein equation is satisfied by the above metric:

In :
EE = g.ricci() - 1/2*g.ricci_scalar()*g + Lamb*g
EE.set_name('E')
EE.display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}E = 0$

The Ricci scalar is constant for this solution:

In :
g.ricci_scalar().display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}\begin{array}{llcl} \mathrm{r}\left(g\right):& M & \longrightarrow & \mathbb{R} \\ & \left(t, r, {\theta}, {\phi}\right) & \longmapsto & 4 \, {\Lambda} \end{array}$

The Ricci tensor is proportional to the metric tensor:

In :
g.ricci().display()

Out:
$\newcommand{\Bold}{\mathbf{#1}}\mathrm{Ric}\left(g\right) = \left( \frac{{\Lambda}^{2} r^{3} + 6 \, {\Lambda} m - 3 \, {\Lambda} r}{3 \, r} \right) \mathrm{d} t\otimes \mathrm{d} t + \left( -\frac{3 \, {\Lambda} r}{{\Lambda} r^{3} + 6 \, m - 3 \, r} \right) \mathrm{d} r\otimes \mathrm{d} r + {\Lambda} r^{2} \mathrm{d} {\theta}\otimes \mathrm{d} {\theta} + {\Lambda} r^{2} \sin\left({\theta}\right)^{2} \mathrm{d} {\phi}\otimes \mathrm{d} {\phi}$
In :
g.ricci() == Lamb * g

Out:
$\newcommand{\Bold}{\mathbf{#1}}\mathrm{True}$