$\displaystyle{\int\sqrt{\tan x}}~dx$

Today, we’ll integrate this POS function you see right before you. Since this page will probably be long enough, I’ll just get on with it.

If you haven’t seen this before, you might think that it would work to make use of u = tanx and du = sec2x dx, or alternatively, du = u2 + 1 dx. The only issue here is that we end up with this integral $$ \int\frac{\sqrt{u}}{u^2+1}~du $$ and this doesn’t help us at all because since the square root on top is a fractional power, and working with integrating that is quite difficult. We can just make another substitution, but we can also just eliminate the use of the square root from the first substitution altogether.

Consider letting $$ \begin{align} u&=\sqrt{\tan x}\newline du&=\frac{\sec^2x}{2\sqrt{\tan x}}~dx\Rightarrow du=\frac{u^4+1}{2u}~dx \end{align} $$ Now, we’re able to come up with this integral $$ \int\frac{2u^2}{u^4+1}~du $$ As I’ve said earlier, we could just make the substitution t2 = u and thus 2t dt = du above and end up with the same integral, but this looks cooler. Now we have options.

We can either break this up using partial fractions, or use some algebra. Since I’m here to use the most straightforward and classic method, let’s now split this into partial fractions.

The first step of partial fractions is to factor the denominator. To do this, we can always try and look at the denominator in terms of the formula (a+b)2 = a2 + 2ab + b2.

In this case, we can look at u4 + 1 as (u2)2 + (1)2. We’re just missing a “2ab” term. So we’ll just add it in and subtract it back again, like so $$ \begin{align} u^4+1&=(u^2)^2+(1)^2\newline &=(u^2)^2+2(u^2)(1)+(1)^2-2(u^2)(1)\newline &=(u^2+1)^2-2u^2 \end{align} $$ Now we’ve made this into a difference of squares, which can be factored [i.e. a2 - b2 = (a+b)(a-b)]. Thus, we end up with $$ \begin{align} u^4+1&=(u^2+1)^2-(\sqrt2u)^2\newline &=(u^2+\sqrt2u+1)(u^2-\sqrt2u+1) \end{align} $$ Now that we’ve factored the denominator, we can actually use partial fractions. Just a little reminder our integral can be transformed now $$ 2\int\frac{u^2}{(u^2+\sqrt2u+1)(u^2-\sqrt2u+1)}~du $$ Yeah, yeah, it somehow looks fucking worse than it did before, but at least we can do partial fractions on it. It’s like breaking someone’s nose to fix it back again. They do still do that, right?

Anyways, we’ll set up the partial fractions like so $$ \frac{u^2}{(u^2+\sqrt2u+1)(u^2-\sqrt2u+1)}=\frac{Au+B}{u^2-\sqrt2u+1}+\frac{Cu+D}{u^2+\sqrt2u+1} $$ Now we multiply both sides by the great denominator on the LHS: $$ \begin{align} u^2&=(Au+B)(u^2+\sqrt2u+1)+(Cu+D)(u^2-\sqrt2u+1)\newline &=\color{red}{Au^3}+\color{blue}{\sqrt2Au^2}+\color{green}{Au}+\color{blue}{Bu^2}+\color{green}{\sqrt2Bu}+\color{orange}{B}\newline &+\color{red}{Cu^3}-\color{blue}{\sqrt2Cu^2}+\color{green}{Cu}+\color{blue}{Du^2}-\color{green}{\sqrt2Du}+\color{orange}{D} \end{align} $$ Finally, we can start equating powers. There are two powers that have exactly two terms, 3 and 0. We’ll now equate those $$ \color{red}{Au^3}+\color{red}{Cu^3}=0\Rightarrow \color{red}{A}=\color{red}{-C} $$ and also $$ \color{orange}{B}+\color{orange}{D}=0\Rightarrow \color{orange}{B}=\color{orange}{-D} $$