40. Let \( f \) be the function defined by
\[
f(x) = \begin{cases}
\frac{1}{16}x^2 + 1 & \text{for } 0 \leq x \leq 4 \\
3\sqrt{x} - x & \text{for } 4 < x \leq 9
\end{cases}
\]
What is the average value of \( f \) on the closed interval \( 0 \leq x \leq 9 \)?