Paper 6.1 LAB Manual
Paper 6.1 LAB Manual
, VI SEMESTER
(NEP-2020 Batch)
Python Commands for
MATHEMATICS
PAPER 6.1
LAB MANUAL
Topic:
Rings, Integral Domains, Fields
Vector Spaces,
Linear Transformation,
Calculus of Variations
Contents
Sl.No. Title
PART A: Ring Theory
Lab 1 Program to verify given ring is a commutative
ring or not.
Lab 2 Program to verify given ring with/without unity
or not
Lab 3 Program to verify given ring with/without zero
divisors
Part B: Vector spaces &
Linear Transformation
Lab 4 Program on Linear Combination of Vectors.
Lab 5 Program to verify Linear dependence and
independence.
Lab 6 Program to find basis and dimension of the
subspace.
Lab 7 Program to verify if a function is linear
transformation or not.
Lab 8 Lab 8: Program to find the matrix of linear
transformation.
Lab 9 Program to find the Eigenvalues of a given
linear transformation.
Part C: Calculus of Variations
Lab 10 Program to verify Variational problems using
Euler’s General formula.
Lab 11 Program to verify Variational problems using
particular forms of Euler’s equations
independent of both x and y
Lab 12 Program to verify Variational problems using
particular forms of Euler’s equations with
equations independent of y
PART A: Ring Theory
Lab 1:Program to verify given ring is a
commutative ring or not.
1) Verify the given ring (�, ⨁� , ⨂� ),
where G={0,1,2,3,4,5,6} is commutative or not.
Python command:
G={0,1,2,3,4,5,6}
def f(a,b):
return (a*b)%7
for a in G:
for b in G:
if f(a,b)!=f(b,a):
print("Ring is not commutative")
break
else:
print("Ring is commutative")
Output:
Ring is commutative
Python command:
G={0,1,2,3,4}
def f(a,b):
return (a*b)%5
for a in G:
k=0
for b in G:
if f(a,b)==b and f(b,a)==b:
e=a
k+=1
if k==len(G):
print(e,'is the multiplicative identity and the
ring is with unity')
break
else:
print('Multiplicative identity does not exists,
hence given ring is without unity')
Output:
Python command:
G={0,1,2,3,4,5}
G=G.difference({0})
def f(a,b):
return (a*b)%6
k=1
for a in G:
for b in G:
if f(a,b)==0:
k=0
break
if k==0:
print("Ring is with zero divisors")
else:
print('Ring is ring without zero divisors')
Output:
Python Command:
from sympy import *
var('a,b')
V=[1,7,-4]
V1=[2,-1,1]
V2=[1,-3,2]
A=Matrix([V1, V2, V]).T
soln=solve_linear_system(A,a,b)
if soln==None:
print("Given vector V cannot be expressed as a linear
combination of V1 and V2")
else:
print("Given vector V can be expressed as a linear
combination of V1 and V2")
print("Scalars are: \n", soln)
Output:
Given vector V can be expressed as a linear combination
of V1 and V2
Scalars are:
{a: 2, b: -3}
Python Command:
from sympy import *
V1=[1,3,2]
V2=[1,-7,-8]
V3=[2,1,-1]
A=Matrix([V1, V2, V3])
D=det(A)
print("Determinant=",D)
if D!=0:
print("Given vectors are linearly independent")
else:
print("Given vectors are linearly dependent")
Output:
Determinant= 0
Given vectors are linearly dependent
Python Command:
from sympy import *
V1=[1,1,-1]
V2=[2,-3,5]
V3=[2,-1,4]
A=Matrix([V1, V2, V3])
D=det(A)
print("Determinant=",D)
if D!=0:
print("Given vector form a basis of R^3")
else:
print("Given vector does not form a basis of R^3")
Output:
Determinant= -9
Given vector form a basis of R^3
Python Command:
from sympy import *
from operator import add
var('x,y')
var('x1,y1,x2,y2,c')
T=lambda x: [x[0]+x[1],x[1]]
X=[x,y]
print("Given transformation T(x,y)=",T(X))
X=[x1,y1]
Y=[x2,y2]
L1=T(list(map(add,X,Y)))
R1=list(map(add,T(X),T(Y)))
L2=T(list(map(lambda x: c*x,X)))
R2=list(map(lambda x: expand(c*x),T(X)))
if L1==R1 and L2==R2:
print("T is linear Transformation")
else:
print("T is not linear Transformation")
Output:
Given transformation T(x,y)= [x + y, y]
T is linear Transformation
Python Command:
Output:
Given transformation T(x,y)= [2*x + 3*y, 4*x - 5*y]
Associated matrix of LT:
⎡ 2 3⎤
⎢ ⎥
⎣ 4 -5 ⎦
Python Command:
Output:
⎡ 1.0 - λ 2.0 ⎤
⎢ ⎥
⎣ 3.0 2.0 - λ⎦
Eigen values [-1. 4.]
2) Let T : R2→R2 be defined by T(1, 0)= (1, 2); T(0, 1)=(4, 3).
Find the Eigen values of the linear Transformation.
1
1) Solve the Variational problem I y' xy dx
2
0
with y(0)=0 and y(1)=0.
Python Command:
from sympy import *
x=symbols('x')
f=Function('f')
y=Function('y')
f=lambda y,x:diff(y(x),x)**2+x*y(x)
eq=diff(f(y,x),y(x))-diff(diff(f(y,x),diff(y(x),x)),x)
soln=dsolve(eq,ics={y(0):0,y(1):0})
pprint(soln)
Output:
x3 x
y( x )
12 12
1
2) Solve the Variational problem I 12 xy y' dx
2
0
with y(0)=0 and y(1)=1.
/2
I y 2 y' 2 y sin x dx
2
0
with the condition y(0)=0 and y(�/�)=0.
x2
I y 2 y' 2 ye x dx .
2
x1
Lab 11: Program to verify Variational problems using
particular forms of Euler’s equations independent of both
x and y
0
y' 1dx
2
,
Output :
y(x) = x + 1
1 dy 2 dy
2) Solve the Variational problem I 1 dx ,
0 dx dx
with y(0)=1 and y(1)=3.
I y' dx .
2
which
0
Lab 12: Program to verify Variational problems using
particular forms of Euler’s equations with equations
independent of y
x2
I y ' x 2 y' dx .
2
1) Find the extremal of the functional
x1
Python Command:
Output:
k 1
y( x ) c1
2x
4
I xy ' y' dx ,
2
2) Find the extremal of the functional
0
with y(0)=0 and y(4)=3.
Python Command:
Output:
x2 7x
y( x )
4 4
2
3) Find the extremal of the functional I 3 x y' dx ,
1
with y(1)=5 and y(2)=7.
1
I xy ' y' dx ,
2
4) Solve the Variational problem
0
with y(0)=1 and y(1)=1/4.