# Differentiating a Triangle Wave function?

Okay this might be a fairly trivial question but I'm a little unsure how to approach it. I'd like to differentiate a triangle wave, as defined in the article: https://en.wikipedia.org/wiki/Triangle_wave

Note that I don't want to work with the Fourier equation or the Trigonometric equation versions of the Triangle Wave, but instead I would rather work with an equation which does not have any trigonometric functions if possible. For example, the wikipedia article listed above has an equation such as:

$x(t) = 2 \left| 2 \left( \frac{t}{a} - \left \lfloor{\frac{t}{a} + \frac{1}{2}}\right \rfloor \right) \right|$

where I take $a = 1$. The problem however is that I don't know how to differentiate functions such as "floor" or "mod"... is such a thing even possible? If not, are there any other equations for the Triangle Wave which do not have any trigonometric terms in it but which can be differentiated?

Thanks!

EDIT: Okay so as stupid as this might be, it honestly didn't occur to me to read up on the square wave function (which is the derivative of the triangle wave), so I guess my question has been more or less answered. Out of curiosities sake however, I am interested in finding out how this is derived, especially since users below mentioned how the floor function has either derivative $0$ or has no derivative. If that's the case, how do we differentiate the triangle wave to obtain the square wave?

• A floor function can be piecewise derived. Commented Jul 31, 2016 at 2:41
• @CaveJohnson: The correct verb is "differentiate" (as OP demonstrates), not "derive", despite the word "derivative". Just saying.
– MPW
Commented Jul 31, 2016 at 3:46

Hint: The floor function is flat between integers, and has a jump at each integer; so its derivative is zero everywhere it exists, and does not exist at integers.

The mod function coincides with identity between $0$ and the divisor; so its derivative is $1$ everywhere it exists, and does not exist at integral multiples of the divisor.

Theoretically, you would take piece-wise derivatives on small intervals on which the floor function is constant and the absolute-value function is either positive or negative. But to make it easy on you, you can visualize it. It's going to be a step function that alternates between some $C$ and some $-C$.

You cannot expect a finite "analytic expression" for a function that is not analytic, but a piecewise linear function.

The Fourier expansion of your triangle wave function $t\mapsto x(t)$ provides a globally uniform approximation of $x(\cdot)$ by analytic functions, but is slowly convergent, and you decline it anyway.

A triangular wave function is continuous, clearly $C^\infty$ on its linear stretches, but has two "corners" per period where only one-sided derivatives exist (of all orders). The single interesting value of the first derivative can be immediately read off from the graph, and does not require differentiating floor and mod functions.

These are the facts, and no notational trick can make them go away.