The Mathematics of Sex Toys…

…in which we learn just how big a stinker Franklin is.

Okay. So. Long story behind it, but I have on my balcony a large Tupperware container filled with sex toys. Vibrating eggs, to be exact. At one point, I had about 250 of them. I keep giving them away to people (in fact, I’ve been known to refuse to let guests leave the house unless they take one with them), and now I’m down to about 20.

Which is still a lot of vibrators, just for the record.

Some time ago, I read online about a guy who’d taken a vibrator and connected it to a Basic Stamp–think “little tiny computer on a single chip”–that he had programmed to switch the vibrator on and off at random intervals. The idea, you see, was to play with a quirk of human physiology.

Quick dissertation about human anatomy: The way our sensory nerves work, if you present the same stimulus to the same part of the body without varying it, eventually, your sensory nerves will quit responding to it. Take a toothpick and put it on your palm; you’ll be able to feel it. Leave it there long enough without moving it or your hand and eventually you’ll stop feeling it.

The sexual organs are no different than any other organ in this regard. Flip side of the same coin, if you vary the stimulation presented to a sensory nerve, it’ll keep informing your brain “Hey! The stimulus has changed!” and you won’t be able to ignore it.

Now, this guy had programmed his Basic Stamp to switch a vibrator on and off at random, but fairly short, intervals. The idea was to create an infuriating sex toy–a sex toy that, when you wear it, you absolutely can not ignore. Because the stimulation is random, you don’t become acclimatized to it–and if it switches on and off quickly enough, it also doesn’t stay on long enough to get you off. So basically, he created a sex toy that will make sure you always pay attention to it but won’t make you come.

If you draw a graph of the way the sex toyy switches on and off, you get something like this:

There’s vibration, then no vibration, then vibration, then no vibration, for randomly varying periods of time:
bzzzzz….bzz………bzzzzzzzzzz..bzzz……bzzzzz… you get the idea.

Now, that’s good and all, but the vibrators I have are equipped with a little thumbwheel speed control. When one of my partners is foolish enough to put me in charge of the control pack for one of these things, I like to run my thumb up and down the speed wheel thingy, making the vibrator go FASTER and slower and FASTER and slower.

So I started thinking, why not program a computer to run the vibrator for random times at random speeds? From there, I started thinking about how to actually code for that.

Now, it seemed to me, as I was thinking about it on the bus on my way down to Tallahassee, that the most obvious way to go about this is to take a bunch of sine waves and put them together. One can construct a waveform of nearly arbitrary complexity by merging together sine waves of different frequencies, via a mathematical bit of wizardry called a fast Fourier transform.

For example, suppose we have something like this:

The sum of the red sine wave and the blue wave (which is itself a composite of three sine waves) looks a bit like this:

Now, feed that into a vibrator and it should keep a person infuriatingly close to orgasm without letting her get off or ignore the vibrator just about indefinitely.

The thing is, you want a wave that looks random. Any composite of a finite number of sine waves will be periodic (that is, at some point it will start to repeat), so you want something that looks random and also has a long periodicity. I was thinking about how to choose a relatively small number of sine waves–say, sixteen or so–in such a way as to maximize the periodicity and also maximize the apparent randomness when combining them with an FFT. Make the ratios of their periods prime? Stuff like that?

I was hampered somewhat by the fact that I also know fuck-all about how to actually do an FFT, too, which means that basically I know squat about the best way to go about choosing the sine waves.

Shelly’s dating a physicist, though. And he took one look at the problem and observed that a fast Fourier transform isn’t really necessary; it’s using an anti-aircraft cannon on a mosquito.

His idea, which is brilliant, is this:

Take a sine wave whose period is the interval of time over which you don’t want the pattern of the vibrator to repeat. Add it to itself with a period of double that, and add it to itself with a period of three times that, and again with a period of five times that. (Geeky readers will already see where this is going: 1, 1, 2, 3, 5… is the Fibonacci sequence.)

You don’t need very many sine waves to get a right royal (and therefore random-looking) mess.

So, in theory, it will be remarkably simple to make The World’s Most Annoying Sex Toy(tm). A little bit of simple programming and some kind of variable interface and the result should be a vibrator that will drive the wearer right straight up the fucking wall for hours, with no relief in sight.

I am such a stinker.

Fortunately, the world is saved by the mere fact that I don’t at the moment have time to actually build one of these. Yet.