M = Manifold(4, 'M', structure='Lorentzian') C.<t,x,y,z> = M.chart() g = M.metric() g[0, 0], g[1, 1], g[2, 2], g[3, 3] = 1, -1, -1, -1 g[:]
Let's perturbate this metric with a small tensor $h$, depending on a small parameter $\tau$.
tau = var('tau') h = M.tensor_field(0, 2, sym=(0,1)) h[0, 1], h[0, 2], h[0, 3] = exp(-tau*x), 2*exp(-2*tau*y), 3*exp(-3*tau*z) g.set(g + h) g[:]
The computation of the connection takes several seconds, and produces big expressions.
nab = g.connection() nab.display(only_nonredundant=True)
If $\tau$ is small, it can be interesting to look a this at the first order. It appears for example that it is completely independent of the coordinates.
nab.set_calc_order(tau, 1, True) nab.display(only_nonredundant=True)
It is also possible to perform the computation of the connection completely at the first order, by setting the order of $g$ instead of $\Gamma$. All derived quatities are then computed at this order.
g.set_calc_order(tau, 1, True) g[:]
The computation of the connection is much faster, and of course gives the same result.
nab2 = g.connection() nab == nab2