Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random  

Sawtooth and Triangle Waves

(Topic)

Sawtooth and Triangle Waves

FS07 built a complete Fourier series for the square wave. We now apply the same coefficient machinery to two piecewise-linear waveforms: the sawtooth wave and the triangle wave.

These two examples are especially valuable because their shapes look similarly simple in the time or spatial domain, but their harmonic spectra decay at different rates.

  • The sawtooth wave has a jump discontinuity in the waveform itself.
  • The triangle wave is continuous, but its slope changes abruptly at its corners.
  • The sawtooth Fourier coefficients decrease like 1∕n.
  • The triangle-wave Fourier coefficients decrease like 1∕n2.

That contrast gives our first concrete connection between waveform smoothness and spectral decay.

We begin on [−π,π], then generalize both results to [−L,L] and to time-periodic signals.

1 Two piecewise-linear periodic waveforms

Let A > 0.

Define the odd sawtooth wave on one reference interval by

s(x ) = A-x,    − π <  x < π,
        π
(1)

with periodic extension

s(x + 2π ) = s(x ).
(2)

As x approaches π from the left, the value approaches +A. Immediately after the period resets, the periodic extension returns to values near −A. Thus the sawtooth has a jump of height 2A at every odd multiple of π.

Now define the centered triangle wave by

         (         )
               2|x|
t(x) = A   1 −  π    ,    − π ≤  x ≤ π,
(3)

and extend it periodically with period 2π.

The triangle wave satisfies

t(0) = A,     t(± π) = − A.
(4)

Unlike the sawtooth, it is continuous across the period boundary. Its corners occur where the slope changes abruptly.

PIC

Figure 1. The odd sawtooth is piecewise linear but jumps at the period boundary. The centered triangle wave is continuous but has corners where its slope changes.

2 Inspect symmetry before integrating

The sawtooth satisfies

s(− x) = − s(x),
(5)

so it is odd. Therefore

a0 = 0,     an = 0,
(6)

and its Fourier series contains only sine terms.

The triangle wave satisfies

t(− x) = t(x ),
(7)

so it is even. Therefore

bn = 0,
(8)

and its Fourier series contains only a constant term and cosine terms.

A second symmetry appears for the triangle wave. Its periodic extension obeys

t(x + π) = − t(x ).
(9)

This is half-wave antisymmetry. It will eliminate every even harmonic.

PIC

Figure 2. Symmetry predicts large parts of each Fourier series before any coefficient integral is evaluated.

3 Derive the sawtooth coefficients

Since the sawtooth is odd, start with the sine coefficient formula

       ∫ π
bn =  1-    s(x)sin(nx) dx.
     π  −π
(10)

Substitute

       A-
s(x) =  πx.
(11)

Then

bn = A--
π2 ∫ −ππx sin(nx) dx. (12)

The product x sin(nx) is even, so

         ∫ π
bn =  2A-    xsin(nx )dx.
      π2  0
(13)

Use integration by parts. Let

u = x,     dv =  sin(nx )dx.
(14)

Then

du = dx,     v = − cos(nx-).
                      n
(15)

Therefore

∫ 0πx sin(nx) dx = [            ]
 − x-cos(nx-)
       n0π + 1-
n∫ 0π cos(nx) dx. (16)

The remaining integral is

∫  π             [        ]π
    cos(nx) dx =   sin(nx-)-  = 0.
  0                  n     0
(17)

The boundary term gives

[  x cos(nx)]
 − ---------
       n0π = −π cos(nπ)
----------
    n
= −π(−-1)n-
   n. (18)

Hence

∫  π                       n
    x sin (nx)dx =  − π(−-1)-.
  0                     n
(19)

Substituting into Eq. (13) gives

bn = 2A
-2-
π[  π (− 1)n ]
 − --------
      n
= 2A(− 1)n+1
----πn-----. (20)

Thus the complete sawtooth Fourier series is

            ∞
        2A-∑   (−-1)n+1
s(x) ∼  π         n    sin(nx ).
           n=1
(21)

Writing the first few terms explicitly,

           [                                         ]
       2A-         1-         1-        1-
