
Symbolic mathematics on Linux - leephillips
https://lwn.net/SubscriberLink/710537/31440d3205ea5d83/
======
a_e_k
Emacs' calc can also be surprisingly powerful. Not quite at the level of
Maxima, but still perfectly capable of basic symbolic algebra and calculus,
arbitrary precision arithmetic, linear algebra, and other good things.

I use it quite heavily since it's right there in my editor. It's kind of like
a good-enough phone camera that's always close at hand vs. a dedicated camera
that's better but takes more effort to have ready.

~~~
pmiller2
That's neat. I had no idea calc could do calculus!

~~~
a_e_k
It can indeed! Adapting the first example from the article, in Emacs type:

    
    
        M-x quick-calc RET
        integ(exp(-x^2),x) RET
    

You'll see that it immediately responds back with:

    
    
        erf(x) sqrt(pi) / 2

------
joelg
Also worth noting is scmutils [0], which is a symbolic computing library for
MIT Scheme that Gerry Sussman [1] wrote and uses to teach 6.945 Symbolic
Systems and 6.946 Computational Classical Mechanics. The documentation is
sparse, but it's incredibly powerful, especially if you're already familiar
with Scheme.

[0]
[http://groups.csail.mit.edu/mac/users/gjs/6946/refman.txt](http://groups.csail.mit.edu/mac/users/gjs/6946/refman.txt)

[1] ... And many others including Hal Abelson and Jack Wisdom

~~~
agumonkey
I thought it was merely a starter kit for SICM not something used elsewhere.

~~~
analognoise
I wish I had the background to understand SICM. Tried to read it, failed
immediately.

~~~
thatcherc
Gotta say - the projects in the book made all the difference for me. It's one
thing to read their high level, notation-heavy chapters, but I found that
working through the exercises really solidified everything in my mind.

That said I got pretty lost near the end. I want to go back in a year or so
once I have a bit more math background.

------
infruset
This is probably obvious to most people here, but I just want to mention that
such software should not be trusted blindly for mathematical correctness. It
is easy in most computer algebra systems to find false results (and trivial if
it includes numerical computations).

An interesting related thread:
[http://mathoverflow.net/questions/11517/computer-algebra-
err...](http://mathoverflow.net/questions/11517/computer-algebra-errors)

~~~
mr337
I never thought of that, just assumed correctness is top priority, but like
anything bugs happen.

------
partycoder
There's a cloud version of Sage called SageMathCloud. Sage is supported in
many distributions, and is also available in a docker image for convenience.

Note that that's not all. Major commercial math packages like Maple,
Mathematica, Mathlab all support Linux as well.

Then you have Scilab, Octave, R, and many others... which happen to also be
integrated into Sage, that you can use independently or through some GUI.

------
n00b101
Also see PARI/GP [1] (specialized CAS for number theory) and GAP [2]
(specialized CAS for group theory). These systems are very prominent within
their fields.

[1]
[https://en.m.wikipedia.org/wiki/PARI/GP](https://en.m.wikipedia.org/wiki/PARI/GP)

[2]
[https://en.m.wikipedia.org/wiki/GAP_(computer_algebra_system...](https://en.m.wikipedia.org/wiki/GAP_\(computer_algebra_system\))

~~~
leephillips
These both happen to be included as components in Sage, which was why I didn't
mention them separately.

~~~
williamstein
And, they are both _very_ tightly integrated with Sage via C library
interfaces (between Python and Pari/GAP), which took many years of pain to
properly write and debug. I wrote the first versions of these interfaces, and
Jereon Demeyer and Nils Bruin massively improved and rewrote them over the
years. Much core functionality in Sage fundamentally relies on Pari and GAP in
order to work efficiently.

------
benley
Another cool one is Mathics, which is a Mathematica-like system implemented in
Python, using SymPy behind the scenes:

[https://github.com/mathics/Mathics](https://github.com/mathics/Mathics)
[http://www.mathics.org/](http://www.mathics.org/)

------
lacampbell
I strongly recommend maxima. Great tool, and a clean language as well. I am
shocked so few people have heard of it or use it.

~~~
williamstein
+1 -- Maxima is used under the hood for many key symbolic functions in Sage,
e.g., limits, symbolic integrals, many simplifications, etc. We Sage devs
(mainly Nils Bruin) also wrote a very efficient C-level bridge interface
between Python and Maxima, which uses ECL (embedded common lisp). We also try
to make Maxima easy to use from Sage, e.g., you can type "maxima(sage
expression)" to convert an expression to Maxima. Maxima developers regularly
post on the Sage mailing list too.

~~~
lacampbell
I am really glad to see Sage is still going strong. I used it years ago, back
when I still had delusions of trying to be a mathematician. Really useful
stuff.

~~~
williamstein
I was just checking recently, and was pleasantly surprised to see that the
amount Sage __development __, has gone up enormously in the last 2 years,
especially thanks to
Europeans![https://github.com/sagemath/sage/graphs/contributors](https://github.com/sagemath/sage/graphs/contributors)

------
torrent-of-ions
No mention of Axiom: [http://www.axiom-developer.org/](http://www.axiom-
developer.org/)

As far as I know, it's the only CAS to have a full implementation of the Risch
algorithm for symbolic integration, and it's also written in a literate
programming style.

~~~
jordigh
I've always wondered about the Risch "algorithm". It's not really an algorithm
because at one crucial step it says "determine if this expression is zero"
which is essentially an open problem. What is it that Axiom does? Does it find
antiderivatives where others fail?

~~~
thechao
The Risch "algorithm", in this sense, is an implementation of the Risch
decision procedure; in particular, the Risch-Bronstein-Trager algorithm.
Axiom's version was written, in large part, by Bronstein, himself. Axiom's
implementation is _complete_ in the sense of capturing the entire Risch
decision procedure for elementary functions: it either returns the
antiderivative or returns a proof that no such antiderivative exists.

However, while elementary functions are extremely important, they aren't the
whole story for functions; in that sense, Axiom is far weaker than, say,
Mathematica.

------
balnaphone
My favorite tools for symbolic math are Maxima as discussed in the article,
for interactive exploration, and GiNaC for large-scale computation.

[http://www.ginac.de/](http://www.ginac.de/)

GiNaC is really fantastic for problems where you have symbolic models that are
generated from large data sets, especially iterating between solvers and
symbolic forms.

For example, high-dimensional Cox proportional hazards models have semi-
parametric forms that require a mixture of symbolic and numeric computation.
In this case, our study run-time was over 3 days, over a few thousand cores.
Without compiling the numerics to native code, taking advantage of symbolic
simplifications, and calculating Hessians symbolically then evaluating
millions of times numerically, the same study would have required years of
runtime.

In a computer vision application, I used GiNaC::compile_ex for a similar
advantage, solving stochastic functional equations, and selecting optimal
model parameters, while accounting for noise. In a way, the massive boost in
symbolic + numeric speed made this practically interactive, since previous
models could be cached in a compiled form, meaning that instead of plodding
along, looking at a few stills here and there to see if the algorithms were
producing good results, I could use live video feeds and interactively get a
sense of whether the noise and stochastic model were functioning as intended.

One of the most fun programs I ever wrote is a program that generates symbolic
forms for stochastic models, runs them against live camera feeds, which in
turn generates optimal copulas and so on, that get reduced to C code, that
ultimately produces optimized VHDL. Every step involves iterations of symbolic
calculation, numeric calculation, and generating the code that will perform
the next step. The code is a mixture of C++ (model computations, camera IO,
optimal pipelining for VHDL), Octave (graphical views), R (statistical
routines), C (mostly generated code), Perl (code transformations), and VHDL
(mostly generated code). The only part that wasn't so fun was actually
invoking the windows-based Altera VHDL compiler, which could take an hour or
more to do the synthesis.

Also, GNU Octave also has a nice package ("symbolic") for using GiNaC
interactively.

[https://octave.sourceforge.io/symbolic/](https://octave.sourceforge.io/symbolic/)

------
teddyh
Lots of alternatives in the answers to this _Unix & Linux_ StackExchange
question:

[https://unix.stackexchange.com/questions/20438/open-
source-c...](https://unix.stackexchange.com/questions/20438/open-source-
computer-algebra-systems-for-linux/20441)

------
divbit
I don't see Maple mentioned, but that was occasionally useful for algebraic
geometry type stuff

[https://en.wikipedia.org/wiki/Maple_computer_algebra_system](https://en.wikipedia.org/wiki/Maple_computer_algebra_system)

~~~
stablemap
The article restricts itself to free and open source software. For algebraic
geometry I can usually get by with Macaulay2, which is mentioned at the end.

~~~
jordigh
What kind of computations do you do with it? What's your field (of study)?

------
pmiller2
I know it's proprietary as hell, but, honestly, you can't beat _Mathematica_
for general symbolic math use. It has an incredible array of libraries
available for just about every need, and the language is very pleasant to work
with.

~~~
williamstein
I've devoted my life to beating Mathematica for general symbolic math use.
Don't tell me I can't. :-)

~~~
Y_Y
I took a "Computer Algebra" class in undergrad which was taught entirely in
Mathematica. It was a lot of work to convert everything (and the instructor
would jokingly refer to me as "sage guy") but I got an awful lot out of using
Sage instead. What keeps me from using sage nowadays is that I have a great
jupyter workflow, and last time I used Sage it was just a worse version of
that with better symbolic support.

~~~
williamstein
Sage 7.4 now includes Jupyter as our main personal notebook UI.

~~~
leephillips
Just went to sagemath.org to check it out. The link to the changelog is
broken.

My editor was concerned about the two names, Sage and SageMath. As far as I
could tell they're just synonyms, but do you have any guidance about which is
to be used when?

~~~
williamstein
Thanks. In the meantime, see
[https://github.com/sagemath/sage/commits/master](https://github.com/sagemath/sage/commits/master)
or [https://git.sagemath.org/sage.git/](https://git.sagemath.org/sage.git/)

------
robmyzie2
No mention of Axiom/Fricas? IMO, they are the most powerful.

~~~
daly
[http://axiom-developer.org](http://axiom-developer.org)

Axiom was originally developed at IBM Research, was a commercial competitor to
Mathematica and Maple, has been open source since 2001.

------
infinity0
The article mentions a PPA for SageMath; in fact we recently (re)packaged
SageMath for official Debian, here:

[https://packages.debian.org/sid/sagemath](https://packages.debian.org/sid/sagemath)

If all goes well it will be in the next Debian stable. Please help test it! It
has ~180 build-dependencies, possibly the most of any Debian package.

------
BeetleB
I used Sage many years ago (around 2008/2009). Awesome project.

It had the "notebook" for Python before iPython itself had it (now called
Jupyter).

~~~
williamstein
Macsyma had a notebook long ago, which probably inspired Mathematica
notebooks. Those inspired an early IPython non-web notebook, developed by some
UCSD students in 2006. They demoed it at Sage Days 1 then, and me, Alex
Clemesha, and Tom Boothby spent 2006-2007 that building the first version of
the Sage notebook. Then a 16 year old kid in the Philippines (Tim Dummol) did
a truly massive amount of development on the Sage notebook. Mike Hansen and
Robert Bradshaw (lead dev of Cython) also did a lot around then. Then we all
kind of got tired of working on the Sage notebook, and I think Tim went off to
college, and it started to linger. IPython (now Jupyter) then got going in
around 2011, with very strong grant support from the Moore and Sloane
foundations, which Fernando Perez (and others) put a huge amount of work into
getting. In 2013, I bit the bullet and got back to web development (SaaS is
really important to bring open source to the masses), and have been working
fulltime (now with a team!) on SageMathCloud since then.

------
raphinou
I discovered this a couple of years ago, but never had the opportunity to use
it extensively:

[http://en.smath.info/](http://en.smath.info/)

Anyone having experience with it?

------
edejong
I'm always slightly sad to see a reference to TeXmacs [1], while it is not
developed anymore. Does anyone know why the project has been abandoned? Always
amazed by the beautiful layout of the interface.

[1] [https://www.ceremade.dauphine.fr/~mgubi/tm-
web/documents/tut...](https://www.ceremade.dauphine.fr/~mgubi/tm-
web/documents/tutorials/maxima-tutorial/maxima-tutorial.en.html)

~~~
jordigh
It was basically a one-man project by Joris van der Hoeven and nobody has come
to pick up the torch from him.

------
achamilt
Ket is a minimalist approach. It's a maths text editor. The basic idea is that
algebra is just rapid text editing. Equations are written in mark-down,
displayed in conventional notation and edited with Vim commands.
[https://sourceforge.net/projects/ket/](https://sourceforge.net/projects/ket/)

------
ecesena
Back in the days I used Magma for symbolic algebra/geometry. Not sure about
the status of the project today, but it had absolutely unique features to work
in extension fields, rings, and build abelian varieties on these.

------
slowrabbit
Why does lwn.net look like its straight out of the 90s? Poor ugly duckling...
surely there is a designer out there willing to give you some love.

~~~
anexprogrammer
You mean why does it load instantly, pulling 100K, and not need JS and Disqus
for comments? After a makeover it'll want to pull 2M+ for a short piece of
text and 5M if there's a few images.

Like with HN I prefer speed and simple for a _text_ medium over watching it
assemble load on demand JPGs like we're on dialup. :)

~~~
slowrabbit
lol you think pages in the 90s loaded instantly? No, poor design doesn't have
to do with loading time. CSS load time is minimal.

