Solution (source code)

= Solution

Factor out $-1/2$ and use the method of <completing the square> inside the bracket:
$$
-\frac{x^2}{2}+x=-\frac12(x^2-2x)
=\boxed{\frac12-\frac12(x-1)^2}.
$$