# Continuous antiderivative of $\frac{1}{1+\cos^2 x}$ without the floor function.

By letting $u = 2x$ and $t = \tan \frac{u}{2}$, I found the continuous antiderivative of the function to be:

$$\int \frac{1}{1+\cos^2 x}dx\\= \int \frac{2}{3+\cos2x} dx\\ = \int \frac{1}{3+\cos u}du \\=\int \frac{\frac{2}{1+t^2}}{3+\frac{1-t^2}{1+t^2}}dt\\= \int\frac{1}{2+t^2}dt \\= \frac{1}{\sqrt2}\arctan\left(\frac{\tan x}{\sqrt2}\right) + \frac{\pi}{\sqrt2} \left\lfloor \frac{x + \frac{\pi}{2} }{\pi} \right\rfloor + C$$

(I graphically deduced the floor function bit as I am not familiar with its algebra.)

However, GeoGebra (notably not wolfram) does it better. It states, without the floor function, that the continuous antiderivative is also:

$$\frac{x}{\sqrt2} + \frac{1}{\sqrt2} \arctan\left( \frac{(1-\sqrt2)\sin 2x}{(\sqrt2 -1)\cos2x +\sqrt2 + 1}\right) + C$$

How did GeoGebra accomplish such a feat? And how can I prove and apply such ingenuity?

• Can you please show your steps? – Gibbs Jun 3 '18 at 18:51
• Should I add it to the question or post in here? But.. why did you remove the parentheses of my trig functions :( I liked those, but thanks for making floor function big. – Mint Jun 3 '18 at 18:57
• Adding the steps in the question is fine. Some of the parentheses were not necessary. The expressions $\cos^2 (x), \tan (x)$ are the same as $\cos^2 x, \tan x$, etc. – Gibbs Jun 3 '18 at 19:00
• Related articles: jstor.org/stable/2690852 doi.org/10.1145/174603.174409 – StayHomeSaveLives Jun 4 '18 at 14:59

One important thing is while doing u-substitution, the substitution has to be injective. When we substitute $u=\tan x$ in samjoe’s answer, $\tan x$ is not injective on the whole real line, but is injective in intervals of length $\pi$. That’s why you get the right ‘behavior’ only within intervals but not between them.

I believe that the Geogebra’s answer can be derived by noting that $$\frac1{\pi}(arctan(\cot(\pi x))+\pi x-\pi/2)$$ behaves exactly the same as a floor function.

Use also the summation formula for arctan: $$arctan (u)+arctan (v)=arctan(\frac{u+v}{1-uv})$$

To demonstrate the importance of injectivity of substitutions, consider the integral $$\int^1_{0}xdx$$ which equals $\frac12$.

If we substitute in $u=x^2-x$, we obtain something like $$\int^0_0 \cdots du=0$$

What caused the paradox is $x^2-x$ is not injective in the interval $[0,1]$.

Similarly, there is nothing wrong for $$\int^x_k \frac1{1+\cos ^2x}dx=\int^x_k\frac{\sec^2x}{2+\tan^2x}dx=^{u=\tan x}\int^{arctan(x)}_{arctan(k)}\frac{du}{2+u^2}=\frac1{\sqrt2}arctan(\frac{\tan x}{\sqrt2})+C$$ as long as $\tan x$ is injective in the interval $[k,x]$. If the injectivity is not achieved in the interval, $C$ would change when $x$ goes from an injective interval of $\tan x$ to another.

This agrees with what the OP observed: the floor function thing is a constant in each injective interval of $\tan x$, and changes when going across the intervals. You may consider, the floor function thing is part of $C$.

The choice of $k$ is arbitrary. But when we try to find an antiderivative for all $x$ while $k$ remains fixed, it is impossible to always achieve the injectivity in $[k,x]$. As a trade off, we need to add a floor function to compensate for the silent change of $C$.

@samjoe derived the antiderivative $$\frac{\pi}{\sqrt2}\left \lfloor\frac{x+\pi/2}{\pi}\right\rfloor + \frac{1}{\sqrt 2}\arctan\left(\frac{\tan x}{\sqrt2}\right)$$

By noting $$\lfloor x\rfloor=\frac1{\pi}(arctan(\cot(\pi x))+\pi x-\pi/2)$$, the above expression can be rewritten to $$\frac{x}{\sqrt2}+\frac{arctan(-\tan x)}{\sqrt2}+\frac{arctan(\frac{\tan x}{\sqrt2})}{\sqrt2}$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}({arctan(-\tan x)}+arctan(\frac{\tan x}{\sqrt2}))$$ By the summation formula stated above $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{-\tan x+\frac{\tan x}{\sqrt2}}{1+\frac{\tan^2x}{\sqrt2}})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{\tan x(1-\sqrt2)}{\sqrt2+\tan^2x+1-1})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{\tan x(1-\sqrt2)}{\sqrt2+\sec^2x-1})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{(1-\sqrt2)\sin x\cos x}{(\sqrt2-1)\cos^2 x+1})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{(1-\sqrt2)2\sin x\cos x}{(\sqrt2-1)(2\cos^2 x)+2})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{(1-\sqrt2)\sin 2x}{(\sqrt2-1)(\cos 2x +1)+2})$$ $$=\frac{x}{\sqrt2}+\frac1{\sqrt2}arctan(\frac{(1-\sqrt2)\sin 2x}{(\sqrt2-1)\cos 2x+\sqrt2+1})$$ which is exactly what we want.

• Nice manipulation +1 :), especially that floor equivalent. But I am wondering how can we find this without resorting to that floor. – SJ. Jun 4 '18 at 13:13
• @samjoe I wonder too. – Szeto Jun 4 '18 at 13:35
• Wow, thank you! Any tips on finding alternate forms of the floor function? – Mint Jun 4 '18 at 15:07
• @jiaminglimjm I discovered this form simply by playing around with functions.:) – Szeto Jun 4 '18 at 22:19

With Floor Function

Let $(1+\cos^2x )^{-1} = f(x)$. Now as you found,

$$\int \frac{dx}{1+\cos^2 x} = \int \frac{\sec^2 x }{2+\tan^2 x} dx = \frac{1}{\sqrt{2} } \arctan\left(\frac{\tan x}{\sqrt 2}\right)$$

The issue is that integral of a continuous function should be continuous. The one we found is discontinuous at all odd multiples of $\pi/2$. Lets analyse for $x\in [\tfrac{(2k-1)\pi}{2}, \tfrac{(2k+1 ) \pi}{2}]$. Then

\begin{align} \int_{0}^{x} f(t) dt &= \int_{0}^{\pi/2}f(t) dt+\int_{\pi/2}^{3\pi/2}f(t) dt ... \int_{(2k-1)\pi/2}^{x}f(t) dt \\ &= \frac{\pi k}{\sqrt2} + \frac{1}{\sqrt 2}\arctan\left(\frac{\tan x}{\sqrt2}\right) \\ \end{align}

Now since $x\in [\tfrac{(2k-1)\pi}{2}, \tfrac{(2k+1 ) \pi}{2}],$ then $x+\pi/2 \in [k\pi, (k+1)\pi]$ and so $\frac{x+\pi/2}{\pi} \in [k, k+1]$ so that $\lfloor\frac{x+\pi/2}{\pi}\rfloor = k$. Substituting in above equation gives:

$$\int_{0}^{x} f(t) dt =\frac{\pi}{\sqrt2}\left \lfloor\frac{x+\pi/2}{\pi}\right\rfloor + \frac{1}{\sqrt 2}\arctan\left(\frac{\tan x}{\sqrt2}\right)$$

Without Floor Function

Couldn't do this one, will add if I find one.