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.
So $36.9 \text{in}^3$. How many ounces is that? It is useful to know
that 1 [gallon](http://en.wikipedia.org/wiki/Gallon) of water is
defined as $231$ cubic inches, contains $128$ ounces, and weighs $8.34$
pounds.
So our cup holds this many ounces:
```julia;
ozs = vol / 231 * 128
```
Full it is about $20$ ounces, though this doesn't really account for the volume taken up by the bottom of the cup, etc.
If you are poor with units, `Julia` can provide some help through the `Unitful` package. Here the additional `UnitfulUS` package must also be included, as was done above, to access fluid ounces:
```julia
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.
```julia; hold=true; echo=false
imgfile = "figures/red-solo-cup.jpg"
caption = "Markings on the red Solo cup indicated various volumes"
ImageFile(:integrals, imgfile, caption)
```
What is the height for $5$ ounces (for a glass of wine)? $12$ ounces (for a beer unit)?
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$.
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.
By rotating the line segment $x/r + y/h=1$ that sits in the first
quadrant around the $y$ axis, we will generate a right-circular
cone. The volume of which can be expressed through the above formula
by noting the radius, as a function of $y$, will be $R = r(1 -
y/h)$. This gives the well-known volume of a cone:
```julia; hold=true
@syms r h x y
R = r*(1 - y/h)
integrate(pi*R^2, (y, 0, h))
```
The frustum of a cone is simply viewed as a cone with its top cut off. If the original height would have been $h_0$ and the actual height $h_1$, then the volume remaining is just $\int_{h_0}^h \pi r(y)^2 dy = \pi h_1 r^2/3 - \pi h_0 r^2/3 = \pi r^2 (h_1-h_0)/3$.
It is not unusual to parameterize a cone by the angle $\theta$ it
makes and the height. Since $r/h=\tan\theta$, this gives the formula
$V = \pi/3\cdot h^3\tan(\theta)^2$.
##### 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?"
```julia;
radius(x) = 1/x
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$.
A liter of volume is $1000 \text{cm}^3$. So this is about $68$ liters, or more than 15
gallons. Perhaps the dimensions given were bit off.
While we are here, to compute the actual volume of the material in the vase could be done by subtraction.
```julia;
Vₜ - V_int
```
### The washer method
Returning to the Michelin Man, in our initial back-of-the-envelope calculation we didn't account for the fact that a tire isn't a disc, as it has its center cut out. Returning, suppose $R_i$ is the outer radius and $r_i$ the inner radius. Then each tire has volume
section. Suppose the dimensions are the same: a top diameter of $d_1 =
3 3/4$ inches, a bottom diameter of $d_0 = 2 1/2$ inches and a height
of $h = 4 3/4$ inches. What is the volume now?
The difference, of course, is that cross sections now have area $d^2$, as opposed to $\pi r^2$. This leads to some difference, which we quantify, as follows:
```julia; hold=true
d0, d1, h = 2.5, 3.75, 4.75
d(x) = d0 + (d1 - d0)/h * x
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?
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
For a general cone, we use this [definition](http://en.wikipedia.org/wiki/Cone):
> A cone is the solid figure bounded by a base in a plane and by a
> surface (called the lateral surface) formed by the locus of all
> straight line segments joining the apex to the perimeter of the
> base.
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.
The small orange line is rotated, so using the washer method we get the cross sections given by $\pi(r_0^2 - r_i^2)$, the outer and inner radii, as a function of $y$.
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.
A right [pyramid](http://en.wikipedia.org/wiki/Pyramid_%28geometry%29) has its apex (top point) above the centroid of its base, and for our purposes, each of its cross sections. Suppose a pyramid has square base of dimension $w$ and height of dimension $h$.
Rotate the region bounded by $y=e^x$, the line $x=\log(2)$ and the first quadrant about the line $x=\log(2)$.
(Be careful, the radius in the formula $V=\int_a^b \pi r(u)^2 du$ is from the line $x=\log(2)$.)
```julia; hold=true; echo=false
a, b = 0, exp(log(2))
ra(y) = log(2) - log(y)
val, _ = quadgk(y -> pi * ra(y)^2, a, b)
numericq(val)
```
###### Question
Find the volume of rotating the region bounded by the line $y=x$, $x=1$ and the $x$-axis around the line $y=x$. (The Theorem of Pappus is convenient and the fact that the centroid of the triangular region lies at $(2/3, 1/3)$.)
Rotate the region bounded by the line $y=x$ and the function $f(x) = x^2$ about the line $y=x$. What is the resulting volume?
You can integrate in the length along the line $y=x$ ($u$ from $0$ to $\sqrt{2}$). The radius then can be found by intersecting the line perpendicular line to $y=x$ at $u$ to the curve $f(x)$. This will do so:
```julia;
theta = pi/4 ## we write y=x as y = x * tan(pi/4) for more generality, as this allows other slants.