$\frac{(x-1)(x+1)}{ (x+1)} \rightarrow (x-1)$ Domain Change

The function $f$ given by $$ f(x):=\frac{(x-1)(x+1)}{x+1} $$ with values in $\mathbb{R}$ can't be defined at $x:=-1$ (because the denominator will be $0$). Hence the domain of $f$ is at most $\mathbb{R}\backslash\{-1\}$.

The function $g$ given by $$ g(x):=x-1 $$ with values in $\mathbb{R}$ is defined for every $x\in\mathbb{R}$, so its domain is $\mathbb{R}$.

Thus, as functions, $f\neq g$ because their domains are not the same.

Perhaps your confusion comes from the fact that $$ \lim_{x\to-1}f(x)=\lim_{x\to-1}\frac{(x-1)(x+1)}{x+1}=\lim_{x\to-1}(x-1)=\lim_{x\to-1}g(x) $$ But this is true because the limit of a function as $x\to-1$ is completely independent of the value of the function at $-1$ and $f(x)=g(x)$ for every $x\in\mathbb{R}\backslash\{-1\}$.


Simply put, the first equation's domain does not include $-1$, while the second equation does.


Consider the three different functions.

The first function is the function that you original function. $$f:\mathbb{R} \setminus\{ -1\} \rightarrow \mathbb{R}$$ $$f(x)=\frac{(x-1)(x+1)}{x+1}$$

The second function is as follows. $$g:\mathbb{R} \setminus\{ -1\} \rightarrow \mathbb{R}$$ $$g(x)=x-1$$

It is actually the same function as $f$. It is alright to cancel the common terms from both numerator and denominator., as long as you know what you are doing and keeping track of your domain.

Now the third function is not exactly the same function as $f$ but it is very close, with an extra point in the domain. $$h:\mathbb{R} \rightarrow \mathbb{R}$$ $$h(x)=x-1$$

I think the book isn't very clear as it does not state the domain of the functions explicitly and just look at the formula and take the largest possible subset of real numbers.

You are right that in cancelling out common terms, the domain shouldn't change.