Merge branch 'main' of https://github.com/jverzani/CalculusWithJuliaNotes.jl
This commit is contained in:
commit
c08eb90a60
@ -493,14 +493,14 @@ What looks at first glance to be just a slightly more complicated equation is th
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
s(u) &= \int_0^u \sqrt{(-\sin(t))^2 + b\cos(t)^2} dt\\
|
||||
&= \int_0^u \sqrt{\sin(t)^2 + \cos(t)^2 + c\cos(t)^2} dt \\
|
||||
&=\int_0^u \sqrt{1 + c\cos(t)^2} dt.
|
||||
s(u) &= \int_0^u \sqrt{(-\sin(t))^2 + (b\cos(t))^2} dt\\
|
||||
&= \int_0^u \sqrt{\sin(t)^2 + \cos(t)^2 + C\cos(t)^2} dt \\
|
||||
&=\int_0^u \sqrt{1 + C\cos(t)^2} dt.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
But, despite it not looking too daunting, this integral is not tractable through our techniques and has an answer involving elliptic integrals. We can work numerically though. Letting $a=1$ and $b=2$, we have the arc length is given by:
|
||||
Where $C = 2c + c^2$ is a constant. But, despite it not looking too daunting, this integral is not tractable through our techniques and has an answer involving elliptic integrals. We can work numerically though. Letting $a=1$ and $b=2$, we have the arc length is given by:
|
||||
|
||||
|
||||
```{julia}
|
||||
@ -710,7 +710,7 @@ For the latter claim, integrating in the $y$ variable gives
|
||||
$$
|
||||
\begin{align*}
|
||||
\int_u^c (f(x)-h) dx &= \int_h^m (c - f_1^{-1}(y)) dy\\
|
||||
&> \int_h^m (c - f_2^{-1}(y)) dy\\
|
||||
&> \int_h^m (f_2^{-1}(y) - c) dy\\
|
||||
&= \int_c^v (f(x)-h) dx
|
||||
\end{align*}
|
||||
$$
|
||||
|
@ -17,7 +17,7 @@ using Roots
|
||||
---
|
||||
|
||||
|
||||
The question of area has long fascinated human culture. As children, we learn early on the formulas for the areas of some geometric figures: a square is $b^2$, a rectangle $b\cdot h$ a triangle $1/2 \cdot b \cdot h$ and for a circle, $\pi r^2$. The area of a rectangle is often the intuitive basis for illustrating multiplication. The area of a triangle has been known for ages. Even complicated expressions, such as [Heron's](http://tinyurl.com/mqm9z) formula which relates the area of a triangle with measurements from its perimeter have been around for 2000 years. The formula for the area of a circle is also quite old. Wikipedia dates it as far back as the [Rhind](http://en.wikipedia.org/wiki/Rhind_Mathematical_Papyrus) papyrus for 1700 BC, with the approximation of $256/81$ for $\pi$.
|
||||
The question of area has long fascinated human culture. As children, we learn early on the formulas for the areas of some geometric figures: a square is $b^2$, a rectangle $b\cdot h$, a triangle $1/2 \cdot b \cdot h$ and for a circle, $\pi r^2$. The area of a rectangle is often the intuitive basis for illustrating multiplication. The area of a triangle has been known for ages. Even complicated expressions, such as [Heron's](http://tinyurl.com/mqm9z) formula which relates the area of a triangle with measurements from its perimeter have been around for 2000 years. The formula for the area of a circle is also quite old. Wikipedia dates it as far back as the [Rhind](http://en.wikipedia.org/wiki/Rhind_Mathematical_Papyrus) papyrus for 1700 BC, with the approximation of $256/81$ for $\pi$.
|
||||
|
||||
|
||||
The modern approach to area begins with a non-negative function $f(x)$ over an interval $[a,b]$. The goal is to compute the area under the graph. That is, the area between $f(x)$ and the $x$-axis between $a \leq x \leq b$.
|
||||
@ -480,9 +480,9 @@ This is just the area of a trapezoid with heights $a$ and $b$ and side length
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
S &= x_1 \cdot (x_1 - x_0) + x_2 \cdot (x_2 - x_1) + \cdots x_n \cdot (x_n - x_{n-1}) \\
|
||||
&= (a + 1\frac{b-a}{n}) \cdot \frac{b-a}{n} + (a + 2\frac{b-a}{n}) \cdot \frac{b-a}{n} + \cdots (a + n\frac{b-a}{n}) \cdot \frac{b-a}{n}\\
|
||||
&= n \cdot a \cdot (\frac{b-a}{n}) + (1 + 2 + \cdots n) \cdot (\frac{b-a}{n})^2 \\
|
||||
S &= x_1 \cdot (x_1 - x_0) + x_2 \cdot (x_2 - x_1) + \cdots + x_n \cdot (x_n - x_{n-1}) \\
|
||||
&= (a + 1\frac{b-a}{n}) \cdot \frac{b-a}{n} + (a + 2\frac{b-a}{n}) \cdot \frac{b-a}{n} + \cdots + (a + n\frac{b-a}{n}) \cdot \frac{b-a}{n}\\
|
||||
&= n \cdot a \cdot (\frac{b-a}{n}) + (1 + 2 + \cdots + n) \cdot (\frac{b-a}{n})^2 \\
|
||||
&= n \cdot a \cdot (\frac{b-a}{n}) + \frac{n(n+1)}{2} \cdot (\frac{b-a}{n})^2 \\
|
||||
& \rightarrow a \cdot(b-a) + \frac{(b-a)^2}{2} \\
|
||||
&= \frac{b^2}{2} - \frac{a^2}{2}.
|
||||
@ -729,7 +729,7 @@ An immediate consequence would be $\int_{-\pi}^\pi \sin(x) = 0$, as would $\int_
|
||||
##### Example
|
||||
|
||||
|
||||
Numerically estimate the definite integral $\int_0^e x\log(x) dx$. (We redefine the function to be $0$ at $0$, so it is continuous.)
|
||||
Numerically estimate the definite integral $\int_0^2 x\log(x) dx$. (We redefine the function to be $0$ at $0$, so it is continuous.)
|
||||
|
||||
|
||||
We have to be a bit careful with the Riemann sum, as the left Riemann sum will have an issue at $0=x_0$ (`0*log(0)`) returns `NaN` which will poison any subsequent arithmetic operations, so the value returned will be `NaN` and not an approximate answer. We could define our function with a check:
|
||||
@ -860,7 +860,7 @@ $$
|
||||
\frac{b-a}{6}(f(x_1) + 4f(x_2) + f(x_3)).
|
||||
$$
|
||||
|
||||
This formula will actually be exact for any 3rd degree polynomial. In fact an entire family of similar approximations using $n$ points can be made exact for any polynomial of degree $n-1$ or lower. But with non-evenly spaced points, even better results can be found.
|
||||
This formula will actually be exact for any 2nd degree polynomial. In fact an entire family of similar approximations using $n$ points can be made exact for any polynomial of degree $n-1$ or lower. But with non-evenly spaced points, even better results can be found.
|
||||
|
||||
|
||||
The formulas for an approximation to the integral $\int_{-1}^1 f(x) dx$ discussed so far can be written as:
|
||||
|
@ -494,7 +494,7 @@ box(f⁻¹(x₀-1Δ), x₀-2Δ, 1 - f⁻¹(x₀-1Δ), Δ, colᵣ)
|
||||
box(f⁻¹(x₀-2Δ), x₀-3Δ, 1 - f⁻¹(x₀-2Δ), Δ, colᵣ)
|
||||
```
|
||||
|
||||
The figure above suggests that the area under $f(x)$ over $[a,b]$ could be represented as the area between the curves $f^{-1}(y)$ and $y=b$ from $[f(a), f(b)]$.
|
||||
The figure above suggests that the area under $f(x)$ over $[a,b]$ could be represented as the area between the curves $f^{-1}(y)$ and $x=b$ from $[f(a), f(b)]$.
|
||||
|
||||
|
||||
---
|
||||
@ -552,7 +552,7 @@ p = plot(xs, ys; line=(3, :black), ylims=(0,4), legend=false)
|
||||
scatter!(p, xs, ys; marker=(7, :circle))
|
||||
```
|
||||
|
||||
Going further, we draw the four trapezoids using different colors depending on the sign of the `xs[i+1] - xs[[i]` terms:
|
||||
Going further, we draw the four trapezoids using different colors depending on the sign of the `xs[i+1] - xs[i]` terms:
|
||||
|
||||
```{julia}
|
||||
for i in 1:4
|
||||
@ -563,7 +563,7 @@ end
|
||||
p
|
||||
```
|
||||
|
||||
The yellow trapezoids appear to be colored green, as they completely overlap with parts of the blue trapezoids and blue and yellow make green. As the signs of the differences of the $x$ values is different, these areas add to $0$ in the sum, leaving just the area of the interior when the sum is computed.
|
||||
The yellow trapezoids appear to be colored grey, as they completely overlap with parts of the blue trapezoids and blue and yellow make grey with lights. As the signs of the differences of the $x$ values is different, these areas add to $0$ in the sum, leaving just the area of the interior when the sum is computed.
|
||||
|
||||
For this particular figure, the enclosed area is
|
||||
|
||||
@ -964,9 +964,10 @@ end
|
||||
What does this imply:
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
choices = ["The two enclosed areas should be equal",
|
||||
"The two enclosed areas are clearly different, as they do not overap"],
|
||||
"The two enclosed areas are clearly different, as they do not overap"]
|
||||
radioq(choices, 1)
|
||||
```
|
||||
"
|
||||
|
||||
|
@ -503,7 +503,7 @@ numericq(val)
|
||||
###### Question
|
||||
|
||||
|
||||
Find the center of mass of the region in the first quadrant bounded by the function $f(x) = x^3(1-x)^4$.
|
||||
Find the center of mass in the $x$ variable of the region in the first quadrant bounded by the function $f(x) = x^3(1-x)^4$.
|
||||
|
||||
|
||||
```{julia}
|
||||
|
@ -589,7 +589,7 @@ The answer will either be at a critical point, at $0$ or as $x$ goes to $\infty$
|
||||
|
||||
|
||||
$$
|
||||
[\text{erf}(x)]' = \frac{2}{\pi}e^{-x^2}.
|
||||
[\text{erf}(x)]' = \frac{2}{\sqrt{\pi}}e^{-x^2}.
|
||||
$$
|
||||
|
||||
Oh, this is never $0$, so there are no critical points. The maximum occurs at $0$ or as $x$ goes to $\infty$. Clearly at $0$, we have $\text{erf}(0)=0$, so the answer will be as $x$ goes to $\infty$.
|
||||
@ -755,7 +755,7 @@ A junior engineer at `Treadmillz.com` is tasked with updating the display of cal
|
||||
**********
|
||||
```
|
||||
|
||||
In this example display there was 1 calorie burned in the first minute, then 2, then 5, 5, 4, 3, 2, 2, 1. The total is $24$.
|
||||
In this example display there was 1 calorie burned in the first minute, then 2, then 5, 5, 4, 4, 3, 2, 2, 1. The total is $29$.
|
||||
|
||||
|
||||
In her work the junior engineer found this old function for updating the display
|
||||
@ -814,7 +814,7 @@ end
|
||||
Then the "area" represented by the dots stays fixed over this time frame.
|
||||
|
||||
|
||||
The engineer then thought a bit more, as the form of her answer seemed familiar. She decides to parameterize it in terms of $t$ and found with $h=1/n$: `c(t) = (C(t) - C(t-h))/h`. Ahh - the derivative approximation. But then what is the "area"? It is no longer just the sum of the dots, but in terms of the functions she finds that each column represents $c(t)\cdot h$, and the sum is just $c(t_1)h + c(t_2)h + \cdots c(t_n)h$ which looks like an approximate integral.
|
||||
The engineer then thought a bit more, as the form of her answer seemed familiar. She decides to parameterize it in terms of $t$ and found with $h=1/n$: `c(t) = (C(t) - C(t-h))/h`. Ahh - the derivative approximation. But then what is the "area"? It is no longer just the sum of the dots, but in terms of the functions she finds that each column represents $c(t)\cdot h$, and the sum is just $c(t_1)h + c(t_2)h + \cdots + c(t_n)h$ which looks like an approximate integral.
|
||||
|
||||
|
||||
If the display were to reach the modern age and replace LED "dots" with a higher-pixel display, then the function to display would be $c(t) = C'(t)$ and the area displayed would be $\int_{t-10}^t c(u) du$.
|
||||
|
@ -161,7 +161,7 @@ $$
|
||||
= \int_{\log(e)}^{\log(M)} \frac{1}{u^{2}} du
|
||||
= \frac{-1}{u} \big|_{1}^{\log(M)}
|
||||
= \frac{-1}{\log(M)} - \frac{-1}{1}
|
||||
= 1 - \frac{1}{M}.
|
||||
= 1 - \frac{1}{\log(M)}.
|
||||
$$
|
||||
|
||||
As $M$ goes to $\infty$, this will converge to $1$.
|
||||
|
@ -95,7 +95,7 @@ end
|
||||
|
||||
@fig-integration-by-parts shows a parametric plot of $(u(t),v(t))$ for $a \leq t \leq b$..
|
||||
|
||||
The total shaded area, a rectangle, is $u(b)v(b)$, the area of $A$ and $B$ combined is just $u(b)v(b) - u(a)v(a)$ or $[u(x)v(x)]\big|_a^b$. We will show that that $A$ is $\int_a^b v(x)u'(x)dx$ and $B$ is $\int_a^b u(x)v'(x)dx$ giving the formula
|
||||
The total shaded area, a rectangle, is $u(b)v(b)$, the area of $A$ and $B$ combined is just $u(b)v(b) - u(a)v(a)$ or $[u(x)v(x)]\big|_a^b$. We will show that $A$ is $\int_a^b v(x)u'(x)dx$ and $B$ is $\int_a^b u(x)v'(x)dx$ giving the formula.
|
||||
|
||||
We can compute $A$ by a change of variables with $x=u^{-1}(t)$ (so $u'(x)dx = dt$):
|
||||
|
||||
|
@ -456,7 +456,7 @@ answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
If $m < n$, then why can we cancel out the $(x-c)^n$ and not have a concern?
|
||||
If $m < n$, then why can we cancel out the $(x-c)^m$ and not have a concern?
|
||||
|
||||
|
||||
```{julia}
|
||||
|
@ -263,7 +263,7 @@ ws = unzip(S.(us,vs'))
|
||||
surface(ws..., alpha=0.75)
|
||||
```
|
||||
|
||||
We compare this answer to that of the frustum of a cone with radii $1$ and $(3/2)^2$, formed by rotating the line segment connecting $(0,f(0))$ with $(3/2,f(3/2))$. From looking at the graph of the surface, these values should be comparable. The surface area of the cone part is $\pi (r_1^2 + r_0^2) / \sin(\theta) = \pi (r_1 + r_0) \cdot \sqrt{(\Delta h)^2 + (r_1-r_0)^2}$.
|
||||
We compare this answer to that of the frustum of a cone with radii $1$ and $(3/2)^2$, formed by rotating the line segment connecting $(0,f(0))$ with $(3/2,f(3/2))$. From looking at the graph of the surface, these values should be comparable. The surface area of the cone part is $\pi (r_1^2 - r_0^2) / \sin(\theta) = \pi (r_1 + r_0) \cdot \sqrt{(\Delta h)^2 + (r_1-r_0)^2}$.
|
||||
|
||||
|
||||
```{julia}
|
||||
@ -354,7 +354,7 @@ That is, the surface area is simply the circumference of the circle traced out b
|
||||
##### Example
|
||||
|
||||
|
||||
The surface area of of an open cone can be computed, as the arc length is $\sqrt{h^2 + r^2}$ and the centroid of the line is a distance $r/2$ from the axis. This gives SA$=2\pi (r/2) \sqrt{h^2 + r^2} = \pi r \sqrt{h^2 + r^2}$.
|
||||
The surface area of an open cone can be computed, as the arc length is $\sqrt{h^2 + r^2}$ and the centroid of the line is a distance $r/2$ from the axis. This gives SA$=2\pi (r/2) \sqrt{h^2 + r^2} = \pi r \sqrt{h^2 + r^2}$.
|
||||
|
||||
|
||||
##### Example
|
||||
|
@ -165,7 +165,7 @@ A = simplify(integrate(nl - f(x), (x, q, a)));
|
||||
#| code-fold: true
|
||||
#| code-summary: "Show the code"
|
||||
@syms k::nonnegative
|
||||
V = simplify(integrate(PI * (nl - f(x) - k)^2, (x, q, a)));
|
||||
V = simplify(integrate(2PI*(nl-f(x))*(a - x + k),(x, q, a)));
|
||||
```
|
||||
|
||||
----
|
||||
@ -218,7 +218,7 @@ L = integrate(sqrt(1 + fp(x)^2), (x, q, a));
|
||||
|
||||
----
|
||||
|
||||
> 5. The $y$ coordinate of the midpoint ofthe line segment $PQ$
|
||||
> 5. The $y$ coordinate of the midpoint of the line segment $PQ$
|
||||
|
||||
|
||||
```{julia}
|
||||
@ -300,7 +300,7 @@ end
|
||||
#| code-summary: "Show the code"
|
||||
# use parametric and 2π ∫ u(t) √(u'(t)^2 + v'(t)^2) dt
|
||||
uu(x) = a - x
|
||||
vv(x) = f(uu(x))
|
||||
vv(x) = f(a - uu(x))
|
||||
SA = 2PI * integrate(uu(x) * sqrt(diff(uu(x),x)^2 + diff(vv(x),x)^2), (x, q, a));
|
||||
```
|
||||
|
||||
@ -394,11 +394,11 @@ plot!([a₀,q₀,q₀,a₀-f(a₀)/fp(a₀),a₀],
|
||||
# v1, v2, v3 = [[x[i]-x[1],y[i]-y[1], 0] for i in 2:4]
|
||||
# area = 1//2 * last(cross(v3,v2) + cross(v2, v1)) # 1/2 area of parallelogram
|
||||
# print(simplify(area))
|
||||
# -(x₁ - x₂)*(y₁ - y₃)/2 + (x₁ - x₃)*(y₁ - y₂)/2 - (x₁ - x₃)*(y₁ - y₄)/2 + (x₁ - x₄)*(y₁ - y₃)/2
|
||||
# (x₁ - x₂)*(y₁ - y₃)/2 - (x₁ - x₃)*(y₁ - y₂)/2 + (x₁ - x₃)*(y₁ - y₄)/2 - (x₁ - x₄)*(y₁ - y₃)/2
|
||||
tl₀ = a - f(a) / fp(a)
|
||||
x₁,x₂,x₃,x₄ = (a,q,q,tl₀)
|
||||
y₁, y₂, y₃, y₄ = (f(a), f(q), 0, 0)
|
||||
quadrilateral = -(x₁ - x₂)*(y₁ - y₃)/2 + (x₁ - x₃)*(y₁ - y₂)/2 - (x₁ - x₃)*(y₁ - y₄)/2 + (x₁ - x₄)*(y₁ - y₃)/2;
|
||||
quadrilateral = (x₁ - x₂)*(y₁ - y₃)/2 - (x₁ - x₃)*(y₁ - y₂)/2 + (x₁ - x₃)*(y₁ - y₄)/2 - (x₁ - x₄)*(y₁ - y₃)/2;
|
||||
```
|
||||
----
|
||||
|
||||
@ -415,7 +415,7 @@ article_answers = (1/(2sqrt(2)), 1/2, sqrt(3/10), 0.558480, 0.564641,
|
||||
#| echo: false
|
||||
# check
|
||||
problems = ("1a"=>yvalue, "1b"=>lseg, "1c"=>hd,
|
||||
"2a" => A, "2b" => V,
|
||||
"2a" => A, "2b" => V(k=>1),
|
||||
"3" => yₘ,
|
||||
"4" => L,
|
||||
"5" => mp,
|
||||
@ -429,7 +429,7 @@ problems = ("1a"=>yvalue, "1b"=>lseg, "1c"=>hd,
|
||||
)
|
||||
≈ₒ(a,b) = isapprox(a, b; atol=1e-5, rtol=sqrt(eps()))
|
||||
∂ = Differential(a)
|
||||
solutions = [k => only(solve(∂(p) ~ 0, a)) for (k,p) in problems]
|
||||
solutions = [k => (find_zero(∂(p), 0.5)) for (k,p) in problems]
|
||||
[(sol=k, correct=(any(isapprox.(s, article_answers; atol=1e-5)))) for (k,s) ∈ solutions]
|
||||
nothing
|
||||
```
|
||||
|
@ -73,7 +73,7 @@ gif(anim, imgfile, fps = 1)
|
||||
|
||||
|
||||
caption = L"""
|
||||
The first triangle has area $1/2$, the second has area $1/8$, then $3$ have area $(1/8)^2$, $4$ have area $(1/8)^3$, ...
|
||||
The first triangle has area $1/2$, the second has area $1/8$, then $2$ have area $(1/8)^2$, $4$ have area $(1/8)^3$, ...
|
||||
With some algebra, the total area then should be $1/2 \cdot (1 + (1/4) + (1/4)^2 + \cdots) = 2/3$.
|
||||
"""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user