We will first consider the existence of \(q(x)\) and \(r(x)\text{.}\) If \(f(x)\) is the zero polynomial, then
\begin{equation*}
0 = 0 \cdot g(x) + 0;
\end{equation*}
hence, both \(q\) and \(r\) must also be the zero polynomial. Now suppose that \(f(x)\) is not the zero polynomial and that \(\deg f(x) = n\) and \(\deg g(x) = m\text{.}\) If \(m \gt n\text{,}\) then we can let \(q(x) = 0\) and \(r(x) = f(x)\text{.}\) Hence, we may assume that \(m \leq n\) and proceed by induction on \(n\text{.}\) If
\begin{align*}
f(x) & = a_n x^n + a_{n-1} x^{n - 1} + \cdots + a_1 x + a_0\\
g(x) & = b_m x^m + b_{m-1} x^{m - 1} + \cdots + b_1 x + b_0
\end{align*}
the polynomial
\begin{equation*}
f'(x) = f(x) - \frac{a_n}{b_m} x^{n - m} g(x)
\end{equation*}
has degree less than \(n\) or is the zero polynomial. By induction, there exist polynomials \(q'(x)\) and \(r(x)\) such that
\begin{equation*}
f'(x) = q'(x) g(x) + r(x)\text{,}
\end{equation*}
where \(r(x) = 0\) or the degree of \(r(x)\) is less than the degree of \(g(x)\text{.}\) Now let
\begin{equation*}
q(x) = q'(x) + \frac{a_n}{b_m} x^{n - m}\text{.}
\end{equation*}
Then
\begin{equation*}
f(x) = g(x) q(x) + r(x)\text{,}
\end{equation*}
with \(r(x)\) the zero polynomial or \(\deg r(x) \lt \deg g(x)\text{.}\)
To show that \(q(x)\) and \(r(x)\) are unique, suppose that there exist two other polynomials \(q_1(x)\) and \(r_1(x)\) such that \(f(x) = g(x) q_1(x) + r_1(x)\) with \(\deg r_1(x) \lt \deg g(x)\) or \(r_1(x) = 0\text{,}\) so that
\begin{equation*}
f(x) = g(x) q(x) + r(x) = g(x) q_1(x) + r_1(x)\text{,}
\end{equation*}
and
\begin{equation*}
g(x) [q(x) - q_1(x) ] = r_1(x) - r(x)\text{.}
\end{equation*}
If \(q(x) - q_1(x)\) is not the zero polynomial, then
\begin{equation*}
\deg( g(x) [q(x) - q_1(x) ] )= \deg( r_1(x) - r(x) ) \geq \deg g(x)\text{.}
\end{equation*}
However, the degrees of both \(r(x)\) and \(r_1(x)\) are strictly less than the degree of \(g(x)\text{;}\) therefore, \(r(x) = r_1(x)\) and \(q(x) = q_1(x)\text{.}\)