Solution (source code)

= Solution

The bound $|\cos(1/x)|\leq1$ gives $|f(x)-f(0)|\leq|x|^p$ when $x\ne0$. If $p>0$, given any $\varepsilon>0$, choose $\delta=\varepsilon^{1/p}$. Then $0<|x|<\delta$ implies
$$
|f(x)-f(0)|\leq|x|^p<\delta^p=\varepsilon;
$$
the inequality also holds at $x=0$. This proves <continuity> using the <epsilon-delta definition of continuity>.

For necessity, take the positive <sequence> $x_n=1/(2\pi n)\to0$. Then $\cos(1/x_n)=1$, so $f(x_n)=(2\pi n)^{-p}$. For $p=0$ this equals $1$; for $p<0$ it tends to $+\infty$. In neither case does it tend to $f(0)=0$, so <continuity> fails. Consequently
$$
\boxed{f\text{ is continuous at }0\iff p>0.}
$$
This is an instance of the general <continuity and differentiability thresholds for a damped oscillation>.