Hacker News new | past | comments | ask | show | jobs | submit login
Symbolic mathematics on Linux (lwn.net)
209 points by leephillips on Jan 6, 2017 | hide | past | favorite | 71 comments



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.


The Emacs Wiki does describe it as the "poor man's Mathematica". Org-tables with Calc functions are also quite nice.


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


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


I always facepalm when I do math outside of Emacs. Calc was never really advertised, it's not a toy.

Also I've heard it might be scraped from vanilla emacs and made into an extesion, but I may be confused.


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

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


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


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


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.


I hit a brickwall too, even though the idea behind Lagrangian Physics felt so natural to me, I still trying to re-read books about the subject on a regular basis (very often it's all it takes to get started on something).


Jack Wisdom actually uses it in his research, which is in solar system dynamics. I think he converts it to C though in order to run it faster.


Never occured to me to check him online https://nerdwisdom.com/tag/sicm/

Thanks


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...


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


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.


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

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


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


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.


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

https://github.com/mathics/Mathics http://www.mathics.org/


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.


+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.


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.


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


So true. A few weeks ago my TI v200 battery died and I went looking to "modernize my algebra workflow" (usually limited to multi parameters `solve` or `simplify` operations or matrix math).

I never heard of Maxima (and never went looking). It works fine (without even checking the manual). I see where TI stole their syntax from. I will need to read the manual to figure out how to input more complex equation systems into `solve`. I tried a few frontend. I prefer Cantor, but it has some visual bugs I reported to the Gentoo and KDE bug trackers. I might solve them at some point. The default terminal UI is cool, but not very readable and keyboard navigation isn't as fine as other solutions (it and looks fugly, and Lispy languages are unreadable (((()))))


No mention of Axiom: 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.


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?


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.


and uses a powerful type system...


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/

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/


Lots of alternatives in the answers to this Unix & Linux StackExchange question:

https://unix.stackexchange.com/questions/20438/open-source-c...


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


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.


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


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.


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


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.


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


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?



The official name is SageMath, but you can call it Sage for short.


Tried it. Dumps core as soon as it's started. I'll look for a place to file a bug report, but thought I would mention it here. Ubuntu 15.10.


I hope you can, someday! Unfortunately, I think Python (as an interface) is one of the things holding Sage back. I very much appreciate having a lispy, mostly functional language when writing mathematics oriented code.

And then, there are the docs....

I appreciate what you do, but your competition has a big manpower advantage and a huge head start. Like I said, I truly do hope you can beat Mathematica at its own game someday, but it doesn't look like that day will be anytime soon.


Keep your chin up. I also don't like hearing the naysayers, and we can still prove them wrong.

https://news.ycombinator.com/item?id=7483648

https://lobste.rs/s/eftgy8/switching_ubuntu_from_apple/comme...


Mathematica is super expensive for personal use, unfortunately. Good if you're really into it, but hard as an impulse buy (plus they discriminate based on country and double the price in some places).


Grab a Pi.

Might be slow, but if you set it up to just remote shell into it, then you do get access to Mathematica for a fairly small outlie.


Great way to experiment with the language, though, even if it is a bit slow. Can't argue with a $0 price, and the Pi is fun to play with by itself. :)


You could just emulate a Pi on an x86 PC and run it that way (though it'll probably be slower than a native Pi), see for example: http://www.linux-mitterteich.de/fileadmin/datafile/papers/20...


I use the Home Edition which I bought for just under $300 a while back.

It is a great mathematics playground, although, concerns over being able to peer review the engine or calcs in the software are valid, not for what I use it for.

It is like Emacs for me. I leave it open all day, and just play around in it. The multiple programming paradigms are fun too for coding practice.


It's showing me a price of $310 for the personal edition right now. I think that's worth it if you're going to get a couple hour's usage a month out of it.


In Japan it's $600. I wonder if there's any region checking...


Mathematica is one of the two pieces of proprietary software I use, but I no longer have a free (academic) license so I haven't used it in a while.

But it's very buggy on Linux, and did not work out of the box last time I tried it. It somehow violates the X11 protocols (some window managers have Mathematica-specific workarounds) and in my case the windows were all over and mouse clicks didn't hit the correct positions. I can't justify buying $300 worth of software I need twice a year and I can't trust to work correctly.

I've used SymPy and Maxima but they are not as easy to use. I managed with SymPy to get some results but they were not as well simplifies as Mathematica results. Maxima was nearly impossible to use for me as I have no background in symbolic computation and the documentation expects you to understand the algorithms (e.g. different methods for simplification).

The biggest plus of Mathematica is the docs. They have tons and tons of examples and every function is thoroughly documented. And it is easy enough for me to understand without a lot of math background.


I haven't tried every WM, but I have tried a few and never had a problem. But, yeah, given your issues with your chosen WM and lack of use, I can hardly blame you.


I use a niche WM, so I'm kinda asking for trouble. I'm pretty sure I would not get any support from them.

I noticed that i3 WM has Mathematica specific workarounds. Might be an issue with non-reparenting WMs in general.


> Mathematica is one of the two pieces of proprietary software I use,

One is the other one?


SketchUp for woodworking plans. I've yet to try a few of the open source CAD solutions, I might migrate if I find a good one. For more artistic modelling I use Blender.

I also play games on Windows/Steam but I could live without that. Openttd and Nethack would do :)


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


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.


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

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.


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).


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.


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

http://en.smath.info/

Anyone having experience with it?


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...


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


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/


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.


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.


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. :)


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.


You could style it up a bit for sure - on the other hand, that thing loads fast and is readable well. Reading it on a FullHD screen actually shows content instead of "cool" empty space where you have to scroll like a crazy man. There are too many pages in the current mainstream that make the fan of my i7-laptop spin up to the max just look fancy.


Who cares? It's fine, it does its job, it's clean and it's clear, no garbage.


Are you aware of what this site looks like?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: