# Rectangular function

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Rectangular_function
> Markdown URL: https://mediated.wiki/source/Rectangular_function.md
> Source: https://en.wikipedia.org/wiki/Rectangular_function
> Source revision: 1351473792
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Function whose graph is 0, then 1, then 0 again, in an almost-everywhere continuous way

"Box function" redirects here. For the Conway box function, see [Minkowski's question-mark function § Conway box function](/source/Minkowski's_question-mark_function#Conway_box_function).

Rectangular function with

        T
        =
        1

    {\textstyle T=1}

The **rectangular function** (also known as the **rectangle function**, **rect function**, **Pi function**, **Heaviside Pi function**,[1] **gate function**, **unit pulse**, or the **normalized [boxcar function](/source/Boxcar_function)**) is defined as[2]

rect ⁡ ( t T ) = Π ( t T ) = { 0 , if | t | > T 2 1 2 , if | t | = T 2 1 , if | t | < T 2 . {\displaystyle \operatorname {rect} \left({\frac {t}{T}}\right)=\Pi \left({\frac {t}{T}}\right)=\left\{{\begin{array}{rl}0,&{\text{if }}|t|>{\frac {T}{2}}\\{\frac {1}{2}},&{\text{if }}|t|={\frac {T}{2}}\\1,&{\text{if }}|t|<{\frac {T}{2}}.\end{array}}\right.}

Alternative definitions of the function define rect ⁡ ( t = ± T 2 ) {\textstyle \operatorname {rect} \left(t=\pm {\frac {T}{2}}\right)} to be 0,[3] 1,[4][5] or undefined. The area under the curve does not change for the different definitions of the functions at t = ± T 2 {\textstyle t=\pm {\frac {T}{2}}} .

The rectangular function can be used as the basis for a *[rectangular wave](/source/Rectangular_wave)*.

## History

The *rect* function has been introduced 1953 by [Woodward](/source/Philip_Woodward)[6] in "Probability and Information Theory, with Applications to Radar"[7] as an ideal [cutout operator](/source/Window_function#Rectangular_window), together with the [*sinc* function](/source/Sinc_function)[8][9] as an ideal [interpolation operator](/source/Whittaker%E2%80%93Shannon_interpolation_formula), and their counter operations which are [sampling](/source/Sampling_(signal_processing)) ([*comb* operator](/source/Dirac_comb#Dirac-comb_identity)) and [replicating](/source/Periodic_summation) ([*rep* operator](/source/Dirac_comb#Dirac-comb_identity)), respectively.

## Relation to the boxcar function

The rectangular function is a special case of the more general [boxcar function](/source/Boxcar_function):

rect ⁡ ( t − X Y ) = H ( t − ( X − Y / 2 ) ) − H ( t − ( X + Y / 2 ) ) = H ( t − X + Y / 2 ) − H ( t − X − Y / 2 ) {\displaystyle \operatorname {rect} \left({\frac {t-X}{Y}}\right)=H(t-(X-Y/2))-H(t-(X+Y/2))=H(t-X+Y/2)-H(t-X-Y/2)}

where H ( x ) {\displaystyle H(x)} is the [Heaviside step function](/source/Heaviside_step_function); the function is centered at X {\displaystyle X} and has duration Y {\displaystyle Y} , from X − Y / 2 {\displaystyle X-Y/2} to X + Y / 2. {\displaystyle X+Y/2.}

## Fourier transform of the rectangular function

Plot of normalized

        sinc
        ⁡
        (
        x
        )

    {\displaystyle \operatorname {sinc} (x)}

 function (i.e.

        sinc
        ⁡
        (
        π
        x
        )

    {\displaystyle \operatorname {sinc} (\pi x)}

) with its spectral frequency components.

The [unitary Fourier transforms](/source/Fourier_transform#Tables_of_important_Fourier_transforms) of the rectangular function are[2] ∫ − ∞ ∞ rect ⁡ ( t ) ⋅ e − i 2 π f t d t = sin ⁡ ( π f ) π f = sinc ⁡ ( π f ) = sinc π ⁡ ( f ) , {\displaystyle \int _{-\infty }^{\infty }\operatorname {rect} (t)\cdot e^{-i2\pi ft}\,dt={\frac {\sin(\pi f)}{\pi f}}=\operatorname {sinc} (\pi f)=\operatorname {sinc} _{\pi }(f),} using ordinary frequency f, where [sinc π {\displaystyle \operatorname {sinc} _{\pi }}](/source/Sinc_function) is the normalized form[10] of the [sinc function](/source/Sinc_function) and 1 2 π ∫ − ∞ ∞ rect ⁡ ( t ) ⋅ e − i ω t d t = 1 2 π ⋅ sin ⁡ ( ω / 2 ) ω / 2 = 1 2 π ⋅ sinc ⁡ ( ω / 2 ) , {\displaystyle {\frac {1}{\sqrt {2\pi }}}\int _{-\infty }^{\infty }\operatorname {rect} (t)\cdot e^{-i\omega t}\,dt={\frac {1}{\sqrt {2\pi }}}\cdot {\frac {\sin \left(\omega /2\right)}{\omega /2}}={\frac {1}{\sqrt {2\pi }}}\cdot \operatorname {sinc} \left(\omega /2\right),} using angular frequency ω {\displaystyle \omega } , where [sinc {\displaystyle \operatorname {sinc} }](/source/Sinc_function) is the unnormalized form of the [sinc function](/source/Sinc_function).

For rect ⁡ ( x / a ) {\displaystyle \operatorname {rect} (x/a)} , its Fourier transform is ∫ − ∞ ∞ rect ⁡ ( t a ) ⋅ e − i 2 π f t d t = a sin ⁡ ( π a f ) π a f = a sinc π ⁡ ( a f ) . {\displaystyle \int _{-\infty }^{\infty }\operatorname {rect} \left({\frac {t}{a}}\right)\cdot e^{-i2\pi ft}\,dt=a{\frac {\sin(\pi af)}{\pi af}}=a\ \operatorname {sinc} _{\pi }{(af)}.}

## Self convolution of the Rectangular function

The unit Rectangular function (in which

        T
        =
        1

    {\textstyle T=1}

) along with the [piecewise defined](/source/Piecewise_function) [splines](/source/Spline_(mathematics)) that result from successive convolutions of the Rectangular function with itself.

The [self convolution](/source/Self_convolution) of the dis-[continuous](/source/Continuous_function) rectangular function results in the [triangular function](/source/Triangular_function), a [piecewise defined](/source/Piecewise_function) [spline](/source/Spline_(mathematics)) that is continuous, but not continuously [differentiable](/source/Differentiable_function). Successive convolutions of the rectangular function result in piecewise defined pulses with lower maximums which are wider and smoother, with "smoother" meaning [higher-order derivatives](/source/Higher-order_derivative) are continuous.[11]

A [convolution](/source/Convolution) of the discontinuous rectangular function with itself results in the triangular function, which is a continuous function:

r e c t ( 2 t / T ) ∗ r e c t ( 2 t / T ) = t r i ( t / T ) = { 1 + t , − T < t < 0 1 − t , 0 < t < T 0 otherwise {\displaystyle {\begin{aligned}\operatorname {rect(2t/T)} *\operatorname {rect(2t/T)} =\operatorname {tri(t/T)} ={\begin{cases}1+t,&-T<t<0\\1-t,&\,\,\,\,\,0<t<T\\0&\,\,\,\,\,{\text{otherwise}}\\\end{cases}}\end{aligned}}}

Self convolution of the rectangular function applied twice yields a continuous and differentiably continuous parabolic spline:

r e c t ( 2 t / T ) ∗ r e c t ( 2 t / T ) ∗ r e c t ( 2 t / T ) = t r i ( t / T ) ∗ r e c t ( 2 t / T ) = { 9 8 + 3 2 t + 1 2 t 2 , − 3 2 T < t < − 1 2 T 3 4 − t 2 , − 1 2 T < t < 1 2 T 9 8 − 3 2 t + 1 2 t 2 , 1 2 T < t < 3 2 T 0 otherwise {\displaystyle {\begin{aligned}\operatorname {rect(2t/T)} *\operatorname {rect(2t/T)} *\operatorname {rect(2t/T)} =\operatorname {tri(t/T)} *\operatorname {rect(2t/T)} ={\begin{cases}{\frac {9}{8}}+{\frac {3}{2}}t+{\frac {1}{2}}t^{2},&-{\frac {3}{2}}T<t<-{\frac {1}{2}}T\\{\frac {3}{4}}-t^{2},&-{\frac {1}{2}}T<t<{\frac {1}{2}}T\\{\frac {9}{8}}-{\frac {3}{2}}t+{\frac {1}{2}}t^{2},&\,\,\,\,\,{\frac {1}{2}}T<t<{\frac {3}{2}}T\\0&\,\,\,\,\,{\text{otherwise}}\\\end{cases}}\end{aligned}}}

A self convolution of the rectangular function applied three times yields a continuous, and a second order differentiably continuous cubic spline:

t r i ( t / T ) ∗ t r i ( t / T ) = { 4 3 + 2 t + t 2 + 1 6 t 3 , − 2 T < t < − T 2 3 − t 2 − 1 2 t 3 , − T < t < 0 2 3 − t 2 + 1 2 t 3 , 0 < t < T 4 3 − 2 t + t 2 − 1 6 t 3 , T < t < 2 T 0 otherwise {\displaystyle {\begin{aligned}\operatorname {tri(t/T)} *\operatorname {tri(t/T)} ={\begin{cases}{\frac {4}{3}}+{2}t+t^{2}+{\frac {1}{6}}t^{3},&-2T<t<-T\\{\frac {2}{3}}-t^{2}-{\frac {1}{2}}t^{3},&-T<t<0\\{\frac {2}{3}}-t^{2}+{\frac {1}{2}}t^{3},&\,\,\,\,\,0<t<T\\{\frac {4}{3}}-{2}t+t^{2}-{\frac {1}{6}}t^{3},&\,\,\,\,\,T<t<2T\\0&\,\,\,\,\,{\text{otherwise}}\\\end{cases}}\end{aligned}}}

A self convolution of the rectangular function applied four times yields a continuous, and a third order differentiably continuous 4th order spline:

4 t h order spline = { 625 384 + 125 48 t + 25 16 t 2 + 5 12 t 3 + 1 24 t 4 , − 5 2 T < t < − 3 2 T 55 96 − 5 24 t − 5 4 t 2 − 5 6 t 3 − 1 6 t 4 , − 3 2 T < t < − 1 2 T 115 192 − 5 8 t 2 + 1 4 t 4 , − 1 2 T < t < 1 2 T 55 96 + 5 24 t − 5 4 t 2 + 5 6 t 3 − 1 6 t 4 , 1 2 T < t < 3 2 T 625 384 − 125 48 t + 25 16 t 2 − 5 12 t 3 + 1 24 t 4 , 3 2 T < t < 5 2 T 0 otherwise {\displaystyle {\begin{aligned}4^{th}\,{\text{order spline}}={\begin{cases}{\frac {625}{384}}+{\frac {125}{48}}t+{\frac {25}{16}}t^{2}+{\frac {5}{12}}t^{3}+{\frac {1}{24}}t^{4},&-{\frac {5}{2}}T<t<-{\frac {3}{2}}T\\{\frac {55}{96}}-{\frac {5}{24}}t-{\frac {5}{4}}t^{2}-{\frac {5}{6}}t^{3}-{\frac {1}{6}}t^{4},&-{\frac {3}{2}}T<t<-{\frac {1}{2}}T\\{\frac {115}{192}}-{\frac {5}{8}}t^{2}+{\frac {1}{4}}t^{4},&-{\frac {1}{2}}T<t<{\frac {1}{2}}T\\{\frac {55}{96}}+{\frac {5}{24}}t-{\frac {5}{4}}t^{2}+{\frac {5}{6}}t^{3}-{\frac {1}{6}}t^{4},&\,\,\,\,\,{\frac {1}{2}}T<t<{\frac {3}{2}}T\\{\frac {625}{384}}-{\frac {125}{48}}t+{\frac {25}{16}}t^{2}-{\frac {5}{12}}t^{3}+{\frac {1}{24}}t^{4},&\,\,\,\,\,{\frac {3}{2}}T<t<{\frac {5}{2}}T\\0&\,\,\,\,\,{\text{otherwise}}\\\end{cases}}\end{aligned}}}

Since the [Fourier transform](/source/Fourier_transform) of the rectangular function is the [Sinc function](/source/Sinc_function), the [convolution theorem](/source/Convolution_theorem) implies that the Fourier transform of pulses resulting from successive convolutions of the rectangular function with itself is simply the Sinc function to the order of the number of times that the convolution function was applied + 1 (i.e., the Fourier transform of the triangular function is Sinc2, the Fourier transform of the parabolic spline resulting from two successive convolutions of the rectangular function with itself is Sinc3, etc.)

## Use in probability

Main article: [Uniform distribution (continuous)](/source/Uniform_distribution_(continuous))

Viewing the rectangular function as a [probability density function](/source/Probability_density_function), it is a special case of the [continuous uniform distribution](/source/Uniform_distribution_(continuous)) with a = − 1 / 2 , b = 1 / 2. {\displaystyle a=-1/2,b=1/2.} The [characteristic function](/source/Characteristic_function_(probability_theory)) is

φ ( k ) = sin ⁡ ( k / 2 ) k / 2 , {\displaystyle \varphi (k)={\frac {\sin(k/2)}{k/2}},}

and its [moment-generating function](/source/Moment-generating_function) is

M ( k ) = sinh ⁡ ( k / 2 ) k / 2 , {\displaystyle M(k)={\frac {\sinh(k/2)}{k/2}},}

where sinh ⁡ ( t ) {\displaystyle \sinh(t)} is the [hyperbolic sine](/source/Hyperbolic_sine) function.

## Rational approximation

The pulse function may also be expressed as a limit of a [rational function](/source/Rational_function):

Π ( t ) = lim n → ∞ , n ∈ ( Z ) 1 ( 2 t ) 2 n + 1 . {\displaystyle \Pi (t)=\lim _{n\rightarrow \infty ,n\in \mathbb {(} Z)}{\frac {1}{(2t)^{2n}+1}}.}

### Demonstration of validity

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

It follows that: lim n → ∞ , n ∈ ( Z ) 1 ( 2 t ) 2 n + 1 = 1 0 + 1 = 1 , | t | < 1 2 . {\displaystyle \lim _{n\rightarrow \infty ,n\in \mathbb {(} Z)}{\frac {1}{(2t)^{2n}+1}}={\frac {1}{0+1}}=1,|t|<{\tfrac {1}{2}}.}

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

It follows that: lim n → ∞ , n ∈ ( Z ) 1 ( 2 t ) 2 n + 1 = 1 + ∞ + 1 = 0 , | t | > 1 2 . {\displaystyle \lim _{n\rightarrow \infty ,n\in \mathbb {(} Z)}{\frac {1}{(2t)^{2n}+1}}={\frac {1}{+\infty +1}}=0,|t|>{\tfrac {1}{2}}.}

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

lim n → ∞ , n ∈ ( Z ) 1 ( 2 t ) 2 n + 1 = lim n → ∞ , n ∈ ( Z ) 1 1 2 n + 1 = 1 1 + 1 = 1 2 . {\displaystyle \lim _{n\rightarrow \infty ,n\in \mathbb {(} Z)}{\frac {1}{(2t)^{2n}+1}}=\lim _{n\rightarrow \infty ,n\in \mathbb {(} Z)}{\frac {1}{1^{2n}+1}}={\frac {1}{1+1}}={\tfrac {1}{2}}.}

We see that it satisfies the definition of the pulse function. Therefore,

rect ⁡ ( t ) = Π ( t ) = lim n → ∞ , n ∈ ( Z ) 1 ( 2 t ) 2 n + 1 = { 0 if | t | > 1 2 1 2 if | t | = 1 2 1 if | t | < 1 2 . {\displaystyle \operatorname {rect} (t)=\Pi (t)=\lim _{n\rightarrow \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}}}

## Dirac delta function

The rectangle function can be used to represent the [Dirac delta function](/source/Dirac_delta_function) δ ( x ) {\displaystyle \delta (x)} .[12] Specifically, δ ( x ) = lim a → 0 1 a rect ⁡ ( x a ) . {\displaystyle \delta (x)=\lim _{a\to 0}{\frac {1}{a}}\operatorname {rect} \left({\frac {x}{a}}\right).} For a function g ( x ) {\displaystyle g(x)} , its average over the width *a {\displaystyle a}* around 0 in the function domain is calculated as,

g a v g ( 0 ) = 1 a ∫ − ∞ ∞ d x g ( x ) rect ⁡ ( x a ) . {\displaystyle g_{avg}(0)={\frac {1}{a}}\int \limits _{-\infty }^{\infty }dx\ g(x)\operatorname {rect} \left({\frac {x}{a}}\right).} To obtain g ( 0 ) {\displaystyle g(0)} , the following limit is applied,

g ( 0 ) = lim a → 0 1 a ∫ − ∞ ∞ d x g ( x ) rect ⁡ ( x a ) {\displaystyle g(0)=\lim _{a\to 0}{\frac {1}{a}}\int \limits _{-\infty }^{\infty }dx\ g(x)\operatorname {rect} \left({\frac {x}{a}}\right)} and this can be written in terms of the Dirac delta function as, g ( 0 ) = ∫ − ∞ ∞ d x g ( x ) δ ( x ) . {\displaystyle g(0)=\int \limits _{-\infty }^{\infty }dx\ g(x)\delta (x).} The Fourier transform of the Dirac delta function δ ( t ) {\displaystyle \delta (t)} is

δ ( f ) = ∫ − ∞ ∞ δ ( t ) ⋅ e − i 2 π f t d t = lim a → 0 1 a ∫ − ∞ ∞ rect ⁡ ( t a ) ⋅ e − i 2 π f t d t = lim a → 0 sinc ⁡ ( a f ) . {\displaystyle \delta (f)=\int _{-\infty }^{\infty }\delta (t)\cdot e^{-i2\pi ft}\,dt=\lim _{a\to 0}{\frac {1}{a}}\int _{-\infty }^{\infty }\operatorname {rect} \left({\frac {t}{a}}\right)\cdot e^{-i2\pi ft}\,dt=\lim _{a\to 0}\operatorname {sinc} {(af)}.} where the [sinc function](/source/Sinc_function) here is the normalized sinc function. Because the first zero of the sinc function is at f = 1 / a {\displaystyle f=1/a} and a {\displaystyle a} goes to infinity, the Fourier transform of δ ( t ) {\displaystyle \delta (t)} is

δ ( f ) = 1 , {\displaystyle \delta (f)=1,} means that the frequency spectrum of the Dirac delta function is infinitely broad. As a pulse is shorten in time, it is larger in spectrum.

## See also

- [Fourier transform](/source/Fourier_transform)

- [Square wave](/source/Square_wave_(waveform))

- [Step function](/source/Step_function)

- [Top-hat filter](/source/Top-hat_filter)

- [Boxcar function](/source/Boxcar_function)

## References

1. **[^](#cite_ref-1)** Wolfram Research (2008). ["HeavisidePi, Wolfram Language function"](https://reference.wolfram.com/language/ref/HeavisidePi.html). Retrieved October 11, 2022.

1. ^ [***a***](#cite_ref-wolfram_2-0) [***b***](#cite_ref-wolfram_2-1) [Weisstein, Eric W.](/source/Eric_W._Weisstein) ["Rectangle Function"](https://mathworld.wolfram.com/RectangleFunction.html). *[MathWorld](/source/MathWorld)*.

1. **[^](#cite_ref-3)** Wang, Ruye (2012). [*Introduction to Orthogonal Transforms: With Applications in Data Processing and Analysis*](https://books.google.com/books?id=4KEKGjaiJn0C&pg=PA135). Cambridge University Press. pp. 135–136. [ISBN](/source/ISBN_(identifier)) [9780521516884](https://en.wikipedia.org/wiki/Special:BookSources/9780521516884).

1. **[^](#cite_ref-4)** Tang, K. T. (2007). [*Mathematical Methods for Engineers and Scientists: Fourier analysis, partial differential equations and variational models*](https://books.google.com/books?id=gG-ybR3uIGsC&pg=PA85). Springer. p. 85. [ISBN](/source/ISBN_(identifier)) [9783540446958](https://en.wikipedia.org/wiki/Special:BookSources/9783540446958).

1. **[^](#cite_ref-5)** Kumar, A. Anand (2011). [*Signals and Systems*](https://books.google.com/books?id=FGGa6BXhy3kC&pg=PA258). PHI Learning Pvt. Ltd. pp. 258–260. [ISBN](/source/ISBN_(identifier)) [9788120343108](https://en.wikipedia.org/wiki/Special:BookSources/9788120343108).

1. **[^](#cite_ref-6)** Klauder, John R (1960). ["The Theory and Design of Chirp Radars"](https://ieeexplore.ieee.org/document/6773600). *Bell System Technical Journal*. **39** (4): 745–808. [doi](/source/Doi_(identifier)):[10.1002/j.1538-7305.1960.tb03942.x](https://doi.org/10.1002%2Fj.1538-7305.1960.tb03942.x).

1. **[^](#cite_ref-7)** Woodward, Philipp M (1953). *Probability and Information Theory, with Applications to Radar*. Pergamon Press. p. 29.

1. **[^](#cite_ref-8)** Higgins, John Rowland (1996). *Sampling Theory in Fourier and Signal Analysis: Foundations*. Oxford University Press Inc. p. 4. [ISBN](/source/ISBN_(identifier)) [0198596995](https://en.wikipedia.org/wiki/Special:BookSources/0198596995).

1. **[^](#cite_ref-9)** Zayed, Ahmed I (1996). *Handbook of Function and Generalized Function Transformations*. CRC Press. p. 507. [ISBN](/source/ISBN_(identifier)) [9780849380761](https://en.wikipedia.org/wiki/Special:BookSources/9780849380761).

1. **[^](#cite_ref-10)** Wolfram MathWorld, [https://mathworld.wolfram.com/SincFunction.html](https://mathworld.wolfram.com/SincFunction.html)

1. **[^](#cite_ref-11)** Spooner, Chad (January 28, 2021). ["SPTK: Convolution and the Convolution Theorem"](https://cyclostationary.blog/2021/01/28/sptk-convolution-and-the-convolution-theorem/).

1. **[^](#cite_ref-:0_12-0)** Khare, Kedar; Butola, Mansi; Rajora, Sunaina (2023). "Chapter 2.4 Sampling by Averaging, Distributions and Delta Function". *Fourier Optics and Computational Imaging* (2nd ed.). Springer. pp. 15–16. [doi](/source/Doi_(identifier)):[10.1007/978-3-031-18353-9](https://doi.org/10.1007%2F978-3-031-18353-9). [ISBN](/source/ISBN_(identifier)) [978-3-031-18353-9](https://en.wikipedia.org/wiki/Special:BookSources/978-3-031-18353-9).

---
Adapted from the Wikipedia article [Rectangular function](https://en.wikipedia.org/wiki/Rectangular_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Rectangular_function?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
