Solution (source code)

= Solution

Parametrize the graph by $X(u,v)=(u,v,f(u,v))$. The <first fundamental form> has coefficients $E=1+f_u^2$, $F=f_uf_v$, $G=1+f_v^2$. With unit normal $(-f_u,-f_v,1)/\sqrt{1+|\nabla f|^2}$, the <second fundamental form> has coefficients $e=f_{uu}/\sqrt{1+|\nabla f|^2}$, $f_{\rm II}=f_{uv}/\sqrt{1+|\nabla f|^2}$, and $g=f_{vv}/\sqrt{1+|\nabla f|^2}$. Consequently the <Gaussian curvature of a graph surface> is
$$
\boxed{K=\frac{eg-f_{\rm II}^2}{EG-F^2}
=\frac{f_{uu}f_{vv}-f_{uv}^2}{(1+f_u^2+f_v^2)^2}.}
$$

A compact embedded surface has a highest point in the vertical direction. At that point its tangent plane is horizontal, so it is locally a graph with a local maximum of $f$. Its <Hessian matrix> is negative semidefinite, giving $\det D^2f\geq0$ and hence $K\geq0$. Thus the <Gaussian curvature> cannot be everywhere negative.

An embedded ring <torus>, with major radius $R$ larger than minor radius $r>0$, is a compact surface without boundary. Its standard parametrization is $((R+r\cos\theta)\cos\phi,(R+r\cos\theta)\sin\phi,r\sin\theta)$, and the <Gaussian curvature of a ring torus> is
$$
\boxed{K=\frac{\cos\theta}{r(R+r\cos\theta)}.}
$$
Since the denominator is positive, curvature is positive on the outer side and negative on the inner side, so this example changes sign.