Limits of functions that can't be attacked by Taylor series or L'hopital's rule Often on this site there is posed a question about a limit which is hard to resolve using l'Hopital.  (I don't mean probelms asking to find a limit without using 'Lhopital, I mean problems where using l'Hopital leads to roadblocks or subtleties.)
I always attack those posed problems using Taylor series. For limit problems involving functions (as opposed to infinite sums or products) this pretty much always allows the limit to be found -- for the problems people pose here.  
I'm interested now in problems of the form "find $\lim_{x\to a}f(x)$" that resist solution by  l'Hopital's rule and also by Taylor series methods.  I have a fairly contrived example:
$$\lim_{x\to 0}\frac{1-\cos\left(\frac{2}{x+e^{-1/x^2}} \right)}{\sin^2\left(\frac{1}{x}\right)}
$$
The combination of the topologist's sin curve in the denominator and the infinitely differentiable but non-analytic $e^{-1/x^2}$ as part of the numerator makes this poison to Taylor series methods, and differentiating the numerator or denominator only makes the behavior worse.  Yet the answer for this case is fairly obvious.
My question is, can you find that limit (and prove the value you find is indeed the limit).
And can anybody come up with a less contrived function whose limit resists Tayler series, yet can be found by a different technique?
 A: There is no hope for a limit in this problem. First, to get rid of the obvious obstacle, we consider the expression only for $x\in A = \mathbb R \setminus \pi\mathbb Z.$ Then we have a bona-fide function $f(x)$ on $A.$ At the endpoints of the intervals $(1/((n+1)\pi), 1/(n\pi))$ we have $f \to \infty.$ Thus $f$ is unbounded in $A\cap (0,\delta)$ for each $\delta > 0.$ This already shows $f$ can't have a finite limit. Could the limit be $\infty?$ No, because for each $n$ there is a unique $x_n> 0$ such that $x_n+e^{-1/x_n^2} = 1/(n\pi).$ By the intermediate value theorem, it follows that for every $\delta > 0,$ $f(A \cap (0, \delta)) =[0,\infty).$
A: This problem has a certain flaw in it. Suppose the definition of limit is as follows:

Let $f$ be defined in a certain neighborhood of $a$ except possibly at $a$. A number $L$ is said to be the limit of $f$ at $a$ (written $\lim_{x \to a}f(x) = L$) if for any given $\epsilon > 0$ there is a $\delta > 0$ such that $|f(x) - L| < \epsilon$ whenever $0 < |x - a| < \delta$.

Then the function $f$ in question does not possess a limit at $x = 0$ because the function is not defined in any neighborhood of $0$ (think of points $x = 1/n\pi$ where $n$ is non-zero integer).
Suppose the definition of limit is as follows:

Let $A$ be a non-empty subset of $\mathbb{R}$ and let $f:A \to \mathbb{R}$ be a function and further let $a$ be a limit point of $A$. A number $L$ is said to be the limit of $f$ at $a$ (written $\lim_{x \to a}f(x) = L$) if for any given $\epsilon > 0$ there is a $\delta > 0$ such that $|f(x) - L| < \epsilon$ whenever $x \neq a, x \in A, |x - a| < \delta$.

Then the function $f$ in question has a limit at $x = 0$ and the limit is clearly equal to $2$ as explained in the very nice answer from user @marty cohen.
Update: Thanks to the user @zhw who pointed out the flaw in the answer given by marty cohen (which I was unable to detect from a cursory glance of his answer). This incident goes on to show the kind of subtle mistakes which can be made if we are not observant enough. The given function does not tend to a limit even if we take into account the second definition of limit.
The fact that $e^{-1/x^{2}} \to 0$ as $x \to 0$ much faster than any power of $x$ does not imply that it tends to $0$ much faster than any function of $x$. We can see that the given function can be written as $$f(x) = 2\cdot\frac{\sin^{2}(1/(x + e^{-1/x^{2}}))}{\sin^{2}(1/x)}$$ and let's put $z = e^{-1/x^{2}}$ so that $$f(x) = 2\frac{\sin^{2}(1/(x + z))}{\sin^{2}(1/x)}$$ Then $$f(x) - 2 = 2\cdot\frac{\sin^{2}(1/(x + z)) - \sin^{2}(1/x)}{\sin^{2}(1/x)} = -2\frac{z}{x(x + z)}\cdot\frac{\sin 2c}{\sin^{2}(1/x)}$$ (via MVT) where $c$ lies between $1/x$ and $1/(x + z)$. Now note that the factor $\sin 2c$ oscillates between $-1$ and $1$. 
The factor $$g(x) = \frac{z}{x(x + z)}\cdot\operatorname{cosec}^{2}(1/x)$$ does not tend to $0$ as it might appear from the presence of $z = e^{-1/x^{2}}$. The reason is that function $h(x)$ which is reciprocal of $g(x)$ is continuous everywhere except $x = 0$. And we can see that $$h(x) = \frac{1}{g(x)} = x(x + z)e^{1/x^{2}}\sin^{2}(1/x)$$ and $h(x)$ vanishes at points $x = 1/n\pi$ and by continuity takes arbitrary small values as $x \to 0$. Hence the function $g(x)$ is unbounded as $x \to 0$ and because of the term $\sin^{2}(1/x)$ it oscillates infinitely. It follows that the overall expression $f(x) - 2$ oscillates infinitely as $x \to 0$.
What we learn from the above is that although $e^{1/x^{2}} \to \infty$ much faster than any power of $1/x$ as $x \to 0$, its growth can be substantially reduced by adding a factor $\sin^{2}(1/x)$ because this factor vanishes many times as $x \to 0$ and it is continuous. And therefore the expression $e^{-1/x^{2}}\operatorname{cosec}^{2}(1/x)$ (which is crucial to this question) is unbounded as $x \to 0$ and oscillates infinitely.

BTW you don't need to construct such complicated examples to get to a function where Taylor series and L'Hospital's rule are not applicable. A simple limit $\lim_{x \to 0}x\sin(1/x)$ also defeats these techniques and is handled very simply via Squeeze theorem.
A: You want
$\lim_{x\to 0}\frac{1-\cos\left(\frac{2}{x+e^{-1/x^2}} \right)}{\sin^2\left(\frac{1}{x}\right)}
$.
First,
$e^{-1/x^2}
\to 0$
extremely quickly
(since
$e^z > z^m/m!$ for any $z > 0$ 
and $m > 0$ 
from the power series,
$e^{-1/x^2}
=\frac1{e^{1/x^2}}
< m!x^{2m} = O(x^{2m})$ for
any $m > 0$),
so it can be ignored,
giving us
$\lim_{x\to 0}\frac{1-\cos\left(\frac{2}{x
} \right)}{\sin^2\left(\frac{1}{x}\right)}
$.
Since
$\sin^2(z)
=\frac12(1-\cos(2z))
$,
this becomes
$\lim_{x\to 0}\frac{1-\cos\left(\frac{2}{x
} \right)}{\frac12\left(1-\cos\left(\frac{2}{x}\right)\right)}
=2
$.
And we are done.
