Male octopuses have a big problem: female octopuses. Each male wants to mate and pass on his genes to a new generation. The trouble is, the female is often larger and hungrier than he is, so there is a constant risk that, instead of mating, the female will strangle him and eat him.

The males have a host of tricks to survive the mating process. Some of them can quite literally mate at arm's length. Others sneak into a female's den disguised as another gal, or sacrifice their entire mating arm to the female and then make a hasty retreat.

It's all very macabre. It's also a paradox. Octopuses are some of the most antisocial, unfriendly animals alive. Yet their bodies have evolved in such a way that they must mate in the most intimate way possible: the male has to insert his sperm directly into the female's body using one of his arms. The resulting mating practices are not just a curiosity: they are a window onto how octopuses have evolved into the creatures they are today.

Octopuses and their close cousins the squid all belong to a group of animals called cephalopods. Both are actually molluscs, making them close relatives of oysters and limpets, but they have lost their shells.

Octopuses tend to be profoundly antagonistic towards each other. Unlike gregarious animals like dolphins, they appear to see their own kind primarily as competition, and sometimes food.

There's always the threat of cannibalism

Squid, which are downright social by comparison, mate in a distinctly unromantic way. A male squid swims by and deposits sperm in one quick move outside of the female's body. She can decide later whether to accept it.

But not so the octopus. "Octopus mating is definitely different than other cephalopods," says marine biologist Jean Boal of Millersville University in Pennsylvania. The male must deposit his sperm inside the female's body, at the risk of his life.

"There's always the threat of cannibalism," says Richard Ross of the California Academy of Science's Steinhart Aquarium.

We don't know how often female octopuses eat the males, but Christine Huffard of the Monterey Bay Aquarium Research Institute in California has seen it happen many times.

She strangled him and took him back to her den to feed on

In one instance, she and her colleagues observed two day octopuses mating on a reef in Indonesia. After about 15 minutes of copulation, the female lunged and wrapped two arms around the male's bulbous body, his mantle. A few minutes later, the male was motionless. The female then carried the corpse to her den, where he presumably became dinner.

In another instance, researchers watched a large female day octopus off the coast of Micronesia. A small male mated with her a dozen times. But then the male went in for a 13th mating session, and the female turned on him. She strangled him and took him back to her den to feed on over the course of the next two days.

Sexual cannibalism does happen in nature - witness the male-eating praying mantis and black widow spiders - but strangulation during mating is a rarity, Ross says. It may not be all bad for the male, though.

As Huffard and her colleagues point out in a 2014 paper describing one of the male-eating incidents, the felled male probably managed to fertilize some of the female's eggs - accomplishing his life's mission despite his unfortunate demise. What's more, females generally make hundreds or even hundreds of thousands of eggs, so just one successful copulation can produce a vast number of offspring.

The male's main tool for this daunting endeavour is a specialized mating arm, known as the hectocotylus. When he is not engaged with a female, the mating arm works just like his other seven arms. It is able to bend, stretch and exert suction. But the mating arm also comes with extra bells and whistles.

For big species, mating can last at least half an hour

For one, it has a central groove. The male releases packets of sperm called spermatophores into this groove, for their journey to the female. The arm's tip is also equipped with erectile tissue, not unlike that found in the human penis, which provides stiffness that helps guide the arm into the female's body. The arm goes in through one of the two siphons on the female's mantle, which she also uses to breathe, expel waste and jet out water for swimming.

The destination for these spermatophores is the female's small oviducal gland, a sort of holding area. When she lays her eggs, which could be days or even months later, they will pass this area and be fertilised.

The male needs to keep his mating arm tip inside the female long enough to transfer at least one spermatophore, and preferably more. In some smaller species this might take just a couple minutes, says Jennifer Mather of the University of Lethbridge in Alberta, Canada. But for big species like the giant Pacific octopus, mating can last at least half an hour.

But being soft-bodied, they can't indulge for too long. "If you get all wrapped up in mating, you're very, very vulnerable to predators," says Mather.

As a general rule, it's the male octopuses that approach the females.Then the males tend to take one of two approaches in attempting insemination.

The first is a risky position called the "mount". "The male grabs onto the female's mantle with all his arms, and reaches into her mantle with his mating arm," says Huffard.

This style of mating tends to be more popular in species with shorter arms, says Huffard. Females of these species may be less likely to eat their mates. Possibly, species in which males are more likely to be devoured during sex have evolved longer arms, which would make mating a little safer for the males.

More cautious males opt for the "reach". "The male sits near the female and reaches over to her only with the mating arm," says Huffard.

This allows him to keep his distance. "The male will extend his arm as long as he can and try to accomplish the copulation from as far away as he can," says Boal.

The "reach" tactic is more common in octopuses with longer arms, which may be the ones where female cannibalism is more likely. An extra-long reach means that the male can stretch his arm into a resting female's den and mate with her without even venturing inside.

The algae octopus is one such cautious mater. "Males have a very long mating arm," says Huffard. "They stretch this arm to twice its resting length when mating." Just to be on the safe side, "these males also frequently mate with females that are busy foraging for food". These females ought to be too busy to eat him.

The "reach" approach also keeps the male's other seven arms free, so he can defend himself if need be, says Ross. This may be why the coconut octopus practices distant sex.

The "reach" tactic might also be advantageous for the female. In theory, she could entertain two male suits at once, says Huffard: one in each siphon.

In some species, male octopuses have moved beyond the "reach". They just give the female their spermatophore-loaded mating arm, and swim away to safety.

A detached mating arm might be a logistical necessity

Male argonaut octopuses are smaller than the females, and the male's hectocotylus simply stays intact inside the female's mantle "until the female is ready to use the sperm for fertilization", Mather says.

It was actually this behaviour that earned the hectocotylus its name. In the early 19th century the zoologist Georges Cuvier discovered strange foreign objects in female argonaut octopuses and thought they must be a type of parasitic worm. He called them Hectocotylus octopodis, and the name stuck.

For blanket octopuses, a detached mating arm might also be a logistical necessity. The females can be 2m long, while the males are just a few centimetres. So the male "removes the arm that carries the sperm, and the arm goes into the [female's] mantle cavity," says Ross. "That's a pretty extreme strategy to not get eaten."

But it's not all rough-and-tumble, strangulation and arm removal. Algae octopuses are slightly more tolerant of each other than most species, and as a result their mating behaviours are more nuanced.

They have even been known to disguise themselves as females

Males of this species have other males as well as females to fear when attempting to mate. The largest males often have the privilege of guarding a desirable female and mating with her repeatedly. Smaller males have no chance of driving them off, and they know it. "Males appear to alter their mating tactics, based on their local chances of winning fights with rivals," says Huffard.

The smaller males wait until a larger guarding male has left the den, then covertly mate with the female. As a result, they are called "sneaker" males. They have even been known to disguise themselves as females, hiding their hectocotylus to make a less threatening approach to a guarded female.

This sly tactic can occasionally backfire, as it did in an instance caught on film by Huffard. A sneaker male approached a burrow where he seemingly sensed a female was hiding. As he reached an arm in, an octopus emerged. But it was not the female: it was her guarding male. Unsurprisingly, this big male was not impressed by the sneaker male's attempt to insert a hectocotylus into his mantle. The small male only narrowly escaped the ensuing fight.

These cunning tactics pale in comparison to the behaviour of one newly-discovered octopus species. The larger Pacific striped octopus has not yet been formally described. But its sexual habits break all the rules for octopuses.

They mate beak-to-beak

The larger Pacific striped octopus is one of the few known gregarious octopuses. These octopuses can live together, even in close quarters, without eating or otherwise maiming each other.

This tolerance carries through to their mating habits. "They mate beak-to-beak, mouthpart-to-mouthpart," says Ross, who has witnessed numerous mating sessions. This is bizarre, because octopuses' sharp and strong beaks are their most dangerous weapons.

In this unusual position, a pair of octopuses will spread their arms out together, so that the suckers seem to touch. "That's a really, really strange thing," says Ross.

The larger Pacific striped octopus has a close cousin, the imaginatively-named lesser Pacific striped octopus. These are much more typical. "The male jumps on top of [the female's] mantle, away from her arms," says Ross. "It's an amazingly quick movement, in case she's in a bad mood or something. Then they mate, and he moves away as fast as he can."

When octopuses mate there are 16 arms to keep track of

No one knows why the larger Pacific striped octopus is so much more sociable than other species. Its apparent oddity reminds us that we don't really understand octopus sex in general. Why would such a voracious, antisocial animal mate so intimately?

Perhaps, despite the scale of the sexual cannibalism, few enough males meet their doom at their mates' hands, er, arms - and enough of them manage to pass on sperm. If that's the case, there might not be much evolutionary pressure on the males to evolve a safer way to mate.

"No one's really worked all of this out," says Mather. That may be in part because only a handful of species have been studied so far. "We have a vague understanding of mating in about a dozen shallow-water octopuses," Huffard says. "That leaves over 275 shallow-water species to go, and all of the deep-water species." Those deep-water octopuses might hold evolutionary clues to what early octopus sex looked like.

It may be some time before we truly understand why octopuses have sex the way they do. Part of the problem is that they are extraordinarily difficult to study. There are the obvious problems that they live underwater and are masters of camouflage. But even more challenging, when octopuses do get together there are 16 arms to keep track of. "It's really difficult to see what's going on," says Ross.