Professional Documents
Culture Documents
Maxima Tutorial/2016
Mathemati
al Modelling I
DSC1520
Semesters 1 and 2
Bar code
university
Learn without limits. of south africa
Maxima/2016
Contents
1 Introdu
tion 3
2 Installation 3
3 Using Maxima 3
3.1 Simple
al
ulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Spe
ial
hara
ters and fun
tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Symboli
omputation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3.1 Fun
tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.3 Dierentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.4 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Linear algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.1 Solving systems of linear equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.2 Matri
es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.5.1 Graphing single fun
tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.5.2 Graphing multiple fun
tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.5.3 Three dimensional graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Solutions to a
tivities 15
4.1 Paragraph 3.1 (Simple
al
ulations) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Paragraph 3.3 (Simboli
omputation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 Paragraph 3.3.1 (Fun
tions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.4 Paragraph 3.3.2 (Limits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.5 Paragraph 3.3.3 (Dierentiation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.6 Paragraph 3.3.4 (Integration) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.7 Paragraph 3.4.1 (Solving linear systems) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.8 Paragraph 3.4.2 (Matri
es) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.9 Paragraph 3.5 (Graphs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2
Maxima/2016
1 Introdu
tion
Maxima is a powerful mathemati
al interfa
e that one
an use to easily nd answers to mathemati
al prob-
lems. For this module, we suggest that you use it to visualise fun
tions in order to
larify
ertain
on
epts
dis
ussed in the study material.
You may also use it to
he
k your answers to assignment questions. It is, however, very important to work
these problems out with pen and paper before you solve them with Maxima, be
ause you will not have
Maxima available in the examination.
2 Installation
You should have re
eived a CD
ontaining the software for Maxima with your study material for this module.
The version of Maxima on the CD might not be the most re
ent, but the instru
tions given in this tutorial
should be appli
able to most versions.
If you want to rather use the most re
ent version, you may download the most re
ent version of Maxima
download from the Internet at the following website:
https://sour
eforge.net/proje
ts/maxima/les/.
Cli
k on the link Download maxima-....exe to download the latest software. When it has nished down-
loading, double
li
k on maxima-5.....exe in your Downloads dire
tory to install it. A
ept all default
settings and
li
k Yes or Next at the prompts that appear.
When the installation has
ompleted, open Maxima to nd the following (or similar) s
reen:
This is the graphi
user interfa
e (GUI) for Maxima,
alled wxMaxima. In this s
reen you
an enter
om-
mands that Maxima will interpret and give answers to.
3 Using Maxima
In the newer versions of Maxima, one needs to use Shift-Enter or Ctrl-Enter to obtain the result of an entered
ommand.
There are a few important symbols that have spe
i
meaning in Maxima, namely
3
Maxima/2016
The use of these symbols will be ome lear when we illustrate some examples in the following se tions.
It is
lear that the input is labelled %i1 and the output %o1. These labels
an be used in future
al
ulations.
For instan
e, if you want to subtra
t this output from 20, the
ommand will be either 20 − % (the last
al
ulated result) or 20−%o1, using the label. (Be
areful not to type a zero in stead of an o.)
The operators that we use for multipli
ation and division are * and /, respe
tively, and to raise a value to a
power, we use . In the following part of the s
reen, we show
ommands using su
h operators.
To assign some value to a variable, we use the
olon (:). For example, the input a:2 assigns 2 to the variable
a, that is a = 2. In the following part of the s
reen, we show the in and outputs for a = 2, b = 5 and 2a + b:
Note that Maxima will not a
ept 2a + b if it is entered as 2a+b. An asterisk must always be used for
multipli
ation. For example, an expression like (a+b)(2a−1) must be entered as (a+b)*(2*a-1) in Maxima.
4
Maxima/2016
A
tivity
1. Enter the following Maxima
ommands and make sure you understand the logi
:
ertain way to get the orre t output. In the following table some of these are shown:
Mathemati
al Maxima
symbol/fun
tion input
π %pi
ln(2) log(2)
e %e
e2 (%e)2
exp(2)
√
2 sqrt(2)
sqrt(2.0)
d
(...) diff(...)
dx
integrate(...)
R
(...)
√
To nd the numeri
al value of π , e, 4, et
. use the float
ommand, or enter the value as a de
imal. For
instan
e, float(%pi), float(%e), float(sqrt(4)) or sqrt(4.0), et
.
A
tivity
Enter the following Maxima
ommands and
he
k that your outputs are the same as ours. Also make sure
you understand the logi
.
5
Maxima/2016
Note that all these a
tions were performed on the same fun
tion. Here, %o15 gives %o14 simplied; %o16
gives %o15 fa
tored, et
. We
ould therefore simply sele
t the a
tions and a
ept the % for the last expression
entered or
al
ulated.
A
tivity
1. Simplify the following expressions:
5x5
(a)
3x3
(b) 2(3 + x) + x(1 − 4x) + 5
6
Maxima/2016
x2 − 6x + 2
(a) (Remember that Maxima sets su
h expressions equal to zero when solved.)
x−3
(b) 2x + 3(x − 3) = 6
Composite fun
tions (a fun
tion of a fun
tion) denoted by (f ◦ g)(x) or (g ◦ f )(x)
an also be
omputed, as
an be seen in the following example:
7
Maxima/2016
A
tivity
1
Enter the fun
tions f (x) = and g(x) = x2 + 1 into Maxima and nd
x
(b) g(10)
(d) (g◦f )(x) and (g◦f )(3) (in both fra tional and de imal forms)
3.3.2 Limits
To nd the limit of a fun
tion in a
ertain point, go to Cal
ulus on the menu bar and sele
t Find Limit.
x
To nd the limit lim 4 − , we enter the fun
tion and the point in whi
h we need to nd the limit in the
x→4 2
Limit window. Note that limits are by default
al
ulated from both sides, unless spe
ied otherwise.
The ommand line input and subsequent output are the following:
A
tivity
Find the following limits:
x−9
(a) lim √
x→9 x−3
2x − 1
(b) lim
x→∞ x+1
3.3.3 Dierentiation
To dierentiate an expression like 5x3 + 4 sin x, go to Cal
ulus in the menu bar and sele
t Dierentiate. A
window opens where one
an enter the expression or fun
tion to be dierentiated. The
ommand line input
is %i1 and the output is %o1 in the following example.
8
Maxima/2016
An existing expression, like %i2
an be dierentiated by simply sele
ting Dierentiate. The window will
ontain % and the last entered expression (%i2) will be dierentiated (%o3).
Finally, one
an highlight an existing expression, su
h as %i2, and then sele
t Dierentiate to have it
dierentiated.
A
tivity
Dierentiate ea
h of the following fun
tions:
3.3.4 Integration
The same pro
edures as for dierentiation
an be followed for integration. Under Cal
ulus sele
t Integrate.
On
e again the last entered expression (%o3 of the previous example) will be integrated if you leave it as it
omes up, giving %o5.
An expression
an also be integrated by entering it in the Integrate window or highlighting an existing
expression and then sele
ting Integrate.
A
tivity
Find the following integrals:
x+9
Z
(a) dx
x2
Z
(b) ln e2x−1 dx
9
Maxima/2016
1
1
Z
(
) dx
0 4 − x2
The ommand line input and resulting output for these equations are as follows:
A
tivity
Solve ea
h of the following systems of linear equations:
(a) 3x + 4y = 10 and x = 3 − y
x− y+ z = 10
(b) 3x + y + 2z = 34
−5x + 2y − z = −14
3.4.2 Matri
es
To enter a matrix in Maxima, go to Algebra on the menu bar and sele
t Enter Matrix. A window opens
where the dimensions of the matrix
an be spe
ied and the matrix
an be named.
" # When you
li
k OK the
1 2
values
an be entered. For example if we want to enter the 2 × 2 matrix a = , these windows will be
3 5
as follows:
10
Maxima/2016
If we now need to nd the determinant, the transpose and the inverse of this matrix, we simply sele
t
Determinant, Transpose and Invert Matrix from Cal
ulus to get the following outputs:
Note that after you have found the determinant, the % in the Transpose and Invert Matrix windows will no
longer represent the original matrix (it represents the last in or output). So, to ensure you use the original
matrix, highlight it before you sele
t Transpose or Invert Matrix.
" #
−1 3
Now enter the matrix b = in the same way as we did for a, so we
an add or multiply them.
1 2
At the left, matri
es a and b are entered. At the right we see that addition works perfe
tly, but a ∗ b simply
multiplies ea
h element in a with the
orresponding element in b. It is therefore important to remember that
to nd the
orre
t answer for a × b, one must enter a.b.
A
tivity
Find the transpose, determinant and inverse of the following matrix:
1 2 −1
5 3 4
−2 0 1
11
Maxima/2016
3.5 Graphs
3.5.1 Graphing single fun
tions
To draw the graph of a fun
tion,
li
k Plot on the menu bar and sele
t Plot 2d. In the window that opens,
insert the fun
tion to be graphed, in this
ase f (x) = x2 + 2x − 5, and
li
k OK.
The ommand line input and the resulting output graph of the fun tion are as follows:
[Note that su
h a graph
an be
opied or saved to be in
luded in a do
ument by right-
li
king on it and
sele
ting Copy or Save Image.℄
12
Maxima/2016
The ommand line input and the resulting output graph of sin(x) and cos(x) are as follows:
Another way to graph multiple fun
tions is to dene the fun
tions (f and g) rst and then simply enter them
as f,g in the Plot 2D window. For example, the graph of the fun
tions f (x) = x+1 and g(x) = ex is as follows:
13
Maxima/2016
This results in the following ommand line input and output graph:
A
tivity
1. Sket
h the graph of ea
h of the following fun
tions and nd the domain and range of ea
h:
(a) f (x) = 4 − x
√
(b) g(x) = x − 1
(
) h(x) = 2 sin πx
sin x2
(d) j(x) = x
1
(e) f (x) = (Does limx→1 f (x) exist?)
x−1
1
2. Consider the fun
tions f (x) = and g(x) = x2 + 1.
x
(a) Sket
h the graphs of f and g.
(b) Find the domain and range of (f ◦g)(x).
3. Determine graphi ally whether ea h of the following fun tions is even or odd. Justify your answers.
14
Maxima/2016
4 Solutions to a
tivities
4.1 Paragraph 3.1 (Simple
al
ulations)
2. The in and outputs are as follows:
2. Fa torising
3. Solving
15
Maxima/2016
16
Maxima/2016
17
Maxima/2016
√
(b) The domain of g(x) = x − 1 is (1; ∞) and the range is (0; ∞).
sin(x2 )
(d) The domain of j(x) = is R and the range is [−0, 84; 0, 84].
x
1
(e) The domain of f (x) = is R\{1} and the range is R\{0}. The limit limx→1 f (x) does not
x−1
exist.
18
Maxima/2016
1
2. We
onsider the fun
tions f (x) = and g(x) = x2 + 1.
x
(a) The graphs of f and g are the following:
(b) The domain of f ◦g is R and and range is (0; 1]. This an be seen in the following graph:
3. To nd graphi ally whether fun tions are even or odd, we draw the graphs.
(a) The fun
tion f (x) = x3 − 3x2 is neither even nor odd sin
e its graph is neither symmetri
al around
the y axis, nor is it ree
ted rst around the y axis and then around the negative x axis.
√
(b) The graph of f (x) = x2 + 4 is symmetri
al around the y axis, therefore we
an say it is an even
fun
tion.
19