This is a short and simple Jupyter notebook shows how to use Cadabra functionality from with Jupyter. The first thing to do is to import the cadabra2 module. To save typing, we will import everything into the global namespace.
from cadabra2 import *
from IPython.display import display, Math, Latex
Expressions are declared by typing them as standard LaTeX, and feeding that into the Ex object. The result is a standard Python object.
ex=Ex(r"A_{m n} B^{m n}")
Printing is still a bit messy in IPython/Jupyter, but you can get the nicely typeset form of the expression using the following:
display(Math(str(ex)))
Properties get assigned to symbols or patterns by using their Cadabra name,
Symmetric(Ex(r"A_{m n}"))
AntiSymmetric(Ex(r"B_{m n"))
Cadabra algorithms are ordinary python functions. They always act on the expression that you pass it, and modify it in-place. Here's an example: the contraction of an antisymmetric and a symmetric tensor is zero:
display(Math(str(canonicalise(ex))))
Let's do another example, with substitution. Note how indices get relabelled automatically.
Indices(Ex(r"{m,n,p,q,r,s,t}"))
ex=Ex(r"A_{m n} B^{m p} C_{p q}")
display(Math(str(substitute(ex, Ex(r"A_{m n} -> D_{m q} D^{q}_{n}")))))
If you are interested in more of this, get in touch by emailing me at info@cadabra.science !