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

micro

Maths abaggagafsgsgsgsgssgsggsgsgsgshshgsghsggsgsgsgsgsvvsvsgsssggsgsvsvsgsgssgsgsfgsgsgsfgsgsggsgsgsgfsgssf

Uploaded by

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

micro

Maths abaggagafsgsgsgsgssgsggsgsgsgshshgsghsggsgsgsgsgsvvsvsgsssggsgsvsvsgsgssgsgsfgsgsgsfgsgsggsgsgsgfsgssf

Uploaded by

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

1) Plot the Cardioids r = a + acos(θ) and r = a − a cos(θ)

import numpy as np
im port matplotlib . pyplot as plt
import math

plt. axes( projection = ' polar ')


a= 3

rad = np. arange (0 , ( 2 * np. pi ), 0 . 01 )


# plotting the cardioid
for i in rad :
r = a + ( a* np. cos( i))
plt. p o lar (i,r , 'g. ')
r1 = a -( a* np. cos ( i))
plt. pola r(i, r1 , 'r. ')
# display the polar plot
plt. show ()

2) Plot the curve y2(a − x) = x2(a + x), a > 0

p3 = plo t _im p lic it (


Eq (( y ** 2 )*( 2 - x), ( x ** 2 )*( 2 +x)), (x, -5 , 5 ), (y, -5 , 5 ),
title = ' Stro ph o id : $y^ 2 (a- x) =x^ 2 ( a+ x), a> 0$ ') # a= 2

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

from sympy import *

r, t = symb ols( 'r, t') # Define the variables required as symbols

r1 = 4 *( 1 + co s ( t)); # Input first polar curve


r2 = 5 *( 1 - cos ( t)); # Inpu t first polar curve
dr1 = diff ( r1 , t) # find the de rivativ e of first function
dr2 = diff ( r2 , t) # find the derivative of secodn function
t1 =r1 / dr1
t2 =r2 / dr2
q= solve ( r1 - r2 , t) # solve r1 ==r2 , to find the point of intersection
betw een curves
w1 =t1 . subs({ t: float( q[ 1 ])}) # subst it ute the value of " t" in t1
w2 =t2 . subs({ t: float( q[ 1 ])}) # substitu te the value of " t" in t2
y1 = atan ( w1 ) # to find the inverse tan of w1
y2 = atan ( w2 ) # to find the inverse tan of w2
w =ab s ( y1 - y2 ) # angle betw een two curves is abs( w1 - w2 )
prin t ( ' Angle between curves in radians is % 0 . 3f'%( w))

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

from sympy import *


t= Symbol('t') # define t as symbol
r= Sym b ol ( 'r')
r= 4 *( 1 +co s ( t))
r1 = Der iva tiv e (r, t). doit () # find the first de rivative of r w. r. t " t"
r2 = De riv ative ( r1 , t). doit () # find the second de rivativ e of r w. r. t " t"
rho =( r ** 2 +r1 ** 2 ) ** ( 1 . 5 )/( r ** 2 + 2 * r1 ** 2 - r* r2 ); # Su bstitu te r1 and r2 in
formula
rho1 = rho . sub s(t, pi/ 2 ) # sub stitute t in rho
prin t ( ' The radius of cur va tur e is % 3 . 4f units '% rho1 )

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

from sympy import *


x, y = sy m bo ls ( 'x y')

u=exp ( x) *( x* cos( y)- y* sin ( y)) # input mu tiva ria bl e func tion u=u (x, y)
dux = diff (u, x) # Differen ta te u w. r. t x
duy = diff (u, y) # Dif ferenta te u w. r. t. y
dux y = diff ( dux , y) # or duxy =d if f ( u,x , y)
duy x = diff ( duy , x) # or duyx =d if f ( u,y, x)
# Check the condtion uxy =u yx
if du xy == duyx:
prin t(' Mixed partial deriv a t iv e s are equal ')
else :
prin t(' Mixed partial derivatives are not equal ')

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

