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 1992

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

Search the Archive

A Boolean 0/1 function in Mma?

  • To: mathgroup at
  • Subject: A Boolean 0/1 function in Mma?
  • From: mcwilljg at
  • Date: Mon, 2 Nov 92 11:25:52 CST

I am trying to recursively define a piecewise function in the
following manner:

For[i=0,i<=(n-1), i++,
		s = s + f[y,x[i]]*Indicator[y,x[i],x[i+1]]

I would like Indicator[y,x[i],x[i+1]] to equal 1 if x[i]<= y <=x[i+1]
and 0 otherwise.

For example, on many programmable cauculators this is how it would be

	f(y) = (Exp(y))*(0 <= y <= 1) + (Sin(y))*(1 <= y <= 2)
	where (x[i] <= y <= x[i+1]) is 1 if true and 0 otherwise.

Does Mma have such a function defined?

If not, how could I do the same thing?  Mma gives "True" or "False"  

(x[i] <= y <= x[i+1]), can this be converted to 1 or 0?

Thanks in advance for any help.

Joseph McWilliams
mcwilljg at

  • Prev by Date: Re: Treating units as positive constants?
  • Next by Date: PS Problems
  • Previous by thread: How to calculate Fisher Information?
  • Next by thread: PS Problems