MathGroup Archive 2003

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

Search the Archive

Re: Defining function


Here are a couple of ideas,

f[x_] := If[x > 0, Exp[-x],
     If[x == 0, Print["Don't know what to do at zero"], 0]]


g[x_] := Switch[x,
     _Integer && x > 0, Exp[-x],
     _Integer && x == 0, Print["Don't know what to do at zero"],
     _Integer && x < 0, 0

     ]

You may also like to try out Condition and Which.

Cheers
Yas


Ravinder Kumar B. wrote:
> Dear All,
> How to define a function over two different ranges in mathematica.
> For example
> 
> f(t):= Exp[-i*t]  for t > 0   and
>      = 0          for t < 0
> 
> Your response/clarification will be deeply appreciated.
> Regards,
> Ravi
> 


  • Prev by Date: Re: Defining function
  • Next by Date: Re: Defining function
  • Previous by thread: Re: Defining function
  • Next by thread: Re: Defining function