The total mechanical energy of the particle at any instant is sum of kinetic and potential energy hence we use
KE+PE=2 J
⇒12mv2+x22−x=2
⇒v2=2x−x2+4
For maximum velocity,
we use d(v2)dx=0
⇒2−2x=0
⇒x=1
Thus maximum speed is at x=1, which is given as
v2max=2−1+4
vmax=√5 ms−1