Velocity of undamped pendulum On this page, under the heading "Orbit Calculations": http://underactuated.mit.edu/pend.html or here.
The author says, 

"This equation has a real solution when $\cos{\theta} > \cos{\theta_{\rm max}}$" 

and then they give a piecewise function for $\theta_{\rm max}$. 
I have no idea how these statement and function were derived from $\dot{\theta}(t) = \pm \sqrt{\frac{2}{I}\dots}$ 
Can someone show the exact steps to get to this derivation?
 A: If the pendulum has enough energy to go all the way around, then any value for $\theta$ is possible between 0 (hanging down) and $\pi$ (standing straight up). For simplicity, take $\theta$ to be the absolute value of the angle between the pendulum and $-\hat{y}$ since the situation is invariant under $\theta\to -\theta$.
If the pendulum does not have enough energy to go all the way around then it will only be able to reach a maximum $\theta_m<\pi$. Given an energy $E$ the pendulum can rise only as high as
$$
E=mgh=-mg\ell\cos(\theta_m)\\
\Downarrow\\
\theta_m=\cos^{-1}\left(\frac{-E}{mg\ell}\right)
$$
Seems the textbook has a missing negative sign. This is because at the maximum height, all the kinetic energy has been converted to potential energy. Note $h$ is measured from the anchor point not the bob as is often done.
It only has a real solution when $\cos(\theta)\leq \cos(\theta_m)$ otherwise the potential energy $-mg\ell\cos(\theta)$, would exceed the total available energy $-mg\ell\cos(\theta_m)$ and the quantity under the radical ($E_0-U$) would be negative and thus would be an imaginary solution.
A: As mentioned above by @bRost03, the condition to be obtained, is when the the angular displacement, is maximum $\theta=\theta_{\text{max}}$ and thus $\dot{\theta}_{\text{ma}x}=0$. 
Then, the condition becomes
$$\pm \sqrt{ \frac{2}{I} \big[E+ mgl \,\cos[\theta_{\text{max}}(t)]\big]}=0$$
or
$$\cos[\theta_{\text{max}}(t)] =\frac{-E}{mgl} \implies \theta_{\text{max}}(t)= \cos^{-1} \left[\frac{-E}{mgl} \right]$$
Mathematically speaking, the range of $\cos^{-1}(\cdots)$ is $[0,\pi]$. The value of $\pi$ is achieved only in the case the pendulum is standing vertically upwards. The ratio $\frac{-E}{mgl}$ cannot be greater than $\pm 1$ as it would be outside the domain of inverse cosine function.
A: In this section, the textbook author is trying to say, how can we solve exactly for a mapping from $\theta$ to $\dot{\theta}$ without sampling points from that mapping and plotting onto a vector field.
The author's answer begins with the equation for total energy, and algebraically isolates the $\dot{\theta}$ on the left hand side, giving us the desired mapping from $\theta$ to $\dot{\theta}$. 
In the section mentioning:

This equation has a real solution when $\cos{(\theta)} \gt$
$\cos{(\theta_{max})}$ ... 

The author is showing here that the real
solutions to this equation correspond to configurations of the pendulum that actually matches our physical intuition of the pendulum.
$\dot{\theta}$ only has a real solution when the input to the square root is positive.
$$\begin{align}E_0 &= E \\
E + m g l \cos{(\theta)} &\geq 0 \\
\cos{(\theta)} &\gt [\frac{E}{-mgl} = \cos{(\theta_{max})} ]\\ 
\end{align}$$
We solve for $\theta_{max}$. Note, although $\cos^{-1}$ is not a true inverse for cosine, using it as an inverse works here because the domain of $\cos$ we care about is only between $-\pi$ and $\pi$, which covers the entire range of angular positions the pendulum joint can take. 
$$\theta_{max} = \cos^{-1}(\frac{E}{-mgl})$$
(The version in the textbook with $\theta_{max} = \cos^{-1}(\frac{E}{mgl})$ is a typo, there should be a negative sign inside the $\cos^{-1}$).
The piecewise expression in the textbook is just rewriting the above equation to expose the maximum value of $\theta_{max}$. If you plot the $\cos^{-1}$, you see it takes on a maximum value at $\pi$. This aligns with our intuition that $\cos{(\theta_{max})} = \cos{(\pi)}$ maximizes our Cartesian height of the pendulum over all configurations, while obeying conservation of energy.
Credit for the algebra and answer that helped me understand this section goes to @bRost03. 
