use quarto, not Pluto to render pages

This commit is contained in:
jverzani
2022-07-24 16:38:24 -04:00
parent 93c993206a
commit 7b37ca828c
879 changed files with 793311 additions and 2678 deletions

View File

@@ -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)
```