Forgive my ignorance. The below seems 'inconsistent'. If canceling the $(x+1)$ is 'legal', how does the domain change? I realize it does, but would someone be so kind as to provide an explanation?
$$ \frac{x^2 - 1}{x + 1} \mbox{ is undefined when } x = -1 $$
Its domain (the values that can go into the expression) does not include $ -1 $.
Now, we can factor $ x^2 - 1 $ into $ (x - 1)(x + 1) $ so we get:
$$ \frac{(x - 1)(x + 1)}{(x + 1)} $$
It is now tempting to cancel $ (x + 1) $ from top and bottom to produce:
$$ x - 1 $$
$$ \mbox{Its domain now } \textbf{does} \mbox{ include } -1 \mbox{.} $$
But it is now a different function because it has a different domain.
Thanks!
A function is not just an expression. It is a special assignment (a formula, a table, a diagram, etc) together with a chosen domain and a chosen codomain. The choices must make sense however. If the domain is the same, the codomain is the same and $f(x)$ and $g(x)$ coincide for every member $x$ of the domain, only then do we say the functions are equal.
For example, let $f(x) = \dfrac{x^2-1}{x+1}$ and $g(x) = x-1$.
and let's choose the domain for both to be the set $\{1,2,3,4,...\}$ and lets choose the codomain to be the range (which is $\{0,1,2,...\}$).
In this case, $f$ and $g$ are the same function. For every member $N$ of the domain, $f(N)$ is equal to $g(N)$.
If we choose the domain instead to be $\mathbb R$ then we run into a problem. $g$ is happy with $-1$ which now belongs to the domain, it hands you back $g(-1)=-2$. but $f(-1)$ doesn't make sense, so the domain we chose for $f$ doesn't even work. We're broken from the get-go. They can't be the same if the function $f$ can't even exist.
Now if we choose the domain for both of them to be everything except for $-1$, sometimes written $\mathbb R \setminus \{-1\}$, and to have codomain $\mathbb R$, then $f$ and $g$ are again the same function.