Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Prerequisites:
Intro to Sage
Graphing and Solving Equations
Differentiation
Optimization
Optimization is the process of maximizing or minimizing a desired quantity given certain constraints.
For example, you may want to create a cylindrical can that holds 1 liter with the smallest possible surface area.
Our goal is to find an absolute max (or min) of some function. We know this will occur at a local max (min). To find these we want to find the critical points (places where the derivative is 0 or undefined). We then plug these critical points into the function to find the biggest (smallest) value.
The challenge of optimization is converting the statement of the problem (a paragraph) into the right equations, in order to define the quantity to maximize (or minimize) as a function of one variable, which allows us to take the derivative and find the critical points.
We will generally follow these steps:
Step 1 Define relevant variables.
Step 2 Draw a picture.
Step 3 Determine equations relating the variables.
Step 4 Use the given constraints to eliminate as many variables as possible in order to write the quantity to be maximized (or minimized) as a function of one variable.
Step 5 Take the derivative of our function.
Step 6 Set the derivative equal to 0 and solve for the variable. Find where the derivative is undefined (if any). These are the critical points.
Step 7 Plug the critical points and the endpoints of the domain into the function. [Note: If the endpoints of the domain are not included in the domain, then take limits instead.] The largest (smallest) value is the absolute max (min).
Step 8 Check your answer with a graph.
Step 9 Answer the original question. Sometimes you are asked for the max (or min) value. Other times you are asked for the values of the variables that result in that max (min) value. Sometimes you're asked for all of the above. When you're done with the other steps, go back and read the question. And don't forget to use correct units.
Example 1
A rectangle has perimeter 100 meters. Find the dimensions that maximize the area.
Solution
Step 1 Define variables: (1) the dimensions of the rectangle, which we'll call and ; (2) the area, which we'll call ; and (3) the perimeter, which we'll call .
Step 2 Draw a picture.
Step 3 Set up equations:
the area of a rectangle is .
the perimeter is .
Step 4 Eliminate variables:
We are told that . Plug this in to the perimeter equation and solve for one of the variables:
We found . Plug this into the area equation:
This equation gives as a function of :
Steps 5 and 6 Take the derivative and find the critical points.
So if and only if .
Is the derivative ever undefined? No, except at the endpoints of the domain.
We need and to be positive (they are distances), which means they also need to be less than 50 (if one is greater than 50, the other would have to be less than 0 to get a perimeter of 100). So our endpoints are and .
Step 7 Plug the critical points into the function:
Now we see that 625 is the maximum possible area, which occurs when .
Step 8 Check with a graph.
We can see that does indeed have a maximum value around .
Step 9 Answer the question:
When meters, meters as well.
So the rectangle with maximum area and perimeter m is a m by m square.
Example 2
A landscape architect wishes to enclose a rectangular garden. On one side she will use a brick wall costing $30 per foot, and on the other three sides she will use a metal fence costing $10 per foot. If the area of the garden is to be 1000 square feet, find the dimensions of the garden that will minimize the cost of material.
Solution
Step 1 =area of garden, =cost of material, =length, =width (put brick along one of the "" sides)
Step 2 Draw a picture.
Step 3
The cost of fence is the cost per foot times the distance for each side:
Step 4 We are told , so plug this into the area equation and solve for :
Now substitute for in the cost equation to get a function of :
Steps 5 and 6 Take the derivative and find the critical points.
Since x is a distance, we know , so we have one critical point: .
The domain of the cost function is .
Step 7 Let's plug the critical point into the cost function:
What happens to the cost as or ?
As the dimension gets really small or really large, the cost increases without bound, so we have a minimum at our critical point.
Step 8 Check with a graph.
We can see a minimum around .
Step 9 Make sure to answer the question: What dimensions minimize the cost?
We want feet, and then feet (remember the brick goes along one of the sides of this length).
Example 3
A box with no top is to be constructed from a 5 ft by 4 ft piece of cardboard by cutting a square from each corner and folding up the sides. How much should be cut off each corner to maximize the volume of the box?
Solution
Step 1 volume, length, width, and height. We'll cut out an by square from each side (when we fold up the sides, will be the height of the box).
Step 2 Draw a picture.
Step 3 The volume of the box is , where and .
Step 4 Substituting we see
Steps 5 and 6
Step 7
The second value gives a negative volume, so that can't be right. It looks like the first value is the one we want.
We should also think about the endpoints of the domain. We need , since it is a length. We also need , because , and if , then .
Indeed, if we set or we get a volume of 0. This also explains why we got a negative volume for .
So the maximum volume is about , which occurs when .
Step 8 On the graph, we can see a max around .
Step 9 We should cut off approximately feet from each corner.