Rectangle function

### 19.1.2 Rectangle function

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 19.1.1) for a=−1/2 and b=1/2.

The rect command computes the rectangle function.

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

#### Example

rect(x/2)

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

To compute the convolution of the rectangle function with itself, you can use the Convolution Theorem (see Section 19.4.2).

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

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

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