**WHAT IS MAXIMA** [1]

Maxima is a computer algebra system, distributed under the General Public License. It has, both, capability of symbolic , as well as numerical operations (Maxima homepage).

A graphical user interface for Maxima is cross-platform wxMaxima (at least it is one of the GUIs for Maxima).

The graphical output is presented using Gnuplot.

The system includes a complete programming language, with ALGOL-like syntax and Lisp-like semantics [2].**WHY THIS INSTRUCTABLE**

Everyone needs calculations of various sort. Human brain calculates all the time, luckily humans are not aware of the most of these computations.

There are scenarios in which the calculations must be performed consciously, with the results preserved for later on. Great many of these computations are complex and complicated, beyond pen-and-paper calculations. In such cases humans, for the time being, prefer to use some devices with suitable capabilities, such as hand calculators or computers. There is a variety of computer software assisting calculations of various kind, beginning with hand calculators equivalent on each operating system, through Excel/Calc/Gnumeric/Numbers spreadsheets, finishing on computer algebra systems, e.g. Matlab, Octave, Mathematica, Maxima.

But what makes Maxima worth interest? There are at least few answers.

I) Since Maxima is a general-purpose system [3], its capabilities cover a wide range of applications. It can be used as a simple calculator, and it can solve sophisticated and complex mathematical problems (where complex can be read both figuratively and literally). Titles of some chapters of Maxima help are:

...

12. Polynomials - Standard forms for polynomials, and functions operating on them.

13. Constants - Numerical constants.

14. Logarithms - Manipulation of expressions involving logarithms.

15. Trigonometric - Manipulating expressions with trig and inverse trig functions.

16. Special Functions - Special functions

17. Elliptic Functions - Elliptic Functions and Integrals

18. Limits - Limits of expressions.

19. Differentiation - Differential calculus.

20. Integration - Integral calculus.

21. Equations - Defining and solving equations.

22. Differential Equations - Defining and solving differential equations.

23. Numerical - Numerical integration, Fourier transforms, etc.

24. Arrays - Creating and working with arrays.

25. Matrices and Linear Algebra - Matrix operations.

...

30. Series - Taylor and power series.

31. Number Theory - Number theory.

32. Symmetries

33. Groups - Abstract algebra.

...

Chapter 8 title is Plotting. Maxima is capable, through Gnuplot, of presenting 2D and 3D plots.

II) Maxima is distributed under General Public License, which makes it very interesting alternative to proprietary software.

III) It seems to be somewhat lightweight and moderatly fast piece of software (from my personal experiences).

IV) wxMaxima is a cross-platform software, which is important for people using different operating systems.

V) Wikipedia also states, that 'Maxima offers the possibility of generating code in other programming languages (notably Fortran) which may execute more efficiently' [3]. This possibility along with writing the code in Lisp are beyond the scope of this text, as well as beyond the author's comprehension, though it is worth noting, Maxima is capable of such things.

The reasons listed above made the author write this instructable. It is shameful to admit, that I have never been good at mathematics. Nevertheless I find the understanding of mathematics desirable and useful. This summarises the reasons for this instructable.

## Step 1: Calculator and Notebook

First of all wxMaxima can be used as a calculator and a notebook. Not only can simple algebraic operations be performed, but variables of any names can be assigned values and can be further processed as well, e.g. (fig. 1: Calculations with variables)

Comment on the basics:

- A single piece of work for Maxima is called a cell. A cell is designated with a bracket on the left side of the screen.

- User input is designated by '(%i*n*)', where *n* stands for consecutive number. A single cell can have multiple input rows.

- Each row must end either with semicolon ';', or dollar sign '$'. '$' makes the input invisible/silent - without input value printed in the output - helps preserve clarity.

- If decimal format of the calculation is preferred, the input must be followed by comma and 'numer' keyword: ' , numer;'

- Blue cells in the picture are text cells (inserted from the 'Cell' menu). Putting a comment inside the input is possible through '/* ... */' - before the ending colon.

- After opening a Maxima file, there is possibility of executing all cells by hitting 'Ctrl+r'.

The second picture shows somewhat real life task calculations (ch01Garden.wxm; the idea came up while setting the lawn in the garden).

The first cell contains basic dimensions and calculations. The second cell contains seed and safety coefficients ('seedCoef' and 'JICCoef'). The first one stands for the area of the land per one kg of the grass seed (1kg per 30m^2 - I think Maxima has got units built in - there should be an update to this instructable). The second one represents uncertainty in the operation - in case places in the garden would need to be resown (that was the case with the real garden, though surplus grass seed was bought by mistake...). The third cell contains desired result: the amount of the grass seed needed for planting the lawn.

