Hacker News new | past | comments | ask | show | jobs | submit login
Maxima – A Computer Algebra System built with Lisp (sourceforge.net)
173 points by dragonsh on Sept 14, 2020 | hide | past | favorite | 64 comments



Fricas (a fork of Axiom, which is a rename of Scratchpad 2) is another very old CAS implemented with Lisp, also now open sourced. I think Fricas is more powerful than Maxima (maybe much more) regarding symbolic integration and its type system, but it sadly has very few developers maintaining it.

Fricas links:

https://en.wikipedia.org/wiki/FriCAS https://fricas.github.io https://fricas.github.io/book.pdf

Axiom links:

https://en.wikipedia.org/wiki/Axiom_(computer_algebra_system... https://github.com/daly/axiom


There must be a reason that maxima is more widely used. Is Maxima easier to use? Or did maxima just have better distribution channels?


At least a couple of non-technical reasons: I believe Maxima was open sourced a few years earlier (1998 vs 2001) which helped it get established. Maxima was also supported by a rather prolific open source developer which probably helped a community coalesce around it. Axiom, on the other hand, looks like it was more of a 'throw it over the wall' open source project which only happened after it failed commercially.


Axiom is also not a normal Lisp program. Maxima can be loaded using ASDF and you can hack on it like any other Lisp project. Axiom in the other hand generates Lisp code from some other format and is rather incomprehensible to someone just coming into the project.

Not that Maxima is all that easy to understand either. The nature of the software makes it complicated, but there is code in there from the 60's, which carries with it some more the classic issues with Lisp code from that era, short symbol names, use of dynamic variables, etc.


Axiom is sort of like Scratchpad source code converted to Literate Programming, and since TeX is near impossible to build these days, that makes Axiom score low on the hackability scale. Fricas on the other hand is much easier to build. However a lot of the equations that are programmed into the system, are sort of like ASCII art mathematics that the system is trained to decipher. A lot of those certainly got handed down over the decades of people figuring things out at IBM.


> I think Fricas is more powerful than Maxima (maybe much more) regarding symbolic integration and its type system

Citations or proofs?


The linked Wikipedia page already mentions the Risch-Bronstein-Trager algorithm, which is supposedly implemented most fully in Fricas (i.e. Fricas or Axiom should, modulo bugs, be able to find an elementary function integral for any function that has an elementary function integral). But note that even in Fricas, there are still unimplemented cases of the "Risch algorithm" (and bugs), as the problem is hard and requires a lot of work and knowledge.

You probably want something more concrete, so take a look at this effort to test symbolic integration software using a common testsuite: https://www.12000.org/my_notes/CAS_integration_tests/reports...

Fricas scores quite a bit better than Maxima there, but note that there are big problems with the test, although there is a somewhat active effort to improve its accuracy. It is problematic (but understandable) that the test uses Sage, as the Sage interface to Fricas, at least, is imperfect. I.e., AFAIK some of the integration tests will fail simply because Sage fails to communicate with Fricas successfully.

Main page of the integration tests: https://www.12000.org/my_notes/CAS_integration_tests/index.h...

Fricas (and Axiom) also has a more well thought out type system (with type checking at time of compilation) than other computer mathematics systems, so writing Fricas programs (the language is called Spad, which presumably comes from Scratchpad) is nice. (Fricas can be used both interactively and as a compiled language.)

This mailing list discussion may also be of interest: https://groups.google.com/forum/#!topic/fricas-devel/xVtvZ46...


That's a very complete analysis. Thanks. I really wish researchers could spend their time developing on top of open sourced CAS engines.


https://www.12000.org/my_notes/CAS_integration_tests/reports... gives Fricas solving 68% of the integrals vs. Maxima's 43%


Does it come with proper equation printing?

A big problem for me getting into Maxima is that the frontends I've found are pretty unstable and the terminal version only does equations as ascii art, which I just cant' stand reading.


Fricas supports several different output formats including TeX and MathML, which can be toggled and redirected independently. (There is some relatively recent work on that front, so changes are possible. I hope interfacing with Fricas programmatically will become nicer.)

It's an ugly solution, but when an output expression is complicated enough that I want it nicely rendered, I copy the TeX output to, e.g., https://arachnoid.com/latex/ while removing the \leqno command and replacing \sp commands with carets (^).


You can use Maxima via Emacs with Latex output: https://www.emacswiki.org/emacs/MaximaMode


>pretty unstable

What do you mean? wxMaxima has worked fine for me.


I've had good success with wxMaxima as well, but none of the equations I've worked with can fill a blackboard. SymPy is very nice as well, but for obvious reasons, it feels a bit more forced when interacting with it.


