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

Lab 2 & 3

Maths lab event

Uploaded by

Rajath S Kashyap
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)
47 views4 pages

Lab 2 & 3

Maths lab event

Uploaded by

Rajath S Kashyap
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

LAB 2: Finding angle between two polar curves, curvature and radius of curvature.

1.Find the angle between the curves r = 4(1 + cost) and r = 5(1 − cost).

from sympy import *


r,t=symbols('r,t')
r1=4*(1+cos(t));
r2=5*(1-cos(t));
dr1=diff(r1,t)
dr2=diff(r2,t)
t1=r1/dr1
t2=r2/dr2
q=solve(r1-r2,t)
w1=t1.subs({t:float(q[1])})
w2=t2.subs({t:float(q[1])})
y1=atan(w1)
y2=atan(w2)
w=abs(y1-y2)
print ('Angle between curves in radians is %0.3f '%(w))

2.Find the angle between the curves r = 4 cost and r = 5 sin t.

from sympy import *


r,t=symbols('r,t')
r1=4*(cos(t));
r2=5*(sin(t));
dr1=diff(r1,t)
dr2=diff(r2,t)
t1=r1/dr1
t2=r2/dr2
q=solve(r1-r2,t)
w1=t1.subs({t:float(q[0])})
w2=t2.subs({t:float(q[0])})
y1=atan(w1)
y2=atan(w2)
w=abs(y1-y2)
print ('Angle between curves in radians is %0.4f '%(w))

3.Find the radius of curvature, r = 4(1 + cost) at t=π/2.

from sympy import *


t=Symbol('t')
r=Symbol('r')
r=4*(1+cos(t))
r1=Derivative(r,t).doit()
r2=Derivative(r1,t).doit()
rho=(r**2+r1**2)**(1.5)/(r**2+2*r1**2-r*r2);
rho1=rho.subs(t,pi/2)
print ('The radius of curvature is %3.4f units '% rho1)
4.Find the radius of curvature for r = asin(nt) at t = pi/2 and n = 1.

from sympy import *


t ,r ,a ,= symbols ('t r a')
r=a*sin( t )
r1= Derivative (r , t ).doit ()
r2= Derivative ( r1 , t ) . doit ()
rho =(r**2+r1**2 )**1.5/(r**2+2*r1**2-r*r2) ;
rho1 = rho.subs (t ,pi/2 )
print ("The radius of curvature is")
display ( simplify ( rho1 ) )

5.Find radius of curvature of x = acos(t), y = asin(t).

from sympy import *


from sympy . abc import rho , x ,y ,r ,K ,t ,a ,b ,c , alpha
y=(sqrt(x)-4)**2
y=a*sin(t)
x=a*cos(t)
dydx=simplify(Derivative(y,t).doit())/simplify(Derivative(x,t).doit())
rho=simplify((1+dydx**2)**1.5/(Derivative(dydx,t).doit()/(Derivative(x,t).doit())))
print('Radius of curvature is')
display(ratsimp(rho))
t1=pi/2
r1=5
rho1=rho.subs(t,t1);
rho2=rho1.subs(a,r1);
print('\n\n Radius of curvature at r=5 and t= pi/2 is',simplify(rho2));
curvature =1/rho2;
print ('\n\n Curvature at (5,pi/2) is',float(curvature))

LAB 3: Finding partial derivatives and Jacobian of functions of several variables.

1.Prove that mixed partial derivatives , uxy = uyx for u = exp(x)(xcos(y) −ysin(y)).

from sympy import *


x,y=symbols('x y')
u=exp(x)*(x*cos(y)-y*sin(y))
dux=diff(u,x)
duy=diff(u,y)
duxy=diff(dux,y)
duyx=diff(duy,x)
if duxy==duyx:
print('Mixed partial derivatives are equal')
else:
print('Mixed partial derivatives are not equal')
2.Prove that if u = exp(x)(x cos(y) − y sin(y)) then uxx + uyy = 0.

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

3.If u = xy/z, v = yz/x, w = zx/y then prove that J = 4.

from sympy import *


x,y,z=symbols('x,y,z')
u=x*y/z
v=y*z/x
w=z*x/y
dux=diff(u,x)
duy=diff(u,y)
duz=diff(u,z)
dvx=diff(v,x)
dvy=diff(v,y)
dvz=diff (v,z)
dwx=diff(w,x)
dwy=diff(w,y)
dwz=diff(w,z)
J=Matrix([[dux, duy, duz],[dvx, dvy, dvz],[dwx, dwy, dwz]]);
print("The Jacobian matrix is \n")
display(J)
Jac=det(J).doit()
print('\n\n J=',Jac)
4. If u = x + 3𝑦 2 − 𝑧 3 , v = 4𝑥 2 yz, w = 2𝑧 2 − xy then prove that at (1, −1, 0), J = 20.

from sympy import *


x,y,z=symbols('x,y,z')
u=x+3*y**2-z**3
v=4*x**2*y*z
w=2*z*z**2-x*y
dux=diff(u,x)
duy=diff(u,y)
duz=diff(u,z)
dvx=diff(v,x)
dvy=diff(v,y)
dvz=diff(v,z)
dwx=diff(w,x)
dwy=diff(w,y)
dwz=diff(w,z)
J=Matrix([[dux,duy,duz],[dvx,dvy,dvz],[dwx,dwy,dwz]]);
print("The Jacobian matrix is")
display(J)
Jac=Determinant(J).doit()
print('\n\n J = \n')
display(Jac)
J1=J.subs([(x,1),(y,-1),(z,0)])
print('\n\n J at (1,-1,0):\n')
Jac1=Determinant(J1).doit()
display(Jac1)

You might also like