I try to type “geocentric” and discover that I have typed “egocentric”; is Autocorrect making a sort of cosmic joke? I want to address my tweeps (a made-up word, admittedly, but that’s what people do). No: I get “twerps.” Some pairings seem far apart in the lexicographical space. “Cuticles” becomes “citified.” “Catalogues” turns to “fatalities” and “Iditarod” to “radiator.” What is the logic?

The logic is hard to discern, and consistency is for hobgoblins. Sometimes “Capistrano” may become “vapid tramp”; next time maybe “campus tramp.” Kathryn Schulz, the author of “Being Wrong,” tweets in verse:

Super fans

sweaty fans

sweaty dreams

sweet dreams.

Autocorrect train wreck over here.

Actually, an assortment of competing algorithms is at work. Autocorrect is not a single entity but a hodgepodge, from different vendors, chief among them Apple, Google and Microsoft. All their algorithms start with the low-hanging fruit. They know what to do when you type “hte.” After that, their goals vary, and so do their capabilities. On most devices and applications, Autocorrect can be switched off, for those who prefer to go naked. It’s not always easy to find the switch.On mobile phones, where our elephant thumbs tramp across tiny keypads, the idea is to free us from backtracking and drudgery. The iPhone’s Autocorrect function loves to insert apostrophes. You can rely on it: type “dont” and get “don’t.” Type “cant” and get “can’t” — but is that what you wanted? Autocorrect is just playing the odds. Even “ill” turns to “I’ll” and “id” to “I’d” (sorry, Dr. Freud).

When Autocorrect can reach out from the local device or computer to the cloud, the algorithms get much, much smarter. I consulted Mark Paskin, a longtime software engineer on Google’s search team. Where a mobile phone can check typing against a modest dictionary of words and corrections, Google uses no dictionary at all.

“A dictionary can be more of a liability than you might expect,” Mr. Paskin says. “Dictionaries have a lot of trouble keeping up with the real world, right?” Instead Google has access to a decent subset of all the words people type — “a constantly evolving list of words and phrases,” he says; “the parlance of our times.”

If you type “kofee” into a search box, Google would like to save a few milliseconds by guessing whether you’ve misspelled the caffeinated beverage or the former United Nations secretary-general. It uses a probabilistic algorithm with roots in work done at AT&T Bell Laboratories in the early 1990s. The probabilities are based on a “noisy channel” model, a fundamental concept of information theory. The model envisions a message source — an idealized user with clear intentions — passing through a noisy channel that introduces typos by omitting letters, reversing letters or inserting letters.

“We’re trying to find the most likely intended word, given the word that we see,” Mr. Paskin says. “Coffee” is a fairly common word, so with the vast corpus of text the algorithm can assign it a far higher probability than “Kofi.” On the other hand, the data show that spelling “coffee” with a K is a relatively low-probability error. The algorithm combines these probabilities. It also learns from experience and gathers further clues from the context.