4. Given the function $f(x)=\frac{\sin (\pi x)-\cos (\pi x)+2}{\sqrt{x}}\left(\frac{1}{4} \leqslant x \leqslant \frac{5}{4}\right)$, then the minimum value of $f(x)$ is
4. $\frac{4 \sqrt{5}}{5}$ Detailed Explanation: Actually $f(x)=\frac{\sqrt{2} \sin \left(\pi x-\frac{\pi}{4}\right)+2}{\sqrt{x}}\left(\frac{1}{4} \leqslant x \leqslant \frac{5}{4}\right)$.

Let $g(x)=\sqrt{2} \sin \left(\pi x-\frac{\pi}{4}\right)\left(\frac{1}{4} \leqslant x \leqslant \frac{5}{4}\right)$, then $g(x) \geqslant 0, g(x)$ is an increasing function on $\left[\frac{1}{4}, \frac{3}{4}\right]$, and a decreasing function on $\left[\frac{3}{4}, \frac{5}{4}\right]$, and the graph of $y=g(x)$ is symmetric about the line $x=\frac{3}{4}$. Therefore, for any $x_{1} \in\left[\frac{1}{4}, \frac{3}{4}\right]$, there exists $x_{2} \in \left[\frac{3}{4}, \frac{5}{4}\right]$, such that $g\left(x_{2}\right)=g\left(x_{1}\right)$. Thus, $f\left(x_{1}\right)=\frac{g\left(x_{1}\right)+2}{\sqrt{x_{1}}}=\frac{g\left(x_{2}\right)+2}{\sqrt{x_{1}}} \geqslant \frac{g\left(x_{2}\right)+2}{\sqrt{x_{2}}}=f\left(x_{2}\right)$, and $f(x)$ is a decreasing function on $\left[\frac{3}{4}, \frac{5}{4}\right]$, so $f(x) \geqslant f\left(\frac{5}{4}\right)=\frac{4 \sqrt{5}}{5}$, which means the minimum value of $f(x)$ on $\left[\frac{1}{4}, \frac{5}{4}\right]$ is $\frac{4 \sqrt{5}}{5}$.