# Symbolic integration in a region obtained using a boolean combination

Inertia tensors for non-typical rigid bodies

Calculate inertia tensors

Integrate over a region

I'm trying to calculate the moment of inertia for a complex figure depending on the $$r$$ parameter.

c1 = Cylinder[{{0.5, 0, -1}, {0.5, 0, 1}}, 1/2]
c2 = Cylinder[{{0, 0, -1}, {0, 0, 1}}, r]
R = RegionDifference[c1, c2]
(***Inertia Field***)
vars = {x, y, z};
r2 = IdentityMatrix Tr[#] - # &@Outer[Times, vars, vars];
r2 // MatrixForm


This is how it looks: Integration works relatively well (except for computational speed) with simple figures and figures specified parametrically. But with boolean combinations, we get such a strange integral that cannot be taken.

Integrate[y^2 + z^2, vars \[Element] R, Assumptions -> {r > 0}] // AbsoluteTiming Is there any way to get around the problem?

Version: 12.0.0 for Microsoft Windows (64-bit)

AFTER SOME TIME:

In this algorithm, the limits of integration are searched for a simpler region (cylinder), and then the triple integral is calculated. Is it possible to build an efficient computational procedure on the basis of this? This thought takes place, in my opinion, because it became possible to break the algorithm into steps and to speed up the process by simplifying at each step. What do you think?

c1 = Cylinder[{{0.5, 0, -1}, {0.5, 0, 1}}, 1/2] // Rationalize[#, 0] &;
R = c1;

(***Inertia Field***)
vars = {x, y, z};
r2 = IdentityMatrix Tr[#] - # &@Outer[Times, vars, vars];
r2 // MatrixForm;

RegionMember[R, {x, y, z}];

Reduce[0 <= (1 + z)/2 <= 1 && (-(1/2) + x)^2 + y^2 <= 1/4, {x, y,
z}] // Expand;

Integrate[
Integrate[
Integrate[y^2 + z^2, {z, -1, 1}], {y, -Sqrt[x - x^2], Sqrt[
x - x^2]}], {x, 0, 1}];

• Please include the output of $Version to your post and also include the OS information that you are working with. – Syed Feb 15 at 5:20 • @Syed I added info – dtn Feb 15 at 5:22 • At least versions 12.2 to 13.2.1 succeed in performing this integration. Feb 15 at 5:24 • @kirma It's a pity. I tried to make a few more assumptions - it did not work. – dtn Feb 15 at 5:25 • @kirma thanks for the advice! I'll try to do something with it. You can also write your own answer if you feel like it. – dtn Feb 15 at 6:27 ## 2 Answers With $Version if we try

c1 = Cylinder[{{0.5, 0, -1}, {0.5, 0, 1}}, 1/2] // Rationalize[#, 0] &;
c2 = Cylinder[{{0, 0, -1}, {0, 0, 1}}, r] // Rationalize[#, 0] &;
R = RegionDifference[c1, c2];
Integrate[y^2 + z^2, vars ∈ R] • Thank you for your answer! The calculation time is satisfactory. But I'm afraid that this is not the end yet, because. more complex shapes may require a more complex procedure. I will accept your answer and would like to offer you the following idea: the calculation of such integrals can be reduced to triple integration with well-defined limits of integration. Using the RegionMember command, we will find conditions that tell us that a given set of parameters is in a given region. Then, using the Reduce command, we will solve the equations for the variables x, y, z.
– dtn
Feb 15 at 6:02
• This approach gave me the same result as the MomentOfInertia command for the whole region (however, I integrated over a regular cylinder). If we learn how to correctly extract the limits of integration and integrate, then something can come of it. See my edit, please.
– dtn
Feb 15 at 6:02
• @dtn I just saw that. sorry for the delayed response, busy day. Your idea is valid and in principle should work very nicely I think. I will try to have a look at your edit later, but cannot make any promises.
– bmf
Feb 15 at 6:58
• It's OK! Check it out when you have free time. I will continue to study the problem. Also see the interesting second answer in this topic.
– dtn
Feb 15 at 7:01
• @dtn I saw it very quickly and upvoted already :-)
– bmf
Feb 15 at 7:05

When working at this problem I found out that newer versions generate particularly complicated results, making FullSimplify never return a nice, simple answer. Performing the integration on cylindrical coordinates (after all, one of the regions involved is a cylinder oriented on the $$z$$ axis in the style of "Cylindrical" coordinates) helps on this problem:

IntegrateChangeVariables[
Inactive[Integrate][
y^2 + z^2,
Element[{x, y, z},
RegionDifference[
Cylinder[{{1/2, 0, -1}, {1/2, 0, 1}}, 1/2],
Cylinder[{{0, 0, -1}, {0, 0, 1}}, r]]]],
{rr, \[Theta], zz}, "Cartesian" -> "Cylindrical",
Assumptions -> r >= 0] Activate[%] FullSimplify[%, 0 <= r <= 1]

(* 1/48 (r Sqrt[1 - r^2] (19 + 2 r^2 + 16 r^4) +
(19 - 8 r^2 (4 + 3 r^2)) ArcCos[r]) *)


Note that rr and zz are used in coordinate conversion in order to avoid conflict with r and z.

• Cool and very inspiring idea with the change of coordinates!
– dtn
Feb 15 at 6:48