What's domain of $\sqrt{\sin\pi(x^2-x)}$ 
Find the domain of 
  $$\sqrt{\sin\pi(x^2-x)}$$

I'm confused about this function. I've been trying to figure out what's the domain but can't get a right answer.
 A: Start with the inequality 
$$\sin\left(\pi(x^2-x)\right)\ge0$$
To understand when this is true let's look at the inequality 
$$\sin(t)\ge0$$
It is clear that 
$$2\pi n\le t\le 2\pi n +\pi, \quad n\in\mathbb Z$$
Substituting $\pi(x^2-x)$ for $t$ we see
$$2\pi n \le \pi(x^2-x) \le \pi (2n +1),\quad n\in\mathbb Z$$
$$2n\le x^2-x\le 2n+1, \quad n\in\mathbb Z$$
This can be interpreted geometrically as bounding a parabola by 2 horizontal lines at $y=2n+1$ and $y=2n$ which means we have to deal with the left and right solutions. 

From this image it is also clear that there is no solution when $n<0$
Let's solve the lower line first. We have 
$$x^2-x\ge 2n$$
$$x\ge\frac 1 2 \left(1+\sqrt{8n+1}\right)\quad\text{or}\quad x\le\frac 1 2 \left(1-\sqrt{8n+1}\right)$$
For $x^2-x\le 2n+1$ it can be shown that
$$x\le \frac 1 2 \left(1+\sqrt{8n+5}\right)\quad\text{or}\quad x\ge \frac 1 2 \left(1-\sqrt{8n+5}\right)$$
Combining these inequalities we obtain
$$\frac 1 2 \left(1+\sqrt{8n+1}\right)\le x\le \frac 1 2 \left(1+\sqrt{8n+5}\right)\quad\text{or}\quad \frac 1 2 \left(1-\sqrt{8n+5}\right)\le x\le \frac 1 2 \left(1-\sqrt{8n+1}\right), \quad n\in\mathbb Z,n\ge 0$$
A: We know that $\sqrt{x} \geq 0$ and so $\sin{\pi(x^2-x)} \geq 0$. The function $\sin{x}$ is nonnegative on $\ldots,[-2\pi,-\pi],[0,\pi], [2\pi, 3\pi],\ldots$. Thus, $x^2-x$ must be in $\ldots,[-2,-1], [0,1], [1,2] \ldots$. So take the union of all $x$ such that $x^2-x$ is in each interval and that is the domain.
In more mathematical terms, $x^2-x \in \displaystyle \bigcup_{i\in\mathbf Z} [2i,2i+1]$ and thus 
$$x \in \displaystyle \bigcup_{i\in\mathbf Z}\left [\dfrac{1}{2}(1 + \sqrt{8i+1}), \dfrac{1}{2}( \sqrt{8i+5})\right ] \bigcup \bigcup_{i\in\mathbf Z}\left[\dfrac{1}{2}(1 - \sqrt{8i+5}),\dfrac{1}{2}(1 - \sqrt{8i+1}) \right].$$
A: Hint:
$p(x)=x^2-x$ must lie in $[2k,2k+1]$ for some $k\in\mathbf Z$. Hence you have to determine $$\displaystyle\bigcup_{k\in\mathbf Z}p^{-1}([2k,2k+1]).$$
Sketching  the function may help.
