Sign mistake calculating electrostatic potential energy formula! I have a problem calculating the electrostatic potential energy.
I rely on these equations coming from mechanics:
\begin{equation}
U_{B}-U_{A} = -W_{A \ \rightarrow \ B} (done\ by \ the \  field \ force)
\end{equation}
\begin{equation}
U_{B}-U_{A} = W_{A \ \rightarrow \ B} (done\ by \ the \ opposite \ force)
\end{equation}
According to the next picture

Work done by the coulomb force (field force) is:
\begin{equation}
W= \int_{A}^{B}  \! \vec{F}.\,\vec{dr}
\end{equation}
According to the picture
\begin{equation}
F = \frac{q_{1}q_{2}}{4\pi e_{o} x^{2}} \vec{i}
\end{equation}
\begin{equation}
\vec{dr} =- dx \vec{i}
\end{equation}
Therefore: 
\begin{equation}
W= \int_{A}^{B}  \! \vec{\frac{q_{1}q_{2}}{4\pi e_{o} x^{2}} \vec{i}}.\,(- dx \vec{i}) 
\end{equation}
let  $B=r$ and A=$\infty$ be
\begin{equation}
W= -\int_{\infty}^{r}  \! \frac{q_{1}q_{2}}{4\pi e_{o} x^{2}} \, dx 
\end{equation}
Let  $B=r$ and A=$\infty$  be
\begin{equation}
W= \frac{q_{1}q_{2}}{4\pi e_{o} } (\frac{1}{x} from\ \infty \ to \ r )
\end{equation}
Then:
\begin{equation}
W= \frac{q_{1}q_{2}}{4\pi e_{o} r} 
\end{equation}
When I put this result into equations at the top:
\begin{equation}
U_{B}-U_{A} = -\frac{q_{1}q_{2}}{4\pi e_{o} r} 
\end{equation}
As $U_{A} =0$
Finally: 
\begin{equation}
U_{B} = -\frac{q_{1}q_{2}}{4\pi e_{o} r} 
\end{equation}
It turned out the potential energy is negative, but it is suppose to be positive since a external force is putting energy into the system. I don't know where my mistake is! 
 A: You are doing a "backwards" integration. From higher to lower rather than from lower to higher x-axis values.
Integrating "backwards" from $\infty$ to $r$ (backwards because $\infty>r$) is the "flipped" and "opposite" version of the one from $r$ to $\infty$,
$$\int_\infty^r \dots dx=-\int_r^\infty \dots dx\,.$$
$\int$ is a generalized summation symbol. It sums up all the small bits. $\int_\infty^r$ and $\int_r^\infty$ should cover the exact same thing. Mathematically, the same area under the drawn graph; physically the same displacement. One is just columns summed left-to-right, and the other columns summed right-to-left; or physically summations over the same path, just starting from the right and then from the left. They should be exactly equal.
But writing them out will give a sign issue, because we always say "final situation" minus "starting situation":
$$\int_\infty^r \dots dx=\underbrace{F_r}_\text{final}-\underbrace{F_\infty}_\text{start}\qquad\quad \int_r^\infty \dots dx=\underbrace{F_\infty}_\text{final}-\underbrace{F_r}_\text{start}$$
$F_r-F_\infty$ and $F_\infty-F_r$ are not the same - their signs are opposite. But we know that they are exactly equal - just summed from different starting points. This mathematical issue means that integrating "backwards" requires us to add a minus sign. Otherwise we do not get the same area under the graph or the same path summation.
