MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: gaps in plot of piecewise function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108286] Re: [mg108220] Re: [mg108217] gaps in plot of piecewise function
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Fri, 12 Mar 2010 07:13:21 -0500 (EST)
  • References: <30604342.1268221205458.JavaMail.root@n11>

Hi again,

I hope everyone saw now that Exclusions->None or using not Piecewise but
e.g. Which will do the trick. In the documentation it sounds to me that
many functions are generally connected to Piecewise (look at Properties
and Relations in the Piecewise doc).

My question is, why would it be wrong to connect the plot in Piecewise
when the Limits are the same? Following example:

Manipulate[
 Plot[Piecewise[{{Exp[1] x, x < 1}}, Exp[x]], {x, 0, 3}, 
  MaxRecursion -> mr, MeshStyle -> {Red, PointSize[0.005]}, 
  Mesh -> All, PlotPoints -> pp, 
  ImageSize -> 500], {{pp, 5, "PlotPoints"}, 3, 30, 
  1}, {{mr, 1, "MaxRecursion"}, 1, 10, 1}]

The function has the same limit at x->1 and the same derivative. I would
clearly expect a plot without a gap even without the Exclusions options.
Where am I wrong?

Is it too unpredictable to check at least numerically the limits?
But why is this working?

Manipulate[
 Plot[Piecewise[{{Sin[x], x < 1.334}}, Cos[ x - Pi/2]], {x, 0, 3}, 
  MaxRecursion -> mr, MeshStyle -> {Red, PointSize[0.005]}, 
  Mesh -> All, PlotPoints -> pp, 
  ImageSize -> 500], {{pp, 5, "PlotPoints"}, 3, 30, 
  1}, {{mr, 1, "MaxRecursion"}, 1, 10, 1}]

What bothers me is that when using PiecewiseExpand you get an equivalent
presentation of one and the same function but you get different plots in
an, say not really predictable way.

Cheers
Patrick

On Thu, 2010-03-11 at 06:34 -0500, David Park wrote:
> I'm not certain of the exact underlying mechanics, but basically because of
> the steep curve as x -> 2 from below, and the piecewise function,
> Mathematica sees a discontinuity and leaves a gap. The way to overcome this
> is to use the Exclusions option.
> 
> s[x_] := Piecewise[{{-Sqrt[2]/2*Sqrt[-x + 0.5] + 2, x < 0.5}, {2, 
>      x >= 0.5}}];  
> 
> Plot[s[x], {x, 0, 1},
>  Exclusions -> None,
>  Frame -> True,
>  PlotRangePadding -> .1] 
> 
> 
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/  
> 
> 
> From: Benjamin Hell [mailto:hell at exoneon.de] 
> 
> Hi,
> I want to plot a piecewise function, but I don't want any gaps to appear 
> at the junctures. An easy example is:
> 
> s[x_] := Piecewise[{{-Sqrt[2]/2*Sqrt[-x + 0.5] + 2, x < 0.5}, {2, x >= 
> 0.5}}];
> Plot[s[x], {x, 0, 1}]
> 
> It should be clear, that the piecewise function defined above is 
> continuous, even at x=0.5. So there should not be any gaps appearing in 
> the plot, but they do. Maybe it's a feature of mathematica, but 
> nevertheless I want to get rid of the gaps. Any suggestions on how to 
> achieve that.
> 
> 
> Thanks in advance.
> 
> 
> 



  • Prev by Date: Manipulate [ Show [graphics ]]]
  • Next by Date: Re: Trouble with coupled quadratic equations where the
  • Previous by thread: Re: Re: gaps in plot of piecewise function
  • Next by thread: Re: Re: gaps in plot of piecewise function