Summary:

In which Tony is a codebreaker, and Loki interrupts his perfected routine by having the gall to be a Nazi defector.

Notes:

Warning: contains excess math, some equations, gratuitous descriptions of the Enigma code machine, and rather a few glancing mentions of Alan Turing and his body of work. If there are inaccuracies, it's because I majored in film, like a genius with things like forethought and future planning, but hopefully a math person would enjoy this as much or more than one of us regular mortals.

Work Text:

Let’s think of the Enigma as an old pocket watch. A really old kind, the sort that ticks around all the seconds, and then -- ka-chunk! -- the minute hand goes one. So the seconds tick all around again, and there goes another minute, and so on and so forth until finally one hour ticks forward. This is essentially how the Enigma operates.

...let’s back up a little here.

It all begins with our hero, Tony Stark, the most stylishly dashing mathematician this side of the Atlantic. He wears nice suits, and ignores the nasty looks that many British officers and/or less dashing, poorer civilians give him during the course of a typical work day.

Tony Stark is holding down this fort. He is the master of the castle. He has whipped all the serfs into submission, nailed more than three of the ladies in service to his whims, and cracked numerous confidential German communications. Sadly, the Enigma code machine was not cracked by Tony himself; that was done by mathematicians with less social skills, and, over the course of the decoding, progressively less sanity. Tony, all things considered, is pretty much okay with this tradeoff.

So here is Tony, in his sanctuary, conducting his orchestra of young ladies banging on typewriters and young men scurrying back and forth with little slips of code intercepts. And this is when a certain someone comes in and jams up all the works, collapses the symphony into a chaotic jam of dissonant and arythmic notes.

This is when Loki enters the equation. Loki, variable L, making what was a function of Tony’s command of the room, ie:

F(command) = D - SA

In which D is number of interesting dispatches per day, otherwise known as demand for Tony’s particular kind of services, and S is the number of days since Tony has had sex and A the number of distractingly attractive personages in close proximity.

This equation has been transformed into:

F(command) = L(D - SA)

In which L, or the presence of Loki, introduces a variable that can disrupt everything, up to and including Tony’s current level of sexual desire and focus on those around him.

This, of course, does not happen immediately.

First, Loki waltzes in there like he owns the place, strange behavior considering both Tony’s alpha male status and the handcuffs around his wrists. Also his escort of three MPs, together comprising approximately seven times Loki’s total body weight and probably something more like 20-30x his total muscle mass. And yet.

He smiles like a sphinx and then someone tells Tony that Loki is an escapee from Germany’s cryptological program and literally everything in the universe goes black and white except for Loki. This is his dread enemy. This is the fellow that he’s been matching wits with for fucking ever, and Tony is basically sexually aroused by the amount that the room’s average IQ has risen.

“So let’s talk,” he says, once he has cornered Loki in a private room. The other man is restrained, literally tied to a chair, and since Tony has used his personality and incidental authority to do this to important people since he was out of the cradle, he quite enjoys the circumstance. (He also has the troubling desire to yank Loki’s hair and bite his neck, but he hears that homosexuality isn’t really approved in places like Berlin, and so he refrains from this.)

“About what?” asks Loki, innocently.

“Enigma.”

Which brings us full circle back to our original talk. Enigma is a pocket watch in that it uses rotating encryptions on each individual letter of a message. Ordinarily, when you encrypt a message, you use substitution: for instance, all Ts might become Vs, all Hs might become Is, all Es might become Fs, rendering the word ‘THE’ something more like ‘VIF’ and hopefully preventing your enemy from reading your communications. Unfortunately for you, that kind of encryption is laughably easy to beat. Tony could do it while he was literally asleep.

Thus: Enigma. Each setting of three wheels yields one encryption alphabet. You type one letter, and then the machine rotates to a new system, and your next letter is encoded that way. The three wheels allow for 26 x 26 x 26 possibilities, also known as 26 ^ 3, or 17576 possible encryption systems.

This is, unfortunately for the Allies, only the first model of Enigma. Later models have added odds and ends, all of which increase the number of cryptological possibilities ad nauseum. Eventually, the Allies reverse engineered and stole enough Enigmas that they basically cracked the code; all they had to do was figure out the starting settings each day, which means that the roomful of girls with typwriters brute-force try all possible combinations, and hopefully get results before the end of the day. That means that all dispatches from that day are suddenly transformed from gibberish to things like SUPPLIESLOWREQUESTORDERS or RENDEZVOUSWITHMILCHCOWATCOORDINATES or something similar.

