Consider the force due to a point charged particle at the origin and the particle which we move to also be charged with the same charge.
When we move a particle from point $\mathbf{x}$(position vector) from origin to infinity(radially), if there is some force $\mathbf{f}$ at $\mathbf{x}$ (position vector) then some work is done on the particle to move from $\mathbf{x}$ to $\mathbf{x}+d\mathbf{x}$ (to ultimately reach infinity) this work is given as: dot product of $\mathbf{f}$ and $d\mathbf{x}$(displacement vector) which in this case, since displacement is parallel to the force vector, gives $\mathbf{f}d\mathbf{x}$, this much I have no trouble understanding.
But, If we move from infinity to $\mathbf{x}$ (everything is the same, but the path of the particle is reversed), if there is some force $\mathbf{f}$ at some intermediate point in the path then, the displacement by $d\mathbf{r}$(vector) towards the final position(x) requires work given as: dot product of $\mathbf{f}$ and $d\mathbf{x}$, but now, the direction of force and displacement are opposite to each other, thus we must get $-\mathbf{f}d\mathbf{x}$ but to my dismay, this is false.
Can someone please explain why I am wrong?