Why can we change a limit's function/expression and claim that the limits are identical? Say you have limit as $x$ approaches $0$ of $x$. You could just write it as $\frac{1}{\frac{1}{x}}$ and then the expression would be undefined. So what are you really doing when you "rearrange" an expression or function so its limit "works", and doesn't have any division by zero? Why can we suddenly change one expression to another, when they are not exactly the same, and say the limit is the same? For example, the expression $x$ is not equal to the expression $\frac{1}{\frac{1}{x}}$ because the latter is not valid for $x=0.$
 A: When we take the limit for $x \rightarrow 0$ of a function $f$, we are actually interested to what happens to $f$ in a punctured neighborhood of $0$. That is, we don't actually care about the behaviour of the function when $x$ is exactly $0$. This means that $f(x)=x$ and $g(x)=\frac{1}{\frac{1}{x}}$ have the same limit for $x \rightarrow 0$, because they are equal in a punctured neighborhood of $0$.
Note that this can be seen from the definition itself; that is, $\lim_{x \rightarrow 0} f(x)=l$ means
$$
\forall \ \epsilon > 0 \ \ \exists \ \delta > 0 : 0 < |x| < \delta \Rightarrow |f(x)-l| < \epsilon.
$$
If you take another function $g$ and you assume $g=f$ in a punctured neighborhood of $0$, it follows that $$\lim_{x \rightarrow 0} f(x)=l \iff \lim_{x \rightarrow 0} g(x)=l\ .$$
A: Note that the limit of $\frac{1}{\frac 1x}$ as $x\to 0$ is not undefined. Of course you cannot plug in $x = 0$ in this expression. However, it is not how limit works. In the definition of limit you need only care about the value of the function near that point, ($0$ in this case). Since 
$$x = \frac{1}{\frac 1x}$$
holds in a punctured neighborhood of $0$, so 
$$\lim _{x \to 0} x = \lim _{x\to 0} \frac{1}{\frac 1x} = 0.$$
You will be less confused (I hope) if you realize that when we talk about 
$$\lim_{x\to c}f(x),$$
the function $f$ does not need to be even defined at $c$. You only need that $f$ is defined on a punctured neighborhood of $c$. 
A: Remark: sort of a long comment.
What you are rediscovering are so called removable singularities: Note that the functions 
$$f(x)=x$$
and 
$$\tilde{f}(x)=\frac{1}{\frac{1}{x}},$$
are not the same, as they domain of definition differs:
the first is defined for all real numbers, whereas the second is not defined at zero (as you noticed).
But one can adjust the second by defining
$$\bar{f}(x):=\begin{cases}\tilde{f}(x)&, x\neq 0\\0 &, x=0\end{cases}.$$
As explained in the other answers, $\lim_{x\rightarrow 0}\bar{f}(x)=0,$ which implies that the function is continuous at $0$ (as was clerly expected).
Such an adjustment is called removal of singularity.
A: When we are computing limits like $x\rightarrow a$, the value of the function at $x=a$ is irrelevant.
This means that if we are evaluating $\lim_{x\rightarrow a} f(x)$, and we know of a second function $g(x)$ which is equal to $f(x)$ everywhere except at $x=a$, then we can make the substitution
$$\lim_{x\rightarrow a} f(x) = \lim_{x\rightarrow a}g(x).$$
The reasoning is that $f$ and $g$ agree everywhere except at $x=a$, and limits don't depend on the value of the function at the limit point, so therefore the two limit values must be identical.

This principle is what allows us to transform, for example,

$$\lim_{x\rightarrow 0}\frac{x^2 +2x}{x} \Rightarrow  \lim_{x\rightarrow 0}(x+2) = 2$$
where here $f(x)\equiv \frac{x^2+2x}{x}$ and $g(x) \equiv x+2$ are two functions that have exactly the same values everywhere except at the irrelevant location $x=0$.
