The methods learned in Chapter 4 of the text for finding extreme values have practical applications in many areas of life. In this lab, we will use SageMath to help with solving several optimization problems.
4.6
The following strategy for solving optimization problems is outlined on Page 264 of the text.
A farmer has 2400 ft of fencing and wants to fence off a rectangular field that borders a straight river. He does not need to fence along the river. What are the dimensions of the field that has the largest area?
Optimization problems often use the same variables, so you should start every new problem with $\textbf{reset}()$ to clear out variables defined during previous examples.
reset()
We will now assign our given information about the perimeter. We will use $l$ to represent the length of the fence and $w$ to represent the width of the fence. Note: we can create multiple variables at the same time by separating the assignment with commas.
Since we do not need to fence the side bordering the river, our equation for the perimeter is $2l + w$.
l, w = var('l', 'w')
perimeter = 2*l + w == 2400
We are trying to maximize the area of the field, which is given by $l \times w$.
def A(l,w):
return l*w
We can now use the perimeter equation to solve either of the variables in terms of the other and substitute this value into our area function to get area as a function of one variable.
solve(perimeter, l)
We now set $l = -\frac{1}{2}w + 1200$ and redefine $A$ as function which only depends on $w$.
l = -1/2 * w + 1200
A(l,w)
def A(w):
return -1/2 *(w-2400)*w
A(w)
Now, we find the critical points of $A(w).$
solve(diff(A(w),w) == 0, w)
We need to check the area of the field at the critical point $w = 1200$ and at the endpoints. Since both $l$ and $w$ represent lengths, they both must be nonnegative. Therefore, one endpoint is $w = 0$. To find the other, we solve the inequality $l > 0$ for $w$.
solve(l > 0, w)
Hence, our other endpoint is $w = 2400.$ We now find the area of the field at each of these values for $w$. We can use the $\textbf{print}(\dots)$ command to output each line of code and not just the last.
print(A(0))
print(A(1200))
print(A(2400))
Therefore, the area of the field is maximized when $w = 1200$. To find the corresponding value of $l$, we can substitute $w = 1200$ into the expression for $l$.
l(w = 1200)
Hence, the dimensions which maximize the area of the field are a length of 600 ft and a width of 1200 ft.
Find the point on the line $\frac{x}{3} + \frac{y}{5} = 1$ that is closest to the origin.
A rectangular storage container with an open top is to have a volume of 10 m$^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.
A man launches his boat from a point $A$ on the bank of a straight river, 3 km wide, and wants to reach point $B$, 8 km downstream on the opposite bank, as quickly as possible. He could row his boat directly across the river to point $C$ and then run to $B$, or he could row directly to $B$, or he could row to some point $D$ between $C$ and $B$ and then run to $B$. If he can row 6 km/hr and run 8 km/hr, where should he land to reach $B$ as soon as possible?