There has been a new innovation recently, which means that the girls with typewriters have not been so successful, and Tony is frequently at a blackboard with a nervous photographer drifting behind him, keen not to miss any of his strokes of genius. Unfortunately, he’s somewhat short on strokes of genius, given that the value of S (days without sex) has been skyrocketing lately. Who has time for orgasms when he has to work?

“Don’t ask me ‘what about Enigma’,” Tony says, with the wave of his hand. “I know you know there’s something new they’ve added lately, and it’s flummoxed all the nice ladies in there.”

Loki leans forward, and Tony’s breath catches. His eyes are on the lines of Loki’s Adam’s apple, and the urge to bite is worse than ever.

“Have you ever thought,” says Loki, “about reflectors?”

Tony Stark’s brain does an immediate ABOUT-FACE, parade-ground style, and has what’s probably the equivalent of an orgasm in his pants, only somewhere in his cerebral cortex.

“Fuck,” he says.

Loki smiles like a cat.

Tony fumbles for a cigarette. “Would you like one?” he asks, before he remembers that Loki’s hands are tied. His brain sees fit to illustrate the lovely mental image of Tony leaning forward, breathing out over Loki’s lips as Loki breathes in, sharing smoke. Nope. Nope. Shouldn’t let his brain go there.

Sometimes it seems that Tony doesn’t actually have much control of the machine stuck up behind his eyeballs.

“Too bad,” says Tony, and lights up. There; he’s asserted his power, time for Loki to bare his neck and surrender.

Bare neck.

God damn it! Couldn’t Tony’s brain have gone with something like groveling? Going down on his knees?

Fuck.

Reflection. If a reflector was put in an Enigma, the code would be run through the three wheels and then back again through them, producing exponentially more codes. Something along the lines of... 308,915,776, unless Tony misses his mark. Which he doesn’t.

Well, those girls are going to have to start banging away a lot faster on those typewriters. Either that or they should find some new ones, rustled up from some motor pool or pencil factory in the ass of Nether Townsfield, Manchester.

“We could share.”

And Loki’s voice brings Tony right out of the fictional Nether Townsfield and into the present.

An innocent look in Loki’s eyes.

He probably just means for Tony to hold the cigarette to his lips.

“No,” says Tony, churlish, and smokes the rest of it himself, absorbed at a blackboard and leaving Loki behind in that room (though ever-present in Tony’s visual cortex).

Later, he lets himself into Loki’s cell, and gives the man a cigarette and they pore together over sheets of scribbles in Tony’s handwriting.

“It might be better represented like this,” and Loki takes the pen and makes a few key alterations. Tony is in love. He is in love, and when Loki grimaces at the cigarette and mentions his preferred brands, Tony is ready to propose marriage. The aforementioned German dislike for aforementioned homo is still holding him back, but when Loki smiles at him cleverly, Tony nearly kisses the snarky arrogant asshat into oblivion. Maybe if the variable S is reduced for Loki, he will experience a similar increase in intelligence. Tony’s knees feel weak at the thought, intellectually and sexually.

Not like this is unprecedented. The government is happy to look the other way while Tony sticks his penis into things, because Tony’s brain is currently a valuable government resource, and certain machines must be kept well-oiled. Alan Turing is gay, at least, and the room full of vacuum tubes and stops and gears that (when in full operation) shakes the shit out of the East Wing of the mansion attests to Turing’s influence on modern cryptanalysis.

And Tony’s.

Cause Tony built the damn thing.

Tony has a breakthrough on Enigma, gets some better cigarettes to his sly little German prisoner with the impeccably accented English, and meanwhile the value of S keeps ticking right on upwards. (Though at least the value of A, when Loki is not present, has decreased significantly. He’s not sure why this is; maybe there was a spate of transfers, to keep all the pretty girls away from him. But he disregards that hypothesis when he realizes that one particular woman, apparently named Anne and possibly the origin of the letter A for that particular variable, has been his assistant for the past four months and that a week ago he really wanted to bang her. This is another effect of L, the warping variable of Loki’s presence.)

Turing is probably at this moment getting more sex than Tony.

This is an intolerable thought, given that Turing goes around in bathrobes and is a complete ditz by any normal person’s measure.

And yet, Tony’s productivity increases.

Goddamnit, L. God damn it.

