# Triangular function

Exemplary triangular function

A triangular function (also known as a triangle function, hat function, or tent function) is a function whose graph takes the shape of a triangle. Often this is an isosceles triangle of height 1 and base 2 in which case it is referred to as the triangular function. Triangular functions are useful in signal processing and communication systems engineering as representations of idealized signals, and the triangular function specifically as an integral transform kernel function from which more realistic signals can be derived, for example in kernel density estimation. It also has applications in pulse code modulation as a pulse shape for transmitting digital signals and as a matched filter for receiving the signals. It is also used to define the triangular window sometimes called the Bartlett window.

## Definitions

The most common definition is as a piecewise function:

{\displaystyle {\begin{aligned}\operatorname {tri} (x)=\Lambda (x)\ &{\overset {\underset {\mathrm {def} }{}}{=}}\ \max(1-|x|,0)\\&={\begin{cases}1-|x|\qquad &|x|<1\\0\qquad &\mathrm {otherwise} \\\end{cases}}\end{aligned}}}

Equivalently, it may be defined as the convolution of two identical unit rectangular functions:

{\displaystyle {\begin{aligned}\operatorname {tri} (x)&=\operatorname {rect} (x)*\operatorname {rect} (x)\\&=\int _{-\infty }^{\infty }\operatorname {rect} (x-\tau )\cdot \operatorname {rect} (\tau )\ d\tau \\\end{aligned}}}

The triangular function can also be represented as the product of the rectangular and absolute value functions:

${\displaystyle \operatorname {tri} (x)=\operatorname {rect} (x/2)\left(1-|x|\right)}$

Triangle function (alternate)

Note that some authors instead define the triangle function to have a base of width 1 instead of width 2:

{\displaystyle {\begin{aligned}\operatorname {tri} (2x)=\Lambda (2x)\ &{\overset {\underset {\mathrm {def} }{}}{=}}\ \max(1-2|x|,0)\\&={\begin{cases}1-2|x|\qquad &|x|<{\tfrac {1}{2}}\\0\qquad &\mathrm {otherwise} \\\end{cases}}\end{aligned}}}

In its most general form a triangular function is any linear B-Spline:[1]

${\displaystyle \operatorname {tri} _{j}(x)={\begin{cases}(x-x_{j-1})/(x_{j}-x_{j-1})&x_{j-1}\leq x

Whereas the definition at the top is a special case

${\displaystyle \Lambda (x)=\operatorname {tri} _{j}(x)}$
where ${\displaystyle x_{j-1}=-1}$, ${\displaystyle x_{j}=0}$, and ${\displaystyle x_{j+1}=1}$.

A linear B-spline is the same as a continuous piecewise linear function, ${\displaystyle f(x)}$, and this general triangle function is useful to formally define such as:

${\displaystyle f(x)=\sum _{j}\ y_{j}\cdot \operatorname {tri} _{j}(x)}$
where ${\displaystyle x_{j} for all integer ${\displaystyle j}$.

The piecewise linear function passes through every point expressed as coordinates with ordered pair ${\displaystyle (x_{j},y_{j})}$. That is

${\displaystyle f(x_{j})=y_{j}}$ .

## Scaling

For any parameter ${\displaystyle a\neq 0}$:

{\displaystyle {\begin{aligned}\operatorname {tri} ({\tfrac {t}{a}})&=\int _{-\infty }^{\infty }{\tfrac {1}{|a|}}\mathrm {rect} ({\tfrac {\tau }{a}})\cdot \mathrm {rect} ({\tfrac {t-\tau }{a}})\ d\tau \\&={\begin{cases}1-|t/a|&|t|<|a|\\0&{\mbox{otherwise}}\end{cases}}\end{aligned}}}

## Fourier transform

The transform is easily determined using the convolution property of Fourier transforms and the Fourier transform of the rectangular function:

{\displaystyle {\begin{aligned}{\mathcal {F}}\{\operatorname {tri} (t)\}&={\mathcal {F}}\{\operatorname {rect} (t)*\operatorname {rect} (t)\}\\&={\mathcal {F}}\{\operatorname {rect} (t)\}\cdot {\mathcal {F}}\{\operatorname {rect} (t)\}\\&={\mathcal {F}}\{\operatorname {rect} (t)\}^{2}\\&=\mathrm {sinc} ^{2}(f)\end{aligned}}}

where ${\displaystyle \operatorname {sinc} (x)=\sin(\pi x)/(\pi x)}$ is the normalized sinc function.

## References

1. ^ "Basic properties of splines and B-splines" (PDF). INF-MAT5340 Lecture Notes. p. 38.