from Hacker News

Maxima in the browser using Embedded Common Lisp on WASM

by v9v on 1/28/25, 3:37 PM with 53 comments

  • by r85804306610 on 1/28/25, 4:09 PM

    because nobody knows maxima, some things to try. also plot2d/plot3d work, so that's pretty neat. the whole thing is powered by https://ecl.common-lisp.dev and the op announcement is here https://mailman3.common-lisp.net/hyperkitty/list/ecl-devel@c...

      :lisp (+ 2 2)
      solve(f(x)^2-1,x);
      integrate(x^2,x);
      2^1024;
      factor(30!);
      a:1
      b:2
      a+b;
      sqrt(a^2+b^2);
      expr: log((x+2)*(x-2))+log(x);
      ratsimp(expr);
      fullratsimp(expr);
      trigsimp(2*cos(x)^2 + sin(x)^2);
      solve(x^3=1,x);
      diff(sin(x), x);
      float([%e,%pi,%phi,%gamma]);
      f(x):=x^2;
      f(10);
      taylor(sin(x),x,0,5);
      plot2d(x^2-x+3,[x,-10,10]);
      plot2d([x^2, x^3, x^4 -x +1] ,[x,-10,10]);
      f(x,y):= sin(x) + cos(y);
      plot3d(f(x,y), [x,-5,5], [y,-5,5]);
  • by unusual-name on 1/28/25, 4:23 PM

    We used maxima extensively in high school. I remember that I forgot to bring my laptop when we had our first maxima lesson. My teachers understandably scolded me for not bringing my laptop to school, but to their surprise I found an online version of maxima. [1] While it was good enough for this period, in contrast to this implementation it was truly awful.

    I just think it's kinda sad that a lot of people never heard of maxima, as it is a pretty decent tool once you learn how to use it.

    [1] http://www.dma.ufv.br/maxima/index.php

  • by veryveryold on 1/28/25, 4:16 PM

    (to_lisp); (loop for i below 1000000 count t) takes 0.34 seconds on my system with vanilla maxima (on gcl). In the browser it takes about 7 seconds, so it must be a factor of 21 in computer time. Using sbcl outside maxima it takes 0.002 seconds. So one can get some idea about performance.

    Perhaps it could be combined with J (array language), like in the playground https://code.jsoftware.com/wiki/Playground that is using webassembly

    It seems to work very well locally without connection to the web.

  • by v9v on 1/28/25, 3:56 PM

    Raymond Toy posted this on the ECL mailing list: https://mailman3.common-lisp.net/hyperkitty/list/ecl-devel@c...
  • by vindarel on 1/28/25, 11:31 PM

    I'll add options to run Maxima:

    * [Maxima on Android](https://play.google.com/store/apps/details?id=jp.yhonda), built with ECL.

    * [Maxima on Jupyter](https://github.com/robert-dodier/maxima-jupyter)

    * Maxima can be used via [SageMath](https://www.sagemath.org/) and [KDE Cantor](https://apps.kde.org/cantor/).

    * Of course, with Emacs: [maxima-mode](https://gitlab.com/sasanidas/maxima) ([screenshot](https://community.linuxmint.com/img/screenshots/maxima-emacs...))

    and [maxima-interface](https://github.com/jmbr/maxima-interface) to ease the interface between Maxima and Common Lisp.

    * it can be used [from a Lisp REPL](https://mahmoodsheikh36.github.io/post/20230510181916-maxima...).

    (and [wxMaxima](https://wxmaxima-developers.github.io/wxmaxima/): a graphical frontend as mentioned earlier)

    (find the links and more scientific libraries for CL on https://github.com/CodyReichert/awesome-cl)

  • by phoe-krk on 1/28/25, 9:28 PM

    It's called "Embeddable Common Lisp", not "Embedded Common Lisp".

    https://ecl.common-lisp.dev/

  • by magicalhippo on 1/28/25, 4:08 PM

    I've tried Maxima on a few occasions but the syntax somehow fails to agree with me.

    Been looking for a self-hosted alternative to Wolfram Alpha, and just stumbled over Mathics, which has a Django front-end[1]. Rough but usable Mathematica alternative, at least for basic use.

    [1]: https://github.com/Mathics3/mathics-django

  • by maple3142 on 1/28/25, 6:21 PM

    Similar project: PARI/GP on WASM https://pari.math.u-bordeaux.fr/gpexpwasm.html
  • by trott on 1/29/25, 1:32 AM

    How do Maxima and SymPy compare in terms of capability, features and speed (native, not WASM)?
  • by fsckboy on 1/28/25, 6:00 PM

    tangential: can Macsyma/Maxima do symbolic boolean algebra, reducing formulae to bog standard "OR of ANDs" form?

    (I've tried looking at the doc, and it's clearly not a feature they showcase, and as others have said, the way it works is not intuitive to me. I really need this, but trying to do it in lisp is becoming its own project and I want to get back to my project. I found some really nice online reducers, but the UIs are not conducive to pasting/putting in simultaneous equations, and using those outputs as inputs again)

  • by azakai on 1/28/25, 7:01 PM

    It looks like the wasm file here is not fully optimized. Reading the wasm and JS, I'd guess -O1 perhaps? Linking with -O3 would make it smaller and possibly faster (10% smaller binary in a quick local test, and it removes 90% of locals, which should speed things up too)

    But it is possible that it's already fast enough for the purposes here, and this doesn't matter.

  • by fud101 on 1/29/25, 2:24 AM

    I love Maxima, i don't really need a CAS much these days but whenever I do, I will turn to Maxima.
  • by hackernj on 1/28/25, 4:11 PM

    Nice. I've been using this Maxima interpreter: http://www.dma.ufv.br/maxima/index.php
  • by gtpedrosa on 1/28/25, 8:28 PM

    This brings back memories. We used this in my mechanical engineering mechanisms class. It was cool to have the (simplified!) symbolic formulas describing the movements we were designing.
  • by phkahler on 1/28/25, 7:34 PM

    Is there a place to get a wxmaxima installer for Windows other than SourceForge? I no longer trust stuff from there.
  • by soegaard on 1/28/25, 9:04 PM

    This is great?

    Feature request: A way to easily copy old expressions into the current input field (to fix mistakes).

  • by dartos on 1/28/25, 5:16 PM

    How did you get Common Lisp running on wasm? I thought wasm didn’t support tail call recursive
  • by openrisk on 1/28/25, 5:20 PM

    omg, macsyma is still alive and I can now manipulate real tensors in the browser?