MathGroup Archive 2005

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

Search the Archive

Re: piecewise vs which


This is not a bug.  By default Piecewise gives a value of 0 if none of
the conditions apply. But you can add an extra argument to change that
default.

In[1]:=
f[x_]:=Piecewise[{{x^2,x<2},{3x,x>2}},Null];
In[2]:=
f[2]
In[3]:=
 g[x_]=Which[x<2,x^2,x>2,3x];
In[4]:=
g[2]


  • Prev by Date: Please explain this weird Integrate result
  • Next by Date: ComplexExpand confusion
  • Previous by thread: Re: piecewise vs which
  • Next by thread: Re: piecewise vs which