Solution (source code)

= Solution

Use the <optimization Lagrangian> $\mathcal L(x,y)=f(x)-y^Tc(x)$, with $A(x)=Dc(x)$ and $H(x,y)=\nabla_{xx}^2\mathcal L(x,y)$. Under the usual <linear independence constraint qualification>, a local minimizer has multipliers $y_*$ satisfying the equality-constrained <Karush-Kuhn-Tucker conditions>
$$
\boxed{c(x_*)=0,\qquad g(x_*)-A(x_*)^Ty_*=0.}
$$
The second-order necessary condition is
$$
\boxed{d^TH(x_*,y_*)d\geq0\quad\text{for every }d\in\ker A(x_*).}
$$
Only feasible tangent directions enter this last test; the <Hessian matrix> need not be positive semidefinite on the entire ambient space.