Let $f:(0,1) \rightarrow \mathbf{R}$ be defined as
$$
f(x)=\left\{\begin{array}{l}
x, x \text { is irrational; } \\
\frac{p+1}{q}, x=\frac{p}{q},(p, q)=1,0<p<q .
\end{array}\right.
$$

Find the maximum value of $f(x)$ on $\left(\frac{7}{8}, \frac{8}{9}\right)$.
Solve: First notice that $f\left(\frac{15}{17}\right)=\frac{16}{17}$, below we prove that $\frac{16}{17}$ is the maximum value sought.
By contradiction, if $x \in\left(\frac{7}{8}, \frac{8}{9}\right)$, and $f(x)>\frac{16}{17}$, then $f(x)>\frac{16}{17}>\frac{8}{9} \geqslant x$. Therefore, $x$ must be a rational number, let's assume $x=\frac{p}{q}, p 、 q \in \mathbf{N},(p, q)=1$, and $0<q<p$, then $\frac{7}{8}<\frac{q}{p}<\frac{8}{9}$, which gives $8(p-q)<p<9(p-q)$. If $p-q \geqslant 3$, then $p \geqslant 25$, hence $f(x)=x+\frac{1}{p}<\frac{8}{9}+\frac{1}{25}<\frac{16}{17}$, a contradiction. If $p-q<3$, then $9(p-q)-8(p-q) \geqslant$ $2, p-q \geqslant 2$. It can only be that $p-q=2,16<p<18$, only $p=17, q=15, f(x)=\frac{16}{17}$, also a contradiction. Therefore, on $\left(\frac{7}{8}, \frac{8}{9}\right)$, $f_{\max }(x)=\frac{16}{17}$.