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

Zaid-LAB - 02 - Jupyter Notebook

Uploaded by

Worldly
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)
60 views4 pages

Zaid-LAB - 02 - Jupyter Notebook

Uploaded by

Worldly
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

In [1]:

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

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

Angle between curves in radians is 1.571

In [2]:

#b.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 '% float(w))

Angle between curves in radians is 1.5708


In [4]:

#2. Radius of curvature

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


from sympy import *
t= Symbol ('t')
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 )

The radius of curvature is 3.7712 units

In [6]:

#b.Find the radius of curvature for r = asin(nt) at t = pi/2 and n = 1.


from sympy import *
t ,r ,a , n= symbols ('t r a n')
r=a*sin( n*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 )
rho1 = rho1 . subs (n , 1 )
print ("The radius of curvature is")
display ( simplify ( rho1 ) )

The radius of curvature is

(𝑎2 )1.5
2𝑎2
In [10]:

#3. Parametric curves

#a.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


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

Radius of curvature is

1 0.5
−𝑎( sin2 (𝑡) ) sin(𝑡)
Radius of curvature at r=5 and t= pi/2 is -5

Curvature at (5,pi/2) is -0.2


In [11]:

#b.Find the radius of curvature of y = (asin(t))3/2, x = (acos(t))3/2;

from sympy import *


from sympy . abc import rho , x ,y ,r ,K ,t ,a ,b ,c , alpha
y=( a*sin( t ) ) ** ( 3/2 )
x=( a*cos( t ) ) ** ( 3/2 )
dydx = simplify ( Derivative (y , t ) . doit () )/ simplify ( Derivative (x , t ) . doit
rho = simplify (( 1+ dydx ** 2 ) ** 1.5/( Derivative ( dydx , t ) . doit ()/( Derivative

t ) . doit () ) ) )

print ('Radius of curvature is ')


display ( ratsimp ( rho ) )
t1=pi/4
r1=1 ;
rho1 = rho . subs (t , t1 ) ;
rho2 = rho1 . subs (a , r1 ) ;
display ('Radius of curvature at r=1 and t=pi/4 is ', simplify ( rho2 ) ) ;
curvature =1/ rho2 ;
print ('\n\n Curvature at (1,pi/4) is ',float ( curvature ) )

Radius of curvature is

3.0(𝑎cos(𝑡))3.0 ( (𝑎 cos(𝑎 (𝑡))sin3.0(𝑡))tan3.0 4 (𝑡) + 1)1.5 sin2 (𝑡) tan2 (𝑡)


− (𝑎sin(𝑡))1.5
'Radius of curvature at r=1 and t=pi/4 is '

−2.52268924576114
Curvature at (1,pi/4) is -0.39640237166757364

You might also like