s(x) ∼  π   sin x − 2 sin2x +  3 sin 3x − 4 sin 4x + ⋅⋅⋅ .
(22)

Two features are immediately visible:

  • every positive integer harmonic appears,
  • and the coefficient magnitude decreases like 1∕n.

4 The sawtooth harmonic spectrum

The magnitude of the nth sine coefficient is

|b | = 2A-.
 n    πn
(23)

So the first few normalized magnitudes are

|b1|-
 A = 2-
π ≈ 0.63662, (24)
|b|
--2-
 A = 1
--
π ≈ 0.31831, (25)
|b3|-
 A = -2-
3π ≈ 0.21221, (26)
|b|
--4-
 A =  1
---
2π ≈ 0.15915. (27)

The signs alternate, but the envelope is proportional to 1∕n.

PIC

Figure 3. The sawtooth contains every sine harmonic. The coefficient signs alternate, while the magnitude envelope decreases as 1∕n.

5 Sawtooth partial sums and the period-boundary jump

Define the N-harmonic sawtooth partial sum by

              N
 (s)      2A-∑   (−-1)n+1
SN  (x ) =  π        n     sin(nx ).
             n=1
(28)

Every finite partial sum is continuous because it is a finite sum of continuous sine functions. The target periodic sawtooth, however, jumps at x = ±π.

This creates the same basic convergence tension that appeared for the square wave in FS07. As more harmonics are added,

  • the straight-line interior is reproduced more accurately,
  • the transition near the periodic jump becomes narrower,
  • and oscillatory ringing remains near the jump.

The detailed limiting analysis belongs to FS14 through FS16.

PIC

Figure 4. Sawtooth partial sums using N = 1, 5, and 20 harmonics. More harmonics improve the interior linear ramp while concentrating oscillatory behavior near the jump.

At the jump point itself, the left and right limiting values are

    −              +
s (π  ) = A,     s(π  ) = − A.
(29)

Their midpoint is

A--+-(−-A)
     2     = 0.
(30)

The later convergence articles will show why the Fourier series approaches this midpoint at the jump.

6 Derive the triangle-wave constant coefficient

Now turn to

         (     2|x |)
t(x) = A   1 − ----  .
                π
(31)

Because t(x) is even,

        ∫ π  (        )
      2-           2x-
a0 =  π  0 A   1 −  π   dx.
(32)

Evaluate the two parts:

a0 = 2A-
 π[∫            ∫       ]
   π        2-  π
     1dx −  π    x dx
  0            0
= 2A-
 π[        2]
 π − -2π--
     π  2
= 0. (33)

Thus the triangle wave has zero mean.

This agrees with its geometry: positive and negative triangular areas cancel over one full period.

7 Derive the triangle-wave cosine coefficients

Since the waveform is even,

     2 ∫ π
an = --    t(x )cos(nx) dx.
     π  0
(34)

Substitute the positive-half expression

         (       )
t(x) = A   1 − 2x- ,     0 ≤ x ≤ π.
               π
(35)

Then

an = 2A-
 π∫ 0π(       )
  1 − 2x-
      π cos(nx) dx
= 2A
---
 π[∫ π              2 ∫ π             ]
     cos(nx) dx − --    xcos(nx )dx
  0               π  0. (36)

The first integral vanishes:

∫  π
    cos(nx )dx = 0.
  0
(37)

For the second integral, use integration by parts. Let

u = x,     dv = cos(nx )dx.
(38)

Then

du = dx,     v =  sin(nx-).
                    n
(39)

Hence

∫ 0πx cos(nx) dx = [          ]
  x-sin(nx-)
      n0π −-1
n∫ 0π sin(nx) dx. (40)

The boundary term is zero because sin(nπ) = 0. The remaining integral is

∫ 0π sin(nx) dx = [  cos(nx)]
 − --------
      n0π
= 1 − (− 1)n
----------
    n. (41)

Therefore

∫ π                          n        n
                    1-−-(−-1)-   (−-1)-−--1
 0 x cos(nx) dx = −     n2     =     n2    .
(42)

