volume of a sphere

Thread Starter

JasonL

Joined Jul 1, 2011
47
Because they are parallel to this plane they are independent of y and z so you can substitute the values into the inequalities defining the limits for x.

Can you follow this on your sketch and see where these planes cut the hemisphere?

You should then be able to do the same for the one plane that is specified parallel to the xy plane. This means that there is no cutting limit on the part of the figure that lies on the negative z axis.

So can you see what the end result on the inequalties defining the limits for z is?
Cutting the hemisphere with x=1 and x=-1. X ranges from -1 to 1. Z ranges from -4 to 4, and Y ranges from -4 to 0.

Cutting it with z=2. Z ranges from -4 to 2.

So if i had to integrate where
-1\(\leq\)x\(\leq\)1
-4\(\leq\)z\(\leq\)4
-4\(\leq\)y\(\leq\)0
with dxdydz
I would get the wrong answer because the answer posted is 40.44 units^3
 

studiot

Joined Nov 9, 2007
4,998
So

-4< z < 2 (not 4 as you have put).

However remember the first line of my post#2?
You have some more work to do.

∫ integral f(x,y,z) dV ie the volume integral is equal to ∫∫∫ f(x,y,z) dxdydz.

I need to knock off for the night so I will leave you to check your notes about evaluating triple integrals
 

WBahn

Joined Mar 31, 2012
33,201
Cutting the hemisphere with x=1 and x=-1. X ranges from -1 to 1. Z ranges from -4 to 4, and Y ranges from -4 to 0.

Cutting it with z=2. Z ranges from -4 to 2.

So if i had to integrate where
-1\(\leq\)x\(\leq\)1
-4\(\leq\)z\(\leq\)4
-4\(\leq\)y\(\leq\)0
with dxdydz
I would get the wrong answer because the answer posted is 40.44 units^3
If you use these limits (the ones you discussed, not the ones you specifically list because you appear to have a typo concerning the upper bound on z) you will get 48 cubic units because this is the volume of a cube that is 2 units in the x, 6 units in the z, and four units in the y.

You walked straight into the trap I specifically warned about in Post #18.

The variable x does NOT range from -1 units to 1 unit over the entire space of the integration! With z=0, if y is greater than ~3.87 units, then the x bounds on the volume are not set by the slicing planes, but by the sphere!

Similarly, the ONLY place where y ranges all the way up to 4 units is directly above the original. Anywhere else and its upper limit is less than that.

Basically, you get to pick one axis and set the limits of integration to be the overall range of that variable. Using that as your outer integral, you then need to set bounds on one of the other axis variables that are a function of the outer axis variable. Finally, you have to set limits on the inner axis variable that are a function of the outer two axis variables.

Think of it as the outer most integral is summing up a bunch of thin slices of the volume. The middle integral is summing up a bunch of strips within one of those slices. The inner integral is summing up a bunch of infinitisimal cubes within one of those strips.
 

wayneh

Joined Sep 9, 2010
18,168
I've done a lot of triple integrals in my life, first in academia and then - amazingly - at work. (I say amazingly, because it makes you a 1 in a 1000 employee, at least, if you even know what a triple integral IS, let alone how to apply and solve one.)

My 2¢ advice is to be extremely wary of integration limits and symmetry. In single integration of a sine wave, for instance, it's easy to calculate an area under the curve of zero if you use the "wrong" limits. The same thing can happen in 3D. If there's a systematic way to avoid this problem, I was never taught the trick.
 

WBahn

Joined Mar 31, 2012
33,201
I think the "systematic" way is to carefully delineate where the transitions are between the different surfaces using inequalities.

If you are doing it numerically, you can brute force it by ensuring that the limits completely enclose a volume that completely includes the volume of interest and then integrate a function that is 1 if the point is within the object and 0 if it is outside the object.
 

wayneh

Joined Sep 9, 2010
18,168
I guess "systematic" was the wrong word. I meant "elegant and easy" as opposed to "brute force, keep checking yourself, easy to get confused" approach.
 

WBahn

Joined Mar 31, 2012
33,201
Out of curiosity I through together a quick Python numerical integrator and with a differential volume that gave me a runtime of about five minutes I got a result that I think is probably within about 0.1 cubic units. That result is 39.78 cubic units. How does that compare with what The Electrician got?

My best estimate is that, to get an accuracy under 0.01 cubic units that it would take my brute force program about 80 hours of run time (three to four days).

I'm gonna spend a few minutes smartening it up and see what I can get.
 

WBahn

Joined Mar 31, 2012
33,201
By eliminating my innermost loop with a computation I reduced the runtime with the same differential volume to under 2.5 seconds. I got a result of 39.75 cubic units, which is well within the error estimate I had from the prior result.

Since my algorithm is now O(n^2) instead of O(n^3), I not only pick up the factor of 60 increase, but now increasing n by a factor of ten will only increase the runtime by about a factor of 100. So it should now run in about 4 minutes to get an accuracy of about 0.01 cubic units.

We'll see what it throws out.
 

WBahn

Joined Mar 31, 2012
33,201
How, it only took a minute. But I also removed a print statement from my outer loop that I was using to gauge how fast it was progressing.

The result is 39.7599 cubic units. I think this should be good to about 0.01 cubic units.

I had earlier done a run that should have been good to about 0.02 cubic units and got a result of 39.7409 cubic units. That right at the edge of agreement with the result above and it is an error the opposite direction from prior results. So, assuming that it is converging on the correct answer, it is not doing so monotonically. I guess I'm not really surprised by that because of how I'm handling the limits on the outer loop.

I've got a run going now that should be within about 0.002 cubic units. It will likely take an hour to finish.
 

WBahn

Joined Mar 31, 2012
33,201
While I'm waiting for that run to finish, I decided to see if I can put reasonably tight bounds on the answer.

If we look down the x axis and assume we have a cylinder instead of a sphere along that axis, the we just need to find the area of the face and multiply that by the 2 unit height in the x direction. For an upper limit, we can just use a cylinder of radius 4. We see that we have a full quarter quadrant plus a bit to the left of the z-axis. We can draw a line from the origin to the point (0,y,-2), where y is where the z=-2 plane intersects the surface, which is at y = √[R^2-(2 units)^2] and split this area into two parts. The left part of this is simply a triangle while the right part is just a circular arc. The arc subtends an angle that we can find by taking the arcsin of (2 units)/R. This gives us volume of