Do you accept the output from Climaxima? Granted, the project isn't near finished (currently held back due to some dependency issues).

I included some example videos in this reply: https://news.ycombinator.com/item?id=24467593


I use Sympy interactively, and I don't know what you mean by "forced". It doesn't feel that way to me.


this is a bit rush, but an example setting up the quadratic equation.

  f(x) := a*x^2 + b*x + c
  solve( f(x),x );
  
  from sympy import symbols, solve
  a, b, c, x = sympy.symbols(('a', 'b', 'c', 'x'))
  y = sympy.Eq(a*x**2+b*x+c, 0)
  solve(y, x)


I would change the first two lines to:

  from sympy.abc import *
  from sympy import *
I would put that into a file, and auto-load it at startup so I don't need to run it manually every time - one way of doing that is using iPython profiles.

Also put this in your startup file to get more pleasant looking output:

  init_printing(use_unicode=True)
Once you've done that, you only need to type:

  y = a*x**2 + b*x + c
  solve(y,x)


SymPy already comes with `isympy` script that will import everything from SymPy and create some common symbols (x, y, z, t, k, m, n, f, g, h) using either `python` or `ipython` (default). To do what you said the following script may be run.

  #!/usr/bin/env python
  from sympy.abc import *
  from sympy import *
  import code
  init_printing()
  code.interact(local=locals())


Sympy can output to Latex or unicode - either looks good.


wxMaxima is a very good front end, which I have used for many years. You just need to make sure you get a stable version, not a development release.


Just use it with Emacs, equations will render in LaTeX


Of interest may be my project that implements a CLIM-based user interface on top of Maxima. It turns out that CLIM is perfect for this, as its idea of presentation forms matches the way mathematical expressions are represented in Maxima.

I have made a few videos showing how it works. It's also available on Flathub, or if you're brave you can build it yourself.

https://peertube.mastodon.host/videos/watch/df751bd5-5a26-44...

https://peertube.mastodon.host/videos/watch/b003360f-97a9-4f...

https://github.com/lokedhs/maxima-client


I love CLIM, too bad it's not used much. The whole idea of it is very interesting, an evolutionary dead end that in many ways seems far superior then what "modern" GUIs provide


I think there are more practical reasons why it's not used more. What you say is absolutely true of course, but the bigger issue is that McCLIM still has some technical issues.

What is really needed is a multiplatform backend that implements everything completely. Right now the only production grade backend is the CLX one, and even that one requires you to jump though hoops to get complete font rendering.

I built all of this into the flatpak distribution, but few people are willing to go through that just to distribute some software.


To my detriment, I avoided having to learn anything in my 2007 highschool online Algebra 2 class by simply feeding the equations into Maxima. That was the year I first started using Linux - a Ubuntu 8.04 install CD on a Linux magazine saved my laptop from a corrupted Windows Vista install while away from home.


I was doing my first Linux install around the same time. I ordered an install CD from both Ubuntu and Linux Mint; the Mint one came in first, so that's the OS I used for my first few years. I used the CD to make a bootable usb stick so that I could use the internet when my parents weren't home (they kept Windows password protected). I've never actually run Windows on a personal machine since I didn't have my own until college, and but that time I was a few years into my Linux journey.


For a bit of a Maxima vs Mathematica perspective, it is worth reading Fateman's review of Mathematics:

https://people.eecs.berkeley.edu/~fateman/papers/mma.review....


Beautiful writing: "... a critique of this aspect of the system will have to wait until the bugs are fixed and only the features remain."


Probably the most penetrating review I've ever seen, but only seen after we got somewhat burned by Mathematica early on.


