0% found this document useful (0 votes)
202 views33 pages

Lab Manual Wxmaxima

The document provides an introduction to the wxMaxima software for performing computer algebra. It outlines the vision and mission of the institution and department. It then describes the background of Maxima and wxMaxima as well as how to perform basic operations in wxMaxima such as arithmetic, plotting, derivatives, matrices, equations and more.

Uploaded by

johanan.jeshrun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views33 pages

Lab Manual Wxmaxima

The document provides an introduction to the wxMaxima software for performing computer algebra. It outlines the vision and mission of the institution and department. It then describes the background of Maxima and wxMaxima as well as how to perform basic operations in wxMaxima such as arithmetic, plotting, derivatives, matrices, equations and more.

Uploaded by

johanan.jeshrun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

wxMaxima: Lab Manual

Advanced Calculus and Numerical Methods


Course Code: 21MA201
2021-2022

D EPARTMENT OF M ATHEMATICS
DAYANANDA S AGAR C OLLEGE OF E NGINEERING

Ms. Sowmya K Dr. Radha Gupta


Coordinator Professor & Head of the Department
wxMaxima: Lab Manual

DAYANANDA S AGAR C OLLEGE OF E NGINEERING


BANGALORE-560078

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.

Computer Algebra Systems (CAS):


A computer algebra system is a collection of software designed primarily for symbolic
manipulation. A CAS can do just about any symbolic calculation one might do “by hand”,
but the CAS is much faster, more accurate, and capable of handling greater complexity.
Complex calculations can be broken into manageable pieces by using function assign-
ments, and systems can be explored by quickly changing their parameters. In addition to
symbolic manipulation, a CAS can produce quality graphics, make numerical approxima-
tions of various types and run simple programs to solve problems that cannot be solved

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

I express my sincere gratitude to Dayananda Sagar College of Engineering, Management,


for all the support and encouragement. My heartfelt thanks to Dr. C. P. S. Prakash,
Principal, DSCE, for his support in bringing up this lab manual. This manual would
not have been possible without the support of Dr. Radha Gupta, Professor and Head,
Department of Mathematics, Dayananda Sagar College of Engineering. I am also thankful
to Dr. Thriveni K, Assistant Professor, Department of Mathematics, Dayananda Sagar
College of Engineering for her support and suggestions. Finally, I would like to thank all
my colleague for their direct or indirect support in bringing up this manual.

Ms. Sowmya K
Coordinator

iv
Contents

Vision and Mission ii

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:

(%i1) (2 ∗ 5 + 10)/(10 − 15);


(%o1) − 4
(%i2) sqrt(7) + %;

(%o2) 7 − 4
(%i3) float(%);
(%o3) − 1.354248688935409
(%i4) %∧ 2;
(%o4) 1.833989511483275

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

0.1 Lab 1: 2D and 3D Plots


wxMaxima creates plots by calling another program called GNUplot. In this text, the
commands plot2d and plot3d are used to create 2D and 3D plots. The related commands
plot2d and plot3d will create the same plot in a GNUplot pop-up window.

Example 1: Plot a function sinx, x ranges from 0 to 2π.


Maxima commands:
(%i1) plot2d(sin(x), [x, 0, 2 ∗ %pi]);

Example 2: Plot a function cosx, x ranges from 0 to 2π.


Maxima commands:
(%i2) plot2d(cos(x), [x, 0, 2 ∗ %pi]);

3
wxMaxima: Lab Manual

Example 3: Plot a function x2 + 1, x ranges from 0 to 10.


Maxima commands:
(%i3) plot2d((x∧ 2 + 1), [x, 0, 10]);

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

0.1.1 Plotting 3D graph


Example 5: Plot a function x + y, x ranges from -3 to 3 and y ranges from -4 to 4.
Maxima commands:
(%i5) plot3d((x + y), [x, −3, 3], [y, −4, 4]);

0.1.2 Plotting 3D graph with grid points (mesh points)


Example 6: Plot a function x2 + y 2 , x ranges from -4 to 4, y ranges from -4 to 4 and grid
points(20,10).
Maxima commands:
(%i6) plot3d((x2 + y 2 ), [x, −4, 4], [y, −4, 4], [grid, 20, 10]);

5
wxMaxima: Lab Manual

0.1.3 Plotting of polar curves