Both examples illustrate the possibility of performing basic calculations with the results that can be saved or/and printed.

## Step 2: Calculator - Applications

Maxima can easily be used as a hand calculator equivalent. The obvious advantages over simple hand-held devices is that the input is displayed with the results, the output. The input can also be altered after first calculation. Both the input and the output can be copied and used elsewhere. Any valid value can be pasted as input.

The first example covers basic calculations. Let's assume we have a fraction and we want its decimal value:

The input value for Maxima would be:

((1.6 + 154.66/70.3)/1.9);

But is it the same fraction? Was it input correctly? How to check it? The apostrophe is the answer ('):

'((1.6 + 154.66/'70.3)/'1.9);

Placing two input rows in a cell, one with apostrophes, and one without, is a way to both checking the input value, and getting the decimal output.

The Maxima cell is in the picture.

Any changes to the input values can be done easily.

Algebraic expressions and mathematical functions can also be used during simple calculations, e.g. x^n, e^x, log(x), sin(x), etc.

## Step 3: Lists and Matrices

Quite often instead of simple, ordinary, variable a list of values proves to be more useful. More advanced form of a list is a matrix. Maxima supports both lists and matrices. Defining a list variable is quite easy thanks to brackets (stp020ListsMatrices.png@(%i1-3)). For a matrix definition a keyword 'matrix' is used (in the example 'matrix' command takes lists as arguments, stp020ListsMatrices.png@(%i4, 5)). The 'ident' keyword defines an identity matrix (the size provided as an argument).

To access particular element of a list, or a matrix, brackets can be used. Indexes start with 1. Accessing an element of a list can be done with the list name followed by brackets with the element index. An element of a matrix can be accessed with brackets also, but the indexes are its row and column number. A row of a matrix can be accessed either with just one index in the brackets, or with the 'row' keyword (matrix name and row number must be provided as arguments). A matrix column can be accessed with the 'col' keyword (stp021ListsMatrices.png).

## Step 4: Plotting

wxMaxima is capable of plotting 2D graphs and 3D as well. It seems a bit difficult to imagine a function analysis without any plot at all. Maxima is well prepared for such analysis and for plotting operations of any kind, virtually. Basic commands for plotting are **plot2d** and **plot3d** (in Linux wxMaxima uses Gnuplot for plotting in a separate window; using **wxplot2d** and **wxplot3d** respectively, makes the graphs appear inside the wxMaxima window, but without some extra capabilities, for example Gnuplot presents values pointed by the mouse cursor. In [2] there is a comment: "When calling the standard plotting routines plot2d, plot3d, draw2d, draw3d, etc., a Gnuplot output window containing the graphic is popping up. Continuing working with Maxima is not possible until that window is closed again.". In Ubuntu linux 11.04 with wxMaxima 0.8.5 it was possible to make a graph in a separate window and work with Maxima further, without closing Gnuplot window.)

A simple plot of sine function looks as follows:

(%i15) wxplot2d( sin(x), [x, -%pi, %pi] )$

(%t15){{sinX.png, pic. 1}}

The arguments of wxplot2d command are: expression, here sin(x), a list containing: the variable and the limits - [x, -%pi, pi] (%pi stands for π).

Plotting with logarithmic scale ( %i16 - regular plot, %i17 - with logarithmic scale):

(%i16) wxplot2d(exp(x), [x, 0, 10]);

(%t17) {{expXPlainPlot.png, pic. 2}} < %e stands for *e* >

(%o17)

(%i17) wxplot2d(exp(x), [x, 0, 10], [logy]);

(%t18) {{expXLogScale.png, pic. 3}}

(%o18)

Plotting discrete values:

(%i18) wxplot2d([discrete, [10, 20, 30, 40, 50], [5, 7, 7.5, 6, 9]]);

(%t19) {{discreteValues.png, pic. 4}}

(%o19)

(%i19) wxplot2d([discrete, 10, 5], [20, 7], [30, 7.7], [40, 7.3], [50, 8 ], [style, points], [point_type, diamond], [color, red]);

(%t20) {{discreteValuesPoints.png, pic. 5}}

(%o20)

Thera are parametric plots possible also (as the description was omitted you can refer to Maxima help or [2]).

## Step 5: Equation Solving

To solve an equation means to find its roots, to express the unknown values in terms of the known values [4].

With the keyword 'solve' Maxima finds a solution to an equation. There are three possibilities:

1) solve(exp, x)

2) solve(exp)

3) solve([eqn1, eqn2, ...], [x1, x2, ...])

With the first possibility Maxima finds a solution to an algebraic equation for variable x. If there is only one variable, the second option is possible. Thirdly Maxima can find the solutions to a system of linear equations.

