Wxmaxima Lab Manual
Wxmaxima Lab Manual
Wxmaxima Lab Manual
2022 - 2023
D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078
wxMaxima: Lab Manual - I
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
D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078
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.
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
Dr. Sowmya K
Coordinator
Contents
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
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 - 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
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:
4
wxMaxima: Lab Manual - I
(%i6) plot3d((x2 + y 2 ), [x, −4, 4], [y, −4, 4], [grid, 20, 10]);
5
wxMaxima: Lab Manual - I
(%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:
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
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
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
Maxima commands:
Maxima commands:
13
wxMaxima: Lab Manual - I
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
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 (θ)
dθ
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
Example 2: Find the roots of the equation xsinx + cosx = 0 in (0, π).
Maxima commands:
15
wxMaxima: Lab Manual - I
16
wxMaxima: Lab Manual - I
17
wxMaxima: Lab Manual - I
18
wxMaxima: Lab Manual - I
19
wxMaxima: Lab Manual - II
II Semester : Mathematics for ME/EE/CS/CV Stream-II
2022 - 2023
D EPARTMENT OF M ATHEMATICS
Shavige Malleswara Hills, Kumaraswamy Layout
Bengaluru-560078
wxMaxima: Lab Manual - II
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
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
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:
1
wxMaxima: Lab Manual - II
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
Maxima commands:
2
wxMaxima: Lab Manual - II
R
Example 8: (x-4)(1 + 2x + x3 )dx
Maxima commands:
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
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 = π.
4
wxMaxima: Lab Manual - II
(%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
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
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:
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
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̂.
⃗ ⃗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:
(%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
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:
10
wxMaxima: Lab Manual - II
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
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:
Problems:
14
wxMaxima: Lab Manual - II
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])
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
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:
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.
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
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
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
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 0 2 4 6 8
f(x)=y 3 7 11 9 3
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