What is Cadabra skin

Cadabra tutorials

The tutorials listed below are meant to illustrate Cadabra concepts at the level of simple examples; for research-level applications of Cadabra please see the papers section.

The pages linked below are produced from actual Cadabra notebooks. Instead of reading them on-line, you can also download the notebooks and play with them inside Cadabra. These notebooks all require the new 2.x version of the software and will not work with the old version 1.x. If you have a nice notebook that you think would help others to learn Cadabra, please get in touch.

Absolute beginners

This notebook explains how to enter expressions, how to do simple substitutions on them, how to use wildcards. It also explains how the new Python functionality works. If you have never used Cadabra before, start here.

For a bit more advanced material, try one of the following tutorials.

If you have used old versions of Cadabra but are new to series 2.x, give the following notebook a shot.

Writing packages for Cadabra

One of the key reasons for the rewrite of Cadabra was to make it much easier for users to contribute small bits of functionality. As all of its internals are available via Python, it becomes much easier to write small add-on packages, just like you can for other computer algebra systems.

A more step-by-step tutorial for writing packages will follow; for the time being here are some smaller tutorials describing a number of Cadabra programming concepts.

Actions, equations of motion, variational derivatives

Quantum mechanics, groups and algebras

Dirac gamma matrix algebra is very simple with Cadabra, and it can handle them in arbitrary dimensions.

A frequently asked question is how to do commutator algebra with Cadabra. The following notebook shows how this works by verifying the invariance of the two quadratic Casimirs of the Poincaré algebra. It shows how to make good use of to simplify expressions automatically.

Because of fact that you can use natural LaTeX notation and because Cadabra understand non-commuting objects, many tedious operator algebra computations in quantum mechanics become relatively simple. Here is an example from string theory, in which we verify that certain states satisfy the quantum string constraints.

Abstract general relativity and differential geometry

Cadabra was originally written in order to facilitate computations in extensions of general relativity. The following example shows how to prove a particular polynomial identity cubic in the Weyl tensor, by virtue of its multi-term symmetries.

You can also do computations with abstract differential forms and the exterior derivative, as in the example below.

Component computations

From version 2.x you can do abstract as well as component computations with Cadabra. The logic is very simple and based on a few key ideas rooted in Cadabra's substitution engine. Examples of varying difficulty are available below.

The first one is a trivial example of computing the curvature tensor and scalar for a 2-sphere. Easy to do by hand, too, of course.

The next one computes Christoffel symbols and related for the Schwarzschild metric; definitely a frequently requested feature ...

Somewhat related to component computations is the concept of splitting a vector bundle into two parts, like you do in Kaluza-Klein models. The following notebook is also discussed in the original Cadabra paper hep-th / 0701238.


Cadabra's notebook now displays graphics from a variety of Python sources; see the notebook below for some basic examples.

SymPy users

Cadabra relies on SymPy for a lot of scalar computer algebra, that is, for algebra on expressions which do not involve indices. Here is a simple notebook to illustrate the basic concepts. This may also be a useful read if you want to use the Cadabra notebook interface just to work with SymPy.

Using Cadabra from IPython / Jupyter

Cadabra now ships with a Jupyter kernel which is installed by default; see Cadabra Jupyter kernel for more details. This is the easiest way to use Cadabra in Jupyter as it allows you to use standard Cadabra notation, just like in Cadabra's own notebook interface.

If you do not want to rely on the Cadabra kernel but would like to use the Python module directly in your Python code, consult the following notebook for some of the absolute basics.