\(
V \, = \, (2\ units) \[ \frac{\pi R^2}{4} \, + \, \frac{1}{2}(2\ units)\sqrt{R^2-(2\ units)^2} \, + \, \pi R^2 \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

You can pull out the area of the cylinder face and get

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi}(2\ units)\sqrt{1- \( \frac{2\ units^2}{R} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

Using R = 4 units, you get an upper bound of 40.43852 cubic units.

If you go to x=1 units, then you get R=3.872983 units, which results in lower bound of 3.872983 cubic units.

If we use as our best estimate the radius at x=0.5 units, we get a volume of 39.84 cubic units.
 

WBahn

Joined Mar 31, 2012
33,201
So it took less time that I estimated, but it produced a result of 39.7428 cubic units.

I then eliminated the inner loop with a computed area and now it runs very quickly. These are the results I get as I decrease dx:

dx (units)|vol (units^3)
0.1|40.440941450
0.01|40.440472205
0.001|40.440428261
0.0001|40.440423897
0.00001|40.440423461
0.000001|40.440423417
0.0000001|40.4404233422

This appears to not only be converging, but doing so monitonically up until the last result, which may indicate that I am now into the sig fig roundoff noise. Since a double gives you about 16 sig figs and I am doing 10 million iterations, I would expect to get a result that is limits to about 9 or 10 sig figs. This agrees nicely with where the noise appears to be.

It also agrees with the given value very nicely.

Normally I would be very happy to accept this result. However, this is why I try to do bounds estimates. This is actually just a tad larger than what I computed the upper bound to be and I don't think I made a mistake in that bounds calculation so I need to reject it based on that alone. I also expect the result to be closer to my best estimate than to the upper bound.

So I am introducing some kind of a systematic error somewhere.
 

WBahn

Joined Mar 31, 2012
33,201
Turns out that there is a closed form result:

I would definitely expect there to be a closed form solution, since it was given as a problem in a calc course. But it involves trig substitutions and I'm just too lazy to delve into it.

I see that my last result that involved two integrals produced a result that is within about 0.004 cubic units of the correct value. I was estimating that my numeric integration should put it within about 0.002 but this number actually came from estimating the total surface area of the volume, multiplying that by the differential thickness I was using and then dividing that by two figuring that I would be somewhere in the middle. In hindsight, I can see that I would expect to overestimate by about that much, too.
 

WBahn

Joined Mar 31, 2012
33,201
So I no sooner than got into bed and it hit me what I had probably done wrong in my final program. Sure enough, I was right. Here are the new results:


dx (units)|vol (units^3)
0.1|39.629733065
0.01|39.727988670
0.001|39.737490389
0.0001|39.738437423
0.00001|39.738532095
0.000001|39.738541561
0.0000001|39.738542518
0.00000001|39.738542513

So I would say that I am again in the roundoff noise at about 9 or 10 sig figs. Notice that I agree with The Electrician's result to 9 sig figs ±1 digit. So I think I can say I got it right.

It pays to estimate the result and ask if the answer makes sense. But I sure have a hard time getting anyone to believe me on that.
 

WBahn

Joined Mar 31, 2012
33,201
Oh, and it's also pretty obvious the mistake that whoever came up with the 40.44 cubic unit answer made. They failed to take into account that the radius perpendicular to the x-axis decreases as you move away from the yz-plane. It's very possible they did this by making the same mistake I warned against in Post #8, because I think that would cause it (and that is pretty much the inadvertent mistake I made in my program, but it wasn't because I didn't know better, it's because I had a typo).
 
While I'm waiting for that run to finish, I decided to see if I can put reasonably tight bounds on the answer.

If we look down the x axis and assume we have a cylinder instead of a sphere along that axis, the we just need to find the area of the face and multiply that by the 2 unit height in the x direction. For an upper limit, we can just use a cylinder of radius 4. We see that we have a full quarter quadrant plus a bit to the left of the z-axis. We can draw a line from the origin to the point (0,y,-2), where y is where the z=-2 plane intersects the surface, which is at y = √[R^2-(2 units)^2] and split this area into two parts. The left part of this is simply a triangle while the right part is just a circular arc. The arc subtends an angle that we can find by taking the arcsin of (2 units)/R. This gives us volume of

\(
V \, = \, (2\ units) \[ \frac{\pi R^2}{4} \, + \, \frac{1}{2}(2\ units)\sqrt{R^2-(2\ units)^2} \, + \, \pi R^2 \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

You can pull out the area of the cylinder face and get

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi}(2\ units)\sqrt{1- \( \frac{2\ units^2}{R} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

Using R = 4 units, you get an upper bound of 40.43852 cubic units.

If you go to x=1 units, then you get R=3.872983 units, which results in lower bound of 3.872983 cubic units.

If we use as our best estimate the radius at x=0.5 units, we get a volume of 39.84 cubic units.
I can tell that you (like me) stayed up late; you should have (inside the square root):

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi}(2\ units)\sqrt{\frac{1}{R^2}- \( \frac{2\ units^2}{R^2} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

Also, you should have:

"If you go to x=1 units, then you get R=3.872983 units, which results in lower bound of 38.334775 cubic units."
 

tracecom

Joined Apr 16, 2010
3,944
I can tell that you (like me) stayed up late; you should have (inside the square root):

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi}(2\ units)\sqrt{\frac{1}{R^2}- \( \frac{2\ units^2}{R^2} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

Also, you should have:

"If you go to x=1 units, then you get R=3.872983 units, which results in lower bound of 38.334775 cubic units."
I think you should change your user name to The Mathematician. :)
 

WBahn

Joined Mar 31, 2012
33,201
I can tell that you (like me) stayed up late; you should have (inside the square root):

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi}(2\ units)\sqrt{\frac{1}{R^2}- \( \frac{2\ units^2}{R^2} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)
Good catch - I had a typo (an exponent that was supposed to be taken outside the radical and ended up in both places) and a brain fart when I checked my units (which I did do, I just screwed up mentally in doing so).

I meant to put

\(
V \, = \, (2\ units)(\pi R^2) \[ \frac{1}{4} \, + \, \frac{1}{2\pi} \( \frac{2\ units}{R} \) \sqrt{1 \, - \, \( \frac{2\ units}{R} \)^2} \, + \, \frac{sin^{-1} \( \frac{2\ units}{R} \) }{2\pi} \]
\)

Also, you should have:

"If you go to x=1 units, then you get R=3.872983 units, which results in lower bound of 38.334775 cubic units."
I copied the radius instead of the volume (which was immediately below it in my little spreadsheet). But I get 38.02609 cubic units. Note that my spreadsheet is building up the pieces separately more along the lines of the first equation, so while it may have an error, it is independent of any errors in the second equation above. I'll look at things closer this evening to resolve the discrepancy.
 
Top