use quarto, not Pluto to render pages
This commit is contained in:
@@ -13,12 +13,12 @@ using Roots
|
||||
```julia; echo=false; results="hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Arc length",
|
||||
description = "Calculus with Julia: Arc length",
|
||||
tags = ["CalculusWithJulia", "integrals", "arc length"],
|
||||
frontmatter = (
|
||||
title = "Arc length",
|
||||
description = "Calculus with Julia: Arc length",
|
||||
tags = ["CalculusWithJulia", "integrals", "arc length"],
|
||||
);
|
||||
fig_size=(600, 400)
|
||||
fig_size=(800, 600)
|
||||
|
||||
nothing
|
||||
```
|
||||
@@ -57,20 +57,15 @@ f'(t)^2}$ is Riemann integrable.
|
||||
> For the special case of the graph of a function $f(x)$ between $a$ and $b$ the formula becomes $L = \int_a^b \sqrt{ 1 + f'(x)^2} dx$ (taking $g(t) = t$).
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
The form of the integral may seem daunting with the square root and
|
||||
the derivatives. A more general writing would create a vector out of
|
||||
the two functions: $\phi(t) = \langle g(t), f(t) \rangle$. It is
|
||||
natural to then let $\phi'(t) = \langle g'(t), f'(t) \rangle$. With
|
||||
this, the integrand is just the norm - or length - of the
|
||||
derivative, or $L=\int \| \phi'(t) \| dt$. This is similar to the
|
||||
distance traveled being the integral of the speed, or the absolute
|
||||
value of the derivative of position.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The form of the integral may seem daunting with the square root and
|
||||
the derivatives. A more general writing would create a vector out of
|
||||
the two functions: $\phi(t) = \langle g(t), f(t) \rangle$. It is
|
||||
natural to then let $\phi'(t) = \langle g'(t), f'(t) \rangle$. With
|
||||
this, the integrand is just the norm - or length - of the
|
||||
derivative, or $L=\int \| \phi'(t) \| dt$. This is similar to the
|
||||
distance traveled being the integral of the speed, or the absolute
|
||||
value of the derivative of position.
|
||||
|
||||
|
||||
To see why, any partition of the interval $[a,b]$ by $a = t_0 < t_1 < \cdots < t_n =b$ gives rise to $n+1$ points in the plane given by $(g(t_i), f(t_i))$.
|
||||
@@ -154,25 +149,20 @@ L = \int_a^b \sqrt{f'(t)^2 + g'(t)^2} dt.
|
||||
(This needs a technical adjustment to the Riemann theorem, as we are evaluating our function at two points in the interval. A general proof is [here](https://randomproofs.files.wordpress.com/2010/11/arc_length.pdf).)
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
!!! note
|
||||
[Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/exhibits/bressoud/)
|
||||
notes that Gregory (1668) proved this formula for arc length of the
|
||||
graph of a function by showing that the length of the curve $f(x)$ is defined
|
||||
by the area under $\sqrt{1 + f'(x)^2}$. (It is commented that this was
|
||||
also known a bit earlier by von Heurat.) Gregory went further though,
|
||||
as part of the fundamental theorem of calculus was contained in his
|
||||
work. Gregory then posed this inverse question: given a curve
|
||||
$y=g(x)$ find a function $u(x)$ so that the area under $g$ is equal to
|
||||
the length of the second curve. The answer given was $u(x) =
|
||||
(1/c)\int_a^x \sqrt{g^2(t) - c^2}$, which if $g(t) = \sqrt{1 + f'(t)^2}$
|
||||
and $c=1$ says $u(x) = \int_a^x f(t)dt$.
|
||||
|
||||
[Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/exhibits/bressoud/)
|
||||
notes that Gregory (1668) proved this formula for arc length of the
|
||||
graph of a function by showing that the length of the curve $f(x)$ is defined
|
||||
by the area under $\sqrt{1 + f'(x)^2}$. (It is commented that this was
|
||||
also known a bit earlier by von Heurat.) Gregory went further though,
|
||||
as part of the fundamental theorem of calculus was contained in his
|
||||
work. Gregory then posed this inverse question: given a curve
|
||||
$y=g(x)$ find a function $u(x)$ so that the area under $g$ is equal to
|
||||
the length of the second curve. The answer given was $u(x) =
|
||||
(1/c)\int_a^x \sqrt{g^2(t) - c^2}$, which if $g(t) = \sqrt{1 + f'(t)^2}$
|
||||
and $c=1$ says $u(x) = \int_a^x f(t)dt$.
|
||||
|
||||
An analogy might be a sausage maker. These take a mass of ground-up sausage material and return a long length of sausage. The material going in would depend on time via an equation like $\int_0^t g(u) du$ and the length coming out would be a constant (accounting for the cross section) times $u(t) = \int_0^t \sqrt{1 + g'(s)} ds$.
|
||||
|
||||
""")
|
||||
```
|
||||
An analogy might be a sausage maker. These take a mass of ground-up sausage material and return a long length of sausage. The material going in would depend on time via an equation like $\int_0^t g(u) du$ and the length coming out would be a constant (accounting for the cross section) times $u(t) = \int_0^t \sqrt{1 + g'(s)} ds$.
|
||||
|
||||
#### Examples
|
||||
|
||||
@@ -194,13 +184,8 @@ f(x) = x^2
|
||||
plot(f, 0, 1)
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
The integrand $\sqrt{1 + f'(x)^2}$ may seem odd at first, but it can be interpreted as the length of the hypotenuse of a right triangle with "run" of $1$ and "rise" of $f'(x)$. This triangle is easily formed using the tangent line to the graph of $f(x)$. By multiplying by $dx$, the integral is "summing" up the lengths of infinitesimal pieces of the tangent line approximation.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The integrand $\sqrt{1 + f'(x)^2}$ may seem odd at first, but it can be interpreted as the length of the hypotenuse of a right triangle with "run" of $1$ and "rise" of $f'(x)$. This triangle is easily formed using the tangent line to the graph of $f(x)$. By multiplying by $dx$, the integral is "summing" up the lengths of infinitesimal pieces of the tangent line approximation.
|
||||
|
||||
|
||||
##### Example
|
||||
@@ -705,8 +690,8 @@ f(x) = \left(\frac{g}{k v_0\cos(\theta)} + \tan(\theta) \right) x + \frac{g}{k^2
|
||||
This comes from solving the projectile motion equations with a drag force *proportional* to the velocity. This function satisfies:
|
||||
|
||||
```julia; hold=true
|
||||
@syms g::postive, k::postive, v₀::positive, θ::postive, x::postive
|
||||
ex = (g/(k*v₀*cos(θ)) + tan(θ))*x + g/k^2 * log(1 - k/(v₀*cos(θ))*x)
|
||||
@syms gₑ::postive, k::postive, v₀::positive, θ::postive, x::postive
|
||||
ex = (gₑ/(k*v₀*cos(θ)) + tan(θ))*x + gₑ/k^2 * log(1 - k/(v₀*cos(θ))*x)
|
||||
diff(ex, x, x), diff(ex, x, x, x,)
|
||||
```
|
||||
|
||||
@@ -857,16 +842,16 @@ y = a \ln\frac{a + \sqrt{a^2 - x^2}}{x} - \sqrt{a^2 - x^2}
|
||||
This can be entered into `julia` as:
|
||||
|
||||
```julia;
|
||||
g(x, a) = a * log((a + sqrt(a^2 - x^2))/x) - sqrt(a^2 - x^2)
|
||||
h(x, a) = a * log((a + sqrt(a^2 - x^2))/x) - sqrt(a^2 - x^2)
|
||||
```
|
||||
|
||||
|
||||
Let $a=12$, $f(x) = g(x, a)$. Compute the length the bow of the
|
||||
Let $a=12$, $f(x) = h(x, a)$. Compute the length the bow of the
|
||||
boat has traveled between $x=1$ and $x=a$ using `quadgk`.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
a = 12
|
||||
f(x) = g(x, a);
|
||||
f(x) = h(x, a);
|
||||
val = quadgk(x -> sqrt(1 + D(f)(x)^2), 1, a)[1];
|
||||
numericq(val, 1e-3)
|
||||
```
|
||||
@@ -874,13 +859,8 @@ numericq(val, 1e-3)
|
||||
(The most elementary description of this curve is in terms
|
||||
of the relationship $dy/dx = -\sqrt{a^2-x^2}/x$ which could be used in place of `D(f)` in your work.)
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
note("""
|
||||
|
||||
To see an example of how the tractrix can be found in an everyday observation, follow this link on a description of [bicycle](https://simonsfoundation.org/multimedia/mathematical-impressions-bicycle-tracks) tracks.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
To see an example of how the tractrix can be found in an everyday observation, follow this link on a description of [bicycle](https://simonsfoundation.org/multimedia/mathematical-impressions-bicycle-tracks) tracks.
|
||||
|
||||
###### Question
|
||||
|
||||
@@ -905,12 +885,14 @@ radioq(choices, 1)
|
||||
|
||||
A curve is parameterized by $g(t) = t + \sin(t)$ and $f(t) = \cos(t)$. Find the arc length of the curve between $t=0$ and $\pi$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
g(t) = t + sin(t)
|
||||
f(t) = cos(t)
|
||||
a, b = 0, pi
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
```julia; echo=false
|
||||
let
|
||||
g(t) = t + sin(t)
|
||||
f(t) = cos(t)
|
||||
a, b = 0, pi
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
end
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -918,24 +900,28 @@ numericq(val)
|
||||
The [astroid](http://www-history.mcs.st-and.ac.uk/Curves/Astroid.html) is
|
||||
a curve parameterized by $g(t) = \cos(t)^3$ and $f(t) = \sin(t)^3$. Find the arc length of the curve between $t=0$ and $2\pi$. (This can be computed by hand or numerically.)
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
g(t) = cos(t)^3
|
||||
f(t) = sin(t)^3
|
||||
a, b = 0, 2pi
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
```julia; echo=false
|
||||
let
|
||||
g(t) = cos(t)^3
|
||||
f(t) = sin(t)^3
|
||||
a, b = 0, 2pi
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
end
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
A curve is parameterized by $g(t) = (2t + 3)^{2/3}/3$ and $f(t) = t + t^2/2$, for $0\leq t \leq 3$. Compute the arc-length numerically or by hand:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
g(t) = (2t+3)^(2/3)/3
|
||||
f(t) = t + t^2/2
|
||||
a, b = 0, 3
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
```julia; echo=false
|
||||
let
|
||||
g(t) = (2t+3)^(2/3)/3
|
||||
f(t) = t + t^2/2
|
||||
a, b = 0, 3
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), a, b)
|
||||
numericq(val)
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
@@ -944,12 +930,14 @@ numericq(val)
|
||||
The cycloid is parameterized by $g(t) = a(t - \sin(t))$ and $f(t) = a(1 - \cos(t))$ for $a > 0$. Taking $a=3$, and $t$ in $[0, 2\pi]$, find the length of the curve traced out. (This was solved by the architect and polymath [Wren](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) in 1650.)
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
a = 3
|
||||
g(t) = a*(t - sin(t))
|
||||
f(t) = a*(1 - cos(t))
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), 0, 2pi)
|
||||
numericq(val)
|
||||
```julia; echo=false
|
||||
let
|
||||
a = 3
|
||||
g(t) = a*(t - sin(t))
|
||||
f(t) = a*(1 - cos(t))
|
||||
val, _ = quadgk( x -> sqrt(D(g)(x)^2 + D(f)(x)^2), 0, 2pi)
|
||||
numericq(val)
|
||||
end
|
||||
```
|
||||
|
||||
A cycloid parameterized this way can be generated by a circle of radius ``a``. Based on this example, what do you think Wren wrote to Pascal about this length:
|
||||
@@ -964,20 +952,16 @@ circle."]
|
||||
radioq(choices, 3, keep_order=true)
|
||||
```
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
note("""
|
||||
In [Martin](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) we read why Wren was mailing Pascal:
|
||||
!!! note
|
||||
In [Martin](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) we read why Wren was mailing Pascal:
|
||||
|
||||
After demonstrating mathematical talent at an early age, Blaise Pascal
|
||||
turned his attention to theology, denouncing the study of mathematics
|
||||
as a vainglorious pursuit. Then one night, unable to sleep as the
|
||||
result of a toothache, he began thinking about the cycloid and to his
|
||||
surprise, his tooth stopped aching. Taking this as a sign that he had
|
||||
God’s approval to continue, Pascal spent the next eight days studying
|
||||
the curve. During this time he discovered nearly all of the geometric
|
||||
properties of the cycloid. He issued some of his results in ``1658`` in
|
||||
the form of a contest, offering a prize of forty Spanish gold pieces
|
||||
and a second prize of twenty pieces.
|
||||
|
||||
""")
|
||||
```
|
||||
After demonstrating mathematical talent at an early age, Blaise Pascal
|
||||
turned his attention to theology, denouncing the study of mathematics
|
||||
as a vainglorious pursuit. Then one night, unable to sleep as the
|
||||
result of a toothache, he began thinking about the cycloid and to his
|
||||
surprise, his tooth stopped aching. Taking this as a sign that he had
|
||||
God’s approval to continue, Pascal spent the next eight days studying
|
||||
the curve. During this time he discovered nearly all of the geometric
|
||||
properties of the cycloid. He issued some of his results in ``1658`` in
|
||||
the form of a contest, offering a prize of forty Spanish gold pieces
|
||||
and a second prize of twenty pieces.
|
||||
|
||||
@@ -14,7 +14,7 @@ using Roots
|
||||
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
fig_size = (600, 400)
|
||||
fig_size = (800, 600)
|
||||
using Markdown, Mustache
|
||||
|
||||
const frontmatter = (
|
||||
@@ -284,17 +284,13 @@ first $n$ natural numbers.
|
||||
|
||||
With this expression, it is readily seen that as $n$ gets large this value gets close to $2/6 = 1/3$.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
!!! note
|
||||
The above approach, like Archimedes', ends with a limit being
|
||||
taken. The answer comes from using a limit to add a big number of
|
||||
small values. As with all limit questions, worrying about whether a
|
||||
limit exists is fundamental. For this problem, we will see that for
|
||||
the general statement there is a stretching of the formal concept of a limit.
|
||||
|
||||
The above approach, like Archimedes', ends with a limit being
|
||||
taken. The answer comes from using a limit to add a big number of
|
||||
small values. As with all limit questions, worrying about whether a
|
||||
limit exists is fundamental. For this problem, we will see that for
|
||||
the general statement there is a stretching of the formal concept of a limit.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
@@ -897,17 +893,12 @@ derivative over $[a,b]$. This is significant, the error in $10$ steps
|
||||
of Simpson's rule is on the scale of the error of $10,000$ steps of
|
||||
the Riemann sum for well-behaved functions.
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
The Wikipedia article mentions that Kepler used a similar formula $100$
|
||||
years prior to Simpson, or about $200$ years before Riemann published
|
||||
his work. Again, the value in Riemann's work is not the computation of
|
||||
the answer, but the framework it provides in determining if a function
|
||||
is Riemann integrable or not.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The Wikipedia article mentions that Kepler used a similar formula $100$
|
||||
years prior to Simpson, or about $200$ years before Riemann published
|
||||
his work. Again, the value in Riemann's work is not the computation of
|
||||
the answer, but the framework it provides in determining if a function
|
||||
is Riemann integrable or not.
|
||||
|
||||
## Gauss quadrature
|
||||
|
||||
@@ -1289,8 +1280,8 @@ choices = [
|
||||
"``p``",
|
||||
"``1-p``",
|
||||
"``p^2``"]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1303,8 +1294,8 @@ choices = [
|
||||
"``2^5/5 - 0^5/5``",
|
||||
"``2^4/4 - 0^4/4``",
|
||||
"``3\\cdot 2^3 - 3 \\cdot 0^3``"]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -1344,8 +1335,8 @@ L"The area between $c$ and $b$ must be positive, so $F(c) < F(b)$.",
|
||||
"``F(b) - F(c) = F(a).``",
|
||||
L" $F(x)$ is continuous, so between $a$ and $b$ has an extreme value, which must be at $c$. So $F(c) \geq F(b)$."
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -1359,8 +1350,8 @@ choices = [
|
||||
"``10/100``",
|
||||
"``(10 - 0) \\cdot e^{10} / 100^4``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -1440,9 +1431,11 @@ The area under a curve approximated by a Riemann sum.
|
||||
#CalculusWithJulia.WeaveSupport.JSXGraph(:integrals, url, caption)
|
||||
# This is just wrong...
|
||||
url = "https://raw.githubusercontent.com/jverzani/CalculusWithJulia.jl/master/CwJ/integrals/riemann.js"
|
||||
url = "./riemann.js"
|
||||
CalculusWithJulia.WeaveSupport.JSXGraph(url, caption)
|
||||
```
|
||||
|
||||
|
||||
The interactive graphic shows the area of a right-Riemann sum for different partitions. The function is
|
||||
|
||||
```math
|
||||
@@ -1502,8 +1495,8 @@ L"around $10^{-2}$",
|
||||
L"around $10^{-4}$",
|
||||
L"around $10^{-6}$",
|
||||
L"around $10^{-8}$"]
|
||||
ans = 4
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
@@ -317,13 +317,9 @@ g1(y)=exp(y)-1 # y=log(x+1) so e^y = x + 1, x = e^y - 1
|
||||
quadgk(y -> f1(y) - g1(y), a1, b1)[1]
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
!!! note
|
||||
When doing problems by hand this latter style can often reduce the complications, but when approaching the task numerically, the first two styles are generally easier, though computationally more expensive.
|
||||
|
||||
When doing problems by hand this latter style can often reduce the complications, but when approaching the task numerically, the first two styles are generally easier, though computationally more expensive.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
#### Integrating in different directions
|
||||
|
||||
@@ -427,7 +423,7 @@ Find the area enclosed by the curves $y=2-x^2$ and $y=x^2 - 3$.
|
||||
```julia; hold=true; echo=false
|
||||
f(x) = 2 - x^2
|
||||
g(x) = x^2 - 3
|
||||
a,b = find_zeros(x -> f(x) - g(x), -10,10)
|
||||
a,b = find_zeros(x -> f(x) - g(x), -10, 10)
|
||||
val, _ = quadgk(x -> f(x) - g(x), a, b)
|
||||
numericq(val)
|
||||
```
|
||||
@@ -569,16 +565,12 @@ Is the guess that the entire sculpture is more than two tons?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=["Less than two tons", "More than two tons"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
note("""
|
||||
We used area to estimate weight in this example, but Galileo used weight to estimate area. It is [mentioned](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) by Martin that in order to estimate the area enclosed by one arch of a cycloid, Galileo cut the arch from from some material and compared the weight to the weight of the generating circle. He concluded the area is close to ``3`` times that of the circle, a conjecture proved by Roberval in 1634.
|
||||
""")
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
!!! note
|
||||
We used area to estimate weight in this example, but Galileo used weight to estimate area. It is [mentioned](https://www.maa.org/sites/default/files/pdf/cmj_ftp/CMJ/January%202010/3%20Articles/3%20Martin/08-170.pdf) by Martin that in order to estimate the area enclosed by one arch of a cycloid, Galileo cut the arch from from some material and compared the weight to the weight of the generating circle. He concluded the area is close to ``3`` times that of the circle, a conjecture proved by Roberval in 1634.
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
@@ -192,13 +192,9 @@ cm = top / bottom
|
||||
|
||||
Our guess from the diagram proves correct.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
!!! note
|
||||
It proves convenient to use the `->` notation for an anonymous function above, as our function `h` is not what is being integrated all the time, but some simple modification. If this isn't palatable, a new function could be defined and passed along to `quadgk`.
|
||||
|
||||
It proves convenient to use the `->` notation for an anonymous function above, as our function `h` is not what is being integrated all the time, but some simple modification. If this isn't palatable, a new function could be defined and passed along to `quadgk`.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -220,13 +216,9 @@ For fun, we compare this to the median, which is the value $M$ so that the total
|
||||
|
||||
Solving $1/2 = 1 - e^{-M}$ gives $M=\log(2) = 0.69...$, The median is to the left of the mean in this example.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
!!! note
|
||||
In this example, we used an infinite region, so the idea of "balancing" may be a bit unrealistic, nonetheless, this intuitive interpretation is still a good one to keep this in mind. The point of comparing to the median is that the balancing point is to the right of where the area splits in half. Basically, the center of mass follows in the direction of the area far to the right of the median, as this area is skewed in that direction.
|
||||
|
||||
In this example, we used an infinite region, so the idea of "balancing" may be a bit unrealistic, nonetheless, this intuitive interpretation is still a good one to keep this in mind. The point of comparing to the median is that the balancing point is to the right of where the area splits in half. Basically, the center of mass follows in the direction of the area far to the right of the median, as this area is skewed in that direction.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -308,13 +300,9 @@ integrate(x*fx, (x, 0, b)) / integrate(fx, (x, 0, b))
|
||||
|
||||
But really, we should have just noted that simply by switching the labels $a$ and $b$ in the diagram we could have discovered this formula.
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
!!! note
|
||||
The [centroid](http://en.wikipedia.org/wiki/Centroid) of a region in the plane is just $(\text{cm}_x, \text{cm}_y)$. This last fact says the centroid of the right triangle is just $(b/3, a/3)$. The centroid can be found by other geometric means. The link shows the plumb line method. For triangles, the centroid is also the intersection point of the medians, the lines that connect a vertex with its opposite midpoint.
|
||||
|
||||
The [centroid](http://en.wikipedia.org/wiki/Centroid) of a region in the plane is just $(\text{cm}_x, \text{cm}_y)$. This last fact says the centroid of the right triangle is just $(b/3, a/3)$. The centroid can be found by other geometric means. The link shows the plumb line method. For triangles, the centroid is also the intersection point of the medians, the lines that connect a vertex with its opposite midpoint.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const frontmatter = (
|
||||
description = "Calculus with Julia: Fundamental Theorem or Calculus",
|
||||
tags = ["CalculusWithJulia", "integrals", "fundamental theorem or calculus"],
|
||||
);
|
||||
fig_size = (600, 400)
|
||||
fig_size = (800, 600)
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -107,11 +107,15 @@ definite integral and the derivative we have
|
||||
```math
|
||||
\begin{align*}
|
||||
F'(x) = & \frac{d}{dx} \int_a^x f(u) du \\
|
||||
& \approx \frac{F(x) - F(x-h)}{h} = \frac{\int_a^x f(u) du - \int_a^{x-h} f(u) du}{h}\\
|
||||
& \approx \frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h + f(a + Mh)h\right)}{h} -
|
||||
& \approx \frac{F(x) - F(x-h)}{h} \\
|
||||
&= \frac{\int_a^x f(u) du - \int_a^{x-h} f(u) du}{h}\\
|
||||
& \approx \frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h + f(a + Mh)h\right)}{h}\\
|
||||
&- \quad
|
||||
\frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h \right)}{h} \\
|
||||
& = \left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) + f(a + Mh)\right) -
|
||||
\left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) \right)
|
||||
& = \left(f(a + 1h) + \quad f(a + 2h) + \cdots + f(a + (M-1)h) + f(a + Mh)\right)\\
|
||||
&- \quad
|
||||
\left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) \right) \\
|
||||
&= f(a + Mh).
|
||||
\end{align*}
|
||||
```
|
||||
|
||||
@@ -152,20 +156,15 @@ With these heuristics, we now have:
|
||||
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
In Part 1, the integral $F(x) = \int_a^x f(u) du$ is defined for any
|
||||
Riemann integrable function, $f$. If the function is not continuous,
|
||||
then it is true the $F$ will be continuous, but it need not be true
|
||||
that it is differentiable at all points in $(a,b)$. Forming $F$ from
|
||||
$f$ is a form of *smoothing*. It makes a continuous function out of an
|
||||
integrable one, a differentiable function from a continuous one, and a
|
||||
$k+1$-times differentiable function from a $k$-times differentiable
|
||||
one.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
In Part 1, the integral $F(x) = \int_a^x f(u) du$ is defined for any
|
||||
Riemann integrable function, $f$. If the function is not continuous,
|
||||
then it is true the $F$ will be continuous, but it need not be true
|
||||
that it is differentiable at all points in $(a,b)$. Forming $F$ from
|
||||
$f$ is a form of *smoothing*. It makes a continuous function out of an
|
||||
integrable one, a differentiable function from a continuous one, and a
|
||||
$k+1$-times differentiable function from a $k$-times differentiable
|
||||
one.
|
||||
|
||||
## Using the fundamental theorem of calculus to evaluate definite integrals
|
||||
|
||||
@@ -616,7 +615,7 @@ We need to figure out when this is $0$. For that, we use some numeric math.
|
||||
```julia;
|
||||
F(x) = exp(-x^2) * quadgk(t -> exp(t^2), 0, x)[1]
|
||||
Fp(x) = -2x*F(x) + 1
|
||||
cps = find_zeros(Fp, -4,4)
|
||||
cps = find_zeros(Fp, -4, 4)
|
||||
```
|
||||
|
||||
We could take a second derivative to characterize. For that we use
|
||||
@@ -714,14 +713,8 @@ dx``, using linearity, as ``\int_0^{x_0} f(x) dx +
|
||||
\int_{x_{n-1}}^{x_n}f(x)dx``. Then all but the last term could be
|
||||
stored from the previous steps of Newton's method. The last term presumably being less costly as it would typically involve a small interval.
|
||||
|
||||
```julia;echo=false
|
||||
note("""
|
||||
The trick using a closure relies on an internal way of accessing elements in a closure. The same trick could be implemented many different ways which aren't reliant on undocumented internals, this approach was just a tad more convenient. It shouldn't be copied for work intended for distribution, as the internals may change without notice or deprecation.
|
||||
""")
|
||||
```
|
||||
|
||||
|
||||
|
||||
!!! note
|
||||
The trick using a closure relies on an internal way of accessing elements in a closure. The same trick could be implemented many different ways which aren't reliant on undocumented internals, this approach was just a tad more convenient. It shouldn't be copied for work intended for distribution, as the internals may change without notice or deprecation.
|
||||
|
||||
|
||||
##### Example
|
||||
@@ -898,8 +891,8 @@ choices = [
|
||||
"``-x^2\\cos(x) + 2x\\sin(x)``",
|
||||
"``-x^2\\cos(x) + 2x\\sin(x) + 2\\cos(x)``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -914,8 +907,8 @@ choices = [
|
||||
"``-(1+x) e^{-x}``",
|
||||
"``-(1 + x + x^2) e^{-x}``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -978,8 +971,8 @@ choices = [
|
||||
L"Between $0$ and $1$",
|
||||
L"Between $1$ and $5$"
|
||||
]
|
||||
ans = 4
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
* The position of the particle is $0$ at $t=0$ and:
|
||||
@@ -990,8 +983,8 @@ choices = [
|
||||
"``t=2``",
|
||||
"``t=3``",
|
||||
"``t=4``"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
* The position of the particle at time $t=5$ is?
|
||||
@@ -1010,8 +1003,8 @@ L"The position, $x(t)$, increases with a slope of $1$",
|
||||
L"The position, $x(t)$, increases quadratically from $-1/2$ to $1$",
|
||||
L"The position, $x(t)$, increases quadratically from $0$ to $1$"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1024,8 +1017,8 @@ choices = [
|
||||
"``-f(t-10)``",
|
||||
"``f(t) - f(t-10)``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1037,8 +1030,8 @@ choices = [
|
||||
"At a critical point",
|
||||
L"At the endpoint $0$",
|
||||
L"At the endpoint $1$"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1058,8 +1051,8 @@ choices = [
|
||||
"The derivative of ``F`` is ``f``, so by the second derivative test, ``x=7``",
|
||||
"The graph of ``f`` has relative maxima at ``x=2,6,8``"
|
||||
]
|
||||
answer = 2
|
||||
radioq(choices, answer)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -1073,8 +1066,8 @@ L"At a critical point, either $0$ or $1$",
|
||||
L"At a critical point, $1/2$",
|
||||
L"At the endpoint $0$",
|
||||
L"At the endpoint $1$"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1122,8 +1115,8 @@ choices = [
|
||||
"``A(x) / \\lvert Tx \\rvert = A'(x)``",
|
||||
"``A(x) \\cdot A'(x) = f(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
The fact that $\lvert PT \rvert$ is tangent says what in terms of $f(x)$, $A(x)$ and $A'(x)$?
|
||||
@@ -1135,8 +1128,8 @@ choices = [
|
||||
"``A(x) / \\lvert Tx \\rvert = A'(x)``",
|
||||
"``A(x) \\cdot A'(x) = f(x)``"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
Solving, we get:
|
||||
@@ -1148,8 +1141,8 @@ choices = [
|
||||
"``A'(x) = A(x)``",
|
||||
"``A(x) = f(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1160,20 +1153,20 @@ According to [Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/
|
||||
choices = [
|
||||
L"Part 1: $[\int_a^x f(u) du]' = f$",
|
||||
L"Part 2: $\int_a^b f(u) du = F(b)- F(a)$."]
|
||||
ans=1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ=1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
## More on SymPy's `integrate`
|
||||
|
||||
Finding the value of a definite integral through the fundamental theorem of calculus relies on the algebraic identification of an antiderivative. This is difficult to do by hand and by computer, and is complicated by the fact that not every [elementary ](https://en.wikipedia.org/wiki/Elementary_function)function has an elementary antiderivative.
|
||||
`SymPy`'s documentation on integration indicates that several different means to integrate a function are used internally. As it is of interest here, it is copied with just minor edits below:
|
||||
`SymPy`'s documentation on integration indicates that several different means to integrate a function are used internally. As it is of interest here, it is copied with just minor edits below (from an older version of SymPy):
|
||||
|
||||
|
||||
#### Simple heuristics (based on pattern matching and integral table):
|
||||
|
||||
* most frequently used functions (e.g. polynomials, products of trigonemetric functions)
|
||||
* most frequently used functions (e.g. polynomials, products of trigonometric functions)
|
||||
|
||||
#### Integration of rational functions:
|
||||
|
||||
@@ -1250,4 +1243,4 @@ Finding the value of a definite integral through the fundamental theorem of calc
|
||||
is to implement enough of the Risch and Meijer G-function methods
|
||||
so that this can be deleted.
|
||||
Setting `heurisch=true` will cause `integrate` to use only this
|
||||
method. Set `heurisch=false to not use it.
|
||||
method. Set `heurisch=false` to not use it.
|
||||
|
||||
@@ -17,7 +17,7 @@ const frontmatter = (
|
||||
description = "Calculus with Julia: Improper Integrals",
|
||||
tags = ["CalculusWithJulia", "integrals", "improper integrals"],
|
||||
);
|
||||
fig_size=(600, 400)
|
||||
fig_size=(800, 600)
|
||||
|
||||
nothing
|
||||
```
|
||||
@@ -108,10 +108,8 @@ For the interval $(-\infty, \infty)$ we have need *both* these limits to exist,
|
||||
\int_{-\infty}^\infty f(x) dx = \lim_{M \rightarrow -\infty} \int_M^a f(x) dx + \lim_{M \rightarrow \infty} \int_a^M f(x) dx.
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note("""When the integral exists, it is said to *converge*. If it doesn't exist, it is said to *diverge*.
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
When the integral exists, it is said to *converge*. If it doesn't exist, it is said to *diverge*.
|
||||
|
||||
##### Examples
|
||||
|
||||
@@ -201,13 +199,8 @@ Suppose $a < c$, we define $\int_a^c f(x) dx = \lim_{M \rightarrow c-} \int_a^c
|
||||
= \lim_{M \rightarrow 0+} 2(1) - 2\sqrt{M} = 2.
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
The cases $f(x) = x^{-n}$ for $n > 0$ are tricky to keep straight. For $n > 1$, the functions can be integrated over $[1,\infty)$, but not $(0,1]$. For $0 < n < 1$, the functions can be integrated over $(0,1]$ but not $[1, \infty)$.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The cases $f(x) = x^{-n}$ for $n > 0$ are tricky to keep straight. For $n > 1$, the functions can be integrated over $[1,\infty)$, but not $(0,1]$. For $0 < n < 1$, the functions can be integrated over $(0,1]$ but not $[1, \infty)$.
|
||||
|
||||
* Now consider $f(x) = 1/x$. Is this integral $\int_0^1 1/x \cdot dx$ defined? It will be *if* this limit exists:
|
||||
|
||||
@@ -417,8 +410,8 @@ choices =[
|
||||
"It is convergent",
|
||||
"It is divergent",
|
||||
"Can't say"]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -433,8 +426,8 @@ choices =[
|
||||
"It is convergent",
|
||||
"It is divergent",
|
||||
"Can't say"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
@@ -450,8 +443,8 @@ choices =[
|
||||
"It is convergent",
|
||||
"It is divergent",
|
||||
"Can't say"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
@@ -465,8 +458,8 @@ choices =[
|
||||
"It is convergent",
|
||||
"It is divergent",
|
||||
"Can't say"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
@@ -480,8 +473,8 @@ choices =[
|
||||
"It is convergent",
|
||||
"It is divergent",
|
||||
"Can't say"]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -496,8 +489,8 @@ choices = [
|
||||
"``\\int_0^1 u^{2/3} \\cdot du``",
|
||||
"``\\int_0^\\infty 1/u \\cdot du``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
@@ -13,10 +13,10 @@ using SymPy
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using QuadGK
|
||||
|
||||
const frontmatter = (
|
||||
title = "Integration By Parts",
|
||||
description = "Calculus with Julia: Integration By Parts",
|
||||
tags = ["CalculusWithJulia", "integrals", "integration by parts"],
|
||||
frontmatter = (
|
||||
title = "Integration By Parts",
|
||||
description = "Calculus with Julia: Integration By Parts",
|
||||
tags = ["CalculusWithJulia", "integrals", "integration by parts"],
|
||||
);
|
||||
|
||||
nothing
|
||||
@@ -41,21 +41,23 @@ Now we turn our attention to the implications of the *product rule*: $[uv]' = u'
|
||||
The following illustrates integration by parts of the integral $(uv)'$ over
|
||||
$[a,b]$ [original](http://en.wikipedia.org/wiki/Integration_by_parts#Visualization).
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
## parts picture
|
||||
u(x) = sin(x*pi/2)
|
||||
v(x) = x
|
||||
xs = range(0, stop=1, length=50)
|
||||
a,b = 1/4, 3/4
|
||||
p = plot(u, v, 0, 1, legend=false)
|
||||
plot!(p, zero, 0, 1)
|
||||
scatter!(p, [u(a), u(b)], [v(a), v(b)], color=:orange, markersize=5)
|
||||
```julia; echo=false
|
||||
let
|
||||
## parts picture
|
||||
u(x) = sin(x*pi/2)
|
||||
v(x) = x
|
||||
xs = range(0, stop=1, length=50)
|
||||
a,b = 1/4, 3/4
|
||||
p = plot(u, v, 0, 1, legend=false)
|
||||
plot!(p, zero, 0, 1)
|
||||
scatter!(p, [u(a), u(b)], [v(a), v(b)], color=:orange, markersize=5)
|
||||
|
||||
plot!(p, [u(a),u(a),0, 0, u(b),u(b),u(a)],
|
||||
[0, v(a), v(a), v(b), v(b), 0, 0],
|
||||
linetype=:polygon, fillcolor=:orange, alpha=0.25)
|
||||
annotate!(p, [(0.65, .25, "A"), (0.4, .55, "B")])
|
||||
annotate!(p, [(u(a),v(a) + .08, "(u(a),v(a))"), (u(b),v(b)+.08, "(u(b),v(b))")])
|
||||
plot!(p, [u(a),u(a),0, 0, u(b),u(b),u(a)],
|
||||
[0, v(a), v(a), v(b), v(b), 0, 0],
|
||||
linetype=:polygon, fillcolor=:orange, alpha=0.25)
|
||||
annotate!(p, [(0.65, .25, "A"), (0.4, .55, "B")])
|
||||
annotate!(p, [(u(a),v(a) + .08, "(u(a),v(a))"), (u(b),v(b)+.08, "(u(b),v(b))")])
|
||||
end
|
||||
```
|
||||
|
||||
The figure is a parametric plot of $(u,v)$ with the points $(u(a),
|
||||
@@ -200,8 +202,8 @@ e^x(x^2 - 2x - 1) \big|_a^b.
|
||||
In fact, it isn't hard to see that an integral of $x^m e^x$, $m$ a positive integer, can be handled in this manner. For example, when $m=10$, `SymPy` gives:
|
||||
|
||||
```julia;
|
||||
@syms x
|
||||
integrate(x^10 * exp(x), x)
|
||||
@syms 𝒙
|
||||
integrate(𝒙^10 * exp(𝒙), 𝒙)
|
||||
```
|
||||
|
||||
|
||||
@@ -264,7 +266,7 @@ by a double angle formula application, is $x/2 - \sin(2x)/4$.
|
||||
`SymPy` is quite able to do this repeated bookkeeping. For example with $n=10$:
|
||||
|
||||
```julia;
|
||||
integrate(cos(x)^10, x)
|
||||
integrate(cos(𝒙)^10, 𝒙)
|
||||
```
|
||||
|
||||
##### Example
|
||||
@@ -403,17 +405,19 @@ When ``u(t)`` is strictly *increasing*, and hence having an inverse function, th
|
||||
|
||||
However, the correct answer requires understanding a minus sign. Consider the area enclosed by ``x(t) = \cos(t), y(t) = \sin(t)``:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
r(t) = [cos(t), sin(t)]
|
||||
p=plot_parametric(0..2pi, r, aspect_ratio=:equal, legend=false)
|
||||
for t ∈ (pi/4, 3pi/4, 5pi/4, 7pi/4)
|
||||
quiver!(unzip([r(t)])..., quiver=Tuple(unzip([0.1*r'(t)])))
|
||||
```julia; echo=false
|
||||
let
|
||||
r(t) = [cos(t), sin(t)]
|
||||
p=plot_parametric(0..2pi, r, aspect_ratio=:equal, legend=false)
|
||||
for t ∈ (pi/4, 3pi/4, 5pi/4, 7pi/4)
|
||||
quiver!(unzip([r(t)])..., quiver=Tuple(unzip([0.1*r'(t)])))
|
||||
end
|
||||
ti, tj = pi/3, pi/3+0.1
|
||||
plot!([cos(tj), cos(ti), cos(ti), cos(tj), cos(tj)], [0,0,sin(tj), sin(tj),0])
|
||||
quiver!([0],[0], quiver=Tuple(unzip([r(ti)])))
|
||||
quiver!([0],[0], quiver=Tuple(unzip([r(tj)])))
|
||||
p
|
||||
end
|
||||
ti, tj = pi/3, pi/3+0.1
|
||||
plot!([cos(tj), cos(ti), cos(ti), cos(tj), cos(tj)], [0,0,sin(tj), sin(tj),0])
|
||||
quiver!([0],[0], quiver=Tuple(unzip([r(ti)])))
|
||||
quiver!([0],[0], quiver=Tuple(unzip([r(tj)])))
|
||||
p
|
||||
```
|
||||
|
||||
|
||||
@@ -441,10 +445,10 @@ This is a case of [Green's Theorem](https://en.wikipedia.org/wiki/Green%27s_theo
|
||||
Apply the formula to a parameterized circle to ensure, the signed area is properly computed. If we use ``x(t) = r\cos(t)`` and ``y(t) = r\sin(t)`` then we have the motion is counterclockwise:
|
||||
|
||||
```julia; hold=true
|
||||
@syms r t
|
||||
x(t) = r*cos(t)
|
||||
y(t) = r*sin(t)
|
||||
-integrate(y(t) * diff(x(t), t), (t, 0, 2PI))
|
||||
@syms 𝒓 t
|
||||
𝒙 = 𝒓 * cos(t)
|
||||
𝒚 = 𝒓 * sin(t)
|
||||
-integrate(𝒚 * diff(𝒙, t), (t, 0, 2PI))
|
||||
```
|
||||
|
||||
We see the expected answer for the area of a circle.
|
||||
@@ -458,9 +462,9 @@ Working symbolically, we have one arch given by the following described in a *cl
|
||||
|
||||
```julia; hold=true
|
||||
@syms t
|
||||
x = t - sin(t)
|
||||
y = 1 - cos(t)
|
||||
integrate(y * diff(x, t), (t, 0, 2PI))
|
||||
𝒙 = t - sin(t)
|
||||
𝒚 = 1 - cos(t)
|
||||
integrate(𝒚 * diff(𝒙, t), (t, 0, 2PI))
|
||||
```
|
||||
|
||||
([Galileo](https://mathshistory.st-andrews.ac.uk/Curves/Cycloid/) was thwarted in finding this answer exactly and resorted to constructing one from metal to *estimate* the value.)
|
||||
@@ -469,20 +473,24 @@ integrate(y * diff(x, t), (t, 0, 2PI))
|
||||
|
||||
Consider the example ``x(t) = \cos(t) + t\sin(t), y(t) = \sin(t) - t\cos(t)`` for ``0 \leq t \leq 2\pi``.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
x(t) = cos(t) + t*sin(t)
|
||||
y(t) = sin(t) - t*cos(t)
|
||||
ts = range(0,2pi, length=100)
|
||||
plot(x.(ts), y.(ts))
|
||||
```julia; echo=false
|
||||
let
|
||||
x(t) = cos(t) + t*sin(t)
|
||||
y(t) = sin(t) - t*cos(t)
|
||||
ts = range(0,2pi, length=100)
|
||||
plot(x.(ts), y.(ts))
|
||||
end
|
||||
```
|
||||
|
||||
How much area is enclosed by this curve and the ``x`` axis? The area is described in a counterclockwise manner, so we have:
|
||||
|
||||
```julia; hold=true
|
||||
x(t) = cos(t) + t*sin(t)
|
||||
y(t) = sin(t) - t*cos(t)
|
||||
yx′(t) = -y(t) * x'(t) # yx\prime[tab]
|
||||
quadgk(yx′, 0, 2pi)
|
||||
let
|
||||
x(t) = cos(t) + t*sin(t)
|
||||
y(t) = sin(t) - t*cos(t)
|
||||
yx′(t) = -y(t) * x'(t) # yx\prime[tab]
|
||||
quadgk(yx′, 0, 2pi)
|
||||
end
|
||||
```
|
||||
|
||||
This particular problem could also have been done symbolically, but many curves will need to have a numeric approximation used.
|
||||
@@ -500,8 +508,8 @@ choices = [
|
||||
"``du=1/x dx \\quad v = x``",
|
||||
"``du=x\\log(x) dx\\quad v = 1``",
|
||||
"``du=1/x dx\\quad v = x^2/2``"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -514,8 +522,8 @@ choices = [
|
||||
"``du=\\csc(x) dx \\quad v=\\sec(x)^3 / 3``",
|
||||
"``du=\\tan(x) dx \\quad v=\\sec(x)\\tan(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -530,8 +538,8 @@ choices = [
|
||||
"``du=-e^{-x} dx \\quad v=-\\sin(x)``",
|
||||
"``du=\\sin(x)dx \\quad v=-e^{-x}``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -581,8 +589,8 @@ choices = [
|
||||
"``\\int (\\log(x))^{n+1}/(n+1) dx``",
|
||||
"``x(\\log(x))^n - \\int (\\log(x))^{n-1} dx``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -597,8 +605,8 @@ Consider the integral $\int x \cos(x) dx$. Which letter should be tried first?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["L", "I", "A", "T", "E"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
@@ -608,8 +616,8 @@ Consider the integral $\int x^2\log(x) dx$. Which letter should be tried first?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["L", "I", "A", "T", "E"]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
@@ -619,8 +627,8 @@ Consider the integral $\int x^2 \sin^{-1}(x) dx$. Which letter should be tried f
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["L", "I", "A", "T", "E"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -631,8 +639,8 @@ Consider the integral $\int e^x \sin(x) dx$. Which letter should be tried first?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["L", "I", "A", "T", "E"]
|
||||
ans = 4
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -644,6 +652,6 @@ choices = [
|
||||
"``x\\cos^{-1}(x)-\\sqrt{1 - x^2}``",
|
||||
"``x^2/2 \\cos^{-1}(x) - x\\sqrt{1-x^2}/4 - \\cos^{-1}(x)/4``",
|
||||
"``-\\sin^{-1}(x)``"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
@@ -98,10 +98,12 @@ Though not continuous, $f(x)$ is integrable as it contains only jumps. The integ
|
||||
What is the average value of the function $e^{-x}$ between $0$ and $\log(2)$?
|
||||
|
||||
```math
|
||||
\text{average} = \frac{1}{\log(2) - 0} \int_0^{\log(2)} e^{-x} dx
|
||||
= \frac{1}{\log(2)} (-e^{-x}) \big|_0^{\log(2)}
|
||||
= -\frac{1}{\log(2)} (\frac{1}{2} - 1)
|
||||
= \frac{1}{2\log(2)}.
|
||||
\begin{align*}
|
||||
\text{average} = \frac{1}{\log(2) - 0} \int_0^{\log(2)} e^{-x} dx\\
|
||||
&= \frac{1}{\log(2)} (-e^{-x}) \big|_0^{\log(2)}\\
|
||||
&= -\frac{1}{\log(2)} (\frac{1}{2} - 1)\\
|
||||
&= \frac{1}{2\log(2)}.
|
||||
\end{align*}
|
||||
```
|
||||
|
||||
Visualizing, we have
|
||||
@@ -214,8 +216,8 @@ choices = [
|
||||
"``\\int_0^t (v(0) + v(u))/2 du = v(0)/2\\cdot t + x(u)/2\\ \\big|_0^t``",
|
||||
"``(v(0) + v(t))/2 \\cdot \\int_0^t du = (v(0) + v(t))/2 \\cdot t``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -278,8 +280,8 @@ value of $g(x) = \lvert x \rvert$ over the interval $[0,1]$?
|
||||
choices = [
|
||||
L"That of $f(x) = x^{10}$.",
|
||||
L"That of $g(x) = \lvert x \rvert$."]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -297,8 +299,8 @@ choices = [
|
||||
]
|
||||
n1, _ = quadgk(x -> x^2 *(1-x)^3, 0, 1)
|
||||
n2, _ = quadgk(x -> x^3 *(1-x)^4, 0, 1)
|
||||
ans = 1 + (n1 < n2)
|
||||
radioq(choices, ans)
|
||||
answ = 1 + (n1 < n2)
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -324,8 +326,8 @@ choices = [
|
||||
L"Because the mean value theorem says this is $f(c) (x-a)$ for some $c$ and both terms are positive by the assumptions",
|
||||
"Because the definite integral is only defined for positive area, so it is always positive"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
* Explain why $F(x)$ is increasing.
|
||||
@@ -336,8 +338,8 @@ L"By the extreme value theorem, $F(x)$ must reach its maximum, hence it must inc
|
||||
L"By the intermediate value theorem, as $F(x) > 0$, it must be true that $F(x)$ is increasing",
|
||||
L"By the fundamental theorem of calculus, part I, $F'(x) = f(x) > 0$, hence $F(x)$ is increasing"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -354,6 +356,6 @@ choices = [
|
||||
L"The average of $f$",
|
||||
L"The exponential of the average of $\log(f)$"
|
||||
]
|
||||
ans = val1 > val2 ? 1 : 2
|
||||
radioq(choices, ans)
|
||||
answ = val1 > val2 ? 1 : 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
@@ -75,15 +75,10 @@ The value of this decomposition is that the terms $a_{ij}(x)/q_i(x)^j$
|
||||
each have an antiderivative, and so the sum of them will also have an
|
||||
antiderivative.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
|
||||
Many calculus texts will give some examples for finding a partial
|
||||
fraction decomposition. We push that work off to `SymPy`, as for all
|
||||
but the easiest cases - a few are in the problems - it can be a bit tedious.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
Many calculus texts will give some examples for finding a partial
|
||||
fraction decomposition. We push that work off to `SymPy`, as for all
|
||||
but the easiest cases - a few are in the problems - it can be a bit tedious.
|
||||
|
||||
In `SymPy`, the `apart` function will find the partial fraction
|
||||
decomposition when a factorization is available. For example, here we see $n_i$ terms for each power of
|
||||
@@ -418,8 +413,8 @@ choices = [
|
||||
L"The value $c$ is a removable singularity, so the integral will be identical.",
|
||||
L"The resulting function has an identical domain and is equivalent for all $x$."
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -431,8 +426,8 @@ choices = [
|
||||
L"The value $c$ is a removable singularity, so the integral will be identical.",
|
||||
L"The resulting function has an identical domain and is equivalent for all $x$."
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -444,8 +439,8 @@ choices = [
|
||||
L"The value $c$ is a removable singularity, so the integral will be identical.",
|
||||
L"The resulting function has an identical domain and is equivalent for all $x$."
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -247,8 +247,12 @@ But $u^3/3 - 4u/3 = (1/3) \cdot u(u-1)(u+2)$, so between $-2$ and $0$
|
||||
it is positive and between $0$ and $1$ negative, so this integral is:
|
||||
|
||||
```math
|
||||
\int_{-2}^0 (u^3/3 - 4u/3 ) du + \int_{0}^1 -(u^3/3 - 4u/3) du =
|
||||
(\frac{u^4}{12} - \frac{4}{3}\frac{u^2}{2}) \big|_{-2}^0 - (\frac{u^4}{12} - \frac{4}{3}\frac{u^2}{2}) \big|_{0}^1 = \frac{4}{3} - -\frac{7}{12} = \frac{23}{12}.
|
||||
\begin{align*}
|
||||
\int_{-2}^0 (u^3/3 - 4u/3 ) du + \int_{0}^1 -(u^3/3 - 4u/3) du
|
||||
&= (\frac{u^4}{12} - \frac{4}{3}\frac{u^2}{2}) \big|_{-2}^0 - (\frac{u^4}{12} - \frac{4}{3}\frac{u^2}{2}) \big|_{0}^1\\
|
||||
&= \frac{4}{3} - -\frac{7}{12}\\
|
||||
&= \frac{23}{12}.
|
||||
\end{align*}
|
||||
```
|
||||
|
||||
##### Example
|
||||
@@ -400,13 +404,11 @@ Finally, we put back in the `u(x)` to get an antiderivative.
|
||||
ex₃(w => u(x))
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
Lest it be thought this is an issue with `SymPy`, but not other
|
||||
systems, this example was [borrowed](http://faculty.uml.edu/jpropp/142/Integration.pdf) from an
|
||||
illustration for helping Mathematica.
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
Lest it be thought this is an issue with `SymPy`, but not other
|
||||
systems, this example was [borrowed](http://faculty.uml.edu/jpropp/142/Integration.pdf) from an
|
||||
illustration for helping Mathematica.
|
||||
|
||||
|
||||
## Trigonometric substitution
|
||||
|
||||
@@ -563,8 +565,8 @@ choices = [
|
||||
"``\\int u (1 - u^2) du``",
|
||||
"``\\int u \\cos(x) du``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -578,8 +580,8 @@ choices = [
|
||||
"``u=\\sec(x)``",
|
||||
"``u=\\sec(x)^2``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -593,8 +595,8 @@ choices = [
|
||||
"``u=\\sqrt{x^2 - 1}``",
|
||||
"``u=x``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
###### Question
|
||||
|
||||
@@ -620,8 +622,8 @@ choices = [
|
||||
"``\\int u du``",
|
||||
"``\\int u^3/x du``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
###### Question
|
||||
|
||||
@@ -633,8 +635,8 @@ choices = [
|
||||
"``u=\\sin(x)``",
|
||||
"``u=\\tan(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -654,8 +656,8 @@ choices = [
|
||||
"``a=0,~ b=0``",
|
||||
"``a=1,~ b=1``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -669,8 +671,8 @@ choices = [
|
||||
"``\\sec(u) = x``",
|
||||
"``u = 1 - x^2``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -684,8 +686,8 @@ choices = [
|
||||
"``\\tan(u) = x``",
|
||||
"``\\sec(u) = x``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -699,8 +701,8 @@ choices = [
|
||||
"``\\sec(u) = x``",
|
||||
"``u = 1 - x^2``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -715,8 +717,8 @@ choices = [
|
||||
"``\\sec(u) = x``",
|
||||
"``4\\sin(u) = x``",
|
||||
"``\\sin(u) = x``"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -730,8 +732,8 @@ choices = [
|
||||
"``\\tan(u) = x``",
|
||||
"``a\\sec(u) = x``",
|
||||
"``\\sec(u) = x``"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -751,8 +753,8 @@ choices =[
|
||||
"``a=\\pi/3,~ b=\\pi/2``",
|
||||
"``a=1/2,~ b= 1``"
|
||||
]
|
||||
ans =1
|
||||
radioq(choices, ans)
|
||||
answ =1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -763,6 +765,6 @@ How would we verify that $\log\lvert (\sec(u) + \tan(u))\rvert$ is an antideriva
|
||||
choices = [
|
||||
L"We could differentiate $\sec(u)$.",
|
||||
L"We could differentiate $\log\lvert (\sec(u) + \tan(u))\rvert$ "]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@ const frontmatter = (
|
||||
description = "Calculus with Julia: Surface Area",
|
||||
tags = ["CalculusWithJulia", "integrals", "surface area"],
|
||||
);
|
||||
fig_size=(600, 400)
|
||||
fig_size=(800, 600)
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -174,11 +174,13 @@ formula, even though we just saw how to get this value.
|
||||
A cone be be envisioned as rotating the function $f(x) = x\tan(\theta)$ between $0$ and $h$ around the $x$ axis. This integral yields the surface area:
|
||||
|
||||
```math
|
||||
\begin{align*}
|
||||
\int_0^h 2\pi f(x) \sqrt{1 + f'(x)^2}dx
|
||||
= \int_0^h 2\pi x \tan(\theta) \sqrt{1 + \tan(\theta)^2}dx
|
||||
= (2\pi\tan(\theta)\sqrt{1 + \tan(\theta)^2} x^2/2 \big|_0^h
|
||||
= \pi \tan(\theta) \sec(\theta) h^2
|
||||
= \pi r^2 / \sin(\theta).
|
||||
&= \int_0^h 2\pi x \tan(\theta) \sqrt{1 + \tan(\theta)^2}dx \\
|
||||
&= (2\pi\tan(\theta)\sqrt{1 + \tan(\theta)^2} x^2/2 \big|_0^h \\
|
||||
&= \pi \tan(\theta) \sec(\theta) h^2 \\
|
||||
&= \pi r^2 / \sin(\theta).
|
||||
\end{align*}
|
||||
```
|
||||
|
||||
(There are many ways to express this, we used $r$ and $\theta$ to
|
||||
@@ -449,8 +451,8 @@ choices = [
|
||||
"``-\\int_1^{_1} 2\\pi u \\sqrt{1 + u^2} du``",
|
||||
"``-\\int_1^{_1} 2\\pi u^2 \\sqrt{1 + u} du``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
Though the integral can be computed by hand, give a numeric value.
|
||||
@@ -506,8 +508,8 @@ choices = [
|
||||
"``\\int_u^{u_h} 2\\pi y dx``",
|
||||
"``\\int_u^{u_h} 2\\pi x dx``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
##### Questions
|
||||
|
||||
@@ -105,13 +105,8 @@ area is $\pi r(x)^2$ so the volume is given by:
|
||||
V = \int_a^b \pi r(x)^2 dx.
|
||||
```
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
The formula is for a rotation around the $x$-axis, but can easily be generalized to rotating around any line (say the $y$-axis or $y=x$, ...) just by adjusting what $r(x)$ is taken to be.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The formula is for a rotation around the $x$-axis, but can easily be generalized to rotating around any line (say the $y$-axis or $y=x$, ...) just by adjusting what $r(x)$ is taken to be.
|
||||
|
||||
|
||||
For a numeric example, we consider the original Red
|
||||
@@ -136,8 +131,8 @@ This is
|
||||
|
||||
```julia;
|
||||
d0, d1, h = 2.5, 3.75, 4.75
|
||||
r(x) = d0/2 + (d1/2 - d0/2)/h * x
|
||||
vol, _ = quadgk(x -> pi * r(x)^2, 0, h)
|
||||
rad(x) = d0/2 + (d1/2 - d0/2)/h * x
|
||||
vol, _ = quadgk(x -> pi * rad(x)^2, 0, h)
|
||||
```
|
||||
|
||||
So $36.9 \text{in}^3$. How many ounces is that? It is useful to know
|
||||
@@ -178,7 +173,7 @@ So we need to solve $v \cdot (231/128) = \int_0^h\pi r(x)^2 dx$ for $h$ when $v=
|
||||
Let's express volume as a function of $h$:
|
||||
|
||||
```julia;
|
||||
Vol(h) = quadgk(x -> pi * r(x)^2, 0, h)[1]
|
||||
Vol(h) = quadgk(x -> pi * rad(x)^2, 0, h)[1]
|
||||
```
|
||||
|
||||
Then to solve we have:
|
||||
@@ -201,12 +196,8 @@ As a percentage of the total height, these are:
|
||||
h5/h, h12/h
|
||||
```
|
||||
|
||||
```julia;echo=false
|
||||
note("""
|
||||
Were performance at issue, Newton's method might also have been considered here, as the derivative is easily computed by the fundamental theorem of calculus.
|
||||
""")
|
||||
```
|
||||
|
||||
!!! note
|
||||
Were performance at issue, Newton's method might also have been considered here, as the derivative is easily computed by the fundamental theorem of calculus.
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -239,16 +230,11 @@ quadgk(x -> pi*radius(x)^2, 1, Inf)[1]
|
||||
|
||||
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$.
|
||||
|
||||
```julia; echo=false
|
||||
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.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! 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.
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -668,8 +654,8 @@ choices = [
|
||||
"``1/3 \\cdot w^2\\cdot h``",
|
||||
"``l\\cdot w \\cdot h/ 3``"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -696,8 +682,8 @@ choices = [
|
||||
"``4/3 \\cdot \\pi a^2 b``",
|
||||
"``\\pi/3 \\cdot a b^2``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -752,9 +738,9 @@ Find the volume of rotating the region bounded by the line $y=x$, $x=1$ and the
|
||||
```julia; hold=true; echo=false
|
||||
cm=[2/3, 1/3]
|
||||
c = [1/2, 1/2]
|
||||
r = norm(cm - c)
|
||||
rr = norm(cm - c)
|
||||
A = 1/2 * 1 * 1
|
||||
val = 2pi*r*A
|
||||
val = 2pi * rr * A
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user