lots of cleanup

This commit is contained in:
jverzani
2026-08-11 17:17:08 -04:00
parent ae461659e0
commit 253295ff6e
91 changed files with 18284 additions and 7872 deletions

View File

@@ -8,8 +8,7 @@ This section uses these add-on packages:
```{julia}
using CalculusWithJulia
using Plots
plotly()
using Plots; plotly()
using QuadGK
using Unitful, UnitfulUS
using Roots
@@ -75,8 +74,11 @@ Hey Michelin Man, how much does that costume weigh?
# ImageFile(:integrals, imgfile, caption)
nothing
```
::: {#fig-michelin-man-as-volume-slice}
![](./figures/michelin-man.jpg)
![Hey Michelin Man, how much does that costume weigh?](./figures/michelin-man.jpg)
Hey Michelin Man, how much does that costume weigh?
:::
An ad for a summer job says work as the Michelin Man! Sounds promising, but how much will that costume weigh? A very hot summer may make walking around in a heavy costume quite uncomfortable.
@@ -84,10 +86,13 @@ An ad for a summer job says work as the Michelin Man! Sounds promising, but how
A back-of-the envelope calculation would start by
* Mentally separating out each "tire" and lining them up one by one.
* Counting the number of "tires" (or rings), say $n$.
* Estimating the radius for each tire, say $r_i$ for $1 \leq i \leq n$.
* Estimating the height for each tire, say $h_i$ for $1 \leq i \leq n$
* Mentally separating out each "tire" and lining them up one by one.
* Counting the number of "tires" (or rings), say $n$.
* Estimating the radius for each tire, say $r_i$ for $1 \leq i \leq n$.
* Estimating the height for each tire, say $h_i$ for $1 \leq i \leq n$
Then the volume would be found by adding:
@@ -105,12 +110,15 @@ Looking at the sum though, we see the makings of an approximate integral. If the
In fact, we have in general:
::: {.definition title="Volume of a figure with a known cross section"}
> **Volume of a figure with a known cross section**: The volume of a solid with known cross-sectional area $A_{xc}(x)$ from $x=a$ to $x=b$ is given by
>
> $V = \int_a^b A_{xc}(x) dx.$
>
> This assumes $A_{xc}(x)$ is integrable.
The volume of a solid with known, integrable, cross-sectional area $A_{xc}(x)$ from $x=a$ to $x=b$ is given by
$$
V = \int_a^b A_{xc}(x) dx.
$$
:::
@@ -120,12 +128,12 @@ This formula is derived by approximating the volume by "slabs" with volume $A_{x
## Solids of revolution
We begin with some examples of a special class of solids - solids of revolution. These have an axis of symmetry from which the slabs are then just circular disks.
We begin with some examples of a special class of solids---solids of revolution. These have an axis of symmetry from which the slabs are then just circular disks.
Consider the volume contained in this glass, it will depend on the radius at different values of $x$:
Consider the volume contained in the glass of @fig-wine-glass-rotation, the volume will depend on the radius at different values of $x$:
::: {#fig-wine-glass-rotation}
```{julia}
#| hold: true
#| echo: false
@@ -141,12 +149,14 @@ between about $0$ and $6.2$cm.
nothing
```
![A wine glass oriented so that it is seen as generated by revolving a
![](./figures/integration-glass.jpg)
A wine glass oriented so that it is seen as generated by revolving a
curve about the $x$ axis. The radius of revolution varies as a function of $x$
between about $0$ and $6.2$cm.
](./figures/integration-glass.jpg)
:::
If $r(x)$ is the radius as a function of $x$, then the cross sectional area is $\pi r(x)^2$ so the volume is given by:
If $r(x)$ is the radius as a function of $x$, then the cross-sectional area is $\pi r(x)^2$ so the volume is given by:
$$
@@ -251,7 +261,7 @@ nothing
```
Illustration of a figure being rotated around the $x$-axis. The discs have approximate volume given by the area of the base times the height or $\pi r(x)^2 \Delta x$. (Figure ported from @Angenent.)
Illustration^[This illustration and others were directly inspired by @Angenent.] of a figure being rotated around the $x$-axis. The discs have approximate volume given by the area of the base times the height or $\pi r(x)^2 \Delta x$.
:::
@@ -302,9 +312,9 @@ If you are poor with units, `Julia` can provide some help through the `Unitful`
vol * u"inch"^3 |> us"floz"
```
Before Solo "squared" the cup, the Solo cup had markings that - [some thought](http://www.snopes.com/food/prepare/solocups.asp) - indicated certain volume amounts.
Before Solo "squared" the cup, the Solo cup had markings that--[some thought](http://www.snopes.com/food/prepare/solocups.asp)---indicated certain volume amounts.
::: {#fig-red-solo-cup-with-markings}
```{julia}
#| hold: true
#| echo: false
@@ -314,7 +324,10 @@ caption = "Markings on the red Solo cup indicated various volumes"
nothing
```
![Markings on the red Solo cup indicated various volumes.](./figures/red-solo-cup.jpg)
![](./figures/red-solo-cup.jpg)
Markings on the red Solo cup indicated various volumes
:::
What is the height for $5$ ounces (for a glass of wine)? $12$ ounces (for a beer unit)?
@@ -322,14 +335,14 @@ What is the height for $5$ ounces (for a glass of wine)? $12$ ounces (for a beer
Here the volume is fixed, but the height is not. For $v$ ounces, we need to convert to cubic inches. The conversion is $1$ ounce is $231/128 \text{in}^3$.
So we need to solve $v \cdot (231/128) = \int_0^h\pi r(x)^2 dx$ for $h$ when $v=5$ and $v=12$.
So we need to solve $v \cdot (231/128) =\int_0^h\pi r(x)^2 dx$ for $h$ when $v=5$ and $v=12$.
Let's express volume as a function of $h$:
```{julia}
Vol(h) = quadgk(x -> pi * rad(x)^2, 0, h)[1]
Vol(h) = first(quadgk(x -> pi * rad(x)^2, 0, h))
```
Then to solve we have:
@@ -395,12 +408,12 @@ frustum - cone * ( 3h0/h - 3(h0/h)^2 + (h0/h)^3) |> simplify
##### Example
[Gabriel's](http://tinyurl.com/8a6ygv) horn is a geometric figure of mathematics - but not the real world - which has infinite height, but not volume! The figure is found by rotating the curve $y=1/x$ around the $x$ axis from $1$ to $\infty$. If the volume formula holds, what is the volume of this "horn?"
[Gabriel's](https://en.wikipedia.org/wiki/Gabriel%27s_horn) horn is a geometric figure of mathematics---but not the real world---which has infinite height, but not volume! The figure is found by rotating the curve $y=1/x$ around the $x$ axis from $1$ to $\infty$. If the volume formula holds, what is the volume of this "horn?"
```{julia}
radius(x) = 1/x
quadgk(x -> pi*radius(x)^2, 1, Inf)[1]
first(quadgk(x -> pi*radius(x)^2, 1, Inf))
```
That is a value very reminiscent of $\pi$, which it is as $\int_1^\infty 1/x^2 dx = -1/x\big|_1^\infty=1$.
@@ -408,7 +421,7 @@ That is a value very reminiscent of $\pi$, which it is as $\int_1^\infty 1/x^2 d
:::{.callout-note}
## Note
The interest in this figure is that soon we will be able to show that it has **infinite** surface area, leading to the [paradox](http://tinyurl.com/osawwqm) that it seems possible to fill it with paint, but not paint the outside.
The interest in this figure is that soon we will be able to show that it has **infinite** surface area, leading to the paradox that it seems possible to fill it with paint, but not paint the outside.
:::
@@ -479,17 +492,20 @@ Rather than use $\pi r(x)^2$ for a cross section, we would use $\pi (R(x)^2 - r(
In general we call a shape like the tire a "washer" and use this formula for a washer's cross section $A_{xc}(x) = \pi(R(x)^2 - r(x)^2)$.
Then the volume for the solid of revolution whose cross sections are washers would be:
::: {.definition title="Volume by the washer method"}
The volume for the solid of revolution whose cross sections are washers with outer and inner radius given by $R(x)$ and $r(x)$ is:
$$
V = \int_a^b \pi \cdot (R(x)^2 - r(x)^2) dx.
$$
:::
::: {#fig-washer-illustration}
```{julia}
#| echo: false
plt = let
let
gr()
# Follow lead of # https://github.com/SigurdAngenent/WisconsinCalculus/blob/master/figures/221/09surf_of_rotation2.py
# plot surface of revolution around x axis between [0, 3]
@@ -519,7 +535,7 @@ plt = let
α = 1.0
line_style = (; line=(:black, 1))
plot(; empty_style..., aspect_ratio=:equal)
plt = plot(; empty_style..., aspect_ratio=:equal)
# by layering, we get x-axis as desired
plot!(pline(viewp, [-1,0,0], [0,0,0]); line_style...)
@@ -572,20 +588,12 @@ plt = let
plot!(curve; line=(:black, 1))
end
current()
plotly()
plt
end
plt
```
```{julia}
#| echo: false
plotly()
nothing
```
Modification of earlier figure to show washer method. The interior volume would be given by $\int_a^b \pi r(x)^2 dx$, the entire volume by $\int_a^b \pi R(x)^2 dx$. The difference then is the volume computed by the washer method.
Modification of @fig-solid-of-revolution to show the washer method. The interior volume would be given by $\int_a^b \pi r(x)^2 dx$, the entire volume by $\int_a^b \pi R(x)^2 dx$. The difference then is the volume computed by the washer method.
:::
@@ -629,10 +637,10 @@ vol, _ = quadgk(x -> d(x)^2, 0, h)
vol / 231 * 128
```
This shape would have more volume - the cross sections are bigger. Presumably the dimensions have changed. Without going out and buying a cup, let's assume the cross-sectional diameter remained the same, not the diameter. This means the largest dimension is the same. The cross section diameter is $\sqrt{2}$ larger. What would this do to the area?
This shape would have more volume---the cross sections are bigger. Presumably the dimensions have changed. Without going out and buying a cup, let's assume the cross-sectional diameter remained the same, not the diameter. This means the largest dimension is the same. The cross-sectional diameter is $\sqrt{2}$ larger. What would this do to the area?
We could do this two ways: divide $d_0$ and $d_1$ by $\sqrt{2}$ and recompute. However, each cross section of this narrower cup would simply be $\sqrt{2}^2$ smaller, so the total volume would change by $2$, or be 13 ounces. We have $26.04$ is too big, and $13.02$ is too small, so some other overall dimensions are used.
We could do this two ways: divide $d_0$ and $d_1$ by $\sqrt{2}$ and recompute. However, each cross section of this narrower cup would simply be $\sqrt{2}^2$ smaller, so the total volume would change by $2$, or be $13$ ounces. We have $26.04$ is too big, and $13.02$ is too small, so some other overall dimensions are used.
##### Example
@@ -645,7 +653,7 @@ For a general cone, we use this [definition](http://en.wikipedia.org/wiki/Cone):
Let $h$ be the distance from the apex to the base. Consider cones with the property that all planes parallel to the base intersect the cone with the same shape, though perhaps a different scale. This figure shows an example, with the rays coming from the apex defining the volume.
Let $h$ be the distance from the apex to the base. Consider cones with the property that all planes parallel to the base intersect the cone with the same shape, though perhaps a different scale. @fig-generic-cone shows an example, with the rays coming from the apex defining the volume.
::: {#fig-generic-cone}
```{julia}
@@ -736,18 +744,21 @@ $$
V = \int_0^h A_{xc}(u) du.
$$
The cross sectional area $A_{xc}(u)$ satisfies a formula in terms of $A_{xc}(0)$, the area of the base:
The cross-sectional area $A_{xc}(u)$ satisfies a formula in terms of $A_{xc}(0)$, the area of the base:
$$
A_{xc}(u) = A_{xc}(0) \cdot (1 - \frac{u}{h})^2
A_{xc}(u) = A_{xc}(0) \cdot \left(1 - \frac{u}{h}\right)^2
$$
So the integral becomes:
$$
V = \int_0^h A_{xc}(u) du = A_{xc}(0) \int_0^h (1 - \frac{u}{h})^2 du = A_{xc}(0) \int_0^1 v^2 h dv = A_{xc}(0) \frac{h}{3}.
\begin{align*}
V &= \int_0^h A_{xc}(u) du = A_{xc}(0) \int_0^h \left(1 - \frac{u}{h}\right)^2 du\\
&= A_{xc}(0) \int_0^1 v^2 h dv = A_{xc}(0) \frac{h}{3}.
\end{align*}
$$
This gives a general formula for the volume of such cones.
@@ -814,9 +825,8 @@ end
plt
```
This figure shows the volume of a figure being comprised of slices. A discrete approximation would be found by estimating the volume of each slice by the cross sectional area times a small $\Delta h$. This leads to a formula
$V = \int_a^b A(h)dh$, where $A$ computes the cross sectional area.
(This figure was ported from @Angenent.)
This figure shows the volume of a figure being comprised of slices. A discrete approximation would be found by estimating the volume of each slice by the cross-sectional area times a small $\Delta h$. This leads to a formula
$V = \int_a^b A(h)dh$, where $A$ computes the cross-sectional area.
:::
```{julia}
@@ -828,7 +838,9 @@ nothing
### Cavalieri's method
[Cavalieri's](http://tinyurl.com/oda9xd9) Principle is "Suppose two regions in three-space (solids) are included between two parallel planes. If every plane parallel to these two planes intersects both regions in cross-sections of equal area, then the two regions have equal volumes." (Wikipedia).
[Cavalieri's](https://en.wikipedia.org/wiki/Cavalieri%27s_principle) Principle is:
> Suppose two regions in three-space (solids) are included between two parallel planes. If every plane parallel to these two planes intersects both regions in cross-sections of equal area, then the two regions have equal volumes." (Wikipedia).
::: {#fig-Cavalieris-first}
@@ -868,19 +880,19 @@ plotly()
nothing
```
Illustration of Cavalieri's first principle. The discs from the left are moved around to form the left volume, but as the volumes of each cross-sectional disc remains the same, the two volumes are equally approximated. (This figure ported from @Angenent.)
Illustration of Cavalieri's first principle. The discs from the left are moved around to form the left volume, but as the volumes of each cross-sectional disc remains the same, the two volumes are equally approximated.
:::
With the formula for the volume of solids based on cross sections, this is a trivial observation, as the functions giving the cross-sectional area are identical. Still, it can be surprising.
Consider a sphere with an interior cylinder bored out of it. (The [Napkin](http://tinyurl.com/o237v83) ring problem.) The bore has height $h$ - for larger radius spheres this means very wide bores.
Consider a sphere with an interior cylinder bored out of it. (The [Napkin](https://en.wikipedia.org/wiki/Cavalieri%27s_principle#The_napkin_ring_problem) ring problem.) The bore has height $h$---for larger radius spheres this means very wide bores.
::: {#fig-napkin-ring-1}
```{julia}
#| echo: false
plt = let
let
gr()
# Follow lead of # https://github.com/SigurdAngenent/WisconsinCalculus/blob/master/figures/221/09surf_of_rotation2.py
# plot surface of revolution around x axis between [0, 3]
# best if r(t) decreases
@@ -937,7 +949,7 @@ plt = let
α = 1.0
line_style = (; line=(:black, 1))
plot(; empty_style..., aspect_ratio=:equal)
plt = plot(; empty_style..., aspect_ratio=:equal)
# washer
t0 = sqrt(3/4)
@@ -997,9 +1009,9 @@ plt = let
end
=#
current()
plotly()
plt
end
plt
```
Figure showing sphere with interior cylinder bored out.
@@ -1040,7 +1052,7 @@ plt = let
x₀ = sqrt(R^2 - (h/2)^2)
annotate!( [
(x₀/2, 0, text(L"\sqrt{R^2- (\frac{h}{2})^2}",10, :top)),
(x₀/2, 0, text(L"\sqrt{R^2- (\frac{h}{2})^2}", :top)),
(x₀, h/4, text(L"\frac{h}{2}",:right)),
(R/2*cos(θ),R/2*sin(θ), text(L"R", :bottom; rotation=rad2deg(θ)))
])
@@ -1067,13 +1079,15 @@ The small orange line is rotated, so using the washer method we get the cross se
The outer radii has points $(x,y)$ satisfying $x^2 + y^2 = R^2$, so is $\sqrt{R^2 - y^2}$. The inner radii has a constant value, and as indicated in the figure, is $\sqrt{R^2 - (h/2)^2}$, by the Pythagorean theorem.
Thus the cross sectional area is
Thus the cross-sectional area is
$$
\pi( (\sqrt{R^2 - y^2})^2 - (\sqrt{R^2 - (h/2)^2})^2 )
= \pi ((R^2 - y^2) - (R^2 - (h/2)^2))
= \pi ((\frac{h}{2})^2 - y^2)
\begin{align*}
\pi\left( (\sqrt{R^2 - y^2})^2 - (\sqrt{R^2 - (h/2)^2})^2 \right)
&= \pi \left((R^2 - y^2) - (R^2 - (h/2)^2)\right)\\
&= \pi \left((\frac{h}{2})^2 - y^2\right)
\end{align*}
$$
As this does not depend on $R$, and the limits of integration would always be $-h/2$ to $h/2$ by Cavalieri's principle, the volume of the solid will be independent of $R$ too.
@@ -1085,7 +1099,9 @@ To actually compute this volume, we take $R=h/2$, so that the bore hole is just
## The second theorem of Pappus
The second theorem of [Pappus](http://tinyurl.com/l43vw4) says that if a plane figure $F$ is rotated around an axis to form a solid of revolution, the total volume can be written as $2\pi r A(F)$, where $r$ is the distance the centroid is from the axis of revolution, and $A(F)$ is the area of the plane figure. In short, the distance traveled by the centroid times the area.
The second theorem of [Pappus](https://en.wikipedia.org/wiki/Pappus%27s_centroid_theorem) says
> If a plane figure $F$ is rotated around an axis to form a solid of revolution, the total volume can be written as $2\pi r A(F)$, where $r$ is the distance the centroid is from the axis of revolution, and $A(F)$ is the area of the plane figure. In short, the distance traveled by the centroid times the area. (Wikipedia)
This can make some computations trivial. For example, we can make a torus (or donut) by rotating the circle $(x-2)^2 + y^2 = 1$ about the $y$ axis. As the centroid is clearly $(2, 0)$, with $r=2$ in the above formula, and the area of the circle is $\pi 1^2$, the volume of the donut is $2\pi(2)(\pi) = 4\pi^2$.
@@ -1103,9 +1119,9 @@ Above, we found the volume of a cone, as it is a solid of revolution, through th
###### Question
Consider this big Solo cup:
@fig-big-solo-cup shows a big Solo cup.
::: {#fig-big-solo-cup}
```{julia}
#| hold: true
#| echo: false
@@ -1115,16 +1131,19 @@ caption = " Big solo cup. "
nothing
```
![Big solo cup.](./figures/big-solo-cup.jpg)
![](./figures/big-solo-cup.jpg)
Big solo cup
:::
It has approximate dimensions: smaller radius 5 feet, upper radius 8 feet and height 15 feet. How many gallons is it? At $8$ pounds a gallon this would be pretty heavy!
Two facts are useful:
* a cubic foot is 7.48052 gallons
* a cubic foot is 7.48052 gallons
* the radius as a function of height is $r(h) = 5 + (3/15)\cdot h$
* the radius as a function of height is $r(h) = 5 + (3/15)\cdot h$
```{julia}
@@ -1143,9 +1162,9 @@ numericq(val, 1e1)
In *Glass Shape Influences Consumption Rate* for Alcoholic [Beverages](http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0043007) the authors demonstrate that the shape of the glass can have an effect on the rate of consumption, presumably people drink faster when they aren't sure how much they have left. In particular, they comment that people have difficulty judging the half-finished-by-volume mark.
This figure shows some of the wide variety of beer-serving glasses:
@fig-beer-glasses shows some of a wide variety of beer-serving glasses:
::: {#fig-beer-glasses}
```{julia}
#| hold: true
#| echo: false
@@ -1155,7 +1174,10 @@ caption = "A variety of different serving glasses for beer."
nothing
```
![A variety of different serving glasses for beer.](./figures/beer_glasses.jpg)
![](./figures/beer_glasses.jpg)
A variety of different serving glasses for beer
:::
We work with metric units, as there is a natural relation between volume in cm$^3$ and liquid measure ($1$ liter = $1000$ cm$^3$, so a $16$-oz pint glass is roughly $450$ cm$^3$.)
@@ -1180,11 +1202,11 @@ The following functions find the volume as a function of height, $h$:
```{julia}
r1(h) = 3 + h/5
s1(h) = 2 + log(1 + h)
r_vol(h) = quadgk(x -> pi*r1(x)^2, 0, h)[1]
s_vol(h) = quadgk(x -> pi*s1(x)^2, 0, h)[1]
r_vol(h) = first(quadgk(x -> pi*r1(x)^2, 0, h))
s_vol(h) = first(quadgk(x -> pi*s1(x)^2, 0, h))
```
* For the straight-sided glass find $h$ so that the volume is $450$.
* For the straight-sided glass find $h$ so that the volume is $450$.
```{julia}
@@ -1193,7 +1215,7 @@ h450 = find_zero(h -> r_vol(h) - 450, 10)
numericq(h450)
```
* For the straight-sided glass find $h$ so that the volume is $225$ (half full).
* For the straight-sided glass find $h$ so that the volume is $225$ (half full).
```{julia}
@@ -1202,7 +1224,7 @@ h225 = find_zero(h -> r_vol(h) - 225, 10)
numericq(h225)
```
* For the straight-sided glass, what is the percentage of the total height when the glass is half full. (For a cylinder it would just be 50.)
* For the straight-sided glass, what is the percentage of the total height when the glass is half full. (For a cylinder it would just be 50.)
```{julia}
@@ -1210,7 +1232,7 @@ numericq(h225)
numericq(h225/h450 * 100, 2, units="percent")
```
* People often confuse the half-way by height amount for the half way by volume, as it is for the cylinder. Take the height for the straight-sided glass filled with $450$ mm, divide it by $2$, then compute the percentage of volume at the half way height to the original.
* People often confuse the half-way by height amount for the half way by volume, as it is for the cylinder. Take the height for the straight-sided glass filled with $450$ mm, divide it by $2$, then compute the percentage of volume at the half way height to the original.
```{julia}
@@ -1221,7 +1243,7 @@ numericq(r_vol(h450/2)/450*100, 2, units="percent")
---
* For the curved-sided glass find $h$ so that the volume is $450$.
* For the curved-sided glass find $h$ so that the volume is $450$.
```{julia}
@@ -1230,7 +1252,7 @@ h_450 = find_zero(h -> s_vol(h) - 450, 10)
numericq(h_450)
```
* For the curved-sided glass find $h$ so that the volume is $225$ (half full).
* For the curved-sided glass find $h$ so that the volume is $225$ (half full).
```{julia}
@@ -1239,7 +1261,7 @@ h_225 = find_zero(h -> s_vol(h) - 225, 10)
numericq(h_225)
```
* For the curved-sided glass, what is the percentage of the total height when the glass is half full. (For a cylinder it would just be 50.)
* For the curved-sided glass, what is the percentage of the total height when the glass is half full. (For a cylinder it would just be 50.)
```{julia}
@@ -1247,7 +1269,7 @@ numericq(h_225)
numericq(h_225/h_450 * 100, 2, units="percent")
```
* People often confuse the half-way by height amount for the half way by volume, as it is for the cylinder. Take the height for the curved-sided glass filled with $450$ mm, divide it by $2$, then compute the percentage of volume at the half way height to the original.
* People often confuse the half-way by height amount for the half way by volume, as it is for the cylinder. Take the height for the curved-sided glass filled with $450$ mm, divide it by $2$, then compute the percentage of volume at the half way height to the original.
```{julia}
@@ -1343,13 +1365,6 @@ numericq(val)
The region enclosed by the graphs of $y=x^3 - 1$ and $y=x-1$ are rotated around the $y$ axis. What is the volume of the solid?
```{julia}
#| hold: true
@syms x
plot(x^3 - 1, 0, 1, legend=false)
plot!(x-1)
```
```{julia}
#| hold: true
#| echo: false
@@ -1363,11 +1378,13 @@ numericq(val)
###### Question
Rotate the region bounded by $y=e^x$, the line $x=\log(2)$ and the first quadrant ($x,y \geq 0$) about the line $x=\log(2)$.
Rotate the region bounded by $y=e^x$, the line $x=\ln(2)$ and the first quadrant ($x,y \geq 0$) about the line $x=\log(2)$, as illustrated in @fig-rotate-e-to-x-around-log-2
::: {#fig-rotate-e-to-x-around-log-2}
```{julia}
#| echo: false
let
gr()
p = plot(exp, -0.1, log(2.2); legend=false, ylim = (-0.3, 2.3))
hline!(p, [0], color=:black)
vline!(p, [0], color=:black)
@@ -1381,12 +1398,17 @@ let
bs(t) = (exp(log(2)) - 4b) + b*sin(t)
plot!(p, as.(ts), bs.(ts), linewidth=1, color=:black, arrow=(:closed, 2.0))
plotly()
p
end
```
(Be careful, the radius in the formula $V=\int_a^b \pi r(u)^2 du$ is from the line $x=\log(2)$, further, the constraint $x \geq 0$ needs attention.)
Rotate a region around the line $x=\ln(2)$
:::
(Be careful, the radius in the formula $V=\int_a^b \pi r(u)^2 du$ is from the line $x=\ln(2)$, further, the constraint $x \geq 0$ needs attention.)
```{julia}
@@ -1428,11 +1450,12 @@ You can integrate in the length along the line $y=x$ ($u$ from $0$ to $\sqrt{2}$
theta = pi/4 ## we write y=x as y = x * tan(pi/4) for more generality, as this allows other slants.
f(x) = x^2
𝒙(u) = find_zero(x -> u*sin(theta) - 1/tan(theta) * (x - u*cos(theta)) - f(x), (u*cos(theta), 1))
𝒓(u) = sqrt((u*cos(theta) - 𝒙(u))^2 + (u*sin(theta) - f(𝒙(u)))^2)
𝑥(u) = find_zero(x -> u*sin(theta) - 1/tan(theta) * (x - u*cos(theta)) - f(x), (u*cos(theta), 1))
𝑟(u) = sqrt((u*cos(theta) - 𝑥(u))^2 + (u*sin(theta) - f(𝑥(u)))^2)
```
(Though in this case you can also find `r(u)` using the quadratic formula.)
(Though in this case you can also find `𝑟(u)` using the quadratic formula.)
With this, find the volume.
@@ -1442,7 +1465,7 @@ With this, find the volume.
#| hold: true
#| echo: false
a, b = 0, sqrt(2)
val, _ = quadgk(u -> pi*𝒓(u)^2, a, b)
val, _ = quadgk(u -> pi*𝑟(u)^2, a, b)
numericq(val)
```
@@ -1455,10 +1478,13 @@ Repeat (find the volume) only this time with the function $f(x) = x^{20}$.
```{julia}
#| hold: true
#| echo: false
a, b = 0, sqrt(2)
f(x) = x^20
xval(u) = find_zero(x -> u*sin(theta) - 1/tan(theta) * (x - u*cos(theta)) - f(x), (0,sqrt(2)))
rad(u) = sqrt((u*cos(theta) - xval(u))^2 + (u*sin(theta) - f(xval(u)))^2)
val, _ = quadgk(u -> pi*rad(u)^2, a, b)
numericq(val)
let
theta = pi/4
a, b = 0, sqrt(2)
f(x) = x^20
x(u) = find_zero(x -> u*sin(theta) - 1/tan(theta) * (x - u*cos(theta)) - f(x), (0,sqrt(2)))
r(u) = sqrt((u*cos(theta) - x(u))^2 + (u*sin(theta) - f(x(u)))^2)
val, _ = quadgk(u -> pi*r(u)^2, a, b)
numericq(val)
end
```