Resitor bank optmizer I have a real world problem where the math is beyond me.  I'm trying to set up an automated resistor bank much like a decade box.  I have $18$ channel that I can switch in up to four channels in parallel at a time.  Each channel is a fixed resistor value.  The system will take a target resistance and calculate which channels to turn on (up to four of the $18$) to get the closest resistance to the target.  That part is easy.  The part I need help with is picking the fixed resistor values for the $18$ channels.  I want to minimize the error between the target resistance and of the resistance value of the four channels switch in.  Here's what I have:
$R_t$ = target resistance
$R_1$ = $1$ of $18$ fixed values
$R_2$ = $1$ of $17$ fixed values  (one fix value used for $R_1$)
$R_3$ = $1$ of $16$ fixed values  (two fix values used for $R_1$ & $R_2$)
$R_4$ = $1$ of $15$ fixed values  (three fixed values used for $R_1$, $R_2$ & $R_3$)
Lets just take the case where we always switch in four channels so the error would be:
$$\left|\frac{1}{R_t} - (\frac{1}{R_1}+\frac{1}{R_2}+\frac{1}{R_3}+\frac{1}{R_4})\right|$$
Lets put some bounds on it.  The target resistance can be from $25$ to $300$  and any of the $18$ fixed resistor channels can be from $25$ to $10,000$
I was thinking the integral from $25$ to $300$ equals zero but I don't want the sum of the errors to be zero.  I want the largest error (for $25\to300$) to be the smallest it can be.  Plus I don't know how to deal with the problem that $R_1\to R_4$ can change to anyone of the $18$ fixed values at any time.  I don't know how to work the fixed values into the equation and solve for them.

Fortunately, you measure the error by the reciprocal resistance, not the resistance itself. This allows us to simply work with reciprocals and their sums. Thus whet we are looking for, is $N=18$ numbers $a_1,\ldots,a_{18}$ such that the numbers that can be achieved as sums of up to four of these numbers are as uniformly dense as possible in a given range.
Without the four-summand limit, we'd simply let $a_k=2^{k-1}u$ for suitable $u$; then we can represent any multiple of $u$ form $0$ up to $(2^N-1)u$. We'll drop the $u$ for now and attempt to produce as many sonsecutive integers as possible,
For the given constraints, lets try what we can get by letting $a_k=A+(k-1)$, for example:
With one summand we can achieve $A,A+1,A+2,\ldots,A+n-1$. 
With two summands we can certainly achieve $2A+1,\ldots,2A+2n-3$. With three summands we get $3A+3,\ldots,3A+3n-6$. And with four summands $4A+6,\ldots,4A+3n-10$. So to cover a contiguous range of integers, we need $A$ to be an integer with 
$$ 2A+1\le A+n,\quad 3A+3\le 2A+2n-2,\quad 4A+6\le 3A+3n-5$$
or $A\le \min\{n-1, 2n-5, 3n-11\}$. So for $n=18$, we may choose $A=17$, and thus cover all integers from $17$ to $112$. Unfortunately, this method is very wasteful (because many of the ${18\choose 4}+{18\choose 3}+{18\choose 2}+{18\choose 1}=4047$ combinations produce the same total $R$), and with $\frac{112}{17}\approx 6.6 \ll 12=\frac{300\,\Omega}{25\,\Omega}$, we see that we managed to cover merely have the range we want.
One definitely needs better picks for the $a_k$ in order to be able to make use of more of the possible combinations. One has to get somewhat closer to the powers-of-two concept ... I suppose much of this process involves a good deal of trial and error.
