y=xxy = x - \lfloor x \rfloor

Graph of the Fractional Part y=xxy = x - \lfloor x \rfloor (Sawtooth Wave)

y=xxy = x - \lfloor x \rfloor extracts the fractional part of xx, and is often written {x}\{x\}1. Subtracting the floor function x\lfloor x \rfloor, the largest integer not exceeding xx, removes the integer part and leaves the fraction behind.

xxx\lfloor x \rfloorxxx - \lfloor x \rfloor
2.32.3220.30.3
555500
1.2-1.22-20.80.8

For a negative number the floor function returns the integer below, so the result is always non-negative. That the fractional part of 1.2-1.2 is 0.80.8 sits a little oddly with intuition, so it is worth noting.

Domain and range

The domain is all real numbers and the range is 0y<10 \leq y < 1. The value never reaches 11.

Periodicity and shape

The function has period 11, with {x+1}={x}\{x + 1\} = \{x\}. Over each interval between consecutive integers it is a straight line of slope 11.

y=xn(nx<n+1)y = x - n \quad (n \leq x < n+1)

It starts at 00 when x=nx = n, climbs straight up, and approaches 11 just before the next integer. That shape repeating is why the graph is called a sawtooth wave.

Discontinuities and jumps

The function is discontinuous at every integer. Approaching an integer nn from the left the value tends to 11, but at x=nx = n it is reset to 00. The jump is therefore 1-1: the curve falls back to the floor just before it would reach the ceiling. Each step includes its left end, where the value is 00, and excludes its right end.

That the floor function is right-continuous carries over directly to this one.

Relations to other functions

  • The fractional part is built from the floor function and agrees with xmod1x \bmod 1
  • The value is 00 exactly when xx is an integer
  • Writing x=x{x}\lfloor x \rfloor = x - \{x\} recovers the floor function from the fractional part

Fourier series

At non-integer points the function is given by the following series.

xx=121πn=1sin(2πnx)nx - \lfloor x \rfloor = \frac{1}{2} - \frac{1}{\pi}\sum_{n=1}^{\infty}\frac{\sin(2\pi n x)}{n}

The constant term 12\dfrac{1}{2} is the average height over one period. Unlike a square wave this one contains even harmonics as well, and the coefficients decay as 1n\dfrac{1}{n}. Since the waveform has jumps the convergence is slow, and partial sums show the Gibbs phenomenon.

Applications

  • The oscillator waveform of a synthesizer
  • The phase accumulator that advances a phase repeatedly from 00 to 11
  • Computations with remainders in general

Containing every harmonic gives it a bright timbre, which makes it a favorite starting point for subtractive synthesis, where a filter carves the sound out.

  1. Sawtooth wave, Wikipedia