# Dealing with indicator functions

I am calculating the integral of two indicator functions with Mathematica. I'm having difficulty in imposing assumptions. What I have done so far:

To define an indicator function:

indicator[c_,d_][x_]:= Piecewise[{{1,c<=x <= d},{0, True}}];


Then the integral is:

Integrate[indicator[-1,1][x-y]*indicator[-n,n][y], {y,-Infinity, Infinity},Assumptions->{Element[n,Integers]}]


Now what I expected, was that it gives me the length of intersection between the two segments $[-n,n]$ and $[x-1,x+1]$, but it lists a set of cases for different values of n and x, but it is still assuming n is real, because it considers cases such as $0<n<1$. Any suggestions?

• You know that Boole[] is built-in, no? – J. M.'s technical difficulties Nov 2 '15 at 15:10
• @J.M. no :( but do you think the issue stems from my definition of "indicator" above? – user21766 Nov 2 '15 at 15:15
• Use UnitBox or HeavisidePi, properly scaled. – David G. Stork Nov 2 '15 at 18:11

FullSimplify@Assuming[n > 0,

$\begin{cases} \frac{1}{2} & (n>0\land 4 n x+2>n\land 4 n x+n\leq 2)\lor (n=2\land x=0) \\ \frac{1}{n} & n>2\land 4 n x+n\geq 2\land 4 n x+2\leq n \\ \frac{1}{2}-x & n=2\land 0<x<\frac{1}{2} \\ x+\frac{1}{2} & n=2\land -\frac{1}{2}<x<0 \\ \frac{-4 n x+n+2}{4 n} & 4 n x<n+2\land ((n>2\land 4 n x+2>n)\lor (4 n x+n>2\land n<2)) \\ \frac{1}{2 n}+x+\frac{1}{4} & 4 n x+n+2>0\land ((n>2\land 4 n x+n<2)\lor (n<2\land 4 n x+2\leq n)) \end{cases}$
• Clearly, then: UnitBox[2 n y]. I'll let you figure out the cases with non-zero centers, etc. – David G. Stork Nov 2 '15 at 22:12