Discontinuous function with continuous derivative

A discontinuous periodic function and its continuous derivative

The moral is, a discontinuous periodic function can have continuous derivative. (More precisely, a periodic function whose left- and right-hand limits are unequal at some points can, nonetheless, have derivative with removable discontinuities.)

The trig functions and the principal branches of their inverses are good at creating this type of behavior. While it's true that $$ \tan(\arctan x) = x\quad\text{for all real $x$,} $$ it's not true that $$ \arctan(\tan x) = x\quad\text{for all real $x$,} $$ only that $$ \arctan(\tan x) = x\quad\text{for all real $x$ with $|x| < \pi/2$.} $$


Edit: The arctangent function (also known as "the principal branch of arctan"), shown bold in the graph below, is single-valued. The tangent function, however, is periodic with period $\pi$, so there are infinitely many branches of inverse tangent, any two differing by an integer multiple of $\pi$. For every integer $n$, we have $$ x = \arctan(\tan x) + n\pi\quad\text{for $(n - \tfrac{1}{2})\pi < x < (n + \tfrac{1}{2})\pi$.} $$

Branches of arctan

Consider the functions $$ f(x) = \frac{1}{\sqrt{2}} \arctan(\sqrt{2} \tan x),\qquad F(x) = \int_{0}^{x} \frac{dt}{1 + \sin^{2} t}. $$ The definite integral of g These functions have the same derivative $g$ for all real $x$ unless $x = (n + \frac{1}{2})\pi$ for some integer $n$; for these $x$, the value $f(x)$ is undefined, because $\tan(n + \frac{1}{2})\pi$ is undefined. Call these points poles of the tangent function.

As $x$ runs over the period interval $(n - \frac{1}{2})\pi < x < (n + \frac{1}{2})\pi$ between two poles of the tangent function, $\sqrt{2}\tan x$ runs once over the entire real line, so $\arctan(\sqrt{2}\tan x)$ runs once over the interval $(-\frac{1}{2}\pi, \frac{1}{2}\pi)$. The graph of $f$ consists of "repeated units", with a "jump" at each point $(n + \frac{1}{2})\pi$; the function $f$ "forgets" how many poles of tan lie between $0$ and $x$.

By contrast, the graph of $F$ "remembers" how many poles lie between $0$ and $x$. When $x$ crosses a pole of tan, $\sqrt{2}\tan x$ "jumps" from being "near $+\infty$" to being "near $-\infty$". Because area under the graph of $g$ accumulates continuously, the value of $F$ "continues" using the "next-highest" branch of arctan. Loosely, instead of "returning to $-\infty$ and re-using the same branch of arctan" (as $f$ does), $F$ continues by "following a dashed line from right to left" and starting on the next branch of arctan.

That is how $f$ and $F$ manage to have the same derivative (except at the poles of tan, where $f$ is undefined), but $f$ is periodic while $F$ extends continuously over the poles.

In the extended real numbers $[-\infty, \infty]$, in fact, arctan has a continuous extension, defined by $$ \arctan(\pm\infty) = \lim_{x \to \pm\infty} \arctan x = \pm\tfrac{1}{2}\pi. $$ This isn't much help with $f$, because now $f$ gets two values at each pole of tan, namely $\pm \frac{\pi}{2\sqrt{2}}$, but it does dictate why each time $x$ crosses a pole of tan, $F$ "climbs" to the next branch of arctan, and it shows why $F$ is continuous at the poles of tan.


The derivative of $f$ at $x$ is, by definition, $$f'(x) = \lim_{h \to 0}\frac{f(x+h)-f(x)}{h}.$$ This definition is meaningless when $f(x)$ is not defined. The expression for the derivative you gave is meaningful when $x \neq \pi/2 + n\pi$, $n \in \mathbb{Z}\setminus\{0\}$.