When I have an area bounded by curves, is there a built-in way to find the center of the area? Or do I have to plot it first and then use ComponentMeasurements on it?
For example: the area under $y= 1-x^2/4$ and above the $x$ axis:

|
When I have an area bounded by curves, is there a built-in way to find the center of the area? Or do I have to plot it first and then use For example: the area under $y= 1-x^2/4$ and above the $x$ axis:
|
||||
| show 6 more comments |
|
This is inelegent for the specific example, but may be useful for more greneral cases:
The exact results for the example are by the way:
Edit: further explintion: we construct a logical function of x,y which is True inside your region and False otherwise, then perform area integrals over the entire plane using the definitions of area and centriod, and relying on the integrands to be zero outside the region of interest. As noted by Daniel in a comment that seems to have dissapeard(?) you can use the analytic Integrate function over the entire plane (+- Infinity):
This does need a bit of warning, Integrate[] fails for even slightly more complicated expressions, so NIntegrate[] is a bit safer (though it yields a numerical approximation). |
|||||||||||||||
|
|
I had previously used the following function as part of designing this site's logo, but I suppose it would be useful to explicitly have it as an answer to this question:
A test, using OP's example:
Pretty close for government work, I think. I exploited |
|||
|
|
|
I finally found the following, which I had done for someone who had wanted to find centroids of polygons, for which The math behind the following is based the ideas in @Jens hints. If you would like an explanation, ask and I will append one.
Beware: The sub-functions (Area, XMoment, XBar, etc.) assume that the argument is a list of the edges of a polygon ( As a test I loaded Italy and found its centroid:
It's the centroid of a "flat-earth" Italy, since no adjustment for spherical coordinates is made.
It's not too slow:
The method is exact on polygons; if one wants exact results,
Curves The function Graphs For the example proposed by @a3f, we can extract the plotted points of the graph with
The relative error of the y-coordinate is about $10^{-6}$.
If we compare with
The first is exact and the second is accurate to Parametric Curves I made up, at random, simple closed curve (picture down below),
and found that for 11000 plot points (no recursion), the
The x-coordinate of |
|||
|
|
|
Here's a more down-to-earth solution in Mathematica that's probably closer to your current level of mathematics study. Just directly use the usual one-dimensional integrals involved in finding plane area and centroids.
Of course there's no real need to calculate the x-coordinate, since by symmetry it must be 0. |
|||
|
|
|
This is a nice application of Stokes' theorem. In fact it could almost be a homework problem - I hope it isn't, so I'll give only the first steps: Observe the following results:
Now think about the surface integrals involved in the calculation: one is simply the area, i.e. its integrand is But since you're given the curves bounding the area, you would be better off writing the area integrations as line integrals along the bounding curves. This is where Stokes' theorem comes in, combined with the above results. The rest should be left for you to complete. This method, once you've written it down, will have the added advantage that it can give you the centroid of the projection of any three-dimensional curve onto the |
|||||||
|
ComponentsMeasurements". Looks like they already know whatComp..M...does – rm -rf♦ Jan 2 at 16:09