well about the book
5 + 4x - x^2 = M - x^2 + 2nx - n^2
and then add x^2 to both sides of equation,
5 + 4x = M + 2nx - n^2
by comparing coefficients, it means that in order to make this equation valid, you have to have the same coefficient in left hand side and right hand side for x^1, and...