\(M=\left(x-5\right)\left(x+2\right)+\left(3x-6\right)\left(x+2\right)-\left(3x-\dfrac{1}{2}\right)^2+5x^2\)
\(=\left(x+2\right)\left(x-2+3x-6\right)-\left(9x^2-3x+1\right)+5x^2\) \(=\left(x+2\right)\left(4x-8\right)-9x^2+3x-1+5x^2\) \(=4\left(x+2\right)\left(x-2\right)-4x^2+3x+1\) \(=4\left(x^2-4\right)-4x^2+3x+1\) \(=4x^2-16-4x^2+3x+1\) \(=3x-15\) \(=3\left(x-5\right)\) Với x=2018 thì \(M=3\left(2018-5\right)=3.2015=6045\)