I am often amazed that one can run Maxima on an Android phone (Maxima on Android), including Gnuplot graphics and MathJax math formulae:

  plot3d ([cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)), y*sin(x/2)], [x, -%pi, %pi], [y, -1, 1], ['grid, 50, 15]);

  /* gradient of the log-likelihood for a time-dependent accelerated failure time model */
  assume(t>0)$ H:-log(S(integrate(exp(alpha+beta*x(u)),u,0,t))); diff(delta*diff(H,t)-H,beta);
Axiom/Fricas is a beautiful language which provides a powerful mathematical type system.


Why are you amazed about that? A modern Android phone is a general purpose computer roughly as powerful as a 2010-2015 laptop. Math software like Maxima, Mathematica, Maple have a very long history and was widely used on 1980s/1990s hardware.


Because it is amazing? Intellectually I know all about Moore's law, but having a supercomputer in your pocket still feels like science fiction in reality. There's no reason to push that feeling away.


But things like plotting a simple function, 3D or not, are vastly less performance-intensive than almost all other things that people do with their phones, like rendering just about any modern webpage. Never mind actually demanding things like playing 3D games (doing that on a cellphone was indeed rather amazing back in 2011, being accustomed to mobile games mostly being simple 2D affairs).


I recently pulled out an old 2008 unibody Macbook pro just to play around on. It was a nearly %100 CPU utilization just attempting to play a 4K youtube video. That's something my $400 phone doesn't even break a sweat on. It's amazing how well cell phones have been optimized in the last decade.


That one's probably thanks to hardware h.264/265 decoding. That poor 2008 MBP likely has to do all the heavy lifting in software…


Indent by two spaces if you want to quote some code, otherwise the asterisks get turned into italics.

  plot3d ([cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)), y*sin(x/2)], [x, -%pi, %pi], [y, -1, 1], ['grid, 50, 15]);


Thank you - now edited.


Used Maxima to find some analytical differentials. It is very powerful but documentation could be a pain to decipher if you're new


See also, computer algebra library for Scheme:

https://github.com/dharmatech/mpl


How does it compare with JACAL, which is the old Scheme one I know? https://people.csail.mit.edu/jaffer/JACAL


According to a file mpl.org in the repo linked, JACAL uses SLIB. Not sure if MPL does not, but I would assume that.

Not sure what difference it makes, but probably some.


If you want to see what it can do for you, wxMaxima is an easier entry, with at least an attempt at a GUI: https://github.com/wxMaxima-developers/wxmaxima/releases, although macOS is quite badly supported.


There is a maxima to python translation tool. It's good for sharing your maxima code with everyone else. https://gist.github.com/LakshyAAAgrawal/33eee2d33c4788764087...


Hey, happy to see this mentioned. I am the developer of Maxima's Pytranslate, developed as a GSoC project.

Would be happy to answer any questions about it.


This is nicee... With this we can bridge between historic Maxima and technology of present aka Python. As they say “It is in the roots, not the branches, that a tree’s greatest strength lies.”


Thank you for the kind words..


I think sagemath uses this for their symbolic package


That is correct. We embed Maxima at the C level using ECL for much better performance than one might expect (basically call Maxima from python very efficiently in the same process!).


Prof Stein,

I am pleasantly surprised to get a reply from you! I have one question, How often is Sympy used in Sagemath compared to Maxima?

Or rather when I do symbolic math in sagemath, do I ever hit Sympy?


Is this related to macsyma?


Yes, "Under the name of Maxima, it [Macsyma] was released under the GPL in 1999, and remains under active maintenance." https://en.wikipedia.org/wiki/Macsyma


Maxima was the port of Macsyma to Franz Lisp at UC Berkeley done by Prof. Fateman and his students. Franz Lisp was written to be Mac Lisp compatible for the sole purpose of running Macsyma. Prof Fateman worked on Macsyma at MIT.


And today Franz Lisp is instrumental in running older maclisp programs because the Franz lisp binaries still run unmodified on current BSD releases (with kernel compatibility turned on).


That's amazing. VAX or 68k binaries?


Less exciting than that, the first BSD port.

Details are here: https://github.com/turbo/netlisp


Try to CTRL-F for Macsyma on the linked Maxima homepage.


How does this compare to Sage?


Sage is a python wrapper around other systems such as Maxima or Fricas.


Does sage also handle numerical stuff? The impression I got was that it was a bit more general than Maxima.

However, I am terribly frightened by programs like this, as I suspect they are much smarter than me, so I tend to avoid them.


Yes, Sage includes Python and the Python numerical stack (numpy, scipy, etc). It also has a lot of new code related to interval arithmetic (arbitrary precision numerical computation with proven error bounds).


I do numerical linear algebra stuff, but every time I hear about interval arithmetic my ears perk up. It just seems like our error bounds require caveats (a-hah, I actually gave you the backward error, nyaah!) while theirs are just numbers.


See https://en.wikipedia.org/wiki/SageMath#Software_packages_con... for an overview of what Sage contains. Sage is like a colonial organism rather than an individual, and maxima is one of the packages that provides CAS features in Sage. Some other packages like SymPy, do too :)

The integration between the various packages in sage it exists, but it's a bit clunky.


Sage is everything and the kitchen sink. Numerical, analytical, integer, all accessible from a leaky python abstraction.

Your python code will look a lot like calls to maxima, which will happen under the hood.

You can think of it like bash, as a contrived example, most sage programs would be like calling an inline python script to find all files whose size is an even number of bytes, passing the results through pipes, pretty printing them with ls and finally sorting them alphabetically with sort.

Whether you think this is good or bad depends on how familiar you are with the underlying systems. I think that it's great since I can use one program to dispatch whatever I need to the correct state of the art project and get a result that with a bit of massaging can be fed into another project.




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

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

Search: