Wxmaxima Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

wxMaxima: Lab Manual - I

I Semester : Mathematics for ME/EE/CS/CV Stream-I

2022 - 2023

Name of the Student :


Semester / Section :
USN :
Batch :

DAYANANDA S AGAR C OLLEGE OF E NGINEERING


Accredited by National Assessment & Accreditation Council (NAAC) with ’A’ Grade
(An Autonomous / Institution Affiliated to Visvesvaraya Technological University, Belagavi
& ISO 9001 : 2015 Certified)

D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078
wxMaxima: Lab Manual - I

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.
wxMaxima: Lab Manual - I

wxMaxima: Lab Manual - I


I Semester : Mathematics for ME/EE/CS/CV Stream-I
2022 - 2023

Name of the Student :


Semester / Section :
USN :
Batch :

DAYANANDA S AGAR C OLLEGE OF E NGINEERING


Accredited by National Assessment & Accreditation Council (NAAC) with ’A’ Grade
(An Autonomous / Institution Affiliated to Visvesvaraya Technological University, Belagavi
& ISO 9001 : 2015 Certified)

D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078

Dr. Sowmya K Dr. Radha Gupta


Coordinator Professor & Head of the Department
wxMaxima: Lab Manual - I

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
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
wxMaxima: Lab Manual - I

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.
wxMaxima: Lab Manual - I

Acknowledgement

I am highly grateful to Management, Dayananda Sagar College of Engineering, for all


the support and encouragement. My heartfelt thanks to Dr. C. P. S. Prakash, Principal,
DSCE, Dr. D. R. Ramesh Babu, Dr. Ramaraju H. K. and Dr. Suma V, Vice-Principals,
DSCE for their 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, DSCE. I am also thankful to Dr. Thriveni K, Assistant Professor, Depart-
ment of Mathematics, 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.

Dr. Sowmya K
Coordinator
Contents

Vision and Mission

Preface

Acknowledgement
1 Lab 1: Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Lab 2: Plotting 2D graph . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Lab 3: Plotting 3D graph . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Lab 4: Plotting polar curves . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Lab 5: Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6 Lab 6: Jacobians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7 Lab 7: Operations on Matrix . . . . . . . . . . . . . . . . . . . . . . . . 11
8 Lab 8: Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . 13
9 Lab 9: Finding Roots of Equations . . . . . . . . . . . . . . . . . . . . . 15
10 Lab 10: Solving Linear System of Equations . . . . . . . . . . . . . . . . 17
wxMaxima: Lab Manual - I

1 Lab 1: 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 - I

(%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 - I

2 Lab 2: Plotting 2D graph


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]);

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


Maxima commands:

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

3
wxMaxima: Lab Manual - I

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 - I

3 Lab 3: Plotting 3D graph


Example 1: 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]);

Plotting 3D graph with grid points (mesh points)

Example 2: 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 - I

4 Lab 4: Plotting polar curves


Example 1: 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 2: 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 - I

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 - I

5 Lab 5: 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 : sin(x)$
(%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 )
(%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

8
wxMaxima: Lab Manual - I

(%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 )
x
(iv) tanh−1
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 - I

6 Lab 6: 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 - I

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

11
wxMaxima: Lab Manual - I
   
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 - I

8 Lab 8: 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
dy
Example 2: Solve dx
= x − y with y(0) = 1 and plot the graph in the range (0, π).

Maxima commands:

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


ic1(y = %e−x ((x − 1)%ex + %c), x = 0, y = 1);
(%o2) y = %e−x ∗ ((x − 1) ∗ %ex + %2)
(%i3) plot2d(%e−x ∗ ((x − 1) ∗ %ex + %2, [x, 0, %pi])

13
wxMaxima: Lab Manual - I
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)

Problems:
dy
1. Solve x dx + y = y 2 logx
dy
2. Solve dx
= e(3x−2y) + x2 e−2y
dy
3. Solve x dx = x2 + 3y
dy
4. Solve x dx + y = ex
dy
5. Solve: ex dx + 2ex y = 1
dy
6. Solve x dx − y = 2xlnx
dr
7. Solve tan(θ) + r = sin2 (θ)

dy
8. Solve dx
= xy given that y(1) = 1
dy
9. Solve: dx
= x2 + y 2 given that y(0) = 0
dy
10. Solve: dx
= 2x − y given that y(−1) = 1

14
wxMaxima: Lab Manual - I

9 Lab 9: 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 - I

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 - I

10 Lab 10: 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 - I

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 - I

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 - II
II Semester : Mathematics for ME/EE/CS/CV Stream-II

2022 - 2023

Name of the Student :


Semester / Section :
USN :
Batch :

DAYANANDA S AGAR C OLLEGE OF E NGINEERING


Accredited by National Assessment & Accreditation Council (NAAC) with ’A’ Grade
(An Autonomous / Institution Affiliated to Visvesvaraya Technological University, Belagavi
& ISO 9001 : 2015 Certified)

D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078
wxMaxima: Lab Manual - II

wxMaxima: Lab Manual - II


II Semester : Mathematics for ME/EE/CS/CV Stream-II
2022 - 2023

Name of the Student :


Semester / Section :
USN :
Batch :

DAYANANDA S AGAR C OLLEGE OF E NGINEERING


Accredited by National Assessment & Accreditation Council (NAAC) with ’A’ Grade
(An Autonomous / Institution Affiliated to Visvesvaraya Technological University, Belagavi
& ISO 9001 : 2015 Certified)

D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078

Dr. Chitra R
Ms. V Selva Sharmila Dr. Radha Gupta
Ms. Padmaja C Professor & Head of the Department
Coordinators
wxMaxima: Lab Manual - II

Acknowledgement

We express our sincere gratitude to the Management, Dayananda Sagar College of


Engineering, Bengaluru, for all the support and encouragement. My heartfelt thanks to
Dr. C. P. S. Prakash, Principal, Dr. D. R. Ramesh Babu, Dr. Ramaraju H. K. and Dr. Suma
V, Vice-Principals, DSCE for their 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. A huge
thanks to Dr. Thriveni K, for all her timely help, support and suggestions. Finally, we
would like to thank all our colleagues for their direct or indirect support in bringing up
this manual.

Dr Chitra R
Ms. V Selva Sharmila
Ms. Padmaja C
Coordinators
Contents

Acknowledgement
1 Lab 1: Basic Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Lab 1.1: Integration between limits . . . . . . . . . . . . . . . . 2
1.2 Lab 1.2: Double Integration . . . . . . . . . . . . . . . . . . . . 2
1.3 Lab 1.3: Integration for product of two functions . . . . . . . . . 2
2 Lab 2: Definite Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 Lab 2.1: Area between two curves f1 (x) and f2 (x) . . . . . . . . 4
2.2 Lab 2.2: Evaluation of Beta Integral and Gamma Integral . . . . . 4
3 Lab 3: Vector Calculus - 1 . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Lab 3.1: Basic Operations in Vectors . . . . . . . . . . . . . . . 6
4 Lab 4: Vector Differentiation . . . . . . . . . . . . . . . . . . . . . . . . 8
5 Lab 5: Vector Calculus - 2 . . . . . . . . . . . . . . . . . . . . . . . . . 13
6 Lab 6: Ordinary Differential Equation with constant coefficients . . . . . 15
7 Lab 7: Numerical Methods
Lagrange’s Interpolation Formula . . . . . . . . . . . . . . . . . . . . . 16
8 Lab 8: Numerical Integration using Simpson’s 1/3rd rule . . . . . . . . . 18
9 Lab 9: Integration using Simpson’s 3/8th rule . . . . . . . . . . . . . . . 19
10 Lab 10: Integration using Weddle’s rule . . . . . . . . . . . . . . . . . . 20
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
wxMaxima: Lab Manual - II

1 Lab 1: Basic Integration


In this program, we shall use the basic commands to integrate, the given function once,
twice etc. Also, we shall integrate the given function with respect to x, y. The wxMaxima
command used is integrate(function, with respect to variable).

R
Example 1: xdx
Maxima commands:

(%i1) integrate(x, x)
(%o1) x2 /2

R
Example 2: y 3 dy
Maxima commands:

(%i1) integrate(y ∧ 3, y)
(%o1) y 4 /4

R
Example 3: sin(x)3 dx
Maxima commands:

(%i1) integrate(sin(x)∧ 3, x)
(%o1) cos(x)3 /3-cos(x)

Example 4:
Z
xdx
p
(b2 − x2 )

Maxima commands:

(%i1) integrate(x/sqrt(b∧ 2-x∧ 2), x);


(%o1) − sqrt(b2 -x2 )

1
wxMaxima: Lab Manual - II

1.1 Lab 1.1: Integration between limits


The command used is Integrate(function, variable, upper limit, lower limit).
Example 5: Z π
x2 sin(x)dx
0

Maxima commands:

(%i1) f (x) := (x∧ 2) ∗ (sin(x))$


(%i2) f (x);
(%o2) (x2 ) ∗ (sin(x))
(%i3) integrate(f (x), x, 0, %pi));
(%o3) π 2 -4

1.2 Lab 1.2: Double Integration


Here the command used is integrate(integrate(function, variable, upper limit, lower
limit),variable, upper limit, lower limit).
R2R3
Example 6: 1 0 xy(1 + x + y)dxdy
Maxima commands:

(%i1) f : x ∗ y ∗ (1 + x + y);
(%o1) x ∗ y ∗ (1 + x + y)
(%i2) integrate(integrate(f, x, 1, 2), y, 0, 3);
(%o2) 123/4

Example 7: The area of the unit square


Z 1Z 1
dxdy
0 0

Maxima commands:

(%i1) integrate(integrate(1, y, 0, 1), x, 0, 1);


(%o1) 1

1.3 Lab 1.3: Integration for product of two functions


Here, we shall first find the product of the two function, then integrate the result, using
the command integrate(function, with respect to variable).

2
wxMaxima: Lab Manual - II
R
Example 8: (x-4)(1 + 2x + x3 )dx
Maxima commands:

(%i1) expand((x-4) ∗ (x∧ 3 + 2 ∗ x + 1));


(%o1) (x4 -4 ∗ x3 + 2 ∗ x2 -7 ∗ x-4 ∗ x-4)
(%i2) integrate(1/(%), x);
R 2
(%o2) (log(x-4)/73)-( (x x+4x+18)dx
3 +2x+1 )/73

Problems:
Evaluate the following integrals.
R R
1. (i) x4 dx (ii) cos3 (y)dy
R√
2. x2 + a2 dx
R
3. (2x + 1)(2x4 )dx
R
4. (x2 + 2x + 5)(x3 + x2 + x + 7)dx
RR 8 RR
5. (i) 8x dx (ii) sin(y)dy
RR
6. sin(2x)dx

3
wxMaxima: Lab Manual - II

2 Lab 2: Definite Integrals


2.1 Lab 2.1: Area between two curves f1 (x) and f2 (x)
The wxMaxima command used to find the intersection between two curves is Solve(f(x)=g(x),x)

Example 1: Evaluate the area enclosed by the curve y 2 =x and y 2 =x3 .


Maxima commands:

(%i1) f 1(x) : = sqrt(x)$


(%i2) f√1(x);
(%o1) x
(%i3) f 2(x) :=(x∧ 3/2)$
(%i4) f 2(x);
(%o2) (x3/2 )
(%i5) Solve(f 1(x)=f 2(x), x);
(%o3) [x = 0, x = 1]
(%i6) integrate(f 1(x)-f 2(x), x, 0, 1);

x2 y 2
Example 2: Evaluate the area enclosed by the ellipse + =1
a2 b2
for the first quadrant with
p
x limits 0 to (b2 -y 2 ) and y limits 0 to b.
Maxima commands:

(%i1) f acts();
(%o1) []
(%i2) assume(a > 0, b > 0, x > 0, x < a, y > 0, y < b)$
(%i3) f acts();
(%o2) [a > 0, b > 0, x > 0, a > x, y > 0, b > y]
(%i4) [xmax : (a/b) ∗ sqrt(b2 -y 2 ), ymax : (b/a) ∗ sqrt(a2 -x2 )]$
(%i5) integrate(integrate(1, x, 0, xmax), y, 0, b);
(%o3) π/4

NOTE: In the above problem, area is evaluated only for the first quadrant, for the entire
ellipse, multiply the resultant area by 4, and hence the total area of the ellipse will be,
A = 4 π4 = π.

2.2 Lab 2.2: Evaluation of Beta Integral and Gamma Integral


The wxMaxima command used to find the value of the Beta Integral is Float(beta(m,n))
and that of Gamma Integral is Float(gamma(n)).

4
wxMaxima: Lab Manual - II

Example 2: Find the value of Γ(1/2), Γ(4), Γ(5/4)


Maxima commands:

(%i1) f loat(gamma(1/2));
(%o1) 1.772453850905516
(%i2) f loat(gamma(4))
(%o2) 6
(%i3) f loat(gamma(5/4));
(%o3) 0.906402477055477

Example 3: Find the value of β( 21 , 12 ), β(3, 4), β( 54 , 54 )


Maxima commands:

(%i1) f loat(beta(1/2, 1/2));


(%o1) 1.772453850905516
(%i2) f loat(beta(3, 4));
(%o2) 0.01666666666666667
(%i3) f loat(beta(5/4, 5/4));
(%o3) 1.032363413887746

Problems:
Evaluate the following integrals.
Z
1
1. y 4 (8-y 3 ) 3 dy

Z 2
4
2. y 2 (4 + y 4 ) 3 dy
0


Z 1 Z x
3. (x2 + y 2 )dxdy
0 x

Z 2 Z 4
4. (xy + ey )dxdy
1 3

Z a Z x Z x+y
5. ex+y+z dxdydz
0 0 0

6. Find the areas between the parabolas y 2 =4ax and x2 =4ay using double integrals.

5
wxMaxima: Lab Manual - II

3 Lab 3: Vector Calculus - 1


3.1 Lab 3.1: Basic Operations in 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]));

6
wxMaxima: Lab Manual - II

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

7
wxMaxima: Lab Manual - II

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
(%i5) 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]

4 Lab 4: Vector Differentiation


wxMaxima uses grad(f) to find the gradient of f.

Example 1: 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]

8
wxMaxima: Lab Manual - II

Example 2: 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

9
wxMaxima: Lab Manual - II

Example 3: 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
(%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)$

10
wxMaxima: Lab Manual - II

