Air travel. It used to be wondrous (so we're told). Now it's the worst.

If it's not inadequate legroom and canceled flights, it's getting beaten bloody and dragged off the plane. With each viral outrage, Facebook and Twitter erupt: When will things get better for the average traveler?

Actually, we know the answer. It comes to us originally from a 19th century French economist writing 168 years ago--long before social media, United Airlines, or even the Wright Brothers.

Meet Jules Dupuit, a civil engineer and scholar who was the first to explain the concept of price discrimination. Before we get to his story, here are the two main questions you probably want to the answers to most, right upfront:

1. When will things get better for economy class travelers?

Probably never--sorry!--for reasons Dupuit put forth in 1849 (explained below, of course).

2. Why not treat economy class customers better?

Dupuit explained it all in four simple words. It's not out of vindictiveness, or even saving money Instead, it all boils down to this: "To scare the rich."

If you think coach is bad...

Railroads were the state-of-the-art mode of travel in Dupuit's time. As bad as coach airplane travel is now, economy class travel by rail back then pretty much sucked.

Dupuit described the experience himself:

"Barbarity. ... [T]raveling without a roof over the carriage, on poorly upholstered seats."

But, he opined, the railroad's motivation for providing such lousy accommodations (even when it would cost very little to improve them) wasn't to spite its economy passengers. Instead, it was to incentivize anyone who could afford to pay for a higher class of service to darn well do so. Here's a slightly longer version of his explanation, which makes the point clearly:

"It is not because of the several thousand francs which they would have to spend to cover the third class wagons or to upholster the benches. ... [I]t would happily sacrifice this [expense] for the sake of its popularity.

Its goal is to stop the traveler who can pay for the second class trip from going third class. It hurts the poor not because it wants them to personally suffer, but to scare the rich."

Price discrimination

Why scare the rich? Here's where we get into economic theory. Setting prices is always challenging. Do you set them low, expecting more volume but less profit per customer? Or do you charge more, anticipating lower volume but more profit per customer?

To overcome that conondrum, companies would love to employ total price discrimination--meaning they'd change their prices constantly, always charging every customer the maximum he or she would be willing to spend. There are several different price discrimination strategies available, but the one that Dupuit described is referred to as "self-incrimination."

So, take an airline, offering basically the same service to every passenger. They'll hurtle you through the sky in a pressurized metal tube, moving you quickly you from Point A to Point B. How do you get passengers to "self-incriminate" in that kind of environment?

Simple: You offer several classes of service on the same flight, and you make the lowest class so miserable that more people will gladly pay the price for the higher class. That way you squeeze as much profit out of each passenger as possible.

So, first class means "first class"

Unfortunately for those of us who normally fly coach, there's a limited amount of profit-squeezing to be done in economy. The much larger apportioned share of airline revenue comes from people paying more, and riding in first class, business class, and even economy-plus.

For example, American Airlines says it makes 70 percent of its international revenue from the the most expensive 25 percent of seats. Separately, a study showed that for all airlines on the most popular U.S. route, 13 percent of seats make up 40 percent of revenue.

(Something I learned while writing this, by the way: The most popular airline route in the United States is the nonstop JFK to LAX.)

As a result, while riding in coach gets coarser and coarser, flying first class (or more realistically, business class), becomes more and more luxurious.

The point is: it's economic forces at work. As uncomfortable as coach class can be, it's really nothing personal. Pilots, flight attendants, and gate agents are people, too, and most would prefer to treat passengers how they themselves would want to be treated. But like the passengers, the employees are largely stuck.

Thanks where they are due

I have to give credit for some of the ideas in this column to two people.

The first is to a reader who commented on LinkedIn about another column I'd written recently, about the woes of United Airlines, saying something like, "Hasn't this guy Murphy ever heard of Jules Dupuit?"

I might have heard of him, back when I took economics in college--but I can't say I remembered his story, or the open-roofed railroads, or the degree to which 19th century railroads and 21st century airlines have a lot in common.

(Not only that, but I'm embarrassed to say I can no longer find the post--but if you're the reader, contact me and I'll update this to give you credit. And to everyone else, please comment on these articles!)

The second bit of credit is to Tim Harford, who writes the Undercover Economist column for The Financial Times, and who did a great job of explaining Dupuit and some of his concepts in greater detail.