Lab Manual Wxmaxima
Lab Manual Wxmaxima
D EPARTMENT OF M ATHEMATICS
DAYANANDA S AGAR C OLLEGE OF E NGINEERING
VISION
To impart quality technical education with a focus on Research and Innovation emphasis-
ing on Development of Sustainable and Inclusive Technology for the benefit of society.
MISSION
• To provide an environment that enhances creativity and Innovation in pursuit of
Excellence.
• To nurture teamwork in order to transform individuals as responsible leaders and
entrepreneurs.
• To train the students to the changing technical scenario and make them to under-
stand the importance of Sustainable and Inclusive technologies.
DEPARTMENT OF MATHEMATICS
VISION
To create lifelong competent and socially innovative Engineers capable of working in
multicultural environment in the world.
MISSION
• To Enhance Mathematical knowledge which will enable them to analyze, interpret
and optimize any engineering related problem.
• To imbibe interest in the convergence of Science and Technology through continu-
ous Research activities.
• To provide a platform to develop extraordinary professionals with high ethical val-
ues to meet the future age world.
i
wxMaxima: Lab Manual
Preface
Maxima is a computer algebra system, implemented in Lisp. Maxima is derived from the
Macsyma system, developed at MIT in the years 1968 through 1982 as part of Project
Mathematics and Computation (MAC). MIT turned over a copy of the Macsyma source
code to the Department of Energy (DOE) in 1982; that version is now known as DOE
Macsyma. A copy of DOE Macsyma was maintained by Professor William F. Schelter of
the University of Texas from 1982 to 2001. In 1998, Schelter obtained permission from
the Department of Energy to release the DOE Macsyma source code under the GNU Pub-
lic License, and in 2000 he initiated the Maxima project at SourceForge to maintain and
develop DOE Macsyma, now called Maxima.
wxMaxima:
wxMaxima is a user interface for the computer algebra system (CAS) Maxima. The in-
terface allows the user to build, edit and save a document (a .wxm file) containing many
calculations and graphics, and most operations (simplifying, rationalizing, solving, func-
tions, fractions, trig, derivatives, integrals, etc.) can be accessed through the GUI if de-
sired. Maxima and wxMaxima are open-source projects, which means they will always
be free and they are always improving. Importantly it is user-friendly with more accuracy.
The latest version of wxMaxima for Windows and Mac machines can be obtained here:
https://t.ly/JoDE. This link will be taken to a sourceforge.net page that will automatically
download Maxima, wxMaxima, GNUplot, and any other necessary auxiliary programs
required for wxMaxima to run on a computer. Installation on a Windows machine typi-
cally takes about 5 minutes.
Software Versions:
This text is written using wxMaxima version 5.45.1 for newer versions of the software, it
is unlikely to cause any problems and bugs do occur rarely.
ii
wxMaxima: Lab Manual
symbolically.
Assuming only basic experience with computers (comfort with an operating system such
as Windows or Mac OS), each text gradually introduces computer algebra by using exam-
ples relevant to the concurrent math course. The main theoretical points of each course are
reviewed concisely, and commands are introduced as they are needed. Examples motivate
and reinforce the important mathematical concepts and illustrate their applications in the
context of computer algebra. Written commands are used exclusively for two reasons:
first, they are more powerful and flexible, and second, getting comfortable with written
commands ensures that the computing learned here will translate easily to other software
packages.
Text Layout:
Each lab component typically starts with a short theoretical discussion followed by ex-
amples worked in wxMaxima. Each lab component ends with a short set of Exercises
progressing from routine to advanced.
To the Student:
For students, it is important to work through the Examples. When students type out the
commands for him/herself, they will undoubtedly make syntax errors that have to be de-
bugged. Fixing syntax errors that occurred in a worked example is excellent preparation
for doing the Exercises on his/her own.
iii
wxMaxima: Lab Manual
Acknowledgement
Ms. Sowmya K
Coordinator
iv
Contents
Preface ii
Acknowledgement iv
Basic Operations 1
0.1 Lab 1: 2D and 3D Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
0.1.1 Plotting 3D graph . . . . . . . . . . . . . . . . . . . . . . . . . . 5
0.1.2 Plotting 3D graph with grid points (mesh points) . . . . . . . . . 5
0.1.3 Plotting of polar curves . . . . . . . . . . . . . . . . . . . . . . . 6
0.2 Lab 2: Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
0.3 Lab 3: Jacobians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
0.4 Lab 4: Operations on Matrix . . . . . . . . . . . . . . . . . . . . . . . . 11
0.5 Lab 5: Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . 13
0.6 Lab 6: Finding Roots of Equations . . . . . . . . . . . . . . . . . . . . . 15
0.7 Lab 7: Solving Linear System of Equations . . . . . . . . . . . . . . . . 17
0.8 Lab 8: Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
v
wxMaxima: Lab Manual
Basic Operations
wxMaxima uses +, −, ∗, /, ∧, sqrt, log for add, subtract, multiply, divide, exponentiate,
square root and natural log. The decimal approximation and calling of previous result can
be done using float and % respectively. The input line end with ; and to get the output hit
shift+enter. To hide the output of a calculation, end the line with $ instead of ;.
Example 1: Perform the following arithmetic operations:
1. Compute (2 · 5 + 10)/(10 − 15).
√
2. Add 7 to the previous output.
3. Find a decimal approximation for the previous output.
4. Square the previous output.
Maxima commands:
wxMaxima uses the symbol %e for the constant e. For angles the inputs are given in
radians, so it is must to convert any problem in degree to radians using a factor of 2π/360.
%pi is the special symbol for π.
Maxima commands:
(%i5) %pi;
(%o5) π
(%i6) cos(%pi);
(%o6) − 1
(%i7) sin(%pi);
(%o7) 0
(%i8) %e∧ (%pi ∗ %i) + 1;
(%o8) 0
1
wxMaxima: Lab Manual
(%i9) %i∧ 2;
(%o9) − 1
(%i10) %e∧ (%pi ∗ %i);
(%o10) − 1
(%i11) log(1);
(%o11) 0;
Assigning values
Users can assign values or functions by calling a variable and perform any operation on
that variable. To clear the assigned variable call kill(variable) and to clear all data use
kill(all).
Maxima commands:
(%i12) a : 5;
(%o12) 5
(%i13) a ∗ 5;
(%o13) 25
(%i14) A : 2 ∗ x + 3$
B : 3 ∗ x − 2$
(%i15) A + B;
(%o15) 5x + 1
(%i16) kill(a);
(%o16) done
(%i17) kill(all);
(%o17) done
2
wxMaxima: Lab Manual
3
wxMaxima: Lab Manual
Example 4: Plot a discrete points x : 1, 2, 3, 4, 5 and y : 2, 8, 13, 15, 20. Label x and y
axis. Also use legend, color.
Maxima commands:
(%i4) plot2d([′ discrete, [1, 2, 3, 4, 5], [2, 8, 13, 15, 20]],
[color, red], [xlabel, “P endulum Length(cm)”], [ylabel, “P eriod(s)”],
[legend, “Experiment”]);
4
wxMaxima: Lab Manual
5
wxMaxima: Lab Manual
Example 8: Plot a function (1 − cos2 t), (1 − sin2 t),t varies from 0 to 2π, x ∈ [−8, 8].
Maxima commands:
(%i8) plot2d([(1 − cos(t)2 ), (1 − sin(t)2 )], [t, 0, 2 ∗ %pi], [x, −8, 8],
[gnuplot postamble, “setpolar”]);
6
wxMaxima: Lab Manual
Problems:
7
wxMaxima: Lab Manual
x ′ ′′
Example 2: If y(x) = xx , find y (x), y (x).
Maxima commands:
x
(%i5) y : xx $
(%i6) y1 : dif f (y, x, 1);
x
(%o6) xx (xx log(x)(log(x) + 1) + xx−1 )
8
wxMaxima: Lab Manual
Problems:
1. Find differentiation of 2x3 − 3x2 + 2.
1
2. Differentiate: (i) e3x (ii) a3x (iii) (3x+2)
(iv) log(2x + 5)
3. Differentiate: (i) sinx cos2x (ii) sin2 x cos3 x (iii) x3 + secx − e−5x
(iv) log(2x) + 5x − 2
4
4. Find second order derivative of (i) sinx cos3x (ii) cos3 x (iii) (x2 + 5) − ex
(iv) log(3x)
x 1
5. Find third order derivative of (i) (1+3x+2x2 )
(ii) e2x cos3 x (iii) (1−x−x2 +x3 )
−1 x
(iv) tanh
a
2
6. Find fourth order derivative of (i) 4e3x (ii) 1
(1−x)5
(iii) tan−1 x (iv) sin−1 4x
7. Find ux , uxx and uxxx for the following (i) u = cosh4x (ii) cosx cos3x cos5x
(iii) tan−1 3x (iv) sin−1 4x
Note: For inverse trigonometric functions add ‘a′ as a prefix. Example: for tan−1 x,
command is atan(x).
9
wxMaxima: Lab Manual
wxMaxima can find the Jacobian of a function using the jacobian command. First find
the Jacobian using the jacobian command then find the determinant value by using the
command determinant.
∂(u,v)
Example 1: If u = x2 − 2y and v = x + y find J = ∂(x,y)
.
Maxima commands:
(%i1) u : x2 − 2 ∗ y; v : x + y$
(%i2) J : jacobian([u, v], [x, y]);
2x −2
(%o2)
1 1
(%i3) D : determinant(J);
(%o3) 2x + 2
Problems:
∂(u,v)
1. If u = 2xy, v = x2 − y 2 find J = ∂(x,y)
.
∂(x,y,z)
2. If u = x + y + z, uv = y + z, uvw = z, find J = ∂(u,v,w)
.
∂(u,v,w)
3. If u = x + 3y 2 − z 3 , v = 4x2 yz, w = 2z 2 − xy evaluate ∂(x,y,z)
at the point
(1,-1,0).
10
wxMaxima: Lab Manual
Problems:
1 2 2 3
1. Given A = and B = find A + B, A − B and AB.
3 4 4 5
2. Find the inverse of the following matrix
1 0 −1
1 −2
(i) A = (ii) A = 3 4 5
−3 8
0 −6 −7
3. Find the echelon form of the following matrix
11
wxMaxima: Lab Manual
1 2 3 2 0 2 3 4
(i) A = 2 3 5 1 (ii) A = 2 3 5 4
1 3 4 5 4 8 13 12
4. Find the rank of the following matrix
2 −1 −3 −1 0 1 −3 −1
1 2 3 −1 1 0 1 1
(i) A =
1 0 (ii) A =
1 1 3 1 0 2
0 1 1 −1 1 1 −2 0
5. Find the eigen value and eigen vector of the following matrix
6 −2 2 4 1 −1 2 −1 0 10 2 1
(i) −2 3 −1 (ii) 2 3 −1 (iii) −1 2 −1 (iv) 2 10 1
2 −1 3 −2 1 5 0 −1 2 2 1 10
12
wxMaxima: Lab Manual
Maxima commands:
Maxima commands:
13
wxMaxima: Lab Manual
dr
Example 3: Solve rsin(θ) − cos(θ) = r2 .
dθ
Maxima commands:
Problems:
dy
1. Solve x dx + y = y 2 logx
dy
2. Solve dx
= e(3x−2y) + x2 e−2y
d2 y dy
3. Solve dx2
+ 17 dx + 12y = 0
d y 3 d y 2
4. Solve 4 dx3 + 4 dx2 + y = 0
d2 y dy
7. Solve dx2
− 2 dx + y = xex sinx
8. Solve (D2 − 3D + 2)y = 2sinxcosx + xex
d2 y dy
9. Solve dx2
+ 3 dx + 2y = x2 + 3x + 1
d2 y dy dy
10. Solve: dx2
+ 5 dx + 6y = 0 given that y(0) = 0, dx (0) = 15
d2 y dy dy
11. Solve: dx2
+ 4 dx + 5y = −2coshx, given that y(0) = 0, dx (0) = 1
14
wxMaxima: Lab Manual
Example 2: Find the roots of the equation xsinx + cosx = 0 in (0, π).
Maxima commands:
15
wxMaxima: Lab Manual
16
wxMaxima: Lab Manual
17
wxMaxima: Lab Manual
18
wxMaxima: Lab Manual
19
wxMaxima: Lab Manual
20
wxMaxima: Lab Manual
Example 2: Find the dot product of two vectors ⃗a = î + 2ĵ + 3k̂ and ⃗b = î − ĵ + 3k̂.
To find the dot product of two vectors use “ · ” between the vectors.
i.e., ⃗a · ⃗b = (î + 2ĵ + 3k̂) · (î − ĵ + 3k̂) = 1(1) + 2(−1) + 3(3) = 8.
Maxima commands:
(%i6) a · b;
(%o6) 8
To cross check the solution
(%i7) 1 · 1 + 2 · −1 + 3 · 3;
(%o7) 8
Example 3: Find the cross product of two vectors ⃗a = î + 2ĵ + 3k̂ and ⃗b = î − ĵ + 3k̂.
To find the cross product of two vectors use “ ∼ ” between the vectors. The package vect
must be loaded before finding the cross product.
⃗i ⃗j ⃗k
Maxima commands:
(%i8) load(vect);
(%i9) a ∼ b;
(%o9) − [1, −1, 3] ∼ [1, 2, 3]
(%i10) express(%);
(%o10) [9, 0, −3]
Example 4: Given vectors ⃗a = î + 2ĵ + 3k̂, ⃗b = î − ĵ + 3k̂ and ⃗c = 2î − 2ĵ + k̂.
21
wxMaxima: Lab Manual
Maxima commands:
(%i18) f : x2 · y + 2 · x · z;
(%o18) 2xz + x2 y
(%i19) scalef actors([x, y, z]);
(%o19) done
(%i20) gdf : grad(f );
(%o21) [2z + 2xy, x2 , 2x]
22
wxMaxima: Lab Manual
Maxima commands:
(%i22) load(vect);
(%i23) kill(f )$
(%i24) f : x∧ 2 · y · z + 4 · x∧ 2 · y;
(%o24) x2 yz + 4x2 y
(%i25) scalef actors([x, y, z]);
(%o25) done
(%i26) gdf : grad(f );
(%o26) grad(x2 yz + 4x2 y)
(%i27) ev(express(gdf ), dif f );
(%o27) [2xyz + 8xy, x2 z + 4x2 , x2 y]
(%i28) def ine(gdf (x, y, z), %);
(%o28) gdf (x, y, z) := [2xyz + 8xy, x2 z + 4x2 , x2 y];
(%i29) delphi : gdf (1, −2, −1);
(%o29) [−12, 3, −2]
(%i30) d : [2, −1, −2]$ n : d/sqrt(d · d);
2 1 2
(%o30) ,− ,−
3 3 3
(%i31) dd : delphi · n;
23
(%o31) −
3
23
wxMaxima: Lab Manual
24
wxMaxima: Lab Manual
(%i47) load(draw);
(%i50) gimp : implicit(9 = x∧ 2 + y ∧ 2 + z ∧ 2, x, −4, 4, y, −4, 4, z, −4, 4);
gexp : implicit(x∧ 2 + y ∧ 2 − z = 3, x, −4, 4, y, −4, 4, z, −4, 4);
draw3d(proportional axes = xyz, xyplane = 0,
color = red, gexp, color = blue, gimp)$
(%o48) implicit(9 = z 2 + y 2 + x2 , x, −4, 4, y, −4, 4, z, −4, 4)
(%o49) implicit(−z + y 2 + x2 = 3, x, −4, 4, y, −4, 4, z, −4, 4)
Problems:
1. For a given vector ⃗a = 4î − 2ĵ + 6k̂ and ⃗b = î + 3ĵ + 3k̂ find
(a) a + ⃗b
(b) a − ⃗b
(c) 3a
(d) 3a + 2⃗b
25
wxMaxima: Lab Manual
(b) F⃗ · G
⃗
(c) gradF⃗
⃗ at the point (1,2,3).
(d) gradG
7. If Φ = xy + yz + zx and F⃗ = x2 y î + y 2 z ĵ + z 2 xk̂ find F⃗ · Φ and F⃗ Φ at te point
(3,-1,2).
8. Find the angle between the normal to the surface xy = z 2 at the points (4,1,2) and
(3,3,-3).
9. Find the angle between the surfaces 4x2 + z 3 = 4 and 5x2 − 2yz − 9x = 0 at the
point (1,-1,2).
26
wxMaxima: Lab Manual
References
1. Zachary Hannan wxMaxima for Calculus II, 2015.
2. https://www2.palomar.edu/users/cchamberlin/Math%20205%20pages/Maxima/MaximaBook.pdf
3. https://www.youtube.com/playlist?list=PLEDEE2F7C6750729F
27