# Discontinuous function with continuous derivative

Differentiability implies continuity, but what in this case ? $$f(x) = \frac{1}{\sqrt{2}}\arctan\left(\sqrt{2} \tan{x}\right)$$ It's discontinuous at $x = \pi/2 + n\pi$, $n$ is integer. But, $$g(x) = \frac{1}{1+\sin^2{x}}$$ It's continuous over real numbers and it's the derivative of $f(x)$.

How could it be?

When I make the definite integral of $g(x)$ from $1.5$ to $4$ using the formal definition of definite integral:

$f(4) - f(1.5) = -0.352255$, which is totally wrong. but when I make Riemann sum to approximate it, I get $1.86919$.

So what I miss ??

The question may be asked in inverse manner.

g(x) is a continuous positive function over all real numbers, so its anti-derivative MUST be an increasing continuous function.

• The function $f(x)$ is not defined when $x$ is of the shape $\pi/2+n\pi$. Jul 8, 2015 at 20:29
• For the second part the FTOC is not applicable. Check the hypotheses. Jul 8, 2015 at 20:33
• The formula you used to define $f(x)$ by is not defined at the points where you say the function is discontinuous. You need to define the function at those points before talking about continuity or discontinuity at those points. (To anticipate other people's objections, I realize the function has no continuous extension to a function from the reals to the reals, but I don't think this is what the OP meant.) Jul 8, 2015 at 20:35
• @DaveL.Renfro The question may be asked in inverse manner. g(x) is a continuous positive function over all real numbers, so its anti-derivative MUST be an increasing continuous function. Jul 9, 2015 at 0:40 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.}$$ 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}.$$ 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.

• Nice diagram (as well as good explanation!) Jul 8, 2015 at 20:55
• Thanks a lot for your helpful answer. Where could I read further information about this behavior ? --- Let's inverse the question,g(x) is continuous positive function over all real numbers, so its antiderivative MUST be increasing continuous function, right? Jul 8, 2015 at 21:14
• @MohamedMostafa: Offhand I don't know of a good written reference, but working out these issues yourself is a great way to learn about "branches" of inverse functions. :) Thinking about $\cos$ and $\arccos$ is an excellent exercise; the main point is, since $0 \leq \arccos y \leq \pi$ for all real $y$, the equation $x = \arccos(\cos x)$ cannot possibly hold unless $0 \leq x \leq \pi$. The trig functions fail to be invertible because they're not one-to-one ("not injective"); for example, $\cos(x + 2\pi) = \cos(x)$ for all $x$, so there's no unique way to recover the input from the output value. Jul 8, 2015 at 21:48
• Also, you're perfectly correct that every antiderivative of $g$ is continuous (in fact, "continuously differentiable") and increasing. Jul 8, 2015 at 21:49
• @AndrewD.Hwang: I worked on this function on Mathematica, I ploted the integral of the function:$$g(x) = \frac{1}{1+\sin^2{x}}$$ with the FTC definition ( integration from 0 to x of g(t) dt ), and I got increasing continuous graph as expected. How could this differ from analytical antiderivative $$f(x) = \frac{1}{\sqrt{2}}\arctan\left(\sqrt{2} \tan{x}\right)$$ ? Jul 9, 2015 at 0:47

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\}$.

• The question may be asked in inverse manner. g(x) is a continuous positive function over all real numbers, so its anti-derivative MUST be an increasing continuous function. Jul 8, 2015 at 21:20

Differentiability implies continuity on the domain of the function. And the domain of a function is not necessarily the whole of $\mathbf R$.

$g(x)$ is NOT the derivative of $f(x)$ at points of discontinuity because $f(x)$ isn't differentiable there!

To obtain this derivative you need to use the chain rule. Essentially, $$\frac{d}{dx}\arctan(\sqrt{2}\tan(x))=\left(\frac{d}{dx}\sqrt{2}\tan(x)\right)\left(\frac{d}{d(\sqrt{2}\tan(x))}\arctan(\sqrt{2}\tan(x))\right).$$ But the chain rule only applies when both of these derivatives exist. The first of these two doesn't exist at certain points (as you have noted), so the derivative you have given does not apply at these points. So in fact the derivative is $$f'(x)=\cases{\frac{1}{1+\sin^2(x)} & \text{ if x\neq \pi/2+n\pi}\\ \text{d.n.e.} & \text{otherwise.}}$$ Thus, the function is not differentiable at these points, even if these are removable singularities in the derivative.

• The question may be asked in inverse manner. g(x) is a continuous positive function over all real numbers, so its anti-derivative MUST be an increasing continuous function. Jul 8, 2015 at 21:21

In the paper "Rectifying Transformations for the Integration of Rational Trigonometric Functions" by D. J. Jeffrey, he writes:

$$\int \frac{2\, \mathrm{d}z}{1+\cos^2 z} = \sqrt{2} z + \arctan \frac{\cos{z}}{\sin{z} + \sqrt{2} + 1} + \arctan \frac{\cos{z}}{\sin{z} - \sqrt{2} - 1}$$

And this primitive is continuous over all $$\mathbb{C} \setminus \{ z \in \mathbb{C} \, \vert \, 1+\cos^2 z = 0 \}$$

You can obtain your integral by using the complementary angle identity for $$\cos z$$.