MathGroup Archive 2003

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

Search the Archive

Re: Defining function


"Ravinder Kumar B." <ravi at crest.ernet.in> 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
concern.

There are other options too.

David


  • 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