Is there an analytic way to solve $\lim_{x \to 0} \cos\left(\frac{1}{x}\right)$? Consider the limit
$$\lim_{x \to 0} \cos\left(\frac{1}{x}\right)$$
Sorry if this is the wrong way to format functions like this. Is there an analytic way to solve questions like these other than "informally noticing a pattern and making a deduction"? (e.g. "noticing" that the cos function oscillates endlessly as $x$ approaches $0$ so the limit does not exist)
I tried using the rule that $\lim_{x \to a} f(g(x)) = f(\lim_{x \to a} g(x))$ if $f(x)$ is continuous, so:
$$\cos\left(\lim_{x \to 0} \frac{1}{x}\right) = \cos\left(\infty\right) $$
Which I suspect is wrong somehow because technically infinity isn't a number we can plug into the cos function so I don't know if I did something wrong or how else you're supposed to solve this.


*

*Is my understanding of the composite-function rule for limits incorrect? Did I apply it incorrectly?

*What's the correct way to solve this limit analytically?
 A: Hint: Let $f(t)=\cos(1/t)$. If $\lim_{t\to 0} f(t)$ exists, for any two sequences $x_1,x_2,\cdots$ and $y_1,y_2,\cdots$, each tending to $0$, such that
$$\lim_{n\to\infty} f(x_n) = a$$
and 
$$\lim_{n\to\infty} f(y_n) = b,$$
we must have that $a = b = \lim_{t\to 0} f(t).$ Can you find two sequences on which $f$ tends towards two different limits?
A: Set $y= 1/x:  $
Consider $x \rightarrow 0^+:$
Then $ y  \lim \rightarrow +\infty$,and we have
$\lim_{ y\rightarrow +\infty} \cos(y).$
Choose sequences:
$1) y_n= π/2 +2πn  ;$
$2) y_n = 2πn ;$
1) $a_n: = \cos (π/2+2πn)=0.$
2) $b_n:= \cos(2πn) = 1.$
Limits:
1)$\lim_{n \rightarrow \infty}a_n= 0.$
2)$\lim{n \rightarrow \infty} b_n=1.$
Hence limit does not exist.
A: If $\lim_{x\to 0^+}\cos(\frac{1}{x})$ exists then $\lim_{x\to + \infty}\cos(x)$ also exists, which is not true since $\cos$ is periodic and not constant.
A: The key fact in general is that
$$x \to x_0 \quad f(x)\to L \implies \forall x_n\to x_0\quad f(x_n)\to L$$
Hence, as shown in the answers here, the proper and efficent way to show that the limit does not exist is to find at least two subsequence $x_n$ and $y_n$ for which the limits are different
$$f(x_n)\to L_1 \quad f(y_n)\to L_2 \quad \text{with} \quad L_1\neq L_2$$
