Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: piecewise vs which

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60115] Re: piecewise vs which
  • From: "dkr" <dkrjeg at adelphia.net>
  • Date: Sat, 3 Sep 2005 02:06:02 -0400 (EDT)
  • References: <df9437$620$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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