Rectangle function : rect

### 5.27.2 Rectangle function : rect

The rect command takes an identifier or an expression x and returns the value of the rectangle function at x , which is defined by Π(x)=u(x+1/2)−u(x−1/2) where u is the Heaviside function. The rectangle function is a special case of boxcar function (see Section 5.27.1) for a=−1/2 and b=1/2 .

For example, input :

rect(x/2)

Output :

Heaviside(x/2+1/2)-Heaviside(x/2-1/2)

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

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

Output :

Heaviside(x+1)-Heaviside(x-1)-2*x*Heaviside(x)+ x*Heaviside(x+1)+x*Heaviside(x-1)

The above result is the triangle function tri(x) (see Section 5.27.3).