You are on page 1of 17

University Of Dhaka

Department of Mathematics

MATH Lab II (MTH 250)

Assignment-01

Calculus

Limit of a Function

Q1.
(a) Use the graph of the function f to state the value of each limit, if it exists, and verify your results by
finding the limit.

i)

clc
clear all

% find limit
syms x
f(x)=1/(1+exp(1/x))

f(x) =

lhl=limit(f(x),x,0,'left');
rhl=limit(f(x),x,0,'right');
l=limit(f(x),x,0);
if (lhl==rhl==l)
disp('limit exists')
fprintf('lhl=%d,rhl=%d,l=%d',lhl,rhl,l)
else
disp('limit doesn''t exists')
end

limit doesn't exists

% graph
fplot(f(x),'r')
grid on
xlabel('x axis')
ylabel('y axis')
ii)

clc
clear all
syms x
f(x)=(x^2+x)/sqrt(x^3+x^2)

f(x) =

lhl=limit(f(x),x,0,'left');
rhl=limit(f(x),x,0,'right');
l=limit(f(x),x,0);
if (lhl==rhl==l)
disp('limit exists')
fprintf('lhl=%d,rhl=%d,l=%d',lhl,rhl,l)
else
disp('limit doesn''t exists')
end

limit doesn't exists

fplot(f(x),'b')
grid on
xlabel('x axis')
ylabel('y axis')

iii)

clc
clear all
syms x
f(x)=(exp(x^3)-1)/(1-cos(sqrt(x-sin(x))))

f(x) =

lhl=limit(f(x),x,0,'left');
rhl=limit(f(x),x,0,'right');
l=limit(f(x),x,0);
if (lhl==rhl==l)
disp('limit exists')
fprintf('lhl=%d,rhl=%d,l=%d',lhl,rhl,l)
else
disp('limit doesn''t exists')
end

limit doesn't exists

fplot(f(x),'g')
grid on
xlabel('x axis')
ylabel('y axis')

(b) Find the limit

i)

clc
clear all
syms x
f(x)=(sqrt(9*x^2+x)-3*x)

f(x) =

l=limit(f(x),x,inf)

l =

fplot(f(x),'g')
grid on
xlabel('x axis')
ylabel('y axis')
ii)

clc
clear all
syms x a b
f(x)= sqrt(x^2+a*x)-sqrt(x^2+b*x)

f(x) =

l=limit(f(x),x,inf)

l =

iii)

clc
clear all
syms x y
f(x,y)=exp(-1/(x^2+y^2))*((sin(x))^2)/x^2*(1+1/y^2)^(x+4*y^2)

f(x, y) =
l=limit((limit(f,x,1/sqrt(y))),y,inf)

l(x, y) =

Differentiation

Q2.
(a) Find the first and second derivatives of the function and compare the derivatives using graph.

i)

clc
clear all
syms x
f(x)=2*x-5*x^(3/4)

f(x) =

f1(x)=diff(f(x),x,1)

f1(x) =

f2(x)=diff(f(x),x,2)

f2(x) =

figure(10)
fplot(f(x),'r:','LineWidth',2)
hold on; grid on
xlabel('x axis'); ylabel('y axis')
xlim([-5,15]); ylim([-15,15]);
fplot(f1(x),'y')
fplot(f2(x),'b')
legend('f(x)','f''(x)','f"(x)')
ii)

clc
clear all
syms x
f(x)=exp(x)-x^3

f(x) =

f1(x)=diff(f(x),x,1)

f1(x) =

f2(x)=diff(f(x),x,2)

f2(x) =

figure(20)
fplot(f(x),'r:','LineWidth',2)
hold on
grid on
xlabel('x axis'); ylabel('y axis')
xlim([-5,15]); ylim([-15,15]);
fplot(f1(x),'y')
fplot(f2(x),'b')
legend('f(x)','f''(x)','f"(x)')

(b) Find the number c that satisfies the conclusion of the mean value theorem on the given interval.
Graph the function, secant line through the endpoints and the tangent line at (c,f(c)). Are the secant line
and the thagent line parallel?

i)

clc
clear all
close all
syms x h c
f(x)=sqrt(x) % define function

f(x) =

x=linspace(0,10); % create space for x


a=0;b=4;
y=f(x); % create corresponding y values
plot(x,f(x),'r','LineWidth',2) % plot main function
hold on
grid on
xlabel('x axis'); ylabel('y axis')

k=(f(b)-f(a))/(b-a); % slope of secant line


secL=k*(x-a)+f(a); % secant line
plot(x,secL,'g','LineWidth',2) % plot secant line
c0=diff(f(c),c,1); % find the point that satisfied MVT
c=solve(k==c0,c)

c =

m=limit((f(c+h)-f(c))/h,h,0) % solpe of tangent line

m =

