TriangleWave[x]
gives a triangle wave that varies between
and
with unit period.
TriangleWave[{min,max},x]
gives a triangle wave that varies between min and max with unit period.
TriangleWave
TriangleWave[x]
gives a triangle wave that varies between
and
with unit period.
TriangleWave[{min,max},x]
gives a triangle wave that varies between min and max with unit period.
Details
- TriangleWave[x] is symmetric about
, and has value
at
. - TriangleWave automatically threads over lists. »
Examples
open all close allBasic Examples (3)
TriangleWave[.2]Plot over a subset of the reals:
Plot[TriangleWave[x], {x, 0, 3}]TriangleWave is a piecewise function over finite domains:
PiecewiseExpand[TriangleWave[x], -1 ≤ x ≤ 1]Scope (34)
Numerical Evaluation (5)
TriangleWave[-1]TriangleWave[1 / 4]TriangleWave[{0, 2}, 1.6]N[TriangleWave[1 / 47], 50]The precision of the output tracks the precision of the input:
TriangleWave[1.2222222222222222222222222]Evaluate efficiently at high precision:
TriangleWave[5 / 7`100]//TimingTriangleWave[3 / 11`100000];//TimingTriangleWave threads over lists in the last argument:
TriangleWave[{0.4, 1.2, 3.6}]TriangleWave[{0, 5}, {0.4, 1.2, 3.6}]Compute the elementwise values of an array using automatic threading:
TriangleWave[{{2 / 3, -1 / 3}, {1 / 2, -2 / 3}}]Or compute the matrix TriangleWave function using MatrixFunction:
MatrixFunction[TriangleWave, {{2 / 3, -1 / 3}, {1 / 2, -2 / 3}}]//FullSimplifySpecific Values (4)
TriangleWave[0]Values of TriangleWave at fixed points:
Table[TriangleWave[x], {x, 0, 2, 2 / 3}]FunctionExpand[TriangleWave[x], x∈Reals]PiecewiseExpand[TriangleWave[x], 0 < x < 1]Find a value of
for which the TriangleWave[x]=0.5:
xval = x /. FindRoot[TriangleWave[x] == 0.5, {x, 0.1}]Plot[TriangleWave[x], {x, 0, 2}, Epilog -> Style[Point[{xval, TriangleWave[xval]}], PointSize[Large], Red]]Visualization (4)
Plot the TriangleWave function:
Plot[TriangleWave[x], {x, -3, 3}, Filling -> Axis]Visualize scaled TriangleWave functions:
Plot[{TriangleWave[x], TriangleWave[x / 2], TriangleWave[2x]}, {x, 0, 2}, PlotLegends -> "Expressions", PlotTheme -> "DashedLines"]Visualize TriangleWave functions with different maximum and minimum values:
Plot[{TriangleWave[x], TriangleWave[{0, 1}, x], TriangleWave[{0, 2}, x]}, {x, -2, 2}, PlotLegends -> "Expressions"]Plot TriangleWave in three dimensions:
Plot3D[TriangleWave[x + y], {x, -1, 1}, {y, -1, 1}, ColorFunction -> "SouthwestColors"]Function Properties (11)
Function domain of TriangleWave:
FunctionDomain[TriangleWave[{a, b}, x], {x, a, b}]It is restricted to real inputs:
FunctionDomain[TriangleWave[{a, b}, x], {x, a, b}, Complexes]Function range of TriangleWave[x]:
FunctionRange[TriangleWave[x], x, y]TriangleWave is periodic with period 1:
FunctionPeriod[TriangleWave[x], x]TriangleWave is an odd function:
FullSimplify[TriangleWave[x] == -TriangleWave[-x], x∈Reals]The area under one period is zero:
Integrate[TriangleWave[x], {x, 0, 1}]TriangleWave is not an analytic function because it is singular at the half-integers:
FunctionSingularities[TriangleWave[x], x]//ExpandAll//SimplifyFunctionDiscontinuities[TriangleWave[x], x]TriangleWave[x] is neither nondecreasing nor nonincreasing:
FunctionMonotonicity[TriangleWave[x], x]TriangleWave is not injective:
FunctionInjective[TriangleWave[{a, b}, x], x, Assumptions -> a < b]Plot[{TriangleWave[x], .5}, {x, -7, 7}]TriangleWave[x] is not surjective:
FunctionSurjective[TriangleWave[x], x]Plot[{TriangleWave[x], -1.5}, {x, -5, 5}]TriangleWave[x] is neither non-negative nor non-positive:
FunctionSign[TriangleWave[x], x]TriangleWave is neither convex nor concave:
FunctionConvexity[TriangleWave[{a, b}, x], x, Assumptions -> a < b]Differentiation and Integration (5)
First derivative with respect to
:
D[TriangleWave[x], x]D[TriangleWave[{-1, 1}, x], x]Derivative of the two-argument form with respect to
:
D[TriangleWave[{a, b}, x], x]The second (and higher) derivatives are zero except at points where the derivative does not exist:
Simplify[D[TriangleWave[{a, b}, x], {x, 2}], a > b]If a==b, TriangleWave[{a,b},x] is constant and its derivatives are zero everywhere:
Table[D[TriangleWave[{a, a}, x], {x, k}], {k, 3}]Integrals over finite domains:
Integrate[TriangleWave[x], {x, 0, 10}]Integrate[Exp[-x]TriangleWave[x], {x, 0, 5}]Series Expansions (5)
FourierSeries[TriangleWave[x], x, 2]Since TriangleWave is odd, FourierTrigSeries gives a simpler result:
FourierTrigSeries[TriangleWave[x], x, 2]The two results are equivalent:
Simplify[% == %%]FourierCosSeries of a scaled TriangleWave:
FourierCosSeries[TriangleWave[(x/π)], x, 4]Series[TriangleWave[x], {x, 0, 3}, Assumptions -> x < 1]//NormalSeries expansion at a singular point:
Series[TriangleWave[x], {x, 1 / 4, 3}, Assumptions -> x < 1]Taylor expansion at a generic point:
Series[TriangleWave[x], {x, x0, 2}]//Normal// FullSimplifyApplications (2)
Coefficients of Fourier series:
FourierSinCoefficient[TriangleWave[x], x, n, FourierParameters -> {1, 2Pi}]Explicit Fourier series approximant:
FourierSinSeries[TriangleWave[x], x, 10, FourierParameters -> {1, 2Pi}]Plot[TriangleWave[x] - %, {x, 0, 1}]Play[TriangleWave[440 x], {x, 0, 1}]Properties & Relations (3)
Use FunctionExpand to expand TriangleWave in terms of elementary functions:
FunctionExpand[TriangleWave[x], x∈Reals]Use PiecewiseExpand to obtain piecewise representation on an interval:
PiecewiseExpand[TriangleWave[x], 0 < x < 2]TriangleWave[x] is both upper and lower semicontinuous, and thus continuous, at the origin:
Underscript[, x -> 0]TriangleWave[x] ≤ TriangleWave[0] && Underscript[, x -> 0]TriangleWave[x] ≥ TriangleWave[0]This is different from SquareWave[x], which is only upper semicontinuous:
{Underscript[, x -> 0]SquareWave[x] ≤ SquareWave[0], Underscript[, x -> 0]SquareWave[x] ≥ SquareWave[0]}As well as SawtoothWave[x], which is only lower semicontinuous:
{Underscript[, x -> 0]SawtoothWave[x] ≤ SawtoothWave[0], Underscript[, x -> 0]SawtoothWave[x] ≥ SawtoothWave[0]}Visualize the three functions:
GraphicsRow[Plot[#[x], {x, -1, 1}, IconizedObject[«Plot options»]]& /@ {TriangleWave, SquareWave, SawtoothWave}, ImageSize -> 500]Possible Issues (1)
TriangleWave is undefined for complex numbers:
TriangleWave[1.0 + 0.5 I]Related Guides
Related Links
History
Text
Wolfram Research (2008), TriangleWave, Wolfram Language function, https://reference.wolfram.com/language/ref/TriangleWave.html.
CMS
Wolfram Language. 2008. "TriangleWave." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TriangleWave.html.
APA
Wolfram Language. (2008). TriangleWave. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TriangleWave.html
BibTeX
@misc{reference.wolfram_2026_trianglewave, author="Wolfram Research", title="{TriangleWave}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/TriangleWave.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_trianglewave, organization={Wolfram Research}, title={TriangleWave}, year={2008}, url={https://reference.wolfram.com/language/ref/TriangleWave.html}, note=[Accessed: 13-June-2026]}