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?

# Author: ejbarth

## 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:

## logabs, logarc: How to make integrate() return what you expect

## logarc

In the back of my calculus book there is a table of famous integrals. Here’s integral number 21 in that table:

From Maxima **integrate()**, I get

What’s going on?

Both forms give a workable antiderivative for the original integrand:

Furthermore, we believe that both forms are correct because of this helpful identity for hyperbolic sine:

Turns out (thanks to a Barton Willis for pointing me in the right direction) there’s a variable **logarc** that we can set to make Maxima return the logarithmic form instead of hyperbolic sine:

I haven’t yet encountered cases where this would be a bad idea in general, but I’ll update this if I do.

## logabs

In the first week of my differential equations course, we study methods of direct integration and separation of variables. I like to emphasize that the absolute values can lend an extra degree of generality to solutions with antiderivatives of the form

As an example, for the initial value problem

, ,

it is convenient for treating all possible initial conditions () in one step to use the antiderivative

However, Maxima omits the absolute values.

For this case, we could consider only the needed interval , but still…

Turns out we can set the Maxima variable **logabs** to make **integrate()** include absolute values in cases like this:

But then later in the course, I saw that **logabs** also impacts the Ordinary Differential Equation solver **ode2()**. I encountered an example for which Maxima, in particular **solve() **applied to expressions involving absolute value, didn’t do what I wanted with **logabs:true**

For the logistic equation

,

we expect that by separating variables we can obtain the solution

Here’s what happens when we use** ode2()** with and without **logabs:true**:

## Student Projects in Maxima Vol 1, Num 4: ODE Systems for Epidemiological Models

Student Projects in Maxima is an online project to disseminate work by undergraduate students using Maxima to reproduce published results in the sciences and social sciences.

Volume 1, Number 4 (2017) is devoted to Systems of Ordinary Differential Equations for SIR models in epidemiology.

Contents:

Emenheiser, Anna, *Virus Dynamics and Drug Therapy*

Radermacher, Erin, *A Model of the 2014 Ebola Outbreak*

Rafai, Sagar, *Analysis of Communicable Disease Models*

## Student Projects in Maxima Vol 1, Num 3: ODE Systems for Interacting Population Models

Student Projects in Maxima is an online project to disseminate work by undergraduate students using Maxima to reproduce published results in the sciences and social sciences.

Volume 1, Number 3 (2017) is devoted to Systems of Ordinary Differential Equations for non-chaotic predator-prey and other interacting population models

Contents:

Bhullar, Abhjeet, * Lions, Wildebeest and Zebras*

Goodin Aunic, *Parasitic Nematodes in Grouse*

DeFore, Brandon, *Breeding Suppression in Predator-Prey*

Jerez, Emilio, *Predator-Prey with Hawk and Dove Tactics*

Bontrager, Eric, *Predator-Prey with Prey Switching*

Beatty, Ethan, *Analysis of Logistic Growth Models*

Rice, Gabriel, *Pharmacokinetic Mechanism of Ethanol-Benzodiazepine Interactions*

Kay, Ian, *Radioactive Isotopes*

Wile, Jessica, *Ebola in Western Lowlands Gorillas*

Bailey, John, *Kinetic Modeling for Interconnected Reactions*

Piet, Joe, *Elephant and Tree Population Dynamics*

Kim, Judy, *A Model for West Nile Virus*

Kamalaldin, Kamalaldin, *Infected Prey in Polluted Environment*

Park, Kayla, *Ratio-Dependent Predator Prey Model*

Lundy, Liam,* Predator Prey in a Single Species with Cannibalism*

Orwin, Michael, *Interactions of Model Neurons*

Schultz, Pete, *Photosynthetic Oscillations*

Wadhwa, Raoul, *Dynamics in an Inflammation Model*

Del Olmo, Ricardo, *Population Growth and Technological Change*

Network Model of Cocaine Traffic in Spain Edited

Kill, Sean, *A Logistic Model with Varying Carrying Capacity *

McFadden-Keesling, Sophia, *Predator Prey Model with a Refuge*

## Student Projects in Maxima Vol 1, Num 1: Systems of ODEs and Chaos

Student Projects in Maxima is an online project to disseminate work by undergraduate students using Maxima to reproduce published results in the sciences and social sciences.

Volume 1, Number 1 (2017) is devoted to Chaotic Systems of Ordinary Differential Equations.

Contents:

Thornburg, Eric, *Simple Pendulum and Chaos*

Bhimani, Kevin, *Chaos in a 3-Species Food Chain*

York, Lily, *A Lattice Model of Epilepsy*

Andrews, Steven,* 3D Chaotic Model*

Rutledge, Tim, *A Model of Neuronal Bursting*

## Student Projects in Maxima Vol 1, Num 2: Systems of ODEs with Impulses and Switching Functions

Volume 1, Number 2 (2017) is devoted to Systems of Ordinary Differential Equations with time-dependent forcing terms, non-continuous inputs, and forcing terms that require knowledge of a past state of the system.

Contents:

Chumley, Qynce, *An Office Heating and Cooling Model*

Williams, Nick,* Baseball Pitch Dynamics*

Rizzolo, Skylar, *BAC Model for alcohol consumption*

Barth, Eric, *A model of bladder bacteria proliferation in prostate disease*

Barth, Eric, *A Model of Pulse Vaccination Strategyi*

## Two y axes in Maxima 2D plots

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**:

## A pause() function for Maxima

**pause**interrupts execution of a loop until the user strikes a key, and

**pause(<n>)**pauses for

**<n>**seconds before resuming execution.

**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.

**(function-name argument)**

**?function-name(argument)**

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("") );

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

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