Limits involving trigonometric functions $f(x)=\lfloor{x^2 \rfloor} \sin^2(\pi x)$ I was asked to find for what values of x the function is differentiable and write down the derivative.
$f(x)=\lfloor{x^2 \rfloor} \sin^2(\pi x)$ for $x \geq 0$.
There are two steps:


*

*When $x \in (\sqrt{n},\sqrt{n+1})$ we get $f'(x)=\pi n \sin(2 \pi x)$.

*If $x=\sqrt{n}$ then:

*I need to find $\lim_{x \rightarrow \sqrt{n}^+} \frac{f(x)-f(\sqrt{n})}{x-\sqrt{n}}=\lim_{x \rightarrow \sqrt{n}^+} \frac{n \sin^2(\pi x)-n \sin^2(\pi \sqrt{n})}{x-\sqrt{n}}$

*I need to find $\lim_{x \rightarrow \sqrt{n}^-} \frac{f(x)-f(\sqrt{n})}{x-\sqrt{n}}=\lim_{x \rightarrow \sqrt{n}^-} \frac{(n-1) \sin^2(\pi x)-n \sin^2(\pi \sqrt{n})}{x-\sqrt{n}}$


I just don't know how to find the limits :\ We haven't covered L'hopital yet, so I need to use other methods.
Of course, after finding both limits, we need to write $f'_{-}(\sqrt{n})=f'_{+}(\sqrt{n})=f'(\sqrt{n})=\pi n \sin(2\pi \sqrt{n})$. This is true if and only if $\sqrt{n} \in \mathbb{N}$ (limits are all 0), otherwise the function is not differentiable in $x=\sqrt{n}$.
Please show how to continue, thanks!
 A: $$\begin{align} \lim_{x\to\sqrt n^+}\frac{f(x)-f(\sqrt n)}{x-\sqrt n}&=\lim_{x\to\sqrt n^+}\frac{n\sin^2(\pi x)-n\sin^2(\pi \sqrt n)}{x-\sqrt n}\\
&=n \frac{\text d}{\text dx}\sin^2(\pi x)|_{x=\sqrt n}\\
&=2\pi n\sin(\pi \sqrt n)\cos(\pi\sqrt n)=\pi n\sin(2\pi\sqrt n) \end{align}$$
However, the limit below is:
\begin{align} \lim_{x\to\sqrt n^-}\frac{f(x)-f(\sqrt n)}{x-\sqrt n}&=\lim_{x\to\sqrt n^-}\frac{(n-1)\sin^2(\pi x)-n\sin^2(\pi \sqrt n)}{x-\sqrt n}\\
&=\lim_{x\to\sqrt n^-}\frac{n\sin^2(\pi x)-n\sin^2(\pi \sqrt n)}{x-\sqrt n}-\frac{\sin^2(\pi x)}{x-\sqrt n}\\
&=\lim_{x\to\sqrt n^-}\pi n\sin(2\pi\sqrt n)-\frac{\sin^2(\pi x)}{x-\sqrt n}\\
\end{align}
If $n=0$, then we have 
$$\lim_{x\to 0}\frac{\sin^2(\pi x)}{x}=\lim_{x\to0}\frac{(\pi x)^2}{x}=\lim_{x\to 0}\pi^2x=0.$$
Otherwise, the limit approaches infinity since $\sin^2(\pi x)$ approaches a nonzero finite value, while the denominator approaches $0$.
A: Both $\lfloor x^2\rfloor$ and $\sin^2(\pi x)$ are differentiable everywhere, except $\lfloor x^2\rfloor$ which is not differentiable when $x^2$ is a non-zero integer. So all we need to check is whether the given function is differentiable when $x^2$ is a non-zero integer.
Suppose that $x_n^2=n$, where $n$ is not a perfect square. $x_n$ is not an integer and so $\sin^2(\pi x_n)\ne0$.  At $x_n$, $\lfloor x^2\rfloor\sin^2(\pi x)$ tends to $(n-1)\sin^2(\pi\sqrt{n})$ from the left and $n\sin^2(\pi\sqrt{n})$ from the right. Thus, the function is not even continuous at $x_n$ if $n$ is not a perfect square.
Suppose that $x_n^2=n$, where $n$ is a perfect square. $x_n$ is an integer and so $\sin^2(\pi x_n)=0$. At $x_n$, $\lfloor x^2\rfloor\sin^2(\pi x)$ tends to $0$ from the left and the right. Therefore, the function is continuous. From the left, the derivative tends to $2\pi(n-1)\sin(\pi x_n)\cos(\pi x_n)=0$ and from the right, the derivative tends to $2\pi n\sin(\pi x_n)\cos(\pi x_n)=0$. Thus, the Mean Value Theorem says that the derivative at $x_n$ is $0$.
Thus, the function is differentiable at all points except non-integers whose squares are integers.
Where differentiable, the derivative would be
$$
2\pi\lfloor x^2\rfloor\sin(\pi x)\cos(\pi x)=\pi\lfloor x^2\rfloor\sin(2\pi x)
$$
Note that except at the troublesome points $\lfloor x^2\rfloor$ is a constant, so the formula above only considers the derivative applied to $\sin^2(\pi x)$.
