Integrate $\int\frac{2t^2}{t^4+1}dt$
While evaluating the integral $\int\sqrt{\tan x}dx$ in Evaluating the indefinite integral $\int\sqrt{\tan x}dx$. using the substitution $t^2=\tan x\implies2tdt=\sec^2x.dx$, thus $$ \int\sqrt{\tan x}dx=\int\frac{2t^2}{t^4+1}dt $$ This is solved using partial fractions, Check answers of @Bhaskara-III, @Harish Chandra Rajpoot. But, what if I try the following
My Attempt $$ \int\frac{2t^2}{t^4+1}dt=\int\frac{2t^2}{(t^2+i)(t^2-i)}dt\\ \frac{2t^2}{(t^2+i)(t^2-i)}=\frac{A}{t^2+i}+\frac{B}{t^2-i}\\ 2t^2=A(t^2-i)+B(t^2+i)\implies A=1, B=1\\ \color{red}{\frac{2t^2}{(t^2+i)(t^2-i)}=\frac{1}{t^2+i}+\frac{1}{t^2-i}}\\ $$ $$ \int\frac{2t^2}{t^4+1}dt=\int\frac{1}{t^2+i}dt+\int\frac{1}{t^2-i}dt=\int\frac{1}{t^2+(\sqrt{i})^2}dt+\int\frac{1}{t^2-(\sqrt{i})^2}dt $$ Is it possible to somehow finish the integration with my substitution ?
Pls check: integrating square root of $\tan x$, answer by @Mhenni Benghorbal, seems to be a similar substitution as in my attempt.
$$t^4+1=(t^2+\sqrt2t+1)(t^2-\sqrt2t+1)$$
By expanding in partial fraction:
$$\frac{2t^2}{1+t^4}=\frac{t/\sqrt2}{t^2-\sqrt2t+1}-\frac{t/\sqrt2}{t^2+\sqrt2t+1}$$
To find the partial fraction decomposition, write
$$\frac{2t^2}{1+t^4}=\frac{at+b}{t^2+\sqrt2t+1}+\frac{ct+d}{t^2-\sqrt2t+1}$$
Multiply both sides by $1+t^4$ and simplify:
$$2t^2=(a+c)t^3+(b+d-\sqrt2a+\sqrt2c)t^2+(a+c+\sqrt2d-\sqrt2b)t+(b+d)$$
Now identify coefficients:
The integral of the first term leads to:
$$\int\dfrac{t/\sqrt2}{t^2-\sqrt2t+1}\mathrm dt=\frac{\sqrt2}{4}\int\dfrac{2t-\sqrt2+\sqrt2}{t^2-\sqrt2t+1}\mathrm dt\\=\frac{\sqrt2}{4}\log|t^2-\sqrt2t+1|+\frac12\int\dfrac{1}{t^2-\sqrt2t+1}\mathrm dt$$
And
$$\int\dfrac{\mathrm dt}{t^2-\sqrt2t+1}=\int\dfrac{\mathrm dt}{\left(t-\frac{\sqrt2}{2}\right)^2+\frac12}=2\int\dfrac{\mathrm dt}{\left(\sqrt2t-1\right)^2+1}$$
With the change of variable $u=\sqrt2t-1$, this integral is
$$2\int\dfrac{\mathrm dt}{\left(\sqrt2t-1\right)^2+1}=\sqrt2\int\frac{\mathrm du}{u^2+1}=\sqrt2\arctan(u)+C=\sqrt2\arctan(\sqrt2t-1)+C$$
The first term thus yields:
$$\int\dfrac{t/\sqrt2}{t^2-\sqrt2t+1}\mathrm dt=\frac{\sqrt2}{4}\log|t^2-\sqrt2t+1|+\frac{\sqrt2}{2}\arctan(\sqrt2t-1)+C$$
The second term is similar:
$$\int\dfrac{t/\sqrt2}{t^2+\sqrt2t+1}\mathrm dt=\frac{\sqrt2}{4}\int\dfrac{2t+\sqrt2-\sqrt2}{t^2+\sqrt2t+1}\mathrm dt\\=\frac{\sqrt2}{4}\log|t^2+\sqrt2t+1|-\frac12\int\dfrac{1}{t^2+\sqrt2t+1}\mathrm dt$$
And
$$\int\dfrac{\mathrm dt}{t^2+\sqrt2t+1}=\int\dfrac{\mathrm dt}{\left(t+\frac{\sqrt2}{2}\right)^2+\frac12}=2\int\dfrac{\mathrm dt}{\left(\sqrt2t+1\right)^2+1}$$
With the change of variable $u=\sqrt2t+1$, this integral is
$$2\int\dfrac{\mathrm dt}{\left(\sqrt2t+1\right)^2+1}=\sqrt2\int\frac{\mathrm du}{u^2+1}=\sqrt2\arctan(u)+C=\sqrt2\arctan(\sqrt2t+1)+C$$
The second term thus yields:
$$\int\dfrac{t/\sqrt2}{t^2+\sqrt2t+1}\mathrm dt=\frac{\sqrt2}{4}\log|t^2+\sqrt2t+1|-\frac{\sqrt2}{2}\arctan(\sqrt2t+1)+C$$
All in all
$$\int\dfrac{2t^2\mathrm dt}{1+t^4}=\frac{\sqrt2}{4}\log\left|\frac{t^2-\sqrt2t+1}{t^2+\sqrt2t+1}\right|+\frac{\sqrt2}2\arctan(\sqrt2t-1)+\frac{\sqrt2}2\arctan(\sqrt2t+1)+C$$
You can remove the absolute value, as the numerator and the denumerator are both positive:
$$\int\dfrac{2t^2\mathrm dt}{1+t^4}=\frac{\sqrt2}{4}\log\left(\frac{t^2-\sqrt2t+1}{t^2+\sqrt2t+1}\right)+\frac{\sqrt2}2\arctan(\sqrt2t-1)+\frac{\sqrt2}2\arctan(\sqrt2t+1)+C$$