Merge branch 'main' into v0.16

This commit is contained in:
jverzani 2023-05-07 19:39:25 -04:00
commit a4d9023caf

View File

@ -84,7 +84,7 @@ implicit_plot(f; xlims=(-3,3), ylims=(-3,3), legend=false)
## Tangent lines, implicit differentiation
The graph $x^2 + y^2 = 1$ has well-defined tangent lines at all points except $(-1,0)$ and $(0, 1)$ and even at these two points, we could call the vertical lines $x=-1$ and $x=1$ tangent lines. However, to recover the slope of these tangent lines would need us to express $y$ as a function of $x$ and then differentiate that function. Of course, in this example, we would need two functions: $f(x) = \sqrt{1-x^2}$ and $g(x) = - \sqrt{1-x^2}$ to do this completely.
The graph $x^2 + y^2 = 1$ has well-defined tangent lines at all points except $(-1,0)$ and $(1, 0)$ and even at these two points, we could call the vertical lines $x=-1$ and $x=1$ tangent lines. However, to recover the slope of these tangent lines would need us to express $y$ as a function of $x$ and then differentiate that function. Of course, in this example, we would need two functions: $f(x) = \sqrt{1-x^2}$ and $g(x) = - \sqrt{1-x^2}$ to do this completely.
In general though, we may not be able to solve for $y$ in terms of $x$. What then?
@ -232,7 +232,7 @@ In this example we mix notations using $g'(x)$ to represent a derivative of $g$
Let's see how to add a graph of a tangent line to the graph of an equation. Tangent lines are tangent at a point, so we need a point to discuss.
Returning to the equation for a circle, $x^2 + y^2 = 1$, let's look at $(\sqrt{2}/2, - \sqrt{2}/2)$. The derivative is $-y/x$, so the slope at this point is $1$. The line itself has equation $y = b + m \cdot (x-a)$. The following represents this in `Julia`:
Returning to the equation for a circle, $x^2 + y^2 = 1$, let's look at $(\sqrt{2}/2, - \sqrt{2}/2)$. The derivative is $-x/y$, so the slope at this point is $1$. The line itself has equation $y = b + m \cdot (x-a)$. The following represents this in `Julia`:
```{julia}
@ -254,7 +254,7 @@ We added *both* the implicit plot of $F$ and the tangent line to the graph at th
##### Example
When we assume $y$ is a function of $x$, it may not be feasible to actually find the function algebraically. However, in many cases one can be found numerically. Suppose $G(x,y) = c$ describes the equation. Then for a fixed $x$, $y(x)$ solves $G(x,y(x))) - c = 0$, so $y(x)$ is a zero of a known function. As long as we can piece together which $y$ goes with which, we can find the function.
When we assume $y$ is a function of $x$, it may not be feasible to actually find the function algebraically. However, in many cases one can be found numerically. Suppose $G(x,y) = c$ describes the equation. Then for a fixed $x$, $y(x)$ solves $G(x,y(x)) - c = 0$, so $y(x)$ is a zero of a known function. As long as we can piece together which $y$ goes with which, we can find the function.
For example, the [folium](http://www-history.mcs.st-and.ac.uk/Curves/Foliumd.html) of Descartes has the equation
@ -308,7 +308,7 @@ To approach this task in `SymPy`, we begin by defining our symbolic expression.
```{julia}
@syms a b c d x y
ex = x*y - (a*c^3 + b*x^2 + c*x + d)
ex = x*y - (a*x^3 + b*x^2 + c*x + d)
```
To express that `y` is a locally a function of `x`, we use a "symbolic function" object:
@ -426,7 +426,7 @@ One last substitution for $dy/dx$ gives:
$$
\frac{d^2y}{dx^2} = \frac{-6x + 6y (\frac{x^2}{y^2})^2}{3y^2} = -2\frac{x}{y^2} + 2\frac{x^4}{y^5} = 2\frac{x}{y^2}(1 - \frac{x^3}{y^3}) = 2\frac{x}{y^5}(y^3 - x^3) = 2 \frac{x}{y^5}(-3).
\frac{d^2y}{dx^2} = \frac{6x - 6y (\frac{x^2}{y^2})^2}{3y^2} = 2\frac{x}{y^2} - 2\frac{x^4}{y^5} = 2\frac{x}{y^2}(1 - \frac{x^3}{y^3}) = 2\frac{x}{y^5}(y^3 - x^3) = 2 \frac{x}{y^5}(-3).
$$
It isn't so pretty, but that's all it takes.
@ -440,7 +440,7 @@ To visualize, we plot implicitly and notice that:
```{julia}
K(x,y) = x^3 - y^3 - 3
K(x,y) = x^3 - y^3
implicit_plot(K, xlims=(-3, 3), ylims=(-3, 3))
```
@ -481,7 +481,7 @@ $$
\sec(y)^2 \frac{dy}{dx} = 1.
$$
Or $dy/dx = 1/\sec^2(y)$.
Or $dy/dx = 1/\sec(y)^2$.
But $\sec(y)^2 = 1 + \tan(y)^2 = 1 + x^2$, as can be seen by right-triangle trigonometry. This yields the formula $dy/dx = [\tan^{-1}(x)]' = 1 / (1 + x^2)$.
@ -501,14 +501,14 @@ Suppose $\theta(t)$ can be defined in terms of the inverse to some function ($\t
$$
\sec^2(\theta(t)) \cdot \theta'(t) = \frac{y'(t) x(t) - y(t) x'(t)}{x(t))^2}.
\sec(\theta(t))^2 \cdot \theta'(t) = \frac{y'(t) x(t) - y(t) x'(t)}{x(t)^2}.
$$
But $\sec^2(\theta(t)) = (r(t)/x(t))^2 = (x(t)^2 + y(t)^2) / x(t)^2$, so moving to the other side the secant term gives an explicit, albeit complicated, expression for the derivative of $\theta$ in terms of the functions $x$ and $y$:
But $\sec(\theta(t))^2 = (r(t)/x(t))^2 = (x(t)^2 + y(t)^2) / x(t)^2$, so moving to the other side the secant term gives an explicit, albeit complicated, expression for the derivative of $\theta$ in terms of the functions $x$ and $y$:
$$
\theta'(t) = \frac{x^2}{x^2(t) + y^2(t)} \cdot \frac{y'(t) x(t) - y(t) x'(t)}{x(t))^2} = \frac{y'(t) x(t) - y(t) x'(t)}{x^2(t) + y^2(t)}.
\theta'(t) = \frac{x(t)^2}{x(t)^2 + y(t)^2} \cdot \frac{y'(t) x(t) - y(t) x'(t)}{x(t)^2} = \frac{y'(t) x(t) - y(t) x'(t)}{x(t)^2 + y(t)^2}.
$$
This could have been made easier, had we leveraged the result of the previous example.
@ -538,9 +538,9 @@ Well, suppose you hold the rope in two places, which we can take to be $(0,0)$ a
Q = (1, -3)
scatter([0,4], [0,1], legend=false, xaxis=nothing, yaxis=nothing)
plot!([0,1,4],[0,-3,1])
a,b = .05, .25
𝑎, 𝑏= .05, .25
ts = range(0, 2pi, length=100)
plot!(1 .+ a*sin.(ts), -3 .+ b*cos.(ts), color=:gold)
plot!(1 .+ 𝑎*sin.(ts), -3 .+ 𝑏*cos.(ts), color=:gold)
annotate!((4-0.3,1,"(a,b)"))
plot!([0,1,1],[0,0,-3], color=:gray, alpha=0.25)
plot!([1,1,4],[0,1,1], color=:gray, alpha=0.25)
@ -629,7 +629,7 @@ We would try to solve `eqn1` for `y` with `solve(eqn1, y)`, but `SymPy` can't co
```{julia}
eqn2 = eqn1(a=>3, b=>3, L=>10)
ystar = find_zero(eqn2, -3)
ystar = find_zero(lambdify(eqn2), -3)
```
Okay, now we need to put this value back into our expression for the `x` value and also substitute in for the parameters:
@ -670,7 +670,7 @@ In the above, we started with $F(x,y) = L$ and solved symbolically for $y=f(x)$
Here we try the same problem numerically, using a zero-finding approach to identify $f(x))$.
Starting with $F(x,y) = \sqrt{x^2 + y^2} + \sqrt{(x-1)^2 + (b-2)^2}$ and $L=3$, we have:
Starting with $F(x,y) = \sqrt{x^2 + y^2} + \sqrt{(x-1)^2 + (y-2)^2}$ and $L=3$, we have:
```{julia}
@ -681,14 +681,14 @@ implicit_plot(F₁)
Trying to find the lowest $y$ value we have from the graph it is near $x=0.1$. We can do better.
First, we could try so solve for the $f$ using `find_zero`. Here is one way:
First, we could try to solve for the $f$ using `find_zero`. Here is one way:
```{julia}
f₀(x) = find_zero(y -> F₁(x, y), 0)
```
We use $0$ as an initial guess, as the $y$ value is near $0$. More on this later. We could then just sample many $x$ values between $-0.5$ and $1.5$ and find the one corresponding to the smallest $t$ value:
We use $0$ as an initial guess, as the $y$ value is near $0$. More on this later. We could then just sample many $x$ values between $-0.5$ and $1.5$ and find the one corresponding to the smallest $y$ value:
```{julia}
@ -769,7 +769,7 @@ For the equation
$$
(y-5)\cdot \cos(4\cdot \sqrt{(x-4)^2 + y^2)} = x\cdot\sin(2\sqrt{x^2 + y^2})
(y-5)\cdot \cos(4\cdot \sqrt{(x-4)^2 + y^2}) = x\cdot\sin(2\sqrt{x^2 + y^2})
$$
is the point $(5,0)$ a solution?
@ -781,7 +781,7 @@ is the point $(5,0)$ a solution?
yesnoq(false)
```
##### Question
###### Question
Let $(x/3)^2 + (y/2)^2 = 1$. Find the slope of the tangent line at the point $(3/\sqrt{2}, 2/\sqrt{2})$.
@ -807,7 +807,7 @@ $$
\left(\frac{x}{a}\right)^n + \left(\frac{y}{b}\right)^n = 1.
$$
An ellipse is when $n=1$. Take $n=3$, $a=1$, and $b=2$.
An ellipse is when $n=2$. Take $n=3$, $a=1$, and $b=2$.
Find a *positive* value of $y$ when $x=1/2$.
@ -864,7 +864,7 @@ $$
y(x^2 + a^2) = a^3.
$$
If $a=1$, numerically find a a value of $y$ when $x=2$.
If $a=1$, numerically find a value of $y$ when $x=2$.
```{julia}
@ -908,7 +908,7 @@ nothing
![Image number 35 from L'Hospitals calculus book (the first). Given a description of the curve, identify the point ``E`` which maximizes the height.](figures/fcarc-may2016-fig35-350.png)
The figure above shows a problem appearing in L'Hospital's first calculus book. Given a function defined implicitly by $x^3 + y^3 = axy$ (with $AP=x$, $AM=y$ and $AB=a$) find the point $E$ that maximizes the height. In the [AMS feature column](http://www.ams.org/samplings/feature-column/fc-2016-05) this problem is illustrated and solved in the historical manner, with the comment that the concept of implicit differentiation wouldn't have occurred to L'Hospital.
The figure above shows a problem appearing in L'Hospital's first calculus book. Given a function defined implicitly by $x^3 + y^3 = axy$ (with $AP=x$, $PM=y$ and $AB=a$) find the point $E$ that maximizes the height. In the [AMS feature column](http://www.ams.org/samplings/feature-column/fc-2016-05) this problem is illustrated and solved in the historical manner, with the comment that the concept of implicit differentiation wouldn't have occurred to L'Hospital.
Using Implicit differentiation, find when $dy/dx = 0$.