Some examples illustrate equation solving.

* Linear equations

solve(2*x - 6); or solve(2*x - 6, x); or solve(2*x - 6 = 0); or solve(2*x - 6 = 0, x);

gives

[x=3]

* System of linear equations

eqSys: [2*x + y, x - y - 4];

[y+2*x,-y+x-4]

solve(eqSys, [x, y]);

[[x=4/3,y=-8/3]]

* Trygonometric equations

solve(sin(x) - 0.5);

rat: replaced -0.5 by -1/2 = -0.5

solve: using arc-trig functions to get a solution.

Some solutions will be lost.

[x=%pi/6]

* Quadratic equations

solve(3*x^2 + 5*x - 7);

[x=-(sqrt(109)+5)/6,x=(sqrt(109)-5)/6]

* Exponential equations

solve(2^x - 8), numer;

rat: replaced 3.0 by 3/1 = 3.0

rat: replaced 3.0 by 3/1 = 3.0

(%o56) [x=3]

* Logarithmic equations:

log10(x) := log(x) / log(10);

solve(log10(x) = 3);

[x=1000]

## Step 6: Differentiation and Integration

**diff(<expr> {, <variable> {, <order>}})**

**<exp>**is the expression to differentiate,

**<variable>**stands for a variable with respect to which the differentiation will be calculated and

**<order>**designates the order of differentiation (<variable> and/or <order> are optional).

**integrate(<expr>, <variable>)**

**<exp>**with respect to

**<variable>**, and

**integrate(<expr>, <variable>, <a>, <b>)**

**<exp>**with limits

**<a>**and

**<b>**

## Step 7: 3D Graphs

The capability of drawing 3D plots in CAS applications has always impressed me the most. This is the case concerning wxMaxima as well.

In the following example 3D functions are defined as parametric surfaces, then the plot is drawn with 'draw3d' command (defining functions in separate cells was chosen to preserve clarity, though it is not necessary). The keyword takes as arguments 3 defining functions, the names of parameters, and their limits (parametric_surface(x(u,v),y(u,v),z(u,v),u,u1,u2,v,v1,v2)). The arguments of 'draw3d' keyword are 'nticks' - high value gives smooth graph, 'surface_hide' - when 'true', it suppresses hidden parts, 'color' is self-explanatory, and the variable containing the surface.

The actual plotting can be done in a Gnuplot window, or inside wxMaxima window, with 'draw3d' and 'wxdraw3d' commands, respectively. The Gnuplot window allows for pivoting the graph.

## Step 8: Summary

In this instructable wxMaxima, free computer algebra system, was presented. The description of the program was brief and introductory, as this was the initial premise. The author was going to whet the reader's appetite. Few examples provided showed some possible applications of the software, starting with plain and simple ones, and reaching to more sophisticated and advanced (wxMaximaScripts.zip).

The instructable suggests that wxMaxima can be used as:

- a simple calculator and a notebook,

- can assist young students beginning their adventures with mathematics,

- a tool for solving complex mathematical problems.

What was omitted in this text:

- Maxima has programming capabilities, what greatly increases possible applications,

- it is possible to write scripts solving even very complex, real life, scientific problems.

- There is whole community of enthusiasts and volunteers, and a great many resources is available (Maxima homepage).

- The author's software environment: Ubuntu Linux 11.04, wxMaxima 0.8.5

Since this is the first instructable, I kindly ask for remarks and comments on what could be improved. English is not my mother tongue, so I'll appreciate every advice also.

Some of the resources I used were:

- *Graphics with MAXIMA* (Version 5.23 and above), Wilhelm Haager, HTL St. Pölten, Department Electrical Engineering, February 25, 2011 wilhelm.haager@htlstp.ac.at11

- *Maxima - przewodnik praktyczny* (in Polish), RafaB Topolnicki, rtopolnicki@o2.pl

- *Maxima manual*, (maxima-5_15.pdf), extensive, 876 pages**Bibliography**

[1] - Maxima (software) - http://en.wikipedia.org/wiki/Maxima_%28software%29

[2] - en.wikipedia.org/wiki/Maxima_(software)#Features

[3] - en.wikipedia.org/wiki/Maxima_(software)#Numeric_calculations

[4] - Equation - en.wikipedia.org/wiki/Equation#Knowns_and_unknowns

## Discussions

6 years ago on Introduction

There's an awful lot of "Maxima is capable of...", and not a lot of instruction here.

I suggest you unpublish this project, and, instead, create a series of instructables on performing tasks with the software.

For example

"How to differentiate equations with free Maxima software".