Re: Division by zero, despite strong hint
- To: mathgroup at smc.vnet.net
- Subject: [mg96573] Re: Division by zero, despite strong hint
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Mon, 16 Feb 2009 16:38:25 -0500 (EST)
- References: <gnbk7i$3a3$1@smc.vnet.net>
dch888 wrote: > Hi, > > I'm trying to plot the Sin[1/x] curve with the curve being defined as > 0 at 0 like this: > > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > > Hmmm... what's the trick here to stop Mathematica evaluating all the branches > of the piecewise fn? There's nothing in the documentation that I can > see to stop this in Piecewise... perhaps I need to use a different Mathematica > function? I think you are just missing a comma, the following works as expected: g3[x_] := Piecewise[{{Sin[1/x], x != 0}, {0, x == 0}}] note that 0 is the default output anyway, so this will give the same results: g4[x_] := Piecewise[{{Sin[1/x], x != 0} }] hth, albert