(%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
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.

11
wxMaxima: Lab Manual - II

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

12
wxMaxima: Lab Manual - II

5 Lab 5: Vector Calculus - 2


In this section, we shall learn how to find divergence, curl of a vector f and potential of a
vector point function F.
wxMaxima uses the commands div(f), express(%), ev(%,diff) to compute the divergence
of a given vector f.

Example 1: If F⃗ (x, y)=(3 ∗ x3 + y 2 )î + (5 ∗ x ∗ y 2 − 3 ∗ x ∗ y)ĵ. Find divergence of F⃗ .


Maxima commands:
(%i1) F (x, y) := [3 ∗ x∧ 3 + y ∧ 2, 5 ∗ x ∗ y ∧ 2 − 3 ∗ x ∗ y];
(%o1) F (x, y) := 3x3 + y 2 , 5xy 2 − 3xy
(%i2) load(vect);
(%o2) /usr/local/share/maxima/5.19.2/share/vector/vect
(%i3) scalef actors([x, y]);
(%o3) done
(%i4) div(F (x, y));
(%o4) div([3x3 + y 2 , 5xy 2 − 3xy])
(%i5) express(%)
(%o5) d/dx(3x3 + y 2 ) − d/dy(5xy 2 − 3xy 2 )
(%i6) ev(%, dif f );
(%o6) 9x2 − 10xy − 3x

NOTE: A vector F is said to be conservative if curlF⃗ =0

Example 2: Is vector, F⃗ (x, y)=(4x3 − 5y 2 )î + (5y 3 − 3x)ĵ conservative?


Maxima commands:
(%i1) F (x, y) := [4 ∗ x∧ 3 − 5 ∗ y ∧ 2, 5 ∗ y ∧ 3 − 3 ∗ x];
(%o1) F (x, y) := 4x3 − 5y 2 , 5y 3 − 3x
(%i2) load(vect);
(%o2) /usr/local/share/maxima/5.19.2/share/vector/vect
(%i3) scalef actors([x, y]);
(%o3) done
(%i4) curl(F (x, y));
(%o4) curl([4x3 − 5y 2 , 5y 3 − 3x])
(%i5) express(%)
(%o5) d/dx(5y 3 − 3x) − d/dy(4x3 − 5y 2 )
(%i6) ev(%, dif f );
(%o6) 10y − 3

13
wxMaxima: Lab Manual - II

Here with respect to the output obtained 10y − 3 is not equal to zero, hence, the given
vector is not conservative.

Example 3: If F⃗ (x, y)=(x3 + 5y)î + (5y 3 + 5x)ĵ conservative? If, so find the vector
potential.
Maxima commands:

(%i1) F (x, y) := [x∧ 3 + 5 ∗ y, 5 ∗ y ∧ 3 + 5x];


(%o1) F (x, y) := [x3 + 5y, 5y 3 + 5x]
(%i2) ev(express(curl(F (x, y))), dif f );
(%o2) 0
[Since curlF is zero, F is conservative and hence we can f ind the scalar potential]
(%i3) F (u, v) := [u∧ 3 + 5 ∗ v, 5 ∗ v ∧ 3 + 5 ∗ u];
(%o3) F (u, v) := [u3 + 5v, 5v 3 + 5u]
(%i4) scalef actors([u, v])
(%o4) done
(%i5) potential(F (u, v));
5v 4 + 20uv + u4
(%o5)
4

Problems:

1. If f⃗=(xy + 3y 2 )î + (x + 3xy + 5y 2 )ĵ, find div f⃗.


2. If f⃗=(x3 y + y 3 )î + (x − x2 y 2 )ĵ, find curlf⃗.
3. If f⃗=2xy 3 î + 3x2 y 2 ĵ, find div f⃗ and curlf⃗.
4. Find the scalar potential if f⃗=y(3x2 y + z 3 − 2xy 2 z 2 )î + (x3 + 3y 2 z − 2yx2 z 2 )ĵ +
(y 3 + 3z 2 x − 2x2 zy 2 )k̂ is a conservative field.
5. Show that F⃗ =yz î + zxĵ + xy k̂ is irrotational. Find ϕ so that F⃗ = ∇ϕ.

14
wxMaxima: Lab Manual - II

6 Lab 6: Ordinary Differential Equation with constant


coefficients
wxMaxima uses the command ode(′ ); to solve a differential equation and to use of the
initial conditions, the command is ic2(solution, x =, y =, y =)

d y 2

Example 1:. Solve dx2 +y=x with y(0)=1, y (0)=2 and plot the graph in the range (0,%pi).

Maxima commands:
(%i1) 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)
(%o1) y = sin(x) + cos(x) + x
(%i2)plot2d(sin(x) + cos(x) + x, [x, 0, %pi])

NOTE: For Order ≥ 3, use the command load(odes) and odeL().

Problems:
Solve the following:
1. (i) (D2 + 17D + 12)y=0 (ii) (4D3 + 4D2 + 1)y=0
2. (4D4 -4D3 -23D2 + 12D + 36)y=0
3. (6D2 + 17D + 12)y=e−x
4. (D2 + 2D + 1)y=xex sin(x) (ii) (D2 + 3D + 2)y=x2 + 3x + 1
5. (D2 + 3D + 2)y=2sin(x)cos(x) + xex

15
wxMaxima: Lab Manual - II

7 Lab 7: Numerical Methods


Lagrange’s Interpolation Formula

wxMaxima uses the package interpol for Lagrange’s Interpolation.

Example 1: Use Lagrange’s Interpolating Polynomial for the following data and find f(5).

X 0 1 2 3
Y 1 2 1 10

Maxima commands:

