Analog Swap Gate: Short Version
Mar. 11th, 2019 07:55 pmOh hey, someone let me know I ought to consider describing what I made in https://mdude.dreamwidth.org/1762.html in a way that actually makes sense instead being mostly incoherent rambling about my thought process.
So, the the main idea of how the function acts as analog version of the Fredkin/controlled swap gate: It takes some sequence of N values, and swaps them around by X places. If X is a whole number, the values just get moved that many places over, wrapping around. So in such cases, the output for function(X) can equal to Input[N+X]. But when it's not, we need to have some way of producing outputs that lie between the outputs for Input[ceiling(X)] and Input[floor(X)].
So, easiest way to do that would be to make the output for function(X) equal:
(Input[floor(X)]*(1-(fractional part of X)))+(Input[ceiling(x)*(fractional part of X))
The only reason I was relying so much on max and min was because I know those are easy to implement in mechanical analog computers, by just letting either input push or pull the output so that the output pushes/pulls as much as whichever input is doing that the most. While I'm at it, here's a version that ditches the modulo function at the cost of only being accurate over a limited range of input: https://www.desmos.com/calculator/or2gurny0c
Edit: I should probably point out that I later realized I'm still doing this wrong, so I'll need to keep working on it. For some reason it just seems slightly too hard to keep all the parts I'm working with in my head at once while translating it from geometry to code. I think it might work if I take some earlier ideas I was trying and go "something something Viviani's theorem" at it, but that'll wait until I feel like getting back to it.
So, the the main idea of how the function acts as analog version of the Fredkin/controlled swap gate: It takes some sequence of N values, and swaps them around by X places. If X is a whole number, the values just get moved that many places over, wrapping around. So in such cases, the output for function(X) can equal to Input[N+X]. But when it's not, we need to have some way of producing outputs that lie between the outputs for Input[ceiling(X)] and Input[floor(X)].
So, easiest way to do that would be to make the output for function(X) equal:
(Input[floor(X)]*(1-(fractional part of X)))+(Input[ceiling(x)*(fractional part of X))
The only reason I was relying so much on max and min was because I know those are easy to implement in mechanical analog computers, by just letting either input push or pull the output so that the output pushes/pulls as much as whichever input is doing that the most. While I'm at it, here's a version that ditches the modulo function at the cost of only being accurate over a limited range of input: https://www.desmos.com/calculator/or2gurny0c
Edit: I should probably point out that I later realized I'm still doing this wrong, so I'll need to keep working on it. For some reason it just seems slightly too hard to keep all the parts I'm working with in my head at once while translating it from geometry to code. I think it might work if I take some earlier ideas I was trying and go "something something Viviani's theorem" at it, but that'll wait until I feel like getting back to it.