Main
Main
Part I
Ms. Menaka B
Gokul S Unnikrishnan
Devika Menon
Francin Mathew
2
2.10 Line integrals with constant and variable limits . . . . . . . . . . . . . . . . . . . . . . 90
3.9 D’ Alembert’s Ratio Test - Test for Convergence of the Series . . . . . . . . . . . . . . 136
4.5 Solution of Second order linear Partial Differential Equations with constant coeffi-
cients of the Form, F(D,D’)=0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
4.6 Solution of PDE when the Equation is of the Form F(D,D’)=f(x,y) . . . . . . . . . . . 168
Appendices 191
3
4
Chapter 1
Code:
5
Output:
2 Write a Python function to find the sum of the first ”n” natural numbers using a while loop.
Code:
def sum(n):
i, s = 0, 0
while i <= n:
s += i
i +=1
print(f’Sum of first {n} natural numbers is: {s}’)
Output:
3 Write a Python function to find the factors of a number using for loop.
Code:
def factors(n):
print(f’The factors of {n} are: ’)
for i in range(1, n + 1):
if n % i == 0:
print(i, end=’ ’)
Output:
6
4 Write a Python function to check whether the given number is prime or not.
Code:
def prime(n):
c = 1
for i in range(2, n):
if n % i == 0:
c = 0
print(f’{n} is a {"prime" if c == 1 else "composite"} number.’)
Output:
Code:
def factorial(n):
p = 1
for i in range(1, n + 1):
p *= i
print(f’{n}! = {p}’)
Output:
Code:
7
if (a >= b and a >= c):
print(f’{a} is bigger’)
elif (b >= a and b >= c):
print(f’{b} is bigger’)
else:
print(f’{c} is bigger’)
Output:
7 Write a Python program to illustrate the logical operators AND, OR, and NOT.
Code:
a, b = False, False
print(f’{a} and {b} is {a and b}’)
print(f’{a} or {b} is {a or b}’)
print(f’not {a} is {not a}’)
print(f’not {b} is {not b}’)
a, b = 2, 3
p = a > 1
q = b > 5
print(a > 1 and b > 1)
print(a > 1 or b > 1)
print(not p, not q)
8
Output:
9
Practical 1.2 Introduction to Matrices
In this practical, we will explore the fundamental operations of matrix addition and subtraction.
These operations play a vital role in linear algebra, forming the basis for more advanced matrix
computations. By performing matrix addition and subtraction, we will understand their key
properties, such as commutativity and associativity, and recognize their importance in solving
mathematical and real-world problems involving matrices. This practical will help build a strong
foundation for further studies in topics like systems of linear equations, transformations, and more.
1 Write a Python program to compute the addition and subtraction of the given matrices A
and B where,
12 7 3 5 8 1
A= 4 5 6 and B = 6 7 3 .
7 8 9 4 5 9
Manual:
12 7 3 5 8 1
Given, A =
4
5 6 B = 6 7 3
7 8 9 4 5 9
12 7 3 5 8 1
A+B =
4 5 6 + 6 7 3
7 8 9 4 5 9
12 + 5 7 + 8 3 + 1
⇒A+B = 4 + 6 5 + 7 6 + 3
7+4 8+5 9+9
17 15 4
⇒A+B = 10 12 9
11 13 18
12 7 3 5 8 1
A−B =
4 5 6 − 6 7 3
7 8 9 4 5 9
10
12 − 5 7 − 8 3 − 1
⇒A−B = 4−6 5−7 6−3
7−4 8−5 9−9
7 −1 2
=
−2 −2 3 .
3 3 0
Code:
Output:
11
2 Write a Python program to compute the addition and subtraction of the given matrices A
and B where,
2 5 7 −1 3 0
A= and B = .
−2 4 3 8 −1 5
Code:
Output:
3 Write a Python program to compute the addition and subtraction of the given matrices A
and B where,
−1 2 −1 3
−3 4 and B = 5
A= 0.
1 0 2 −2
Code:
12
print("Sum is: ")
pprint(sum_matrix)
difference_matrix = A - B
print("Difference is: ")
pprint(difference_matrix)
Output:
Practical Application:
Matrix addition and subtraction have diverse applications, including analyzing financial data
in economics, enhancing images in image processing, and combining forces or displacements in
physics for structural engineering or mechanics. They also support informed decision-making in
data analysis, particularly in social sciences and business analytics.
13
Practical 1.3 Matrix Multiplication
In this practical, we will explore the concept of matrix multiplication, an essential operation in linear
algebra. Matrix multiplication plays a crucial role in various fields such as computer graphics,
machine learning, physics, and engineering, where it is used to model transformations, solve
systems of equations, and perform data analysis. We will focus on understanding how to multiply
two matrices, covering the necessary conditions for multiplication and the step-by-step process of
calculating matrix products.
1 Write a Python program to compute the multiplication of the given matrices A and B where,
12 7 3 5 8 1 2
4 5 6 and B = 6 7 3 0.
A=
7 8 9 4 5 9 1
Manual:
12 7 3 5 8 1 2
Given, A =
4 5 6 and B = 6 7 3 0
7 8 9 4 5 9 1
60 + 42 + 12 96 + 49 + 15 12 + 21 + 27 24 + 0 + 3
AB =
20 + 30 + 24 32 + 35 + 30 4 + 15 + 54 8 + 0 + 6
35 + 48 + 36 56 + 56 + 45 7 + 24 + 81 14 + 0 + 9
114 160 60 27
74 97 73 14 .
∴ AB =
Code:
14
# Compute the product of matrices A and B
product_matrix = A * B
print("Product is: ")
pprint(product_matrix)
Output:
2 Write a Python program to compute the multiplication of the given matrices A and B where,
1 3 3 1 2
2 6 4 and B = 7 0.
A=
−2 0 3 5 1
Manual:
1 3 3 1 2
Given, A =
2 6 4 and B = 7 0
−2 0 3 5 1
1 + 21 + 15 2+0+3
AB =
2 + 42 + 20 4+0+4
−2 + 0 + 15 −4 + 0 + 3
37 5
∴ AB = 64 8 .
13 −1
Code:
15
print("Product is: ")
pprint(product_matrix)
Output:
3 Write a Python program to compute the multiplication of the given matrices A and B where,
1 −2 3 1 0 2
A=
2 3 and B = 0 1 2.
−1
−3 1 2 1 2 0
Manual:
1 −2 3
1 0 2
Given, A =
2 3 −1 and B = 0 1 2.
−3 1 2 1 2 0
1+0+3 0−2+6 2−4+0
AB = 2+0−1 0+3−2 4+6+0
−3 + 0 + 2 0 + 1 + 4 −6 + 2 + 0
4 4 −2
∴ AB =
1 1 10
−1 5 −4
Code:
16
Output:
Practical Application:
17
Practical 1.4 Trace and Transpose of Matrices
In this practical, we will explore two fundamental operations on matrices: calculating the trace
and finding the transpose. The trace is obtained by summing the diagonal elements of a square
matrix and serves as an important tool in various mathematical fields, including linear algebra and
differential equations, for analyzing matrix properties. The transpose, obtained by interchanging
the rows and columns of a matrix, is an essential operation in simplifying computations, solving
systems of equations, and transforming data.
1 Write a Python program to compute the trace and transpose of the 2x2 matrix
12 7
A= .
4 5
Manual:
12 7
Given, A =
4 5
Trace of A = 12 + 5
Trace of A = 17
Transpose
of the
matrix
12 7
A=
4 5
12 4
AT = .
7 5
Code:
# Define matrix A
A = Matrix([[12, 7], [4, 5]])
18
pprint(A.trace())
Output:
2 Write a Python program to compute the trace and transpose of the 3x3 matrix
2 7 4
4 9 2 .
A=
3 2 1
Code:
Output:
19
3 Write a Python program to compute the transpose of the 3x4 matrix
2 7 4 −6
A=
4 −2 9 .
2
3 −5 2 1
Code:
Output:
Practical Application:
The trace and transpose of matrices have important applications, including tensor analysis for
stress-strain relations in materials, determining system stability in control systems, and efficient
data storage and manipulation in computer science, particularly in graph algorithms.
20
Practical 1.5 Rank of a Matrix
In this practical, we will into the fundamental concept of matrix rank, an important measure that
determines the number of linearly independent rows or columns in a matrix. By exploring the
rank of a matrix, students will gain valuable insights into its properties and its ability to represent
linear transformations, essential knowledge for various fields such as computer graphics, machine
learning, physics, and engineering. This practical will also cover methods for determining the rank
and discuss its significance in solving systems of equations.
1 Write a Python program to find the rank of the given matrix by reducing it to its row reduced
Echelon form
1 2 1
A= 3 4 7
.
3 6 3
Manual:
1 2 1
Given, A =
3 4 7
3 6 3
h i
R2 → R2 − 3R1 = 0 −2 4
h i
R3 → R3 − 3R1 = 0 0 0
1 h i
R2 → − R2 = 0 1 −2
2
h i
R1 → R1 − 2R2 = 1 0 5
1 0 5
RREF=
0 1 −2
0 0 0
21
Code:
# Define matrix A
A = Matrix([[1, 2, 1], [3, 4, 7], [3, 6, 3]])
Output:
2 Write a Python program to find the rank of the given matrix by reducing it to its row reduced
Echelon form
4 0 2 1
A= 2 1 3 4 .
2 3 4 7
Code:
22
print(’The RREF is: ’)
pprint(echform)
print(f’The rank is: {A.rank()}’)
Output:
3 Write a Python program to find the rank of the given matrix by reducing it to its row reduced
Echelon form
1 2 3 2
A= 2 3 5 1
1 3 4 5
Code:
Output:
23
Practical Application:
The rank of a matrix determines the dimension of its column or row space, reflecting the indepen-
dent information it holds. It supports dimensionality reduction techniques like PCA in machine
learning, aids in solving systems of equations in engineering, and is used in econometrics and
structural analysis to assess multicollinearity and stability.
24
Practical 1.6 Inverse of a Matrix
In this practical, we will learn how to compute the inverse of a matrix, a key concept in linear
algebra. The inverse plays a vital role in solving systems of linear equations, as it enables us to find
unique solutions when they exist. Understanding the conditions for invertibility is essential, as not
all matrices possess an inverse. We will also explore various methods for calculating the inverse,
equipping us with the tools necessary to tackle a range of mathematical problems. Mastering these
concepts will deepen our understanding of matrix theory and its applications in mathematical
analysis.
1 Write a Python program to find the inverse of the given matrix using the Cayley-Hamilton
theorem
2 1
A= .
7 4
Manual:
2 1
Given, A =
7 4
2−λ 1
det(A − λ) = det = (2 − λ)(4 − λ) − (1 × 7) = λ2 − 6λ − 1
7 4−λ
p(A) = A2 − 6A + I = 0
A−1 × (A2 − 6A + I) = 0
25
1 0 2 1
A−1 = 6I − A = 6 −
0 1 7 4
4 −1
∴ A−1 = .
−7 2
Code:
26
Output:
2 Write a Python program to find the inverse of the given matrix using the Cayley-Hamilton
Theorem.
2 1
A= .
4 2
Code:
Output:
3 Write a Python program to find the inverse of the given matrix using the Cayley-Hamilton
Theorem.
−4 9
A= .
3 −7
Code:
27
I = eye(2)
d = A.det()
b = A.trace()
if d == 0:
print("Determinant is 0, inverse does not exist.")
else:
print("The inverse is: ")
pprint(((b * I) - A) / d)
Output:
Practical Application:
The inverse of a matrix is essential for solving systems of linear equations. It is used in electrical
engineering for circuit analysis, in computer vision for camera calibration, in economics for solving
input-output models, and in robotics for determining joint movements in robotic arm kinematics.
28
Practical 1.7 Solve the System of Equations
In this practical, we will solve systems of linear equations using matrix operations in Python
with the SymPy library. This approach allows us to represent the system of equations in matrix
form, facilitating efficient computation. We will apply the LU decomposition method to find
the solution, which is a powerful technique for simplifying complex systems. The focus will be
on constructing matrices and utilizing the LUsolve() function to derive the unknown variables
effectively. By mastering these techniques, we will enhance our problem-solving skills and deepen
our understanding of linear algebra in a computational context.
1 Write a Python program to solve the following system of equations using the Matrix method
5x + 2y = 4.
7x + 3y = 5.
Manual:
5x + 2y = 4
7x + 3y = 5
Step 2: Perform row elementary operations to obtain row reduced Echelon form
7
We subtract times the first row from the second row:
5
7
New element at (2, 1) : 7 − ×5=7−7=0
5
7 14
New element at (2, 2) : 3 − × 2 = 3 − = 3 − 2.8 = 0.2
5 5
7 28
New element at (2, 3) : 5 − × 4 = 5 − = 5 − 5.6 = −0.6
5 5
29
The augmented matrix is now:
5 2 | 4
0 0.2 | −0.6
#AX=Y
5 2 x 4
=
0 0.2 y −0.6
5x + 2y = 4
0.2y = −0.6
0.2y = −0.6
Solving for y:
−0.6
y= = −3
0.2
5x + 2(−3) = 4
Simplifying:
5x − 6 = 4
5x = 10
x=2
x = 2, y = −3.
30
Code:
Output:
2 Write a Python program to solve the following system of equations using the Matrix method
x + 2y + 3z = 0.
y + 5z = 0.
2x + 3y = 0.
Code:
31
Output:
3 Write a Python program to solve the following system of equations using the Matrix method
1x + 2y − 1z = 3.
3x − 1y + 2z = 1.
2x − 2y + 3z = 2.
Code:
Output:
Practical Application:
The matrix method is crucial for solving large systems of linear equations. It is widely applied in
fields like mathematics, engineering, computer science, and economics, supporting circuit analysis,
machine learning, and market behavior modeling.
32
Practical 1.8 Eigenvectors And Eigenvalues
In this practical, we will compute the eigenvectors and eigenvalues of a matrix using Python’s
SymPy library. Eigenvalues and eigenvectors are fundamental concepts in linear algebra, providing
insights into the properties of linear transformations and the behavior of matrices. We will begin by
defining a matrix, then calculate its eigenvalues and extract the corresponding eigenvectors. The
practical will involve iterating through the eigenvalues and displaying their respective eigenvectors
using the eigenvects() method. By mastering these concepts, we will enhance our understanding of
matrix theory and its significance in various mathematical applications.
1 Write a Python program to find the eigenvectors and eigenvalues for the following matrix:
2 −1
A= .
0 1
Manual:
2 −1
Given, A =
0 1
2 −1
To find the eigenvalues and eigenvectors for the matrix A =
0 1
Step 1: we find the eigenvalues by solving the characteristic equation, which is given by:
det(A − λI) = 0
(2 − λ)(1 − λ) = 0
λ1 = 2, λ2 = 1.
33
Step 2: we find the eigenvectors for each eigenvalue by solving:
(A2 − λI)v = 0
So, y = 0, and x can be any value. Thus, the eigenvector corresponding to λ1 = 2 is:
1
v1 =
0
For λ2 = 1:
Substituteλ = 1 into A −
λI:
2 − 1 −1 1 −1
A − 1I = =
0 1−1 0 0
Solve (A − 1I)v = 0:
1 −1 x 0
=
0 0 y 0
Thus,
theeigenvalues
of A are λ1 = 2 and λ2 = 1, with corresponding eigenvectors:
1 1
v1 = , v2 = .
0 1
34
Code:
# Define matrix A
A = Matrix([[2, -1], [0, 1]])
Output:
Practical Application:
Eigenvectors are used in physics to describe principal axes of rotation and vibration modes in
mechanical structures, in engineering for analyzing stress and strain in materials, in computer
science for dimensionality reduction in tasks like face recognition, and in finance for portfolio
optimization and machine learning for feature extraction.
35
Practical 1.9 nth Derivative of Standard Functions
In this practical, we will compute the nth derivatives of various standard functions using SymPy’s
differentiation capabilities. Differentiation is a fundamental operation in calculus that allows
us to analyze the behavior of functions and their rates of change. We will differentiate a range
of functions, including powers of x, trigonometric functions, and exponential expressions. By
exploring these derivatives, we will gain a deeper understanding of the principles of calculus and
the practical applications of differentiation in mathematical analysis.
Manual:
Let y = x10
Compute the First Derivative
dy d 10
y1 = = (x ) = 10x9
dx dx
yn = 10 × 9 × 8 × · · · × (10 − n + 1) × x10−n
Say if n=5,
then,
y5 = 30240x5 .
Code:
36
print(y.diff(x, n))
Output:
Code:
Output:
Manual:
If n = 5,
y5 = 4 · 2x 60 · 23x + 150 · 22x (2x + 3) + 45 · 2x (2x + 3)2 + (2x + 3)3 log(2)5
Code:
37
Output:
Manual:
Let y = eax ,
then,
yn = an eax
if n = 5,
then,
y5 = 32e2 x.
Code:
Output:
Manual:
Let y = log(cos x)
d − sin x
y1 = (log(cos x)) = = − tan x
dx cos x
38
d
y2 = (− tan x) = − sec2 x
dx
.
.
.
3 sin4 (x) 5 sin2 (x)
+ + 2 sin(x)
cos4 (x) cos2 (x)
∴ y5 = −8 · /
cos(x)
Code:
Output:
Manual:
39
Code:
Output:
Manual:
Given, ex sinx
If y = eax · sin x
n nπ
then yn = 2 2 · ex · sin(x + )
4
for n = 5,
y5 = −4 · (sin x + cos x) · ex .
Code:
Output:
40
Practical Application:
The nth derivative of functions is useful in various fields, including physics for motion analysis,
engineering for vibration analysis, economics for studying the rate of change of economic indicators,
and signal processing for filtering out noise.
41
Practical 1.10 Taylor’s and Maclaurin’s series
In this practical, we will calculate the Taylor and Maclaurin series expansions for the cosine function
using SymPy. Series expansions are powerful tools in mathematics that allow us to approximate
functions using polynomials, providing insights into their behavior near specific points. We will
utilize the series() function to generate the expansions around different points, specifically at
x = a and x = 0. This practical will demonstrate how to derive and display these series to a
specified order of approximation, enhancing our understanding of function approximation and the
significance of series in mathematical analysis.
1 Write a Python program to find Taylor’s and Maclaurin’s series expansion for the following
function: f(x)=cosx
Manual:
(x − a)2 (x − a)3
f (x) = cos(x) = cos(a) + (x − a) (− sin(a)) + cos(a) + (− sin(a)) + · · ·
2! 3!
x2
where a is the center point. The Maclaurin series of f (x) = cos(x) is: cos(x) = 1 − .
2
Code:
Output:
42
Practical Application:
Taylor’s and Maclaurin’s series are used to approximate solutions to differential equations in
physics, render 3D models in computer graphics, optimize mechanical systems in engineering, and
model stock prices and option pricing in finance.
43
Practical 1.11 Tracing of Standard Curves
This practical will explore the generation and plotting of standard curves in polar coordinates using
the NumPy and Matplotlib libraries. The primary goal is to create a range of angles using NumPy
and utilize Matplotlib to generate accurate polar plots of the curves. The focus is on configuring
and displaying polar plots to accurately represent various standard curves. Through this practical,
we will gain insights into the complexities of plotting in polar coordinates and strengthen their
data visualization skills for future applications.
Code:
Output:
2 Write a Python program to trace a cardioid and its reflection intersecting each other.
Code:
44
polar(theta, 5 * (1 - cos(theta)), ’g’)
Output:
Code:
Output:
Code:
45
Output:
Code:
Output:
Code:
46
Output:
Practical Application:
47
48
Chapter 2
In this practical, we will explore binary operations within the context of algebraic groups. Binary
operations, such as addition and multiplication, play a crucial role in defining group structures,
which are fundamental in abstract algebra. We will examine how these operations can establish
group properties, including closure, associativity, identity, and the existence of inverses. By
verifying these properties, we will gain a deeper understanding of the structure and behavior of
algebraic groups, highlighting their importance in various areas of mathematics. This practical will
enhance our ability to analyze and work with algebraic systems systematically.
1 Write a Python program to verify commutativity and associativity of the set Z = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
with the binary operation: a ∗ b = 1 + ab , ∀ a, b ∈ Z.
Manual:
a ∗ b = 1 + (a × b)
Commutative law:
Let a, b ∈ Z, a ∗ b = b ∗ a
49
1 + (a × b) = 1 + (b × a)
Associative Law
Let a, b, c ∈ Z, (a ∗ b) ∗ c = a ∗ (b ∗ c)
(1 + ab) ∗ c = a ∗ (1 + bc)
abc + 1 + c ̸= abc + 1 + a
Code:
import sys as s
z={0,1,2,3,4,5,6,7,8,9,10}
def f(a,b):
return(1+(a*b))
flag=1
for a in z:
for b in z:
if f(a,b)!=f(b,a):
flag=0
if flag!=0:
print("The binary operation * in z is commutative")
else:
print("The binary operation * in z is not commutative")
s.exit()
flag1=1
for a in z:
for b in z:
for c in z:
if f(a,f(b,c))!=f(f(a,b),c):
flag1=0
50
if flag1!=0:
print("The binary operation * in z is associative")
else:
print("The binary operation * in z is not associative")
s.exit()
Output:
2 Write a Python program to show that the identity element is 1 and inverse of 2 is 0 of the set
Z = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} with the binary operation: a ∗ b = a + b − 1 ∀ a, b ∈ Z.
Manual:
a∗b=a+b−1
i)Identity element
a∗e=a=e∗a
a+e−1=a=e+a−1
e=1
∴ Identity element is 1
ii)Existence of Inverse
2∗b=1⇒2+b−1=1
b=0
∴ Inverse of 2 is 0.
51
Code:
import sys as s
z={0,1,2,3,4,5,6,7,8,9,10}
def f(a,b):
return(a+b-1)
if e in z:
print("Identity element=",e)
else:
print("Identity does not exist")
for a in z:
for b in z:
if f(a,b)==1 and f(b,a)==1:
if b==2:
print("Inverse of ",b," is ",a)
Output:
3 Write a Python program to find the inverse of all the square roots of unity under usual
multiplication.
Code:
import sys as s
z={1,-1}
52
def f(a,b):
return(a*b)
e=5
for a in z:
for b in z:
if f(a,b)==b and f(b,a)==b:
e=a
if e in z:
print("Identity element=",e)
else:
print("Identity does not exist")
for a in z:
for b in z:
if f(a,b)==1 and f(b,a)==1:
print("Inverse of ",b," is ",a)
Output:
4 Write a Python program to find the inverse of all the elements of the set Z={0,1,2,3,4,5 }
under addition modulo 6.
Code:
import sys as s
z={0,1,2,3,4,5}
def f(a,b):
return((a+b)%6)
e=20
53
for a in z:
for b in z:
if f(a,b)==b and f(b,a)==b:
e=a
if e in z:
print("Identity element=",e)
else:
print("Identity does not exist")
for a in z:
for b in z:
if f(a,b)==0 and f(b,a)==0:
print(b," is the inverse of ",a)
Output:
Practical Application:
In digital signal processing, binary operations help manipulate binary data for tasks like filtering
and compression. In mathematics, binary operations are foundational in algebraic structures
such as groups, rings, and fields, used to model symmetry and transformations in physics and
engineering.
54
Practical 2.2 Cayley Table for Different Binary Operations
In this practical, we will create a Cayley table to represent the binary operation on a given group.
The Cayley table is a valuable tool in group theory, providing a visual representation of how each
pair of group elements interacts under the specified operation. We will systematically compute
the results of the operation for every combination of group elements and organize these results in
a table format. This exercise will not only reinforce our understanding of binary operations and
group structures but also illustrate the properties of the group in a clear and concise manner.
1 Write a Python program to construct the Cayley Table for the set G = {0, 1, 2, 3, 4, 5} with
respect to addition modulo 6.
Manual:
+6 0 1 2 3 4 5
0 0 1 2 3 4 5
1 1 2 3 4 5 0
2 2 3 4 5 0 1
3 3 4 5 0 1 2
4 4 5 0 1 2 3
5 5 0 1 2 3 4
Code:
55
print("Cayley’s Table is")
pprint(c)
Output:
2 Write a Python program to construct Cayley Table for the set G={ 1, 3, 7, 9 } with respect to
multiplication modulo 10.
Code:
56
Output:
3 Write a Python program to construct Cayley Table for multiplication modulo 4, (Z4 , ×4 ), Z4 =
G = {1, 2, 3} .
Code:
Output:
57
4 Write a Python program to construct Cayley Table for the set (Z - { 3 } ) with respect to
addition modulo 3.
Code:
Output:
Practical Application:
In cryptography, Cayley tables help understand the structure of encryption keys and operations. In
computer science, they are applied in error-correcting codes and algorithms to identify patterns
and symmetries, and in quantum mechanics, they analyze the symmetries of physical systems.
58
Practical 2.3 Generators and Subgroups of cyclic group
In this practical, we will identify generators and subgroups of a cyclic group defined by specific
elements. Generators are fundamental in understanding the structure of cyclic groups, as they can
produce all elements of the group through repeated application of the group operation. Using
Python, we will determine which elements of the group serve as generators and compute the
subgroups generated by each element. This exploration will deepen our understanding of cyclic
groups and their properties, highlighting the relationships between generators and the subgroups
they create.
1 Write a Python program to find the generators, number of generators and subgroups gener-
ated by the elements of a cyclic group G, where G= { 1, -1, i, -i}.
Manual:
O(G) = 4
i1 = i
i2 = −1
i3 = −i
i4 = 1
∴ i is a generator of G
(−i)1 = −i
(−i)2 = −1
(−i)3 = i
(−i)4 = 1
∴ −i is a generator of G
59
Subgroup generated by 1 is {1}.
Code:
G={1,-1,1j,-1j}
s=set()
for a in G:
for i in range(1,len(G)+1):
if a**i==1:
if i==len(G):
print(a," is a generator")
s.update([a])
break
if len(s)==0:
print("G has no generator")
else:
print("Number of generators= ",len(s))
for a in G:
s=set()
for i in range(1,len(G)+1):
s.update([a**i])
print("Subgroup generated by ",a," is ",s)
Output:
60
2 Write a Python program to find the generators, number of generators and subgroups gener-
ated by the elements of a cyclic group G, where G= { 0,1,2,3,4 } with respect to addition modulo
5.
Code:
G={0,1,2,3,4}
s=set()
for a in G:
for i in range(1,len(G)+1):
if (a*i)%5==0:
if i==len(G):
print(a," is a generator")
s.update([a])
break
if len(s)==0:
print("G has no generator")
else:
print("Number of generators= ",len(s))
for a in G:
s=set()
for i in range(1,len(G)+1):
s.update([(a*i)%5])
print("Subgroup generated by ",a," is ",s)
Output:
61
3 Write a Python program to find the generators, number of generators and subgroups gen-
erated by the elements of a cyclic group G, where G= { 2,4,6,8 } with respect to multiplication
modulo 10.
Code:
G={2,4,6,8}
s=set()
for a in G:
for i in range(1,len(G)+1):
if (a**i) % 10==6:
if i==len(G):
print(a," is a generator")
s.update([a])
break
if len(s)==0:
print("G has no generator")
else:
print("Number of generators= ",len(s))
for a in G:
s=set()
for i in range(1,len(G)+1):
s.update([(a**i) % 10])
print("Subgroup generated by ",a," is ",s)
Output:
62
Practical Application:
Generators and subgroups of cyclic groups are used in cryptography for secure communication
in algorithms like RSA and Diffie-Hellman. In chemistry, they help analyze the symmetry of
molecules and crystals, and in physics, they describe rotational symmetries in atomic structures
and spin systems.
63
Practical 2.4 Coset Decomposition
In this practical, we will perform a coset decomposition for a given group G with a subgroup
H. Cosets are essential in group theory, as they help us understand the relationship between a
group and its subgroups. We will calculate and print the number of distinct cosets formed by the
subgroup Hwithin the group G. By applying the elements of the subgroup to each element of G,
we will list each distinct coset. The focus of this practical is on computing the distinct cosets and
their representation, which will enhance our understanding of the structure of groups and the role
of subgroups within them.
1 Write a Python program to find distinct cosets of a subgroup H={ 1,-1 } of a group
G= { 1, -1, i, -i } with respect to multiplication.
Manual:
Code:
G={1,-1,-1j,1j}
n=len(G)
H={1,-1}
m=len(H)
cs=[{1,-1}]
print("Number of distinct cosets are ",n/m)
print("Distinct cosets are ")
for a in G:
s=set()
for b in H:
s.update([a*b])
64
if len(s)==m:
if s not in cs:
cs.append(s)
print(cs)
Output:
Code:
G={0,1,2,3,4,5}
n=len(G)
H={0,2,4}
m=len(H)
cs=[{0,2,4}]
print("Number of distinct cosets are ",n/m)
print("Distinct cosets are ")
for a in G:
s=set()
for b in H:
s.update([(a+b)%6])
if len(s)==m:
if s not in cs:
cs.append(s)
print(cs)
Output:
65
3 Write a Python program to find distinct cosets of a subgroup H={ 1 ,3 ,9 } of a group G={ 1,
2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, 12 } with respect to multiplication modulo 13.
Code:
G={1,2,3,4,5,6,7,8,9,10,11,12}
n=len(G)
H={1,3,9}
m=len(H)
cs=[{1,3,9}]
print("Number of distinct cosets are ",n/m)
print("Distinct cosets are ")
for a in G:
s=set()
for b in H:
s.update([(a*b)%13])
if len(s)==m:
if s not in cs:
cs.append(s)
print(cs)
Output:
4 Write a Python program to find distinct cosets of a subgroup H=1,2,3,4 of a group G={1,2,3,4}
with respect to multiplication modulo 5.
Code:
G={1,2,3,4}
n=len(G)
H={1,2,3,4}
66
m=len(H)
cs=[{1,2,3,4}]
print("Number of distinct cosets are ",n/m)
print("Distinct cosets are ")
for a in G:
s=set()
for b in H:
s.update([(a*b)%5])
if len(s)==m:
if s not in cs:
cs.append(s)
print(cs)
Output:
Practical Application:
Coset decomposition is applied in group theory to study symmetry and structure in mathematical
systems. In physics, it is used to model particle systems and quantum states by breaking down
complex symmetries. In computer science, it helps in error correction and optimization algorithms.
67
Practical 2.5 Lagrange’s Theorem
In this practical, we will verify Lagrange’s theorem for a given group G and its subgroup H.
Lagrange’s theorem is a fundamental result in group theory that states the order of a subgroup
divides the order of the group. We will first check whether H satisfies the properties of a valid
subgroup of G. Then, we will compare the orders of G and H to confirm the theorem’s validity.
This practical not only reinforces our understanding of subgroup properties but also highlights the
significance of Lagrange’s theorem in the study of group structures and their relationships.
1 Write a Python program to verify Lagrange’s theorem for the set H = {1, −1} in the multi-
plicative group G = {1, −1, i, −i}.
Manual:
To prove that H = {1, −1} is a subgroup, we will construct the Cayley table.
× 1 -1
1 1 -1
-1 -1 1
Hence H is a subgroup of G.
68
Code:
G = {1,-1, 1j,-1j}
H= {1,-1}
s=set()
for a in H:
for b in H:
if (a*b)==1:
s.update([b])
print(s)
sg=1 #sg is initialized to 1 to assume H is a subgroup until proven otherwise
if H==s:
for a in H:
for b in H:
if a*b not in H:
sg=0
if sg==1:
if len(G)%len(H) == 0:
print("Lagrange’s theorem is satisfied.")
else:
print("Lagrange’s theorem is not satisfied.")
else:
print("H is not a subgroup of G")
else:
print("H is not a subgroup of G")
Output:
69
2 Write a Python program to verify Lagrange’s theorem for the set H = {i, −i} in the multi-
plicative group G = {1, −1, 1j, −1j}.
Code:
G = {1,-1, 1j,-1j}
H= {1j,-1j}
s=set()
for a in H:
for b in H:
if (a*b)==1:
s.update([b])
print(s)
sg=1
if H==s:
for a in H:
for b in H:
if a*b not in H:
sg=0
if sg==1:
if len(G)%len(H) == 0:
print("Lagrange’s theorem is satisfied.")
else:
print("Lagrange’s theorem is not satisfied.")
else:
print("H is not a subgroup of G")
else:
print("H is not a subgroup of G")
Output:
70
3 Write a Python program to verify Lagrange’s theorem for the set H = {0, 2, 4} in the multi-
plicative group G = {0, 1, 2, 3, 4, 5}.
Code:
G = {0,1,2,3,4,5}
H= {0,2,4}
s=set()
for a in H:
for b in H:
if (a+b)%6==0:
s.update([b])
print(s)
sg=1
if H==s:
for a in H:
for b in H:
if a+b%6 not in H:
sg=0
if sg==1:
if len(G)%len(H) == 0:
print("Lagrange’s theorem is satisfied.")
else:
print("Lagrange’s theorem is not satisfied.")
else:
print("H is not a subgroup of G")
else:
print("H is not a subgroup of G")
Output:
71
4 Write a Python program to verify Lagrange’s theorem for the set H = {4, 6} in the group
G = {2, 4, 6, 8} under multiplication modulo 10.
Code:
G = {2,4,6,8}
H= {4,6}
s=set()
for a in H:
for b in H:
if (a*b)%10==6:
s.update([b])
print(s)
sg=1
if H==s:
for a in H:
for b in H:
if (a*b)%10 not in H:
sg=0
if sg==1:
if len(G)%len(H) == 0:
print("Lagrange’s theorem is satisfied.")
else:
print("Lagrange’s theorem is not satisfied.")
else:
print("H is not a subgroup of G")
else:
print("H is not a subgroup of G")
Output:
72
Practical Application:
Lagrange’s Theorem determines the possible orders of subgroups in a finite group, with applications
in cryptography for understanding cryptographic system security. It also helps in classifying
symmetries in physics and plays a role in analyzing the motion and constraints of robotic arms.
73
Practical 2.6 Euler Phi Function
In this practical, we will compute Euler’s phi function for a given group G. Euler’s phi function,
denoted as ϕ(n), is a crucial concept in number theory that counts the number of integers less than
n that are relatively prime to n. We will begin by determining the order of the group G and then
apply the formula for Euler’s phi function based on the group’s order. The focus of this practical is
on effectively using the formula to find ϕ(n) and understanding its significance in relation to the
structure of the group. Through this practical, we will gain insights into the relationship between
group theory and number theory, enhancing our overall comprehension of these mathematical
concepts.
1 Write a Python program to find Euler Phi function of the group G = {1, −1, −i, i}.
Manual:
Given, n = 4, P = 22
1 1 1
ϕ(n) = n. 1 − . 1− .... 1 −
P1 P2 Pn
1
ϕ(4) = 4 1 − =2
2
∴ ϕ(4) = 2.
Code:
74
Output:
2 Write a Python program to find Euler Phi function of the group G = {0, 1, 2, 3, 4}.
Code:
Output:
3 Write a Python program to find Euler Phi function of the group G = {2, 4, 6, 8}.
Code:
75
Output:
4 Write a Python program to find Euler Phi function of the group G = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}.
Code:
Output:
Practical Application:
The Euler Phi function is used in number theory and cryptography, particularly in algorithms
like RSA, to determine the number of integers that are coprime to a given number. It also helps
in optimization algorithms and appears in the study of periodic functions and cyclic behavior in
systems like electrical circuits.
76
Practical 2.7 Partial Derivatives of Variable Functions
In this practical, we will compute the partial derivatives of a function involving two variables.
Partial derivatives are essential in multivariable calculus, as they allow us to analyze how a function
changes with respect to one variable while keeping the other variable constant. We will calculate
both first-order partial derivatives and mixed partial derivatives, which involve differentiating
with respect to one variable and then the other. This practical will deepen our understanding
of differentiation in multiple dimensions and highlight the importance of partial derivatives in
analyzing complex functions.
∂2u ∂2u
1 Write a Python program to verify = for the function u = xy + y x .
∂x∂y ∂y∂x
Manual:
Given, u = xy + y x
∂u
= y · xy−1 + y x · logy
∂x
∂u
= xy logx + x.y x−1
∂y
∂2u xy
LHS = = + logx(y.xy−1 ) + y x−1 + (xy x−1 logy)
∂x∂y x
∂2u xy
RHS = = (y.xy−1 )logx + + y x−1 + (xy x−1 logy)
∂y∂x x
∴ LHS=RHS.
Hence proved.
Code:
77
print("RHS =", uyx)
if(uxy==uyx):
print("=> LHS=RHS . Hence proved")
Output:
∂f ∂f ∂2f ∂2f
2 Write a Python program to find & and hence verify = for the function
∂x ∂y ∂x∂y ∂y∂x
x
f (x, y) = tan−1 .
y
Code:
Output:
78
x
!
−
3 Write a Python program to find ux , uy , uxx , uyy , uxy , uyx for the function f (x, y) = y.e y .
Code:
Output:
Code:
79
uyy = diff(u,y,2)
uzz = diff(u,z,2)
LHS = simplify((x**2+y**2+z**2)*(uxx+uyy+uzz))
RHS=1
if LHS==RHS:
print(’(x**2+y**2+z**2)*(uxx+uyy+uzz)=1, Hence proved’)
else:
print("LHS not equal to RHS")
Output:
Practical Application:
Partial derivatives are widely used in physics, particularly in fluid dynamics, thermodynamics, and
electromagnetism, to describe how a system changes with respect to one variable. In economics,
they help understand marginal changes in supply, demand, and production. In machine learning,
they are used in optimization algorithms like gradient descent.
80
Practical 2.8 Euler’s theorem for homogeneous function
In this practical, we will apply Euler’s theorem for homogeneous functions using SymPy. Homoge-
neous functions play a significant role in various fields of mathematics and physics, as they exhibit
a specific scaling behavior. We will begin by defining a homogeneous function and computing
its degree of homogeneity. Next, we will calculate the partial derivatives of the function. Finally,
we will verify Euler’s theorem by comparing the left-hand side and right-hand side expressions
derived from the function and its derivatives. This practical will enhance our understanding of
homogeneous functions and their properties, while also illustrating the application of Euler’s
theorem in a computational context.
x2 + y 2
1 Write a Python program to verify Euler’s theorem of the homogeneous function .
x+y
Manual:
x2 + y 2
Given, u =
x+y
To prove that u is a homogenous function
(tx)2 + (ty)2
u(tx, ty) = = tu
tx + ty
u is a homogeneous function of degree 1
∂u ∂u
By Euler’s theorem we have: x. +y =u
∂x ∂y
(x + y) · 2x − (x2 + y 2 ) · 1 (x + y) · 2x − (x2 + y 2 ) · 1 y(2xy + y 2 − x2 )
=x + y +
(x + y)2 (x + y)2 (x + y)2
x3 + y 3 + x2 y + xy 2 (x + y)(x2 + y 2 ) x2 + y 2
= = =u
(x + y)2 (x + y)2 x+y
Hence verified.
Code:
81
ux, uy = diff(u, x), diff(u, y) # Calculate the partial derivatives of u with
respect to x and y
Output:
x3 + y 3
2 Write a Python program to verify Euler’s theorem for the homogeneous function .
x+y
Code:
82
ux, uy = diff(u, x), diff(u, y) # Calculate the partial derivatives of u with
respect to x and y
Output:
x
3 Write a Python program to verify Euler’s theorem for the homogeneous function xy sin .
y
Code:
83
ux, uy = diff(u, x), diff(u, y)
lhs = simplify(x*ux + y*uy)
print("LHS is: ")
print(lhs)
print()
rhs = n*u
print("RHS is: ")
print(rhs)
print()
print(f"Thus, Euler’s theorem is{’’ if lhs == rhs else ’ not’} satisfied.")
Output:
x
4 Write a Python program to verify Euler’s theorem for the homogeneous function .
x−y
Code:
84
print()
print(f"Thus, Euler’s theorem is{’’ if lhs == rhs else ’ not’} satisfied.")
Output:
Practical Application:
85
Practical 2.9 Maclaurin’s expansion for the function of two
variables
In this practical, we will compute the Maclaurin series expansion for various functions using
Python. The Maclaurin series is a special case of the Taylor series, centered at the point (0, 0)), and
is useful for approximating functions near this point. We will utilize the SymPy library to derive
the series expansion and analyze the terms up to a specified degree for both variables x and y. This
process will involve expanding the function in terms of its power series, allowing us to gain insights
into the behavior of the function near the origin. This practical will enhance our understanding of
series expansions and their applications in mathematical analysis and problem-solving.
1 Write a Python program to expand the function ex sin(y) in the power of x and up to degree
three using Maclaurin expansions.
Manual:
Given, ex sin(y)
Maclaurin’s Table for the function ex sin(y) is as follows:
86
∴ For the given function the Maclaurin’s series is
y 3 x2 y
ex sin y = y + xy − + + ...
6 2
Code:
Output:
2 Write a Python program to expand the function cos x cos y in the power of x and up to degree
three using Maclaurin expansion.
Code:
87
return cos(x)*cos(y)
for i in range(n+1):
for j in range(n+1-i):
Y[i, j] = diff(diff(f(x, y), x, i), y, j)
Y[i, j] = Y[i, j].subs({x: 0, y: 0})
s = Y[0, 0]
for i in range(1, n+1):
S1 = 0
for j in range(0, i+1):
S1 = S1 + binomial(i, j) * x**(i-j) * y**j * Y[i-j, j]
s = s + S1/factorial(i)
print("Maclaurin expansion is ", s)
Output:
3 Write a Python program to expand the function cos(x + y) in the power of x and up to degree
three using Maclaurin expansion.
Code:
s = Y[0, 0]
for i in range(1, n+1):
S1 = 0
for j in range(0, i+1):
88
S1 = S1 + binomial(i, j) * x**(i-j) * y**j * Y[i-j, j]
s = s + S1/factorial(i)
print("Maclaurin expansion is ", s)
Output:
Practical Application:
Maclaurin’s expansion for functions of two variables is used in physics to approximate complex
systems near equilibrium, such as in quantum mechanics and fluid dynamics. In engineering, it
is applied to model vibrations and stress in structures, and in economics, it helps approximate
functions for optimization problems.
89
Practical 2.10 Line integrals with constant and variable lim-
its
In this practical, we will compute line integrals with both constant and variable limits. Line
integrals are essential in vector calculus, as they allow us to evaluate integrals along a specified
path in space. We will define a parameterized path and calculate the line integral by integrating
the product of the function values and the derivatives of the path parameters. This practical will
involve evaluating these integrals over the specified interval, enabling us to find the result and
understand the geometric interpretation of line integrals.
Z
1 Write a Python program to evaluate xy dx + x2 z dy + xyz dz; c is given by x = et , y =
c
e−t , z = t2 ; 0 ≤ t ≤ 1.
Manual:
Z
Given, xy dx + x2 z dy + xyz dz
C
Where x = et , y = e−t , z = t2
90
y = exp(-t)
z = t**2
F = [x*y, x**2*z, x*y*z]
line_integral = integrate(F[0]*diff(x,t) + F[1]*diff(y,t) + F[2]*diff(z,t),
(t, 0, 1))
print("The required solution is ",line_integral)
Output:
Z
2 Write a Python program to evaluate (3x − 2y)dx + (y + 2z)dy − x2 dz; c is given by x = t, y =
c
2t2 , z = 3t3 ; 0 ≤ t ≤ 1
Code:
Output:
91
x2
Z
3 Write a Python program to evaluate (x+2y)dx+(4−2x)dy; c is bounded by the ellipse +
c 16
y2
= 1.
25
Code:
Output:
Z
4 Write a Python program to evaluate (3xy)dx − (5z)dy + 10xdz given x = t2 + 1; y = 2t2 ; z =
c
t2 ; 1 ≤ t ≤ 2.
Code:
Output:
92
Practical Application:
Line integrals are used in physics to calculate work done by a force field along a path, such as in
electromagnetism or fluid dynamics. In computer graphics, they help render curves and calculate
distances, and in economics, they are applied in optimization problems to determine costs or
benefits over a path.
93
Practical 2.11 Double Integrals with constant and variable
limits
In this practical, we are going to learn about double integrals, which are used to calculate the
volume under a surface in a two-dimensional space. Double integrals extend the concept of single
integrals to functions of two variables, allowing us to evaluate the accumulation of quantities over
a specified region. We will explore the computation of double integrals with both constant and
variable limits, examining how these limits affect the evaluation process. Through this practical,
we will gain a deeper understanding of double integrals, their applications in calculating areas and
volumes, and their significance in fields such as physics, engineering, and probability theory.
Z 1Z 2
1 Write a Python program to evaluate (x − y)dxdy.
0 1
Manual:
Z 1Z 2
Given, (x − y)dxdy
0 1
Z 1 2 2
x
= − xy dy
0 2 1
Z 1
3
= − y dy
0 2
1
3y − y 2
3 1
= = −
2 0 2 2
= 1.
Code:
Output:
94
Z 1Z 2
2 Write a Python program to evaluate (x + y)dydx.
0 1
Code:
Output:
Z 3Z 2
3 Write a Python program to evaluate (x2 + 3y 2 )dydx.
0 1
Code:
Output:
Z 2 Z x2
4 Write a Python program to evaluate x(x2 + y 2 )dydx .
0 0
Code:
95
Output:
Z 1 Z 1−x
5 Write a Python program to evaluate xydydx.
0 0
Code:
Output:
Practical Application:
Double integrals are used in physics to calculate areas and volumes, such as in fluid dynamics
and electromagnetism. In engineering, they calculate the center of mass and moments of inertia,
and in environmental science, they model pollutant dispersion and other processes involving two
variables.
96
Practical 2.12 Triple Integrals with constant and variable
limits
In this practical, we are going to learn about triple integrals, which extend the concept of double
integrals to three dimensions. Triple integrals enable us to compute volumes and other quantities
in higher-dimensional spaces, making them essential in various fields such as physics, engineering,
and probability theory. By understanding the process of integrating functions of three variables,
we will gain insights into the accumulation of quantities in three-dimensional space. This practical
will enhance our skills in working with multivariable calculus and deepen our appreciation for the
applications of triple integrals in real-world scenarios.
Z 1Z 2Z 2
1 Write a Python program to evaluate x2 yz dx dy dz .
0 0 1
Manual:
Z 1Z 2Z 2
Given, x2 yz dx dy dz
0 0 1
Z 1Z 2 3 2
x yz
= dy dz
0 0 3 1
1Z 2
7y 2
Z
= dy dz
0 0 3
Z 1
14z 14
= dz =
0 3 6
7
= .
3
Code:
Output:
97
Z 1Z 2Z 2
2 Write a Python program to evaluate ex+y+z dx dy dz .
0 0 1
Code:
Output:
Z 1 Z 1−x Z 1−x−y
1
3 Write a Python program to evaluate dz dy dx .
0 0 0 (x + y + z + 1)3
Code:
Output:
Practical Application:
Triple integrals are used in physics and engineering to calculate volumes and mass distributions
in three-dimensional space, such as in fluid dynamics and electromagnetism. In environmental
science, they model the spread of pollutants, and in computer graphics, they help render and model
complex 3D shapes.
98
Chapter 3
In this practical, we are going to learn about solving ordinary differential equations (ODEs) using
the variable separable method. This technique is particularly useful for first-order differential
equations, as it allows us to separate the variables so that all terms involving one variable are on
one side of the equation and all terms involving the other variable are on the opposite side. By
doing so, we can integrate both sides independently, leading to a solution for the ODE. Through
this practical, we will have a solid grasp of the variable separable method and its significance in
the broader context of differential equations.
dy
1 Write a Python program to solve x2 + 1 = 1.
dx
Manual:
dy
Given, x2 + 1 =1
dx
dy 1
⇒ = 2
dx x +1
dx
⇒ dy =
x2+1
99
R R 1
On Integrating dy = dx + c
x2 +1
y = tan−1 x + c
∴ y − tan−1 x = c.
Code:
Output:
dy
Write a Python program to solve x2 − yx2 + y 2 + xy 2 = 0.
2
dx
Code:
Output:
100
dy
3 Write a Python program to solve + xy = xy 3 .
dx
Code:
Output:
Code:
Output:
dy
5 Write a Python program to solve xy =y+2.
dx
Code:
101
y=Symbol(’y’)
x_term=integrate(1/x,x)
y_term=integrate(y/(y+2),y)
Ans=simplify(y_term-x_term)
print(Ans,"= C")
Output:
Practical Application:
The solution of ordinary differential equations (ODEs) in the variable separable form is applied
in fields like physics and biology. For instance, in population modeling, it describes the growth
of populations where the rate of change is proportional to the current population size. It is also
used in chemistry to model the rate of reactions and in physics for solving problems related to heat
conduction or fluid dynamics.
102
Practical 3.2 Homogeneous Differential Equations - Solu-
tion of ODE
In this practical, we are going to learn about homogeneous differential equations, which are a
specific type of ordinary differential equation characterized by their structure. A differential
equation is considered homogeneous if it can be expressed in a form where all terms are of the same
degree when the variables are scaled. Through examples, we will gain insights into identifying
homogeneous equations and applying appropriate methods to find their solutions.Through this
practical, we will have a deeper understanding of homogeneous differential equations and their
significance in mathematical modeling and analysis.
Manual:
dy 2x − y
= .....(1)
dx x−y
dv 2x − vx
(1) becomes v + x =
dx x − vx
dv 2 − v − v(1 − v) v 2 − 2v + 2
x = =
dx 1−v 1−v
dx 1−v
= 2
x v − 2v + 2
On integrating:
1−v
Z Z
dx
dv = +c
v 2 − 2v + 2 x
1
− log(v 2 − 2v + 2) = log x + log c
2
log x2 (v 2 − 2v + 2) = log c
103
y2
2 2y
x − +2 =c
x2 x
Code:
Output:
Code:
104
print("The given differential equation is homogeneous")
v=Symbol(’v’)
lhs=integrate((2+3*v)/(-4*v**2-4*v),v)
RHS=integrate(1/x,x)
LHS=lhs.subs(v,y/x)
print("Required solution is ",LHS,"=",RHS,"+c")
Output:
Code:
Output:
105
p
4 Write a Python program to solve xdy − ydx = x2 + y 2 dx.
Code:
Output:
x x
x
5 Write a Python program to solve 1 + e y dx + e y 1 − dy = 0.
y
Code:
106
lhs=integrate((1+exp(v))/(v+exp(v)),v)
RHS=integrate(-1/y,y)
LHS=lhs.subs(v,x/y)
print("Required solution is ",LHS,"=",RHS,"+c")
Output:
Practical Application:
Homogeneous differential equations are used in mechanical vibrations and electrical circuits. For
example, they model the behavior of a mass-spring system, where the displacement follows a
homogeneous ODE. In electrical engineering, they are essential for analyzing circuits with resistors,
capacitors, and inductors, as well as in wave propagation and signal processing.
107
Practical 3.3 Linear Differential Equations - Solution of ODE
In this practical, we will solve a linear ordinary differential equation (ODE) by employing the
integrating factor method. This technique is particularly useful for first-order linear ODEs, where
we will determine the integrating factor based on the given functions. By calculating the integrating
factor, we can simplify the equation and find the general solution of the ODE. This process involves
integrating the resulting expressions to obtain the solution, allowing us to understand the behavior
of the system described by the differential equation.
Manual:
dy
⇒ (1 + x2 ) + y − tan−1 x = 0
dx
dy 1 tan−1 x
⇒ +y =
dx (1 + x2 ) 1 + x2
dy
It is of the form + Py = Q
dx
Z
1
2
dx −1
I.F = e 1 + x = etan x
Z
−1 x −1
⇒ y.e tan = Q.etan x dx + C
tan−1 x tan−1 x
Z
−1
⇒ y · etan x
= ·e dx + c
1 + x2
1
⇒ tan−1 x = t ⇒ dx = dt
1 + x2
Z
tan−1 x
⇒y·e = tdt · et + c
−1 −1 −1
⇒ y · etan x
= e(tan x)
tan−1 x − e(tan x)
+ c.
108
Code:
Output:
dy
2 Write a Python program to solve x − 2y = 2x.
dx
Code:
109
print(’Q =’,Q)
InP=integrate(P,x)
IF=exp(InP)
print("Integrating Factor =",IF)
LHS=y*IF
R=IF*Q
RHS=integrate(R,x)
print("Required solution is ",LHS,"=",RHS,"+c")
Output:
2
3 Write a Python program to solve dx + 2xydy = ye−y dy.
Code:
110
Output:
dy
4 Write a Python program to solve x + y log y = xyex .
dx
Code:
Output:
111
dy −1
5 Write a Python program to solve x2 + 1 + y = etan x .
dx
Code:
Output:
Practical Application:
Linear differential equations are crucial in fluid mechanics, control theory, and economics. In fluid
mechanics, they describe the flow of fluids, while in control theory, they are used for modeling
systems like temperature regulation. In economics, linear ODEs help model financial systems,
where variables like stock prices or interest rates change based on linear relationships.
112
Practical 3.4 Bernoulli Form - Solution of ODE
In this practical, we will solve a Bernoulli differential equation by reducing it to a linear form.
Bernoulli equations are a specific type of nonlinear ODE that can be transformed into a linear
equation through a suitable substitution. We will calculate the integrating factor using the given
functions and apply it to transform the Bernoulli equation into a linear one. This practical will
involve deriving the integrating factor, substituting it into the transformed equation, and integrating
to obtain the solution.
dy
1 Write a Python program to solve x + (1 − x)y = x2 y 2 .
dx
Manual:
dy
Given, x + (1 − x)y = x2 y 2
dx
Divide throughout by xy 2
1 dy 1
2
+ (1 − x) =x
y dx xy
dy (1 − x) −1
y −2 + y = x....(1)
dx x
put v = y −1
dv dy
= −y −2
dx dx
dv dy
− = y −2
dx dx
−dv (1 − x)
(1) becomes + v=x
dx x
dv x−1
+ v = −x
dx x
R R 1
x− x dx ex
I.F = e P dx =e = ex .e− log x =
x
R
Thus the general solution is V.IF= Q.(I.F )dx + c
ex R ex
v. = −x dx + c
x x
ex
= −ex .dx + c
R
xy
113
ex
Thus the required solution is = −ex + c.
xy
Code:
Output:
dy
2 Write a Python program to solve x + y = x3 y 6 .
dx
Code:
114
P=-5/x
Q=-5*x**2
print(’P =’,P)
print(’Q =’,Q)
InP=integrate(P,x)
IF=exp(InP)
print("Integrating Factor =",IF)
lhs=v*IF
LHS=lhs.subs(v,1/y**5)
R=IF*Q
RHS=integrate(R,x)
print("Required solution is ",LHS,"=",RHS,"+c")
Output:
dy
3 Write a Python program to solve + y tan x = y 3 sec x.
dx
Code:
115
LHS=lhs.subs(v,1/y**2)
R=IF*Q
RHS=integrate(R,x)
print("Required solution is ",LHS,"=",RHS,"+c")
Output:
dy
4 Write a Python program to solve x + y = y 2 log x.
dx
Code:
116
Output:
Practical Application:
Bernoulli differential equations are applied in biology, chemistry, and fluid dynamics. They
model the spread of diseases, where the rate of infection depends on both the number of infected
individuals and the susceptible population. In fluid dynamics, Bernoulli’s equation describes the
motion of fluids, such as air flow over a wing or water flow through pipes.
117
Practical 3.5 Complementary Function of the Ordinary Lin-
ear Differential Equation
In this practical, we are going to learn about finding the complementary function for linear dif-
ferential equations. The complementary function is a crucial component of the general solution,
representing the solution to the associated homogeneous equation. We will explore the methods
for determining the complementary function, including the characteristic equation approach for
constant coefficient linear differential equations. By working through examples, we will gain
insights into how the complementary function contributes to the overall solution of the differential
equation.
d3 y dy
1 Write a Python program to solve 3
− 13 + 12y = 0.
dx dx
Manual:
d3 y dy
Given, 3
− 13 + 12y = 0
dx dx
A.E = m3 − 13m + 12 = 0
⇒ (m − 1)(m2 + m − 12) = 0
⇒ (m − 1)(m + 4)(m − 3) = 0
⇒ m = 1, −4, 3.
Code:
import numpy as np
import sympy as sp
x=sp.symbols (’x’)
coeff=[1,0,-13,12]
print("The roots are", np.roots (coeff))
# Enter the value of the roots that are found manually
r1=-4
r2=3
118
r3=1
if ((r1.imag or r2.imag and r3.imag)!=0):
print ("c1", sp.exp(r1*x),’+’,sp.exp(r2.real*x),"(c2 cos",r2.imag,"x+c3
sin",r2.imag,"x)")
if ((r1.imag or r2.imag and r3.imag)==0):
if (r1!=r2!=r3):
print("The general soluition is
y=c1",sp.exp(r1*x),"+c2",sp.exp(r2*x),"+c3",sp.exp(r3*x))
if (r1==r2):
print("The general soluition is y=(c1+c2 x)",sp.exp(r1*x),"+c3",sp.exp(r3*x))
if (r2==r3):
print("The general soluition is y=(c2+c3 x)",sp.exp(r2*x),"+c1",sp.exp(r1*x))
if (r1==r3):
print("The general soluition is y=(c1+c3 x)",sp.exp(r1*x),"+c1",sp.exp(r2*x))
Output:
d3 y d2 y
2 Write a Python program to solve − 3 + 4y = 0.
dx3 dx2
Code:
import numpy as np
import sympy as sp
x=sp.symbols (’x’)
coeff=[1,-3,0,4]
print("The roots are", np.roots (coeff))
r1=-1
r2=2
r3=2
if ((r1.imag or r2.imag and r3.imag)!=0):
print ("c1", sp.exp(r1*x),’+’,sp.exp(r2.real*x),"(c2 cos",r2.imag,"x+c3
sin",r2.imag,"x)")
if ((r1.imag or r2.imag and r3.imag)==0):
119
if (r1!=r2!=r3):
print("The general soluition is
y=c1",sp.exp(r1*x),"+c2",sp.exp(r2*x),"+c3",sp.exp(r3*x))
if (r1==r2):
print("The general soluition is y=(c1+c2 x)",sp.exp(r1*x),"+c3",sp.exp(r3*x))
if (r2==r3):
print("The general soluition is y=(c2+c3 x)",sp.exp(r2*x),"+c1",sp.exp(r1*x))
if (r1==r3):
print("The general soluition is y=(c1+c3 x)",sp.exp(r1*x),"+c1",sp.exp(r2*x))
Output:
d3 y d2 y dy
3 Write a Python program to solve − 2 +4 − 8y = 0.
dx3 dx2 dx
Code:
import numpy as np
import sympy as sp
x=sp.symbols (’x’)
coeff=[1,-2,4,-8]
print("The roots are", np.roots (coeff))
r1=2
r2=2j
r3=-2j
if ((r1.imag or r2.imag and r3.imag)!=0):
print ("c1", sp.exp(r1*x),’+’,sp.exp(r2.real*x),"(c2 cos",r2.imag,"x+c3
sin",r2.imag,"x)")
if ((r1.imag or r2.imag and r3.imag)==0):
if (r1!=r2!=r3):
print("The general soluition is
y=c1",sp.exp(r1*x),"+c2",sp.exp(r2*x),"+c3",sp.exp(r3*x))
if (r1==r2):
print("The general soluition is y=(c1+c2 x)",sp.exp(r1*x),"+c3",sp.exp(r3*x))
if (r2==r3):
120
print("The general soluition is y=(c2+c3 x)",sp.exp(r2*x),"+c1",sp.exp(r1*x))
if (r1==r3):
print("The general soluition is y=(c1+c3 x)",sp.exp(r1*x),"+c1",sp.exp(r2*x))
Output:
Practical Application:
121
Practical 3.6 Ordinary Linear Differential Equations
In this practical, we are going to learn the general approach for solving ordinary linear differential
equations. We will focus on first and second-order equations, examining their standard forms
and the various methods available for finding solutions. By exploring techniques such as the
integrating factor method, the characteristic equation, and variation of parameters, we will develop
a comprehensive understanding of how to tackle these equations effectively. Through examples
and exercises, we will enhance our problem-solving skills and gain insights into the applications of
linear differential equations in various fields.
Manual:
CF = D2 + 2Dy + y = 0
D2 + 2D + 1 = 0
AE = m2 + 2m + 1
m = −1, −1
1 1 1
PI = · 2e2x = · 2e2x = · 2e2x
D2 + 2D + 1 4+4+1 9
y = CF + P I
2
= (c1 + xc2 )e−x + e2x .
9
Code:
import sympy as sp
sp.init_printing()
x=sp.symbols(’x’)
y=sp.Function(’y’)
y1=sp.Derivative(y(x),x)
122
y2=sp.Derivative(y1,x)
eqdiff=y2+2*y1+y(x)-2*sp.exp(2*x)
sol=sp.dsolve(eqdiff,y(x))
sp.pprint(sol)
Output:
d3 y d2 y dy
2 Write a Python program to solve + − − y = cos 2x.
dx3 dx2 dx
Code:
import sympy as sp
sp.init_printing()
x=sp.symbols(’x’)
y=sp.Function(’y’)
y1=sp.Derivative(y(x),x)
y2=sp.Derivative(y1,x)
y3=sp.Derivative(y2,x)
eqdiff=y3+y2-y1-y(x)-sp.cos(2*x)
sol=sp.dsolve(eqdiff,y(x))
sp.pprint(sol)
Output:
123
d2 y
3 Write a Python program to solve − y = 2 + 5x.
dx2
Code:
import sympy as sp
sp.init_printing()
x=sp.symbols(’x’)
y=sp.Function(’y’)
y1=sp.Derivative(y(x),x)
y2=sp.Derivative(y1,x)
eqdiff=y2-y(x)-2-5*x
sol=sp.dsolve(eqdiff,y(x))
sp.pprint(sol)
Output:
d2 y dy
4 Write a Python program to solve +3 + 2y = e2x sin x
dx2 dx
Code:
import sympy as sp
sp.init_printing()
x=sp.symbols(’x’)
y=sp.Function(’y’)
y1=sp.Derivative(y(x),x)
y2=sp.Derivative(y1,x)
eqdiff=y2+3*y1+2*y(x)-sp.exp(2*x)*sp.sin(x)
sol=sp.dsolve(eqdiff,y(x))
sp.pprint(sol)
Output:
124
d3 y
5 Write a Python program to solve + y = 3 + e−x + 5ex x2 .
dx3
Code:
import sympy as sp
sp.init_printing()
x=sp.symbols(’x’)
y=sp.Function(’y’)
y1=sp.Derivative(y(x),x)
y2=sp.Derivative(y1,x)
y3=sp.Derivative(y2,x)
eqdiff=y3+y(x)-3-sp.exp(-x)-5*sp.exp(x)*x**2
sol=sp.dsolve(eqdiff,y(x))
sp.pprint(sol)
Output:
Practical Application:
Ordinary linear differential equations (OLDEs) are used in modeling dynamic systems across
various scientific fields. In physics, they describe phenomena like motion under gravity, while in
biology, they model population dynamics. OLDEs are also applied in economics to predict trends
in growth, interest rates, and market behavior.
125
Practical 3.7 Test the Convergence of the Sequence
In this practical, we are going to learn how to determine whether a given sequence is convergent.
We will explore different convergence criteria and apply these criteria to test whether a sequence
approaches a finite limit. By working through various examples, we will develop a deeper under-
standing of the behavior of sequences and the significance of convergence in mathematical analysis.
This practical will equip us with the tools needed to analyze sequences effectively.
1 Write a Python program to test the convergence, divergence and oscillatory of the sequence
n + (−1)n
xn = .
n
Manual:
n + (−1)n
Given, xn =
n
2n + (−1)2n
Consider x2n =
n
2n + (−1)2n
lim {x2n } = lim
n→∞ n→∞ 2n
1
lim 1 + =1
n→∞ 2n
2n + 1 + (−1)2n+1
Consider x2n+1 =
2n + 1
2n + 1 + (−1)2n+1
lim {x2n+1 } = lim
n→∞ n→∞ 2n + 1
1
= lim 1 − =1
n→∞ 2n + 1
Code:
126
print("Given Expression: ",exp)
print("Limit: ",lim)
if abs(lim)==oo:
print("The sequence diverges")
elif issubclass(type(lim),Rational):
print("The sequence converges to ",lim)
else:
print("The sequence oscilates between", lim.min,"and ",lim.max)
Output:
2 Write a Python program to test the convergence, divergence and oscillatory of the sequence
xn = 1 + (−1)n .
Code:
127
Output:
3 Write a Python program to test the convergence, divergence and oscillatory of the sequence
(n + 1)n+1
xn = .
nn
Code:
Output:
4 Write a Python program to test the convergence, divergence and oscillatory of the sequence
3n − 4
xn = .
4n + 3
Code:
128
from numbers import Rational
exp=(3*n-4)/(4*n+3)
lim=limit_seq(exp,n)
print("Given Expression: ",exp)
print("Limit: ",lim)
if abs(lim)==oo:
print("The sequence diverges")
elif issubclass(type(lim),Rational):
print("The sequence converges to ",lim)
else:
print("The sequence oscilates between", lim.min,"and ",lim.max)
Output:
5 Write a Python program to test the convergence, divergence and oscillatory of the sequence
2n + 5
xn = .
5n + 2
Code:
129
Output:
Practical Application:
Testing the convergence of sequences is important in numerical analysis and computer science.
It helps in approximating solutions to problems like finding roots of equations or optimizing
functions. In signal processing, it is used to analyze the stability of digital signals and systems, and
in financial mathematics, it models the long-term behavior of financial portfolios.
130
Practical 3.8 Comparison Test - Test the Convergence of the
Series
In this practical, we are going to learn about convergence tests for series. Understanding whether
a series converges or diverges is essential in mathematical analysis, as it helps us determine the
behavior of infinite sums. We will explore various convergence tests. By applying these tests to
different series, we will gain insights into their convergence properties and learn how to make
informed conclusions about their behavior. This practical will enhance our analytical skills and
deepen our understanding of series in the context of calculus and mathematical analysis.
1 Write a Python program to test the convergence, divergence and oscillatory of the series
1 1 1
+ + + ...
1·2 2·3 3·4
Manual:
1 1 1
Given, + + + ...
1.2 2.3 3.4
1 1
Consider Un = = 2
n+1 n +n
P 1 1
Here Un = then vn = 2
n2 n
Un n2 n
lim = lim = lim =1
n→∞ Vn n→∞ n(n + 1) n→∞ 1
n 1+
n
P P
Comparison test Un and Vn converge or diverge together.
P P 1
But Vn =
n2
P
Here p = 2, so Vn is convergent.
P
Therefore Un converges.
Code:
131
sn=an/bn
L=limit(s,n,oo)
if L!=0:
print("Both an and bn converges and diverges together")
print("Use p - series to find the convergence and divergence of bn")
p=2
print("The value of p is : ",p)
if p>1:
print("Series bn is convergent using p - series")
print("Hence series an is also convergent")
elif p<=1:
print("Series bn is divergent using p - series")
print("Hence series an is also divergent")
else:
print("Series an and bn neither converges nor diverges together")
Output:
2 Write
r r a Python
r program to test the convergence, divergence and oscillatory of the series
1 2 3
+ + + ...
4 6 8
Code:
132
print("Both an and bn converges and diverges together")
print("Use p - series to find the convergence and divergence of bn")
p=0
print("The value of p is : ",p)
if p>1:
print("Series bn is convergent using p - series")
print("Hence series an is also convergent")
elif p<=1:
print("Series bn is divergent using p - series")
print("Hence series an is also divergent")
else:
print("Series an and bn neither converges nor diverges together")
Output:
3 Write a Python program to test the convergence, divergence and oscillatory of the series
1 1 1
√ √ +√ √ +√ √ + ...
1+ 2 2+ 3 3+ 4
Code:
133
if p>1:
print("Series bn is convergent using p - series")
print("Hence series an is also convergent")
elif p<=1:
print("Series bn is divergent using p - series")
print("Hence series an is also divergent")
else:
print("Series an and bn neither converges nor diverges together")
Output:
4 Write a Python program to test the convergence, divergence and oscillatory of the series
1 3 5
+ + + ...
1·2·3 2·3·4 3·4·5
Code:
134
print("Series bn is divergent using p - series")
print("Hence series an is also divergent")
else:
print("Series an and bn neither converges nor diverges together")
Output:
Practical Application:
The comparison test is widely used in analysis and engineering. In signal processing, it helps
determine the convergence of Fourier series, which represent signals as sums of sinusoids. In
physics, it is applied to series expansions in quantum mechanics and statistical mechanics, and in
algorithm analysis, it evaluates the efficiency and convergence of iterative methods.
135
Practical 3.9 D’ Alembert’s Ratio Test - Test for Convergence
of the Series
In this practical, we are going to learn about D’Alembert’s ratio test for convergence. This widely
used test provides a systematic way to determine the convergence or divergence of infinite series
by examining the ratio of consecutive terms. We will explore the conditions under which the ratio
test is applicable and how to interpret the results. Through a series of examples, we will apply
D’Alembert’s ratio test to various series, enhancing our understanding of its effectiveness and
limitations.
2! 3! 4!
1+ 2
+ 3 + 4 + ...
2 3 4
Manual:
2! 3! 4!
Given, 1 + 2
+ 3 + 4 + ...
2 3 4
n! (n + 1)!
Here Un = n and Un+1 =
n (n + 1)n+1
Un+1 (n + 1)! nn
Now, = × .
Un (n + 1)n+1 n!
nn
Un+1 (n + 1)!
lim = lim ×
n→∞ Un n→∞ (n + 1)( n + 1) n!
nn (n + 1)
= lim
n→∞ (n + 1)( n + 1)
n
= lim
n→∞ n(n+1)
1
= lim =0<1
n→∞ nn
Code:
136
# Give the nth term of the series
expr = factorial(n)/n**n
# Convert the input string into a SymPy expression
u = Lambda(n, sympify(expr))
# Print the given series
print("The given series is:", u(n))
# Calculate the ratio for D’Alembert’s Ratio Test
ratio = u(n + 1) / u(n)
print("The ratio is:", ratio)
# Compute the limit of the ratio as n tends to infinity
L1 = limit(ratio, n, oo)
print("The limit is:", L1)
# Apply D’Alembert’s Ratio Test
if L1 < 1:
print("The series is convergent by D’Alembert’s Ratio Test.")
elif L1 > 1:
print("The series is divergent by D’Alembert’s Ratio Test.")
else:
print("D’Alembert’s Ratio Test fails. Consider using Raabe’s Test
for convergence.")
Output:
2! 3! 4!
+ 2 + 3 + ...
3 3 3
Code:
137
print("The given series is:", u(n))
ratio = u(n + 1) / u(n)
print("The ratio is:", ratio)
L1 = limit(ratio, n, oo)
print("The limit is:", L1)
if L1 < 1:
print("The series is convergent by D’Alembert’s Ratio Test.")
elif L1 > 1:
print("The series is divergent by D’Alembert’s Ratio Test.")
else:
print("D’Alembert’s Ratio Test fails. Consider using Raabe’s Test
for convergence.")
Output:
12 22 22 32 32 42
+ + + ...
1! 2! 3!
Code:
138
print("The series is divergent by D’Alembert’s Ratio Test.")
else:
print("D’Alembert’s Ratio Test fails. Consider using Raabe’s Test
for convergence.")
Output:
2 22 23
+ 2 + 2 + ...
12 +1 2 +1 3 +1
Code:
139
Output:
1 1 1 1
+ + + . . . + n−1 + ...
2 3 5 2 +1
Code:
Output:
140
Practical Application:
D’Alembert’s ratio test is important in solving differential equations and modeling physical systems.
In fluid dynamics, it helps evaluate the convergence of series used in flow problems, and in electrical
engineering, it is applied to power series expansions for circuit responses, ensuring stable and
efficient circuit design.
141
Practical 3.10 Raabe’s Test - Test for Convergence of the
Series
In this practical, we are going to learn about Raabe’s test, another method for testing the conver-
gence of a series. Raabe’s test is particularly useful for series where the ratio test is inconclusive.
We will compare Raabe’s test with the ratio test, discussing the scenarios in which each test is most
effective. By applying Raabe’s test to various series, we will analyze their convergence properties
and gain insights into the behavior of infinite series. This practical will deepen our understanding
of convergence tests and enhance our ability to evaluate series in mathematical analysis.
1 Write a Python program to test the convergence, divergence and oscillatory of the series
1 1·3 1·3·5
1+ + + + ...
2 2·4 2·4·6
Manual:
1 1·3 1·3·5
Given, 1 + + + + ...
2 2·4 2·4·6
1.3.5(2n − 1)
Here Un =
2.4.6.....2n
1.3.5...(2n+!)
Un+1 =
2.4.6...(2n + 2)
Code:
142
print("The ratio is", ratio)
L1=limit(ratio,n,oo)
print("The limit is", L1)
if L1<1:
print("By D’Alembert’s Rato Test the given series is convergent")
elif L1>1:
print("By D’Alembert’s Rato Test the given series is divergent ")
else:
print("D’Alembert’s Rato Test fails and we use Raabe’s Test for convergence")
L2=limit(((n/ratio)-n),n,oo)
print("The limit of the series using Raabe’s test is ", L2)
if L2>1:
print("The series is convergent by Raabe’s Test")
elif L2<1:
print("The series is divergent by Raabe’s Test ")
else:
print("Both the test fails")
Output:
2 Write a Python program to test the convergence, divergence and oscillatory of the series
2 1 2·4 1 2·4·6 1
1+ · + · + · + ...
1 2 1·3 3 1·3·5 4
Code:
143
if L1<1:
print("By D’Alembert’s Rato Test the given series is convergent")
elif L1>1:
print("By D’Alembert’s Rato Test the given series is divergent ")
else:
print("D’Alembert’s Rato Test fails and we use Raabe’s Test for convergence")
L2=limit(((n/ratio)-n),n,oo)
print("The limit of the series using Raabe’s test is ", L2)
if L2>1:
print("The series is convergent by Raabe’s Test")
elif L2<1:
print("The series is divergent by Raabe’s Test ")
else:
print("Both the test fails")
Output:
3 Write a Python program to test the convergence, divergence and oscillatory of the series
2 2 4 2 4 6
+ · + · · + ...
3 3 5 3 5 7
Code:
144
print("By D’Alembert’s Rato Test the given series is divergent ")
else:
print("D’Alembert’s Rato Test fails and we use Raabe’s Test for convergence")
L2=limit(((n/ratio)-n),n,oo)
print("The limit of the series using Raabe’s test is ", L2)
if L2>1:
print("The series is convergent by Raabe’s Test")
elif L2<1:
print("The series is divergent by Raabe’s Test ")
else:
print("Both the test fails")
Output:
4 Write a Python program to test the convergence, divergence and oscillatory of the series
3 3·6 3·6·9
1+ + + + ...
7 7 · 10 7 · 10 · 13
Code:
145
L2=limit(((n/ratio)-n),n,oo)
print("The limit of the series using Raabe’s test is ", L2)
if L2>1:
print("The series is convergent by Raabe’s Test")
elif L2<1:
print("The series is divergent by Raabe’s Test ")
else:
print("Both the test fails")
Output:
Practical Application:
Raabe’s test is used in number theory, quantum mechanics, and numerical methods. In number
theory, it helps determine the convergence of series related to prime numbers, while in quantum
mechanics, it is applied to Schrödinger’s equation. In numerical methods, it ensures the accuracy
of series-based algorithms used in computational simulations.
146
Chapter 4
In this practical, we will determine whether a given total differential equation is integrable. We will
use SymPy to check the integrability condition by computing the partial derivatives of the functions
involved and verifying if the integrability condition holds. This process involves comparing the
calculated expressions to ensure they satisfy the integrability criteria for the differential equation.
Through this practical, we will have a clear understanding of how to assess the integrability of total
differential equations and the significance of the integrability condition in solving these equations.
3x2 dx + 3y 2 dy − x3 + y 3 + e2z dz = 0.
Manual:
147
∂P ∂Q ∂R
=0 =0 = −3y 2
∂y ∂x ∂y
∂P ∂Q ∂R
=0 =0 = −3x2
∂z ∂z ∂x
∂Q ∂R ∂R ∂P ∂P ∂Q
⇒P − +Q − +R −
∂z ∂y ∂x ∂z ∂y ∂x
= 3x2 3y 2 + 3y 2 −3x2 + 0
= 3x2 3y 2 + 3y 2 −3x2 + 0
= 9x2 y 2 − 9x2 y 2 = 0
Code:
Output:
148
2 Write a Python program to check whether the equation is integrable
Code:
Output:
z 2 dx + z 2 − 2yz dy + 2y 2 − yz − zx dz = 0.
Code:
149
z=symbols(’z’)
p= z**2
q=z**2-2*y*z
r=2*y**2-y*z-z*x
py=p.diff(y)
pz=p.diff(z)
qx=q.diff(x)
qz=q.diff(z)
rx=r.diff(x)
ry=r.diff(y)
inte=simplify(p*(qz-ry)+q*(rx-pz)+r*(py-qx))
if(inte==0):
print("The equation is integrable ")
else:
print("The equation is not integrable")
Output:
Total differential equations are used to model physical systems with multiple variables. In thermo-
dynamics, they describe the change in state variables like pressure, temperature, and volume in a
gas. In economics, they represent how multiple economic factors interact and change over time,
and in biology, they model population growth rates considering various factors.
150
Practical 4.2 Solution of Partial Differential Equations of
Type 1
In this practical, we will solve a first-order partial differential equation (PDE) by determining
the specific solution based on given conditions. We will derive the general solution of the given
PDE and then substitute values into the equation to find specific parameters. By solving for these
parameters, we will obtain the particular solution of the PDE. This practical will enhance our skills
in working with first-order PDEs and deepen our understanding of how to apply boundary or
initial conditions to find specific solutions.
Manual:
Given, p2 + q 2 = 1
b2 = 1 − a2
√
b = ± 1 − a2
√
∴ z = ax + 1 − a2 y + c.
Code:
151
ans=solve(eq1,b)
b_value=ans[1]
print("Let the b value be",b_value)
a1=z.subs(b,b_value)
print("z=",a1)
Output:
Code:
Output:
152
3 Write a Python program to solve p = eq .
Manual:
p = eq
log a = b
∴ z = ax + log ay + c
Code:
Output:
153
Practical Application:
Type 1 partial differential equations are used in heat conduction problems, such as designing
heating or cooling systems in engineering. They also describe fluid flow through porous media in
environmental science, modeling the spread of pollutants like contaminants in air or water.
154
Practical 4.3 Solution of Partial Differential Equations of
Type 2
In this practical, we will solve a second-type partial differential equation (PDE) of type 2 using
Python, which is essential for modeling various physical phenomena in fields like physics and
engineering. We will define the PDE, substitute appropriate expressions for the derivatives, and
simplify the equation to fit the standard form. By working with the PDE in terms of its derivatives,
we will apply the type 2 method to derive the general solution. This practical will not only enhance
our programming skills but also deepen your understanding of PDEs, equipping us with valuable
tools for mathematical modeling and analysis.
Manual:
Given, z 2 p2 + q 2 + 1 = 1
f (p, q, z) = 0
dz dz
Let u = x + by, p= , q=b
du du
z 2 p2"+ q 2 + 1 = 1
2 #
dz 2
2 dz
→z + b +1 =1
du du
2
dz 2
dz
→ z2 + bz 2 b2+ z2 = 1
du du
2
dz 2
2 dz 2 2
→z +z b b = 1 − z2
du du
2
2 dz
1 + b2 = 1 − z 2
→z
du
dz 2 1 − z 2
→ z. =
du 1 + b2
√
dz 1 − z2
→z· = √
du 1 + b2
155
dz du
→z·√ =√
1 − z2 1 + b2
Integrating on both sides
Z Z
z 1
→ √ dz = √ · du
1 − z2 1 + b2
p 1
→ − 1 − z2 = u+c
1 + b2
p p p
→− 1 − z2 1 + b2 = u + c 1 + b2
p p
→− 1 − z2 1 + b2 = u + k
p p
→− 1 − z2 1 + b2 = x + by + k
→ 1 − z2 1 + b2
= (x + by + k)2
Code:
156
soln = soln.subs(u, x + b*y)
pprint(soln)
Output:
Code:
Output:
157
3 Write a Python program to solve p (1 + q) = zq.
Code:
Output:
Practical Application:
Type 2 partial differential equations are important in quantum mechanics, where they model wave
functions of particles. In electromagnetics, they describe the propagation of electromagnetic waves,
and in geophysics, they model seismic wave propagation during earthquakes.
158
Practical 4.4 Solution of Partial Differential Equations of
Type 3 and Type 4
In this practical, we will learn how to solve Type 3 and Type 4 partial differential equations (PDEs),
which involve more complex forms and higher-order equations. These types of PDEs require
advanced methods for obtaining solutions, making them essential for tackling real-world problems
in various fields such as physics, engineering, and applied mathematics. By exploring these
advanced techniques, we will enhance your problem-solving skills and deepen our understanding
of the intricacies involved in working with higher-order PDEs.
Manual:
Given, p2 − q 2 = x − y
p2 − q 2 = x − y
p2 − x = q 2 − y
f1 (p, x) = f2 (q, y) = a
p2 − x = q 2 − y = a
p2 − x = a, q2 − y = a
p2 = a + x, q2 = a + y
√ √
p= a + x, q= a+y
√ √
Substitute p = a+x and q = a + y in dz = pdx + qdy
√ √
=⇒ dz = a + x dx + a + y dy
3 3
2 2
⇒ z = (x + a) 2 + (y + a) 2 + c.
3 3
159
Code:
Output:
√ √
2 Write a Python program to solve p+ q = x + y.
Code:
160
p=p_sol[0]
q=q_sol[0]
soln=Eq(Integral(1,z),Integral(p,x)+Integral(q,y))
soln=soln.doit()
pprint(soln)
Output:
Code:
Output:
161
4 Write a Python program to solve z = px + qy + p2 + q 2 .
Manual:
z = px + qy + p2 + q 2
Replace p by a and q by b
z = ax + by + a2 + b2
Code:
Output:
Code:
Output:
162
Practical Application:
Type 3 and Type 4 partial differential equations are applied in fluid dynamics and aerodynamics.
In meteorology, they model air mass movements and weather patterns, while in engineering, they
simulate airflow over aircraft wings for efficient design. In biology, they model the diffusion of
substances like oxygen in tissues.
163
Practical 4.5 Solution of Second order linear Partial Differ-
ential Equations with constant coefficients of
the Form, F(D,D’)=0
In this practical, we are going to learn about solving second-order linear partial differential equa-
tions (PDEs) with constant coefficients. We will focus on equations where the differential operator
F (D, D′ ) equals zero, which guides us toward finding the solution. The practical will begin with
identifying the standard form of these equations and discussing the significance of the characteristic
equation in determining the nature of the solutions. We will explore various methods for solving
these PDEs and apply these techniques to specific examples to derive general solutions. Through
this practical, we will have a solid understanding of how to approach and solve second-order
linear PDEs with constant coefficients, as well as their applications in fields such as physics and
engineering.
1 Write a Python program to find the complementary function for the equation
h i
D2 − 2DD′ + (D′ )2 z = 0.
Manual:
h i
Given, D2 − 2DD′ + (D′ )2 z=0
Substituting D as m and D’ as 1
⇒ m2 − 2m + 1 = 0
⇒ (m − 1) (m − 1) = 0
⇒ m = 1, 1
CF = f1 (y + x) + xf2 (y + x).
164
Code:
import sympy as sp
m = sp.symbols(’m’)
eqn = m**2-2*m+1
roots = sp.solve(eqn)
if len(roots)==1:
print("CF = f1(y+", roots[0], "x) + xf2(y+", roots[0], "x)")
else:
print("CF = f1(y+", roots[0], "x) + f2(y+", roots[1], "x)")
Output:
2 Write a Python program to find the complementary function for the equation
2r − s − 3t = 0.
∂2z ∂2z ∂2z
Where r= s= t=
∂x2 ∂x∂y ∂y 2
Code:
import sympy as sp
m = sp.symbols(’m’)
eqn = 2*m**2-m-3
roots = sp.solve(eqn)
if len(roots)==1:
print("CF = f1(y+", roots[0], "x) + xf2(y+", roots[0], "x)")
else:
print("CF = f1(y+", roots[0], "x) + f2(y+", roots[1], "x)")
Output:
165
3 Write a Python program to find the complementary function for the equation
h i
D2 − 5DD′ + 4 (D′ )2 z = 0.
Code:
import sympy as sp
m = sp.symbols(’m’)
eqn = m**2-5*m+4
roots = sp.solve(eqn)
if len(roots)==1:
print("CF = f1(y+", roots[0], "x) + xf2(y+", roots[0], "x)")
else:
print("CF = f1(y+", roots[0], "x) + f2(y+", roots[1], "x)")
Output:
4 Write a Python program to find the complementary function for the equation
h i
D2 − 3DD′ + 2 (D′ )2 z = 0.
Code:
import sympy as sp
m = sp.symbols(’m’)
eqn = m**2-3*m+2
roots = sp.solve(eqn)
if len(roots)==1:
print("CF = f1(y+", roots[0], "x) + xf2(y+", roots[0], "x)")
else:
print("CF = f1(y+", roots[0], "x) + f2(y+", roots[1], "x)")
Output:
166
Practical Application:
These equations model wave propagation, such as sound or light waves, in various fields. In
mechanical engineering, they describe vibrations in structures under stress. In acoustics, they
model sound wave behavior in different environments, like concert halls or open spaces.
167
Practical 4.6 Solution of PDE when the Equation is of the
Form F(D,D’)=f(x,y)
In this practical, we are going to learn how to solve partial differential equations (PDEs) where
the operator F (D, D′ ) equals a function of x and y. These equations are more complex than those
with constant coefficients and require additional steps for finding solutions. We will explore
various techniques to tackle these PDEs, including the method of characteristics and appropriate
substitutions. By working through examples, we will develop a deeper understanding of how to
approach these more intricate equations and the strategies needed to derive their solutions.
Manual:
It is of the form
f (D, D′ ) = f (x, y)
D=m and D′ = 1
⇒ m2 − 2m + 1 = 0
Solving m2 − 2m + 1 = 0
(m − 1)2 = 0
m−1=0 and m − 1 = 0
⇒ m = 1, 1
=⇒ CF = f1 (y + x) + xf2 (y + x)
168
1
PI = f (x, y)
F (D, D′ )
1
PI = · e2x+y
D2 − 2DD′ + (D′ )2
Here a = 1, b = 2:
⇒ f1 (x + y) + xf2 (x + y) + e2x+y .
Code:
import sympy as sp
D, D_prime, x, y, z, m = sp.symbols("D, D’, x, y, z, m")
f1, f2=sp.symbols("f1, f2", cls=sp.Function)
PDE=sp.Eq(D**2-2*D*D_prime+D_prime**2, sp.exp(2*x+y))
aux_eqn=sp.Eq(PDE.lhs.subs([(D, m), (D_prime, 1)]), 0)
roots=sp.solve(aux_eqn)
if len(roots) == 1:
CF=f1(y + roots[0]*x)+x*f2(y+roots[0]*x)
else:
CF=f1(y+roots[0]*x)+f2(y+roots[1]*x)
PI=(1/ PDE.lhs)*PDE.rhs
a, b=PDE.rhs.args[0].coeff(x), PDE.rhs.args[0].coeff(y)
PI=PI.subs([(D, a), (D_prime, b)])
z=CF + PI
sp.pprint(z)
Output:
169
2 Write a Python program to solve the second order PDE
Manual:
D2 − 2DD′ + (D′ )2 = 0
m2 − 2m + 1 = 0
(m − 1)2 = 0
m−1=0 and m − 1 = 0
⇒ m = 1, 1
CF = f1 (y + x) + xf2 (y + x)
1
PI = sin (2x + 3y)
D2 − 2DD′ + (D′ )2
here a = 2 b = 3
D2 = −4 DD′ = −6 (D′ )2 = −9
1
∴ PI = sin (2x + 4y)
(−4) − 2(−6) + (−9)
1
PI = sin (2x + 3y)
−4 + 12 − 9
1
PI = sin (2x + 3y)
−1
The complete solution is CF + PI is f1 (y + mx) + xf2 (y + mx) − sin (2x + 3y) .
170
Code:
import sympy as sp
D, D_prime, x, y, z, m = sp.symbols("D, D’, x, y, z, m")
f1, f2=sp.symbols("f1, f2", cls=sp.Function)
PDE=sp.Eq(D**2-2*D*D_prime+D_prime**2, sp.sin(2*x+3*y))
aux_eqn=sp.Eq(PDE.lhs.subs([(D, m), (D_prime, 1)]), 0)
roots=sp.solve(aux_eqn)
if len(roots) == 1:
CF=f1(y + roots[0]*x)+x*f2(y+roots[0]*x)
else:
CF=f1(y+roots[0]*x)+f2(y+roots[1]*x)
PI=(1/ PDE.lhs)*PDE.rhs
a, b=PDE.rhs.args[0].coeff(x), PDE.rhs.args[0].coeff(y)
PI=PI.subs([(D**2, -(a**2)),(D*D_prime,-a*b), (D_prime**2, -(b**2))])
z=CF + PI
sp.pprint(z)
Output:
Code:
import sympy as sp
D, D_prime, x, y, z, m = sp.symbols("D, D’, x, y, z, m")
f1, f2=sp.symbols("f1, f2", cls=sp.Function)
PDE=sp.Eq(D**2-3*D*D_prime+2*D_prime**2, sp.cos(3*x-y))
aux_eqn=sp.Eq(PDE.lhs.subs([(D, m), (D_prime, 1)]), 0)
roots=sp.solve(aux_eqn)
if len(roots) == 1:
CF=f1(y + roots[0]*x)+x*f2(y+roots[0]*x)
else:
171
CF=f1(y+roots[0]*x)+f2(y+roots[1]*x)
PI=(1/ PDE.lhs)*PDE.rhs
a,b=PDE.rhs.args[0].coeff(x), PDE.rhs.args[0].coeff(y)
PI=PI.subs([(D**2, -(a**2)),(D*D_prime,-a*b), (D_prime**2, -(b**2))])
z=CF + PI
sp.pprint(z)
Output:
Practical Application:
This type of partial differential equation is used in meteorology to represent temperature or pressure
changes in the atmosphere. In engineering, it models material deformation under stress, and in
economics, it tracks the evolution of market variables like supply and demand.
172
Practical 4.7 Finding the Laplace Transform of Standard
Functions
In this practical, we will compute the Laplace transforms of various standard functions using
Python. We will utilize the SymPy library to find the Laplace transform of functions such as
trigonometric functions, exponentials, and polynomials. This practical will involve defining
the functions in SymPy, applying the Laplace transform, and interpreting the results. Through
this practical, we will gain a solid understanding of how to compute Laplace transforms and
their significance in solving ordinary differential equations and analyzing linear systems. This
knowledge will enhance our mathematical toolkit for tackling a variety of problems in engineering
and applied mathematics.
Manual:
Given, emt
The definition of the Laplace transform:
Z ∞
L [f (t)] = e−st f (t)dt
0
1
=0−
m−s
173
−1 1
L emt =
=
m−s s−m
Therefore, the Laplace transform of emt is:
1
L emt =
.
s−m
Code:
Output:
Code:
Output:
174
3 Write a Python program to find the Laplace transform of sin mt.
Code:
Output:
Manual:
Given, cosh mt
The hyperbolic cosine function is defined as:
emt + e−mt
cosh(mt) =
2
So, the Laplace transform of cosh(mt) is:
e + e−mt
mt
L [cosh(mt)] = L
2
This can be broken down into two separate Laplace transforms:
1 mt
+ L e−mt
L [cosh(mt)] = L e
2
1 1 1
L [cosh(mt)] = +
2 s−m s+m
1 (s + m) + (s − m)
L [cosh(mt)] = ·
2 (s − m)(s + m)
1 2s
L [cosh(mt)] = ·
2 s2 − m2
s
∴ L [cosh(mt)] = 2
s − m2
175
Code:
Output:
Code:
Output:
Code:
176
trans_fun=t**n
F=laplace_transform(trans_fun, t, s, noconds=True)
pprint(F)
Output:
Code:
Output:
8 Write a Python program to find the Laplace transform of eat cos mt.
Code:
177
Output:
9 Write a Python program to find the Laplace transform of eat sin mt.
Code:
Output:
10 Write a Python program to find the Laplace transform of eat cosh mt.
Code:
Output:
178
11 Write a Python program to find the Laplace transform of eat sinh mt.
Code:
Output:
Practical Application:
The Laplace transform is essential in control systems engineering for analyzing dynamic systems,
such as electrical circuits and mechanical systems. In signal processing, it converts differential
equations into algebraic ones, simplifying system behavior analysis in the frequency domain.
179
Practical 4.8 Finding the Inverse Laplace Transform of Stan-
dard Functions
In this practical, we will compute the inverse Laplace transforms of standard functions using Python.
Utilizing the SymPy library, we will obtain the inverse Laplace transforms of various functions,
including rational functions, trigonometric functions, and exponentials. This practical will involve
defining the functions in SymPy, applying the inverse Laplace transform, and interpreting the
results. Through this practical, we will gain a solid understanding of how to compute inverse
Laplace transforms and their importance in solving differential equations and analyzing dynamic
systems.
1
1 Write a Python program to find the inverse Laplace transform of .
s
Code:
import sympy as sp
a,s,t=symbols (’a s t’)
expression=1/s
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
Output:
1
2 Write a Python program to find the inverse Laplace transform of .
s2
Code:
import sympy as sp
a,s,t=symbols (’a s t’)
expression=1/s**2
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
180
Output:
1
3 Write a Python program to find the inverse Laplace transform of .
s3
Code:
import sympy as sp
a,s,t=symbols (’a s t’)
expression=1/s**3
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
Output:
1
4 Write a Python program to find the inverse Laplace transform of .
sn
Code:
import sympy as sp
a,s,t,n=symbols (’a s t n’)
expression=1/s**n
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
Output:
181
1
5 Write a Python program to find the inverse Laplace transform of .
s−k
Code:
import sympy as sp
a,s,t=symbols (’a s t’)
k=sp.symbols(’k’, real=true)
expression=1/(s-k)
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
Output:
s
6 Write a Python program to find the inverse Laplace transform of .
s2 + a2
Code:
import sympy as sp
a,s,t=symbols (’a s t’)
a=sp.symbols(’a’, real=true)
expression=s/(s**2+a**2)
F=sp.inverse_laplace_transform(expression, s, t)
pprint(F)
Output:
Practical Application:
The inverse Laplace transform is used to solve for time-domain responses in electrical circuits, such
as voltage and current after a disturbance. In control theory, it helps determine system behaviors
and ensures the design of stable and efficient systems.
182
Practical 4.9 Plotting of Periodic Functions
In this practical, we will plot a periodic function using Matplotlib. We will generate values for the
function over a specified range and visualize it on a graph with customized axes and spines. This
practical involves setting up the plot, configuring axis properties, and displaying the function to
analyze its periodic behavior. Through this practical, we will enhance our skills in data visualization
and gain insights into the characteristics of periodic functions, which are essential in various fields
such as signal processing and physics.
1 Write a Python program to plot the graph of periodic function f (x) = sin x in [−2π, 2π ].
Code:
183
Output:
2 Write a Python program to plot the graph of periodic function f (x) = tan x in [−π, π ].
Code:
184
Output:
3 Write a Python program to plot the graph of periodic function f (x) = cos x in [−2π, 2π ].
Code:
Output:
185
Practical Application:
Plotting periodic functions is crucial in signal processing, where they represent waveforms used in
communication systems. In physics, they describe oscillatory phenomena, like pendulum motion
or string vibrations. In electrical engineering, they help analyze alternating current (AC) signals for
power system and circuit design.
186
Practical 4.10 Solution of ODE using Lapalace Transform
In this practical, we will solve an ordinary differential equation (ODE) using the Laplace transform.
We will convert the ODE into an algebraic equation by applying the Laplace transform, allowing
us to solve for the transformed variable. After obtaining the solution in the transformed domain,
we will use the inverse Laplace transform to find the solution in the time domain. Additionally, we
will incorporate initial conditions into the solution process to ensure that our final result is specific
to the given problem. By the end of this practical, we will have a comprehensive understanding of
how to apply the Laplace transform method to solve ODEs effectively.
1 Write a Python program to solve an ode using Laplace transform y ′ − 5y = e5x given
y(0) = 2.
Manual:
L [y ′ ] − 5L [y] = L e5x
L {y ′ } = sY (s) − y(0)
L{y} = Y (s)
1
L {eax } =
s−a
We get
1
sY (s) − y(0) − 5Y (s) =
s−5
1
(s − 5)Y (s) − 2 =
s−5
Given y(0) = 2
1 2
Y (s) = +
(s − 5)(s − 5) s − 5
1 2
Y (s) = 2
+
(s − 5) s−5
Now, take the inverse Laplace transform to find y(x):
187
1 1
y(x) = L−1 + 2 L−1
(s − 5)2 s−5
y(x) = xe5x + 2e5x
∴ y (x) = (x + 2) e5x .
Code:
Output:
y(0) = 3, y ′ (0) = 1.
Code:
188
soln=inverse_laplace_transform(solve(alg_eqn,Y)[0],s,t)
pprint(soln)
Output:
Practical Application:
The Laplace transform is widely used to solve ordinary differential equations in electrical and
mechanical systems. It helps solve for current and voltage in circuits and models the motion of
objects under varying forces. In control systems, it analyzes system stability and response to inputs,
aiding in controller design.
189
190
Appendices
• C: Complex Numbers — Numbers of the form a + bi, where a and b are real numbers and i is
the imaginary unit.
191
• round: Rounds a floating-point number to a specified number of decimal places.
• max, min: Returns the maximum or minimum value from a list or set.
192
Algebra II and Calculus II
• Matrix: Used to create matrices.
193
• modulo (%): Computes the remainder of a division operation.
• limit seq: Finds the limit of a sequence as the index approaches infinity.
194
Partial Differential Equations and Integran Transformations
• Eq: Defines an equation between two symbolic expressions.
195