[go: up one dir, main page]

0% found this document useful (0 votes)
12 views4 pages

Cse Lab 1

Uploaded by

Sanjana ML
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Cse Lab 1

Uploaded by

Sanjana ML
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ANIL.S.

C, JNNCE, SHIVAMOGGA

LAB -1(MULTIPLE INTEGRALS)

Objectives:
Use python

1. to evaluate double integration.

2. to compute area and volume.


1 𝑥
1) Evaluate ∫0 ∫0 (𝑥 2 + 𝑦 2 )𝑑𝑦𝑑𝑥

from sympy import *


x,y,z = symbols ('x y z')
w1= integrate (x ** 2+y ** 2 ,(y,0,x) ,(x,0,1))

print (w1)

Out put: 1/3

3 3−𝑥 3−𝑥−𝑦
2) Evaluate ∫0 ∫0 ∫0 (𝑥 2 + 𝑦 2 )𝑑𝑦𝑑𝑥

from sympy import *


x,y,z = symbols ('x y z')
w2= integrate ((x*y*z) ,(z,0,3-x-y) ,(y,0,3-x) ,(x,0,3))
print (w2)

Out put: 81/80

3) Prove that ∬(𝑥 2 + 𝑦 2 )𝑑𝑦𝑑𝑥 = ∬(𝑥 2 + 𝑦 2 )𝑑𝑥𝑑𝑦

from sympy import *


x,y,z = symbols ('x y z')
w3= integrate (x ** 2+y ** 2,y,x)
print (w3)
w4= integrate (x ** 2+y ** 2,x,y)
print (w4)

Out put: x**3*y/3 + x*y**3/3


x**3*y/3 + x*y**3/3
ANIL.S.C, JNNCE, SHIVAMOGGA

Area and Volume:


Area of the region R in the cartesian form is ∬ 𝑑𝑥𝑑𝑦

4) Find the area of an ellipse by double integration.


𝑏
𝑎 ( )√𝑎2 −𝑥 2
A=4 ∫0 ∫0 𝑎 𝑑𝑦𝑑𝑥

from sympy import *


x,y = symbols ('x y')
#a= Symbol ('a ')
#b= Symbol ('b ')
a=4
b=6
w5=4* integrate (1 ,(y,0 ,(b/a)* sqrt (a ** 2-x ** 2)) ,(x,0,a))
print (w5)

Out put: 24.0*pi

5) Find the area of the cardioid r = a(1 + cosθ) by double integration

from sympy import *


r,t = symbols ('r t')
a= Symbol ('a')
#a=4
w6=2* integrate (r ,(r,0,a*(1+cos (t))) ,(t,0,pi))
print (w6)

Out put: 3*pi*a**2/2

6) Find the volume of the tetrahedron bounded by the planes


𝑥 𝑦 𝑧
x=0,y=0 and z=0, 𝑎 + 𝑏 + 𝑐 = 1

from sympy import *


x,y,z = symbols ('x y z')
a= Symbol ('a')
b= Symbol ('b')
c= Symbol ('c')
w7= integrate (1 ,(z,0,c*(1-x/a-y/b)) ,(y,0,b*(1-x/a)) ,(x,0,a))
ANIL.S.C, JNNCE, SHIVAMOGGA

print (w7)

Out put: a*b*c/6

LAB 2: Finding gradient, divergent, curl


Objectives:
Use python
1. to find the gradient of a given scalar function.
2. to find find divergence and curl of a vector function.

1) To find gradient of ∅ = 𝑥 2 𝑦 + 2𝑥𝑧 − 4.

from sympy . vector import *


from sympy import symbols
N= CoordSys3D ('N')
x,y,z= symbols ('x y z')
A=N.x ** 2*N.y+2*N.x*N.z-4
delop =Del ()
print ( delop (A))
gradA = gradient (A)
print (f"\n Gradient of {A} is \n")
print ( gradA )

Out put: (2*N.x*N.y + 2*N.z)*N.i + N.x**2*N.j + 2*N.x*N.k

2) To find divergence of 𝐹 = 𝑥 2 𝑦𝑧 𝑖 + 𝑦 2 𝑧𝑥 𝑗 + 𝑧 2 𝑥𝑦 𝑘

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 ()
divA = delop .dot (A)
print ( divA )
print (f"\n Divergence of {A} is \n")
print ( divergence (A))
ANIL.S.C, JNNCE, SHIVAMOGGA

Out put: 6*N.x*N.y*N.z

3) To find curl of 𝐹 = 𝑥 2 𝑦𝑧 𝑖 + 𝑦 2 𝑧𝑥 𝑗 + 𝑧 2 𝑥𝑦 𝑘

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

Out put:
(-N.x*N.y**2 + N.x*N.z**2)*N.i + (N.x**2*N.y - N.y*N.z**2)*N.j + (-
N.x**2*N.z + N.y**2*N.z)*N.k

You might also like