-
Notifications
You must be signed in to change notification settings - Fork 0
/
13-optimisation.qmd
116 lines (80 loc) · 4.4 KB
/
13-optimisation.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Optimisation
One application of differentiation is to find where functions have their maximum and minimum values. This is useful since many real life systems can often be modeled by functions, and the maximum and minimum values of these functions correspond to some kind of optimisation. For example:
* optimise profits by finding a maximum
* optimise a journey cost by finding minimum fuel use
If a situation can be defined with a function, differentiation can be used to help optomise it.
## Turning points on a curve
Maximum and minimum values of a function happen at turning points on a graph. At a turning point on a graph the gradient is zero. These turning points are also call critical points.
```{r, echo=FALSE}
knitr::include_url("https://www.desmos.com/calculator/yge6iy1mwg?embed")
```
Notice two things:
* the gradient will change depending on which value of $x$. The slope fo the tangent shows you this.
* maximums and minimums aren't actually the biggest or smallest value the function can give!
There are two types of Maxima (plural of maximum) and minima (plural of minimum). They can be either global, for the whole function, or local, for just particular region. Most problems are constrained within bounds and so interested in the local maxima and minima along with what happens at the boundary of any constraint.
## Classifying critical points
Critical points can be found by looking at the values of $f'(x)$ and $f''(x)$. The graph below shows $f(x)$, $f'(x)$ and $f''(x)$ all plotted on the same axes. As you move the point notice how when $f(x)$ is at it's maximum, $f'(x) = 0$ and $f''(x) < 0$. The three different lines are as follows: $f(x)$ is solid red, $f'(x)$ is dashed blue and $f''(x)$ is dotty and green. There is a lot going on in the graph below but it's worth taking some time to play with the points to see what is going on.
```{r, echo=FALSE}
knitr::include_url("https://www.desmos.com/calculator/ybaguwnu8g?embed")
```
We can summarise this in a table:
:::{.callout-note}
| critical point | $f(x)$ | $f'(x)$ | $f''(x)$ |
|:--:|:--:|:--:|:--:|
| minimum | smallest value | $0$ | $f''(x) > 0$ |
| maximum | largest value | $0$ | $f''(x) < 0$ |
:::
We can use this information to classify critical points. For example let's find and classify the critical points of:
$$
y=2x^3 - 4^2 + 2
$$
First we need to find the points where $\frac{dy}{dx} = 0$ (remember $f'(x)$ and $\frac{dy}{dx}$ mean the same thing). So differentiating $y=2x^3 - 4^2 + 2$ we have:
$$
\frac{dy}{dx} = 6x^2 -8x
$$
Setting $\frac{dy}{dx} = 0$ and solving we have:
$$
\begin{aligned} \frac{dy}{dx} &= 6x^2 -8x \\
0 &= 6x^2 -8x \\
&= 2x(3x-4)
\end{aligned}
$$
Now either $2x=0$ or $3x-4 =0$. Solving these two equations we get that $x$ is equal to either to $0$ or $\frac{4}{3}$.
Try this question on classifying critical points.
```{r, echo=FALSE}
knitr::include_url("https://numbas.mathcentre.ac.uk/question/67953/differentiation-stationary-points-and-their-nature-1/embed/", height="500px")
```
## Finding gradient at a point
The rule for differentiating polynomials (functions made up of adding different powers of $x$)is:
:::{.callout-note}
* if $y=ax^n$ then $\frac{dy}{dx} = anx^{n-1}$, or,
* if $f(x)=ax^n$ then $f'(x) = anx^{n-1}$
**Times by the power, then take one off the power**
:::
Here are some examples:
If $y = 3x^4$ then $\frac{dy}{dx} = 3 \times 4 \times x^{4-1} = 12x^3$
Multiple terms added together are differentiated one by one then added together:
$$
\begin{aligned} y &= 6x^3 + 2x^2 + 4x + 5 \\
\frac{dy}{dx} &= 6x^3 + 2x^2 + 4x^1 + 5x^0 \\
&= 3\times6x^{3-1} + 2\times x^{2-1} + 1\times 4x^{1-1} + 0\times5x^{0-1} \\
&= 18x^2 + 2x^1 + 4x^{0} + 0 \\
&= 18x^2 + 2x + 4
\end{aligned}
$$
In the above example we've used the following mathematical facts:
* $x=x^1$, $x$ on it's own is $x^1$
* $x^0=1$, you can always multiply by $x^0$ since it's $1$
* $0 \times a = 0$ anything times zero is zero
The take away from this is that constant terms, terms without $x$ in, disappear, and terms with just $x$ in loose the $x$.
To find the gradient at a point. Differentiate the original function and then substitute the $x$ value of the point into the derivative.
For example to find the gradient when $x=3$ for the function $y=x^2$. We would differentiate and then substitute in $x=3$.
$$
\begin{aligned} y &= x^2 \\
\frac{dy}{dx} &= 2x \\
&= 2(3) \\
&= 2 \times 3 \\
&= 6
\end{aligned}
$$
So the gradient at $x=3$ on the curve $y=x^2$ is $6$.