# Computational symbolic mathematics

Cheating at calculus exams

October 13, 2016 — May 11, 2021

A.k.a. computer algebra systems, which is correct but not descriptive enough to be helpful. For now I am simply noting down systems that solve particular problems for me without pretence to general usefulness.

## 1 How do computational symbolic mathematics work

Long story of which I understand only tiny fragments.

However, I’m in ML now, so let us take an obligatory second to consider how it mathematics might be performed with neural nets (Lample and Charton 2019). The linked method looks like a heinous hack at first glance, but maybe it is suggestive of the potential differentiable search in the future? This kind of neural automata has much hype but ends up being tricky in to make general. Something like it is making gains in Natural language processing, though where transformer models are making headway so, hang around.

OK, that solves no immediate problem for me; let us look actual tools. I am especially interested in ones that can do abstract non-commutative algebra; in this area my needs are very basic; multiplying expanding and factorising non-commuatative associative objects would be swell. It would be amazing if they could even do matrix calculus but I’ll take what I can get and get the rest via Taylor expansions.

## 2 Tools

Famously Mathematica and MAPLE are the expensive options with big marketing budgets. Mathematica can do noncommutative algebra via the NCAlgebra library.

Other options?

### 2.1 Sympy

Open source and new sympy:

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python.

It has basic differential geometry support, interesting Geometric Algebra stuff, called GAlgebra, (see also the manual) which is a selling point since Mathematica is kinda crappy for that.

Sympy is an infrastructural component of omnibus maths system sagemath, which also incorporates some of the others systems here — e.g. I think it includes maxima, cadabra and maybe singular.

#### 2.1.1 Cadabra

Brewin (2009);Brewin (2019);Peeters (2007);Peeters (2018b);Peeters (2018a). macos/linux.

Somehow connects to the Sympy ecosystem although in a confusing way, Cadabra: a field-theory motivated approach to computer algebra:

- Designed for field-theory problems, with handling of anti-commuting and non-commuting objects without special notations for their products, gamma matrix algebra, Fierz identities, Dirac conjugation, vielbeine, flat and curved, covariant and contravariant indices, implicit dependence of tensors on coordinates, partial and covariant derivatives…
- Powerful tensor simplification algorithms, not just for mono-term symmetries but also for multi-terms symmetries like the Bianchi identity, or dimensionally-dependent symmetries like the Schouten identity.
- Allows for both abstract and component computations.
- A standalone graphical notebook interface which can also be used as a front-end for SymPy.
- Input and output using a subset of LaTeX notation.
- Programmable using Python.

I think it uses Sympy under the hood, but implements its own notebook interface. Looks like the cleanest UI on offer here, which is to say, I am not sure if it is helpful but at least I should be able to find out expeditiously.

On macos this works:

On linux or macos this works

### 2.2 Maxima

Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, sets, lists, vectors, matrices and tensors. Maxima yields high precision numerical results by using exact fractions, arbitrary-precision integers and variable-precision floating-point numbers. Maxima can plot functions and data in two and three dimensions. […]

Maxima is a descendant of Macsyma, the legendary computer algebra system developed in the late 1960s at the Massachusetts Institute of Technology. It is the only system based on that effort still publicly available and with an active user community, thanks to its open source nature. Macsyma was revolutionary in its day, and many later systems, such as Maple and Mathematica, were inspired by it.

### 2.3 Singular

Singular is a computer algebra system for polynomial computations, with special emphasis on commutative and non-commutative algebra, algebraic geometry, and singularity theory. It is free and open-source under the GNU General Public Licence. …

Its main computational objects are ideals, modules and matrices over a large number of base rings. These include

- polynomial rings over various ground fields and some rings (including the integers),
- localizations of the above,
- a general class of non-commutative algebras (including the exterior algebra and the Weyl algebra),
- quotient rings of the above,
- tensor products of the above.
Singular’s core algorithms handle

- Gröbner resp. standard bases and free resolutions,
- polynomial factorization,
- resultants, characteristic sets, and numerical root finding.

Singular also seems to be rather confusing, and it is not clear how I would expand a non-commutative polynomial and collect like terms, for example; there is a profusion of different subsystems of infrastructure for that and no clear guidance on which might do the things I want.

### 2.4 Magma

Magma positions itself as

… a large, well-supported software package designed for computations in algebra, number theory, algebraic geometry and algebraic combinatorics. It provides a mathematically rigorous environment for defining and working with structures such as groups, rings, fields, modules, algebras, schemes, curves, graphs, designs, codes and many others. Magma also supports a number of databases designed to aid computational research in those areas of mathematics which are algebraic in nature. The overview provides a summary of Magma’s main features.

It seems like it might support non-commutative algebras but I cannot really work it out from the rather dense manual, and I will try this last since buying Magma is complicated and mysterious — maybe also expensive not just in time but in cash, but it is hard to know without investing yet more time.

### 2.5 PARI/GP

PARI/GP is a GPL package favoured by number theorists and supports fun stunts and has a lot of functions for modular forms, plus the ability to convert some number theoretic stuff to native C code. I do not need any of these tools.

### 2.6 Javascript

Weirdly, there is a javascript symbolic math library, nerdamer. Bare bones but, I suppose, useful in javascript machine learning.

## 3 Proof assistants

## 4 References

*arXiv:2002.11319 [Cs, q-Bio]*.

*Classical and Quantum Gravity*.

*arXiv:1912.08839 [Gr-Qc]*.

*IJCAI 2020*.

*IJCAI 2020*.

*arXiv:1912.01412 [Cs]*.

*Computer Physics Communications*.

*arXiv:hep-Th/0701238*.

*Journal of Open Source Software*.