[proofplan]
We use the coordinate definition of $C^2(U)$: a function belongs to $C^2(U)$ when all first and second partial derivatives exist on $U$ and are continuous on $U$. Linear combinations are handled by linearity of partial derivatives and the [algebra of continuous functions](/theorems/197). Products are handled by applying the product rule once for first partial derivatives and once more for second partial derivatives. For quotients, we first prove that the reciprocal $1/g$ is $C^2$ by explicit differentiation, and then apply the product case to $f\cdot (1/g)$.
[/proofplan]
[step:Reduce the problem to continuity of first and second partial derivatives]
For each $i,j\in\{1,\dots,n\}$, write $\partial_i f:U\to\mathbb R$ and $\partial_i\partial_j f:U\to\mathbb R$ for the first and second coordinate partial derivatives of $f$, and define the analogous functions for $g$. Since $f,g\in C^2(U)$, the functions $f$, $g$, $\partial_i f$, $\partial_i g$, $\partial_i\partial_j f$, and $\partial_i\partial_j g$ are continuous on $U$ for every $i,j\in\{1,\dots,n\}$.
Thus, to prove that a function $h:U\to\mathbb R$ belongs to $C^2(U)$, it is enough in each case below to compute its first and second coordinate partial derivatives and verify that all of them are continuous on $U$.
[/step]
[step:Differentiate linear combinations and preserve continuity]
Fix $a,b\in\mathbb R$, and define the function $h:U\to\mathbb R$ by $h(x)=af(x)+bg(x)$. For each $i,j\in\{1,\dots,n\}$, linearity of coordinate partial differentiation gives
\begin{align*}
\partial_i h=a\,\partial_i f+b\,\partial_i g.
\end{align*}
Applying the same linearity to $\partial_i h$ gives
\begin{align*}
\partial_i\partial_j h=a\,\partial_i\partial_j f+b\,\partial_i\partial_j g.
\end{align*}
Each right-hand side is a linear combination of continuous functions on $U$, hence is continuous on $U$. Therefore $h\in C^2(U)$.
[/step]
[step:Apply the product rule twice to prove closure under products]
Define the product function $p:U\to\mathbb R$ by $p(x)=f(x)g(x)$. For each $i\in\{1,\dots,n\}$, the product rule for the coordinate [partial derivative](/page/Partial%20Derivative) $\partial_i$ gives
\begin{align*}
\partial_i p=(\partial_i f)g+f(\partial_i g).
\end{align*}
The right-hand side is continuous on $U$, because it is a sum of products of continuous functions.
Now fix $i,j\in\{1,\dots,n\}$. Differentiating the preceding identity with respect to the $x_j$ coordinate and applying the product rule to both summands gives
\begin{align*}
\partial_j\partial_i p=(\partial_j\partial_i f)g+(\partial_i f)(\partial_j g)+(\partial_j f)(\partial_i g)+f(\partial_j\partial_i g).
\end{align*}
Each term on the right-hand side is a product of continuous functions on $U$, and the sum is therefore continuous on $U$. Hence all first and second coordinate partial derivatives of $p$ exist and are continuous on $U$, so $fg=p\in C^2(U)$.
[guided]
We want to prove that multiplying two $C^2$ functions does not destroy the existence or continuity of first and second partial derivatives. Define the function $p:U\to\mathbb R$ by
\begin{align*}
p(x)=f(x)g(x).
\end{align*}
The first derivative is computed by the ordinary product rule in the coordinate direction $x_i$. For each $i\in\{1,\dots,n\}$,
\begin{align*}
\partial_i p=(\partial_i f)g+f(\partial_i g).
\end{align*}
This formula is useful because every factor on the right-hand side is already known to be continuous: $f$, $g$, $\partial_i f$, and $\partial_i g$ are continuous since $f,g\in C^2(U)$. Products and sums of continuous real-valued functions are continuous, so $\partial_i p$ is continuous on $U$.
For second derivatives, we differentiate the first-derivative formula again. Fix $i,j\in\{1,\dots,n\}$. Applying $\partial_j$ to the term $(\partial_i f)g$ gives
\begin{align*}
\partial_j((\partial_i f)g)=(\partial_j\partial_i f)g+(\partial_i f)(\partial_j g).
\end{align*}
Applying $\partial_j$ to the term $f(\partial_i g)$ gives
\begin{align*}
\partial_j(f(\partial_i g))=(\partial_j f)(\partial_i g)+f(\partial_j\partial_i g).
\end{align*}
Adding these two identities gives
\begin{align*}
\partial_j\partial_i p=(\partial_j\partial_i f)g+(\partial_i f)(\partial_j g)+(\partial_j f)(\partial_i g)+f(\partial_j\partial_i g).
\end{align*}
Again, every factor in every product is continuous on $U$, because $f$ and $g$ are $C^2$. Therefore $\partial_j\partial_i p$ is continuous on $U$. Since this holds for all coordinate indices $i,j$, the product function $p=fg$ belongs to $C^2(U)$.
[/guided]
[/step]
[step:Differentiate the reciprocal without assuming a global lower bound]
Assume that $g(x)\ne 0$ for every $x\in U$. Define the reciprocal function $q:U\to\mathbb R$ by
\begin{align*}
q(x)=\frac{1}{g(x)}.
\end{align*}
Since $g$ is continuous and nowhere zero, $q$ is continuous on $U$.
For each $i\in\{1,\dots,n\}$, differentiating the reciprocal in the coordinate direction $x_i$ gives
\begin{align*}
\partial_i q=-\frac{\partial_i g}{g^2}.
\end{align*}
The denominator $g^2$ is nowhere zero on $U$, so this is a [continuous function](/page/Continuous%20Function) on $U$.
Fix $i,j\in\{1,\dots,n\}$. Differentiating the displayed formula for $\partial_i q$ with respect to $x_j$ gives
\begin{align*}
\partial_j\partial_i q=\frac{2(\partial_i g)(\partial_j g)}{g^3}-\frac{\partial_j\partial_i g}{g^2}.
\end{align*}
Again $g^2$ and $g^3$ are nowhere zero on $U$, and the numerator functions are continuous on $U$. Therefore every second coordinate partial derivative of $q$ is continuous on $U$. Hence $q\in C^2(U)$.
[/step]
[step:Write the quotient as a product with the reciprocal]
Under the same nonvanishing hypothesis on $g$, the quotient function $f/g:U\to\mathbb R$ satisfies
\begin{align*}
\frac{f}{g}=fq.
\end{align*}
The preceding step proves that $q\in C^2(U)$, and the product step proves that the product of two $C^2(U)$ functions belongs to $C^2(U)$. Therefore $f/g\in C^2(U)$. Combining the linear combination, product, and quotient arguments proves all assertions of the theorem.
[/step]