tanL=m*(x-c)+f(c); % tangent line


plot(x,tanL,'b','LineWidth',2) % plot tangent line

if (k==m) % verify whether parallel or not


disp('parallel')
else
disp('not not parallel')
end

parallel

scatter(a,f(a),'filled') % plot the points


scatter(b,f(b),'filled')
scatter(c,f(c),'filled')

ii)
clc
clear all
close all
syms x c h
a=1;b=2;
f(x)=x^3+x-4

f(x) =

fplot(f(x),'LineWidth',2)
grid on; hold on; xlabel('x axis'); ylabel('y axis');

k=(f(b)-f(a))/(b-a) % slope of secant line

k =

secant(x)=k*(x-a)+f(a) % secant line

secant(x) =

fplot(secant(x),'r','LineWidth',2)

f1(x)=diff(f(x),x,1);
c=solve(k==f1(x),x) % point that satisfies MVT

c =

m=limit((f(c+h)-f(c))/h,h,0) % slope of tangent

m =

if m==k % verify
disp('parallel')
else
disp('not parallel')
end

parallel

% positive value is taken


tangent(x)=m*(x-c(2,1))+f(c(2,1)) % tangent line

tangent(x) =
fplot(tangent(x),'b:','LineWidth',2) % plot tangent

scatter(a,f(a),'filled') % plot points


scatter(b,f(b),'filled')
scatter(c,f(c),'filled')

(c) Sketch f(x),f'(x) and f''(x) and find interval of increasing or decreasing, local maximum or minimum
and interval of concavity and inflection and also draw them in the same graph.

clc
clear all ; close all
syms x
f(x)=-36*x+3*x^2-2*x^3

f(x) =

f1(x)=diff(f(x),x,1);
f2(x)=diff(f(x),x,2);
fplot(f(x),'r','LineWidth',2)
hold on; grid on; xlabel('x axis');ylabel('y axis');
fplot(f1(x),'b','LineWidth',2)
fplot(f2(x),'g','LineWidth',3)
legend('f(x)','f''(x)','f"(x)')

cp=solve(f1(x)==0,x) % critical point

cp =

f(cp)

ans =

inc=solve(f1(x)>0,x) % increasing interval

inc =

dec=solve(f1(x)<0,x) % decreasing interval

dec =

xmin=fminsearch(f,1) % minimum value

Exiting: Maximum number of function evaluations has been exceeded


- increase MaxFunEvals option.
Current function value: -5092589940836256200000000000000000000000000000000000000000000000000000
xmin = 6.3383e+28

f(xmin)

ans
=

xmax=fminsearch(@(x) -f(x),-1) % maximum value

Exiting: Maximum number of function evaluations has been exceeded


- increase MaxFunEvals option.
Current function value: -5092589940836256200000000000000000000000000000000000000000000000000000
xmax = -6.3383e+28

f(xmax)
ans
=

ip=solve(f2(x)==0,x) % inflection point

ip =

f(ip)

ans =

c_up=solve(f2(x)>0,x) % concave up interval

c_up =

c_down=solve(f2<0,x) % concave down interval

c_down =

plot(cp,f(cp),'ro')

Warning: Imaginary parts of complex X and/or Y arguments ignored

plot(ip,f(ip),'*')
d) Partial derivatives

i)

clc ; clear all; close all;


syms x y
f(x,y)=(x^2-2*x)*exp(-x^2-y^2-x*y)

f(x, y) =

fx(x,y)=diff(f(x,y),x,1)

fx(x, y) =

fy(x,y)=diff(f(x,y),y,1)

fy(x, y) =

ii)

clc ; clear all; close all


syms x y z
f(x,y,z)=sin(x^2*y)*exp(-x^2*y-z^2)
f(x, y, z) =

fzyxx=diff(diff(diff(f(x,y,z),z,1),y,1),x,2)

fzyxx =

Integration
3. Sketch the Graph and find the area.

i)

clc; clear all; close all


syms x
f(x)=sqrt(x-1)

f(x) =

g(x)=x-1 % functions

g(x) =

fplot(f(x),'r',[0,3],'LineWidth',2)
hold on; grid on
fplot(g(x),'g',[0,3],'LineWidth',2)
legend('f(x)','g(x)')
fg(x)=f(x)-g(x) % integrand

fg(x) =

solx=solve(f(x)==g(x),x) % limit of integration

solx =

area=int(fg,solx(1,1),solx(2,1)) % area

area =

ii)

clc; clear all; close all


syms x
f(x)=cos(x)

f(x) =

g(x)=1-cos(x) % functions
g(x) =

a=0;b=pi;
fplot(f(x),'r')
hold on; grid on
fplot(g(x),'g')
legend('f(x)','g(x)')

area=abs(int((f(x)-g(x)),a,b))

area =

The End

You might also like