A Boolean 0/1 function in Mma?
- To: mathgroup at yoda.physics.unc.edu
- Subject: A Boolean 0/1 function in Mma?
- From: mcwilljg at euler.sfasu.edu
- Date: Mon, 2 Nov 92 11:25:52 CST
I am trying to recursively define a piecewise function in the following manner: ======================== s=0 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 accomplished: 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" to (x[i] <= y <= x[i+1]), can this be converted to 1 or 0? Thanks in advance for any help. --- Joseph McWilliams mcwilljg at euler.sfasu.edu