Professional Documents
Culture Documents
html
Department of Mathematics
Roll Number: 85
Section: M(M3)
1.Limit
dir" - (default: None); dir may have the value 'plus' (or '+' or 'right' or 'above') for a limit from above, 'minus' (or '-'
or'left' or 'below') for a limit from below,or may be omitted (implying a two-sided limit is to be computed).
x
Problem: Find the limit of limx→0 ∣x∣
In [4]: f(x)=x/abs(x)
plot(f(x),(x,-2,2),figsize=3)
Out[4]:
In [5]: limit(f(x),x=0)
Out[5]: und
Out[6]: 1
Out[7]: -1
Problem:
x2 −4
Evaluate limx→2 x−2
In [8]: plot((x^2-4)/(x-2),0,4,figsize=3)
Out[8]:
In [9]: limit((x^2-4)/(x-2),x=2)
Out[9]: 4
Problem:
a
Evaluate limx→a x for various values of a.
In [1]: var('a')
Out[1]: a
In [2]: assume(a>0)
In [3]: limit(x^a,x=infinity)
Out[3]: +Infinity
In [4]: forget()
In [5]: assume(a<0)
In [6]: limit(x^a,x=oo)
Out[6]: 0
Exercise 3.1
Find the following limits
1. limx→0 (x2 − 2x
1000 )
2. limx→0.5− ( ∣2x2x−1
3 −x2 ∣ )
solution 1
In [11]: f(x)=x^2-(2^x/1000)
limit(f(x),x=0)
Out[11]: -1/1000
solution 2
In [23]: f(x)=(2*x-1)/abs(2*x^3-x^2)
limit(f(x),x=0.5,dir="-")
Out[23]: -4.0
2.Derivatives
The syntax for derivative of f(x) is
diff(f, args)
Repeated differentiation is supported by the syntax given in the examples below.
In [29]: f(x)=x*sin(1/x)
Problem:
2
Consider a function f (x) = sin(cos(5x)) − e(x−1) . Plot the graph of f (x) along with first two derivative in [0.5, 2].
In [39]: f(x)=sin(cos(5*x))-exp((x-1)^2)
In [42]: f1(x)=f.diff()
In [44]: f2(x)=f.diff(2)
In [46]: p1=plot(f(x),0.5,2,color='green')
p2=plot(f1(x),0.5,2,color='red')
p3=plot(f2(x),0.5,2,color='magenta')
show(p1+p2+p3,figsize=5)
Out[46]:
Exercise 3.2
1. Find the first four derivatives of f (t) = ln(1 + t2 ) and plot them along with the graph of f (t).
In [0]: solution 1:
In [46]: var('t')
f= log(1+t^2)
f1=f.diff(1),show(f1)
f2=f.diff(2),show(f2)
f3=f.diff(3),show(f3)
f4=f.diff(4),show(f4)
Out[46]: 2t
t2 +1
4 t2 2
− 2 +
(t2 t2 + 1
+ 1)
16 t3 12 t
3 − 2
(t2 (t2
+ 1) + 1)
96 t4 96 t2 12
− 4
+ 3
− 2
In [42]: p1=plot(f1,color='green')
p2=plot(f2,color='red')
p3=plot(f3,color='magenta')
p4=plot(f4,color='blue')
(p1+p2+p3+p4)
Out[42]:
In [0]: solution 2:
In [48]: var('x')
f= sin(3*x)+exp(-2*x)+log(7*x)
f1=f.diff(1),show(f1)
f2=f.diff(2),show(f2)
f3=f.diff(3),show(f3)
f4=f.diff(4),show(f4)
Out[48]:
1
(
+ 3 cos (3 x) − 2 e(−2 x) , None)
x
1
(− + 4 e(−2 x) − 9 sin (3 x) , None)
x2
(
file:///C:/Users/VEDANT PULLIWAR/Downloads/CALCULUS (2).html
) 4/13
2/4/22, 6:46 PM CALCULUS (2).html
2
( − 27 cos (3 x) − 8 e(−2 x) , None)
x3
6
(− + 16 e(−2 x) + 81 sin (3 x) , None)
x4
Partial Derivatives
xy ∂f ∂f ∂ 2 f ∂ 2 f ∂ 2 f ∂2 f
For f (x) = x+y find ∂x , ∂y , ∂x2 , ∂y 2 , ∂x∂y , ∂y∂x
In [48]: var('x,y')
f(x,y)=x*y/(x+y)
show(f(x,y))
Out[48]: xy
x+y
In [51]: show(f.diff(x))
Out[51]: y xy
(x, y ) ↦ −
x+y (x + y )2
In [52]: show(f.diff(x,y))
Out[52]: 1 x y 2 xy
(x, y ) ↦ − 2 − 2 +
x+y (x + y ) (x + y ) (x + y )3
In [53]: show(f.diff(y))
Out[53]: x xy
(x, y ) ↦ −
x+y (x + y )2
In [54]: show(f.diff(y,x))
Out[54]: 1 x y 2 xy
(x, y ) ↦ − 2 − 2 +
x+y (x + y ) (x + y ) (x + y )3
In [56]: f.diff(x)(x=1.0,y=2.0)
Out[56]: 0.444444444444444
In [64]: show(f.diff(2)(x=2.0,y=5.0))
Out[64]:
−0.145772594752187 0.0583090379008746
( )
0.0583090379008746 −0.0233236151603499
In [58]: show(f.diff(x,2))
Out[58]: 2y 2 xy
(x, y ) ↦ − 2 + 3
(x + y ) (x + y )
In [60]: show(f.diff(x,3)(x=2.0,y=5.0))
Out[60]:
0.0624739691795085
In [62]: show(f.diff(y,3))
Out[62]:
In [65]: f.diff(x,y)(x=2,y=1)
Out[65]: 4/27
In [67]: show(f.diff(x,2,y,3))
Out[67]:
36 72 x 48 y 120 xy
(x, y ) ↦ − 4 + 5 + 5 −
(x + y ) (x + y ) (x + y ) (x + y )6
In [69]: show(f.diff(y,2,x,3))
Out[69]: 36 48 x 72 y 120 xy
(x, y ) ↦ − 4 + 5 + 5 −
(x + y ) (x + y ) (x + y ) (x + y )6
In [70]: show(f.diff(x,2,y,4))
In [71]: var('x,y')
f(x,y)=log(x^2+y^2)
In [73]: show(f.diff(x,2,y,2))
Out[73]:
96 x2 y 2 16 x2 16 y 2 4
(x, y ) ↦ − 4 + 3 + 3 − 2
(x2 y2 ) (x2 y2 ) (x2 y2 ) (x2 + y2 )
+ + +
Problem:
2 −y 2 )
For f (x) = f (x, y) = 4xye(−x , find all first order and second order derivatives at point (1,2).
In [2]: var('x,y')
f(x,y)=4*x*y*exp(-x^2-y^2)
show(f(x,y))
Out[2]:
4 xye(−x −y )
2 2
Out[53]:
(x, y ) ↦ − 8 x2 ye(−x −y ) + 4 ye(−x −y )
2 2 2 2
Out[54]:
−8 x2 ye(−x −y ) + 4 ye(−x −y )
2 2 2 2
Out[55]:
−8 x2 ye(−x −y ) + 4 ye(−x −y )
2 2 2 2
Out[3]: -0.0539035759926837
Out[4]: -28*e^(-5)
Out[5]: -16*e^(-5)
In [6]: f.diff(x,y)(x=1,y=2) # Gives Derviative of f first with respect to x and then with
respect to y at (1,2).
Out[6]: 28*e^(-5)
In [7]: f.diff(y,x)(x=1,y=2) # Gives Derviative of f first with respect to y and then with
respect to x at (1,2).
Out[7]: 28*e^(-5)
EXERCISE 3.3
∂2 f ∂2 f
1. Let f (x, y) = ln(x2 + y 2 ). Show that ∂x2
+ ∂y 2
= 0.
2. Find all the first order partial derivatives of w = x2 y − 10y 2 z 3 + 43x − 7tan(4y)
Solution 1:
In [4]: var('x,y')
f(x,y)=log(x^2+y^2)
f1=f.diff(x,2)
f2=f.diff(y,2)
show(f1+f2)
Out[4]:
4 x2 4 y2 4
(x, y ) ↦ − − +
(x2 + y 2 )2 (x2 + y 2 )2 x2 + y2
4(x2 +y 2 ) 4
− (x2 +y2 )2 +
(x2 +y 2 ) =0
Solution 2:
In [32]: var('x,y,z')
w(x,y,z)=(x^2)*y-10*(y^2)*(z^3)+43*x-7*tan(4*y)
show(w.diff(1))
show(w.diff(x,1))
show(w.diff(y,1))
show(w.diff(z,1))
Out[32]:
(x, y, z ) ↦ (2 xy + 43, −20 yz 3 + x2 − 28 tan (4 y )2 − 28, −30 y 2 z 2 )
(x, y, z ) ↦ 2 xy + 43
(x, y, z ) ↦ − 20 yz 3 + x2 − 28 tan (4 y )2 − 28
(x, y, z ) ↦ − 30 y 2 z 2
4. Implicit Derivative
dy
Find the slope formula for the Folium of Descartes implicitly defined by x^3 + y^3 = 6xy.( Find dx )
In [79]: x=var('x')
y=var('y')
f(x,y)=x^3+y^3-6*x*y
y=function('y')(x)
a=diff(f(x,y))
show(solve(a,diff(y)))
[ ]
file:///C:/Users/VEDANT PULLIWAR/Downloads/CALCULUS (2).html 7/13
2/4/22, 6:46 PM CALCULUS (2).html
[ ]
Out[79]: ∂ x2 − 2 y (x)
y (x) = −
∂x y (x)2 − 2 x
EXERCISE 3.4
dy
1. Find the dx for the implicit function 2(x2
+ y 2 )2 = 25(x2 − y 2 ).
2. Find the dx for the implicit function y 2 = x3 (2 − x).
dy
Solution 1:
In [33]: x=var('x')
y=var('y')
f(x,y)=(2*(x^2+y^2)^2)-25*(x^2-y^2)
y=function('y')(x)
a=diff(f(x,y))
show(solve(a,diff(y)))
Out[33]:
4 x3 + 4 xy (x)2 − 25 x
[ ]
∂
y (x) = − 3
∂x 4 y (x) + (4 x2 + 25)y (x)
Solution 2:
In [34]: x=var('x')
y=var('y')
f(x,y)=y^2-x^3*(2-x)
y=function('y')(x)
a=diff(f(x,y))
show(solve(a,diff(y)))
Out[34]:
∂ 2 x3 − 3 x2
[ y (x) = − ]
∂x y (x)
Syntax for finding local maximum value of function f (x) in interval (a, b) is
f.find_local_maximum(a,b
Syntax for finding local minimum value of function f(x) in interval (a, b) is
f.find_local_minimum(a,b).
Problem:
2
Find the local maximum and local minimum of the function f (x) = e−x/2 + e−2x .
f.plot(-2,2,figsize =4)
Out[6]:
In [7]: f.find_local_maximum(-1,1)
In [8]: f.find_local_minimum(-1.5,-0.5)
In [9]: f.find_local_minimum(1,2)
In [10]: f.find_local_minimum(-1.5,-0.5)
In [11]: f.find_local_maximum(1,2)
In [12]: plot(f.diff(),-2,2,figsize=4)
Out[12]:
In [13]: c1 = f.diff().find_root(-2,-0.5)
c1
Out[13]: -0.8669457228341761
In [14]: c2 = f.diff().find_root(-0.5,0);c2
Out[14]: -0.13932333585693482
Problem:
pf = plot(f,0,3)
show(pf,figsize=4)
Out[41]:
In [17]: df = f.diff()
d2f = f.diff(2)
cpts
In [22]: c = infl[0][x]
In [23]: pf = plot(f,0,3,thickness=0.5)
pdf = plot(df,0,3,thickness=0.5,color='red')
pd2f = plot(d2f,0,3,thickness=0.5,color='black')
show(pf+pt1+pt2+pt3+pdf+pd2f,ymin=-5,ymax=8,figsize=4)
Out[23]:
cpts
In [46]: f.find_local_maximum(0,3)
Problem:
The Hubble Space Telescope was deployed on April 24, 1990, by the space shuttle
Discovery. Amodel for the velocity of the shuttle during this mission, from liftoff at
$t=0$ until the solid rocket boosters were jettisoned at $t=126$ seconds, is given by
(in feet per second). Using this model, estimate the absolute maximum and minimum values of the acceleration of
the shuttle between liftoff and the jettisoning of the booster.
In [3]: var('t')
v(t) =0.001302*t^3-0.09029*t^2+23.61*t-3.083
In [26]: plot(v,0,126,figsize=4)
Out[26]:
In [4]: a = v.diff()
a.plot(0,126,figsize=4)
Out[4]:
In [28]: a.find_local_minimum(0,126)
In [5]: a.find_local_maximum(0,126)
Exercise 3.5
1. Find the local maximum and local minimum of f (x) = x4 e−x .
2. The power needed to propel an airplane forward at velocity v is
BL2
P = Av 3 +
v
where A and B are positive constants specific to the particular aircraft and L is the lift, the upward force supporting the weight of
the plane. Find the speed that
Solution 1:
In [3]: f(x)=(x^4)*exp(-x)
plot(f,-1,6,figsize=4)
Out[3]:
In [4]: df = f.diff()
d2f = f.diff(2)
cpts
In [14]: pf = plot(f,-1,6,thickness=0.5)
pd2f = plot(d2f,0,6,thickness=0.5,color='green')
pdf = plot(df,0,6,thickness=0.5,color='violet')
show(pf+pt1+pt2+pd2f+pdf,figsize=4)
Out[14]:
In [76]: f.find_local_maximum(-1,6)
In [12]: f.find_local_minimum(0,0)
Solution 2:
In [7]: var('v')
f(v)=(a*(v^3))+(b*(l^2)/v)
df= f.diff()
show(df)
Out[7]:
bl2
v ↦ (3 av 2 − )
v2
bl2
v= 4
3a
In [0]: