Update optimization.qmd

some typos.
This commit is contained in:
Fang Liu 2023-04-29 15:38:52 +08:00
parent f4d42fd4c6
commit 235f224f7a

View File

@ -278,7 +278,7 @@ This value is the lone critical point, and in this case gives the position of th
### Using `argmax` to identify where a function is maximized ### Using `argmax` to identify where a function is maximized
This value that maximizes a function is sometimes referred to as the *argmax*, or argument which maximizes the function. In `Julia` the `argmax(f,domain)` function is defined to "Return a value $x$ in the domain of $f$ for which $f(x)$ is maximized. If there are multiple maximal values for $f(x)$ then the first one will be found." The domain is some iterable collection. In the mathematical world this would be an interval $[a,b]$, but on the computer it is an approximation, such as is returned by `range` below. Without out having to take a derivative, as above, but sacrificing some accuracy, the task of identifying `x` for where `A` is maximum, could be done with This value that maximizes a function is sometimes referred to as the *argmax*, or argument which maximizes the function. In `Julia` the `argmax(f,domain)` function is defined to "Return a value $x$ in the domain of $f$ for which $f(x)$ is maximized. If there are multiple maximal values for $f(x)$ then the first one will be found." The domain is some iterable collection. In the mathematical world this would be an interval $[a,b]$, but on the computer it is an approximation, such as is returned by `range` below. Without having to take a derivative, as above, but sacrificing some accuracy, the task of identifying `x` for where `A` is maximum, could be done with
```{julia} ```{julia}
@ -445,10 +445,10 @@ Ethan Hunt, a top secret spy, has a mission to chase a bad guy. Here is what we
* He can drive a car - usually some concept car by BMW - at $30$ miles per hour, but only on the road. * He can drive a car - usually some concept car by BMW - at $30$ miles per hour, but only on the road.
For his mission, he needs to go $10$ miles west and $5$ `miles north. He can do this by: For his mission, he needs to go $10$ miles west and $5$ miles north. He can do this by:
* just driving $8.310$ miles west then $5$ miles north, or * just driving $10$ miles west then $5$ miles north, or
* just running the diagonal distance, or * just running the diagonal distance, or
* driving $0 < x < 10$ miles west, then running on the diagonal * driving $0 < x < 10$ miles west, then running on the diagonal
@ -846,7 +846,7 @@ Is there "symmetry" in the answer between $x$ and $y$?
yesnoq("no") yesnoq("no")
``` ```
What is you were do do two pens like this back to back, then the answer would involve a rectangle. Is there symmetry in the answer now? What is you were to do two pens like this back to back, then the answer would involve a rectangle. Is there symmetry in the answer now?
```{julia} ```{julia}
@ -969,7 +969,7 @@ diff(SA, x, x)(xx) > 0
radioq(( radioq((
"This applies the second derivative test to the lone *real* critical point showing there is a local minimum at that point.", "This applies the second derivative test to the lone *real* critical point showing there is a local minimum at that point.",
"This applies the first derivative test to the lone *real* critical point showing there is a local minimum at that point.", "This applies the first derivative test to the lone *real* critical point showing there is a local minimum at that point.",
"This finds the ``4`th derivative of `SA`" "This finds the `4`th derivative of `SA`"
), 1) ), 1)
``` ```
@ -1004,7 +1004,7 @@ numericq(val, 1e-3)
###### Question Non-Norman windows ###### Question Non-Norman windows
Suppose our new "Norman" window has half circular tops at the top and bottom? If the perimeter is fixed at $20$ and the dimensions of the rectangle are $x$ for the width and $y$ for the height. Suppose our new "Norman" window has half circular tops at the top and bottom. If the perimeter is fixed at $20$ and the dimensions of the rectangle are $x$ for the width and $y$ for the height.
What is the value of $y$ that maximizes the area? What is the value of $y$ that maximizes the area?
@ -1091,7 +1091,7 @@ We approach this using `SymPy` and $n=10$
```{julia} ```{julia}
#| hold: true #| hold: true
#| eval: false #| eval: false
@syms s xs[1:10] @syms x xs[1:10]
s(x) = sum((x-xi)^2 for xi in xs) s(x) = sum((x-xi)^2 for xi in xs)
cps = solve(diff(s(x), x), x) cps = solve(diff(s(x), x), x)
``` ```
@ -1274,7 +1274,7 @@ choices = ["exactly four times",
L"exactly $\pi$ times", L"exactly $\pi$ times",
L"about $2.6$ times as big", L"about $2.6$ times as big",
"about the same"] "about the same"]
answ = 1 answ = 3
radioq(choices, answ) radioq(choices, answ)
``` ```
@ -1390,7 +1390,7 @@ choices = ["It finds the critical points",
radioq(choices, 1) radioq(choices, 1)
``` ```
The polynomial `nu` is what degree in `p`? The polynomial `eq` is what degree in `p`?
```{julia} ```{julia}
@ -1399,7 +1399,7 @@ The polynomial `nu` is what degree in `p`?
numericq(4) numericq(4)
``` ```
The only positive real solution for $p$ from $nu$ is The only positive real solution for $p$ from $eq$ is
```{julia} ```{julia}
@ -1420,7 +1420,8 @@ In [Hall](https://www.maa.org/sites/default/files/hall03010308158.pdf) we can fi
```{julia} ```{julia}
#| hold: true, echo #| hold: true
#| echo: false
p = plot(; legend=false, aspect_ratio=:equal, axis=nothing, border=:none) p = plot(; legend=false, aspect_ratio=:equal, axis=nothing, border=:none)
b = 2. b = 2.
plot!(p, x -> x^2, -b, b) plot!(p, x -> x^2, -b, b)
@ -1471,7 +1472,7 @@ numericq(a)
Numerically find the value of $a$ that minimizes the length of the line seqment $PQ$. Numerically find the value of $a$ that minimizes the length of the line seqment $PQ$.
```{juila} ```{julia}
#| hold: true #| hold: true
#| echo: false #| echo: false
x(a) = -a - 1/(2a) x(a) = -a - 1/(2a)