# Computing the Chern–Pontryagin invariant

Hi there,

I'm currently trying to construct the so called Chern–Pontryagin invariant for (say) Schwarzschild spacetime, which is a term constructed as the Riemann tensor contracted with its dual:

$ P_4 = R_{\alpha \beta \mu \nu} \varepsilon^{\alpha \beta \rho \sigma} R_{\rho \sigma}^{\mu \nu}, $

where $\varepsilon$ is the volume form (or effectively the Hodge dual in this set up).

This term cannot be broken up into two independent contractions which we then trace over, since in this case the trace will vanish identically. Therefore the contraction has to appear as is, in one single computation.

I thought about constructing this as a sequence of for loops (regardless of how long it would take)

```
Id = 0
for i in range(4):
for j in range(4):
for k in range(4):
for l in range(4):
for m in range(4):
for n in range(4):
Id = R_down['_ijkl']*dual['^ijmn']*R_up['^kl_mn']
```

But this always returns the TypeError: 'the second item of * must be a tensor with specified indices'.

How can I perform the type of triple tensor contraction appearing above in general? Note that the problem would be the same as for computing the topological Euler density, which involves a double dual:

$ \varepsilon^{\alpha \beta \gamma \delta} R^{\mu \nu}_{\alpha \beta} R^{\rho \sigma}_{\gamma \delta} \varepsilon_{\mu \nu \rho \sigma} $

Any ideas?

Many thanks.

I do not think that you will need loops. Please check this page to see that the Kretschmann scalar is defined and calculated as

and the types are:

You will need to make sure that the type of your "dual" is correct and update your code accordingly.