Evaluating $\int_{0}^{\pi/4}\left[4\cos^2(x)-1\right]{\sqrt{\tan x}}\,\mathrm dx$ in a less tedious way Consider this integral

$$\int_{0}^{\pi/4}\left[4\cos^2(x)-1\right]\color{red}{\sqrt{\tan x}}\,\mathrm dx\tag1=1$$

An attempt:
Rewrite $(1)$ as
$$\int_{0}^{\pi/4}4\cos^2(x)\sqrt{\tan x}\,\mathrm dx-\int_{0}^{\pi/4}\sqrt{\tan x}\,\mathrm dx=I_1-I_2\tag2$$
For $I_2$ we choose $u=\sqrt{\tan x}\implies {2u\over 1+u^2}dx=dx$, then it becomes
$$\int_{0}^{1}{2u^2\mathrm du\over 1+u^4}\tag3$$
Rearrange $(3)$ in the form of
$$\int_{0}^{1}{1+{1\over u^2}\over u^2+{1\over u^2}}\mathrm du+\int_{0}^{1}{1-{1\over u^2}\over u^2+{1\over u^2}}\mathrm du\tag4$$
Apply completing the square to $(4)$
$$\int_{0}^{1}{1+{1\over u^2}\over \left(u-{1\over u}\right)^2+2}\mathrm du+\int_{0}^{1}{1-{1\over u^2}\over \left(u+{1\over u}\right)^2-2}\mathrm du=I_3+I_4\tag5$$
For $I_3$ setting $v_1=u-{1\over u}$ and for $I_4$ setting $v_2=u+{1\over u}$ then 
$$\left.{1\over \sqrt{2}}\tan^{-1}\left({v_1\over \sqrt{2}}\right)\right|_{0}^{\infty}-{1\over \sqrt{8}}
\left.\ln{\left({v_2+\sqrt{2}\over v_2-\sqrt{2}}\right)}\right|_{2}^{\infty}={\pi\over \sqrt{8}}+{1\over \sqrt{8}}\ln{(3+2\sqrt{2})}\tag6$$
We can rewrite $I_1$ as
$$I_1=2\int_{0}^{\pi/4}\sqrt{\tan x}\,\mathrm dx+2\int_{0}^{\pi/4}\cos(2x)\sqrt{\tan x}\,\mathrm dx\tag7$$
$$I_1=2\cdot(6)+2\int_{0}^{\pi/4}\cos(2x)\sqrt{\tan x}\,\mathrm dx\tag8$$
$(8)$ we can apply integration by part, I am sure it would be lengthy.
How else can we tackle $(1)$ in another less lengthy way?
 A: I don't see an easy approach to tackle your last integral : you can apply the method I will show just after this block of text, but it is faster to apply it directly to the initial integral.
Here is the other approach :
$$I=\int_{0}^{\pi/4}\left[4\cos^2(x)-1\right]{\sqrt{\tan x}}\mathrm dx={\displaystyle\int}_0^{\pi/4}\class{steps-node}{\cssId{steps-node-1}{\sec^2\left(x\right)}}\class{steps-node}{\cssId{steps-node-2}{\left(-\dfrac{\sqrt{\tan\left(x\right)}\left(\tan^2\left(x\right)-3\right)}{\left(\tan^2\left(x\right)+1\right)^2}\right)}}\,\mathrm{d}x$$
By using the identities $\cos(x)=\frac{1}{\sec(x)}$ and $\sec^2(x)=1+\tan^2(x)$.  
Now you can substitute $u=\tan(x)$ and $du=\sec^2(x) dx$.
$$I=-{\displaystyle\int}_0^1\dfrac{\sqrt{u}\left(u^2-3\right)}{\left(u^2+1\right)^2}\,\mathrm{d}u$$
Now you can substitute $v=\sqrt u$ and $dv=\frac{du}{2\sqrt u}$.
$$I=\class{steps-node}{\cssId{steps-node-3}{-2}}{\displaystyle\int}_0^1\dfrac{v^2\left(v^4-3\right)}{\left(v^4+1\right)^2}\,\mathrm{d}v$$
Now you can do a long division and finish.
A: $\displaystyle J=\int_{0}^{\pi/4}\left[4\cos^2(x)-1\right]{\sqrt{\tan x}}\,\mathrm dx$
Perform the change of variable $y=\dfrac{\pi}{2}-x$,
$\displaystyle J=\int_{\tfrac{\pi}{4}}^{\tfrac{\pi}{2}}\dfrac{4(\sin x)^2-1}{\sqrt{\tan x}}dx$
Perform the change of variable $y=\sqrt{\tan x}$,
$\begin{align} J&=\int_{1}^{\infty} \dfrac{\tfrac{4}{1+\frac{1}{x^4}}-1}{x}\times \dfrac{2x}{1+x^4}dx\\
&=2\int_{1}^{\infty} \dfrac{3x^4-1}{(1+x^4)^2}dx\\
&=2\left[\dfrac{-x}{1+x^4}\right]_{1}^{\infty}\\
&=2\times \left(0+\dfrac{1}{2}\right)\\
&=\boxed{1}
\end{align}$
A: What has been seen cannot be unseen:
$$
\begin{aligned}
\int (4\cos^2x-1)\sqrt{\tan x}\,dx&=\int (1+2\cos 2x)\sqrt{\tan x}\,dx\\
&=\int\sin 2x\frac{1}{2\sqrt{\tan x}}\frac{1}{\cos^2 x}+2\cos 2x\sqrt{\tan x}\,dx\\
&=\int \sin2x\frac{d}{dx}\sqrt{\tan x}+\Bigl(\frac{d}{dx}\sin 2x\Bigr)\sqrt{\tan x}\,dx\\
&=\int \frac{d}{dx}\Bigl(\sin 2x\sqrt{\tan x}\Bigr)\,dx\\
&=\sin 2x\sqrt{\tan x}+C.
\end{aligned}
$$
Then just insert limits, and you will get

$$\int_0^{\pi/4}\bigl(4\cos^2x-1\bigr)\sqrt{\tan x}\,dx=1.$$

