The App That Helped Write a Breakout Sci-Fi Novel

Like most books, author Andy Weir's new novel The Martian was written on a computer. Unlike most books, though, it was also written by a computer.
Andy Weir039s The Martian is a bit like Cast Away on Mars. Image courtesy Crown Publishers
Andy Weir'sThe Martian is kinda like Cast Away on Mars—just without a volleyball. Image courtesy Crown Publishers

Like most books, author Andy Weir's novel The Martian was written on a computer. However, unlike most books, it was also written by a computer.

Well, sort of. In the novel, which became a self-published phenomenon in 2012 but is out as a "real book" this week on Crown, the narrator is a wry astronaut named Mark Watney. After becoming one of the first humans to walk on the surface of Mars, Watney is abandoned; his team loses him in a dust storm, assumes he's dead, and leaves the planet. For Weir, a software engineer by trade, it was essential that his book have a realistic flight plan—so he wrote a program that would create one.

"I wanted to know how long it took for them to get there, and what their planned return route was," Weir says. "Their return route was particularly important, because I wanted to know what the transmission delay between the ship and Earth would be at any given time during the story."

#iframe: http://player.cnevids.com/embed/52f8ffc369702d284c090000/5176e86968f9d a6db1000025||||||

The Mars-destined spacecraft in The Martian, which is being called "the best pure sci-fi novel in years," is powered by ion engines, which Weir says "apply a very small thrust constantly. Using conventional chemical engines would just require too much mass in fuel." While it's easy enough to calculate non-accelerating orbital trajectories, the constant acceleration of ion engines and the ability to change the direction of their thrusts at any time made it a little bit more complicated to figure. So Weir "wrote an app to incrementally calculate it."

"I set it up so I could mess around with the angle of thrust at any point along the journey, as well as turn the engine on or off," he says. "The app walks the trajectory forward to calculate position and displays it all at once. From there it was just a matter of picking points along the trip to change course and fiddle with it until it got to Mars."

The app, which Weir just called "orbits," also calculated how far the ship would be from Earth and Mars at any given time. Planning out the mission course using the app also proved useful when Weir was writing the transmissions between, say, his astronaut and NASA's Jet Propulsion Lab: It could calculate the exact timestamps to put on those conversations. "The app can also play back the motions of all bodies as an animation, rather than show the whole course at once," Weir said. Check out some of those animations in the video above—or some of Weir's other self-published work (which includes both Doctor Who and Sherlock fanfiction) here.