Johann Sebastian Bach’s Musical Offerings contains ten canons: in each of these, a musical line is played twice (four times in canon 10) and the second version is transformed by shift in time and/or pitch or is played upside-down or backwards. All of these transformations can be exemplified by elementary functions, as Tony Phillips from AMS thoroughly illustrates.
In fact, in mathematical terms, the canon is a periodic function, where, for example, f is the first voice and g is the second, we will have g(t)=f(t-x), with t indicating the numbers of measures and x the interval difference between g and t.
Canon 5, described as per tonos is g(t) = f(t-1) + H where H indicates that the pitch has shifted by a perfect fifth.
Bach described Canon 3 had to be executed “per motum contrarium”. Canon 3 is g(t) = -f(t-0.5) + K.
Canon 4 is to be played, as Bach notated, per augmentationem contrario motu. Each note in voice 2 has double the value it had in voice 1. Voice 2 moves with “half the speed” of voice 1. Fun fact: both canon 3 and 4 present an upside-down second clef. Canon 4 is g(t) = -f((t-0.5)/2) + L.
Canon 1, the most peculiar, is described as cancrizans (lit. “crabwise”), which means that voice 2 plays the score of voice 1 backwards. This canon is 18 measures long (8.5 bars of royal theme, 9.5 bars of counterpoint) and both voices start simultaneously.