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$?

$$ \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

enter image description here


$$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