Symmetric elliptic Dirichlet energy with a nonpositive potential (source code)

= Symmetric elliptic Dirichlet energy with a nonpositive potential
{title2=$J(u)=\tfrac12\int(A\nabla u\cdot\nabla u-qu^2)+\int fu$}

For a bounded domain, bounded symmetric uniformly elliptic $A$, $q\leq0$, and $f\in L^2$, minimizing $J$ on $\psi+H_0^1$ solves $\operatorname{div}(A\nabla u)+qu=f$. The nonnegative quadratic terms are weakly lower semicontinuous, and <Poincaré inequality> makes the gradient norm coercive on the zero-boundary part. The first variation gives the weak equation with the forcing sign displayed above. If $q$ is positive, coercivity may fail at a Dirichlet eigenvalue; orthogonality to the homogeneous kernel is then needed for solvability.