0% found this document useful (0 votes)
20 views4 pages

Calculus Lab 2

The document describes two lab experiments: 1. Finding the maxima and minima of a function of a single variable using critical points, the second derivative test, and plotting. It provides code to find critical points, evaluate the second derivative at those points, and plot the function with critical points marked. 2. Calculating the definite integral of a function over a given interval. It provides a code template to input the function and limits and calculate the integral.
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)
20 views4 pages

Calculus Lab 2

The document describes two lab experiments: 1. Finding the maxima and minima of a function of a single variable using critical points, the second derivative test, and plotting. It provides code to find critical points, evaluate the second derivative at those points, and plot the function with critical points marked. 2. Calculating the definite integral of a function over a given interval. It provides a code template to input the function and limits and calculate the integral.
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/ 4

Lab experiment 2

A. Maxima and Minima for a function of a single variable:


i) Critical points
ii) Second derivative test
iii) Plotting the points on the curve

i) Critical Points:
 Initialization:

syms x real
f= input('Enter the function f(x):');

 Solving the function for critical points:

fx= diff(f,x)

c = solve(fx)

cmin = min(double(c));

cmax = max(double(c));

ezplot(f,[cmin-2,cmax+2])

hold on

ii) Second derivative test:

 Check if each of the point is a maximum or a minimum or a point of inflection:

for i = 1:1:size(c)

T1 = subs(fxx, x ,c(i) );

T3= subs(f, x, c(i));

if (double(T1)==0)

sprintf('The point x is %d inflexion


point',double (c(i)))
else

if (double(T1) < 0)

sprintf('The maximum point x is %d', double(c(i)))

sprintf('The value of the function is %d', double (T3))

else

sprintf('The minimum point x is %d', double(c(i)))

sprintf('The value of the function is %d', double (T3))

end

end

 Plot the critical points on the graph

% plot the critical points


plot(double(c(i)), double(T3), 'r*', 'markersize', 15);

end

Visualization of all the functions:

h=ezplot(fx,[cmin-2,cmax+2])

set(h,'color','r')

hold on

pause
e=ezplot(fxx,[cmin-4,cmax+4])

set(e,'color','g')

hold off

Practice Problems:
1. An open-top box is to be made by cutting small congruent squares from
the comers of a 12-in.-by-12-in. sheet of tin and bending up the sides.
How large should the squares cut from the corners be to make the box
hold as much as possible?

.
2. A rectangle is to be inscribed in a semicircle of radius 2. What is the
largest area the rectangle can have, and what are its dimensions?

Length :2x, Height: Area: 2x . A(x)= 2x .

B. Finding a definite Integral for a given function:


Command: int (function, lower limit, upper limit)

syms x

f=input('enter the function f(x):');

a=input('enter lower limit of x ');

b=input('enter the upper limit of x');

z=int(f,a,b)

You might also like