Example 7: Plot a function 5(1 − cost), t varies from 0 to 2π, x ∈ [−10, 10], y ∈
[−13, 13].
Maxima commands:
(%i7) plot2d([5 ∗ (1 − cos(t))], [t, 0, 2 ∗ %pi], [x, −10, 10], [y, −13, 13],
[gnuplot postamble, “setpolar”], [color, red]);

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:

1. Plot a graph y(x) = x2 ,


(i) x ranges from 0 to 10.
(ii) x ranges from -10 to 10
2. If y(x) = x2 + 2x + 3, plot a graph x vs y for x ∈ [−5, 5].
3. Plot a discrete set of points defining x and y coordinates as [10,20, 30, 40, 50] and
[0.6, 0.9, 1.1, 1.3, 1.4] label x axis and y axis and give a color to curve.
4. Plot log(x2 y 2 ), x ∈ [−3, 3], y ∈ [−2, 2], z ∈ [0, 3].
5. Plot x3 + 3xy 2 − 15x2 − 15y 2 + 72x, x ∈ [0, 10], y ∈ [0, 30] and grid points (10,25)
6. Plot e2x , x ∈ [−5, 5], y ∈ [−10, 10]
2 +y 2 )
7. Plot 2−(x
(i) x ∈ [0, 10], y ∈ [0, 8]
(ii) x ∈ [−10, 10], y ∈ [−8, 8]
8. Plot 5(1 − cos2 t), (1 − cost),
(i) t varies from 0 to 2π, x ∈ [−10, 10]
(ii) t varies from 0 to 2π, x ∈ [−10, 10], y ∈ [−13, 13]
(iii) t varies from 0 to 6π, x ∈ [−6, 6], y ∈ [−7, 7]

7
wxMaxima: Lab Manual

0.2 Lab 2: Derivatives


wxMaxima can find the derivative of a function using the dif f command. To find the
derivative, first assign the function to a variable y, then use the command dif f (y, x, 1)
which is defined as y1. Here y is the function which is differentiated with respect to x
once. To get the second order derivative use the command dif f (y, x, 2) or dif f (y1, x, 1).
′ ′′ ′′′
Example 1: If y(x) = sinx, find y (x), y (x), y (x).
Maxima commands:
(%i1) y : sinx$
(%i2) y1 : dif f (y, x, 1);
(%o2) cos(x)
(%i3) y2 : dif f (y, x, 2);
(%o3) − sin(x)
(%i4) y3 : dif f (y, x, 3);
(%o4) − cos(x)
(%i5) plot2d([y, y1, y2, y3], [x, −5, 5]);

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

(%i7) y2 : dif f (y, x, 2);


x 2 x
(%o7) xx (xx log(x)(log(x) + 1) + xx−1 ) + xx (xx log(x)(log(x) + 1)2
 
x−1 x−1
+x log(x) + + xx−1 (log(x) + 1) + xx−1 log(x))
x
(%i8) plot2d([y, y1, y2], [x, 0.5, 2]);

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

0.3 Lab 3: Jacobians


A determinant which is defined for a finite number of functions of the same number of
variables and in which each row consists of the first partial derivatives of the same function
with respect to each of the variables.

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).

4. If x = rsinθcosϕ, y = rsinθsinϕ,z = rcosθ , prove that J = r2 sinθ.


∂(u,v,w)
5. Find ∂(x,y,z)
where u = x2 + y 2 + z 2 , v = xy + yz + zx, w = x + y + z.
∂(u,v,w)
6. If u = yz/x, v = zx/y, w = xy/z prove that ∂(x,y,z)
=4.
∂(u,v)
7. If u + v = ex cosy, u − v = ex siny then determine the Jacobian ∂(x,y)
.
∂(x,y) ∂(r,θ) ′
8. If x = rcosθ, y = rsinθ, find J = ∂(r,θ)
and J ′ = ∂(x,y)
. Verify JJ = 1.

10
wxMaxima: Lab Manual

0.4 Lab 4: Operations on Matrix


For a given matrix A, wxMaxima uses the commands determinant, echelon, rank, eigen-
values to find determinant, echelon form, rank, eigen value of a matrix A respectively.
Example 1: Find
 the determinant,
 echelon form, rank, eigen value and eigen vector of
2 3 4
the matrix A = −1
 2 3.
1 5 7
Maxima commands:

