Nonlinear Equation in state variable form Given the following system of differential equations
$$(M+m)\ddot{z} + mL(\ddot{\theta}\cos(\theta) - \dot{\theta}^2\sin{\theta}) = u$$
$$m\ddot{z}\cos({\theta}) + mL\ddot{\theta} = mg\sin(\theta)$$
Where $m,L,g$ are positive constants.
I'm having trouble figuring out how to turn these nonlinear equations into state variable form, I end up having an equation with sine and cosine, but 

How can I turn this into the form of $Ax(t) + Bu(t)$? 

Any advice on how to continue is appreciated, thanks. I may be approaching this wrong but I have the $x(t)$ matrix as $(z, \dot{z},\theta, \dot{\theta})$ and am unsure how to form the coefficient matrices.
 A: You cannot write this system in the form you want. The wikipedia equations you are citing and trying to get are linear. The system you have is a nonlinear Lagrangian system. There is a conceptually very deep method that can put your system as an explicit first order system (i.e. involving only first derivatives) of four functions and four differential equations. It is called Legendre's transformation which transforms the Euler-Lagrange equations into Hamilton's equations.
Start with the Lagrangian function
$$\mathcal{L}(z, \theta, \dot{z}, \dot{\theta}) = \frac{M+m}{2} \, \dot{z}^2 + mL\,\cos{\theta}\,\, \dot{z}\,\dot{\theta} + \frac{mL^2}{2} \, \dot{\theta}^2 + u\, z - mgL \, \cos{\theta}$$ Compute 
$$\frac{\partial \mathcal{L}}{\partial \dot{z}} = (M+m) \, \dot{z} + mL \,\dot{\theta} \cos{\theta} $$
$$\frac{\partial \mathcal{L}}{\partial \dot{\theta}}  = mL \, \dot{z} \cos{\theta + mL^2\, \dot{\theta}}$$
$$\frac{\partial \mathcal{L}}{\partial {x}} = u$$
$$\frac{\partial \mathcal{L}}{\partial {\theta}} = - \, mL \, \dot{z}\, \dot{\theta} \sin{\theta} + mgL \, \sin{\theta}$$
The Euler-Legrange equations are
\begin{align}
\frac{d}{dt}\left(\frac{\partial \mathcal{L}}{\partial \dot{z}}\right) &= \frac{\partial \mathcal{L}}{\partial {z}} \\
\frac{d}{dt}\left(\frac{\partial \mathcal{L}}{\partial \dot{\theta}} \right) &= \frac{\partial \mathcal{L}}{\partial {\theta}}   
\end{align} or written explicitly
\begin{align}
&\frac{d}{dt}\left((M+m) \, \dot{z} + mL \,\dot{\theta} \cos{\theta}\right) = u \\
&\frac{d}{dt}\left(mL \, \dot{z} \cos{\theta + mL^2\, \dot{\theta}}\right) = - \, mL \, \dot{z}\, \dot{\theta} \sin{\theta} + mgL \, \sin{\theta}
\end{align} which after differentiation in the left hand side become
\begin{align}
&(M+m) \, \ddot{z} - mL \,\dot{\theta}^2 \sin{\theta} + mL \,\ddot{\theta} \cos{\theta} = u \\
&mL \, \ddot{z} \cos{\theta} - mL \,\dot{z} \, \dot{\theta} \sin{\theta} + mL^2\, \ddot{\theta}= - \, m L \, \dot{z}\, \dot{\theta} \sin{\theta} + mgL \, \sin{\theta}
\end{align}
They reduce to
\begin{align}
&(M+m) \, \ddot{z} - mL \,\dot{\theta}^2 \sin{\theta} + mL \,\ddot{\theta} \cos{\theta} = u \\
&m \, \ddot{z} \cos{\theta} + mL\, \ddot{\theta} = mg \, \sin{\theta}
\end{align}
With this structure in mind we switch to Hamiltonian formulation. Define the conjugate momenta
\begin{align}
p_z = \frac{\partial \mathcal{L}}{\partial \dot{z}} &= (M+m) \, \dot{z} + mL \,\dot{\theta} \cos{\theta}\\
p_{\theta} = \frac{\partial \mathcal{L}}{\partial \dot{\theta}} &=  mL \, \dot{z} \cos{\theta + mL^2\, \dot{\theta}} 
\end{align} Solve this linear system with respect to $\dot{z}, \dot{\theta}$ obtaining
\begin{align}
\dot{z} &= \frac{mL^2 \, p_{z} -  mL \, p_{\theta} \cos{\theta}}{(M+m)mL^2 - m^2L^2 \, \cos^2{\theta}} = \frac{mL^2 \, p_{z} -  mL \, p_{\theta} \cos{\theta}}{MmL^2 + m^2L^2 \, \sin^2{\theta}} \\
\dot{\theta} &= \frac{-  mL \, p_{z} \cos{\theta} + (M+m) \, p_{\theta}}{(M+m)mL^2 - m^2L^2 \, \cos^2{\theta}} =  \frac{-  mL \, p_{z} \cos{\theta} + (M+m) \, p_{\theta}}{MmL^2 + m^2L^2 \, \sin^2{\theta}}
\end{align} 
Now observing that
\begin{align}
\frac{d}{dt}p_z &= \frac{\partial \mathcal{L}}{\partial {z}} \\
\frac{d}{dt} p_{\theta} &= \frac{\partial \mathcal{L}}{\partial {\theta}}   
\end{align} combining all pairs of equations together 
\begin{align}
\dot{x} &=  \frac{L \, p_{z} -   \, p_{\theta} \cos{\theta}}{ML + mL \, \sin^2{\theta}} \\
\dot{\theta} &=  \frac{-  mL \, p_{z} \cos{\theta} + (M+m) \, p_{\theta}}{MmL^2 + m^2L^2 \, \sin^2{\theta}}\\
\dot{p}_x &= u \\
\dot{p}_{\theta} &= - \, \, \frac{\big(L \, p_{z} -   \, p_{\theta} \cos{\theta}\big) \, \big(-  mL \, p_{z} \cos{\theta} + (M+m) \, p_{\theta}\big) \, \sin{\theta}}{\big(ML + mL \, \sin^2{\theta}\big)^2}  \, +  \, mgL \, \sin{\theta} 
\end{align} These are the Hamiltonian equations. 
I am assuming the function $u$ is some kind of control function. 
