# Triangular function

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

{{distinguish|Trigonometric functions|Schwarz triangle function}}
{{Short description|Tent function, often used in signal processing}}
[[Image:Triangular function.svg|thumb|right|[Exemplary](/source/Exemplification) 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](/source/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](/source/signal_processing) and ''communication systems engineering'' as representations of idealized signals, and the triangular function specifically as an [integral transform](/source/integral_transform) kernel function from which more realistic signals can be derived, for example in [kernel density estimation](/source/kernel_density_estimation).  It also has applications in [pulse-code modulation](/source/pulse-code_modulation) as a pulse shape for transmitting [digital signal](/source/Digital_signal_(electronics))s and as a [matched filter](/source/matched_filter) for receiving the signals.  It is also used to define the '''triangular window''' sometimes called the [Bartlett window](/source/Bartlett_window).

== Definitions ==  
The most common definition is as a piecewise function:
<math display="block">
\begin{align}
\operatorname{tri}(x) = \Lambda(x) \ &\overset{\underset{\text{def}}{}}{=} \ \max\big(1 - |x|, 0\big) \\
   &= \begin{cases}
      1 - |x|, & |x| < 1; \\
      0        & \text{otherwise}. \\
      \end{cases}
\end{align}
</math>

Equivalently, it may be defined as the [convolution](/source/convolution) of two identical unit [rectangular function](/source/rectangular_function)s:

<math display="block">
\begin{align}
\operatorname{tri}(x) &= \operatorname{rect}(x) * \operatorname{rect}(x) \\
                      &= \int_{-\infty}^\infty \operatorname{rect}(x - \tau) \cdot \operatorname{rect}(\tau) \,d\tau. \\
\end{align}
</math>

The triangular function can also be represented as the product of the rectangular and [absolute value](/source/absolute_value) functions:

<math display="block">\operatorname{tri}(x) = \operatorname{rect}(x/2) \big(1 - |x|\big).</math>

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

<math display="block">
\begin{align}
\operatorname{tri}(2x) = \Lambda(2x) \ & \overset{\underset{\text{def}}{}}{=} \ \max\big(1 - 2|x|, 0\big) \\
   &= \begin{cases}
      1 - 2|x|, & |x| < \tfrac12; \\
      0         & \text{otherwise}. \\
      \end{cases}
\end{align}
</math>

In its most general form a triangular function is any linear [B-spline](/source/B-spline):<ref>{{cite book |title=INF-MAT5340 Lecture Notes |chapter=Basic properties of splines and B-splines |url=http://www.uio.no/studier/emner/matnat/ifi/INF-MAT5340/v05/undervisningsmateriale/komp.html |chapter-url=http://www.uio.no/studier/emner/matnat/ifi/INF-MAT5340/v07/undervisningsmateriale/kap2.pdf |page=38}}</ref>

<math display="block">
\operatorname{tri}_j(x) = \begin{cases}
     (x - x_{j-1})/(x_j - x_{j-1}), & x_{j-1} \le x < x_j; \\
     (x_{j+1} - x)/(x_{j+1} - x_j), & x_j \le x < x_{j+1}; \\
     0                              & \text{otherwise}.
     \end{cases}
</math>

Whereas the definition at the top is a special case

<math display="block">\Lambda(x) = \operatorname{tri}_j(x),</math>

where <math>x_{j-1} = -1</math>, <math>x_j = 0</math>, and <math>x_{j+1} = 1</math>.

A linear B-spline is the same as a continuous [piecewise linear function](/source/piecewise_linear_function) <math>f(x)</math>, and this general triangle function is useful to formally define <math>f(x)</math> as

<math display="block">f(x) = \sum_j y_j \cdot \operatorname{tri}_j(x),</math>

where <math>x_j < x_{j+1}</math> for all integer <math>j</math>.
The piecewise linear function passes through every point expressed as coordinates with [ordered pair](/source/ordered_pair) <math>(x_j, y_j)</math>,  that is,

<math display="block">f(x_j) = y_j.</math>

==Scaling==
For any parameter <math>a \ne 0</math>:

<math display="block">\begin{align}
\operatorname{tri}\left(\tfrac{t}{a}\right) &= \tfrac{1}{\sqrt{a}} \operatorname{rect}\left(\tfrac{t}{a}\right)* \tfrac{1}{\sqrt{a}} \operatorname{rect}\left(\tfrac{t}{a}\right) \\[1ex]
&= \int_{-\infty}^\infty \tfrac{1}{|a|} \operatorname{rect}\left(\tfrac{\tau}{a}\right) \cdot \operatorname{rect}\left(\tfrac{t-\tau}{a}\right) \,d\tau \\
&= 
\begin{cases}
1 - |t/a|, & |t| < |a|; \\
0 & \text{otherwise}.
\end{cases}
\end{align}</math>

==Fourier transform==
The transform is easily determined using the [convolution property of Fourier transforms](/source/Fourier_transform) and the [Fourier transform of the rectangular function](/source/Fourier_transform):

<math display="block">\begin{align}
\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{align}</math>
where <math>\operatorname{sinc}(x) = \sin(\pi x) / (\pi x)</math> is the [normalized sinc function](/source/Sinc_function).

For the general form, we have:

<math display="block">\begin{align}
\mathcal{F}\{\operatorname{tri}\left(\tfrac{t}{a}\right)\}
&= \mathcal{F}\left\{\tfrac{1}{\sqrt{a}} \operatorname{rect}\left(\tfrac{t}{a}\right) * \tfrac{1}{\sqrt{a}}\operatorname{rect}\left(\tfrac{t}{a}\right)\right\} \\
&= \tfrac{1}{a} \ \mathcal{F}\left\{\operatorname{rect}\left(\tfrac{t}{a}\right)\right\} \cdot \mathcal{F}\left\{\operatorname{rect}\left(\tfrac{t}{a}\right)\right\}\\
&= \tfrac{1}{a} \ \mathcal{F}\left\{\operatorname{rect}\left(\tfrac{t}{a}\right)\right\}^2 \\
&= \tfrac{1}{a} \ {a}^2 \ \mathrm{sinc}^2(a \cdot f) = {a} \ \mathrm{sinc}^2(a \cdot f).
\end{align}</math>

==See also==
*[Källén function](/source/K%C3%A4ll%C3%A9n_function), also known as triangle function
*[Tent map](/source/Tent_map)
*[Triangular distribution](/source/Triangular_distribution)
*[Triangle wave](/source/Triangle_wave), a piecewise linear periodic function
*[Trigonometric functions](/source/Trigonometric_functions)

== References ==
{{Reflist}}

Category:Special functions

---
Adapted from the Wikipedia article [Triangular function](https://en.wikipedia.org/wiki/Triangular_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Triangular_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.
