It's pouring outside, I have an appointment across town in 30 minutes, and my car's in the shop. To make matters worse, the rain means all the cabs near me are already taken.

Desperate to hitch a ride, I launch the Uber app on my iPhone and tap a button to track my location. In four minutes, a black sedan pulls up to my house, and a driver opens the rear door, welcoming me in.



Editor's note: This article is part of a series of profiles about hit apps and the successful programmers behind them.

See Also: How Angry Birds Is Becoming the Next Super Mario

Fifteen minutes later, I arrive at my destination and step out of the car. I don't have to hand over the $25 fare or tip, because I've already paid through the app. Yes, it was pricey, but it was worth it.

For me, Uber was simple: Request a ride, get in a car and go. But to get the car to my door, Uber's system first had to crunch through an array of complex mathematical formulas created by its team of computer scientists, all in an attempt to solve a decades-old economics problem plaguing the cab industry: how to optimize driving routes – and provide enough cars – to pick up the most customers in the least amount of time.

"It's really fun, sexy math," says Travis Kalanick, Uber's fearless CEO. He sounds cocky and self-assured, but without giving the impression that he's trying to sell something. It's math with real-world benefits, he explains.

"We are not just moving bits," Kalanick said. "We're moving people."

Uber is not a cab business — the app hires luxury sedans — but it offers a compelling alternative to the traditional cab. The cab business is ruthless for everyone, especially the drivers. In order to legally drive a cab, every driver in most American cities must display a "medallion," a city-issued badge that permits him or her to pick up people on the street when they wave their hands.

For about 80 years, cities' transportation agencies have enforced the medallion system to regulate the quantity and quality of cabs zooming up and down the streets. The problem is, in most cities, the number of medallions has remained stagnant even as human population and traffic balloon.

Because of the limited number of medallions, the competition among drivers for obtaining a medallion is fierce. Cab drivers camp on waiting lists for nearly 20 years just to grab a badge. Once you've got one, the potential payoff is big: Some medallion owners auction off their badges for as much as $600,000 apiece, while others lease their medallions to cab drivers for $100 to $200 per shift.

And because a city's cab supply is scarce, the competition for hailing a cab on the street is likewise intense, especially on a night like New Year's Eve, or the minute the bars shout, "Last call!"

With technology, Uber offers an app-powered car service that helps drivers earn money outside the medallion system, which amounts to more vehicles to fill more people.

A startup based in downtown San Francisco, Uber launched in June 2010. The startup has partnered with dozens of sedan services to hire their drivers and hook them up with iPhones containing the Uber drivers' app. Uber customers can hire drivers using the Uber app available on both iPhone and Android, or anybody with a cellphone can hail an Uber car by sending a text message containing the pick-up address to Uber's number. Once riders make a request, they receive an ETA from the driver.

When a driver receives a request, it appears on his iPhone, along with GPS coordinates of the rider. From here on, riders can call the driver if they need to make any special requests. Customers are required to enter their credit card information through the Uber app or website prior to requesting a car, so when they step out, there's no need to yank out their wallets. Riders can rate their drivers with a rating of 1 to 5, so if someone reports a negative experience, Uber can discipline (or fire) delinquent drivers.

Uber so far is only deployed in San Francisco, but over 10,000 customers have registered for the service already. The service will become available in New York "very soon," according to Kalanick.

There's no charge for the app, but customers pay a premium each time they book an Uber car — about 40 percent more than a regular cab fare.

To justify the premium, Uber guarantees that anybody who asks for a ride will get a car in a timely manner no matter what. Morevoer, Kalanick promises, the entire experience will be "über."

"We want a more über experience," Kalanick said. "Giving somebody you don't know your credit card is not uber."

The trick is, it's not easy being "über." It takes some really complicated math.

The Traveling Salesman

Imagine a giant sheet of paper with 4,000 dots scattered all over it. If you were to draw a line connecting all the dots, what would be the shortest, ideal path to get to all of them? Even if all the world's fastest supercomputers were put to work, they couldn't generate a perfect algorithm to solve this classic puzzle, which computer scientists call the traveling-salesman problem.

