Maths LAB Programs BMATS201
Maths LAB Programs BMATS201
Maths LAB Programs BMATS201
Ans: 1/3
Ans: -1/24
Ans: 3/35
Ans: 81/80
5. Prove that ∫ ∫ ∫∫
Ans
Ans:
Ans:
Part 2: Gradient. Curl, Divergence
1. To find gradient of
print(gradA)
Ans:
2. To find divergence of ⃗
print(divA)
print(divergence(A))
Ans: 6xyz
3. To find curl of ⃗
from sympy.vector import *
from sympy import symbols
N=CoordSys3D('N')
x,y,z=symbols('x y z')
A=N.x**2*N.y*N.z*N.i+N.y**2*N.z*N.x*N.j+N.z**2*N.x*N.y*N.k
delop=Del()
curlA=delop.cross(A)
print(curlA)
print(f"\n Curl of {A} is \n ")
print(curl(A))
Ans:
Ans: 24
Ans:
m :3
n :5
gamma ( 5.0 ) is 24.000
Beta ( 3.0 5.0 ) is 0.010
3. Calculate Beta(5/2,7/2) and Gamma(5/2)
Ans:
m : 2.5
n :3.5
gamma ( 3.5 ) is 3.323
Beta ( 2.5 3.5 ) is 0.037
import numpy as np
import sympy as sp
# Define the vector space V
V = np.array([
[1, 2, 3],
[2, 3, 1],
[3, 1, 2]])
# Find the dimension and basis of V
basis = np.linalg.matrix_rank(V)
dimension = V.shape[0]
print("Basis of the matrix",basis)
print("Dimension of the matrix",dimension)
Ans:
Basis of the matrix 3
Dimension of the matrix 3
import numpy as np
from scipy.linalg import null_space
# Define a linear transformation interms of matrix
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Find the rank of the matrix A
rank = np.linalg.matrix_rank(A)
print("Rank of the matrix",rank)
# Find the null space of the matrix A
ns = null_space(A)
print("Null space of the matrix",ns)
# Find the dimension of the null space
nullity = ns.shape[1]
print("Null space of the matrix",nullity)
# Verify the rank-nullity theorem
if rank + nullity == A.shape[1]:
print("Rank-nullity theorem holds.")
else:
print("Rank-nullity theorem does not hold.")
Ans:
Rank of the matrix 2
Null space of the matrix [[-0.40824829]
[ 0.81649658]
[-0.40824829]]
Null space of the matrix 1
Rank-nullity theorem holds.
R K F method method:
n = int((x - x0) / h)
y = y0
for _ in range(n):
k1 = h * f(x0, y)
k2 = h * f(x0 + h / 2, y + k1 / 2)
k3 = h * f(x0 + h / 2, y + k2 / 2)
k4 = h * f(x0 + h, y + k3)
y += (k1 + 2 * k2 + 2 * k3 + k4) / 6
x0 += h
return y
x0 = 0
y0 = 1
x = 0.1
h = 0.1
return 1/(x+y)
n = int((x - x0) / h)
y = y0
for _ in range(n):
k1 = h * f(x0, y)
k2 = h * f(x0 + h / 2, y + k1 / 2)
k3 = h * f(x0 + h / 2, y + k2 / 2)
k4 = h * f(x0 + h, y + k3)
y += (k1 + 2 * k2 + 2 * k3 + k4) / 6
x0 += h
return y
x0 = 0.4
y0 = 1
x = 0.5
h = 0.1
Ans: y(0.5) = 1
h = x[1] - x[0]
y_approx = [y[0]]
y_approx.append(y_approx[i-1] + delta_y)
return y_approx
def factorial(n):
result = 1
result *= i
return result
# Initial condition
x0 = 0
y0 = 1
h = 0.1
n=3
# Generate x values