### What-is-the-theoretical-minimum-energy-cost-of-desalinating-water

The energy cost is zero. In desalination, you take the ions that were in one body of water and move them to a different body of water, but the energy is the same no matter where the ions are. Desalination is about paying the entropy cost, not the energy cost.

We imagine the desalination process part-way complete. On the left we have the ocean with a constant concentration ${c}_{0}$ of ions. On the right we have water we're trying to desalinate, which currently has concentration $c$ of ions. How much does the entropy change if we move an ion from the right to the left?

You may know the formula for entropy,
$S=\mathrm{ln}\mathrm{\Omega }$ where $\Omega$ is the number of possible states of the system. We need a way to estimate $\Omega$.

Imagine each ion living in its own little house, with all the houses jammed up next to each other to take up all the space in the water. When the concentration of ions is low the houses are big and when the concentration is high the houses are small. The volume of each house is $V=1/c$.

The ion can wander around anywhere inside its house. That means that if you make the house twice as big, there are twice as many possible states for the molecule. States are proportional to volume. In an equation, $\mathrm{\Omega }=\alpha V=\alpha /c$ where $\alpha$ is just a constant of proportionality that won't matter because it cancels out.

The entropy of being on the right is therefore ${S}_{r}=\mathrm{ln}\left(\alpha /c\right)$ and the entropy of being on the left is ${S}_{l}=\mathrm{ln}\left(\alpha /{c}_{0}\right)$. The change in entropy $dS$ when a molecule moves from right to left is

$\mathrm{d}S=\left({S}_{l}-{S}_{r}\right)\mathrm{d}N$
$=\left(\mathrm{ln}\left(\alpha /{c}_{0}\right)-\mathrm{ln}\left(\alpha /c\right)\right)\mathrm{d}N=\mathrm{ln}\left(c/{c}_{0}\right)\mathrm{d}N$

where $N$ is the number of ions in the water we're desalinating.

When the concentrations are equal, we're at equilibrium and this expression comes to zero. When $c$ is smaller than ${c}_{0}$ the expression is negative, meaning we are decreasing the entropy when we desalinate. To desalinate completely, we need to take $c$ down from ${c}_{0}$ to zero, so the average entropy decrease per ion is

$\frac{\mathrm{d}\overline{S}}{\mathrm{d}N}=\frac{1}{{c}_{0}}{\int }_{0}^{{c}_{0}}\mathrm{ln}\left(c/{c}_{0}\right)\mathrm{d}c=-1$
If we want to desalinate a volume of water
$V$, then it has $cV$ ions, so the total entropy cost is

$\mathrm{\Delta }S=-cV$

The total entropy of the universe can't go down, so you need to increase the entropy of something else by at least this much to complete the desalination.

You can pay this entropy cost however you like. For example, you could theoretically set up a device that takes in salt water and 1 TB hard drives full of 0's. It then writes over the hard drives with random bits, increasing their entropy by ${10}^{12}$ bytes, or $2.1\ast {10}^{12}$ in our units (base $e$). Sea water has roughly $7\ast {10}^{23}$ ions per liter, so each hard drive would yield a maximum of about $8\ast {10}^{-11}$ liters. All of Google's servers processed in this way would only make about a cubic centimeter of desalinated water.

More realistically, suppose we do work on the system while holding it at a constant temperature $T$. Then the system gives off an equal amount of heat, and the entropy increase is

$\mathrm{\Delta }S=\frac{Q}{T}=\frac{W}{T}$
(The second equality says that all the work we did gets turned into heat.) Then equating our two entropy expressions, the minimum work is

${W}_{min}=TcV$

at room temperature, this is about 0.8 kilowatt hours per cubic meter, or 0.7 kCal/liter. If you rode an exercise bike hooked up to an ideal desalination machine, it could make you a liter of water in about a minute of relaxed riding.

notes:
This answer is written in units where Boltzmann's constant is one. Throughout, I've used the "ideal gas" approximation for solutes - i.e. the solutes don't interact with each other. All of the expressions and statements are approximations; the energy change in moving ions is not precisely zero, just much smaller than the free energy change, etc.