In mad science, "malfunction" does not mean fried circuits and broken equipment (sometimes) but often it turns out that a malfunction has created something wondrous. Usually there is no explanation to how a "malfunction" can make modifications that seem intelligent, and no mention to where it gets the parts for a technology that is entirely different from the intended. For example, a toaster can easily become a Time Machine through Miraculous Malfunction.
This can be used as an Achievement in Ignorance for the Bungling Inventor (most of whose works are created in this manner). It can also serve as an alternative explanation to why there are No Plans, No Prototype, No Backup: it's not that the technology was lost but rather, the individual sample was a result of a one-time event that cannot be recreated. Particularly good researchers might then learn to reverse engineer this piece to create more, but usually they will be just as dumbfounded about how it works as everyone else even if they themselves have created it. Surpringly such technology will usually be surprisingly stable and not at all prone to Phlebotinum Breakdown, unless the plot suddenly calls for it. Note, that because of the poorly understood nature of such technology it can unexpectedly become dangerous.
(While there are real-world examples of inventors accidentally stumbling upon new things while researching something else, the fictional inventor will never need to bother with follow-up research: they will get the new tech from it ready-made.)
- In Ghost in the Shell: Stand Alone Complex, the tachikomas become sapient due to an imperfection on one of their circuit boards caused by Batou giving his "personal" tachikoma natural oil which corroded part of it. This tachikoma induced sapience in the others when their AIs were synchronized. They did try that with the fujikomas, yet that did not work. They never quite figured the reason out.
- The material that became Captain America's circular shield was created accidentally during an experiment to merge vibranium and an iron alloy. An unknown catalyst entered the mixture while the scientist overseeing it was asleep.
- When the Metal Men were introduced in The Silver Age of Comic Books, it was stated that they came out fully sentient because of freak solar flare activity or some such. Doc Magnus was never able to recreate the phenomenon to make more sentient robots.
- In Cloudy with a Chance of Meatballs, Flint hooks up his machine to the town's power station to give it enough electricity to create food from water. Instead, the extra power makes the machine take off like a rocket and start orbiting in the lower stratosphere, creating food that comes down in showers using moisture from the clouds. Later, being overworked makes the machine start overmutating the food, and it eventually gains sentience.
- In Electric Dreams, the hero Miles spills champagne on his PC while it is plugged into his company's megacomputer, causing his computer (of course!) to come to life.
- Honey, I Shrunk the Kids: A stray baseball landing on the shrinking machine is what actually makes it work. Though Wayne Szalinski is able to figure out why the baseball made the machine functional, and replicate the results.
- In Inspector Gadget 2, G2 swaps control chips with Gadget. Because of this, she gets some of his "glitches," which come with some fairly absurd side-effects. For example, her hat-mounted "boomerang gun" turns into a cartoon mallet, and her "net guns" turn into flying drones armed with rolls of wrapping paper. Just... don't ask.
- Short Circuit: A robot is struck by lightning, which causes a "malfunction" that gives it sentience.
- Dirk Gently's Holistic Detective Agency: Professor Chronotis' time machine seems to be in a strange relationship with the telephone system. After he has his phone repaired, the time machine is inoperable too.
- In the Discworld books, this is the best-case scenario of allowing Bloody Stupid Johnson to build anything. Case in point: his "improved manicure device" is best used for peeling potatoes.
- In Murray Leinster's short story "A Logic Named Joe", a flaw in the wiring of the titular Logic (essential search engine terminals) somehow gives it the compulsion and ability to find a perfect, easy, workable answer to any query asked of him, even if it involves breaking the law or violating the laws of physics. Such queries include how to easily build a perfect counterfeiting machine, commit the perfect murder, pull off the perfect bank robbery, mix a fast, effective hangover cure that eliminates all traces of having been drunk, build a perpetual motion machine, and (in the case of The Protagonist's Stalker with a Crush ex-girlfriend) find the exact location of someone who doesn't want you to find them. Oh, and it also makes Joe override the entire network, so any query asked of any Logic automatically goes to Joe instead.
- In Memoirs of an Invisible Man, it's implied that someone spilling a cup of coffee on a control panel resulted in uncontrolled but permanent invisibility, in a lab whose research had nothing to do with invisibility.
- The Robot Series stories have several examples of unusual robots coming into being via a Miraculous Malfunction:
- "Liar! (1941)": Herbie's ability to read minds is the result of a production accident. Nobody could figure out how it happened; Herbie knew but couldn't tell because telling would hurt the ego of human engineers to know that a robot knew something they didn't.
- "Robot AL-76 Goes Astray" has the robot of the title managing to create a mountain-destroying mining laser that runs on two D-batteries after being exposed to unexpected stimuli when lost on Earth.
- "Light Verse": One of Mrs. Lardner's robots is so old that it can barely function. She insists that he's able to do simple tasks well enough, hiding the fact that whatever malfunction that has made him terrible at most household tasks has also made him the greatest light-sculptor on Earth. This hidden talent is only revealed after a US Robotics man repairs him.
- It's noted in "The Bicentennial Man" that Andrew was the result of a production error. US Robots tightens their controls as a result to prevent it happening again, since expressive robots who want to be human are bad for business.
- In the Lije Bailey sub-series, the psychic robot Giskard is created this way.
- In Star Wars: Kenobi, Annileen Calwell's husband Dannar fiddled with a vaporator at their store once, and it began producing water so incredibly sweet and delicious that the farmers are afraid to ever touch the settings again, but that means they have trouble replicating the results. Their friend and business partner Orrin Gault has come close and is attempting to ramp up production (he considers it an exquisite irony that the desert planet might export water), but nothing can match Old Number One. Then the Tuskens smash the control panel to bits during their raid on the Claim, destroying the formula forever. Orrin's copycat vaporators somehow stop producing the sweetwater themselves after that, worsening his cashflow problem.
- The Strange Case of Dr. Jekyll and Mr. Hyde: As Jekyll reasons in his final letter, the only reason that his potion worked (sort of) was because the batch of salt he used had been contaminated with an unknown substance. The potion has a limited supply because when he ordered more salt, the other batches were pure, and he couldn't re-create his potion with them.
- A darker example occurs in one of the vignettes in Arthur Machen's The Three Impostors (specifically, The Novel of the White Powder) when a character's antidepressant prescription is accidentally filled from an expired batch of the drug that (thanks to unknown environmental conditions) has randomly degraded to the point of being chemically identical to Vinum Sabbati, the wine of the witch's sabbath (which isn't wine so much as a sort of horrifying eldritch version of ecstasy that temporarily converts the taker into a Humanoid Abomination). Since the prescribed dosage of antidepressant is several orders of magnitude larger (and much more frequent) than the amount of ''Vinum Sabbati'' offered at a Witch's Sabbath, Body Horror ensues, and the unfortunate victim is eventually reduced to a permanent mucous stain (but not actually killed). However, the miraculousness can be explained by the fact that the vignettes in story are all lies (which doesn't necessarily mean Vinum Sabbati doesn't actually work that way, and the liar in question would definitely know if it did).
- In Mission Top Secret, the incident that allowed the Master Computer to hijack an old communication satellite and establish contact with kids all over the world was caused by a jar of candy being spilled onto a keyboard. However it is reproducible because the program was still in the computer's memory.
- In the Red Dwarf episode "Lemons", the crew tries to assemble a "rejuvenation shower" from flat pack. They don't use all the parts, and the finished shower looks decidedly wonky. Rather than simply not working, the shower — which is simply meant to rejuvenate the bather — transports them through time and space to Earth in the year 23 AD.
- Genius: The Transgression does not make use of this trope, curiously; rather, any new technological piece created by a Genius is one-of-a-kind called a Wonder. They can replicate Wonders, but don't understand exactly how they work; as the book points out, if they knew that, they wouldn't be practicing mad science, just regular science. Giving a non-Genius a Wonder doesn't tend to work out well; if they're lucky, it just refuses to work as the laws of physics remember that whatever the Wonder does is actually impossible. If they're unlucky, it explodes or goes on a rampage.
- Invoked in an episode of Adventures of Sonic the Hedgehog when Robotnik explicitly says that the creation of his "Super-Genius Program" was a million-to-one shot — and after the program is stolen and he orders his computer to make it again, the computer has to remind him of exactly this fact (which he said himself not five minutes before!).
- The Simpsons: In the "Treehouse of Horror V" segment "Time and Punishment", Homer's attempts to repair the toaster create a time-machine that sends him back to the Mesozoic. As soon as the toaster "pops", he returns to the 20th century, but that's enough time to totally alter the history and evolution of all life on Earth by swatting a bug.
- R.W Wood noticed that a heating circuit is broken, but a wire in a glass with atomic hydrogen not only doesn't cool, but in fact is white hot. This provoked some useful research on recombination and the invention of atomic-hydrogen welding.
- Iodine was discovered completely by accident as a byproduct of adding too much sulfuric acid to the waste left over after making saltpeter (a component of gunpowder) from seaweed. After the initial fight over who had discovered the new element, there came the question of what to do with it. It dyed and stained things well, but didn't smell too good, so it was given to soldiers to use to mark the wounds of those who had been shot, stabbed, etc. in battle. Surgeons of the period quickly noticed that soldiers whose wounds had been marked by iodine were far less prone to infection.
- Teflon was invented when an organo-fluoride gas was left in a cylinder a long time and solidified by itself.
- The microwave oven was invented when engineers working on a radar project realized that working in the same room as the radar when it was running caused the candy in their pockets to melt. This is why the original name of the microwave was the Radarange.
- Engineers at 3M were not initially happy to discover their efforts at making an improved adhesive were weak enough to be pulled away by hand. Then one of them, tired of having the bookmarks in his church hymnal fall out, added some of the weak adhesive to it. And that's why we have Post-It Notes.
- The antibiotic Penicillin was discovered when Alexander Fleming found his bacterial samples contaminated by Penicillium mould and studied the way the mould was able to create bacteria-free areas on his petri dish.
- While software developers joke "it's not a bug, it's a feature!", sometimes those bugs do become features in later releases as seen in Ascended Glitch. Note that for all intents and purposes, a bug is an unintentional error in the implementation of the software.
- Researchers at Pfizer were trying to develop a drug to treat angina and high blood pressure. The drug they created, sildenafil, turned out to be not all that great at treating chest pains or high blood pressure. What it *did* do was cause men, even impotent men, to get erections. So instead of treating chest pains Pfizer marketed their drug as an "erectile dysfunction" treatment under the brand name Viagra.