Homework, 3.7
Calculus I
Andy Long

(* 8, 13, 14, 16, 19, 21, 23, 30, p. 257 *)

(* #8: Find the dimensions of a rectangle with area 1000 m^2 whose perimeter is as small as possible. *)
Clear[l,w, Area, Perimeter, deriv,roots]
Area=l*w
roots=Solve[Area==1000,w]
w=w/.roots
w=w[[1]]
Perimeter=2l+2w
deriv=D[Perimeter,l]
roots=Solve[deriv==0,l]
l=l/.roots[[2]]
N[w]
(* It's square! *)

#13, p. 257: A farmer wants to fence an area of 1.5 million square feet in a rectangular field and then divide it in half with a fence parallel to one of the sides of the rectangle. How can he do this so as to minimize the cost of the fence?

Clear[l,w,h, area, volume, cost, deriv,roots]
area=l*w
l[w_]:=1.5/w
perimeter[w_]:=3w+2l[w]
perimeter[w]
roots=Solve[D[perimeter[w],w]==0,w]
ws=Replace[w,roots]
l[ws]

#14, p. 257: A box with a square base and open top must have a volume of 32,000 cm^3. Find the dimensions of the box that minimize the amount of material used.

Clear[l,w,h, b,area, volume, cost, deriv,roots]
volume=h*b^2
h[b_]:=32000/b^2
surfacearea[b_]:=b*b+4b*h[b]
surfacearea[b]
roots=Solve[D[surfacearea[b],b]==0,b]
bs=Replace[b,roots]
h[bs]

#16: A rectangular storage container with an open top is to have a volume of 10m^3. The length of its base is twice the width. Material for the base costs $10 per square meter. Material for the sides costs $6 per square meter. Find the cost of materials for the cheapest such container.

Clear[l,w,h, Area, volume, cost, deriv,roots]
Area=l*w
l=2*w
Volume=Area*h
roots=Solve[Volume==10,h]
h=h/.roots
h=h[[1]]
cost=10*Area+6*(2*w*h+2*l*h)
Plot[cost,{w,5,20}]
deriv=D[cost,w]
roots=Solve[deriv==0,w]
w=w/.roots[[3]]
N[w]
N[cost]
450^(1/3)

(* #19: Find the point closest to the origin on the line y=2x+3. *)

f[x_]:=x^2+(2x+3)^2
Plot[f[x],{x,-3,3}]
Together[f'[x]]
roots=Solve[f'[x]==0]

2*-6/5+3

(* so the point of closest approach is (-6/5,3/5) *)

(* #21: Find the points on the ellipse 4x^2+y^2=4 farthest from (1,0). We'll maximize the distance squared:
 *)
Clear[x, distanceSquared, deriv,roots]
distanceSquared=(x-1)^2 + 4 -4x^2
deriv=D[distanceSquared,x]
roots=Solve[deriv==0,x]
x=x/.roots[[1]]
y=Sqrt[4-4x^2]
y=-Sqrt[4-4x^2]

#23: Find the dimensions of the rectangle of largest area that can be inscribed inside a circle of radius r.

y[x_]:=Sqrt[r^2-x^2]
Area[x_]:=4*x*y[x]
Together[Area'[x]]

Solve[Area'[x]==0,x]

y[r/Sqrt[2]]

(* so the rectangle is square. *)

(* #30: A right circular cylinder is inscribed in a cone with height h and base r. Find the largest possible volume of such a cylinder. *)
y[x_]:=-h/r*x+h
Block[{r=1,h=2},Plot[y[x],{x,0,r}]]
Volume[x_]:=Pi*x^2*y[x]
Together[Volume'[x]]
Solve[Volume'[x]==0,x]

Volume[2r/3]

2*-6/5+3

(* so the point of closest approach is (-6/5,3/5) *)

(* #23: Find the dimensions of the rectangle of largest area that can be inscribed inside a circle of radius r. *)
y[x_]:=Sqrt[r^2-x^2]
Area[x_]:=4*x*y[x]
Together[Area'[x]]

Solve[Area'[x]==0,x]

y[r/Sqrt[2]]

(* so the rectangle is square. *)

(* #30: A right circular cylinder is inscribed in a cone with height h and base r. Find the largest possible volume of such a cylinder. *)
y[x_]:=-h/r*x+h
Volume[x_]:=Pi*x^2*y[x]
Solve[Volume'[x]==0,x]

Volume[2r/3]