# Calculus/Optimization
## Introduction

Optimization 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

These 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
### Volume Example

* Write out known formulas and information
    $A_{base}=x^{2}$
    $A_{side}=x\cdot h$
    $A_{total}=2x^{2}+4x\cdot h=100$
    $V=l\cdot w\cdot h=x^{2}\cdot h$
* Write the variable $h$ in terms of $x$ in the volume equation.
    $2x^{2}+4xh=100$
    $x^{2}+2xh=50$
    $2xh=50-x^{2}$
    $h={\frac {50-x^{2}}{2x}}$
    ${\begin{aligned}V&=\left(x^{2}\right)\left({\frac {50-x^{2}}{2x}}\right)\\&={\frac {50x-x^{3}}{2}}\end{aligned}}$
* Find the derivative of the volume equation in order to maximize the volume
    ${\frac {dV}{dx}}={\frac {50-3x^{2}}{2}}$
* Set ${\frac {dV}{dx}}=0$ and solve for $x$
    ${\frac {50-3x^{2}}{2}}=0$
    $50-3x^{2}=0$
    $3x^{2}=50$
    $x=\pm {\frac {\sqrt {50}}{\sqrt {3}}}$
* Plug-in the $x$ value into the volume equation and simplify
    ${\begin{aligned}V&={\frac {1}{2}}\left[50{\sqrt {\frac {50}{3}}}-\left({\sqrt {\frac {50}{3}}}\right)^{3}\right]\\&=68.04138174...\end{aligned}}$
$V_{max}=68.04138174...$

### Volume Example II

