\(M=6x-x^2+2\\ M=-\left(x^2-6x-2\right)\\ M=-\left(x^2-6x+9-11\right)\\ M=-\left(x-3\right)^2+11\)
Có \(\left(x-3\right)^2\ge0\forall x\)
\(\Rightarrow-\left(x-3\right)^2\le0\forall x\\ \Rightarrow-\left(x-3\right)^2+11\le11\forall x\)
Dấu \("="\) xảy ra \(\Leftrightarrow\left(x-3\right)^2=0\\ \Leftrightarrow x=3\)
Vậy \(max_M=11\Leftrightarrow x=3\)