Maxima Tutorial 3 – Trigonometric Functions and Calculus

In this tutorial, we are going to discuss some of the most elementary commands used in Maxima in Trigonometry and Calculus. Note that in maxima, most constants are written with the percent sign before it. For instance, the most common constants are π, e and i are written as %pi, %e and %i.

Maxima can perform the following trigonometric and calculus operations:

  • Get the value of trigonometric functions
  1. sin(%pi/2);
  2. cos(%pi/4);
  3. tan(%pi/6);
  4. [sin(%pi/3),cos(%pi/3)];

As you can see, in 4, we can get the values simultaneously by separating the functions with comma and enclosing them with bracket.

  • Get the Limits of Functions
  1. computes the limit of 2x3 + 5x2– 2x as x approaches -1: limit(2*x^3 + 5*x^2 – 2*x – 1, x, -1);
  2. computes the limit of (x4 + 4x2)/(2x4 – 2) as x approaches negative infinity: limit((x^4 + 4*x^2)/(2*x^4 – 2), x, minf);
  3. computes the limit of (x4 + 4x2)/(2x4 – 2) as x approaches infinity: limit((x^4 + 4*x^2)/(2*x^4 – 2), x, inf);
  • Get the Derivatives and Integrals of Functions
  1. Get the derivative of derivative of (x4 + 2x3 + 5x2): diff(x^4 + 2*x^3 + 5*x^2, x);
  2. Perform indefinite integration: integrate(x^3 + 4*x^2 – 2*x, x);
  3. Perform definite integration: integrate(x^3 – 2*x^2 + x, x, -1, 2)

Maxima Tutorial 2: Algebraic Manipulation and Graphing

In Maxima Tutorial 1, we have discussed how Maxima can be used to perform numerical computations.  In this tutorial, we are going to enumerate some of the capabilities of Maxima to perform symbol manipulation.  Note than in each equation below, do not forget to press the ENTER key after the semicolon.

Maxima can perform algebraic operations and here are a few of its capabilities:

  • Assigning values to variables and using them in computations.
  1. p:5; q:12; (Press the Enter key on your keyboard after the second semicolon)
  2. r: sqrt(p^2 + q^2);

In a, we used the colon sign to assign values to p and q and assign them as the value of r in b.

  • Solve equations in one variable
  1. solve(2*x  = 3, x);
  2. solve(a^3 + 3*a^2 + 5*a = 15,a);
  3. ratsimp(2*a + 3*b + c – a –b +2*c);
  4. ratsimp(x^2 – 3*x*y + y^2 – 2*x^2 – 5*y^2);

In c, we solve for the 2x = 3 for the value of x. In d, we use * for multiplication, and ^ for exponentiation. The ratsimp command simplifies expressions.

  • Expand and factor algebraic expressions
  1. expand((x + y)^6);
  2. factor (x^6 – 1);

Figure 1 – The Maxima command line.

  • Solve systems of linear equations
  1. linsolve ([3*x + 4*y = 7, 2*x + a*y = 13], [x, y]);
  2. eq_1: x^2 + 3*x*y + y^2 = 0;
  3. eq_2: 3*x + y = 1;
  4. solve (eq_1,eq_2);

In a, we solved for the values of x and y in the systems of linear equation 3x + 4y = 7 and 2x + ay = 3. In b and we defined two equations, eq_1 and eq_2, then used the two variables in d.

  • Plot graphs in 2 and 3 dimensions
  1. plot2d (sin(x)/x, [x, -20, 20]); (See Figure 1)
  2. plot3d(sin(sqrt(x^2 + y^2))/sqrt(x^2 + y^2), [x,-12, 12], [y,-12,12] (See Figure 2)

Figure 2 – Graph of sin(x)/x.

Figure 3 – Graph of (sin(sqrt(x^2 + y^2))/sqrt(x^2 + y^2).

Maxima Tutorial 1: Numerical Computation

Maxima is free a computer algebra system capable of a variety of computations. It can manipulate symbolic and numerical expressions, as well as  perform differentiation and integration.  It can also manipulate Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, and sets, lists, vectors, matrices, and tensors. Maxima can perform high-precision computations as well as plot two and three-dimensional graphs.  In this tutorial, we are going to learn how to use Maxima to perform basic numerical computations.

Figure 1 - The Maxima Command LIne

To perform simple numeric computations, we need to open the Command line Maxima as shown in Figure 1. The Command line Maxima is similar to the DOS-prompt as shown below.  We just have to type the expression, the press the ENTER key.

Figure 2 - The Maxima Command Line Window

  1. To add 12 and 15, type the following 12 + 15; and press the ENTER key on your keyboard. Note that each computation, command or expression ends in a semi-colon. The (%i1) text means first user input and the (%o1) means first output. After pressing the ENTER key, your first output should be 27.
  2. Maxima is capable of computing a wide variety of operations.  It can compute very large or small numbers as well as perform many functions. Type the following and press ENTER after each expression:
    1. 18 – (-5);
    2. -15*34;
    3. 18/2;
    4. 12^39;
    5. sqrt(3);

After typing sqrt(3) and pressing the ENTER key, your screen would look like the one shown below. Notice that what when we typed sqrt(3), the output is also sqrt(3). That is because, Maxima also accepts expressions like fractions and radicals without simplifying them. To simplify an expression into a decimal number, we need the float command. The float command converts fractions, radical expressions and other expressions to decimal numbers.

Figure 3 - Maxima accepts fractions and irrational numbers without convering them to decimal numbers.

Therefore, we need to “float” sqrt(3); to do this type float(sqrt(3)); and press the ENTER key. Then type the following:

  1. float(log(5));
  2. float(15^20);
  3. %o6 +  %o7;

Figure 4 - Maxima can handle very large numbers as shown above.

Note that the output of float(15^20) is in different form that that of 12^39. The output in of in (%o8) means

3.3252567300596506 x 1023

We can also perform operations of previous inputs and outputs by typing their corresponding prompts.  The command %o6 +  %o7; added the value in output 6 and output 7.

Mathematical Constants

Maxima has also mathematical constants stored in the program. So computations like pi*r*2 is possible.

%e \approx 2.71828

%pi  \approx 3.14159

%phi  = \frac{1+\sqrt 5}{2}

%i   = \sqrt {-1}

inf  \infty and minf  for  - \infty

In Maxima Tutorial 2, we will discuss how to use Maxima to help us perform symbolic manipulations.