A question regarding $f(x) = x^{2}|\cos(\pi/x)|$ that I am unsure about The question is:
Define $f(x)=x^2\left|\cos\left(\dfrac{\pi}{x}\right)\right|$ if x is not $0$ and $f(0)=0$. Prove that $f'(0)$ exists but $f'(x_0)$ does not for $x_0$ is an aribitrary point found in any neighborhood of $0$.
Since $f(0)=0$, $f'(0)=0$. Then I take the derivative of $f(x)$ which is 
$f'(x) = \dfrac{\cos\left(\dfrac{{\pi}}{x}\right)\left(2\cos\left(\dfrac{{\pi}}{x}\right)x+{\pi}\sin\left(\dfrac{{\pi}}{x}\right)\right)}{\left|\cos\left(\dfrac{{\pi}}{x}\right)\right|}$
From here I think I could construct two positive sequences $x_n$ and $x_k$ which will approach to $0$ as n and k approach $\infty$. However, the values of $f'(x_n)$ and $f'(x_k)$ will be different since $\pi\sin(\frac{\pi}{x})$ gives different value at $x_n$ and $x_k$.
But I am unsure whether I can say $f(0)=0$, so $f'(0)=0$ and whether the above thought of mine is faultless. Thank you for helping me deal with my uncertainty!
 A: Let $$f(x) = x^{2}\left|\cos \left(\frac{\pi}{x}\right)\right|$$ if $x \neq 0$ and $f(0) = 0$. Clearly $$f'(0) = \lim_{h \to 0}\frac{f(h) - f(0)}{h} = \lim_{h \to 0}h|\cos(\pi/h)| = 0$$ Let's consider a non-zero value of $x$. Since the absolute value function $|x|$ is differentiable for non zero values of $x$ it follows that $f'(x)$ exists for all those $x$ where $x \neq 0 \neq \cos(\pi/x)$.
Next note that $$\cos\left(\frac{\pi}{a}\right) = 0$$ if $$a = \frac{2}{2n + 1}$$ where $n$ is an integer. We will analyze the behavior of $f'(x)$ near these points $x = a = \dfrac{2}{2n + 1}$. Let $$g(x) = \cos\left(\frac{\pi}{x}\right)$$ Clearly $g(x)$ changes sign around $x = a = \dfrac{2}{2n + 1}$. Let $x$ be a point near $a$ then it follows that $f(x) = x^{2}g(x)$ if $g(x) > 0$ and $f(x) = -x^{2}g(x)$ if $g(x) < 0$. Now $$g'(x) = \frac{\pi\sin(\pi/x)}{x^{2}}$$ so that $$f'(x) = 2xg(x) + \pi\sin(\pi/x)$$ if $g(x) > 0$ and $$f'(x) = -2xg(x) - \pi\sin(\pi/x)$$ if $g(x) < 0$. At the specific points $x = a = \dfrac{2}{2n + 1}$ we have $g(x) = 0$, but the term $\pi\sin(\pi/x) \neq 0$ and therefore the limits of $f'(x)$ as $x \to a^{+}$ and $x \to a^{-}$ are different (one of the limits is $\pi$ and another one is $-\pi$). Since derivatives don't have jump discontinuity it follows that the function $f$ is not differentiable at points $x = \dfrac{2}{2n + 1}$ where $n$ is an integer.
It thus follows that $f'(0)$ exists, but every neighborhood of $0$ contains points where $f$ is not differentiable.
A: Since cosine is always between 0 and 1.
$-x^2 \leq f(x)\leq x^2$
$\lim_\limits{x\to 0} f(x)=0$ by the squeeze theorem.  $f(x)$ is continuous at 0.
$f'(x)$ also gets squezed at 0.  that is:
$|f'(0)| = |\lim_\limits{h\to 0} \dfrac{f(h) - f(0)} {h}| \leq \lim_\limits{h\to 0} |h^2/h| = 0$
The derivative exists, at 0 (and equals 0).
however for $x_0$ very near 0.  For any $x_0,$ when $\epsilon < x_0$, there exists an $x$ inside of $|x-x_0|<\delta$ such that $|f'(x)-f'(x_0)| > \epsilon$
A: I dk how you got that formula for $f'(x)$ for $x\ne 0$ but it's wrong. And "Since $f(0)=0, f'(0).$" isn't logical although in this case we have,for $x\ne 0,$ $$|f(x)-f(0)/(x-0)|=|x\cos \pi/x|\leq |x|$$ and  $|x|\to 0$ as $x\to 0,$ so $f'(0)=0.$...... For $x\ne 0$ we have $$(x^2 \cos \pi /x)'=(x^2)'\cos \pi /x +x^2 (\cos \pi /x)'=$$ $$=(x^2)'\cos \pi /x+x^2 (-\sin \pi /x)(\pi /x)'=$$ $$=2 x \cos \pi /x+x^2(-\sin \pi /x)(-\pi /x^2)=$$ $$=2 x \cos  \pi /x-\pi \sin \pi /x.$$
For $x\ne 0$ and $\cos \pi /x=0$  we have $\sin \pi/x=\pm 1$ and $$f'(x)= \mp \pi \ne 0.$$ For $x\ne 0 \ne\cos \pi /x$ we have $$f'(x)=(\pi x\cos \pi /x)(2/\pi-x^{-1}\tan x).$$ Now $\lim_{x\to 0}x^{-1}\tan x=1$ but $2/\pi \ne 1.$ So take $r>0$ such that  $0<|x|<r\implies (2/\pi-x^{-1}\tan x)\ne 0$..... Hence  $0<|x|<r$ implies $$(i)\quad \cos \pi/x=0\implies f'(x)=\mp \pi\ne 0$$ $$(ii)\quad \cos \pi /x \ne 0\implies f'(x)=(\pi x \cos \pi /x)(2/\pi-x^{-1}\tan x)\ne 0.$$ 
