Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg44561] Re: [mg44539] Defining function
  • From: Yasvir Tesiram <yat at omrf.ouhsc.edu>
  • Date: Fri, 14 Nov 2003 01:58:57 -0500 (EST)
  • Organization: OMRF
  • References: <200311131236.HAA23886@smc.vnet.net>
  • Reply-to: yat at omrf.ouhsc.edu
  • Sender: owner-wri-mathgroup at wolfram.com

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