This site is supported by donations to The OEIS Foundation.

# Rectangular function

The rectangular function ${\displaystyle \scriptstyle \mathrm {rect} (t),\,t\,\in \,\mathbb {R} ,\,}$ (also known as the rectangle function, rect function, Pi function, gate function, unit pulse, or the normalized boxcar function) is defined as

${\displaystyle \mathrm {rect} (t)=\sqcap (t)={\begin{cases}0&{\mbox{if }}|t|>{\frac {1}{2}},\\{\frac {1}{2}}&{\mbox{if }}|t|={\frac {1}{2}},\\1&{\mbox{if }}|t|<{\frac {1}{2}}.\end{cases}}\,}$

Alternate definitions of the function define ${\displaystyle \scriptstyle \mathrm {rect} \left(\pm {\frac {1}{2}}\right)\,}$ to be 0, 1, or undefined.

## Relation to the Heaviside step function

The rectangular function may be expressed in terms of the Heaviside step function as

${\displaystyle \mathrm {rect} (t)=H\left(t+{\tfrac {1}{2}}\right)-H\left(t-{\tfrac {1}{2}}\right)=H\left(t+{\tfrac {1}{2}}\right)+H\left(-t+{\tfrac {1}{2}}\right)-1=H\left({\tfrac {1}{4}}-t^{2}\right).\,}$

For a duration ${\displaystyle \scriptstyle T\,}$, we have

${\displaystyle \mathrm {rect} \left({\tfrac {t}{T}}\right)=H\left(t+{\tfrac {T}{2}}\right)-H\left(t-{\tfrac {T}{2}}\right)=H\left(t+{\tfrac {T}{2}}\right)+H\left(-t+{\tfrac {T}{2}}\right)-1=H\left({\tfrac {T^{2}}{4}}-t^{2}\right).\,}$

## Relation to the sign function

${\displaystyle \mathrm {rect} (t)={\tfrac {1}{2}}\left(\operatorname {sgn}(t+{\tfrac {1}{2}})-\operatorname {sgn}(t-{\tfrac {1}{2}})\right).\,}$

For a duration ${\displaystyle \scriptstyle T\,}$, we have

${\displaystyle \mathrm {rect} \left({\tfrac {t}{T}}\right)={\tfrac {1}{2}}\left(\operatorname {sgn}(t+{\tfrac {T}{2}})-\operatorname {sgn}(t-{\tfrac {T}{2}})\right).\,}$

## Relation to the boxcar function

The rectangular function is a special case of the more general boxcar function

${\displaystyle \mathrm {rect} \left({\frac {t-\tau }{T}}\right)=H(t-\tau +{\tfrac {T}{2}})-H(t-\tau -{\tfrac {T}{2}})=H(t-\tau +{\tfrac {T}{2}})+H(-t+\tau +{\tfrac {T}{2}})-1=H\left({\tfrac {T^{2}}{4}}-(t-\tau )^{2}\right),\,}$
${\displaystyle \mathrm {rect} \left({\frac {t-\tau }{T}}\right)={\tfrac {1}{2}}\left(\operatorname {sgn}(t-\tau +{\tfrac {T}{2}})-\operatorname {sgn}(t-\tau -{\tfrac {T}{2}})\right),\,}$

where the function is centered at ${\displaystyle \scriptstyle \tau \,}$ and has duration ${\displaystyle \scriptstyle T\,}$.

## Fourier transform of the rectangular function

The unitary Fourier transforms of the rectangular function are

${\displaystyle \int _{-\infty }^{\infty }\mathrm {rect} (t)\cdot e^{-i2\pi ft}\,dt={\frac {\sin \pi f}{\pi f}}=\mathrm {sinc} \,\pi f=\mathrm {sinc} _{\pi }\,f,\,}$

and

${\displaystyle {\frac {1}{\sqrt {2\pi }}}\int _{-\infty }^{\infty }\mathrm {rect} (t)\cdot e^{-i\omega t}\,dt={\frac {1}{\sqrt {2\pi }}}\cdot \mathrm {sinc} _{\pi }\left({\frac {\omega }{2\pi }}\right)={\frac {1}{\sqrt {2\pi }}}\cdot \mathrm {sinc} \,\left({\frac {\omega }{2}}\right),\,}$

