Maximizing $\frac{a^2+6b+1}{a^2+a}$, where $a=p+q+r=pqr$ and $ab=pq+qr+rp$ for positive reals $p$, $q$, $r$

Hint.

Using the AM-GM we get

$$ a \ge 3\sqrt[3]{pqr}=3\sqrt[3]{a}\Rightarrow a\ge \sqrt{27} $$

$$ ab\ge 3\sqrt[3]{a^2}\ge 3\sqrt[3]{27} $$

now we can solve

$$ \max \frac{a^2+6b+1}{a^2+a}\ \ \ \text{s. t.}\ \ \ (a\ge \sqrt{27})\cap (ab \ge 9) $$

and the solution is

$$ a = 3\sqrt 3,\ \ b = \sqrt 3 $$

with

$$ \frac{a^2+6b+1}{a^2+a} = 1+\frac{1}{3 \sqrt{3}} $$

NOTE

Using the Lagrangian to obtain the stationary points

$$ L(a,b,\lambda,\mu,s_1,s_2) = \frac{a^2+6b+1}{a^2+a}+\lambda (a-\sqrt 27-s_1^2)+\mu(a b-9-s_2^2) $$

the stationary points are the solutions for

$$ \nabla L = 0 \Rightarrow\left\{ \begin{array}{rcl} \frac{2 a}{a^2+a}-\frac{(2 a+1) \left(a^2+6 b+1\right)}{\left(a^2+a\right)^2}+\lambda +b \mu & = & 0 \\ a \mu +\frac{6}{a^2+a} & = & 0\\ -s_1^2+a-3 \sqrt{3} & = & 0 \\ -s_2^2+a b-9 & = & 0 \\ \lambda s_1 & = & 0\\ \mu s_2 & = & 0 \\ \end{array} \right. $$