Uber, and any car service, for that matter, faces this problem, many times over.

"We have 100 cars out there and riders sprinkled all around the city," Kalanick said. "Each car has its own traveling-salesman problem."

And Uber's up for the challenge. The staff consists of 15 employees, including engineers, driver operations managers and community support reps who use Twitter, Facebook and other social media to interact with riders.

Kalanick himself studied computer science at UCLA, and one of the first companies he founded was a P2P search engine called Scour, which the music and movie industries sued for $250 billion, forcing Scour to settle and sell its assets. Kalanick believes his new startup Uber can only get better as it continues to chase the most sophisticated algorithm.

For Uber, the traveling salesman problem is even more complicated than determining the shortest distances between pickups. What about circumstances that would cause spikes in demand, like a rainstorm or a Giants game?

To measure and predict demand, Uber's system is constantly tracking ride-request patterns in different parts of the city. It also downloads weather-forecast data to get an idea of when to expect harsh conditions, and employees stay keenly aware of special events in the city that could affect demand and traffic.

On days of skyrocketing demand, such as Halloween night, Uber still promises everybody will get a car. How? Dynamic pricing: The cost of a fare goes up if Uber predicts exceptionally high demand, and this gives drivers incentive to work on these extremely hectic nights. It's like paying an employee overtime for working on a holiday.

It also helps keep demand manageable, by discouraging customers who aren't willing to pay what the ride is worth.

At the end of each day, Uber creates charts to analyze how accurately it was able to predict demand for rides throughout the city versus how high demand actually turned out to be. Using these charts, the company refines the prediction algorithm, so Uber gets better and better at estimating how many cars will be needed in the city on certain days and at certain hours.

Currently, the company is experimenting with a heat-map system (below) that will show drivers where demand is likely to be "hot," so they can hover around areas where someone is most likely to request a ride.

But even a heat map isn't a flawless solution, because if every driver got to see the heat map, they would all gravitate toward the same areas and leave the rest of the city dry. For this reason, Uber must publish the heat map to drivers in a gradual manner, so a few get it at a time. Who gets the map, and when, and how much of it is another complex math problem to explore.

Uber will soon hire Ph.D. scholars to help study and refine the company's statistical algorithm and heat-map distribution, according to Kalanick.

In the Uber office, operations managers watch a screen showing a "God View" (below) of the entire city, which displays all the active Uber cars in real time to ensure quality is maintained on the system at all times. Kalanick said it's mesmerizing watching the car requests light up all over the city during peak hours.

"When new employees see the God View, they end up watching it for hours — not because they have to, but because they're just amazed by it," Kalanick said.

Cruising Ahead

Uber doesn't eliminate the broken medallion system in the cab industry, nor does it fix it. However, by providing an alternative car service, Uber could potentially alleviate some of the supply pressure exerted on existing cab services: The more people take Uber cars, the more cabs become available for everybody else.

The initial hurdle for customers will be price. Uber isn't cheap – my 2.6-mile ride to my appointment cost $25, for example, whereas a taxi would have cost $10 or $12 – but Kalanick sees the possibility of eventually offering a tiered pricing structure for customers depending on car type and quality of the driver, among other factors.

Uber plans to expand to every major city in the world, because cabs face the same supply problem everywhere, Kalanick said.

Before it can do that, it has to overcome a few obstacles at home. The City and County of San Francisco issued a cease-and-desist letter to the company in October 2010, when the company was still called "UberCab." Anything with the word "cab," the city's transportation agency complained, must have a permit to operate as a cab service, and Uber doesn't even hire actual cabs.

Within 24 hours, Uber removed "Cab" from its company name. Nonetheless, the city can't be happy that Uber is filling the streets with cars that are beyond its jurisdiction.

"There's no way they like us," Kalanick said.

Uber also faces competition from other startups trying similar car solutions, such as TaxiMagic, an app that uses a computerized dispatch system to hail traditional cabs. Kalanick said he welcomes any rivals to join the race.

"We don't look in the rear-view mirror much," he said. "We just keep going forward. We're faster and intelligent. If you've got something to compete, bring it — I'm not sleeping. If you're sleeping, I'm gonna kick your ass."