Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

piecewise and if

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128622] piecewise and if
  • From: Jon Joseph <josco.jon at gmail.com>
  • Date: Sat, 10 Nov 2012 02:08:52 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

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

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: Re: Export a graphical plot to pdf file
  • Next by Date: Re: Quirks of EventHandler
  • Previous by thread: FindFit::eit Error Message in Mathematica
  • Next by thread: Re: piecewise and if