Or perhaps L contains a whole different equation. Loki has moods, which alternately give Tony a hard-on and make him pissed off. Loki sulks like a child, has leaps of intuition like a god of mathematics, and can change the timbre of a room just by walking into it. He seems to mean different things every time he speaks, such that the single word “Fine” has approximately seven thousand different meanings dependent on the internal circumstances of Loki’s emotional state (which in turn depends on several different sets of hormones and chemicals, imbibed through the blood and fizzing into neurological signals, their own little encryption machine).

At first, Tony thinks of Loki as a kind of differential function, incorporating rate of progress in codes, number of excellent cigarettes, quality of recently imbibed brandy, and the relative disrespect of certain MPs for Loki’s intelligence and bloodline. Then Tony revises this to a rather more complicated equation, a sum-function of dozens of interplaying factors, including sin-waves of circadian rhythm, the weekly peaks and valleys of Nazi broadcasts, etcetera.

Finally, he considers him through the lens of Enigma, in which every word of Loki’s simply rotates through a set cryptological system, defined by exponential powers. He must rotate through a set of moods, a set of intellectual conditions, and a set of external circumstances, each one creating a different encryption set shifting the meaning of his words along defined axes.

“What are you doing?” asks Loki, one night, after Tony has spent quite a while musing over this on a blackboard. No photographers, this time. Much as Tony loves his dick, he doesn’t want top brass in the British command analyzing his efforts to get laid.

“Um,” says Tony, and literally nothing occurs to him. How long has Loki even been standing there? The man is quieter than a cat. They need to get him a bell.

“Does that say -- function of penis?”

“Um.”

Why does he not have an excuse for this? Come to think of it, why did he write out the word ‘PENIS’ instead of using a variable?

Oh, right, because P, E, N, I and S are all already in use.

Tony decides on a tried and often unsuccessful tactic: he tells the truth. “It’s an analysis of your possibility of ending up in bed with me, given certain interpretations of your words,” he says, shifting directly into Math Mode. “At the moment, I’m working off a set of assumptions of a completely broken abnormal human emotional scale, and a fair amount of intentional obfuscation, though perhaps not for the subject matter at hand. If one asserts that each human brain is an infinitely complex Turing machine, subject to certain infinitely complex inputs, such states can be approximated by the value of E, as t approaches infinity...”

Loki nods, eyes narrowed and on the board, as though he is actually absorbing this through the lens of some sort of intellectual exercise.

“You’re missing a number of pertinent factors,” he tells Tony.

“Such as...?”

And Loki steps up next to him. He eliminates a few variables, including pet variables that Tony actually quite liked. Stripping down to a tank top and suspenders must increase the probability of sexual intercourse in the near future -- that always works.

Apparently not.

Loki makes several alterations, creating equations from scratch in longhand. Tony stares. Eventually, Loki sets down the chalk and leaves, and Tony is left bewildered at the tangle that his calculations have become.

So he gets to work.

Getting through the minor mountain of data that Loki has given him isn’t easy, but before dawn he has a solution to the equation.

And the solution is that it is always fucking positive.

He storms into Loki’s cell all ready to say you could have just said yes, but then he stops himself, and considers, and realizes that this is his favorite foreplay ever.

“I need your help with the Turing machine,” he says, instead, as the machine is chewing away on the day’s intercepts. Loki follows, willingly, curious and hesitant in a way that Tony recognizes now.

And so this becomes not the story of how Tony decodes German command’s communication traffic, nor the story of how he saves the lives of thousands of soldiers and civilians and averts a world catastrophe, the march of facism, Nazi bastards, etcetera. It, instead, becomes the story of how he bangs Loki against a fully functional Turing machine, thereby cementing in his mind the connection between math and sex.

“You’re a bastard,” he breathes, and sinks his teeth into Loki’s neck. Loki yowls -- like a cat, again -- and arches up and grinds his erection against Tony’s, and Tony rips his shirt trying to get it off too quickly, and Loki mewls when Tony takes him in hand. He is so hard and desperate, and he claws at Tony’s back and bites his ear and goes wordless in about two strokes of Tony’s hand.

Like he could help it.

