Movatterモバイル変換


[0]ホーム

URL:


Cadabra
a field-theory motivated approach to computer algebra
[download]
Download
[cadabra in jupyter]
Jupyter
[quick start]
Quick start

[help]
Help & book
[tutorials]
Tutorials
[features]
Reference
manual
[paper]
Papers

[user notebooks]
User
notebooks
[contribute]
Contribute

[people]
People
[license]
License
[github]
Source

Cadabra quick start

This is a quick start introduction to Cadabra. For more in-depthdiscussion of its features, consult the varioustutorials.After installation, Cadabra can be started withcadabra2-gtk from the command line, or by picking it from the 'Education' menu.

Bosonic basics

Before discussing actual calculations, let us start with a few wordsconcerning notation. This discussion can be short because mathematical expressions are enteredessentially as one would enter them in TeX (with a few restrictionsto avoid ambiguities, which we will discuss as we go along). In orderto manipulate expressions, Cadabra often needs to know a bit more aboutproperties of tensors or other symbols. Such properties are enteredusing the '::' symbol. A simple example is the declaration ofindex sets, useful for automatic dummy index relabelling. An examplewill clarify this,
{ a, b, c, d }::Indices;ex:= A_{a b} B_{b c};
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left[a, b, c, d\right].\)
\(\displaystyle{}A_{a b} B_{b c}\)
substitute(_, $B_{a b} -> C_{a b c} D_{c}$ );
\(\displaystyle{}A_{a b} C_{b c d} D_{d}\)
The automatic index relabelling which has taken place in thissubstitute command was clearly only possible because of the propertydeclaration in the first line. Note how the substitute command hasalso figured out thatB_{a b} on the left-hand side isequivalent toB_{b c}, without any explicit wildcards orpatterns. We will see more of this type of field-theory motivatedlogic throughout the paper.
Indices can be simple letters, as in the example above, but it is alsoperfectly possible to put accents on them. This can be useful fore.g. notations involving chiral spinors. The following exampleillustrates the use of accents on indices.
\dot{#}::Accent;A_{\dot{a} \dot{b}}::AntiSymmetric;ex:= A_{\dot{b} \dot{a}};
canonicalise(_);
\(\displaystyle{}-A_{\dot{a} \dot{b}}\)
Here we also see a second usage of property declarations: theconstruction in the first line declares that the $A_{\dot{a} \dot{b}}$tensor is antisymmetric in its indices. The canonicalise commandsubsequently writes the input in a canonical form, which in thistrivial example simply means that the indices gets sorted inalphabetical order. Continuing the example above, one can also usesubscripts or superscripts on indices, as in the example below.
{ a_{1}, a_{2}, a_{3}, a_{4} }::Indices(vector);ex:= V_{a_{1}} W_{a_{1}};substitute(_, $V_{a_{2}} -> M_{a_{2} a_{1}} N_{a_{1}}$ );
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left\{a_{1}, \mmlToken{mo}[linebreak="goodbreak"]{} a_{2}, \mmlToken{mo}[linebreak="goodbreak"]{} a_{3}, \mmlToken{mo}[linebreak="goodbreak"]{} a_{4}\right\}.\)
\(\displaystyle{}V_{a_{1}} W_{a_{1}}\)
\(\displaystyle{}M_{a_{1} a} N_{a} W_{a_{1}}\)
The input format is a mixture of Cadabra's own LaTeX-like language forthe description of mathematical expressions, and Python. Theunderscore symbol '_' always refers to the last-used expression.
A guiding principle in Cadabra is that nothing ever has to be declaredunless this is absolutely needed. This is in contrast to many othersystems, where for instance one has to declare manifolds and indexsets and so on before one can even enter a tensor expression. Thismakes code hard to read, but more importantly, such additionaldeclarations are hard to remember. As an example of how Cadabra works,one can e.g. input tensor expressions and perform substitution on them,without ever declaring the symbols used for indices. Only when theprogram needs to generate new dummy indices does one need to declareindex sets, so that dummy indices can be taken out of the rightset. The general guideline is that "one onlyneeds to tell the program about the meaning of symbols when this isactually required to do the manipulation correctly".
In order to declare symmetries of tensors, it is possible to usesimple shorthands like theAntiSymmetric in the example above. More generally, symmetries can be declared using a generic Youngtableau notation. An object with the symmetries of a Riemann tensor,for example, can be declared as in the following example.
R_{a b c d}::TableauSymmetry(shape={2,2}, indices={0,2,1,3}).ex:=R_{a b c d} R_{d c a b};canonicalise(_);
\(\displaystyle{}R_{a b c d} R_{d c a b}\)
\(\displaystyle{}-R_{a b c d} R_{a b c d}\)
The first line indicates that the tensor has the symmetries of the$2\times 2$ Young tableau. Thecanonicalise command writesthe input in canonical form with respect to mono-term symmetries(anti-symmetry in the two index pairs and symmetry under pairexchange). The Ricci symmetry is also encoded in the Young tableau andwill be discussed later. Many tensor symmetries have shorthandnotations, so one often does not have spell out the tableau (e.g.RiemannTensor orSatisfiesBianchi).