Substitute this into Eq. (36):

an = −4A-
π2[           ]
  (− 1)n-−-1
     n2
= -4A--
π2n2[1 − (− 1)n] . (43)

Thus

      (
      { -8A--,  n odd,
an =    π2n2
      ( 0,      n even.
(44)

The triangle-wave Fourier series is therefore

           ∑∞
t(x) = 8A-     cos[(2k-+-1)x],
        π2       (2k + 1)2
           k=0
(45)

with convergence qualifications to be formalized later.

The first terms are

          [                                            ]
       8A-         1-        -1-         -1-
t(x ) = π2  cos x + 9 cos3x + 25 cos 5x + 49 cos7x + ⋅⋅⋅  .
(46)

PIC

Figure 5. The triangle wave is even, so only cosine projections are needed. Half-wave antisymmetry then removes the even cosine harmonics.

8 A useful check at the triangle peak

At x = 0,

t(0) = A.
(47)

The Fourier series gives

     8A [     1    1       ]
A =  --2  1 + -2 + -2-+ ⋅⋅⋅  .
     π        3    5
(48)

Cancel A:

        ∞
     8-∑   ----1----
1 =  π2    (2k + 1)2.
        k=0
(49)

Therefore

 ∞                2
∑   ----1---- = π--.
    (2k + 1)2    8
k=0
(50)

This identity will later connect naturally to Parseval-type arguments, but here it is simply a consistency check obtained from the triangle-wave series.

9 Triangle-wave partial sums

Define

 (t)      8A  M∑ −1cos[(2k + 1)x]
SM (x) = --2     ----------2---.
          π  k=0   (2k + 1 )
(51)

The coefficient magnitude now decreases like

----1----,
(2k + 1)2
(52)

which is much faster than the sawtooth’s 1∕n decay.

As a result, relatively few harmonics already reproduce the broad triangular shape well.

PIC

Figure 6. Triangle-wave partial sums using the first 1, 3, and 8 nonzero harmonics. The 1∕n2 coefficient decay makes the reconstruction settle rapidly compared with the sawtooth.

The triangle wave has no jump in the function value. Its non-smooth points are corners, where the derivative changes abruptly. This difference in smoothness is reflected directly in the harmonic spectrum.

10 Why the decay rates are different

We now have two exact coefficient laws:

       2A
|b(ns)| = ---     for the sawtooth,
       πn
(53)

and, for odd n,

|a (t)| =-8A--     for the triangle wave.
  n    π2n2
(54)

The sawtooth has a jump discontinuity in the function. One integration by parts leaves a nonzero boundary contribution, which produces a factor proportional to 1∕n.

The triangle wave is continuous. Its first integration-by-parts boundary contributions cancel more strongly, and the remaining calculation supplies another factor of 1∕n. The result is 1∕n2.

This suggests a broader principle:

greater smoothness  usually produces  faster Fourier-coefficient decay.
(55)

The word “usually” matters. Precise statements require hypotheses about differentiability, periodic endpoint matching, and integrability. Those refinements belong later in the series.

PIC

Figure 7. Coefficient-magnitude comparison for equal amplitude A. The sawtooth envelope falls as 1∕n, while the nonzero triangle-wave coefficients fall as 1∕n2.

11 A derivative connection to the square wave

There is also a structural reason for the triangle wave’s extra factor of 1∕n.

Away from its corners, differentiate

         (     2|x |)
t(x) = A   1 − ----  .
                π
(56)

For −π < x < 0,

t′(x) =  2A-,
        π
(57)

while for 0 < x < π,

 ′       2A-
t(x ) = − π .
(58)

Thus the derivative is a scaled square wave with opposite sign convention:

t′(x) = − 2A- q(x),
          π
(59)

where

       {

q(x) =   − 1,  − π < x < 0,
         1,    0 < x < π.
(60)

FS07 gave

       4 ∑∞  sin[(2k +  1)x]
q(x) ∼ --    --------------.
       π k=0     2k + 1
(61)

Formally integrating a sine harmonic divides by its harmonic number. This hints at why integrating a square-wave spectrum proportional to 1∕(2k + 1) produces a triangle-wave spectrum proportional to 1∕(2k + 1)2.

The rigorous rules for differentiating and integrating Fourier series are deferred to FS17. Here this relation is used only as a structural preview.

12 The extra factor of 1∕n: an integration-by-parts comparison

The exact formulas already show the decay rates. It is useful to see where the extra factor of 1∕n enters the calculus.

For the sawtooth, the coefficient contains

      ∫ π
I(s)=      xsin(nx) dx.
n      0
(62)

After one integration by parts,

       [  x cos(nx )]π   1 ∫  π
In(s)=   − ---------   + --    cos(nx )dx.
              n     0   n   0
(63)

The second term vanishes, but the boundary term does not:

              n
I(s)=  − π(−-1)-.
n          n
(64)

The nonzero endpoint contribution leaves exactly one Power of 1∕n.

Now consider the triangle coefficient in the form

      ∫ π (       )
 (t)             2x-
In  =  0    1 − π   cos(nx )dx.
(65)

Integrate by parts with

         2x
u =  1 − --,     dv = cos(nx )dx.
         π
(66)

Then

       -2            sin(nx-)
du = − π dx,     v =    n    .
(67)

Therefore

In(t) = [(        )        ]
       2x-  sin(nx)-
   1 −  π      n0π + -2-
πn∫ 0π sin(nx) dx. (68)

The boundary term now vanishes because

sin(0) = sin (nπ) = 0.
(69)

The remaining sine integral contributes another factor of 1∕n:

∫
  π              1 −-(− 1-)n
    sin(nx )dx =      n     .
 0
(70)

Hence

 (t)   2[1-−-(−-1)n]
In  =      πn2     .
(71)

So the contrast can be summarized as follows:

  • sawtooth: a nonzero boundary contribution survives after one integration by parts, giving 1∕n;
  • triangle: the first boundary contribution vanishes, and a second 1∕n enters through the remaining integral, giving 1∕n2.

This is the concrete calculus behind the spectral-decay comparison.

13 How much faster is 1∕n2 decay?

The phrases “1∕n decay” and “1∕n2 decay” become more intuitive if we compare harmonics whose index differs by a factor of two.

For the sawtooth envelope,

|b(s)|   1∕(2n)    1
-2(ns)-=  -------=  -.
|bn  |    1∕n      2
(72)

Doubling harmonic number cuts the envelope in half.

For the triangle envelope,

|a(2t)n|   1∕-(2n-)2   1-
  (t)  ∼   1∕n2  =  4,
|an |
(73)

where the comparison refers to the nonzero-harmonic envelope rather than to an even triangle coefficient, which is exactly zero.

Thus doubling harmonic number reduces the triangle-wave envelope by a factor of four.

For equal amplitude A, a few representative magnitudes are

nsawtooth envelope 2A∕(πn)triangle envelope 8A∕(π2n2)



1 0.63662A 0.81057A
3 0.21221A 0.09006A
5 0.12732A 0.03242A
9 0.07074A 0.01001A

The triangle’s fundamental can be larger, yet its higher harmonics become smaller much more quickly.

14 Why other books may show different-looking formulas

A periodic waveform can be shifted horizontally without changing its geometric shape. A shift changes Fourier phase, so two correct series for “a triangle wave” need not look identical.

Our centered triangle has its positive peak at x = 0 and is even. Therefore its series uses cosine terms:

       8A  ∑∞  cos[(2k + 1)x]
t(x) = --2     ----------2--.
        π  k=0   (2k + 1)
(74)

Now shift the waveform by π∕2:

        (     π)
u(x) = t x −  -- .
              2
(75)

Then

u(x) = 8A
--2
 π ∑ k=0∞    1
--------2
(2k + 1 ) cos [        (     π) ]
 (2k + 1)  x − --
               2. (76)

For an odd integer m = 2k + 1,

   (           )
cos  mx −  m-π-  = (− 1)k sin (mx ).
            2
(77)

Therefore

       8A ∑∞    (− 1)k
u(x) = --2    --------2 sin [(2k + 1)x].
       π   k=0(2k + 1)
(78)

So a sine-only triangle-wave formula found in another reference may simply describe a triangle wave whose origin is chosen at a different point in the cycle.

The same warning applies to the sawtooth. Reversing the ramp direction changes coefficient signs, and shifting the jump changes harmonic phases. Always compare the waveform definition before comparing formulas.

15 General interval [−L,L]: sawtooth

Define

        A
sL(x) = --x,     − L < x < L,
        L
(79)

with period 2L.

FS06 gives the sine coefficient formula

        ∫ L         (     )
     -1               nπx-
bn = L   −L sL(x)sin   L    dx.
(80)

By odd symmetry,

     2A ∫  L     ( nπx )
bn = --2    x sin   ----  dx.
     L    0         L
(81)

The same integration-by-parts calculation gives

             n+1
b  =  2A(−-1)---.
 n       n π
(82)

Therefore

             ∞             (     )
        2A- ∑   (− 1)n+1     nπx-
sL(x) ∼  π         n    sin   L    .
            n=1
(83)

Notice something important: the coefficient numbers are independent of L. Changing L changes the basis frequencies, not the dimensionless coefficient pattern for the same normalized waveform shape.

16 General interval [−L,L]: triangle wave

Define

          (        )
               2-|x|
tL (x ) = A  1 −   L   ,     − L ≤ x ≤  L.
(84)

This waveform is even and has zero mean. Its cosine coefficients are

      1 ∫ L          (n πx)
an =  --    tL(x)cos  ----  dx.
      L  −L            L
(85)

After the scaled substitution u = πx∕L, the integral becomes exactly the same dimensionless integral as on [−π,π]. Therefore

      -4A--         n
an =  π2n2 [1 − (− 1) ].
(86)

Thus

           ∑∞               (            )
tL (x) = 8A-    ----1---- cos  (2k-+-1)πx-  .
        π2  k=0 (2k + 1)2           L
(87)

Again the numerical coefficients are unchanged. Only the harmonic spatial frequencies depend on L.

17 Time-domain forms

For a time-periodic signal of period T, use

      T
L −→  --,     x −→  t,
       2
(88)

so that

      2π
ω0 =  --.
      T
(89)

A centered sawtooth may be written over one period as

s(t) = 2A-t,    − T-<  t < T-.
       T          2        2
(90)

Its series is

          ∑∞      n+1
s(t) ∼ 2A-     (− 1-)--sin(nω0t).
       π  n=1    n
(91)

A centered triangle wave is

         (        )
               4|t|         T        T
t(t) = A  1 −  ---- ,    − -- ≤ t ≤ --,
               T            2        2
(92)

with series

      8A  ∞∑  cos[(2k + 1)ω t]
t(t) = --2    ------------20--.
      π   k=0    (2k + 1)
(93)

18 Numerical example: equal-amplitude waveforms

Let

A =  5 V,     f0 = 1 kHz.
(94)

Then

T =  1 ms,     ω0 = 2π(1000 ) rad ∕s.
(95)

For the sawtooth,

b1 = 10
---
π V ≈ 3.1831 V, (96)
b2 = −5-
π V ≈−1.5915 V, (97)
b3 = 10-
3π V ≈ 1.0610 V. (98)

For the triangle wave,

a1 = 40
--2
π V ≈ 4.0528 V, (99)
a3 = -40-
9π2 V ≈ 0.4503 V, (100)
a5 = -40--
25π2 V ≈ 0.1621 V. (101)

The triangle-wave harmonics decrease much more rapidly.

At the same fundamental frequency, the two waveforms therefore place very different amounts of signal amplitude into their high-frequency harmonics.

19 What FS08 has established

We can now summarize the two complete series.

For the odd sawtooth,

          ∑∞       n+1
A-x ∼  2A-    (−-1)---sin(nx ),     − π < x < π.
π      π  n=1    n
(102)

For the centered triangle wave,

  (     2|x|)    8A  ∞∑  cos[(2k + 1)x]
A   1 − ----   = --2    -----------2--.
         π       π   k=0   (2k + 1)
(103)

The essential comparison is

                                       1
sawtooth  jump  in value   =⇒    |cn| ∼ n-,
(104)

whereas

                                                     1
triangle continuous with  slope jumps    =⇒     |cn| ∼ -2-.
                                                    n
(105)

This is our first explicit spectral signature of smoothness.

PIC

Figure 8. FS08 closes the first waveform-derivation block. FS09 formalizes even and odd symmetry as a systematic coefficient-reduction tool.

20 Self-check questions

  1. Why does the sawtooth have no cosine coefficients?
  2. Why does the triangle wave have no sine coefficients?
  3. Why do all positive integer harmonics appear in the sawtooth series?
  4. Why do only odd harmonics appear in the centered triangle-wave series?
  5. Which waveform is continuous at the period boundary?
  6. Which coefficient law decays faster: 1∕n or 1∕n2?
  7. What feature of the triangle wave prevents the classic jump-type Gibbs phenomenon in the function itself?
  8. Why do the dimensionless coefficient values remain unchanged when the interval changes from [−π,π] to [−L,L] for geometrically similar waveforms?
  9. How is the derivative of the triangle wave related to a square wave away from the corners?
  10. Which later article will justify differentiation and integration of Fourier series more carefully?

21 Practice problems

  1. For A = 3, compute b1,b2,b3,b4 for the sawtooth wave.
  2. Write the five-harmonic partial sum S5(s)(x) for a unit-amplitude sawtooth.
  3. Verify directly that the sawtooth has zero mean on [−π,π].
  4. For A = 2, compute a1,a3,a5 for the triangle wave.
  5. Verify that the triangle-wave constant coefficient is zero by comparing positive and negative triangular areas.
  6. Show from Eq. (43) that all even cosine coefficients vanish.
  7. Evaluate the first four nonzero terms of the triangle-wave series at x = 0 and compare with A.
  8. On [−L,L], derive the sawtooth coefficient bn directly rather than by rescaling.
  9. On [−L,L], derive the triangle coefficient an using u = πx∕L.
  10. Explain in words why a 1∕n2 spectrum is more concentrated at low harmonics than a 1∕n spectrum.
  11. For a 500 Hz sawtooth, list the frequencies of its first six harmonics.
  12. For a 500 Hz triangle wave, identify which of the first six integer harmonic frequencies have zero coefficients.

22 Where the series goes next

FS07 and FS08 used symmetry repeatedly because it was useful. FS09 now makes that idea systematic. It develops even and odd decomposition as a general Fourier tool, clarifies when sine or cosine families disappear, and prepares for half-range expansions later in the sequence.

References

[1]   R. V. Churchill and J. W. Brown, Fourier Series and Boundary Value Problems, McGraw-Hill.

[2]   E. Kreyszig, Advanced Engineering Mathematics, Wiley.

[3]   R. N. Bracewell, The Fourier Transform and Its Applications, McGraw-Hill.


"Sawtooth and Triangle Waves" is owned by bloftin.
(view preamble)
View style:
Other names:  FS08
Also defines:  sawtooth wave, triangle wave, sawtooth Fourier series, triangle-wave Fourier series, harmonic-coefficient decay, spectral-decay comparison
Keywords:  Fourier series, sawtooth wave, triangle wave, harmonic spectrum, coefficient decay, spectral decay, partial sums, waveform smoothness, piecewise linear waveform

Cross-references: fundamental frequency, frequencies, FS06, phase, Power, relation, harmonic number, amplitude, spectrum, identity, tension, functions, partial sum, magnitude, formula, half-wave antisymmetry, piecewise linear, boundary, period, periodic, Fourier coefficients, harmonic, domain, square wave, Fourier series, FS07
There are 2 references to this object.

This is version 1 of Sawtooth and Triangle Waves, born on 2026-11-11.
Object id is 1582, canonical name is SawtoothAndTriangleWaves.
Accessed 3 times total.

Classification:
Physics Classification: 02.30.Nw (Fourier analysis)
 02.30.Lt (Sequences, series, and summability)

Pending Errata and Addenda

None.

Discussion

No messages.

Interact