6. On the interval $\left[\frac{1}{2}, 2\right]$, the function $f(x)=x^{2}+p x+q$ and $g(x)=2 x+\frac{1}{x^{2}}$ achieve the same minimum value at the same point. The maximum value of $f(x)$ on $\left[\frac{1}{2}, 2\right]$ is $\qquad$ .