# Rectangle function: rect

### 15.2.2 Rectangle function: rect

The rectangle function Π is 0 everywhere except on [−1/2,1/2], where it is 1; namely, Π(x)=θ(x+1/2)−θ(x−1/2) where θ is the Heaviside function. The rectangle function is a special case of boxcar function (see section 15.2.1) for a=−1/2 and b=1/2.

- rect takes one argument:
  x, an identifier or an expression.
- rect(x) returns the value of the rectangle function at x.

#### Example.

Input:

rect(x/2)

Output:

θ

⎛
⎜
⎜
⎝

x
2

+

1
2

⎞
⎟
⎟
⎠

−θ

⎛
⎜
⎜
⎝

x
2

−

1
2

⎞
⎟
⎟
⎠

To compute the convolution of the rectangle function with itself, you can use the convolution theorem.
Input:

R:=fourier(rect(x),x,s):; ifourier(R^2,s,x)

Output:

−2 x θ | ⎛ ⎝ | x | ⎞ ⎠ | +x θ | ⎛ ⎝ | x+1 | ⎞ ⎠ | +x θ | ⎛ ⎝ | x−1 | ⎞ ⎠ | +θ | ⎛ ⎝ | x+1 | ⎞ ⎠ | −θ | ⎛ ⎝ | x−1 | ⎞ ⎠

This result is the triangle function tri(x) (see section 15.2.3).