RE: Define a function
- To: mathgroup at smc.vnet.net
- Subject: [mg34599] RE: [mg34556] Define a function
- From: "tgarza01 at prodigy.net.mx" <tgarza01 at prodigy.net.mx>
- Date: Wed, 29 May 2002 02:45:23 -0400 (EDT)
- Reply-to: tgarza01 at prodigy.net.mx
- Sender: owner-wri-mathgroup at wolfram.com
Use Condition (/;). This will do what you want: In[1]:= f[x_] := 0 /; x < 10; f[x_] := x /; 0 <= x <= 20; f[x_] := x/2 /; x > 20; Tomas Garza Mexico City Original Message: ----------------- From: Michael Popp popp.michael at gmx.at To: mathgroup at smc.vnet.net Subject: [mg34599] [mg34556] Define a function Hello I want to define a function in Mathematica. But just f[x_]:=... does not work, because I have to define different functions for different ranges of the variable x. For example: x < 10: f(x) = 0 10 < x < 20: f(x) = x 20 < x: f(x) = x/2 How to do this? Thanks, greetings Michael -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ .