0% found this document useful (0 votes)
48 views

Maths Lab Questions

Uploaded by

rhanamshetti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Maths Lab Questions

Uploaded by

rhanamshetti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

LAB QUESTIONS

1. Using modern mathematical tool, write a program/code to plot the


sine and cosine curve.

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)).

from sympy import *


x , y = symbols ('x y')
u=exp( x )*( x*cos( y )-y*sin( y ) )
display ( u )
dux = diff (u , x )
duy = diff (u , y )
uxx = diff ( dux , x )
uyy = diff ( duy , y )
w=uxx+uyy
w1= simplify ( w )
print ('Ans :',float ( w1 ) )

OUTPUT

(xcos(y)−ysin(y))ex
Ans: 0.0

3. Using modern mathematical tool, write a program/code to evaluate

from sympy import *


from math import inf x= Symbol ('x')
l= Limit (( 1+1/x ) ** x ,x , inf ) . doit ()
display ( l )

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

The system has unique solution


[[ 7.]
[-4.]
[-2.]]

5. Using modern mathematical tool, write a program/code to plot the curve


r= 2|cos2(theta)|

from pylab import *


theta = linspace (0 , 2*pi , 1000 )
r=2*abs(cos( 2* theta ) )
polar ( theta ,r ,'r')
show ()
OUTPUT

6. Using modern mathematical tool, write a program/code to find the

largest eigen value of by power method.

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]

You might also like