Eev hacks for Maxima
I use eepitch to send lines from Emacs to Maxima; see the figure below for the main idea, and my presentation at the EmacsConf2021 for the details. My default definition for eepitch-maxima is the simplest possible at the moment - I tried to write a variant that used Fermin MF's maxima-mode, but it behaved in a weird way when it had to sent empty lines. TODO: fix that.
The video below explains a way to run my executable notes on Maxima with eev without downloading anything extra. Click on the first screenshot to go to the page about that video, and click on the third screenshot to play the very nice demo that starts at 15:14.
Click on the second screenshot to play the video starting from 11:30. That part has a very technical explanation of the "...without downloading anything extra" - not very recommended! 😕
3. Embedding in LaTeX
Here is an example of how I am embedding Maxima code in LaTeX files. The trick that makes eepitch ignore a prefix is explained here. If I execute that eepitch block skipping the lines "load" and "display2d" I get a human-friendly output, as in the first screenshot below; if I execute the lines "load" and "display2d" I get an output that I can process with M-x emaxima-conv (that calls emaxima.lua) to obtain this LaTeX code, that becomes this in the PDF. This trick is based on the answers that I got for this question that I sent to Maxima mailing list; note that 1) I am using this copy of emaxima.sty that has two lines commented out, and 2) my emaxima.lua is a quick hack, and it should be converted to elisp at some point.
4. "Physicist's notation"
In 2022jan10 I sent to the Maxima mailing list this big e-mail, that had two parts. In the first part I asked about the (internal) differences between using expressions, like "f : x^2", and using functions, like "g(x) := x^3"; the code associated to that part is here. In the second part I asked if, and how, Maxima supports "physicists' notation" - where "physicists' notation" ("PN") is my informal name for a notation that is common in old books like this one by Silvanus Thompson. In PN variables and functions can share the same names, variables can be "dependent", some arguments can be omitted, and several abbreviations are standard - for example, if y=y(x) then the default meaning for y1 is y1=y(x1)=y(x0+Δx). It turns out that YES, Maxima supports physicists' notation, and it's easy to translate calculations in PN to Maxima if we use gradef and subst in the right way to translate between PN and "mathematician's notation". I recorded a 20s video demo-ing this - it's here, and its code is here. The slides on PN that I prepared for my course on Calculus 3 are here.
My first attempts to understand how Maxima implements the "#$expr$" syntax in Lisp are here: 1, 2, 3. Then Stavros Macrakis explained how I could define "dosimp" and "doeval" and I produced the example below. Its code is here. My long e-mail explaining why I am teaching substitution in this way is here (includes gossip).
To draw Maxima objects as trees - as in the first screenshot below - I use a program that is made of three files: luatree.mac, luatree.lisp, luatree.lua. Its git repo is here, and you can test it by running the test block at the end of luatree.mac. There is an explanation of luatree here.
The screenshot at the right below shows a (primitive) port of luatree to SymPy. Its code is here: luatree.py.
7. Maxima by Example
The best place for learning Maxima from examples is a (free) book whose name is - ta-daaa! - Maxima by Example. It is divided into chapters, and my script to download a local copy of it is here. Its chapter 13 is about QDraw, that is a front-end to Maxima's plot and draw commands; I find qdraw much easier to use than plot and draw - for example, the code for drawing the Lissajous figure with velocity and acceleration vectors below is just this.
8. Debugging the Lisp (with Sly)
Most people use Slime and Swank to debug the Lisp code of Maxima. I couldn't make Slime work with eepitch, so instead of Slime and Swank I'm using Sly, Slynk, and an eepitch-sly defined in this way, and I had to adapt these instructions. My code to use Sly and Slynk in Maxima is here: ~/.maxima/startsly.lisp.
See also this: eev-sly.html.