Two similar method to calculate one equation get different answer Method1:$$\lim_{x\rightarrow0}({\frac{e^x+xe^x}{e^x-1}}-\frac1x)=\lim_{x\rightarrow0}({\frac{e^x+xe^x}{x}}-\frac1x)=\lim_{x\rightarrow0}(\frac{e^x+xe^x-1}{x})=\lim_{x\rightarrow0}(2e^x+xe^x)=2$$
Method2:$$\lim_{x\rightarrow0}({\frac{e^x+xe^x}{e^x-1}}-\frac1x)=\lim_{x\rightarrow0}{\frac{xe^x(1+x)+1-e^x}{x(e^x-1)}}=\lim_{x\rightarrow0}{\frac{xe^x(1+x)+1-e^x}{x^2}}=\lim_{x\rightarrow0}{\frac{3xe^x+x^2e^x}{2x}}=\lim_{x\rightarrow0}{\frac{3e^x+xe^x}{2}}=\frac32$$
I know there are something wrong when I use Taylor series but I don't know exactly. And is there any method to use Taylor Series correctly when I calculate a infinite related equation? Any hints or answers are going to be appreciated.
 A: In method $1$, you wrote
$$\lim_{x\to 0}({\frac{e^x+xe^x}{e^x-1}}-\frac1x)=\lim_{x\to 0}({\frac{e^x+xe^x}{x}}-\frac1x)$$
This is incorrect.  The correct way forward is 
$$\begin{align}
\lim_{x\to 0}({\frac{e^x+xe^x}{e^x-1}}-\frac1x)&=\lim_{x\to 0}\left({\frac{e^x+xe^x}{x(1+\frac12x+O(x^2))}}-\frac1x\right)\\\\
&=\lim_{x\to 0}\frac{e^x+xe^x-(1-\frac12 x+O(x^2))}{x(1+\frac12 x+O(x^2))}\\\\
&=\lim_{x\to 0}\left(2e^x+xe^x-\frac12+O(x)\right)\\\\
&=\frac32
\end{align}$$
A: Method 2 is correct, but Method 1 is wrong. What you have done is noted that when $x \approx 0$, $e^x \approx 1+x$ and then that 
$$\frac{e^x + xe^x}{e^x-1} \approx \frac{e^x + xe^x}{x}$$
which is correct. But it does not follow that
$$\frac{e^x + xe^x}{e^x-1} - \frac{1}{x} \approx \frac{e^x + xe^x}{x} - \frac{1}{x}$$
for the same reason that you can't use
$$\lim_{x\rightarrow 0}(f(x) + g(x)) = \lim_{x\rightarrow 0}f(x) + \lim_{x\rightarrow 0}g(x)$$
when one or both limits do not exist.
Essentially, you have made a correct calculation but then, as it were, subtracted something that doesn't exist from both sides.
A: I wonder how one manages to go from $$\lim_{x \to 0}\left(\frac{e^{x} + xe^{x}}{e^{x} - 1} - \frac{1}{x}\right)$$ to $$\lim_{x \to 0}\left(\frac{e^{x} + xe^{x}}{x} - \frac{1}{x}\right)$$ There is no theorem in calculus which justifies this. It is like writing $1 + 2 = 1 + 3 = 4$.
The second approach works and is justified as follows 
\begin{align}
\lim_{x \to 0}\frac{xe^{x}(1 + x) + 1 - e^{x}}{x(e^{x} - 1)} &= \lim_{x \to 0}\frac{xe^{x}(1 + x) + 1 - e^{x}}{x^{2}}\cdot\frac{x}{e^{x} - 1}\notag\\
&= \lim_{x \to 0}\frac{xe^{x}(1 + x) + 1 - e^{x}}{x^{2}}\cdot 1\notag\\
&= \lim_{x \to 0}\frac{xe^{x}(1 + x) + 1 - e^{x}}{x^{2}}\notag
\end{align}
It is better to write all the steps above so that there is no mystery involved.
While calculating limits one is allowed to use any transformation to replace one expression by another if these two are equal (this is obvious, you can replace $a$ by $b$ if $a = b$). Apart from this obvious replacement one can make use of rules of limits or any standard theorems in calculus. No other transformations are allowed. They may sometimes generate correct answer but with no guarantee and it will only add to confusion and mystery.
Thus you can't replace $e^{x} - 1$ by $x$ because these are not equal (unless $x = 0$). In the second approach it looks like $e^{x} - 1$ is replaced by $x$ but in reality it is a typical use of limit theorems (the way I have shown above) which finally looks like a replacement.
Similarly the other answer by Dr. MV is wrong because it replaces (answer by Dr. MV is now edited to fix the problem mentioned, hence the strikethrough) it is wrong to replace $e^{x} - 1$ by $1 + x + (x^{2}/2)$. These are not equal and hence it is incorrect. This procedure gives correct answer by good luck. It is better to replace $e^{x} - 1$ by $x + (x^{2}/2) + O(x^{3})$ or by $x + (x^{2}/2) + o(x^{2})$ because these are all equal. You can also replace $e^{x} - 1$ by $x + O(x^{2})$ or $x + o(x)$ because these are also equal, but these will not help you to get the answer because it won't be possible to get rid of $o$ and $O$ symbols.
