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

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