from sym py import *

x,y, z= sy m bo ls ( ' x,y , z')

u=x* y/ z
v=y* z/ x
w=z* x/ y
# find the all first order partial derivates
dux = diff (u , x)
duy = dif f (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 = dif f (w , z)

# con s tr uc t the Ja cob ia n matrix


J= Ma t rix ( [[ dux , duy , du z],[ dvx , dvy , dvz ],[ dwx , dwy , dwz]]);

print (" The Jacob ian matrix is \ n")


display ( J)

# Find the de t erm ina t of Jac o bian Matrix


Ja c = det ( J). doit ()
pr int (' \ n\ n J = ', Jac)

2
7) Find the Maxima and minima of f (x, y) = x2 + y2 + 3x − 3y + 4.

import sympy
from sym py imp ort Symbol , solve , Derivative , pprint
x= Sym bol( 'x' )
y= Sym bo l( 'y')
f=x ** 2 +x* y+y ** 2 + 3 * x- 3 * y+ 4

d1 = Der iv a tiv e (f, x). doit ()


d2 = Deriv ative (f, y). doit ()
critic alp oin ts1 = solve ( d1 )
critic alp oin ts2 = solve ( d2 )
s1 = Deriv ative (f,x, 2 ). doit ()
s2 = De riv ati ve (f,y, 2 ). doit ()
s3 = Deriv ative ( Derivative (f, y),x). doit ()
prin t (' functio n value is ')

q1 =s1 . subs ( { y: critica lpo in ts 1 , x: cr itica l po in ts 2 }). evalf ()


q2 =s2 . subs ( { y: critica lpo in ts 1 , x: cr itica l po in ts 2 }). evalf ()
q3 =s3 . subs ( { y: critica lpo in ts 1 , x: cr itica l po in ts 2 }). evalf ()
delta =s1 * s2 - s3 ** 2
print( delta , q1 )

if( delta > 0 and s1 < 0 ):


prin t (" f takes maxim um ")
elif ( delta > 0 and s1 > 0 ):
print(" f takes minimu m ")
if ( delta < 0 ):
print (" The point is a saddle point")
if ( delta == 0):
print (" further tests re quir ed ")

8) Expand sin(x) as Taylor series about x = pi/2 upto 3rd degree term.

import numpy as np
from matplotlib im port pyplot as plt
from sym py im port *
x= Sym bo l( 'x ')

y=sin ( 1 * x)
format
x0 = float ( pi/ 2 )
dy= diff (y , x)
d2y = diff (y,x , 2 )
d3y = dif f(y,x, 3 )
yat= lambdify (x, y)
dyat= lam bdify (x, dy)
d2yat= lamb dif y (x, d2y)
d3yat= lamb dify (x , d3y)
y= ya t( x0 ) +(( x- x0 )/ 2 )* dy at( x0 ) +(( x- x0 ) ** 2 / 6 )* d2yat( x0 ) +(( x- x0 ) ** 3 / 24 )*
d3yat( x0 )
print ( simplify ( y))
yat = lamb dify (x, y)
print ( "%. 3f" % yat( pi/ 2+ 10 *( pi/ 180 )))

3
def f( x):
return np. sin ( 1 * x)

x = np. lins pace (- 10 , 10 )

plt. plo t (x, yat( x), co l o r=' red ')


plt. plo t (x, f( x), colo r =' green ')
plt. ylim ( [- 3 , 3 ])
plt. grid ()
plt. show ()

dy
9) Solve: + tanx − y3secx = 0.

from sympy import *

x, y= sy m b o ls( 'x, y')


y= Fun ction (" y" )( x)

y1 = De riv ative (y, x)


z1 = dsolve ( Eq( y1 +y* tan ( x)- y ** 3 * sec( x)),y)

display ( z1 )

Q1) Solution

Q2) Solution

You might also like