<s>[INST] 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.

 [/INST] $$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
</s>