Sections 6.9 and 16.1  16.3 in Matter and Interactions (4th edition)
Electric Potential Energy
As you read about in the electric force, we noted that the electric force is a conservative force. This means we can define a potential energy  electric potential energy in this case  using that force. These notes will talk about the general relationship between force and potential energy, walk through an example for point charges, and highlight the relationship between electric potential energy and electric potential.
General Relationship  Energy and Force
Much like the gravitational force, the electric force is conservative. This means that we can define an electric potential energy using the general relationship: $$\Delta U = \int_i^f\vec{F}\bullet d\vec{r}$$ This relationship is always true for conservative forces (works for springs, gravitational interactions, electric interactions, etc.). In our case, we are particularly interested in the electric potential energy ($U_{elec}$): $$\Delta U_{elec}= \int_i^f\vec{F}_{elec}\bullet d\vec{r}$$
There are a few important features of this relationship:
 Energy is scalar (including electric energy), so to get from the vector force we must use the dot product with displacement to get energy. Dot products produce scalar quantities from two vector quantities.
 The electric force is not constant, it usually depends on $r$. This means we have to use the integral rather than just multiplying by the distance.
 If we are integrating from some initial location to some final location, we will get a change in electric potential energy between the two locations (not the energy at a single place). This change in energy is the important part  it does not matter how you get from the initial to the final location (squiggly or straight path), you will get the same change in energy. This means that electric potential energy is path independent.
 Energy conservation and the workenergy theorem from mechanics still apply (and are highly dependent on your choice of system)
 The units of electric potential energy are joules (J) just like all the other forms of energy.
Deriving Electric Potential Energy for Two Point Charges
Using the relationship between force and potential energy, we can derive the electric potential energy between two point charges from the electric force. Suppose we have two positive point charges $q_1$ and $q_2$, who are initially separated by a distance r. We will assume $q_1$ is fixed and let $q_2$ move to infinity. Starting with the general relationship: $$\Delta U_{elec} = U_fU_i= \int_i^f\vec{F}_{elec}\bullet d\vec{r}$$ we can plug in the electric force equation for the force from $q_1$ on $q_2$ (point charges), and we know that our initial location is $r_i=r$ and our final location is $r_f=\infty$. So we get:
$$\Delta U_{elec} = U_\inftyU_r= \int_r^\infty \frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r^2}\hat{r} \bullet d\vec{r}$$
The force from $q_1$ on $q_2$ points in the $+\hat{x}$ direction so this means $\hat{r}=\hat{x}$. $q_2$ will also move in the $\hat{x}$ direction so that means $d\vec{r}=dr\hat{x}$. $$ U_\inftyU_r= \int_r^\infty \frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r^2}\hat{x} \bullet dr\hat{x}$$ Since here we have a scalar times a vector dotted with another scalar times a vector, we can rearrange this equation so that we have the scalars multiplied in the front times the dot product of the two vectors. $$ U_\inftyU_r= \int_r^\infty \frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r^2}dr \hat{x}\bullet\hat{x}$$ Because $\hat{x}$ has a magnitude of 1, and we are dotting $\hat{x}$ with $\hat{x}$ (these are parallel vectors) $$\hat{x} \bullet \hat{x}= \hat{x}\hat{x}cos(0)=1\cdot 1\cdot 1 = 1$$ So we get for our energy equation: $$ U_\inftyU_r= \int_r^\infty \frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r^2}dr$$ Pulling all of the constants out of the integral, we get $$U_\inftyU_r= \frac{1}{4\pi\epsilon_0}q_1q_2\int_r^\infty \frac{1}{r^2}dr$$ $$U_\inftyU_r= \frac{1}{4\pi\epsilon_0}q_1q_2 \left.\left( \frac{1}{r} \right) \right_r^\infty$$ $$U_\inftyU_r= \frac{1}{4\pi\epsilon_0}q_1q_2 \left(\frac{1}{\infty}+\frac{1}{r} \right)$$
Because 1 divided by a very large number is extremely close to zero, we say $\frac{1}{\infty}=0$. (You can show this formally using limits, but physicists tend to be lazy in this regard. This is one way we tend to drive mathematicians crazy.) This leaves the change in electric potential energy from r to $\infty$ as: $$\Delta U_{elec} = U_\inftyU_r=  \frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r}$$ Just as we did with the superposition of potential, we will often assume that $U=0$ at infinity. You don't have to choose infinity as the location where $U=0$ but we often will because it is convenient. This assumption allows us to be consistent with how potential is defined, and it allows us to interpret a positive potential energy as repulsion and a negative potential energy as attraction. Using this assumption, then $$U_r=\frac{1}{4\pi\epsilon_0}\frac{q_1q_2}{r}$$
This energy then is the electric potential energy between two point charges $q_1$ and $q_2$ that are separated by a distance $r$. If $U$ is positive, $q_1$ and $q_2$ have the same sign and if $U$ is negative, $q_1$ and $q_2$ have opposite signs.
Getting from Energy to Force
We can also use the inverse of energyforce relationship to get the electric force from electric potential energy. If we know what the electric potential energy is in terms of $r$, you can calculate the electric force by taking the negative derivative of energy with respect to $r$, which will give you the electric force in the $\hat{r}$ direction. This assumes that your electric potential energy equation does not depend on an angle. (If your electric potential energy does depend on an angle, then you have to use the gradient.) $$\vec{F}=\frac{dU}{dr}\hat{r}$$
If you know the electric potential energy in terms of $x$, $y$, and $z$ variables, you can calculate the electric force by taking the negative derivative with respect to each direction (this is the gradient in cartesian coordinates). $$\vec{F}=\frac{dU}{dx}\hat{x}\frac{dU}{dy}\hat{y}\frac{dU}{dz}\hat{z}=\left\langle \frac{dU}{dx},\frac{dU}{dy},\frac{dU}{dz} \right\rangle$$
Relating Energy Back to Potential
Now that we have an idea of what the electric potential energy looks like (both generally and specifically for point charges), we can relate energy back to what we learned last week about electric potential. Let's start by considering two point charges again. Looking at the electric energy equation, we could easily rewrite this equation in term of the electric potential from $q_1$: $$U=q_2 \frac{1}{4\pi\epsilon_0}\frac{q_1}{r}= q_2 V_1$$
Or the electric potential from $q_2$: $$U=q_1 \frac{1}{4\pi\epsilon_0}\frac{q_2}{r}= q_1 V_2$$
This shows a larger, more general relationship between electric potential energy and electric potential. $$U=qV$$ Or even more importantly: $$\Delta U=q\Delta V$$
Note that electric potential energy is NOT the same thing as electric potential. Electric potential energy requires two charges or a charge interacting with potential, whereas electric potential is from a single charge. Electric potential energy has units of joules and electric potential has units of volts. That being said, electric potential is related to electric potential energy. Electric potential tells you about how much energy there could be, without needing to know charges are interacting.
Examples

 Video Example: Particle Acceleration through an Electric Field

 Video Example: Preventing an Asteroid Collision