Characteristic Classes in SageMath

Michael Jung
Vrije Universiteit Amsterdam
October 30, 2020


  1. Mixed Differential Forms
  2. Example: Euler Class
  3. Characteristic Classes in General
  4. Implementation Details and Improvements
  5. Future Prospects

Mixed Differential Forms

$$\nonumber\Omega^*(M;\mathbb{K}) := \bigoplus^n_{k=0} \Omega^k(M;\mathbb{K})$$

Example on $\mathbb{R}^2$

Define manifold:

Algebra of mixed forms:

Consider some predefined forms:

Define a mixed form:

It shall consist of the differential forms $f, \omega_1, \omega_2$. The forms are assigned by using index operations:

Another mixed form:

The multiplication is executed degree wise:

Recall: Curvature Forms


Let $M$ be a smooth manifold and $R$ be the Riemann tensor w.r.t. to some connection $\nabla$. We define the curvature form matrix $\Omega^\nabla$ w.r.t. the frame $(e_1, \ldots, e_n)$ via:

$$R(X,Y) \, e_i = \sum_{j=1}^n \Omega_{ij}(X,Y) \, e_j.$$


Theorem (Gauß-Bonnet)

Let $M$ be an $2$-dimensional closed oriented Riemannian manifold. Then

$$\int_M \frac{\Omega^g_{12}}{2 \pi} = \chi(M),$$

where $\Omega^g$ is the from $g$ induced curvature form matrix w.r.t. an orthonormal oriented frame and $\chi(M)$ is the Euler characteristic of $M$.

Example: Euler Characteristic

Euler Class

Chern-Weil Theory


If $P\colon \mathfrak{gl}(n, \mathbb{C}) \to \mathbb{C}$ is an (under conjugation) invariant formal power series, then:

  1. $P(\Omega^\nabla)$ can be globally defined and is closed,
  2. $\left[ P(\Omega^\nabla) \right] \in H^{2*}(M;\mathbb{C})$ is independent of the choice of $\nabla$.

Proof (sketch):

  1. Use the transformation behaviour of $\Omega^\nabla$ and invariant nature of $P$. Closedness follows from the Bianchi identity.
  2. Connect two connections via homotopy.


We call $\left[ P(\Omega^\nabla) \right]$ a characteristic class of $M$.

Chern-Weil: Recipe

  1. Choose a connection $\nabla$.
  1. Compute its curvature form matrix $\Omega^\nabla$.
  1. Plug it into an invariant formal power series $P$.

Some Important Classes

Name Designation Representative Regime
Chern class $c$ $\det\!\left( 1 + \frac{\Omega^\nabla}{2 \pi \mathrm{i}} \right)$ complex
Chern character $\mathrm{ch}$ $\mathrm{tr}\!\left( \exp\!\left( \frac{\Omega^\nabla}{2 \pi \mathrm{i}}\right) \right)$ complex
Todd class $\mathrm{Td}$ $\det\!\left(\frac{\frac{\Omega^\nabla}{2 \pi \mathrm{i}}}{1-\exp\left(\frac{\Omega^\nabla}{2 \pi \mathrm{i}}\right)}\right)$ complex
Pontryagin class $p$ $\det\!\left( 1 - \frac{\left(\Omega^\nabla\right)^2}{4 \pi^2} \right)$ real
$\hat{A}$ class $\hat{A}$ $\det\!\left( \sqrt{\frac{\frac{\mathrm{i}}{4 \pi} \Omega^\nabla}{\sinh\left( \frac{\mathrm{i}}{4 \pi} \Omega^\nabla \right)}}\right)$ real
Euler class $e$ $\mathrm{Pf}\!\left( \frac{\Omega^\nabla}{2 \pi} \right)$ real


$\phantom{\rightarrow}$ Define an affine connection $\nabla$

$\rightarrow$ Compute (or manually plug in) curvature form matrix $\Omega^\nabla$ w.r.t. some frame

$\rightarrow$ Compute $f\left(\frac{\Omega^\nabla}{2 \pi i}\right)$ using functional calculus

$\rightarrow$ Apply $\det$, $\mathrm{tr}$ or $\mathrm{Pf}$

$\Rightarrow$ Repeat until $M$ is covered and patch results together

Non-Spinable Manifold Example

Fubini-Study Metric

$\Rightarrow$ $\mathbb{C}P^2$ is not spin!

Can we do better?

Fundamental Theorem of Symmetric Polynomials

For each symmetric polynomial $P \colon \mathfrak{gl}(n, \mathbb{C}) \to \mathbb{C}$ there exists a unique polynomial $Q$ such that

$$ P = Q(\sigma_1, \ldots, \sigma_n), $$

where $\sigma_i$ denotes the $i$-th elementary symmetric polynomial.

Special Case: The Pfaffian


$\mathrm{Pf} \colon \mathfrak{so}(2n) \to \mathbb{R}$ is invariant under $\mathrm{SO}(2n)$ conjugation.

Workaround (Chern 1963)

Let $(G_{ij})$ be the Gram matrix of a pseudo-Riemannian metric w.r.t. to some not necessarily ON but oriented frame. Then the matrix

$$G \cdot \Omega$$

is skew-symmetric.

Idea now: Take $\mathrm{Pf}(G \cdot \Omega)$ and normalize by $\sqrt{|\det(G)|}$.

Generators of Characteristic Classes

Complex setup:

Real setup:

Choose metric connection such that $\Omega^\nabla$ can be chosen skew-symmetric:

If $M$ is orientable:

Generators of Characteristic Classes II

Let $R$ be a ring (typically $R= \mathbb{Z}, \mathbb{Q}, \mathbb{R}, \mathbb{C}$) then the following polynomial rings give the set of characteristic classes:

$\rightarrow$ Implement these structures in Sage to obtain all characteristic classes directly and more easily

Future Prospect: Transgression Forms

Suppose $\nabla,\nabla'$ are two connections. Then:

\begin{align*} \int_M \kappa\big(M, \nabla \big) - \kappa\big(M, \nabla'\big) &= \int_{M} \mathrm{d} Q\big(M, \nabla, \nabla' \big) \\ &= \int_{\partial M} Q\big(M, \nabla, \nabla' \big) \end{align*}


  1. M. F. Atiyah, I. M. Singer, The Index of Elliptic Operators: III (1968) in Annals of Mathematics.
  2. C. Bär, The Faddeev-LeVerrier algorithm and the Pfaffian (2020), available at
  3. S.-S. Chern, Pseudo-Riemannian Geometry and the Gauss-Bonnet Formula (1963) in An. da Acad. Brasileira de Ciencias.
  4. M. Jung, Characteristic classes in computer algebra (2020), available at