many edits

This commit is contained in:
jverzani
2024-04-26 18:26:12 -04:00
parent 6e807edb46
commit 4f924557ad
45 changed files with 326 additions and 296 deletions

View File

@@ -69,7 +69,7 @@ $$
It has the interpretation of pointing out the direction of greatest ascent for the surface $z=f(x,y)$.
We move now to two other operations, the divergence and the curl, which combine to give a language to describe vector fields in $R^3$.
We move now to two other operations, the *divergence* and the *curl*, which combine to give a language to describe vector fields in $R^3$.
## The divergence
@@ -680,7 +680,7 @@ V(v) = V(v...)
p = plot([NaN],[NaN],[NaN], legend=false)
ys = xs = range(-2,2, length=10 )
zs = range(0, 4, length=3)
CalculusWithJulia.vectorfieldplot3d!(p, V, xs, ys, zs, nz=3)
vectorfieldplot3d!(p, V, xs, ys, zs, nz=3)
plot!(p, [0,0], [0,0],[-1,5], linewidth=3)
p
```

View File

@@ -210,8 +210,8 @@ Identifying a formula for this is a bit tricky. Here we use a brute force approa
```{julia}
𝒅(x, y) = sqrt(x^2 + y^2)
function 𝒍(x, y, a)
d(x, y) = sqrt(x^2 + y^2)
function l(x, y, a)
theta = atan(y,x)
atheta = abs(theta)
if (pi/4 <= atheta < 3pi/4) # this is the y=a or y=-a case
@@ -226,10 +226,10 @@ And then
```{julia}
𝒇(x,y,a,h) = h * (𝒍(x,y,a) - 𝒅(x,y))/𝒍(x,y,a)
f(x,y,a,h) = h * (l(x,y,a) - d(x,y))/l(x,y,a)
𝒂, 𝒉 = 2, 3
𝒇(x,y) = 𝒇(x, y, 𝒂, 𝒉) # fix a and h
𝒇(v) = 𝒇(v...)
f(x,y) = f(x, y, 𝒂, 𝒉) # fix a and h
f(v) = f(v...)
```
We can visualize the volume to be computed, as follows:
@@ -238,14 +238,14 @@ We can visualize the volume to be computed, as follows:
```{julia}
#| hold: true
xs = ys = range(-1, 1, length=20)
surface(xs, ys, 𝒇)
surface(xs, ys, f)
```
Trying this, we have:
```{julia}
hcubature(𝒇, (-𝒂/2, -𝒂/2), (𝒂/2, 𝒂/2))
hcubature(f, (-𝒂/2, -𝒂/2), (𝒂/2, 𝒂/2))
```
The answer agrees with that known from the formula, $4 = (1/3)a^2 h$, but the answer takes a long time to be produce. The `hcubature` function is slow with functions defined in terms of conditions. For this problem, volumes by [slicing](../integrals/volumes_slice.html) is more direct. But also symmetry can be used, were we able to compute the volume above the triangular region formed by the $x$-axis, the line $x=a/2$ and the line $y=x$, which would be $1/8$th the total volume. (As then $l(x,y,a) = (a/2)/\sin(\tan^{-1}(y,x))$.).
@@ -691,8 +691,7 @@ The computationally efficient way to perform multiple integrals numerically woul
However, for simple problems, where ease of expressing a region is preferred to computational efficiency, something can be implemented using repeated uses of `quadgk`. Again, this isn't recommended, save for its relationship to how iteration is approached algebraically.
In the `CalculusWithJulia` package, the `fubini` function is provided. For these notes, we define three operations using Unicode operators entered with `\int[tab]`, `\iint[tab]`, `\iiint[tab]`. (Using this, better shows the mechanics involved.)
For these notes, we define three operations using Unicode operators entered with `\int[tab]`, `\iint[tab]`, `\iiint[tab]`.
```{julia}
# adjust endpoints when expressed as a functions of outer variables
@@ -1404,11 +1403,11 @@ partition(u,v) = [ u^2-v^2, u*v ]
push!(ps, showG(partition))
xlabel!(ps[end], "partition")
l = @layout [a b c;
lyt = @layout [a b c;
d e f;
g h i]
plot(ps..., layout=l)
plot(ps..., layout=lyt)
```
### Examples

View File

