0% found this document useful (0 votes)
9 views5 pages

Sai 2

The document outlines a digital assignment for a calculus lab using MATLAB to find local and global maxima and minima of the function f(x) = x + sin(2x) over the interval (-4, 4), calculate the area between the curves x = y^3 and x = y^2, and determine the volume of a solid generated by revolving the curve y = 4/(x^2 + 4) around the x-axis from x = 0 to x = 2. It includes MATLAB code snippets for each task and the corresponding outputs. The assignment is for a student named Sai Prashanth in the M.Tech Software Engineering course.

Uploaded by

sair85765
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Sai 2

The document outlines a digital assignment for a calculus lab using MATLAB to find local and global maxima and minima of the function f(x) = x + sin(2x) over the interval (-4, 4), calculate the area between the curves x = y^3 and x = y^2, and determine the volume of a solid generated by revolving the curve y = 4/(x^2 + 4) around the x-axis from x = 0 to x = 2. It includes MATLAB code snippets for each task and the corresponding outputs. The assignment is for a student named Sai Prashanth in the M.Tech Software Engineering course.

Uploaded by

sair85765
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CALCULUS LAB DIGITAL ASSIGNMENT-2

NAME: SAI PRASHANTH


REGISTRATION NUMBER: 24MIS0380
COURSE: M.Tech Software Engineering(Integrated)

1
1. Using MATLAB, find the local and global maxima and minima
for the function f(x) = x + sin(2x) in the interval (−4, 4).

CODE:
f = @(x) x + sin(2*x);
x = -4:0.01:4;
y = f(x);
plot(x, y);
xlabel('x');
ylabel('f(x)');
title('f(x) = x + sin(2*x)');
[local_max_y, local_max_idx] = findpeaks(y);
local_max_x = x(local_max_idx);
[local_min_y, local_min_idx] = findpeaks(-y);
local_min_x = x(local_min_idx);
[global_max_y, global_max_idx] = max(y);
global_max_x = x(global_max_idx);
[global_min_y, global_min_idx] = min(y);
global_min_x = x(global_min_idx);
fprintf('Local Maxima:\n');
for i = 1:length(local_max_x)
fprintf('x = %.4f, f(x) = %.4f\n', local_max_x(i), local_max_y(i));
end
fprintf('Local Minima:\n');
for i = 1:length(local_min_x)
fprintf('x = %.4f, f(x) = %.4f\n', local_min_x(i), -local_min_y(i));

2
end
fprintf('Global Maximum:\n');
fprintf('x = %.4f, f(x) = %.4f\n', global_max_x, global_max_y);
fprintf('Global Minimum:\n');
fprintf('x = %.4f, f(x) = %.4f\n', global_min_x, global_min_y);

2. Using MATLAB, find the area of the region bounded by the


curves x = y^3 and x = y^2 .

3
CODE:
f1 = @(y) y.^3;
f2 = @(y) y.^2;
syms y;
intersection_points = double(solve(y^3 == y^2, y));
intersection_points = intersection_points(intersection_points >= 0);
area = integral(@(y) f2(y) - f1(y), intersection_points(1),
intersection_points(2));
fprintf('The area of the region bounded by the curves is: %f\n', area);

3. Using MATLAB, find the volume of the solid generated by


revolving about the x− axis the region bounded by the curve y
= 4 x2+4 , the x− axis, and the lines x = 0 and x = 2.

4
CODE:
f = @(x) 4 ./ (x.^2 + 4);
a = 0;
b = 2;
volume = pi * integral(@(x) (f(x)).^2, a, b);
fprintf('The volume of the solid generated by revolving about the x-axis is:
%f\n', volume);

You might also like