Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Defining function

  • To: mathgroup at
  • Subject: [mg44562] Re: Defining function
  • From: "David W. Cantrell" <DWCantrell at>
  • Date: Fri, 14 Nov 2003 01:58:58 -0500 (EST)
  • References: <bovtvd$nbc$>
  • Sender: owner-wri-mathgroup at

"Ravinder Kumar B." <ravi at> wrote:
> 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

(This type of question seems to be asked frequently.)
The common (and perhaps best) answer would to write it using the UnitStep
function as

f[t_] := UnitStep[t]Exp[-i*t]

but that also defines f at t = 0, which perhaps you didn't want. If that is
the case, here are two other options, which leave f undefined at t = 0:

f[t_] := Which[t < 0, 0, t > 0, Exp[-i*t]]

f[t_] := (1 + Abs[t]/t)/2 * Exp[-i*t]

Note that the latter also leaves f undefined at +/-Infinity, if that's a

There are other options too.


  • Prev by Date: Re: Defining function
  • Next by Date: Re: Automatic comment coloring
  • Previous by thread: Re: Defining function
  • Next by thread: Re: Defining function