Is $f(x)=\sin(x^2)$ periodic?
Let $f : \mathbb{R} \to \mathbb{R}$ be periodic with period $T$.
- The range of $f$ is precisely $f([0, T])$; in particular, if $f$ is continuous, the range of $f$ is bounded.
- If $f$ is differentiable, then $f'$ is periodic with period $T$.
Note that $f(x) = \sin(x^2)$ is differentiable and $f'(x) = 2x\cos(x^2)$ which is unbounded. Therefore, $f'$ cannot be periodic by the first point, and hence $f$ cannot be periodic by the second point.
Your approach simply forces $k$ to be a square. Observing that the LHS will be irrational sometimes is a crucial idea but it cannot apply when you are using only two intervals $[0, T]$ and $[\sqrt{\pi}, \sqrt\pi + T]$ to form equations. Here is an approach that uses more.
Assume that $f$ is periodic with period $T$. Note that the solution set for $f(x) = 0$ is $\{\pm\sqrt{n\pi}\ |\ n = 0, 1, 2, \dotsc\}$. For any nonnegative integer $m$, $f(\sqrt{m\pi}) = 0$ thus $f(\sqrt{m\pi} + T) = 0$. Hence, there exists some integer $k_m$ such that $\sqrt{m\pi} + T = \sqrt{k_m\pi}$. Note that $T = \sqrt{k_0\pi}$, which gives us $$\begin{align} \sqrt m + \sqrt k_0 &= \sqrt k_m\\ m + k_0 + 2\sqrt{mk_0} &= k_m. \end{align}$$
And now we have a number-theoretic question. Let $k_0 = a^2b$, where $a^2$ is the greatest square that divides $k_0$.
- If $b = 1$, choose $m = 2$ to have an irrational LHS and an integer RHS.
- If $b \neq 1$, choose $m = 1$ to have an irrational LHS and an integer RHS.
Contradiction!