Why is this trivial algebraic operation wrong in this case? These functions are basically the same thing right? $\frac{4x^2}{x^2-1}=-\frac{4x^2}{1-x^2}$
What I don't understand is why do I get different integrals when i plug these two fractions into an integral calculator. Why is $\frac{4x^2}{x^2-1}\neq \frac{4x^2}{-(1-x^2)}\neq -\frac{4x^2}{1-x^2}$ when taking the integral of it? This seems like an trivial algebraic operation to me and it does not make sense to me why it is wrong in this case. I get $\int_{}^{}$$\frac{4x^2}{x^2-1}$=$4x+2\ln\left(x-1\right)-2\ln\left(x+1\right)$ and $\int_{}^{}$$-\frac{4x^2}{1-x^2}$=$4x+2\ln\left(1-x\right)-2\ln\left(1+x\right)$
Why?
 A: There's a hint in the $\ln$ functions you get as an answer: they are not defined on the whole real line. So, both answers are correct; they are just giving you the function on different parts of the real line. A complete answer is below.

Consider the following three functions.
$$
f(x) = 4x + 2\ln(x-1) - 2\ln(x+1)
\\
g(x) = 4x + 2\ln(1-x) - 2\ln(x+1)
\\
h(x) = 4x + 2\ln(1-x) - 2\ln(-x-1)
$$
If you take the derivative of each of these functions, you get the same thing: $4 + \frac{2}{x-1} - \frac{2}{x+1}$, which you can check (by putting it on a common denominator) is equal to your original function $\frac{4x^2}{x^2-1}$.
However, consider the domain of definition of each of these functions: $f$ is defined only on $(1,\infty)$; $g$ is defined only on $(-1,1)$; and $h$ is defined only on $(-\infty,-1)$. Note that the points $1$ and $-1$ are left out, which makes sense since $\frac{4x^2}{x^2-1}$ is not defined at these points.
So, if you want to find the antiderivative of $\frac{4x^2}{x^2-1}$ on its entire domain of definition (which is $\mathbb{R} \backslash \{1,-1\}$), you can use a piecewise function built from the three functions $f,g,h$ above.
$$
F(x) = \left\{ \begin{matrix}
f(x) & x \in (1,\infty) \\
g(x) & x \in (-1,1) \\
h(x) & x \in (-\infty,-1)
\end{matrix}\right.
$$
In fact, this antiderivative $F$ simplifies to $F(x) = 4x+2\ln|x-1| - 2\ln|x+1|$. This is why the antiderivative of $1/x$ is usually written $\ln|x|$: using this absolute value in your integral gets you the whole possible domain.

There is another subtlety worth pointing out here. Usually, when you find an antiderivative $A(x)$ of a function $a(x)$, you write $A(x)+C$ to indicate the family of possible antiderivatives of $a$. You get this $+C$ because the derivative of a constant is zero. However, in this case where the domain is broken into several pieces, you actually get many more antiderivatives! For any constants $C_1, C_2, C_3$, the function
$$
F_{C_1, C_2, C_3}(x) = \left\{ \begin{matrix}
f(x)+C_1 & x \in (1,\infty) \\
g(x)+C_2 & x \in (-1,1) \\
h(x)+C_3 & x \in (-\infty,-1)
\end{matrix}\right.
$$
is an antiderivative of $\frac{4x^2}{x^2-1}$ on its domain. These three constants correspond to the three pieces that the domain is broken into when we remove $1$ and $-1$.
