0% found this document useful (0 votes)
16 views6 pages

23MAT107 Calculus Lab3

Uploaded by

Abhinav p
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)
16 views6 pages

23MAT107 Calculus Lab3

Uploaded by

Abhinav p
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/ 6

Amrita School of Engineering, Bengluru-35

23MAT107 - Calculus
Lab Practice Sheet-3

Plots- Shifting, scaling of functions, Animation Plots


➢ Shifting of functions
Shifting of the parabola function 𝑦 = 𝑥 2
(i) 4 units upward
(ii) 4 units downward
(iii) 1 unit to the right
(iv) 2 units to the left and 4 unit upward
(v) 3 units to the right and 5 unit downward
(vi) reflection about the x-axis

x=-5:0.1:5; y=x.^2; plot(x,y,'Color','yellow')


grid on
hold on
y1=x.^2+4; plot(x,y1,'Color','red')
hold on
y2=x.^2-4; plot(x,y2,'Color','green')
hold on
y3=(x-1).^2; plot(x,y3,'Color','blue')
hold on
y4=(x+2).^2+4; plot(x,y4,'Color','black')
hold on
y5=(x-3).^2-5; plot(x,y5,'Color','magenta')
axis([-8 8 -8 8])
hold off

(OR)

syms f(x)
f(x) = x^2;
figure
fplot(f(x), [-5 5], 'Color','yellow')
grid on; hold on
fplot(f(x)+4, [-5 5],'Color','red')
hold on
fplot(f(x)-4, [-5 5],'Color','green')
hold on
fplot(f(x-1), [-5 5],'Color','purple')
hold on
fplot(f(x+2)+4, [-5 5],'Color','blue')
hold on
fplot(f(x-3)-5, [-5 5],'Color','black’)
hold on
fplot(-f(x), [-5 5],'Color','magenta')
hold off
axis equal; axis([-8 8 -8 8])
xlabel('x'); ylabel('y')
title('Shifting of graph')

➢ Scaling of functions

Example of original, stretched or compressed or reflected graph of the function

x=0:0.01:10; plot(x,sqrt(x),'Color','yellow')
grid on
hold on
t=-10:0.01:0; plot(t,sqrt(-t),'Color','red')
hold on
y2=-sqrt(x); plot(x,y2,'Color','green')
hold on
y3=3*sqrt(x); plot(x,y3,'Color','blue')
hold on
y4=(1/3)*sqrt(x); plot(x,y4,'Color','black')
hold on
y5=sqrt(x/3); plot(x,y5,'Color','magenta')
hold on
y6=sqrt(3*x); plot(x,y6,'Color','cyan')
axis([-8 8 -8 8])
hold off

Example of scaling of graph of the function 𝑦=𝑥2:

1. Vertical Scale

syms f(x)
f(x) = x^2;
figure
fplot(f(x), [-4 4], 'Color','yellow')
grid on; hold on
fplot(2*f(x), [-4 4], 'Color','blue')
hold on
fplot((1/2)*f(x), [-4 4], 'Color','magenta')
hold off
axis equal; axis([-6 6 0 5])
xlabel('x'); ylabel('y')
title('Vertical Scale')

2. Horizontal Scale

syms f(x)
f(x) = x^2;
figure
fplot(f(x), [-4 4], 'Color','yellow')
grid on; hold on
fplot(f(2*x), [-4 4], 'Color','red')
hold on
fplot(f((1/2)*x), [-4 4], 'Color','green')
hold off
axis equal; axis([-6 6 0 5])
xlabel('x'); ylabel('y')
title('Horizontal Scale')

➢ Animate and plot a line segment AB

The points on a line segment AB are:


𝑥 = {(1 − 𝜆)𝐴 + 𝜆𝐵, 0 ≤ 𝜆 ≤ 1}

➢ Animate and plot 2 continuous line segments


Practise Questions

1. Consider the semi-circle 𝐶: 𝑓(𝑥) = √1 − (𝑥 − 1)2 (semicircle above the 𝑋 axis).


(a) Plot 𝑓(𝑥).
>>𝑥 = 0: 0.01: 2; 𝑓𝑥 = 𝑠𝑞𝑟𝑡(1 − (𝑥 − 1). ^2); plot(𝑥, 𝑓𝑥); axis equal
(b) Plot 𝑓(𝑥) + 1 and check how the graph shifts.
>> 𝑥 = 0: 0.01: 2; 𝑓𝑥 = 𝑠𝑞𝑟𝑡(1 − (𝑥 − 1). ^2); plot(𝑥, 𝑓𝑥 + 1); axis
equal
(c) Plot 𝑓(𝑥) − 4 and check how the graph shifts.
>> 𝑥 = 0: 0.01: 2; 𝑓𝑥 = 𝑠𝑞𝑟𝑡(1 − (𝑥 − 1). ^2); plot(𝑥, 𝑓𝑥 − 4); axis
equal
(d) Plot 𝑓(𝑥 − 3) and check how the graph shifts.
(e) Plot 𝑓(𝑥 + 5) and check how the graph shifts.
(f) Plot 3𝑓(𝑥) and check what happens to the graph.
(g) Plot 𝑓(𝑥)/2 and check what happens to the graph.
(h) Plot 𝑓(2𝑥) and check what happens to the graph.
(i) Plot 𝑓(𝑥/4) and check what happens to the graph.
(j) Plot −𝑓(𝑥) and check what happens to the graph.
(k) Plot 𝑓(−𝑥) and check what happens to the graph.
2. Sketch the curve 𝐶: 𝑓(𝑥) = 𝑥 2 in the interval (−2, 2)
(a) Sketch the curve obtained by shifting 𝐶 right by two units
(b) Sketch the curve obtained by shifting 𝐶 left by one unit
(c) Sketch the curve obtained by shifting 𝐶 up by three units
(d) Sketch the curve obtained by shifting 𝐶 down by four units
(e) Sketch the reflection of 𝐶 about the 𝑋 axis.
(f) Plot all the above resultant curves manually as well as in MATLAB.
3. Consider the semi-circle 𝐶: (𝑥 − 1)2 + (𝑦 − 1)2 = 1, above the X axis.
a. Plot the curve 𝐶.
b. Plot the curve obtained after shifting 𝐶 to the right by two units.
c. Plot the curve obtained after shifting 𝐶 up by three units.
4. Show the animation of a line segment drawn from a point 𝐴(25, −10) to 𝐵(1, 15).
5. Using animation try to plot the letters in your name. (Select coordinates accordingly).
6. Try animation of a picture you like using the given concept. (Marvel images, Marvel
weapons, or anything that’s your favorite).
7. You can also try solving the following textbook questions.

You might also like