|
[Date Index]
[Thread Index]
[Author Index]
Re: Defining function
- To: mathgroup at smc.vnet.net
- Subject: [mg44562] Re: Defining function
- From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
- Date: Fri, 14 Nov 2003 01:58:58 -0500 (EST)
- References: <bovtvd$nbc$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"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
|