({{, (RefLink[UnitTriangle, paclet:ref/UnitTriangle])[x] 
represents the unit triangle function on the interval |x|≤1 .}, {, (RefLink[UnitTriangle, paclet:ref/UnitTriangle])[(Subscript[x, 1]),(Subscript[x, 2]),…]
represents the multidimensional unit triangle function on the interval |(Subscript[x, i])|≤1.}})

OpenersNotesSection(Spacer1)Details

(RefLink[UnitTriangle, paclet:ref/UnitTriangle])[x] is equivalent to (RefLink[Piecewise, paclet:ref/Piecewise])[{{x+1,-1≤x<0},{1-x,0≤x≤1}}].

(RefLink[UnitTriangle, paclet:ref/UnitTriangle]) can be used in integrals and integral transforms.

(RefLink[UnitTriangle, paclet:ref/UnitTriangle]) has attribute (RefLink[Orderless, paclet:ref/Orderless]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (28)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Plot in one and two dimensions:

Plot[UnitTriangle[x], {x,-2,2}]

Plot3D[UnitTriangle[x,y],{x,-1.5,1.5},{y,-1.5,1.5},PlotRange->All]

(RefLink[UnitTriangle, paclet:ref/UnitTriangle]) is a piecewise function:

PiecewiseExpand[UnitTriangle[x]]

The derivative of (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) is a piecewise function:

D[UnitTriangle[x],x]

OpenersExampleSection1(Spacer1)Scope  (20)

OpenersExampleSubsection0(Spacer1)Numerical Evaluation  (3)

Evaluate numerically:

UnitTriangle[.9]

UnitTriangle[-5]

Evaluate to high precision:

N[UnitTriangle[-1/7],50]

The precision of the output tracks the precision of the input:

UnitTriangle[.555555555555555555555555]

Evaluate efficiently at high precision:

UnitTriangle[-1/3`100]//Timing

UnitTriangle[5/11`10000000];//Timing

OpenersExampleSubsection1(Spacer1)Specific Values   (7)

Values of (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) at fixed points:

Table[UnitTriangle[n ],{n,{1,1/7,1/3,1/2}}]

(RefLink[UnitTriangle, paclet:ref/UnitTriangle]) threads over lists:

UnitTriangle[{-3,-1,0,1/3,1}]

Value at zero:

UnitTriangle[0]

The area of the (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) is 1:

Integrate[UnitTriangle[x],{x,-∞,∞}]

Evaluate symbolically:

PiecewiseExpand[UnitTriangle[x],0<x<2]

Find a value of x for which (RefLink[UnitTriangle, paclet:ref/UnitTriangle])[x]=0.4:

xval=x/.FindRoot[UnitTriangle[x]== 0.4,{x,0.5}]

Plot[UnitTriangle[x],{x,-2,2},Epilog->{PointSize[Large],Red,Point[{xval,UnitTriangle[xval]}]},ExclusionsStyle->Dotted]

(RefLink[TraditionalForm, paclet:ref/TraditionalForm]) typesetting:

UnitTriangle[x]//TraditionalForm

OpenersExampleSubsection2(Spacer1)Visualization  (2)

Plot the (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) function:

Plot[UnitTriangle[x],{x,-2,2}]

Plot (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) in three dimensions:

Plot3D[UnitTriangle[x,y],{x,-1.5,1.5},{y,-1.5,1.5},]

OpenersExampleSubsection3(Spacer1)Differentiation and Integration  (4)

First derivative with respect to x:

D[UnitTriangle[x],x]

First and second derivatives with respect to x:

Table[D[UnitTriangle[x],{x,k}],{k,1,2}]//FullSimplify

Compute the indefinite integral using (RefLink[Integrate, paclet:ref/Integrate]):

Integrate[UnitTriangle[x],x]

Verify the anti-derivative:

FullSimplify[D[%,x]]

Definite integral:

Integrate[UnitTriangle[x],{x,0,5}]

OpenersExampleSubsection4(Spacer1)Series Expansions  (4)

Find the Taylor expansion using (RefLink[Series, paclet:ref/Series]):

Series[UnitTriangle[x],{x,0,5}]//Normal

(RefLink[FourierSeries, paclet:ref/FourierSeries]):

FourierSeries[UnitTriangle[x],x,1]// FullSimplify

Series expansion at a generic point:

Series[UnitTriangle[x],{x,x0,2}]// Normal//FullSimplify

(RefLink[FourierTransform, paclet:ref/FourierTransform]) of a unit triangle is squared (RefLink[Sinc, paclet:ref/Sinc]) function:

FourierTransform[UnitTriangle[x],x,t,FourierParameters->{1,1}]

Plot[%,{t,-15,15}]

OpenersExampleSection3(Spacer1)Applications  (2)

Integrate a piecewise function involving (RefLink[UnitTriangle, paclet:ref/UnitTriangle]) symbolically and numerically:

Plot[Gudermannian[x] UnitTriangle[3x-1],{x,0,1}]

Integrate[Gudermannian[x] UnitTriangle[3x-1],{x,-1,1}]

N[%]

NIntegrate[Gudermannian[x]UnitTriangle[3x-1],{x,-1,1}]

Solve a differential equation involving (RefLink[UnitBox, paclet:ref/UnitBox]) and (RefLink[UnitTriangle, paclet:ref/UnitTriangle]):

DSolve[y'[x]+UnitBox[x-1/2] y[x]==UnitTriangle[x]&&y[0]==3,y,x]

Plot[y[x]/.%,{x,-2,2}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Convolution of (RefLink[UnitTriangle, paclet:ref/UnitTriangle]):

Convolve[UnitTriangle[x],UnitTriangle[x],x,y]

Plot[{UnitTriangle[y],%},{y,-2,2},PlotRange->All]

Multidimensional unit triangle function equals the product of 1D functions for each argument:

UnitTriangle[x,y,z]==UnitTriangle[x]UnitTriangle[y]UnitTriangle[z]

Simplify[%]

(RefLink[UnitTriangle, paclet:ref/UnitTriangle]) is a special case of (RefLink[BSplineBasis, paclet:ref/BSplineBasis]):

{Plot[BSplineBasis[1,1/2(x+1)],{x,-2,2}],Plot[UnitTriangle[x],{x,-2,2}]}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[UnitStep, paclet:ref/UnitStep])  ▪  (RefLink[UnitBox, paclet:ref/UnitBox])  ▪  (RefLink[DiracDelta, paclet:ref/DiracDelta])  ▪  (RefLink[HeavisideTheta, paclet:ref/HeavisideTheta])  ▪  (RefLink[HeavisidePi, paclet:ref/HeavisidePi])  ▪  (RefLink[HeavisideLambda, paclet:ref/HeavisideLambda])  ▪  (RefLink[TriangleWave, paclet:ref/TriangleWave])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Numerical Functions, paclet:guide/NumericalFunctions])}})}})