Computational symbolic mathematics

Cheating at calculus exams



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.

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 really amazing if they could even do matrix calculus but I’ll take what I can get and get the rest via Taylor expansions.

Tools

Famously Mathematica and MAPLE are the expensive options with big marketing budgets. Mathematica can do noncommutative algebra via a third party plugin.

Other options?

Sympy

Somewhat newer, 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.

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:

brew tap kpeeters/repo
brew install cadabra2
/usr/local/bin/python3 -m pip install sympy gmpy2

On linux or macos this works

conda config --add channels conda-forge
conda config --set channel_priority strict
#and then install these packages by using one of the following lines:
conda install cadabra2
conda install cadabra2-gtk
conda install cadabra2-jupyter-kernel

Maxima

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.

Singular

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 subsystem infrastructure for that and no clear guidance on which might do the things I want.

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.

PARI/GP

PARI/GP is a GPL package favoured by number theorists and has some 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.

Javascript

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

References

Blazek, Paul J., and Milo M. Lin. 2020. “A Neural Network Model of Perception and Reasoning.” February 26, 2020. http://arxiv.org/abs/2002.11319.
Brewin, Leo. 2009. “Riemann Normal Coordinate Expansions Using Cadabra.” Classical and Quantum Gravity 26 (17): 175017. https://doi.org/10.1088/0264-9381/26/17/175017.
———. 2019. “Using Cadabra for Tensor Computations in General Relativity.” December 18, 2019. http://arxiv.org/abs/1912.08839.
Clark, Peter, Oyvind Tafjord, and Kyle Richardson. 2020. “Transformers as Soft Reasoners over Language.” In IJCAI 2020. http://arxiv.org/abs/2002.05867.
Lamb, Luis C., Artur Garcez, Marco Gori, Marcelo Prates, Pedro Avelar, and Moshe Vardi. 2020. “Graph Neural Networks Meet Neural-Symbolic Computing: A Survey and Perspective.” In IJCAI 2020. http://arxiv.org/abs/2003.00330.
Lample, Guillaume, and François Charton. 2019. “Deep Learning for Symbolic Mathematics.” December 2, 2019. http://arxiv.org/abs/1912.01412.
Lozano-Duran, A, and M Bassenne. n.d. “Towards Model Discovery with Reinforcement Learning,” 11.
Peeters, Kasper. 2007. “Cadabra: A Field-Theory Motivated Symbolic Computer Algebra System.” Computer Physics Communications 176 (8): 550–58. https://doi.org/10.1016/j.cpc.2007.01.003.
———. 2018a. “Introducing Cadabra: A Symbolic Computer Algebra System for Field Theory Problems.” April 3, 2018. http://arxiv.org/abs/hep-th/0701238.
———. 2018b. “Cadabra2: Computer Algebra for Field Theory Revisited.” Journal of Open Source Software 3 (32): 1118. https://doi.org/10.21105/joss.01118.

No comments yet. Why not leave one?

GitHub-flavored Markdown & a sane subset of HTML is supported.