# RevolutionPlot3D of 4 piecewise functions around X-axis crashing mathematica

Bug introduced in 8.0.4 or earlier, persisting through 13.2 or later

I'm trying to rotate 4 piecewise functions around the X-axis using RevolutionPlot3D. The 4 functions I have are:

bottom[x_] := Piecewise[{{{2 + x - x^2/6}, 0 <= x < 3}}, Indeterminate]
side[x_] := Piecewise[{{7/2, 3 <= x < 15}}, Indeterminate]
top[x_] := Piecewise[{{{37/2 - x}, 15 <= x < 17}}, Indeterminate]
neck[x_] := Piecewise[{{3/2, 17 <= x <= 20}}, Indeterminate]


If I try to rotate all of these around the X-axis using RevolutionPlot3D, I get errors:

RevolutionPlot3D[{{bottom[x]}, {side[x]}, {top[x]}, {neck[x]}}, {x, 0, 20},
AxesLabel -> {"x", "y", "z"}, RevolutionAxis -> {1, 0, 0}]


This gives me

Dot::rect: Nonrectangular tensor encountered.

errors.

This has worked previously with other functions. I tried only the straight lines one for debugging; that is, side and neck:

RevolutionPlot3D[{{side[x]}, {neck[x]}}, {x, 0, 20},
AxesLabel -> {"x", "y", "z"}, RevolutionAxis -> {1, 0, 0}]


But this actually crashes the Mathematica kernel. Any ideas how I get Mathematica to show a revolution plot around the X-axis of these 4 functions?

• What version does this occur on? Commented Oct 3, 2012 at 12:31
• @rcollyer I see the issue in 8.0.4 Commented Oct 3, 2012 at 12:35
• Why not merge your four functions as a single Piecewise[] object: Piecewise[{{2 + x - x^2/6, 0 <= x < 3}, {7/2, 3 <= x < 15}, {37/2 - x, 15 <= x < 17}, {3/2, 17 <= x <= 20}}, Indeterminate]? Commented Oct 3, 2012 at 12:38
• That actually worked! The reason I didn't do that to begin with was that I was working with each function separately. Commented Oct 3, 2012 at 12:42
• I filed the crash as a bug to be looked at. Thanks.
– user21
Commented Oct 3, 2012 at 15:00

## 1 Answer

If I merge your four components into a single Piecewise[] object, things work out:

RevolutionPlot3D[
Piecewise[{{2 + x - x^2/6, 0 <= x < 3},
{7/2, 3 <= x < 15},
{37/2 - x, 15 <= x < 17},
{3/2, 17 <= x <= 20}}], {x, 0, 20},
AxesLabel -> {"x", "y", "z"}, Mesh -> None, RevolutionAxis -> {1, 0, 0}]


though there are unsightly gaps in your bottle, which can be rectified by adding Exclusions -> None to the options: