# Calculus/Optimization

## Introduction

editOptimization is one of the uses of calculus in the real world. Perhaps we are a pizza parlor and wish to maximize profit. Perhaps we have a flat piece of cardboard and we need to make a box with the greatest volume. How does one go about this process?

This requires the use of maximums and minimums. We know that we find maximums and minimums via derivatives. Therefore, one can conclude that calculus will be a useful tool for maximizing or minimizing (collectively known as "optimizing") a situation.

In general, an optimization problem has a constraint that changes how we view the problem. The wording of the problem (whether subtle or not) can also drastically change how we view the problem. The constraint is the thing we will absolutely not change (such as the general shape, or the amount that we are willing to pay for the entire operation, etc.). If we can identify what we are going to change and what we are going to require stay the same, we will be on our way to solve the problem.

## How to Solve

editThese general steps should be taken in order to complete an optimization problem.

- Write out necessary formulas and other pieces of information given by the problem.
- The problems should have a variable you control and a variable that you want to maximize/minimize.
- The formulas you find may contain extra variables. Depending on how the question works out, they may be substituted out or can be ignored (which will be explained later).

- Combine the formulas together so that the variable you want to maximize/minimize is on one side of the equation and everything else on the other.
- Differentiate the formula. If your equation has multiple variables, pick any variable to differentiate as long as it is not the one you control (i.e. pick the variable that you could not get rid of from the formula).
- Note that during differentiation, if you come across a variable that you have not picked, imagine it as a number and apply the necessary differentiation rule. Do not treat it as a variable in this case.

- Set the differentiated formula to equal 0 and solve for the variable you control.
- The value you get here is your answer. If you instead have another formula, that means that your answer depends on those other variables, which would usually be what the question asked for if you have such a situation that you have another variable to juggle to begin with.

The reason why this algorithm works comes from a few mathematical theorems which you will probably not need to know when completing these problems. Usually the problems given will be mathematically simple (in other words, there are not a lot of cases to test). However, if you wish to know, they work like this:

- A derivative of 0 is either a global or local maximum or minimum. Usually the question will tend towards answering that question without much difficulty (like always positive numbers, for example)

## Examples

edit### Volume Example

edit- Write out known formulas and information

- Write the variable in terms of in the volume equation.

- Find the derivative of the volume equation in order to maximize the volume

- Set and solve for

- Plug-in the value into the volume equation and simplify

### Volume Example II

editIf we call the side length of the cut-out squares , then each side of the base of the folded box is , and the height is . Therefore, the volume function is . We must optimize the volume by taking the derivative of the volume function and setting it equal to 0. Since it does not change, is treated as a constant, not a variable.

We can now use the quadratic formula to solve for :

We reject , since it is a minimum (it results in the base length being 0, making the volume 0).

### Volume Example III

editThis is a classic problem for optimization. The problem is we do not have any specified measurements. Luckily enough, we are given SI units, so we can write what we are given accordingly,

- Conversion factor: . This means that through dimensional analysis (or basic algebra): . Recall that this is the volume!
- Volume of a cylinder:
- Surface area of a cylinder:

Recall what we are trying to minimize: "the amount of material required to construct the can of specified volume." This means the surface area needs to be minimized! The unfortunate part is we have two variables (it is not constant). Luckily, we can use the volume to write in terms of :

We can the substitute this information into the surface area formula and minimize (set the first derivative to zero):

- . Eliminate the and .
- Set the first derivative equal to zero.

All that is left to do is find the critical values of the operation. This ultimately means to let the numerator equal zero and find what values of make the denominator equal to zero. Here is the operation for the numerator:

Here is the operation for the denominator:

Let us note that we do not care about one of the critical values being equal to zero. This problem is asking us to find the value that makes the condition true but also minimized. While zero does minimize the amount of material used to construct the can, we cannot make a can if we do not show one. This solution would be interesting, however, if we were asked about the graph of . Nevertheless, our final answer may not necessarily be and . We need to verify that the critical value we found is the correct answer. That is where we substitute values for and into the first derivative:

- For , let : . For , let : .

Based on these results above, it is clear that is a value that minimizes the function such that it allows us to make a can. Keep in mind, if you do not show that the value we found is a minimum, then this value could also be a maximum. Imagine if that were the case, and we suggested the company to produce a can that would maximize the amount of material used. Potentially millions of dollars of material costs would offset the profit from the optimum. Either way, we have found our answers:

### Sales Example

editThe retailer's profit is defined by the equation , which is the net revenue generated. The question asks for the maximum amount of profit, or the maximum of the above equation. As previously discussed, the maxima and minima of a graph are found when the slope of the said graph is equal to zero. To find the slope, one finds the derivative of the function of interest – here, . By using the subtraction rule :

