0

I'm having a very puzzling issue with piecewise defined but smoothly continuous functions.

I have a perfectly continuous piecewise function defined as

u[xb_, t_, L_] :=  
  Piecewise[
    {{t - xb, xb <= L/2}}, 
    t - (xb - L/2)/0.9 +  ArcTan[ Tanh[xb - L/2]] - L/2]

When I plot it for various vlaues of L (for example L = 3) I get the following density plot with missing parts.

DensityPlot[u[0, 0, 3] - u[xb, t, 3], {xb, 1, 3}, {t, -4, 4}, 
  PlotPoints -> 30, PlotLegends -> Automatic]

Looks like some sort of coarse graining problem but I can't seem to get rid of it without increasing the number of points in the plot by a large amount

Can anyone help me find out what's going on and how to solve it without having to increase the resolution of the plot? I don't want to increase PlotPoints because I am integrating that expression numerically later on, and this introduces coarse graining errors in the integrals.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Collector
  • 503
  • 4
  • 6

0 Answers0