Domain of a Trigonometric Composite Function I am struggling with a question based on finding the domain of a composite function. I have managed to complete questions such as in the following document at the bottom of page three:
http://www.sinclair.edu/centers/mathlab/pub/findyourcourse/worksheets/Algebra/CompositeFunctionsAndTheirDomains.pdf
However, this question feels different and I am unsure of how the answer was gained:
Let $f$ and $g$ be the functions:
$$ f : [0, 2\pi] \to \mathbb R, \quad f(x) = \cos (x), $$
and
$$g : [0, 20] \to\mathbb R, \quad g(x) = x^2$$
Determine the domain for each of the compositions
$f \circ g$ and $g \circ f$. "
The given answers are: 

$$\operatorname{Dom}(f \circ g) = [0,\sqrt{2\pi} ]$$

and

$$\operatorname{Dom}(g \circ f) = \:\left[0,\frac{\pi }{2}\right]\:\bigcup \:\left[\frac{3\pi }{2},\:2\pi \right]$$

Could anybody help me in working out how to find these domains please? 
Thank you,
Lewis
 A: In order to find the domain of$f \circ g (x) = f(g(x)) = \cos (x^2)$ we first notice that  $$\underbrace{0 \leq x^2 \leq 2\pi}_{\text{domain of}f} \Rightarrow -\sqrt{2\pi} \leq x \leq \sqrt{2\pi}$$ then $$ Dom f(g(x)) = [-\sqrt{2\pi},\sqrt{2\pi}] \cap [0,20] = [0,\sqrt{2\pi}] $$
Now for $g \circ f(x) = g(f(x)) = \cos^2 x$, we have that $0\leq\cos x \leq 20$ (domain of $g$), in particular $\cos \geq 0$ in $[0 , \frac{\pi}{2}]$ or $[\frac{3\pi}{2}, 2\pi]$ and $[0,20]$ that is,$$Dom\  g(f(x)) =  [0 , \frac{\pi}{2}]\cup [\frac{3\pi}{2}, 2\pi]$$
A: Let's consider $f\circ g$; for $x$ in the still to find domain, we have
$$
f\circ g(x)=f(g(x))
$$
so in particular $g(x)\in[0,2\pi]$, because otherwise we can't compute $f$ on it. On the other hand, whenever $g(x)\in[0,2\pi]$, we can compute $f(g(x))$. So we need to ensure
$$
0\le x^2\le 2\pi
$$
that is,
$$
x\in[-\sqrt{2\pi},\sqrt{2\pi}]
$$
However, we must take into into account that $0\le x\le 20$. So we get
$$
x\in[-\sqrt{2\pi},\sqrt{2\pi}]\cap[0,20]=[0,\sqrt{2\pi}]
$$
For $g\circ f$ it's similar: we need $f(x)\in[0,20]$, that is
$$
0\le \cos x\le 20
$$
with the condition that $x\in[0,2\pi]$. The cosine is always at most $1$, so we just need $\cos x\ge0$, which happens for $x$ in the sets of the form
$$
[0+2k\pi,\pi/2+2k\pi]\cup[3\pi/2+2k\pi,2\pi+2k\pi]
$$
with $k$ integer. Intersecting with $[0,2\pi]$ gives
$$
[0,\pi/2]\cup[3\pi/2,2\pi]
$$