(%i1) load(interpol)$
p : [[0, 1], [1, 2], [2, 1], [3, 10]];
(%o1) [[0, 1], [1, 2], [2, 1], [3, 10]]
(%i2) lagrange(p);
(%o2) (5 ∗ (x-2) ∗ (x-1) ∗ x)/3-((x-3) ∗ (x-1) ∗ x)/2 +
(x-3) ∗ (x-2) ∗ (x) + ((1-x) ∗ (x-3) ∗ (x-2))/6
(%i3) f (x) := (5 ∗ (x-2) ∗ (x-1) ∗ x)/3-((x-3) ∗ (x-1) ∗ x)/2 +
(x-3) ∗ (x-2) ∗ (x) + ((1-x) ∗ (x-3) ∗ (x-2))/6
(%o3) f (x) := (5 ∗ (x-2) ∗ (x-1) ∗ x)/3-((x-3) ∗ (x-1) ∗ x)/2 +
(x-3) ∗ (x-2) ∗ (x) + ((1-x) ∗ (x-3) ∗ (x-2))/6
(%i4) ratsimp(f (x));
(%o4) 2 ∗ x3 -7 ∗ x2 + 6 ∗ x + 1
(%i5) f (5);
(%o5) 106

Example 2: Use Lagrange’s Interpolating Polynomial for the following data and find f(5).

X 5 6 9 11
Y 12 13 14 16

16
wxMaxima: Lab Manual - II

Maxima commands:

