In MATLAB, I occasionally have need for the plotyy() command for making a plot of two different functions with widely varying scales.
Turns out Maxima draw has an equivalent functionality by setting the option yaxis_secondary:
pause([options]):=block([tsecs], tsecs:assoc('pausetime,options,0), if tsecs=0 then read("Execution Paused...enter any character then CTRL-ENTER") else( disp(sconcat("paused for ", tsecs," seconds")), ?sleep(tsecs)), return("") );
In MATLAB, I often use the subplot() command to make an array of multiple plots in a single figure.
In Maxima, we can achieve that by generating each of the subplots using gr2d(), and then putting them all together with a call to draw() or wxdraw():
There’s an optional columns argument — the subplots are drawn row-wise in an array with the specified number of columns:
And of course all this works for 3d plots using gr3d():
Notepad++ is lots of people’s favorite text editor for Windows. I use it every day.
A little googling around led me to a Notepad++ user-defined syntax highlighting file for the Maxima language, written by David Scherfgen and shared at the Maxima-Discuss list.
I made a little change to the file that overcame a nagging difficulty — I found that .mac file extensions weren’t automatically being recognized upon opening.
To include Maxima syntax highlighting in Notepad++ do this:
I was looking recently at the PYPL PopularitY of Programming Language.
That site ranks popularity of programming languages (Java is #1) using Google Trends tools based on searches of the form <Language Name> Tutorial. I did my own Google Trend search, comparing the 3M of Computer Algebra Systems: Maple, Mathematica, and Maxima using the Tutorial criteria as at PYPL.
With the data from Google Trends, I computed the proportion of the total 3M monthly searches for each program. Here’s how that looks over time since 2004:
It appears to me that Maxima is slowly and steadily gaining with nearly 20% share, Maple is currently at about 30%, and Mathematica at 50%. Does anybody know what happened between 2006 and 2013 to account for the increase in popularity of Mathematica and decrease for Maple?
I’ve put together a collection of functions — some direct quotes of other contributed functions, some renamed or repackaged, and some newly implemented — for various needed tasks in my undergraduate ordinary differential equations course.
The package includes my home-grown help utility.
You can download the package MATH280.mac
…and if you’re interested, here’s my multivariable calculus package MATH214.mac
MATH280.mac contains: wxphaseplot2d(s) wxphaseplot3d(s) phaseplot3d(s) wxtimeplot(s) plotdf(rhs) wxdrawdf(rhs) sol_points(numsol,nth,mth) rkf45(oderhs,yvar,y0,t_interval) BDF2(oderhs,yvar,y0,t_interval) BDF2a(oderhs,yvar,y0,t_interval) odesolve(eqn,depvar,indvar) ic1(sol,xeqn,yeqn) ic2(sol,xeqn,yeqn,dyeqn) eigU(z) eigdiag(z) clear() - - for any of the above functions, help(function_name) returns help lines for function_name - Last Modified 5:00 PM 3/27/2017
There is an undocumented user-contributed feature of Maxima for rational inequalities: solve_rat_ineq().
Here are few examples of its capabilities and limitations:
Yesterday I needed a cumulative sum function in Maxima to do the job of cumsum() in R and MATLAB, but couldn’t find anything. So here’s a one-liner that does the trick for a list:
After not easily finding such a thing from a cursory search of the Maxima documentation, I spent a few hours over the weekend beginning to write a Maxima function to compute, for any given square matrix , an invertible matrix so that
where is the Jordan matrix that displays the eigenvalue/vector structure of .
It took several searches for me to find, but of course there’s already such a function — with a not so easily searched-for name — in the diag package: ModeMatrix()
To see just the matrix , diag provides jordan() and dispJordan()
In a previous post, I included my little coding project to implement a general backsolve() function to use with the built-in maxima matrix function echelon(), producing an easy-to-call matrix solver matsolve(A,b). The result is meant to solve a general matrix vector equation , including cases when is non-square and/or non-invertible.
Here’s a quicker approach — convert the matrix into an explicit system of equations using a vector of dummy variables, feed the result into the built-in Maxima function linsolve(), and then extract the right hand sides of the resulting solutions and put them into a column vector.
The two methods often behave identically, but here’s an example that breaks the linsolve() method, where the backsolve() method gives a correct solution:
*Note, I’ve found that the symbol rhs is a very popular thing for users to call their problem-specific vectors or functions. Maxima’s “all symbols are global” bug/feature generally wouldn’t cause a problem with a function call to rhs(), but the function map(rhs, list of equations) ignores that rhs() is a function and uses user-defined rhs. For that reason I protect that name in the block declarations so that rhs() works as expected in the map() line at the bottom. I think I could have done the same thing with a quote: map(‘rhs, list of equations).
matsolve2(A,b):=block( [rhs,inp,sol,Ax,m,n,vars], [m,n]:[length(A),length(transpose(A))], vars:makelist(xx[i],i,1,n,1), Ax:A.vars, inp:makelist(part(Ax,i,1)=b[i],i,1,n,1), sol:linsolve(inp,vars), expand(transpose(matrix(map(rhs,sol)))) );