# performance tuning – Area of ImplicitRegion is slow or doesn’t compute under certain circumstances

I’m trying to find the area of a region defined by `ImplicitRegion` using the `Area` function. I have the following:

``````h0 = 1.0;
r0 = 2.0;
xpmax = 0.6;
ypmax = 0.2;

ArcTanSeries(x_) = !(
*SubsuperscriptBox(((Sum)), (n = 0), (3))(
*SuperscriptBox((((-1))), (n))
*FractionBox(
SuperscriptBox((x), (2  n + 1)), (2  n + 1))));

(Phi) = ArcTan(yi/xi);
l = Sqrt(yi^2 + xi^2);
h = ArcTanSeries(-l/z);
h = ArcTan(-l/z);
h = -l/z;
xp = h Cos((Phi));
yp = h Sin((Phi));

R = ImplicitRegion({xp < xpmax, yp < xpmax,
xi^2 + yi^2 + (z + r0 + h0)^2 == r0^2}, {{xi, 0, r0/2}, {yi, 0,
r0/2}, {z, -3 h0, -h0}});
Show(DiscretizeRegion(R), Graphics3D(Sphere({0, 0, -r0 - h0}, r0)))

Area(R)
``````

This is the area of a region of the surface of a sphere bounded by a few inequalities. If I run this as-is, it completes in a few seconds and gives me the area. That is the case when using `h = -l/z` but I would like to instead set `h = ArcTan(-l/z)`. If I switch to this definition of h everything works nicely up to and including showing the defined region on the surface of a sphere. However, on the last line Mathematica spends 5-10 minutes trying to calculate the area before eventually giving up and returning my input.

Is there something I can do to improve this? Or maybe a different approach I can take? I believe the region is well defined using either definition of `h`, so it isn’t obvious to me why it fails when using the `ArcTan` definition. I have also tried using a series expansion of ArcTan, which does result in a number after a bit of time. But it is still quite slow due to requiring quite a few terms (9-ish probably, maybe more) to be accurate enough for my needs. In fact, when testing 9 terms, Mathematica again gave up after ~10 minutes and returned my input. Are there any ways I can speed this up and ensure a precise answer?

Is this something I should be trying to numerically integrate? I imagine that is what the `Area` function does, but I’m not exactly sure how to set up such an integral.

Posted on Categories Articles