home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!destroyer!ncar!vexcel!copper!slate!news
- From: jkc@keller.Mines.Colorado.EDU (Jack K. Cohen)
- Newsgroups: sci.math.symbolic
- Subject: Re: Mathematica: defining functions. HELP!
- Message-ID: <1992Aug14.155245.22729@slate.mines.colorado.edu>
- Date: 14 Aug 92 15:52:45 GMT
- References: <l8mkk4INN5ll@halcyon.usc.edu>
- Sender: news@slate.mines.colorado.edu
- Organization: Colorado School of Mines
- Lines: 20
-
- In article <l8mkk4INN5ll@halcyon.usc.edu> rao@halcyon.usc.edu (Anil Rao)
- writes:
- >
- > ... I want a function to behave 'differently' in different regions.
- > How does one do this in Mma? ...
-
- Here's one I did recently:
-
- MeyerPhiHat[v_, xi_] :=
- Which[
- (* If *) Abs[xi] <= 1/3, (* then *) 1,
- (* Elseif *) Abs[xi] >= 2/3, (* then *) 0,
- (* Else *) True, (* then *) Cos[Pi/2 v[3 Abs[xi] - 1]]
- ]
-
-
- Another way is to use /; as in:
-
- f[x_] := ... /; 0 < x < 1
- f[x_] := ... /; 1 <= x
-