(%i1) A : matrix([2, 3, 4], [−1, 2, 3], [1, 5, 7]);


 
2 3 4
(%o1) −1 2 3
1 5 7
(%i2) determinant(A);
(%o2) 0
(%i3) echelon(A);
 
3
1 2 2 
(%o3) 0 1 10 
 
 7
0 0 0
(%i4) rank(A);
(%o4) 2
(%i5) eigenvalues(A);
"" p p # #
(57) − 11 (57) + 11
(%o5) − , , 0 , [1, 1, 1]
2 2

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

0.5 Lab 5: Ordinary Differential Equations


wxMaxima uses the command ode2(’); to solve the given differential equation and for a

given initial condition use the command ic2(solution,x=,y=,y =); .
dy
Example 1: Solve dx
+ y = 0.

Maxima commands:

(%i1) ode2(′ dif f (y, x) + y = 0, y, x)$


(%o1) y = %c ∗ %e−x
d2 y ′
Example 2: Solve dx2
+ y = x with y(0) = 1, y (0) = 2 and plot the graph in the range
(0, 2π).

Maxima commands:

(%i2) ode2(′ dif f (y, x, 2) + y = x, y, x);


ic2(y = %k1 ∗ sin(x) + %k2 ∗ cos(x) + x, x = 0, y = 1,′ dif f (y, x) = 2);
(%o2) y = sin(x) + cos(x) + x
(%i3) plot2d(sin(x) + cos(x) + x, [x, 0, %pi])

13
wxMaxima: Lab Manual

dr
Example 3: Solve rsin(θ) − cos(θ) = r2 .

Maxima commands:

(%i4) ode2(r ∗ sin(theta) −′ dif f (r, theta) ∗ cos(theta) = r2 , r, theta);


1
(%o4) r =
cos(θ)(tan(θ) + %c)

Note: For order ≥ 3, load(odes) and use odeL( ).

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

5. Solve: (4D4 − 4D3 − 23D2 + 12D + 36)y = 0


d y 2 dy −x
6. Solve 6 dx2 + 17 dx + 12y = e

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

0.6 Lab 6: Finding Roots of Equations


wxMaxima uses the command to poly solve([equation], [variable]); to solve the given
equation. To find the roots of the equation wxMaxima uses the command f ind root(equation,
variable, range);.
Example 1: Solve the equation x2 + 2x + 1 = 0.
Maxima commands:

(%i1) to poly solve([x2 + 2 ∗ x + 1], [x]);


(%o1) %union([x = −1])
(%i2) plot2d(x2 + 2 ∗ x + 1, [x, −2, 2]);

Example 2: Find the roots of the equation xsinx + cosx = 0 in (0, π).
Maxima commands:

(%i3) f ind root(x ∗ sin(x) + cos(x), x, 0, %pi);


(%o3) 2.798386045783887
(%i4) plot2d(x ∗ sin(x) + cos(x), [x, 0, %pi]);

15
wxMaxima: Lab Manual

Note: To find all roots maxima command is allroots().


Problems:
1. Solve x2 + 5x + 6 = 0
2. Solve x2 + a2 = 0.
3. Solve m2 + 2m + 10 = 0.
4. Solve m3 + 8 = 0.
5. Find the root of the equation x3 − 4x − 9 = 0 in (-3,3).
6. Find the root of the equation xlog10 (x) − 1.2 = 0 in (2,3).
7. Find all the roots of the equation x4 − 12 = 0.
8. Find the root of the equation tanx + tanhx = 0 lies between 2 and 3 and plot 2D
graph.
9. Find the root of the equation xexp(x) − cosx = 0 in the interval (0,1) and (15,-20)
and plot 2D graph in each interval.
10. Find the root of the equation tanx = x in the interval (4,5) and plot 2D graph.
x  x 2 5
11. Plot the 2D graph cos exp − − sin(x3/2 ) − in (0,5) find the interval
π 4 4
and root of the equation.
12. Find three possible intervals for which root exists for the equation x3 +5x−11 = 0.

16
wxMaxima: Lab Manual

0.7 Lab 7: Solving Linear System of Equations


wxMaxima uses the command linsolve([equations],[variables]); to solve a linear system
of equations.

Example 1: Solve the system of equations: 2x + 5y + 7z = 52, 2x + y − z = 3,


x + y + z = 9.
Maxima commands:

(%i1) linsolve([2 ∗ x + 5 ∗ y + 7 ∗ z = 52, 2 ∗ x + y − z = 3, x + y + z = 9], [x, y, z]);


 
1 27 11
(%o1) x = − , y = , z =
2 4 4
(%i2) t1 : implicit(2 ∗ x + 5 ∗ y + 7 ∗ z = 52, x, −5, 5, y, −5, 5, z, −5, 5)$
t2 : implicit(2 ∗ x + y − z = 3, x, −5, 5, y, −5, 5, z, −5, 5)$
t3 : implicit(x + y + z = 9, x, −5, 5, y, −5, 5, z, −5, 5)$
draw3d(t1, t2, t3, color = red, t1, color = blue, t2, color = green, t3,
xlabel = x, ylabel = y, zlabel = z);

17
wxMaxima: Lab Manual

Example 2: Solve the system of equations: −6x + 4y = 2, 3x − 2y = −1.


Maxima commands:

(%i3) linsolve([−6 ∗ x + 4 ∗ y = 2, 3 ∗ x − 2 ∗ y = −1], [x, y]);


 
2%r2 − 1
(%o3) x = , y = %r2
3
(%i4) plot2d([−6 ∗ x + 4 ∗ y = 2, 3 ∗ x − 2 ∗ y = −1], [x, −10, 10], [y, −20, 20]);

Example 3: Solve the system of equations: −4x + 10y = 6, 2x − 5y = 3.


Maxima commands:

(%i5) linsolve([−4 ∗ x + 10 ∗ y = 6, 2 ∗ x − 5 ∗ y = 3], [x, y]);


(%o5) [ ]
(%i6) plot2d([−4 ∗ x + 10 ∗ y = 6, 2 ∗ x − 5 ∗ y = 3], [x, −20, 20], [y, −20, 20]);

18
wxMaxima: Lab Manual

Problems: Solve the following system of equations


1. x + y + z = 9, x − 2y + 3z = 8, 2x + y − z = 3
2. x − y + z = 1, −3x + 2y − 3z = −6, 2x − 5y + 3z = 5
3. x − 4y + 7z = 14, 3x + 8y − 2z = 13, 7x − 8y + 26z = 5
4. x + 2y + 2z = 1, 2x + y + z = 2, 3x + 2y + 2z = 3, y + z = 0
5. 5x + 3y + 7z = 4, 3x + 26y + 2z = 9, 7x + 2y + 10z = 5
6. x + 2y + 3z = 0, 2x + 3y + z = 0, 4x + 5y + 4z = 0, x + y − 2z = 0
7. p + q − r + s = 0, p − q + 2 ∗ r − s = 0, p + q + s = 0

19
wxMaxima: Lab Manual

0.8 Lab 8: Vectors


wxMaxima uses the package vect for vector analysis. load (vect) loads this package. To
draw the figure use load(draw) package.

Example 1: Given vectors ⃗a = î + 2ĵ + 3k̂ and ⃗b = î − ĵ + 3k̂. Find ⃗a + ⃗b (vector


addition), 2⃗a (scalar multiplication) and draw the vectors.
Maxima commands:
(%i1) a : [1, 2, 3]; b : [1, −1, 3]$
(%i2) a + b;
(%o2) [2, 1, 6]
(%i3) 2 ∗ a;
(%o3) [2, 4, 6]
(%i4) load(draw);
(%i5) draw3d(proportional axes = xyz, xrange = [−3, 3], yrange = [−3, 3],
zrange = [−5, 5], xyplane = 0, xlabel = x, ylabel = y, zlabel = z,
enhanced3d = true, head angle = 25, head length = 0.1, color = red,
vector([0, 0, 0], [1, 2, 3]), color = blue, vector([0, 0, 0], [1, −1, 3]), color = green,
vector([0, 0, 0], [2, 1, 6]), color = black, vector([0, 0, 0], [2, 4, 6]));

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
 

i.e., ⃗a × ⃗b = 1 2 3 = 9⃗i − 3⃗k.


1 −1 3

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̂.

1. Find ⃗a · (b × ⃗c) (scalar triple product).

2. Find the vectors from ⃗a to ⃗b, and ⃗a to ⃗c.


⃗ = ⃗b − ⃗a and B
Let A ⃗ = ⃗c − ⃗a then, normal vector to the plane is ⃗n = A
⃗ × B.

21
wxMaxima: Lab Manual

