4. Let $n$ be a given integer $(n>1)$, and positive integers $a, b, c, d$ satisfy $\frac{b}{a}+\frac{d}{c}<1, b+d \leqslant n$. Find the maximum value of $\frac{b}{a}+\frac{d}{c}$.
4. Let the maximum value of $\frac{b}{a}+\frac{d}{c}$ be $f(n)$, and assume $a \leqslant c$. If $a \geqslant n+1$, then $\frac{b}{a}+\frac{d}{c} \leqslant$ $\frac{b}{a}+\frac{d}{a}=\frac{b+d}{a} \leqslant \frac{n}{n+1}$. If $a \leqslant n$, then fix $a$, and let $x=a(n-a+1)+1$. If $c \leqslant x$, then by $\frac{b}{a}+\frac{d}{c}x$, we have $\frac{b}{a}+\frac{d}{c}<1$, which implies $\frac{b}{a}<1$, so $a \geqslant b+1$. Therefore, $\frac{b}{a}+\frac{d}{c}-\left(\frac{a-1}{a}+\frac{b+d-a+1}{c}\right)=(b+1-$ a) $\left(\frac{1}{a}-\frac{1}{c}\right) \leqslant 0$, so $\frac{b}{a}+\frac{d}{c} \leqslant \frac{a-1}{a}+\frac{b+d-a+1}{c} \leqslant \frac{a-1}{a}+\frac{n-a+1}{c} \leqslant$ $\frac{a-1}{a}+\frac{n-a+1}{x}=1-\frac{1}{a x}$. Therefore, when $a \leqslant n$, we always have $\frac{b}{a}+\frac{d}{c} \leqslant 1-\frac{1}{a x}$, and the equality can be achieved. Thus, the problem reduces to finding the maximum value of the function $g(a)=1-\frac{1}{a x}=1-\frac{1}{a[a(n-a+1)+1]}$ $\left(2 \leqslant a \leqslant n, a \in \mathbf{N}^{*}\right)$, which is equivalent to finding the maximum value of $h(a)=a[a(n-a+1)+1](2 \leqslant$ $\left.a \leqslant n, a \in \mathbf{N}^{*}\right)$. Since $h^{\prime}(a)=-3 a^{2}+(2 n+2) a+1$, the positive root of $h^{\prime}(a)=0$ is $a_{0}=\frac{n+1+\sqrt{(n+1)^{2}+3}}{3}$. And $\frac{2 n+2}{3}<a_{0}<\frac{2 n+3}{3}=\frac{2 n}{3}+1$, substituting the two positive integers closest to $a_{0}$ into $h(a)$ for comparison. It is found that when $a=\left[\frac{2 n}{3}\right]+1$, $h(a)$ reaches its maximum value. At this point, $g(a)$ reaches its maximum value $1-\frac{1}{a[a(n-a+1)+1]}$, where $a=\left[\frac{2 n}{3}\right]+1$.