You are on page 1of 12

DIGITAL ASSIGNMENT – 1

EEE1020 - ENGINEERING OPTIMISATION

NAME: ADIL AHAMED SLOT: A1+TA1

REGNO: 18BEE0307

Example 4.7.1: Maximizing the Area of a Garden

A rectangular garden is to be constructed using a rock wall as one side of the garden and wire fencing for
the other three sides (Figure ). Given of wire fencing, determine the dimensions that would create a
garden of maximum area. What is the maximum area?

MATLAB CODE:

clear;
clc;
syms x
A=100*x-2*x.^2;
g=diff(A,x)
solve(g == 0, x);
extrema=vpa(ans,3)
Max_Area=subs(A,extrema)
fplot(A,[0,50])
ylim([0,1400]);
xlabel('x');
ylabel('y');
title('Maximizing the Area of a Garden')
hold on
plot(extrema, subs(A,extrema), '*')
hold off
Example 4.7.2: Maximizing the Volume of a Box

An open-top box is to be made from a by piece of cardboard by removing a square from each corner of
the box and folding up the flaps on each side. What size square should be cut out of each corner to get a
box with the maximum volume?

MATLAB CODE:

clear;
clc;
syms x
V=4*x.^3-120*x.^2+864*x;
g=diff(V,x)
solve(g == 0, x);
extrema=vpa(ans,3)
Max_volume=subs(V,4.71)
fplot(V,[0,16])
ylim([0,2000]);
xlabel('x');
ylabel('V(x)');
hold on
plot(extrema, subs(V,extrema), '*')
hold off
Maximum Volume = 456324111/250000 = 1825 cubic inches
Example 4.7.3: Minimizing Travel Time

An island is mi due north of its closest point along a straight shoreline. A visitor is staying at a cabin on
the shore that is mi west of that point. The visitor is planning to go from the cabin to the island. Suppose
the visitor runs at a rate of mph and swims at a rate of mph. How far should the visitor run before
swimming to minimize the time it takes to reach the island?

MATLAB CODE:

clear;
clc;
syms x
T = (x/8)+sqrt((6-x)^2+4)/3;
g=diff(T,x)
solve(g == 0, x);
extrema=vpa(ans,3)
Time=subs(T,extrema)
fplot(T,[0,50])
ylim([0,10]);
xlabel('x');
ylabel('y');
title('Minimizing Travel Time')
hold on
plot(extrema, subs(T,extrema), '*')
hold off
Example 4.7.4: Maximizing Revenue

Owners of a car rental company have determined that if they charge customers dollars per day to rent a
car, where 50 ≤ p ≤ 200, the number of cars they rent per day can be modeled by the linear function . If
they charge per day or less, they will rent all their cars. If they charge per day or more, they will not rent
any cars. Assuming the owners plan to charge customers between per day and per day to rent a car, how
much should they charge to maximize their revenue?

MATLAB CODE:

clear;
clc;
syms p
R = -5*p.^2+1000*p;
g=diff(R,p)
solve(g == 0, p);
extrema=vpa(ans,3)
Max_revenue=subs(R,extrema)
fplot(R,[50,200])
ylim([0,55000]);
xlabel('p');
ylabel('R(p)');
title('Maximizing Revenue')
hold on
plot(extrema, subs(R,extrema), '*')
hold off
Example 4.7.5: Maximizing the Area of an Inscribed Rectangle

A rectangle is to be inscribed in the ellipse

What should the dimensions of the rectangle be to maximize its area? What is the maximum area?

MATLAB CODE:

clear;
clc;
syms x
A = 2*x*sqrt(4-x^2);
g=diff(A,x)
solve(g == 0, x);
extrema=vpa(ans,3);
y = sqrt(1-((sqrt(2)).^2/4));
L = 2*extrema;
length= L(L>0)
width = 2*y
Max_Area=subs(A,sqrt(2))
Example 4.7.6: Minimizing Surface Area

A rectangular box with a square base, an open top, and a volume of is to be constructed. What should the
dimensions of the box be to minimize the surface area of the box? What is the minimum surface area?

MATLAB CODE:

clear;
clc;
syms x
S=(864/x)+x.^2;
g=diff(S,x)
solve(g == 0, x);
extrema=vpa(ans,3);
extrema=extrema(extrema>0)
x=extrema
y=216/x^2
Min_surfaceArea=subs(S,extrema)
Min_surfaceArea =Min_surfaceArea(Min_surfaceArea>0);
fplot(S,[0,25])
ylim([0,600]);
xlabel('x');
ylabel('S(x)');
title('Minimizing Surface Area')
hold on
plot(extrema, subs(S,extrema), '*')
hold off

You might also like