where ${\displaystyle \scriptstyle \mathrm {sinc} \,}$ is the unnormalized sinc function and ${\displaystyle \scriptstyle \mathrm {sinc} _{\pi }\,}$ is the normalized sinc function.

Note that as long as the definition of the pulse function is only motivated by the time-domain experience of it, there is no reason to believe that the oscillatory interpretation (i.e. the Fourier transform function) should be intuitive, or directly understood by humans. However, some aspects of the theoretical result may be understood intuitively, such as the infinite bandwidth requirement incurred by the indefinitely-sharp edges in the time-domain definition.

## Relation to the triangular function

We can define the triangular function as the convolution of two rectangular functions

${\displaystyle \mathrm {tri} (t)=(\mathrm {rect} *\mathrm {rect} )(t)=\int _{-\infty }^{\infty }\mathrm {rect} (\tau )\,\mathrm {rect} (t-\tau )\,d\tau .\,}$

## Use in probability

Viewing the rectangular function as a probability density function, it is a special case of the continuous uniform distribution with ${\displaystyle \scriptstyle (a,\,b)\,=\,(-{\frac {1}{2}},\,{\frac {1}{2}})\,}$. The characteristic function is

${\displaystyle \varphi (k)={\frac {\sin \left({\tfrac {k}{2}}\right)}{\tfrac {k}{2}}}=\mathrm {sinc} \left({\tfrac {k}{2}}\right),\,}$

and its moment generating function is

${\displaystyle M(k)={\frac {\mathrm {sinh} \left({\tfrac {k}{2}}\right)}{\tfrac {k}{2}}},\,}$

where ${\displaystyle \scriptstyle \mathrm {sinh} (t)\,}$ is the hyperbolic sine function.

## Rational approximation

The pulse function may also be expressed as a limit of a rational function

${\displaystyle \sqcap (t)=\lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{(2t)^{2n}+1}}.\,}$

### Demonstration of validity

First, we consider the case where ${\displaystyle \scriptstyle |t|\,<\,{\frac {1}{2}}\,}$. Notice that the term ${\displaystyle \scriptstyle (2t)^{2n}\,}$ is always positive for integer ${\displaystyle \scriptstyle n\,}$. However, ${\displaystyle \scriptstyle 2t\,<\,1\,}$ and hence ${\displaystyle \scriptstyle (2t)^{2n}\,}$ approaches zero for large ${\displaystyle \scriptstyle n\,}$.

It follows that

${\displaystyle \lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{(2t)^{2n}+1}}={\frac {1}{0+1}}=1,\,|t|<{\frac {1}{2}}.\,}$

Second, we consider the case where ${\displaystyle \scriptstyle |t|\,>\,{\frac {1}{2}}\,}$. Notice that the term ${\displaystyle \scriptstyle (2t)^{2n}\,}$ is always positive for integer ${\displaystyle \scriptstyle n\,}$. However, ${\displaystyle \scriptstyle 2t\,>\,1\,}$ and hence ${\displaystyle \scriptstyle (2t)^{2n}\,}$ grows very large for large ${\displaystyle \scriptstyle n\,}$.

It follows that

${\displaystyle \lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{(2t)^{2n}+1}}={\frac {1}{+\infty +1}}=0,\,|t|>{\frac {1}{2}}.\,}$

Third, we consider the case where ${\displaystyle \scriptstyle |t|\,=\,{\frac {1}{2}}\,}$. We may simply substitute in our equation

${\displaystyle \lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{(2t)^{2n}+1}}=\lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{1^{2n}+1}}={\frac {1}{1+1}}={\frac {1}{2}}.\,}$

We see that it satisfies the definition of the pulse function

${\displaystyle \therefore \mathrm {rect} (t)=\sqcap (t)=\lim _{\stackrel {n\to \infty }{n\in \mathbb {Z} }}{\frac {1}{(2t)^{2n}+1}}={\begin{cases}0&{\mbox{if }}|t|>{\frac {1}{2}},\\{\frac {1}{2}}&{\mbox{if }}|t|={\frac {1}{2}},\\1&{\mbox{if }}|t|<{\frac {1}{2}}.\end{cases}}\,}$