(%i1) load(interpol)$
(%i2) p : [[5, 12], [6, 13], [9, 14], [11, 16]];
(%o2) [[5, 12], [6, 13], [9, 14], [11, 16]]
(%i3) lagrange(p);
(%o3) (4 ∗ (x-9) ∗ (x-6) ∗ (x-5))/15-(7 ∗ (x-11) ∗ (x-6) ∗ (x-5)/12 +
(13 ∗ (x-11) ∗ (x-9) ∗ (x-5))/15 + ((6-x) ∗ (x-11) ∗ (x-9))/2
(%i4) f (x) := (4 ∗ (x-9) ∗ (x-6) ∗ (x-5))/15-(7 ∗ (x-11) ∗ (x-6) ∗ (x-5)/12 +
(13 ∗ (x-11) ∗ (x-9) ∗ (x-5))/15 + ((6-x) ∗ (x-11) ∗ (x-9))/2
(%o4) (4 ∗ (x-9) ∗ (x-6) ∗ (x-5))/15-(7 ∗ (x-11) ∗ (x-6) ∗ (x-5)/12 +
(13 ∗ (x-11) ∗ (x-9) ∗ (x-5))/15 + ((6-x) ∗ (x-11) ∗ (x-9))/2
(%i5) ratsimp(f (x));
(%o5) (3x3 -70x2 + 557x-690)/60
(%i6) f (10);
(%o6) 44/3
(%i7)f loat(44/3);
(%o7)14.66666666666667

Problems:

1. Given u0 =70, u2 =819, u3 =866, u6 =966, compute u4 using Lagrange Interpolation.


2. If y(1)=3, y(3)=9, y(4)=30, y(6)=132, find Lagrange’s Interpolation polynomial
that takes on these values.
3. Find the form of the function y for the following data by using Lagrange’s Interpo-
lation. Hence find y(3).

X 0 1 2 5
y 2 3 12 147

4. Use Lagrange’s Interpolation formula and estimate from the following data the
number of workers getting income not exceeding Rs 26 per month.

Income not exceeding(Rs) 15 25 30 35


No.of workers: 36 40 45 48

5. Using Lagrange’s Interpolation formula find a polynomial which passes the points
(0,-12),(1,0),(3,6),(4,12).

17
wxMaxima: Lab Manual - II

8 Lab 8: Numerical Integration using Simpson’s 1/3rdrule


In the below set of programs, we shall input the interval length, the corresponding y val-
ues, followed by the code to find the corresponding values of the functions using the
required rules. R6 1
Example 1 : Use Simpson’s 1/3rd , rule for the given integral, taking h value 1, 0 1+x 2 dx.

Maxima commands

(%i1) h : 1$
(%i2) y0 : 1$
(%i3) y1 : 0.5$
(%i4) y2 : 0.2$
(%i5) y3 : 0.1$
(%i6) y4 : 0.0588$
(%i7) y5 : 0.0385$
(%i8) y6 : 0.027$
(%i9) sol2 : (h/3) ∗ ((y0 + y6) + 4 ∗ (y1 + y3 + y5) + 2 ∗ (y2 + y4))$
(%i10) print(”T he value of the given integral by Simpson′ s 1/3rd rule is : ,̈ sol2)$
(%o10) ”T he value of the given integral by Simpson′ s 1/3rd rule is : ””1.3662””

18
wxMaxima: Lab Manual - II

9 Lab 9: Integration using Simpson’s 3/8thrule


Example 1 : For the given integral, use Simpson’s 3/8th , for the given integral of step
size 1 Z 6
1
2
dx
0 1+x

Maxima commands

(%i1) h : 1$
(%i2) y0 : 1$
(%i3) y1 : 0.5$
(%i4) y2 : 0.2$
(%i5) y3 : 0.1$
(%i6) y4 : 0.0588$
(%i7) y5 : 0.0385$
(%i8) y6 : 0.027$
(%i9) sol3 : (3 ∗ (h/8)) ∗ ((y0 + y6) + 3 ∗ (y1 + y2 + y4 + y5) + 2 ∗ (y3))$
(%i10) print(”T he value of the given integral by Simpson′ s 3/8th rule is : ,̈ sol3)$
(%o10) ”T he value of the given integral by Simpson′ s 3/8th rule is : ¨” ”1.3570875””

19
wxMaxima: Lab Manual - II

10 Lab 10: Integration using Weddle’s rule


Example
R6 1 1 : For the given integral, use Weddle’s, for the given integral of step size 1.
0 1+x2
dx

Maxima commands

(%i1) h : 1$
(%i2) y0 : 1$
(%i3) y1 : 0.5$
(%i4) y2 : 0.2$
(%i5) y3 : 0.1$
(%i6) y4 : 0.0588$
(%i7) y5 : 0.0385$
(%i8) y6 : 0.027$
(%i9) sol4 : (3 ∗ (h/10)) ∗ ((y0 + y2 + y4 + y6) + 5 ∗ (y1 + y5))$
(%i10) print(”T he value of the given integral by W eddle′ s rule is : ,̈ sol4)$
(%o10) ”T he value of the given integral by W eddle′ s rule is : ””3.07824””

20
wxMaxima: Lab Manual - II

Problems:

1. Evaluate the given integral by dividing the interval into six equal parts by applying
Weddle’s rule, Simpson’s 1/3rd and 3/8th rule.
Z 1
x
2
dx
0 1+x

2. Use Simpson’s 3/8th and Weddle’s rule to compute the area bounded by the curve
y = f(x), x-axis and the extreme ordinates from the following table.

x 0 1 2 3 4 5 6
y 0 2 2.5 2.3 2 1.7 1.5

3. Use Simpson’s 3/8th and Weddle’s rule to compute the area bounded by the curve
y = f(x), x-axis and the extreme ordinates from the following table.

x 0 1 2 3 4 5 6
y 0 2 2.5 2.3 2 1.7 1.5

4. Use Simpson’s 1/3rd rule to compute the area bounded by the curve y = f(x), x-axis
and the extreme ordinates from the following table.

x 1.4 1.6 1.8 2 2.22


f(x)=y 4.0552 4.953 6.0436 7.3891 9.025

5. Use Simpson’s 1/3rd rule to evaluate.

x 0 2 4 6 8
f(x)=y 3 7 11 9 3

6. Use Simpson’s 1/3rd rule to evaluate.

x 0 2 4 6 8
f(x)=y 3 7 11 9 3

21
wxMaxima: Lab Manual - II

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.mb.uni-siegen.de/kobelev/maxima.pdf
4. https://www.ms.uky.edu/ lee/amspalg05/MaximaTutorial.pdf
5. https://www.youtube.com/playlist?list=PLEDEE2F7C6750729F

22

You might also like