Solving algebra problems step by step with wxMaxima

The roots of the wxMaxima computer algebra system (CAS) go way back. A program called Macsyma [1], which has not been developed for quite some time, forms the basis of a variant named Maxima [2] that served the U.S. Department of Energy (DoE). Its developer, William Shelter, got permission from his employer to publish the program under the GPL [3]. Andrej Vodopivec is currently coordinating the project.

With the program's introduction into the world of free software, developers soon emerged who took the code under their wing. Aside from Xmaxima, wxMaxima currently is the preferred interface, and it uses a Lisp kernel called Maxima. It works not only on Linux but also on Mac OS X and Windows.

With many distributions, wxMaxima [4] is installed through a simple command and thus avoids configuring the core. However, if you want to work with Xmaxima and the associated Tcl/Tk widgets, you will need some additional packages.

Three versions of the same app are available: the shiny wxMaxima (Figure 1), the old-fashioned looking Xmaxima graphical interface (Figure 2), and the sober Maxima with a text-based interface (Figure 3).

Figure 1: The wxWidgets give the software a modern interface.
Figure 2: The somewhat old-fashioned Tcl/Tk widgets don't alter the fact that Xmaxima is a powerful program.
Figure 3: Maxima feels at home even in the terminal, although without the ease of use that a GUI provides.

IPO Principle

Figures 1 through 3 show the IPO principle: input, processing, and output. Lines with input are labeled with (%i<x>) . Maxima and Xmaxima both require semicolons at the end of lines. Pressing Enter processes the data. The result (output) begins with (%o<x>) .

wxMaxima handles the end of input somewhat differently; it completes the line with Ctrl+Enter, which adds a semicolon automatically.

The flashing cursor offers you the full potential of a digital mathematician. The scope of the system, however, can overwhelm the typical computer user, so a study of the documentation is definitely called for.

Maxima has a lot to offer in this respect, including a series of online PDF documents [5] and an integrated help. Other commands can be found in wxMaxima's menus.

The main problem usually isn't the use of the syntax but the semantics. wxMaxima, like every other computer algebra system, provides useful help only to those who understand the semantics.

Instructions

wxMaxima is an ideal tool for teaching mathematics. The program helps with homework and allows printing it. The optimal application is for high school sophomores, and the manual is perfect for this user group.

A CAS is not only a calculator but a system that processes mathematical expressions (i.e., provides equation solving). This functionality also affects the exercises. For example, the fraction 1/3 appears as such and not as an imprecise floating point. If you want rounding, as with a calculator, however, you can enable it. You use the float() function or the numer variable to do this, which changes the result to a finite precision set by the fpprec option. Conversely, you can change decimal fractions into real fractions using the rat() (ratio) function. The software uses dotted decimals in the English nomenclature.

Curve Sketching

Learning algebra in school often involves "curve sketching," or drawing a curve based on an f(x) algebraic function. This is a perfect example of where wxMaxima excels. The curvesketching.wxm batch file provides an example [8]. When you view the file with a text editor, you'll discover that it's a simple text file with the .wxm extension. It contains a sample curve-sketching exercise.

The simple syntax of this file is noticeable at first glance. Each command is enclosed in a comment composed of three lines. The first line is in square brackets and describes the character and start of the command. The second line contains the actual content of the command, and the third line ends the command. If you read this file with the wxMaxima program, you see only the second line. To get the result seen in Figure 4, after loading the file, you would use either Edit | Cell | Evaluate all cells or Ctrl+R.

Figure 4: wxMaxima allows for structured documentation. To see the result, use the application's menu entries to evaluate each line (known as a "cells").

If the cell has a reference to a result, this result could become untenable with a new evaluation. Therefore, you should use an absolute reference such as %o17 (the result of the 17th calculation) only if all the previous evaluations are done again in the proper order.

Relative addresses such as a simple % (in the last exercise) involve the risk that preceding lines will change when processing the file and the reference is no longer valid. This risk, however, applies only to users who routinely create real programs for evaluation. Using the program interactively, you can reference at will. Using the Cell menu entry, you can add the different cells at relevant file locations. Simple text cells are in blue and have the nature of a comment. Cells of the Section and Subsection types are automatically numbered, which allows you to structure a task.

