Digital Assignment-1, Slot: L29+L30 Name: MD RAKHSHAN SAIF
Course: CALCULUS (BMAT101P) Reg no. 24BKT0164
Department of Mathematics, School of Advanced Sciences
Faculty Name: Dr Mellacheruvu Naga Srinivasu
1. Plot the following using Matlab code : (i) r = 2+ 3cos (ii) 2sin (iii) x=sin t; y=cos t; z=t^2
(iv) x=t; y=t^2; z=t^3
(i) r=2+3 cos
Code:
theta = linspace(0, 2*pi, 1000); r
= 2 + 3 * cos(theta);
figure; polarplot(theta, r); title('Polar
Plot: r = 2 + 3 \cos(\theta)');
2sin
(ii)
Code:
theta = linspace(0, 2*pi, 1000);
x = 2 * sin(theta);
figure;
plot(theta, x); xlabel('\theta'); ylabel('x');
title('Parametric Plot: x = 2 \sin(\theta)');
x=sin t; y=cos t; z=t^2
Code: t = linspace(-2*pi, 2*pi, 1000); % Define t from -2*pi
to 2*pi
x = sin(t); y
= cos(t); z
= t.^2;
(iii)
figure; plot3(x, y, z); xlabel('x'); ylabel('y'); zlabel('z');
title('3D Parametric Plot: x = \sin(t), y = \cos(t), z = t^2');
grid on;
x=t; y=t^2; z=t^3
Code:
t = linspace(-2, 2, 1000); % Define t from -2 to 2
x = t; y
= t.^2; z
= t.^3;
figure; plot3(x, y, z); xlabel('x'); ylabel('y');
zlabel('z'); title('3D Parametric Plot: x = t, y =
t^2, z = t^3'); grid on;
(iv)
2. Find the derivatives of the following using MATLAB (i) Sinx cosx (ii) sin x/ cos x
(iii) (3x+2)/(4x+5) (i).
Sinx cosx
Code: syms
x;
f = sin(x) * cos(x);
f_derivative = diff(f, x);
disp('The derivative of sin(x) * cos(x) is:'); disp(f_derivative);
Output : The derivative of sin(x) * cos(x) is: cos(x)^2 - sin(x)^2
(ii) sin x/ cos x
Code: syms
x;
f = sin(x) / cos(x);
f_derivative = diff(f, x);
disp('The derivative of sin(x) / cos(x) is:'); disp(f_derivative);
Output: The derivative of sin(x) / cos(x) is: sin(x)^2/cos(x)^2 + 1
(iii)(3x+2)/(4x+5) Code:
f = (3*x + 2) / (4*x + 5);
f_derivative = diff(f, x);
disp('The derivative of (3x + 2) / (4x + 5) is:'); disp(f_derivative);
Output: The derivative of (3x + 2) / (4x + 5) is: 3/(4*x + 5) - (4*(3*x + 2))/(4*x + 5)^2
3. Find the area between the parabolas y^2=4x and x^2= 4y using Matlab code.
Code: syms
x y;
eq1 = y^2 - 4*x; eq2
= x^2 - 4*y;
[sol_x, sol_y] = solve([eq1, eq2], [x, y]);
disp('Points of intersection:'); disp([sol_x,
sol_y]);
f1 = @(x) 4 * sqrt(x); f2
= @(x) x.^2 / 4;
a = double(sol_x(1)); b
= double(sol_x(2));
area = integral(@(x) f1(x) - f2(x), a, b);
disp('The area between the parabolas is:'); disp(area);
Output: Points of intersection:
[ 0, 0]
[ 4, 4]
[- 2 + 3^(1/2)*2i, - 2 - 3^(1/2)*2i] [-
2 - 3^(1/2)*2i, - 2 + 3^(1/2)*2i]
The area between the parabolas is: 16
4. Find the area between the parabola x^2=4y, x-2 and x-axis using Matlab code
Code: syms
x y;
parabola_eq = x^2 - 4*y;
x_val = 2;
y_intersection = solve(subs(parabola_eq, x, x_val), y);
disp('Intersection point at x = 2:'); disp(['y = ',
num2str(double(y_intersection))]);
y_parabola = @(x) (x.^2) / 4;
x_lower = 0; x_upper
= 2;
area = integral(@(x) y_parabola(x), x_lower, x_upper);
disp('The area between the parabola x^2 = 4y, x = 2, and the x-axis is:');
disp(area);
Output:
Intersection point at x = 2:
y=1
The area between the parabola x^2 = 4y, x = 2, and the x-axis is: 0.6667