Example 5 Let $a, b$ be positive integers. Satisfy $a b \neq 1$. Find all possible integer values of $f(a, b)=\frac{a^{2}+b^{2}+a b}{a b-1}$.
(2004 Romanian National Team Selection)
Solve $f(a, b)=\frac{a^{2}+b^{2}+a b}{a b-1}=\frac{a^{2}+b^{2}+1}{a b-1}+1$, let $\frac{a^{2}+b^{2}+1}{a b-1}=k$, where $k$ is a positive integer. It is easy to know that $k>2$. By symmetry, without loss of generality, assume that among all integer pairs that achieve the value of $k$, $\left(a_{0}, b_{1}\right)$ has the smallest $a_{0}$, then $\frac{a_{0}^{2}+b_{1}^{2}+1}{a_{0} b_{1}-1}=k$, rearranging gives: $b_{1}^{2}-k a_{0} b_{1}+k+1+a_{0}^{2}=0$, let the other root of the equation $x^{2}-k a_{0} x+k+1+a_{0}^{2}=0$ be $b_{2}$, by Vieta's formulas we get: $\left\{\begin{array}{l}b_{1}+b_{2}=k a_{0} \\ b_{1} b_{2}=a_{0}^{2}+k+1\end{array}\right.$ (1), we know $b_{2}$ is also a positive integer, since $a_{0}$ is the smallest, then $\left(b_{1}-a_{0}\right)\left(b_{2}-a_{0}\right) \geqslant 0$, expanding and substituting (1) we get: $a_{0}^{2}+k+1-a_{0}\left(k a_{0}\right)+a_{0}^{2} \geqslant 0$, so $a_{0}^{2} \leqslant \frac{k+1}{k-2}=$ $1+\frac{3}{k-2} \leqslant 4$, so $a_{0} \leqslant 2$.
(1) When $a_{0}=1$, solving (1) gives: $\left\{\begin{array}{l}b_{1}=2 \\ b_{2}=4\end{array}\right.$, or $\left\{\begin{array}{l}b_{1}=4 \\ b_{2}=2\end{array}, k=6\right.$.
(2) When $a_{0}=2$, solving (1) gives: $\left\{\begin{array}{l}b_{1}=2 \\ b_{2}=4\end{array}\right.$, or $\left\{\begin{array}{l}b_{1}=4 \\ b_{2}=2\end{array}, k=3\right.$. Therefore, $f(a, b)=4$ or 7.
/Note: Vieta's formulas are also an important method for solving number theory problems.