MathGroup Archive 2012

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

Search the Archive

Re: piecewise and if

  • To: mathgroup at
  • Subject: [mg128628] Re: piecewise and if
  • From: "djmpark" <djmpark at>
  • Date: Sun, 11 Nov 2012 01:27:27 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <24859112.10967.1352531545869.JavaMail.root@m06>


I seems a mysterious feature, perhaps a bug, that plotting g[x,y] gives that
segmentation of the surface. But note that the Exclusion option says that
the excluded region must be one dimensional if the object is two
dimensional. Maybe the algorithm is trying to use Exclusion.

How about using this:

f[x_, y_] := Exp[-1/(x^2 + y^2)] 

g2[x_, y_] := Piecewise[{{0, Abs[x^2 + y^2] == 0}}, f[x, y]]  

Plot3D[g2[x, y], {x, -1, 1}, {y, -1, 1}] 

Or maybe something like this:

RevolutionPlot3D[Exp[-1/r^2], {r, 0.05, 1}] 

David Park
djmpark at 

From: Jon Joseph [mailto:josco.jon at] 

I think these two functions should be the same but their plots show a clear

f[x_, y_] := Exp[-1/(x^2 + y^2)] (* this function undefined at (0,0) *)

g[x_, y_] := Piecewise[{{0, x == 0 && y == 0}}, f[x, y]]  (* Redefine so the
hole is plugged *)

h[x_, y_] := If[x == 0 && y == 0, 0, f[x, y]]  (* Another, I think,
equivalent way to redefine f[x, y] *)

On my machine,   "8.0 for Mac OS X x86 (64-bit) (October 5, 2011)"

when I

Plot3D[g[x, y], {x, -1,1}, {y, -1,1}]

Plot3D[h[x, y], {x, -1,1}, {y, -1,1}]

I see clear gaps along y=0 and x=0 for the g[x, y] plot and h[x, y] works
properly.  Am I misusing Piecewise?

Thanks, Jon.

  • Prev by Date: Uninstall previous version [Linux OS]
  • Next by Date: Re: piecewise and if
  • Previous by thread: Re: piecewise and if
  • Next by thread: How to add a Locator (Tooltip) to RootLocusPlot?