Re: A plot of Sign[x]
- To: mathgroup at smc.vnet.net
- Subject: [mg94164] Re: A plot of Sign[x]
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Sat, 6 Dec 2008 06:14:55 -0500 (EST)
- Organization: University of Bergen
- References: <gh8hjr$r0h$1@smc.vnet.net> <ghb5da$rlj$1@smc.vnet.net>
Bert Aerts (rm X) wrote: > Thanks for the replies. > > But do I really have to conclude that Mathematica is unable to make a decent > automatic Plot of a function as simple as Sign[x]? Automatic plotting is not easy at all. To do what you've asked for, Mathematica would need to know that Sign[x] is a function with a very special behaviour at x==0. This specific case is not very difficult to program of course, but what if we have a more complicated function, like Sign[Exp[x]-3x]? Where *exactly* is this function 0? Detecting the exact position of jumps is not always possible with symbolic methods. So we might have to resort to numerical jump detection ... if this is a good idea at all ... If you had to write an automatic plotting function, how would you detect the jumps? What do you think about this plot? Is the position of the point near x==0 incorrect? Plot[2/(Exp[-10000 x] + 1) - 1, {x, -1, 1}, Mesh -> 21, MeshStyle -> {PointSize[.02], Red}] No, because it's a continuous function, with no jumps at all! I hope you see my point. Actually Mathematica's plotting function is quite impressive because in many cases it *can* detect the position of discrete jumps, even in complicated cases. Plot[UnitStep[Exp[x] - 3 x], {x, -2, 2}, PlotStyle -> Thick, Mesh -> 21, MeshStyle -> {PointSize[.02], Red}] When it cannot, you need to help it with the Exclusions option (as already suggested by Ulises Cervantes). -- Szabolcs > > Following does the trick: > a := Table[{x, Sign[x]}, {x, -5, 5, .01}] > ListPlot[a] > > > Bert Aerts (rm X) wrote: > >> I tried to plot the Sign function, making clear that Sign[0]=0 by typing >> Plot[Sign[x], {x, -5, 5}, Mesh -> 51, PlotRange -> All] >> Making Mesh an odd value shows x=0. >> >> But the point at x=0 is being plot as 0.5 in stead of zero. >> >> What am I doing wrong? >> >> Mathematica 6.0.3 Linux x86_64 > >
- Follow-Ups:
- Re: Re: A plot of Sign[x]
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: A plot of Sign[x]