11
$\begingroup$

Bug introduced in 13.0.0 and fixed in 13.0.1 [CASE:4894156]


In version 13, Tube is a recognized region. E.g., RegionQ[Tube[{{0, 0, -h}, {0, 0, h}}, r]] returns True. However, it's not clear what the precise definition of the region is. Comparing with a cylinder, suggests that a Tube region from a single line segment is the surface of a cylinder, but with hemispherical caps:

 Graphics3D[{Style[Tube[{{0, 0, -1}, {0, 0, 1}}, 1/2],
     Opacity[0.5, Red]], Cylinder[{{0, 0, -1}, {0, 0, 1}}, 1/2]}]

But the area of the tube is not what I expect from that of a cylinder and the caps:

Simplify[Area[Tube[{{0, 0, -h}, {0, 0, h}}, r]], h > 0]

gives

4 \[Pi] (h + r^2)

which adds different physical quantities: a length (h) and an area (r^2).

Compare to the surface area of a cylinder:

Simplify[SurfaceArea[Cylinder[{{0, 0, -h}, {0, 0, h}}, r]], h > 0]

which gives

2 \[Pi] r (2 h + r)

The difference in areas between Tube and Cylinder suggests the tube is not the surface of the cylinder with circular ends replaced by hemispheres.

The area of the tube region also differs from discretizing a graphics:

With[{reg = Tube[{{0, 0, -1}, {0, 0, 1}}, 0.5]},
 {Area[reg], SurfaceArea[BoundaryDiscretizeGraphics[reg]]}
 ]

gives different values for the tube region and discretized graphics:

{15.708, 9.32718}

To find a definition of the Tube region, I tried

RegionConvert[Tube[{{0, 0, -h}, {0, 0, h}}, r], "Implicit"]

but that does not evaluate. In contrast, RegionConvert does work for a cylinder.

Is the difference between Tube and Cylinder just a problem with the evaluation of Area? Or is Tube as a region something different than as it appears as a graphics?

$\endgroup$
4
  • 1
    $\begingroup$ Tube is a complex object compare to CapsuleShape. Volume[CapsuleShape[{{0, 0, -h}, {0, 0, h}}, r]] $\endgroup$
    – cvgmt
    Commented Jan 9, 2022 at 0:59
  • $\begingroup$ The title: Is "Region" literal or not? $\endgroup$ Commented Jan 9, 2022 at 14:21
  • 1
    $\begingroup$ 4 \[Pi] (h + r^2) is my new favourite surface area formula, great work Mathematica! $\endgroup$
    – Jojo
    Commented Jan 9, 2022 at 18:12
  • $\begingroup$ CapsuleShape, which is a filled-in version of this tube, gives the same surface area: Simplify[SurfaceArea[CapsuleShape[{{0, 0, -h}, {0, 0, h}}, r]], h > 0] gives 4 \[Pi] (h + r^2) $\endgroup$
    – tad
    Commented Jan 19, 2022 at 22:34

2 Answers 2

10
$\begingroup$

I think you've found a bug! I think different parts of Mathematica deal with Tube differently.

Note that DiscretizeRegion thinks Tube is degenerate: evaluate DiscretizeRegion[Tube[]] for an error message. This suggests to me the reason for the mixing of areas and lengths in the Area output—some kind of degeneracy. (By the way, it's not only Area that doesn't work—Area's functionality likely comes through RegionMeasure, and that gives the same bizarre result.)

A workaround: However, RegionMember seems to work "as expected" and produce a good tube. Thus we can use this in conjunction with ImplicitRegion to make our own tube (with memoization as long as there are no messages, so we don't always have to recompute; not sure this actually needs it, though, as it seems pretty fast):

fixedTube[args___] := 
 Module[{tube},
   (fixedTube[args] = tube) /;
    Check[(tube = 
      ImplicitRegion[RegionMember[Tube[args], {x, y, z}], {x, y, z}]); True, 
      False]]

(See DiscretizeRegion @ fixedTube[] to be convinced that this works.)

Note that this produces a filled-in 3D tube (as opposed to just its surface). This seems different than the region Mathematica considers Tube[] to refer to by itself!

RegionDimension[fixedTube[]] (* 3 *)

RegionDimension[Tube[]]      (* 2 *)

This is weird, because ImplicitRegion should essentially be the inverse of RegionMember. So I suspect this is a bug, and that Mathematica is mistakenly treating Tube one way in some part of its code but not in another.

$\endgroup$
3
  • 2
    $\begingroup$ (+1) Have you reported this to the support? $\endgroup$ Commented Jan 9, 2022 at 5:10
  • 1
    $\begingroup$ DiscretizeGraphics also thinks that Tube[] is a 2D region. $\endgroup$ Commented Jan 9, 2022 at 5:12
  • 1
    $\begingroup$ ImplicitRegion gives a full region because RegionMember considers interior points part of the region, e.g., RegionMember[Tube[{{0, 0, -1}, {0, 0, 1}}, 1/2], {0, 0, 0}] returns True. As you note, inconsistent definition among different region functions. $\endgroup$
    – tad
    Commented Jan 10, 2022 at 20:58
1
$\begingroup$

The original bug is fixed in version 13.0.1:

Simplify[Area[Tube[{{0, 0, -h}, {0, 0, h}}, r]], h > 0]
4 Pi r (h + r)

Which equals to

Simplify[Area[Sphere[{0, 0, 0}, r]] + 2 h Perimeter[Disk[{0, 0}, r]]]
4 Pi r (h + r)

And also equals to

Simplify[SurfaceArea[Cylinder[{{0, 0, -h}, {0, 0, h}}, r]] - 2 Area[Disk[{0, 0}, r]] + 
  Area[Sphere[{0, 0, 0}, r]], h > 0]
4 Pi r (h + r)
$\endgroup$

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.