An improved Maxima function for inverse Laplace transform

Maxima has a fairly serviceable Laplace transform utility built-in.  Here’s an example from the popular ordinary differential equations book by Blanchard, Devaney and Hall:

laplace1

Trouble arises when we look at discontinuous forcing functions, which is especially sad because it seems to me that’s what makes it worthwhile to spend time with Laplace transforms.  In particular, the inverse transform function ilt() fails on the Heaviside Function and Dirac Delta, even though the built-in laplace() treats them correctly:

laplace2

So, I’ve written an alternative inverse Laplace function laplaceInv() that fixes that problem:

laplace3

Here are a few differential equation solutions to show how the new function behaves:

A second-order linear equation with a constant forcing function that vanishes at t=7

laplace6

laplace7

A second-order equation with two impulsive forces:

laplace4

laplace5

The new Laplace transform Maxima function can be downloaded here.

Advertisements

Popularity of CAS programming languages: Maxima, Maple, Mathematica

A few months ago, inspired by the PYPL PopularitY of Programming Language,  I compared Google trends data for the 3M of CAS software:  Maxima, Maple, and Mathematica based searches of the form “<language> tutorial”.  The result was that Maxima seems to be slowly increasing in popularity  with about 20% of the interest in the 3M.

Today I saw another popularity metric: The TIOBE index.  Using their methodology of Google trends data for the search string <language> + programming, I have these  results for the proportion of searches among the 3M:

3MProgrammingProportions

An undocumented synonym for diff() in Maxima

Today, a student turned in some Maxima work for my class. I discovered he had successfully used the command derivative() in place of diff() with seemingly identical results.  I verified that the same thing works in several versions of Maxima I have installed on my windows computer.  Who knew?

diffderivative

Legend Position in Maxima Plots

Here’s something I just learned and want to share with others and record for my use the next time I need to do this and have already forgotten!

The position and appearance of the figure legend in Maxima plots drawn with plot() (by setting gnuplot_preamble) and in draw() (by setting user_preamble),  can be manipulated to any of the gnuplot options listed here.

Here are some examples:

plot_legend0

plot_legendtopleft

draw_legendatbox

A pause() function for Maxima

In MATLAB, pause interrupts execution of a loop until the user strikes a key, and pause(<n>) pauses for <n> seconds before resuming execution.
Here’s my attempt at a pause() function for Maxima that works in a similar way to MATLAB.  It uses Maxima’s read() to stop everything and wait for user input, and it uses the lisp function sleep to stop for a fixed number of seconds.
**note that a lisp function
     (function-name argument)
can be called inside Maxima as
     ?function-name(argument)
I’m not happy that in order to resume after the pause, the user needs to enter a valid character (space or nothing results in an error) followed by CTRL-SHIFT.  I hope to either figure something else out or even better hear suggestions from other Maxima users!
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("")
);
call this either as
     pause();
or, for a three second pause
     pause(pausetime=3);

Multiple plots in a single Maxima figure

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

2scenes

There’s an optional columns argument — the subplots are drawn row-wise in an array with the specified number of columns:

3scenes

And of course all this works for 3d plots using gr3d():

3dscenes