Shoves Loki back against the vibrating machine, the ka-chunks of the machinery muffling all of Loki’s sounds for any listeners, and goes to his knees. Loki’s fingers tangle in his hair, and then Tony has Loki’s cock down his throat. Tongue makes circles around the head, long lines down the shaft, and Loki wrings out Tony’s vaguely sweaty hair and tries not to thrust. Completely useless. Tony pulls away, and draws his hand up and down Loki’s shaft, thinking about machine lubricant and how he’s about to turn Loki around and ram him like a suicidal submarine, when Loki bucks and comes in a semi-parabolic arc, his belly streaked with come.

He is wrecked.

Tony takes a moment to observe, fascinated at the sight of his immaculate colleague with mussed hair, half-undone clothing, and dirtied with come.

Loki senses his gaze, tenses.

“You are the hottest thing I have ever seen,” says Tony, simply and factually.

Loki does not believe him, he can tell, but Tony doesn’t give even a single shit at this point. Wipes up Loki’s come from his belly and feeds it to him, Loki’s smooth tongue licking away every drop. Loki’s eyes avert. He can be made into the whore, but he is unwilling to watch himself, it seems.

“Turn around.”

Loki is pliant as soft clay, willing, bracing his palms against the Turing machine. And Tony comes back with oil and spreads it down Loki’s cleft, and presses fingers up inside him.

Loki jumps with the suddenness of Tony’s penetration, and his legs widen. His breath is short. So Tony sinks the fingers deeper and curls them and drags. His arm is already around Loki’s waist, so he’s prepared when Loki’s legs buckle and a feeble last shiver of come drools from his dick and Loki makes a noise like he’s been run over by a wayward lady from an unfortunately undertrained motor pool.

“You want something?” asks Tony, surprised his voice is so clever, so teasing, not completely broken with desire.

“Tony,” Loki breathes, “Tony,” his voice a whine.

“Ask me. Ask, and ye shall receive.” Probably the wrong time to bring up religion, but he’s distracted again quickly, his fingers pushing and pulling inside Loki.

Tony drags his fingers, and Loki murmurs something long and complicated and angry-sounding in German. Not particularly surprising; all German is angry-sounding.

“Okay,” says Tony. “Then I just want you to be. Because I crave you all the time. C’mon. C’mon, Loki, ask me to fuck you.”

Loki lets out a cry, and his hand tightens to a fist braced against the vibrations of the machine.

“Don’t give me up,” he says, fiercely. “Don’t you toss me away, once you have what I want.”

“Baby,” says Tony, “we will be better together -- mathematically and sexually -- then we ever will be apart.”

Loki’s cheeks are wet -- tears? -- and he nods. And Tony sinks inside him, reaching immediate Nirvana, fuck the Buddhists cause they don’t know shit. He fucks Loki’s slippery and tight body, and slides a hand onto his pelvis, and thrusts the way Loki seems to like. All things considered, it’s a fantastic lay. It’s very complicated, somewhat awkward due to relative heights of certain organs, and made a bit awkward by the constantly clanking machine, and yet it’s still the best sex Tony has ever had.

He thrusts faster and Loki’s muscles go spasm-tight around him, and he comes, suddenly and explosively, pumping at least a six spurts of semen in the longest orgasm he has ever had in his entire life.

They both collapse to the floor, and only then does he realize that Loki’s still hard.

So he takes Loki in hand, and murmurs something about zeta functions into Loki’s ear, and curls close. Loki’s hand on his waist, Loki’s face buried in his throat, feeling more than hearing the soft moans.

Eventually Loki jerks and comes on Tony’s palm, and this time Tony licks it up.

They lay together on the somewhat prickly carpet, both of them basking in nature’s best high, sharing sweat and smelling of sex.

“So,” says Tony, ascertaining that he has a narrow window to exchange important information, “why did you leave Germany?”

“My brother asked me to,” says Loki.

Yep. The equations were right. The reason Loki acts the way he does isn’t the suppression of emotion; it’s the excess of it. Tony has an active volcano on his hands, and he has just built a village of Basically In Love at the root of it without any plans for the constant rain of ash.

But that’s okay.

“And then he died,” says Loki, softer.

“We’ll get the bastards,” is all Tony can say.

Loki’s eyes flick to Tony, and in them Tony finds a hunger for revenge, a passion. He shifts forward and kisses Loki, deep and slick, and hopes that it’s just passion, and not utter madness. Because Tony will never recover from the latter. It is a non-computable number, like i, and it will break his personal Turing machine.

He has hope, though. Because when he says, “I think I’m in love with you,” Loki’s eyes twitch over to his, and there’s raw wanting there.