Find all values of $x$ at which $P(x)=x^4-4x^3+22x^2-36x+18$ is a perfect square Find all values  of  positive  integer  $x$ at which  the following  expression is perfect  square 
$$P(x)=x^4-4x^3+22x^2-36x+18$$
I tried  to assume $P= (x^2+ax+b)^2$  ;  and  comparing the cofactors , get that $a= -2 ; b= 9$ 
, but when expand the $x^2-2x+9$,  I didn't get  the same as $P$
What is wrong in my work? 

If $x$ is an integer, then
$$x^4-4x^3-22x^2-36x+18$$
$\qquad$is congruent to $2$ mod $4$ if $x$ is even, 

$\qquad$and is congruent to $5$ mod $8$ if $x$ is odd, 

hence can't be a perfect square.

(Even squares are congruent to $0$ mod $4$, and odd squares are congruent to $1$ mod $8$.)

Some details . . .

If $x$ is even, all the terms are multiples of $4$ except $18$, so
\begin{align*}
&x^4-4x^3-22x^2-36x+18\\[4pt]
\equiv\;&18\;(\text{mod}\;4)\\[4pt]
\equiv\;&2\;(\text{mod}\;4)\\[4pt]
\end{align*}
If $x$ is odd, then $x^2 \equiv 1\;(\text{mod}\;8)$, hence
\begin{align*}
&x^4-4x^3-22x^2-36x+18\\[4pt]
\equiv\;&x^4-4x^3-6x^2-4x+2\;(\text{mod}\;8)\\[4pt]
\equiv\;&(x^2)^2-4(x^2)x-6x^2-4x+2\;(\text{mod}\;8)\\[4pt]
\equiv\;&(1)^2-4(1)x-6(1)-4x+2\;(\text{mod}\;8)\\[4pt]
\equiv\;&-3-8x\;(\text{mod}\;8)\\[4pt]
\equiv\;&5\;(\text{mod}\;8)\\[4pt]
\end{align*}
