Professional Documents
Culture Documents
2 - 5 6 - 11 12 - 13 Limit of A Function 14 - 17 18 - 21 22 - 25
2 - 5 6 - 11 12 - 13 Limit of A Function 14 - 17 18 - 21 22 - 25
1. Shifting of a Graph
2-5
2. Scaling of a Graph
6 - 11
3. Plotting a Piecewise
Function 12 - 13
4. Limit of a Function
14 - 17
5. Continuity of a Function
18 - 21
6. Differentiability of a 22 - 25
Function
Page | 1
OUTPUT:
Shifting of a graph:
Page | 2
1. Horizontal Shifting:
CODE:
syms x x = -10 : 1 :
10 y = abs(x) y1 =
abs(x+2) y2 = abs(x-
2) plot(x, y, 'r') hold
on grid on plot(x, y1,
'b') hold on plot(x, y2,
'g') xlabel('x')
ylabel('y')
title("Horizontal Shifting of Graph")
legend('y=abs(x)', 'y1=abs(x)+2', 'y2=abs(x)-2')
OUTPUT:
Page | 3
2. Vertical Shifting:
CODE:
clc clear ll syms x x
= -10 : 1 : 10 y =
abs(x) y1 = abs(x)+2
Page | 4
y2 = abs(x)-2 plot(x,
y, 'r') hold on grid on
plot(x, y1, 'b') hold
on plot(x, y2, 'g')
xlabel('x') ylabel('y')
title("Vertical Shifting of Graph") legend('y=abs(x)',
'y1=abs(x)+2',
'y2=abs(x)-2')
OUTPUT:
Page | 5
Scaling of Graph
CODE
:
1.Horizontal Strech & Compression of Graph:
syms x x = 0 : 1 : 10
y = sqrt(x) y1 =
Page | 6
sqrt(3*x) y2 =
sqrt(x/3) plot(x, y, 'r')
hold on, grid on
plot(x, y1, 'b') hold on
plot(x, y2, 'g')
xlabel('X') ylabel('Y')
title("Horizontal Strech & Compression of Graph") legend('y=sqrt(x)',
'y1=sqrt(3*x)', 'y2=sqrt(x/3)')
OUTPUT:
Page | 7
2.Vertical Strech & Compression of Graph:
CODE:
Page | 8
syms x x = 0 : 1 : 10 y = sqrt(x) y1 = 5*sqrt(x) y2 = sqrt(x)/2 plot(x, y,
'r') hold on, grid on plot(x, y1, 'b') hold on plot(x, y2, 'g') xlabel('X')
ylabel('Y') title("Vertical Strech & Compression of Graph")
legend('y=sqrt(x)', 'y1=5*sqrt(x)', 'y2=sqrt(x)/2')
OUTPUT:
Page | 9
3.Reflection over X-Axis & Y-Axis:
Page | 10
CODE:
(i) Reflection over X-Axis
syms x x = -10 : 1 :
10 y = abs(x) y1 = -
abs(x) plot(x, y, 'r')
hold on, grid on
plot(x, y1, 'b')
xlabel('X') ylabel('Y')
title("Reflection over X-Axis")
legend('y=abs(x)', 'y1=-abs(x)')
OUTPUT:
Page | 11
Plotting a Piecewise Function
CODE:
Page | 12
syms x f(x)=piecewise(x>-4 & x<-1, x.^2+1,x==-1,-2, x>-1 &
x<=0,x.^2+1, x>0 & x<1,sqrt(2*x), x==1,2, x>1 & x<4, sqrt(2*x))
OUTPUT:
Page | 13
Page | 14
Limit of a Function
CODE:
Page | 15
Page | 16
x3 = 1
LHL3 = limit(f,x,x3,"left") RHL3 =
limit(f,x,x3,"right") if any(LHL3 ==
RHL3)
fprintf("Limit exist at %d", x3) else
fprintf("Limit doesnot exist at %d", x3) end
xlabel('x') ylabel('y')
title("Limit of a Function")
Page | 18
OUTPUT:
Continuity of a Function
CODE:
syms x
f(x)=piecewise(x>=-4 & x<=-1, x.^2+1, x>-1 & x<=0,x.^3-1, x>0 & x<=1, x.^2,
x>1 & x<=4, sqrt(x))
xlabel('x') ylabel('y')
title("Continuity of a Function")
x1 = -1
f_val1 = vpa(subs(f,x,x1)) lt1 =
limit(f,x,x1) if any(f_val1 == lt1)
fprintf("The function is continous at %d", x1) else
fprintf("The function is not continous at %d", x1) end
Page | 19
Page | 20
x2 = 0
f_val2 = vpa(subs(f,x,x2)) lt2 =
limit(f,x,x2) if any(f_val2 == lt2)
fprintf("The function is continous at %d", x2) else
fprintf("The function is not continous at %d", x2) end
x3 = 1
f_val3 = vpa(subs(f,x,x3)) lt3 =
limit(f,x,x3) if any(f_val3 == lt3)
fprintf("The function is continous at %d", x3) else
fprintf("The function is not continous at %d", x3) end
x4 = 4 f_val4 = vpa(subs(f,x,x4))
lt4 = limit(f,x,x4,"left") if
any(f_val4 == lt4)
fprintf("The function is continous at %d", x4) else
fprintf("The function is not continous at %d", x4) end
x5 = -4
f_val5 = vpa(subs(f,x,x5)) lt5 =
limit(f,x,x5,"right") if any(f_val5 == lt5)
fprintf("The function is continous at %d", x5) else
fprintf("The function is not continous at %d", x5) end
Page | 21
Page | 22
OUTPUT:
Differentiability of a Function
CODE:
#Piecewise Function:
syms x
f(x)=piecewise(x<=0,x.^3-x.^2,x>0,x.^2+x)
Df=diff(f(x),x)
LHD=limit((f(x)-f(0))/(x-0),x,0,'left') RHD=limit((f(x)-
f(0))/(x-0),x,0,'right') if (LHD==RHD)
fprintf("The function is differentiable at x=0") else
fprintf("The function is not differentiable at x=0") end
#Polynomial Function:
syms x
f(x)=(x.^3)/3-(x.^2)+x
Df(x)=diff(f(x),x) Pt1=Df(3)
critpt=solve(Df(x)==0,x)
D2f(x)=diff(Df(x),x)
Pt2=Df(2)
Pt_inflect=solve(D2f(x)==0,x)
Page | 24
#Rational Function:
Page | 25
syms x
f(x)=(2*x+1)/(x.^3) Df(x)=diff(f(x),x)
[n,d]=numden(Df(x)) crit_pt1=solve(n==0,x)
crit_pt2=solve(d==0,x)
Page | 26