Derivatives and dependencies

There are relatively few surprises when it comes to derivatives.It is possible to write derivatives with respect to coordinates,i.e. write $\partial_x$ where $x$ is a coordinate, butit is also possible to use indices, as in $\partial_i$ with $i$ beinga vector index. It is also possible to make objects implicitlydependent on a derivative operator, so that one can write $\partialA$ without an explicit specification of the coordinate which isinvolved here.
In order to make this possible, however, derivative objects have to bedeclared just like indices, otherwise the system does not know whichsymbol ($\partial$, $D$, $d$, $\nabla$, ...) one wants to use forthem. Implicit dependencies of objects on coordinates associated toderivatives is indicated through aDepends property. Here is anexample to illustrate all this:
{m,n,p,q,r}::Indices(position=free);\nabla{#}::Derivative;\partial{#}::PartialDerivative;A_{m n}::AntiSymmetric;V_{m}::Depends(\nabla{#});ex:= \partial_{m p}( A_{q r} V_{n} ) A^{p m};
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left\{m, \mmlToken{mo}[linebreak="goodbreak"]{} n, \mmlToken{mo}[linebreak="goodbreak"]{} p, \mmlToken{mo}[linebreak="goodbreak"]{} q, \mmlToken{mo}[linebreak="goodbreak"]{} r\right\}.\)
\(\displaystyle{}\text{Attached property Derivative to }\nabla{\#}.\)
\(\displaystyle{}\text{Attached property PartialDerivative to }\partial{\#}.\)
\(\displaystyle{}\text{Attached property AntiSymmetric to }A_{m n}.\)
\(\displaystyle{}\text{Attached property Depends to }V_{m}.\)
\(\displaystyle{}\partial_{m p}\left(A_{q r} V_{n}\right) A^{p m}\)
canonicalise(_);
\(\displaystyle{}0\)
ex:=\nabla_{m p}( A_{q r} V_{n} ) A^{p m};canonicalise(_);
\(\displaystyle{}\nabla_{m p}\left(A_{q r} V_{n}\right) A^{p m}\)
\(\displaystyle{}-\nabla^{m p}\left(A_{q r} V_{n}\right) A_{m p}\)
unwrap(_);
\(\displaystyle{}-A_{q r} \nabla^{m p}{V_{n}} A_{m p}\)
Note how the symmetry of a double partial derivative has automaticallybeen taken into account (itis part of thePartialDerivative property). This is called"property inheritance".

More to follow ...

Copyright © 2001-2025 Kasper Peeters
Questions?info@cadabra.science

[8]ページ先頭

©2009-2025 Movatter.jp