Find the largest value of the expression $P=\frac{3x+2y+1}{x+y+6}$ For real numbers $x, y$ satisfy the condition $x>0, y>0$ and
$$\log _{\sqrt{3}}\left(\frac{x+y}{x^2+y^2+xy+2}\right)=x\left(x-3\right)+y\left(y-3\right)+xy$$
Find the largest value of the expression $$P=\frac{3x+2y+1}{x+y+6}$$

I think this is a very nice question.
We have $$P(x,y)=\frac{3x+2y+1}{x+y+6}\tag{1}$$ so by the Quotient Rule $$P'(x,y)=\frac{(3+2y')(x+y+6)-(3x+2y+1)(1+y')}{(x+y+6)^2}=\frac{y+(11-x)y'+17}{(x+y+6)^2}=0$$ for stationary points. Thus $$(11-x)y'+y+17=0\implies y'+\frac1{11-x}y=-\frac{17}{11-x}$$ is a first-order linear ODE, which is easy to solve.
Here $p(x)=\dfrac1{11-x}$ and $q(x)=-\dfrac{17}{11-x}$. The integrating factor is $$h(x)=\exp\left(\int p(x)\, dx\right)=\frac1{11-x}$$ so we solve $$y\cdot p(x)=\int p(x)q(x)\, dx \implies \frac y{11-x}=\int -\frac{17}{(11-x)^2}\, dx=-\frac{17}{11-x}+c$$ where $c$ is a constant. Hence $$y=-17-c(x-11)=-17+11c-cx\tag{2}$$ Plugging this back into $(1)$, we get $$\max P=\frac{3x-34+22c-2cx+1}{x-17+11c-cx+6}=\frac{(3-2c)(x-11)}{(1-c)(x-11)}=\frac{3-2c}{1-c}\tag{3}$$ 
Now let $x=0$. Then by $(2)$, we have $$y(0)=-17+11c\implies c=\frac1{11}(y(0)+17)\tag{4}$$ We are given the condition that $$\log _{\sqrt{3}}\left(\frac{x+y}{x^2+y^2+xy+2}\right)=x\left(x-3\right)+y\left(y-3\right)+xy$$ so $$\log_{\sqrt3}\left(\frac y{y^2+2}\right)=y(y-3)$$ This has solutions when $y=1, 2$. 
Therefore, when $y=1$, $c=\dfrac{18}{11}$ from $(4)$ and so from $(3)$,$$P_{y=1}=\frac{3-2\left(\frac{18}{11}\right)}{1-\frac{18}{11}}=\frac37$$ and when $y=2$, $c=\dfrac{19}{11}$ from $(4)$ and so from $(3)$, $$P_{y=2}=\frac{3-2\left(\frac{19}{11}\right)}{1-\frac{19}{11}}=\frac58$$ Since $\dfrac58>\dfrac37$, $$\boxed{\max P = \frac58.}$$