Maxima commands:

(%i11) c : [2, −2, 1]$


(%i12) a · (b ∼ c);
(%o12) [1, 2, 3] · [1, −1, 3] ∼ [2, −2, 1]
(%i13) express(%);
(%o13) 15
(%i15) A : b − a; B : c − a;
(%o14) [0, −3, 0]
(%o15) [1, −4, −2]
(%i16) n : A ∼ B;
(%o16) [0, −3, 0] ∼ [1, −4, −2]
(%i17) express(%);
(%o17) [6, 0, 3]

Example 5: Find the gradient of function f : x2 y + 2xz.


∂f ∂f ∂f
Let f : x2 y + 2xz. Gradient of f is given by ▽f = î + ĵ + k̂
∂x ∂y ∂z
i.e., ▽f = (2xy + 2z)⃗i + x2 ĵ + 2xk̂
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

Example 6: Find the directional derivative of f : x2 yz+4x2 y at (1,-2,-1) along 2î−ĵ−2k̂.


⃗a
Directional derivative = ▽f · n̂ where n̂ = .
|⃗a|
Directional derivative of f : x2 yz + 4x2 y at (1, −2, −1) along 2î − ĵ − 2k̂ is
▽f = (2xyz + 8xy)î + (x2 z + 4x2 )ĵ + (x2 y)k̂
2î − ĵ − 2k̂
▽f(1,−2,−1) = −12î − 3ĵ − 2k̂, n̂ =
3
−23
▽f · n̂ =
3

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

Example 7: Find the angle between the surfaces x2 + y 2 + z 2 = 9 and z = x2 + y 2 − 3


at the point (2, −1, 2).
Maxima commands:

(%i33) phi : x∧ 2 + y ∧ 2 + z ∧ 2 − 9; psi : x∧ 2 + y ∧ 2 − z − 3;


(%o32) z 2 + y 2 + x2 − 9
(%o33) − z + y 2 + x2 − 3
(%i34) load(vect);
(%i35) scalef actors([x, y, z]);
(%o35) done
(%i36) grad(phi);
(%o36) grad(z 2 + y 2 + x2 − 9)
(%i37) ev(express(%), dif f );
(%o37) [2x, 2y, 2z]
(%i38) def ine(gdf 1(x, y, z), %);
(%o38) gdf 1(x, y, z) := [2x, 2y, 2z];
(%i39) delphi : gdf 1(2, −1, 2);
(%o39) [4, −2, 4]
(%i40) grad(psi);
(%o40) grad(−z + y 2 + x2 − 3)
(%i41) ev(express(%), dif f );
(%o41) [2x, 2y, −1]
(%i42) def ine(gdf 2(x, y, z), %);
(%o42) gdf 2(x, y, z) := [2x, 2y, −1]
(%i43) delpsi : gdf 2(2, −1, 2);
(%o43) [4, −2, −1]
(%i44) mod delphi : sqrt(delphi.delphi);
(%o44) 6
(%i45) mod delpsi : sqrt(delpsi.delpsi);

(%o45) 21
(%i46) theta : acos(delphi.delpsi/(mod delphi · mod delpsi));
 
8
(%o46) acos √
3 21

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

and draw the graphs.


2. For a given vector ⃗a = î − 2ĵ + 2k̂, ⃗b = 43 − 2ĵ + k̂ and ⃗c = î + 3ĵ + 3k̂ find
(a) ⃗a · ⃗b · ⃗c
(b) ⃗a · (⃗b × ⃗c)
(c) (⃗a × ⃗b) · ⃗c
3. For a given vector ⃗a = î − 2ĵ + 2k̂, ⃗b = 43 − 2ĵ + k̂ and ⃗c = î + 3ĵ + 3k̂ verify
⃗a × (⃗b × ⃗c) = (⃗a × ⃗b) × ⃗c.
4. Find the directional derivative of Φ = 4xz 3 − 3x2 y 2 z at (2,-2,2) along 2î − 3ĵ + 6k̂.
5. Find the directional derivative of the following Φ = 2x2 yz + xz 2 at (1,-1,-1) along
2î − ĵ − 2k̂.
6. F⃗ = 2xy 3 î + 3x2 y 2 z 4 ĵ + 4y 3 z 3 k and G = yz î + zxĵ + xy k̂ find
(a) F⃗ × G

(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

You might also like