Calculus with Maxima

Troy Henderson

Updated: May 6, 2008

Contents

What is Maxima?
Getting Started with Maxima
Using Maxima as a Calculator
Assignments and Equations

What is Maxima?

Maxima is an open source computer algebra system whos origins formed the foundation for many of its commerical counterparts including, for example, Maple and Mathematica. A computer algebra system is a software application that is designed to perform symbolic mathematical computations as opposed to numerical applications which perform all computations using fixed or floating point arithmetic. In layman’s terms, computer algebra systems provide exact answers to problems but at a cost of being computationally expensive as opposed to numerical applications which produce approximate answers very efficiently.

Since Maxima is open source, it is completely free to use and distribute. Currently, the student version of Maple and Mathematica costs $99 and $140, respectively, and a single academic license of Maple and Mathematica costs $995 and $1,095, respectively. Both Maple and Mathematica have many bells and whistles that many users do no need, and thus, from an economic point of view, Maxima is a natural choice for individuals and institutions with relatively small budgets.

Getting Started with Maxima

Most Maxima users will want to interact with Maxima using a graphical user interface (GUI). The most popular GUI is wxMaxima, and this GUI is available for each of the most popular operating systems including Micro$oft Windows, Mac O$ X, and Linux. As previously mentioned, Maxima is completely free, and it can be downloaded from Maxima’s website at http://maxima.sourceforge.net. The Windows installer of Maxima is packaged with wxMaxima; however, users of other operating system users may need to download wxMaxima from http://wxmaxima.sourceforge.net.

Figure 1 shows a screenshot of wxMaxima. Input to wxMaxima is entered in the box labeled INPUT, and once input is entered, an echo of the input as well as the output is displayed in the preview window pane. Common commands are available via the buttons below the input field, and many other commands may be accessed via window menus. A complete list of available commands may be found in wxMaxima’s the help file, and a list (as well as several examples) of common commands used for calculus problems will be discussed here.


PIC

Figure 1: Maxima Screenshot


Using Maxima as a Calculator

The 5 basic numerical operations are addition, subtraction, multiplication, division, and exponentiation and are performed in Maxima using +, -, *, /, and ^, respectively. For example, in order to add 3 and 5 with Maxima, simply enter

3+5

into the INPUT field, and the output will be

 
(%i1) 3+5; 
(%o1) 8

Notice that the input is echoed as (%i1) which is synonymous with “input 1” and the evaluation of this input, namely 8, is shown in (%o1) which is synonymous with “output 1”. As more inputs are entered, the input and output fields are incremented accordingly. For example, the following illustrates the other 4 basic operations.

 
(%i2) 3-5; 
(%o2) -2 
 
(%i3) 3*5; 
(%o3) 15 
 
(%i4) 3/5; 
(%o4) {3\over 5} 
 
(%i5) 3^5; 
(%o5) 243

Notice that (%o4) returns the fraction {3\over 5} as opposed to 0.6, say. The reason for this is that 0.6 is assumed to a floating point approximation (even though in this case the approximation would be exact) of the exact answer. This example illustrates the primary difference between computer algebra systems and numerical applications.

Maxima follows the standard order of operations, and parenthesis are used as delimiters for individual terms in an expression. For example, notice (because of order of operations) that the following two inputs generate the same output.

 
(%i6) 1+2*3+4^5; 
(%o6) 1031 
 
(%i7) 1+(2*3)+(4^5); 
(%o7) 1031

There are several built-in constants in Maxima, but these constants are used symbolically unless (or until) a floating point representation of them is requested. Several of these constants are found in Table 1.






Constants








Constant
Description
Symbol Value




%pi  Pi π 3.141592653589793\mathop{\mathop{…}}
%e   Euler’s numbere 2.718281828459045\mathop{\mathop{…}}
%phi Golden Ratio φ{1+\sqrt{5}\over 2} = 1.618033988749895\mathop{\mathop{…}}
%i   Imaginary Uniti\sqrt{-1}
inf  Infinity





Table 1: Several Built-in Constants

So, in order to illustrate the use of these constants, consider the following example.

 
(%i8) %pi/4; 
 
(%o8) {\hbox{@(tt)%pi@(/tt)}\over 4} 
 
(%i9) float(%); 
(%o9) 1.618033988749895

Notice that (%o8) is the exact result when dividing π by 4. The input (%i9) is used to perform a floating point evaluation of (%o8), and this is accomplished using float(%). The float() function performs a floating point evaluation of an expression, and % represents the “last output” which, in this case, is (%o8).

A calculuator would just not be a calculator without several built-in functions. Table 2 shows several functions provided by Maxima.




Mathematical Functions




Function
Description


abs   Absolute value
sqrt  Square root
exp   (Natural) Exponential
log   (Natural) Logarithm
sin   Sine
cos   Cosine
tan   Tangent
csc   Cosecant
sec   Secant
cot   Cotangent
asin  Arcsine
acos  Arccosine
atan  Arctangent
atan2 Four quadrant Arctangent



Table 2: Several Maxima Functions

Table 2 is far from a complete list of functions in Maxima, but it does contain some of the most commonly used mathematical functions. The following example is an illustration of several of these functions in action.

 
(%i10) abs(5-9); 
(%o10) 4 
 
(%i11) sqrt(81); 
(%o11) 9 
 
(%i12) exp(3); 
(%o12) %e{}^{3} 
 
(%i13) float(exp(3)); 
(%o13) 20.08553692318767

Assignments and Equations

It is often desired to store the value of a particular output so that this value may be resused later. Simple variable assignmetns are achieved using the : assignment operator. In order to illustrate the use of this assignment operator, consider the following example.

 
(%i1) x:9/5; 
(%o1) {9\over 5} 
 
(%i2) 5*x^2-24*x+27; 
(%o2) 0

In this example the value of {9\over 5} is stored into x, and then the expression 5x{}^{2}-24x+27 is evaluated to 0. The value of an output can also be assigned to a variable by using % to refer to the previous output or by referring to the specific output. The following example illustrates this.

 
(%i3) (4+1/2)-(8+1/3); 
(%o3) -{23\over 6} 
 
(%i4) a:%; 
(%o4) -{23\over 6} 
 
(%i5) a+4; 
(%o5) {1\over 6} 
 
(%i6) b:(%o5); 
(%o6) {1\over 6}

Notice that the expression was first evaluated and then the answer was assigned to a. Finally the expression a+4 was evaluated to {1\over 6} and this value is then stored into the variable b.