Maths Lab Questions
Maths Lab Questions
Maths Lab Questions
import numpy as np
import matplotlib . pyplot as plt
x = np . arange (-10 , 10 , 0 . 001 )
y1 = np .sin ( x )
y2=np .cos ( x )
plt . plot (x , y1 ,x , y2 )
plt . title (" sine curve and cosine curve ")
plt . xlabel (" Values of x")
plt . ylabel (" Values of sin (x) and cos(x) ")
plt . grid ()
plt . show ()
OUTPUT
2. Using modern mathematical tool, write a program/code.
show that uxx + uyy = 0, given u = ex(xcos(y) − y sin(y)).
OUTPUT
(xcos(y)−ysin(y))ex
Ans: 0.0
OUTPUT
e
4. Using modern mathematical tool, write a program/code to test the
consistency of the equations x+2y-z=1; 2x+y+4z=2; 3x+3y+4z=1.
import numpy as np
A=np . matrix ([[1 ,2 ,-1],[2 ,1 , 4],[3 ,3 , 4]])
B=np . matrix ([[1],[2],[1]])
AB=np . concatenate (( A , B ) , axis =1 )
rA=np . linalg . matrix_rank ( A )
rAB =np . linalg . matrix_rank ( AB )
n=A . shape [1]
if ( rA==rAB ):
if ( rA==n ):
print ("The system has unique solution ")
print ( np . linalg . solve (A , B ) )
else :
print ("The system has infinitely many solutions ")
else :
print ("The system of equations is inconsistent ")
OUTPUT
import numpy as np
def normalize ( x ):
fac = abs( x ) .max ()
x_n = x / x .max ()
return fac , x_n
x = np . array ([1 , 1 , 1])
a = np . array ([[1 ,1 , 3 ],[1 ,5 , 1],[3 ,1 , 1]])
for i in range ( 10 ):
x = np .dot(a , x )
lambda_1 , x = normalize ( x )
print (' Eigenvalue :', lambda_1 )
print (' Eigenvector :', x )
OUTPUT
Eigenvalue : 6.001465559355154
Eigenvector : [0.5003663 1. 0.5003663]