# Problem with 3D surface disconnections [duplicate]

I have a problem with a 3D surface in Mathematica 10.1. The problem is that the surface comes out disconnected even if it shouldn't. Here's a minimal toy example showing the problem:

Plot3D[E^-(x - Round[x])^2, {x, 0, 3}, {y, 0, 3}, PlotRange -> {0, 1}]


the result is

The surface profile (in 2D) is that of a continuous line (even if it is not differentiable at all points):

Plot[E^-(x - Round[x])^2, {x, 0, 3}, PlotRange -> {0, 1}]


Increasing the PlotPoints actually reduce the gaps' width, but doesn't eliminate them.

I have also tried the above code in Mathematica 9 and there's the same problem.

That effect is very awful in the rendering of a much more complex surface intended to reproduce a seashell (with bumps and nodules). Is there any simple workaround to smooth out (not differentiable) surfaces?

• Try a combination of Exclusions -> None and a larger number for MaxRecursions. Commented May 4, 2015 at 13:52
• @Virgil Thanks. I didn't know about the Exclusions -> None option. It seems to work. Commented May 4, 2015 at 14:19
• – kglr
Commented May 5, 2015 at 15:56
• Luca, I hope someday you can post pictures of your simulated seashells. :) Commented May 6, 2015 at 5:31

For the record, this can be solved by setting Exclusions -> None in Plot3D, which tells Mathematica not to exclude subregions of the domain that are associated with discontinuities. Generally, if you want that plot to look sharp, you will have to couple it with a largish number for MaxRecursions:
Plot3D[E^-(x - Round[x])^2, {x, 0, 3}, {y, 0, 3},

• Yet another (sneaky!) way to thwart automatic exclusion is to make the definition f[x_?NumericQ] := E^-(x - Round[x])^2 and use that for the plots. Commented May 6, 2015 at 4:26