Therefore, when the profit will be maximized or minimized. Use the quadratic formula to find the roots, giving . To find which of these is the maximum and minimum the function can be tested:

Because we only consider the functions for all (i.e., you can't have units), the only points that can be minima or maxima are those two listed above. To show that is in fact a maximum (and that the function doesn't remain constant past this point) check if the sign of changes at this point.

Here, it does, and for greater than , will continue to decrease. This demonstrates that the firm will be maximizing its profits at . The retailer selling units would return a profit of $ .

### Revenue Example

editThe revenue of a firm is calculated by multiplying the quantity sold to the price. Since is the price, and is the quantity sold, . The question is asking us to find the price that will maximize the quantity. This means finding the quantity is the first goal. The final goal is the price found.

Our first goal is finding the quantity that will maximize the revenue. The revenue function is maximized if the slope of the tangent line is zero at a point and the sign of the slope around those points change sign from positive to negative. This is achieved through taking the derivative and applying the first derivative test. This is made easier when the revenue function distributes the :

Let us now take the first derivative:

Set the first derivative equal to zero to find the critical values:

Take note of the original revenue function. Because the revenue function is a quadratic that has its term multiplied by a factor less than 0, it is guaranteed there is only one critical value, and it must be a maximum. The calculus-based approach simply confirms this truth (using the first derivate test):

- For any , . For any , . Therefore, the critical value must be a maximum.

All that is left to do is input this domain into the demand function to find the price the widgets should be sold at. This is a simple substitution exercise:

### Distance of Function to Origin

editLet us write all the relevant equations we might want to keep in mind:

The problem with optimization problems is that most of the time, you work with two variables as opposed to one. However, the main idea and focus is to write the two-variable equation into a single-variable equation. It is important to relate the variables here. The best way to do this is by using the set-up of the problem to your advantage.

We want to leave the function at and minimize the distance required to reach the origin. This means we let . Recall that the origin is at , so . With all the information we have here, let us go ahead and write the distance function in terms of the singular variable. Because :

We will show two ways to take the derivative: the standard way and the non-standard way. The standard way will require us to use the chain rule, so let us demonstrate this procedure:

#### Standard way

editWe now have the first derivative of the distance formula. To minimize the distance between and the origin, set the first derivate equal to zero. By now, you should know why we have to do this:

- Let .
- implies the numerator is zero. As such:

- Let .
- Recall that if the denominator can be set equal to zero, then the value for which makes that true is a critical value. As such, let :
- There is no real value for which makes the above equation true. This can be shown using the determinant is less than zero: . As such,

The only critical value is . By now, you should be saying that we need to use the first derivative test:

- For any , . For any , . This implies the function before the critical value is decreasing, and the function after the critical value is increasing. This implies the function at the critical value is a local minimum.

As such, the -value that will minimize the distance between and the origin is .

However, you have not finished the question yet. You still have to find the point of the function that the particle needs to stop at. This is simply a matter of substitution into the function :

Most teachers in calculus classes don't mind if you leave the answer as . However, for the minuscule number of teachers or testing organizations that care about rationalizing the denominator, the work for is done below:

This is the reason most teachers don't mind if the denominator is left as a square root; it distracts from the calculus (although slightly). This leaves us with the final answer:

#### Non-standard way: implicit differentiation

editOnly the implicit differentiation will be shown, since any calculations beyond that would result in the same procedures we outlined before. Recall . Square both sides to return the function seen below:

Taking the derivative of the above function with respect to will require us to implicitly differentiate (although this differentiation is neatly disguised). The calculations are demonstrated below:

Notice how the calculation above resulted in the same first derivative when done the standard way, meaning the calculations from herein will be the same. With this let us move on to the next problem.

### Maximizing the Rectangular Area Formed by a Curved Shelf

editThis problem seems very weird. However, in actuality, this is a disguised variation of another common optimization problem, the maximum rectangular area formed by a function problem. The problem becomes much more manageable when thinking about it in those terms. What the manufacturer wants, after all, is a maximized indentation size. It is not asking about the volume of that size, only the part where you can find this is actually true.

The image shown on the right is actually the maximum area formed. However, if the problem did not provide an image (and no numbers on the axes), then one would not be approximating.

Let be the distance from the left-hand side of the shelving unit, and let the height of the rectangle formed be . Such a construction means that is the length of the rectangle while the height is . Therefore, the area function is

We want to find the maximum of the function given herein. Let us find the derivative of the area and set it equal to zero:

However, after finding the first derivative, it is evident that finding the value for in this specific situation is unknown to us at this time because we do not know about the Lambert-W Function. Therefore, a graphing calculator is acceptable to use now (typically, many teachers want to see as much work as possible before allowing you to use the calculator for solutions). If one does not have a graphing calculator, use Desmos or Geogebra or the many other online graphing calculators.

The answer obtained by those websites is or an exact answer of . We know this is also the maximum that we are looking for because the derivative function is positive for but negative after it. For those curious, the maximum area is centimeters-squared.

### Velocity in Different Regions

edit*Fermat's Principle of Least Time*, travels in the fastest time over the least amount of distance (i.e. a light ray travels the path that results in the least amount of time wasted). The speed of a light wave is defined as the speed of light to the refractive index of the material traveled, or . Let a light wave travel through two materials, starting at and ending at where . The angle of incidence and refraction is given on the diagram to the right. What is the relationship between the light ray traveling through the two different materials?

This does not seem like an optimization problem. In fact, it seems that trying to make this into an optimization problem would be unintuitive. However, this beautiful result in physics is but a clever discovery found by making this into an optimization problem.

Let us write what we know:

- The distance between the point of incidence and the change in the material is (The diagram has an italicized capital upsilon).
- The distance that minimizes the travel time the most is (The diagram has an italicized capital lambda). This means the remaining horizontal distance, according to the diagram, is .
- The distance between the change in materials and the end of the refractive material is (The diagram has an italicized capital gamma).

All that is left to do is put it all together. We want to find the distance that light travelled.

- The distance travelled by the incident ray is .
- The distance travelled by the refractive ray is .

Let us review what we know. We are trying to manipulate so that the time travelled is as small as possible to reflect and model how light ravels through two different materials. Everything else that is not a function of is a constant. Since we are trying to model the amount of time it takes light to travel through two different materials, we should manipulate the distances so that it models time.

Recall that speed is a ratio between distance and time , so to model the amount of time light took to travel with the given distances, all it means is some rearrangements. Because light travelled through two different materials, the speeds are different. Let where is the speed of light traveling through the first material of index of refraction (and similar for ).

The time light took to travel through the two materials is given as a function of , so

We now finally have an optimization problem. We want to minimize the amount of time travelled. Set the first derivative of equal to zero. Remember, everything else besides is a constant.

Recall what we are trying to solve for. We are not trying to solve for ; we are trying to model the situation. If we did have to solve for , it would be a nightmare (we may even leave it as a non-trivial exercise for the reader), but nevertheless, we can begin modeling the situation. First, move the negative term to the other side:

The next thing we should attempt to do is rewrite the expression so that we clean-up those fractions (they are intimidating after all, and it would not be practical to model).

We can use the trigonometric functions to help us here in this department. Because the trigonometric functions are simply relations of the ratio of a right triangle, this would be a very good solution.

The *normal* is defined as the line perpendicular a given "surface". Because the distance is parallel to the normal, the angle generated by that is also . Because the horizontal distance light travelled is parallel to the "surface," the incident angle of the light, , is an angle between the distance and the incident light vector , and the light vector is a transversal, by the corresponding angles theorem, the angle between the distance and the incident light vector is also (see the upper-left corner of the diagram for reference).

The result of this geometric derivation is simply this: we have found an angle of part of a right triangle. As a result, we can write the distance as a trigonometric equivalent

We can use similar logic to show that

As a result, we can rewrite the equations involved into something much more manageable and easy to calculate without measuring ratios:

We are technically not done with the problem. Although we may have related the two different light vectors, we did not model the situation in terms of index of refractions. This leaves us with the two final steps. Recall the speed of light going through a certain material of index of refraction is . This is equivalent to saying . Since the speeds relate to the index of refraction, we may rewrite the above equation as

Multiply both sides by and we finally found *Snell's Law*:

Keep in mind, this result is still a derivative. However, we are allowed to model real life scenarios in terms of differential equations. Sometimes, it may be impossible to model situations without differential equations. We are allowed to write our equation like this (physics certainly does not care here). Finally, although this is not *strictly* an optimization problem, thinking about in that sense allowed us to obtain a nice rule of the world (a *law* in science). We proved this behavior, so it seems light will be consistent according to this equation. This in effect has allowed us to confirm in 2003 that negative index of refraction exists (even through experimental observations)^{[1]} and allowed us to discover properties of spin waves^{[2]}.

## References

edit- ↑ Houck, A. A., Brock, J. B., & Chuang, I. L. (2003). Experimental observations of a left-handed material that obeys Snell’s law.
*Physical Review Letters*,*90*(13), 137401. Retrieved 25 July 2020 from http://feynman.mit.edu/ike/homepage/papers/METAMAT-houck-brock-chuang-experimental-observations-of-a-left-handed-material-that-obeys-snells-law-prl-v90-p137401-04apr03.pdf. - ↑ Stigloher, J., Decker, M., Körner, H. S., Tanabe, K., Moriyama, T., Taniguchi, T., ... & Ono, T. (2016). Snell’s law for spin waves.
*Physical review letters*,*117*(3), 037204. Retrieve 22 July 2020 from https://arxiv.org/pdf/1606.02895.pdf.