Solution (source code)

= Solution

Here $N=2$ and $M=1$. At $(x,0,0)$, the $z$-components of the fields of the two outer charges cancel by reflection symmetry. By <Coulomb's law>, the remaining field is
$$
E_x=\frac{2Qx}{4\pi\epsilon_0}
\left(\frac1{|x|^3}-\frac1{(x^2+d^2)^{3/2}}\right).
$$
Multiplying by the test charge $-Q$ gives
$$
\boxed{F=-\frac{Q^2x}{2\pi\epsilon_0}
\left(\frac1{|x|^3}-\frac1{(x^2+d^2)^{3/2}}\right)\widehat x}.
$$
The quantity in parentheses is positive. Thus for $x>0$ the force points in the negative $x$ direction, while for $x<0$ it points in the positive $x$ direction. It is always attractive toward the origin, as in the <transverse force from a collinear electric quadrupole>.