Curve sketching doesn't run quite automatically. You first have to assign it a function. In the curvesketching.wxm file the f(x):=x^3/(x^2-4) function is an example of this. If necessary, you can start by modifying the definition by editing the input line. Whether the definition needs to be verified depends on the type of function. Polynomials don't need verification in that their scope encompasses the entire set of real numbers (see the "Totally Real" box). The curvesketching.wxm file includes a function where the polynomial in the denominator needs to evaluate to non-zero. This happens using the solve(x^2-4=0,x); line in the script used to solve the equation. The definition range excludes the solution from the full set of real numbers (D=R\{-2,2} ).

Totally Real

wxMaxima works with complex numbers, like any CAS – but unlike high school math classes where students work with real numbers. Hence, the application providing solutions that lie in the set of complex numbers makes it unsuited for teaching math.

Rewriting Equations

The mechanized derivation of equations with wxMaxima sometimes deviates strongly from a manual one. In curve sketching, for example, the software gives the third derivative in a rather complicated form (Figure 5), whereas the original author of the problem [7] had a much simpler one (Figure 6).

Figure 5: wxMaxima defines the third derivative with the define command, resulting in a rather complicated function.
Figure 6: The original author's version of the example is a much simpler one.

You can identify both functions as identical by recasting the equation. The software provides the simplify and ratsimp (rational simplify) functions, as well as factor and expand . Using these functions skillfully, you can see that both derivatives are the same (Figure 7).

Figure 7: Using factor, you can see that the third derivative matches in the manual and software versions.

Vectors and Matrices

wxMaxima provides functionality for calculating vectors, although some simplification might be desired at this point. Although defining vectors and calculating sums, differences, and scalar products is easy enough, computing vector products relies on the vect library, which has a complex syntax (Figure 8).

Figure 8: Although all vector arithmetic calculations are relatively simple, computing vector products is rather complicated.

Nevertheless, wxMaxima solves the display of vectors in space quite nicely. The result of the corresponding command appears in a separate Gnuplot window and you can rotate the objects with the mouse (Figure 9). You'll find the vectors.wxm file, which is the basis for Figures 8 and 9, included with the listings for this issue [8].

Figure 9: The vector chain drawn by the 3D graphics library as Gnuplot output that you can rotate per mouse in virtual space.

Calculating matrices is significantly easier. You create them using the matrix command, where the numbers in square brackets output a line. The linking with plus and minus signs is defined much as the dot operator is used for multiplication. In all operations, it's important to observe the rules for computing matrices – that is, to add and subtract only the equivalent n*m matrices and multiply only the equivalent number of rows and columns. The software provides functions to modify matrices, including the important invert command that computes an inverse matrix as a quadratic matrix.

If you multiply the original matrix with its inversion, you get the identity matrix. Thus, you can determine linear equations simply by multiplying the inverse coefficient matrix with its result matrix. You'll find the matrix.wxm file with a corresponding example with the listings [8].

Equations

You can solve equations and systems of equations using the solve command with no prior knowledge of matrix algebra. This has the advantage that you can enter equations in the form given by the problem without having to separate the coefficient matrix with the result matrix (Figure 10).

Figure 10: With the solve command, you can solve equations and systems of equations in one shot.

The documentation provides probability theory examples and functions, including input and output and examples of loops and conditions. These components make wxMaxima a universal mathematical system.

The emphasis, as with any CAS, is on symbolic mathematics, however. The software provides graphical output as well as programming and numerical analysis. For the latter, however, other less bulky and more accessible environments can be used.

Help

The usual F1 opens a help window with the contents on three tabs, Contents , Index , and Search . Be warned that if you don't know what you're looking for, you can easily get lost in details. Referring to the manual [6] from time to time is certainly recommended.

If you remember the name of a command or what it starts with but not how you can invoke it, the Show all button on the Index tab can help. You then browse through the index and click the entry when you find it, which opens a detailed description of the command.

Conclusion

wxMaxima is a powerful CAS with few operating hitches. If any, they're mainly in the vector computation domain. This open source program provides high school students with everything they need. Additionally, the program is free and platform independent for Windows, Mac, and Linux computers.

The ability to format files for text input means that you can deliver homework or assignments in a printed form, which is usually sufficient for the classroom, provided the work involves only solving basic math problems.

The extensive documentation and many Internet forums provide assistance with problems that the built-in help cannot solve.