# Mathematics, Moodle and Computer Algebra Systems

This is the first in a series of posts exploring the STACK online mathematics assessment system (currently being developed by the University of Edinburgh). Specifically, we will be studying STACK integration with the Moodle VLE.

In this post we explore why a computer algebra-based system is needed for teaching and assessment. We then show how to install Maxima 5.38.1 on an Ubuntu 16.04 Digital Ocean droplet – the first step in implementing the STACK + Moodle integration.

## The Problem

If we are assessing mathematics, or a mathematics-related discipline, using an online learning environment then we don’t need to move far into secondary-level mathematics (pupils aged 11 years and above) before we encounter a fairly fundamental mathematical equivalence problem. Here is a relatively simple algebra question to demonstrate it:

Expand the brackets and simplify where possible

$$4(3x + 2)$$

The answer we would normally expect is:

$$12x + 8$$

If this question were posed in an online test we could have the student enter their answer as a text string then then perform some form of string comparison. Our model answer would be [latext]12x + 8[/latex]. If a student (correctly) enters ’12x+8′ then that would be marked correct when compared to our model answer. So far so good. But what if they entered:

$$8 + 12x$$

This is also correct. But ‘8 + 2x’ a different text string to the model answer we are comparing it to. We would mark this this as incorrect – and this is the problem: by comparing strings we are checking lexicographical equivalence and not mathematical equivalence. So, how do we confirm mathematical equivalence?

## The Solution

The Maxima project

At its most basic level, a computer algebra system (CAS) manipulates mathematical expressions and, by being able to do so, a CAS is able to check for mathematical equivalence and so provide the solution to our problem. Not only that, but by using a CAS to support assessment means being able to provide more sensible automatic feedback on student’s answers, provide line-by-line reasoning in worked answers (in the style of Wolfram Alpha) and much more. The CAS we will be using, Maxima, can trace its history back to one of the very first computer algebra systems, Macsyma, developed at the Massachusetts Institute of Technology back in the 1960s. What’s great about Maxima is that it is not only open source but also supported by an active community of developers (as witnessed by the level of development activity on Open Hub).

In the rest of this post we will learn how to install Maxima, specifically version 5.38.1 which is the STACK recommended version. Sadly, the version of Maxima included in the official Ubuntu 16.04 LTS repositories is 5.37.2 and this contains a known bug which affects STACK. If we check out the Maxima 5.38.1 downloads on Sourceforge, we see that .rpm files are available but not .deb (which we would need as Ubuntu is a Debian-based system). Here is an overview of what’s covered in this post:

1. Converting .rpm (RPM/Red Hat Package Manager) files to .deb (Debian Package Manager) files
2. Creating a local repository on your server
3. Verifying a new Maxima install

Let’s begin by installing two components required by Maxima, clisp and gnuplot. Log onto your server terminal and at the command line type the following:

sudo apt-get install gnuplot



then,

sudo apt-get install clisp

And now let’s install a third component, Alien, which we will use to convert .rpm packages to .deb packages:

sudo apt-get install alien

Now we are ready to begin…

### Converting RPM packages to .deb files

First step is to download both the maxima-5.38.1-1.x86_64.rpm and maxima-exec-clisp-5.38.1-1.x86_64.rpm files from SourceForge onto the server (it’s the AMD64 version of both files we need).

Next, convert both of these files to Debian packages using Alien. For example, to convert maxima-exec-clisp-5.38.1-1.x86_64.rpm:

alien -k --scripts maxima-exec-clisp-5.38.1-1.x86_64.rpm

followed by,

alien --scripts -k maxima-5.38.1-1.x86_64.rpm

This will generate a new file called maxima-exec-clisp_5.38.1-1_amd64.deb. Note the output is an ‘amd64’ Debian file.

### Creating a local repository

Create a new local repository folder for your system architecture, for example:

/var/local-deb-repo/debs/amd64/

Move the newly created .deb to the local relevant folder:

mv maxima-exec-clisp_5.38.1-1_amd64.deb /var/local-deb-repo/debs/amd64/

Next we need to sign the repository. For this we use GNU Privacy Guard (GPG). Create a new key by running:

gpg --gen-key

Follow the onscreen instructions to generate the required key. Create a key that’s RSA (sign only) and ensure it doesn’t expire. You can list your keys at any time using the command:

gpg --list-keys

As in the screen grab below, make a note of the key’s ID. We will need this for the next command.

Screen grab showing a newly created GPG key. The ID of the key is highlighted.

Having created the key, we now need to export the public key to a text file, located in the root of the repository. Run the following:

gpg --output keyFile --armor --export 2A23B5D2

Remember to replace 2A23B5D2 with the ID of your new key.

We will need to add this new key to the list trusted by APT. Run:

sudo apt-key add keyFile

Next step is to create the packages themselves. Run the following:

apt-get install dpkg-dev

and then run

dpkg-scanpackages . /dev/null > Packages

Now zip up the packages folder with

gzip -c Packages > Packages.gz

Next we need to create the Release, InRelease and Release.gpg files:

apt-ftparchive release . > Release
gpg -abs -o Release.gpg Release
gpg --clearsign -o InRelease Release

Now we are in the final straits. Next update /etc/apt/sources.list by adding the following:

## APT local repository
deb file:/var/local-deb-repo/debs/ amd64/



Now run:

apt-get update

And now, finally(!), install Maxima. Run:

apt-get install ./maxima-exec-clisp_5.38.1-1_amd64.deb



… followed by:

apt-get install ./maxima_5.38.1-1_amd64.deb

You might well see a ‘–configure’ post-installation error but don’t worry about this: Maxima will be installed. Finally step is to verify your installation.

### Verifying a new Maxima install

Run Maxima from the command line. Type:

maxima

You may well see a warning about the help system:

WARNING: Maxima is unable to set up the help system.


Ignore this for now (it’s a simple fix – see comments below).

Check the build version by running:

build_info();

You should see something similar to:

(%i1) build_info();
(%o1)
Maxima version: "5.38.1"
Maxima build date: "2016-05-12 10:08:11"
Host type: "x86_64-slackware-linux-gnu"
Lisp implementation type: "CLISP"
Lisp implementation version: "2.49 (2010-07-07) (built on vtt1.vttoth.com [199.166.252.1])"
(%i2)


At this stage you can try experimenting with some mathematical problems. For example, try solving a quadratic:

Maxima 5.38.1 http://maxima.sourceforge.net
using Lisp CLISP 2.49 (2010-07-07)
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) f(x) := x^2 + 7*x + 12;
2
(%o1)                        f(x) := x  + 7 x + 12
(%i2) solve(f(x));
(%o2)                         [x = - 3, x = - 4]
(%i3)


There is a wealth of information on Maxima on the Internet – just type ‘Maxima CAS tutorial’ in your favourite search engine.

### Summary

In this post we worked through the installation of Maxima version 5.38.1, the version recommended for use with STACK. Specifically we learned how to:

1. Convert .rpm (RPM/Red Hat Package Manager) files to .deb (Debian Package Manager) files for installation on Ubuntu 16.04
2. Create a local repository on our Ubuntu 16.04 server, specifically for Maxima, so we can use apt-get update to manage the Maxima installation.
3. Verify and test a new Maxima install.

If you encounter any issues or have any questions then please feel free to comment on this post.