<s>[INST] Solving an indefinite integral in the middle of a question In the process of solving an integral, I came across the following step and couldn't proceed: $$\int \sqrt{\frac{2t^2-1}{1-2t^2+t^4}}dt$$I know that I should use partial fractions but I don't know how to apply that here. Any suggestions?
 [/INST] Let's call
$$
f(t)=\sqrt{\frac{2t^2-1}{1-2t^2+t^4}}=\frac{\sqrt{2t^2-1}}{|1-t^2|}
$$
which is even because $f(-t)=f(t)$. Let's call $\varphi(t)$ the function defined for $|t|>\frac{1}{\sqrt 2}$ and $|t|\ne 1$ as
$$
\varphi(t)=\frac{\sqrt{2t^2-1}}{1-t^2}
$$
so that the function $f(t)$, for $|t|>\frac{1}{\sqrt 2}$, may be written as
$$
f(t)=\begin{cases} \varphi(t) & |t|<1\\ -\varphi(t) & |t|>1\end{cases}
$$
Then, the integral which we have to evaluate is 
$$
I=\int \sqrt{\frac{2t^2-1}{1-2t^2+t^4}}\operatorname{d}t=\int f(t)\operatorname{d}t=\begin{cases} \int\varphi(t) \operatorname{d}t & \frac{1}{\sqrt 2}<|t|<1\\ -\int\varphi(t)\operatorname{d}t & |t|>1\end{cases}
$$
So we can evaluate the integral
$$
J=\int\varphi(t) \operatorname{d}t=\int \frac{\sqrt{2t^2-1}}{1-t^2} \operatorname{d}t.
$$
Let's put
$$
x=\frac{\sqrt 2 t}{\sqrt{2t^2-1}}
$$
so that $$\operatorname{d}t=-\frac{1}{\sqrt 2}\frac{1}{(x^2-1)^{3/2}}\operatorname{d}x$$
and
$$
\begin{align}
\sqrt{2t^2-1}&=\frac{1}{(x^2-1)^{1/2}} &
1-t^2&=\frac{x^2-2}{2(x^2-1)}
\end{align}
$$
Putting all together we find
$$
J=\int \frac{1}{(x^2-1)^{1/2}}\frac{2(x^2-1)}{x^2-2}\left(-\frac{1}{\sqrt 2}\right)\frac{1}{(x^2-1)^{3/2}}\operatorname{d}x
$$
and simplifying we obtain
$$
J=-\sqrt 2 \int \frac{1}{(x^2-1)(x^2-2)}\operatorname{d}x.
$$
Expanding the integrand function in partial fraction one has
$$
\begin{align}
\frac{1}{(x^2-1)(x^2-2)}&=\frac{1}{x^2-2}-\frac{1}{x^2-1}\\
&=\frac{1}{2\sqrt 2}\left(\frac{1}{x-\sqrt 2}-\frac{1}{x+\sqrt 2}\right)-\frac{1}{2}\left(\frac{1}{x-1}-\frac{1}{x+1}\right)
\end{align}
$$
Integrating term by term and recalling that $\int \frac{1}{u}\operatorname{d}u=\log u + c$ we find
$$
J=-\frac{1}{2}\log\left(\frac{x-\sqrt 2}{x+\sqrt 2}\right)+\frac{1}{\sqrt 2}\log\left(\frac{x-1}{x+1}\right)+C
$$
Finally, substituting back $x=\frac{\sqrt 2 t}{\sqrt{2t^2-1}}$ and simplifying, we obtain
$$
J=-\frac{1}{2}\log\left(\frac{t-\sqrt{2t^2-1}}{t+\sqrt{2t^2-1}}\right)+\frac{1}{\sqrt 2}\log\left(\frac{\sqrt 2 t-\sqrt{2t^2-1}}{\sqrt 2t+\sqrt{2t^2-1}}\right)+C
$$
</s>