# Thread: Ordering resisters for the most stable circuit

1. this is for your values multiplied by 10000 because my program is set to work with integer values. shouldn't make a differance. there are 9 combinations with the same result.

2. Hmm. Interesting. What is the value of the function on those permutations?

3. Originally Posted by Ackbeet
Hmm. Interesting. What is the value of the function on those permutations?
it's 0,000144

4. Hmm. Well, I've written my own little program in Mathematica to find the minimizing permutation. The winner I found was your sixth permutation. The function's value at that permutation is smaller, by a very small amount, than the function's value at the first permutation. It also beats out the second permutation, by a very little bit. I wonder if your integer arithmetic is hiding some numerical errors in computation such as round-off error. Mathematica has arbitrary-precision arithmetic, so I'm thinking that you might want to increase the precision of your computations.

The sixth permutation that you found does do this alternating about the mean, to some extent. The first two values are actually both higher than the mean; after that, they alternate. However, I can't see any discernible pattern in the order of the numbers above or below the mean.

I've attached my Mathematica code, and a few plots, for you to see.

5. yeah, you're wright, looks like i have a bug somewhere. however, there are still 4 permutations with the same result. there must be a pattern but it looks like it's really complicated...

i'm giving up on this one. this is for a collage project, so i'll just tell my mentor that i can't do it...

anyway, it's getting late here in croatia, tnx for your efforts...

6. Interesting thread. The problem reminds me of this one on Project Euler (I hide the link because the site is pseudo-competitive and this post could be considered a hint at how to solve it):

although the resemblance might only be superficial. The fastest solver of that problem used a random-restart hill climbing algorithm, which might be usable here. Of course a closed-form solution if one exists would be nice. I'll be looking into this as time allows and hopefully can report back before too many hours pass (and hopefully with something to contribute).

$\displaystyle f(\mathbf{R})=\sum_{k=1}^{49}\left(\frac{\sum_{j=1 }^{k}R_{j}}{\sum_{n=1}^{50}R_{n}}-\frac{k}{50}\right)^{\!\!2}.$

We can multiply this function by a positive constant, and not change the minimums. We wish to multiply by

$\displaystyle\left(\sum_{n=1}^{50}R_{n}\right)^{\! \!2}.$ Define $\displaystyle\bar{R}=\frac{1}{50}\sum_{n=1}^{50}R_ {n}$ as the mean. Then

$\displaystyle g(\mathbf{R}):=\left(\sum_{n=1}^{50}R_{n}\right)^{ \!\!2}f(\mathbf{R})=\sum_{k=1}^{49}\left(\sum_{j=1 }^{k}R_{j}-k\bar{R}\right)^{\!\!2}=\sum_{k=1}^{49}\left(\sum_ {j=1}^{k}(R_{j}-\bar{R})\right)^{\!\!2}.$

Define $\Delta_{j}:=R_{j}-\bar{R}.$ Then we have to minimize the function

$\displaystyle g(\mathbf{R})=\sum_{k=1}^{49}\left(\sum_{j=1}^{k}\ Delta_{j}\right)^{\!\!2}.$

Note that the sum of the $\Delta_{j}$'s from 1 to 50 will give exactly zero. This means that the above can be rewritten as:

$\displaystyle g(\mathbf{R})=\sum_{k=1}^{25}\left(\sum_{j=1}^{k}\ Delta_{j}\right)^{\!\!2}+\sum_{k=1}^{24}\left(\sum _{j=1}^{k}\Delta_{51-j}\right)^{\!\!2}.$

Examination of this last expression will show that if 1 is exchanged with 50, 2 with 49, etc., that the formula will remain unchanged. (This corresponds to a complete mirror image switch.)

Writing out the equation longhand will reveal a strategy for selection of placement of the resistors:

$g(\mathbf{R})=(\Delta_{1})^{2}+(\Delta_{1}+\Delta_ {2})^{2}+\dots+(\Delta_{1}+\dots+\Delta_{25})^{2}+ (\Delta_{50})^{2}+(\Delta_{50}+\Delta_{49})^{2}+\d ots+(\Delta_{50}+\dots+\Delta_{27})^{2}.$

Note that the delta for 26 is missing. As one can see, the lower numbers and the higher numbers both should have small deltas, because they appear the most frequently. Also, it would seem that alternate signs of the deltas would be good in cancelling out at least some of the quantities in the parentheses. Therefore, it would seem to be a good strategy to go from ends to middle using smaller alternating deltas until the resistors in the center of the array have the largest departure from the mean.

Cheers.

8. There. I think my edits have settled down a bit now. Sorry about all that.

9. sorry, i don't get it

can you explain how to sort them again?

10. Based on the analysis in post # 22, you want to start at both endpoints and work your way to the center. The endpoints themselves need to be the two resistors that are closest to the mean. As you work your way in, you want to alternate values that are above and below the mean. (This corresponds to delta values that are positive and negative.) Also, you will generally want to pick more and more oscillatory values - that is, ones that are farther and farther away from the mean. If I were to plot the envelope of the resistances, it would look something like this. Think of the x-axis here as the mean of the resistance values.

Make sense? That is generally what the solutions we've found look like, with some small possible exceptions. The point is, you can find a permutation that gets your function quite small, even if it isn't the global minimum.

11. thanks, got it. i'll present this solution to my mentor, and see if he'd be satisfied with it.

anyway, i'll post his solution here after he tells me.

12. Yeah. I'd be interested to see what he got.

Page 2 of 2 First 12