4
$\begingroup$

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[3] Tr[#] - # &@Outer[Times, vars, vars];
r2 // MatrixForm

This is how it looks:

enter image description here

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

enter image description here

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[3] 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}];
$\endgroup$
10
  • 2
    $\begingroup$ Please include the output of $Version to your post and also include the OS information that you are working with. $\endgroup$
    – Syed
    Feb 15, 2023 at 5:20
  • $\begingroup$ @Syed I added info $\endgroup$
    – dtn
    Feb 15, 2023 at 5:22
  • $\begingroup$ At least versions 12.2 to 13.2.1 succeed in performing this integration. $\endgroup$
    – kirma
    Feb 15, 2023 at 5:24
  • $\begingroup$ @kirma It's a pity. I tried to make a few more assumptions - it did not work. $\endgroup$
    – dtn
    Feb 15, 2023 at 5:25
  • 1
    $\begingroup$ @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. $\endgroup$
    – dtn
    Feb 15, 2023 at 6:27

2 Answers 2

5
$\begingroup$

With

$Version

ver

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]

res

$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$
    – dtn
    Feb 15, 2023 at 6:02
  • $\begingroup$ 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. $\endgroup$
    – dtn
    Feb 15, 2023 at 6:02
  • 1
    $\begingroup$ @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. $\endgroup$
    – bmf
    Feb 15, 2023 at 6:58
  • $\begingroup$ 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. $\endgroup$
    – dtn
    Feb 15, 2023 at 7:01
  • 1
    $\begingroup$ @dtn I saw it very quickly and upvoted already :-) $\endgroup$
    – bmf
    Feb 15, 2023 at 7:05
5
$\begingroup$

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]

enter image description here

Activate[%]

enter image description here

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.

$\endgroup$
1
  • $\begingroup$ Cool and very inspiring idea with the change of coordinates! $\endgroup$
    – dtn
    Feb 15, 2023 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.