$\alpha$
If we call the side length of the cut-out squares $x$, then each side of the base of the folded box is $\alpha -2x$, and the height is $x$. Therefore, the volume function is $V(x)=x(\alpha -2x)^{2}=x(\alpha ^{2}-4\alpha x+4x^{2})=\alpha ^{2}x-4\alpha x^{2}+4x^{3}$. We must optimize the volume by taking the derivative of the volume function and setting it equal to 0. Since it does not change, $\alpha$ is treated as a constant, not a variable.
    $V(x)=\alpha ^{2}x-4\alpha x^{2}+4x^{3}$
    ${\begin{aligned}0&=V'(x)=\alpha ^{2}-8\alpha x+12x^{2}\\&=12x^{2}-8\alpha x+\alpha ^{2}\end{aligned}}$
We can now use the quadratic formula to solve for $x$:
    $x={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}$
    ${\begin{aligned}x&={\frac {-(-8\alpha )\pm {\sqrt {(-8\alpha )^{2}-4(12)(\alpha ^{2})}}}{2(12)}}\\&={\frac {8\alpha \pm {\sqrt {64\alpha ^{2}-48\alpha ^{2}}}}{24}}\\&={\frac {8\alpha \pm {\sqrt {16\alpha ^{2}}}}{24}}\\&={\frac {8\alpha \pm 4\alpha }{24}}\end{aligned}}$
    $x={\frac {\alpha }{6}},{\frac {\alpha }{2}}$
We reject $x={\frac {\alpha }{2}}$, since it is a minimum (it results in the base length $\alpha -2x$ being 0, making the volume 0).
$x={\frac {\alpha }{6}}$

### Volume Example III

$1.024{\text{ L}}$
This 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: $1{\text{ L}}=1000{\text{ cm}}^{3}$. This means that through dimensional analysis (or basic algebra): $1.024{\text{ L}}=1024{\text{ cm}}^{3}$. Recall that this is the volume!
* Volume of a cylinder: $V=\pi r^{2}h$
* Surface area of a cylinder: $S=2\pi rh+2\pi r^{2}$
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 $h$ in terms of $r$:
    $1024{\text{ cm}}^{3}=\pi r^{2}h$
    $\Rightarrow {\frac {1024{\text{ cm}}^{3}}{\pi {r{\text{ cm}}}^{2}}}={\frac {1024}{\pi r^{2}}}{\text{ cm}}=h$
We can the substitute this information into the surface area formula and minimize (set the first derivative to zero):
    $S(r)=2\pi r\left({\frac {1024}{\pi r^{2}}}\right)+2\pi r^{2}$. Eliminate the $\pi$ and $r$.
    $\Rightarrow S(r)=2\cdot {\frac {1024}{r}}+2\pi r^{2}$ Set the first derivative equal to zero.
    ${\begin{aligned}\Rightarrow 0=S'(r)&={\frac {d}{dr}}\left({\frac {2048}{r}}+2\pi r^{2}\right)\\&={\frac {d}{dr}}\left({\frac {2048}{r}}\right)+{\frac {d}{dr}}\left(2\pi r^{2}\right)\\&={\frac {d}{dr}}\left(2048\cdot {r}^{-1}\right)+2\pi {\frac {d}{dr}}\left(r^{2}\right)\\&=2048\cdot {\frac {d}{dr}}\left({r}^{-1}\right)+2\pi \left(2r\right)\\&=2048\cdot (-1){r}^{-2}+4\pi r\\&=-{\frac {2048}{{r}^{2}}}+4\pi r\\&={\frac {4\pi r^{3}-2048}{{r}^{2}}}\end{aligned}}$
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 $r$ make the denominator equal to zero. Here is the operation for the numerator:
    $4\pi r^{3}-2048=0$
    $\Leftrightarrow 4\pi r^{3}=2048$
    $\Leftrightarrow r^{3}={\frac {2048}{4\pi }}={\frac {512}{\pi }}$
    $\Leftrightarrow r={\sqrt[{3}]{\frac {512}{\pi }}}={\frac {8}{\sqrt[{3}]{\pi }}}\approx 5.4623$
Here is the operation for the denominator:
    ${r}^{2}=0$
    $r=\pm 0$
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 $S(r)$. Nevertheless, our final answer may not necessarily be $r\approx 5.4623{\text{ cm}}$ and $h\approx 10.9245{\text{ cm}}$. We need to verify that the critical value we found is the correct answer. That is where we substitute values for $r\in \left(0,\,{\frac {8}{\sqrt[{3}]{\pi }}}\right)$ and $r\in \left({\frac {8}{\sqrt[{3}]{\pi }}},\,\infty \right)$ into the first derivative:
    For $r\in \left(0,\,{\frac {8}{\sqrt[{3}]{\pi }}}\right)$, let $r=5$: $S'(5)={\frac {4\pi (5)^{3}-2048}{(5)^{2}}}<0$. For $r\in \left({\frac {8}{\sqrt[{3}]{\pi }}},\,\infty \right)$, let $r=6$: $S'(6)={\frac {4\pi (6)^{3}-2048}{(6)^{2}}}>0$.
Based on these results above, it is clear that $r={\frac {8}{\sqrt[{3}]{\pi }}}$ 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:
$5.4623{\text{ cm}}$
$10.9245{\text{ cm}}$

### Sales Example

$n$
$r(n)=8.1n$
$c(n)=n^{3}-7n^{2}+18n$
The retailer's profit is defined by the equation $p(n)=r(n)-c(n)$, 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, $p(n)$. By using the subtraction rule $p'(n)=r'(n)-c'(n)$:
    $p(n)=r(n)-c(n)$
    $p'(n)={\frac {d}{dn}}[8.1n]-{\frac {d}{dn}}\left[n^{3}-7n^{2}+18n\right]=-3n^{2}+14n-9.9$
Therefore, when $-3n^{2}+14n-9.9=0$ the profit will be maximized or minimized. Use the quadratic formula to find the roots, giving $n=0.869,3.798$. To find which of these is the maximum and minimum the function can be tested:
    $p(0.869)=-3.97321,p(3.798)=8.58802$
Because we only consider the functions for all $n\geq 0$ (i.e., you can't have $n=-5$ units), the only points that can be minima or maxima are those two listed above. To show that $3.798$ is in fact a maximum (and that the function doesn't remain constant past this point) check if the sign of $p'(n)$ changes at this point.
Here, it does, and for $n$ greater than $3.798$, $P'(n)$ will continue to decrease. This demonstrates that the firm will be maximizing its profits at $n=3.798$. The retailer selling $3.798$ units would return a profit of $$8,588.02$.
$n=3.798$

### Revenue Example

$D(q)=-{\frac {1}{5}}q+10$
$q$
The revenue of a firm is calculated by multiplying the quantity sold to the price. Since $D(q)$ is the price, and $q$ is the quantity sold, $R(q)=q\cdot D(q)$. 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 $q$:
    ${\begin{aligned}R(q)&=q\cdot D(q)\\&=q\cdot \left(-{\frac {1}{5}}q+10\right)\\&=-{\frac {1}{5}}q^{2}+10q\end{aligned}}$
Let us now take the first derivative:
    ${\frac {d}{dq}}\left[R(q)\right]={\frac {d}{dq}}\left[-{\frac {1}{5}}q^{2}+10q\right]$
    ${\begin{aligned}R'(q)&={\frac {d}{dq}}\left[-{\frac {1}{5}}q^{2}\right]+{\frac {d}{dq}}\left[10q\right]\\&=-{\frac {1}{5}}{\frac {d}{dq}}\left[q^{2}\right]+10{\frac {d}{dq}}\left[q\right]\\&=-{\frac {1}{5}}\left[2q\right]+10\left[1\right]\\&=-{\frac {2}{5}}q+10\end{aligned}}$
Set the first derivative equal to zero to find the critical values:
    $R'(q)=0=-{\frac {2}{5}}q+10$
    $\Leftrightarrow -10=-{\frac {2}{5}}q$
    $\Leftrightarrow 25=q$
Take note of the original revenue function. Because the revenue function is a quadratic that has its $q^{2}$ 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 $q<25$, $R'(q)>0$. For any $q>25$, $R'(q)<0$. Therefore, the critical value $q=25$ 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:
    ${\begin{aligned}D(25)&=-{\frac {1}{5}}(25)+10\\&=-5+10\\&=5\end{aligned}}$
$5$

### Distance of Function to Origin

$f(x)={\sqrt {4-x}}$
$xy$
Let us write all the relevant equations we might want to keep in mind:
* $D={\sqrt {\left(x_{2}-x_{1}\right)^{2}+\left(y_{2}-y_{1}\right)^{2}}}$
* $y=f(x)$
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 $(x,y)$ and minimize the distance required to reach the origin. This means we let $\left(x_{2},y_{2}\right)=(x,y)$. Recall that the origin is at $(0,0)$, so $\left(x_{1},y_{1}\right)=(0,0)$. With all the information we have here, let us go ahead and write the distance function in terms of $x$ the singular variable. Because $y=f(x)$:
    ${\begin{aligned}D(x)&={\sqrt {\left(x-0\right)^{2}+\left(f(x)-0\right)^{2}}}\\&={\sqrt {x^{2}+\left({\sqrt {4-x}}\right)^{2}}}\\&={\sqrt {x^{2}+4-x}}\\&={\sqrt {x^{2}-x+4}}\end{aligned}}$
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

    $D(x)={\sqrt {x^{2}-x+4}}$
    $\Rightarrow {\frac {d}{dx}}\left[D(x)\right]={\frac {d}{dx}}\left({\sqrt {x^{2}-x+4}}\right)$
    ${\begin{aligned}\Rightarrow D'(x)&={\frac {d}{dx}}\left({\sqrt {x^{2}-x+4}}\right)&\left({\text{Recall the chain rule: }}{\frac {d}{dx}}\left[f\left(g(x)\right)\right]={\frac {df}{dg}}\cdot {\frac {dg}{dx}}\right)\\&={\frac {d}{dx}}\left(x^{2}-x+4\right)\cdot {\frac {df}{dg}}\left({\sqrt {x^{2}-x+4}}\right)\\&=\left(2x-1\right)\cdot {\frac {1}{2{\sqrt {x^{2}-x+4}}}}\\&={\frac {2x-1}{2{\sqrt {x^{2}-x+4}}}}\end{aligned}}$
We now have the first derivative of the distance formula. To minimize the distance between $(x,y)$ and the origin, set the first derivate equal to zero. By now, you should know why we have to do this:
    Let $D'(x)=0$.
       ${\frac {2x-1}{2{\sqrt {x^{2}-x+4}}}}=0$ implies the numerator is zero. As such:
    Let $2x-1=0$.
       $2x-1=0$
       $\Leftrightarrow 2x=1$
       $\Leftrightarrow x={\frac {1}{2}}$
    Recall that if the denominator can be set equal to zero, then the value for $x$ which makes that true is a critical value. As such, let $2{\sqrt {x^{2}-x+4}}=0$:
       $2{\sqrt {x^{2}-x+4}}=0$
       $\Rightarrow {\sqrt {x^{2}-x+4}}=0$
       $\Rightarrow x^{2}-x+4=0$
    There is no real value for $x$ which makes the above equation true. This can be shown using the determinant is less than zero: $b^{2}-4ac<0$. As such,
The only critical value is $x={\frac {1}{2}}$. By now, you should be saying that we need to use the first derivative test:
    For any $x<{\frac {1}{2}}$, $D'(x)<0$. For any $x>{\frac {1}{2}}$, $D'(x)>0$. 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 $x$-value that will minimize the distance between $(x,y)$ and the origin is $x={\frac {1}{2}}$.
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 $f(x)$:
    ${\begin{aligned}f\left({\frac {1}{2}}\right)&={\sqrt {4-\left({\frac {1}{2}}\right)}}\\&={\sqrt {{\frac {8}{2}}-{\frac {1}{2}}}}\\&={\sqrt {\frac {7}{2}}}\end{aligned}}$
Most teachers in calculus classes don't mind if you leave the answer as $\left({\frac {1}{2}},{\sqrt {\frac {7}{2}}}\right)$. However, for the minuscule number of teachers or testing organizations that care about rationalizing the denominator, the work for ${\sqrt {\frac {7}{2}}}$ is done below:
    ${\begin{aligned}{\sqrt {\frac {7}{2}}}&={\frac {\sqrt {7}}{\sqrt {2}}}\\&={\frac {\sqrt {7}}{\sqrt {2}}}\cdot {\frac {\sqrt {2}}{\sqrt {2}}}\\&={\frac {{\sqrt {7}}\cdot {\sqrt {2}}}{2}}\\&={\frac {\sqrt {14}}{2}}\\\end{aligned}}$
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:
$\left({\frac {1}{2}},{\frac {\sqrt {14}}{2}}\right)$
$\blacksquare$

#### Non-standard way: implicit differentiation

Only the implicit differentiation will be shown, since any calculations beyond that would result in the same procedures we outlined before. Recall $D(x)={\sqrt {x^{2}-x+4}}$. Square both sides to return the function seen below:
    $\left[D(x)\right]^{2}=x^{2}-x+4$
Taking the derivative of the above function with respect to $x$ will require us to implicitly differentiate (although this differentiation is neatly disguised). The calculations are demonstrated below:
    ${\frac {d}{dx}}\left[\left(D(x)\right)^{2}\right]={\frac {d}{dx}}\left(x^{2}-x+4\right)$
    ${\begin{aligned}\Rightarrow 2D(x){\frac {dD}{dx}}&={\frac {d}{dx}}\left(x^{2}\right)-{\frac {d}{dx}}\left(x\right)+{\frac {d}{dx}}\left(4\right)\\&=2x-1+0\\\end{aligned}}$
    $2D(x){\frac {dD}{dx}}=2x-1$
    ${\begin{aligned}\Leftrightarrow {\frac {dD}{dx}}&={\frac {2x-1}{2D(x)}}\\&={\frac {2x-1}{2{\sqrt {x^{2}-x+4}}}}\end{aligned}}$
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

$f(x)=15\log(x)$
$100$
This 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 $x$ be the distance from the left-hand side of the shelving unit, and let the height of the rectangle formed be $y=f(x)$. Such a construction means that $(100-x)$ is the length of the rectangle while the height is $15\log(x)$. Therefore, the area function is
    $A(x)=15(100-x)\log(x)$
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:
    $A(x)=15(100-x)\log(x)$
    $\Rightarrow {\frac {d}{dx}}\left[A(x)\right]={\frac {d}{dx}}\left[15(100-x)\log(x)\right]$
    ${\begin{aligned}\Rightarrow A'(x)&=15{\frac {d}{dx}}\left((100-x)\log(x)\right)&\left({\text{Recall the product rule: }}{\frac {d}{dx}}\left[f(x)\cdot g(x)\right]=f\cdot {\frac {dg}{dx}}+g\cdot {\frac {df}{dx}}\right)\\&=15\left[(100-x)\cdot {\frac {d}{dx}}\left(\log(x)\right)+\log(x)\cdot {\frac {d}{dx}}\left(100-x\right)\right]\\&=15\left[{\frac {100-x}{x\ln(10)}}-\log(x)\right]\\&=15\left[{\frac {100-x}{x\ln(10)}}-{\frac {\ln(x)}{\ln(10)}}\right]&\left({\text{Multiply by }}{\frac {x}{x}}{\text{ to the right fraction.}}\right)\\&=15\left[{\frac {100-x}{x\ln(10)}}-{\frac {x\ln(x)}{x\ln(10)}}\right]\\&=15\left[{\frac {100-x-x\ln(x)}{x\ln(10)}}\right]=0\\\end{aligned}}$
However, after finding the first derivative, it is evident that finding the value for $x$ 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 $x\approx 23.94721$ or an exact answer of $x=e^{W(100e)-1}$. We know this is also the maximum that we are looking for because the derivative function is positive for $x<23.94721$ but negative after it. For those curious, the maximum area is $1573.44277$ centimeters-squared.
$x\approx 23.94721$

### Velocity in Different Regions

$v={\frac {c}{n}}$
$n_{1}$
$n_{2}$
$n_{1}<n_{2}$
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 $\Upsilon$ (The diagram has an italicized capital upsilon).
* The distance that minimizes the travel time the most is $\Lambda$ (The diagram has an italicized capital lambda). This means the remaining horizontal distance, according to the diagram, is $d-\Lambda$.
* The distance between the change in materials and the end of the refractive material is $\Gamma$ (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 ${\sqrt {(\Lambda )^{2}+(\Upsilon )^{2}}}$.
* The distance travelled by the refractive ray is ${\sqrt {(d-\Lambda )^{2}+(\Gamma )^{2}}}$.
Let us review what we know. We are trying to manipulate $\Lambda$ 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 $\Lambda$ 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 $\left(v={\frac {D}{\Delta t}}\right)$, 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 $v_{1}>v_{2}$ where $v_{1}$ is the speed of light traveling through the first material of index of refraction $n_{1}$ (and similar for $v_{2}$).
* $t_{1}={\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}$
* $t_{2}={\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}$
The time light took to travel through the two materials is given as a function of $\Lambda$, so
* $T(\Lambda )=t_{1}+t_{2}={\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}+{\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}$
We now finally have an optimization problem. We want to minimize the amount of time travelled. Set the first derivative of $T(\Lambda )$ equal to zero. Remember, everything else besides $\Lambda$ is a constant.
    $T(\Lambda )={\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}+{\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}$
    ${\frac {d}{d\Lambda }}\left[T(\Lambda )\right]={\frac {d}{d\Lambda }}\left({\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}+{\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}\right)$
    ${\begin{aligned}0=T'(\Lambda )&={\frac {d}{d\Lambda }}\left({\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}+{\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}\right)\\&={\frac {d}{d\Lambda }}\left({\frac {\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}{v_{1}}}\right)+{\frac {d}{d\Lambda }}\left({\frac {\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}{v_{2}}}\right)\\&={\frac {1}{v_{1}}}\cdot {\frac {d}{d\Lambda }}\left({\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}\right)+{\frac {1}{v_{2}}}\cdot {\frac {d}{d\Lambda }}\left({\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}\right)\\&={\frac {1}{v_{1}}}\cdot \left({\frac {2\Lambda }{2{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}}\right)+{\frac {1}{v_{2}}}\cdot \left({\frac {2(d-\Lambda )\cdot (-1)}{2{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}}\right)\\&={\frac {1}{v_{1}}}\cdot \left({\frac {\Lambda }{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}\right)-{\frac {1}{v_{2}}}\cdot \left({\frac {d-\Lambda }{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}\right)\end{aligned}}$
Recall what we are trying to solve for. We are not trying to solve for $\Lambda$; we are trying to model the situation. If we did have to solve for $\Lambda$, 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:
    ${\frac {1}{v_{1}}}\cdot \left({\frac {\Lambda }{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}\right)-{\frac {1}{v_{2}}}\cdot \left({\frac {d-\Lambda }{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}\right)=0$
    ${\frac {1}{v_{1}}}\cdot \left({\frac {\Lambda }{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}\right)={\frac {1}{v_{2}}}\cdot \left({\frac {d-\Lambda }{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}\right)$
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 $\Upsilon$ is parallel to the normal, the angle generated by that is also $90^{\circ }$. Because the horizontal distance $d$ light travelled is parallel to the "surface," the incident angle of the light, $\theta _{1}$, is an angle between the distance $\Upsilon$ and the incident light vector $\mathbf {I}$, and the light vector $\mathbf {I}$ is a transversal, by the corresponding angles theorem, the angle between the distance $\Upsilon$ and the incident light vector $\mathbf {I}$ is also $\theta _{1}$ (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
* $\sin(\theta _{1})={\frac {\Lambda }{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}$
We can use similar logic to show that
* $\sin(\theta _{2})={\frac {d-\Lambda }{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}$
As a result, we can rewrite the equations involved into something much more manageable and easy to calculate without measuring ratios:
    ${\frac {1}{v_{1}}}\cdot \left({\frac {\Lambda }{\sqrt {\Lambda ^{2}+\Upsilon ^{2}}}}\right)={\frac {1}{v_{2}}}\cdot \left({\frac {d-\Lambda }{\sqrt {(d-\Lambda )^{2}+\Gamma ^{2}}}}\right)$
    $\Leftrightarrow {\frac {1}{v_{1}}}\cdot \sin(\theta _{1})={\frac {1}{v_{2}}}\sin(\theta _{2})$
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 $n$ is $v={\frac {c}{n}}$. This is equivalent to saying ${\frac {1}{v}}={\frac {n}{c}}$. Since the speeds relate to the index of refraction, we may rewrite the above equation as
    ${\frac {n_{1}\cdot \sin(\theta _{1})}{c}}={\frac {n_{2}\cdot \sin(\theta _{2})}{c}}$
Multiply both sides by $c$ and we finally found Snell's Law:
$n_{1}\sin(\theta _{1})=n_{2}\sin(\theta _{2})$
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) and allowed us to discover properties of spin waves.

## References

* ↑ 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.
This page or section of Calculus is a stub. You can help Wikibooks by expanding it.
Navigation:
Main Page · Precalculus · Limits · Differentiation · Integration · Parametric and Polar Equations · Sequences and Series · Multivariable Calculus · Extensions · References