How to prove that function $f(p)= \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$ is less than 0.3 for all $p$? How to prove that function $f(p)= \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$ is less than 0.3 for all $p$?
Let's suppose that we have a function defined as follows:
$f(p) = \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$
where $p$ is a prime number and $[...]$ are Iverson brackets.
Here are the first few values of $f(p)$:
$f(3) = \frac{1}{(3^2 - 1)} \times \frac {(3^2-3)}{3}$
$f(3) = \frac{1}{8} \times  \frac{6}{3}$
$f(3) = 0.25$
$f(5) = \frac{1}{(5^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} ]$
$f(5) = \frac{1}{24} \times [ \frac{6}{3} +\frac{22}{5} ]$
$f(5) = 0.26667$
$f(7) = \frac{1}{(7^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} +\frac{(7^2-3)}{7}]$
$f(7) = \frac{1}{48} \times [ \frac{6}{3} +\frac{22}{5} +\frac{46}{7}]$
$f(7) = 0.273214286$
$f(11) = \frac{1}{(11^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} +\frac{(7^2-3)}{7}+\frac{(11^2-3)}{11}]$
$f(11) = \frac{1}{120} \times [ \frac{6}{3} +\frac{22}{5} +\frac{46}{7}+\frac{118}{11}]$
$f(11) = 0.198679654$
How to prove that $f(p)$ is always less than 0.3 for all prime numbers $p$?
I wrote a program to calculate $f(p)$ for the first $1000$ primes up to $p = 7,927$ and graphically it appears to approach $0$ with a maximum value of $0.2732$ at $p=7$. From the graph, it looks like it should be easy, but for some reason, I cannot figure it out.
Notice that $f(3) < f(5) < f(7)$, but $f(7) > f(11)$ so a proof by induction may not work.

 A: $$
\begin{align}
\sum_{q=3}^p\frac{q^2-3}{q}
&=\int_{3^-}^{p^+}\frac{x^2-3}{x}\,\mathrm{d}\pi(x)\\
&=\left[\frac{p^2-3}{p}\pi(p)-2\right]-\int_{3^-}^{p^+}\pi(x)\left(1+\frac3{x^2}\right)\mathrm{d}x\\[3pt]
&=\frac{p^2}{2\log(p)}+\frac{p^2}{4\log(p)^2}+\frac{p^2}{4\log(p)^3}+O\!\left(\frac{p^2}{\log(p)^4}\right)
\end{align}
$$
Thus, we have
$$
\frac1{p^2-1}\sum_{q=3}^p\frac{q^2-3}{q}\sim\frac1{2\log(p)}+\frac1{4\log(p)^2}+\frac1{4\log(p)^3}
$$
whose plot looks like

A: $$f(p)=\frac{1}{p^2-1}\sum_{q=3}^p\frac{q^2-3}{q}$$
If we use the fact that:
$$\sum_{q=3}^p\frac{q^2-3}{q}=\sum_{q=3}^pq-3\sum_{q=3}^p\frac1q$$
Now we know that:
$$\sum_{q=3}^pq=\sum_{q=1}^pq-\sum_{q=1}^2q=\frac{p(p+1)}{2}-3$$
$$-3\sum_{q=3}^p\frac1q=-3\left[\sum_{q=1}^p\frac1q-\sum_{q=1}^2\frac1q\right]=-3\left[\ln(p)+\gamma+\frac{1}{2p}-\frac32\right]$$
If we add these together we get:
$$f(p)=\frac{1}{p^2-1}\left[\frac{p(p+1)}{2}-3\left(\ln(p)+\gamma+\frac{1}{2p}-\frac12\right)\right]$$
Now if you find $f'(p)$ you can find a maximum value and find what this is
A: The result is true for $p = 3$, $5$, and $7$, so assume that $p = 2n+1$ for $n \ge 4$.
Note that all the primes $q$ occurring in the sum are odd. Thus
$$
\begin{aligned}
f(p) = f(2n+1) = & \ \frac{1}{4n^2 + 4n} \sum_{q=3}^{p, \text{ with $q$ prime}} \frac{q^2 - 3}{q}\\
 < & \  \frac{1}{4(n^2 + n)} \sum_{q=3}^{p, \text{ with $q$ prime}} q \\
< & \  \frac{1}{4(n^2 + n)} \sum_{q = 3}^{p, \text{with $q$ odd}}
q \\
 = & \   \frac{1}{4(n^2 + n)} \sum_{j=1}^{n} (2j+1)\\
 = &  \ \frac{n^2 +2n}{4(n^2 + n)} \\
= & \ \frac{3}{10} - \frac{(n-4)}{20(n+1)} \\
 \le & \  \frac{3}{10}. \end{aligned}$$
In reality, $f(p) \rightarrow 0$, since 
$$f(p) \le \frac{1}{p^2} \sum_{q \le p} q
\le \frac{1}{p^2} \sum_{q \le p} p
=  \frac{1}{p^2} \cdot p \pi(p) \sim 1/\log p.$$
