 the actual and desired position of tip of the pendulum. 
% The mean and the variance of the loss are computed by averaging over the
% Gaussian state distribution $p(x) = \mathcal N(m,s)$ with mean $m$ 
% and covariance matrix $s$. 
% Derivatives of these quantities are computed when desired. 
%
%
%   function [L, dLdm, dLds, S2] = loss_cp(cost, m, s)
%
%
% *Input arguments:*
%
%   cost            cost structure
%     .p            length of pendulum                              [1 x  1 ]
%     .width      