@@ -906,8 +906,8 @@ Let $S$ be the closed surface bounded by the cylinder $x^2 + y^2 = 1$, the plane
```{julia}
𝐅(x,y,z) = [1, y, z]
𝐅(v) = 𝐅(v...)
F(x,y,z) = [1, y, z]
F(v) = F(v...)
```
The surface has three faces, with different outward pointing normals for each. Let $S_1$ be the unit disk in the $x-y$ plane with normal $-\hat{k}$; $S_2$ be the top part, with normal $\langle-1, 0, 1\rangle$ (as the plane is $-1x + 0y + 1z = 1$); and $S_3$ be the cylindrical part with outward pointing normal $\vec{r}$.
@@ -917,32 +917,32 @@ Integrating over $S_1$, we have the parameterization $\Phi(r,\theta) = \langle r
```{julia}
@syms 𝐑::positive 𝐭heta::positive
𝐏hi₁(r,theta) = [r*cos(theta), r*sin(theta), 0]
𝐉ac₁ = 𝐏hi₁(𝐑, 𝐭heta).jacobian([𝐑, 𝐭heta])
𝐯₁, 𝐰₁ = 𝐉ac₁[:,1], 𝐉ac₁[:,2]
𝐍ormal₁ = 𝐯× 𝐰₁ .|> simplify
@syms R::positive theta::positive
Phi₁(r,theta) = [r*cos(theta), r*sin(theta), 0]
Jac₁ = Phi₁(R, theta).jacobian([R, theta])
v₁, w₁ = Jac₁[:,1], Jac₁[:,2]
𝐍ormal₁ = v× w₁ .|> simplify
```
```{julia}
A₁ = integrate(𝐅(𝐏hi₁(𝐑, 𝐭heta)) ⋅ (-𝐍ormal₁), (𝐭heta, 0, 2PI), (𝐑, 0, 1)) # use -Normal for outward pointing
A₁ = integrate(F(Phi₁(R, theta)) ⋅ (-𝐍ormal₁), (theta, 0, 2PI), (R, 0, 1)) # use -Normal for outward pointing
```
Integrating over $S_2$ we use the parameterization $\Phi(r, \theta) = \langle r\cos(\theta), r\sin(\theta), 1 + r\cos(\theta)\rangle$.
```{julia}
𝐏hi₂(r, theta) = [r*cos(theta), r*sin(theta), 1 + r*cos(theta)]
𝐉ac₂ = 𝐏hi₂(𝐑, 𝐭heta).jacobian([𝐑, 𝐭heta])
𝐯₂, 𝐰₂ = 𝐉ac₂[:,1], 𝐉ac₂[:,2]
𝐍ormal₂ = 𝐯× 𝐰₂ .|> simplify # has correct orientation
Phi₂(r, theta) = [r*cos(theta), r*sin(theta), 1 + r*cos(theta)]
Jac₂ = Phi₂(R, theta).jacobian([R, theta])
v₂, w₂ = Jac₂[:,1], Jac₂[:,2]
Normal₂ = v× w₂ .|> simplify # has correct orientation
```
With this, the contribution for $S_2$ is:
```{julia}
A₂ = integrate(𝐅(𝐏hi₂(𝐑, 𝐭heta)) ⋅ (𝐍ormal₂), (𝐭heta, 0, 2PI), (𝐑, 0, 1))
A₂ = integrate(F(Phi₂(R, theta)) ⋅ (Normal₂), (theta, 0, 2PI), (R, 0, 1))
```
Finally for $S_3$, the parameterization used is $\Phi(z, \theta) = \langle \cos(\theta), \sin(\theta), z\rangle$, but this is over a non-rectangular region, as $z$ is between $0$ and $1 + x$.
@@ -953,17 +953,17 @@ This parameterization gives a normal computed through:
```{julia}
@syms 𝐳::positive
𝐏hi₃(z, theta) = [cos(theta), sin(theta), 𝐳]
𝐉ac₃ = 𝐏hi₃(𝐳, 𝐭heta).jacobian([𝐳, 𝐭heta])
𝐯₃, 𝐰₃ = 𝐉ac₃[:,1], 𝐉ac₃[:,2]
𝐍ormal₃ = 𝐯× 𝐰₃ .|> simplify # wrong orientation, so we change sign below
Phi₃(z, theta) = [cos(theta), sin(theta), 𝐳]
Jac₃ = Phi₃(𝐳, theta).jacobian([𝐳, theta])
v₃, w₃ = Jac₃[:,1], Jac₃[:,2]
Normal₃ = v× w₃ .|> simplify # wrong orientation, so we change sign below
```
The contribution is
```{julia}
A₃ = integrate(𝐅(𝐏hi₃(𝐳, 𝐭heta)) ⋅ (-𝐍ormal₃), (𝐳, 0, 1 + cos(𝐭heta)), (𝐭heta, 0, 2PI))
A₃ = integrate(F(Phi₃(𝐳, theta)) ⋅ (-Normal₃), (𝐳, 0, 1 + cos(theta)), (theta, 0, 2PI))
```
In total, the surface integral is

View File

@@ -685,7 +685,6 @@ The constant $A$ just sets the scale, the parameter $n$ has a qualitative effect
```{julia}
#| hold: true
gr() # pyplot doesn't like the color as specified below.
n = 2
f(r,theta) = r^n * cos(n*theta)
g(r, theta) = r^n * sin(n*theta)
@@ -698,7 +697,6 @@ f(v) = f(v...); g(v)= g(v...)
xs = ys = range(-2,2, length=50)
p = contour(xs, ys, f∘Φ, color=:red, legend=false, aspect_ratio=:equal)
contour!(p, xs, ys, g∘Φ, color=:blue, linewidth=3)
#pyplot()
p
```