Image copyright Getty Images

Would you like to pay less tax? Make a sandwich: specifically, a "double Irish, Dutch sandwich".

Suppose you're American. You set up a company in Bermuda and sell it your intellectual property. It then sets up a subsidiary in Ireland.

Now, set up another company in Ireland: it bills your European operations for amounts resembling their profits. Now, start a company in the Netherlands.

Have your second Irish company send money to your Dutch company, which immediately sends it back to your first Irish company. You know, the one headquartered in Bermuda.

Are you bored and confused yet? If so, that's part of the point.

Tax havens depend on making it, at best, very difficult to get your head around financial flows, and, at worst, impossible to find out any facts.

Accounting techniques that make your brain hurt enable multinationals such as Google, eBay and Ikea to minimise their tax bills - completely legally.

50 Things That Made the Modern Economy highlights the inventions, ideas and innovations that have helped create the economic world.

It is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.

You can see why people get upset. Taxes are a bit like membership fees for a club: it feels unfair to dodge the fees but still expect to benefit from the services provided to members - defence, police, roads, sewers, education, and so on.

But tax havens haven't always had such a bad image. Sometimes they've functioned like any other safe haven, allowing persecuted minorities to escape the oppressive rules of home.

Jews in Nazi Germany, for example, were able to ask secretive Swiss bankers to hide their money.

Avoidance v evasion

Unfortunately, secretive Swiss bankers soon undid the good this did their reputation by proving to be just as happy to help the Nazis hide the gold they managed to steal, and reluctant to give it back to the people it was stolen from.

Nowadays, tax havens are controversial for two reasons: tax avoidance and tax evasion.

Tax avoidance is legal. It's the stuff of double Irish, Dutch sandwiches.

Image copyright Getty Images Image caption Like other major technology companies, Google has come under pressure over its tax arrangements.

The laws apply to everyone: smaller businesses and even ordinary individuals could set up border-hopping legal structures too. They just don't earn enough to justify the accountants' fees.

If everyday folk want to reduce their tax bill, their options are limited to various forms of tax evasion, which is illegal: VAT fraud, undeclared cash-in-hand work, or taking too many cigarettes through the "nothing to declare" lane at customs.

Secrecy boost

The British tax authorities reckon that much evaded tax comes from countless such - often modest - infractions, rather than the wealthy entrusting their money to shadowy bankers.

But it's hard to be sure. If we could measure the problem exactly, it wouldn't exist in the first place.

Image copyright Getty Images Image caption In 1934, the Swiss made it a criminal offence for bankers to disclose financial information

Perhaps it's no surprise that banking secrecy seems to have started in Switzerland: the first known regulations limiting bankers' ability to share information about their clients were passed in 1713 by the Great Council of Geneva.

Secretive Swiss banking really took off in the 1920s, as many European nations hiked taxes to repay their debts from World War One - and many rich Europeans looked for ways to hide their money.

Recognising that this was boosting their economy, in 1934 the Swiss made it a criminal offence for bankers to disclose financial information.

The euphemism for a tax haven these days, of course, is "offshore" - despite Switzerland's lack of coastline. Gradually, tax havens have emerged on islands such as Jersey or Malta, or, most famously, in the Caribbean.

Image copyright Getty Images Image caption Many small islands have become tax havens as a pragmatic way to grow their economies

There's a logistical reason for this: a small island isn't much good for manufacturing or agriculture, so financial services are an obvious alternative.

But the real explanation is historical: the dismantling of European empires in the decades after World War Two.

Unwilling to prop up Bermuda or the British Virgin Islands with explicit subsidies, the UK instead encouraged them to develop financial expertise, plugged into the City of London. The subsidy was implicit, instead - tax revenue steadily leaked away to these islands.

Mind the gap

The economist Gabriel Zucman came up with an ingenious way to estimate the wealth hidden in the offshore banking system.

In theory, if you add up the assets and liabilities reported by every global financial centre, the books should balance - but they don't. Each individual centre tends to report more liabilities than assets.

Zucman crunched the numbers and found that, globally, total liabilities were 8% higher than total assets. That suggests at least 8% of the world's wealth is illegally unreported. Other methods have come up with even higher estimates.

Image caption Zucman identified a gap between the global economy's declared assets and liabilities

The problem is particularly acute in developing countries. For example, Zucman finds 30% of wealth in Africa is hidden offshore. He calculates an annual loss of $14bn (£11bn) in tax revenue. That would build plenty of schools and hospitals.

Zucman's solution is transparency: creating a global register of who owns what, to end banking secrecy and anonymity-preserving shell corporations and trusts.

That might well help with tax evasion. But tax avoidance is a subtler and more complex problem.

To see why, imagine I own a bakery in Belgium, a dairy in Denmark, and a sandwich shop in Slovenia.

I sell a cheese sandwich, making 1 euro of profit. How much of that profit should be taxed in Slovenia, where I sold the sandwich, or Denmark, where I made the cheese, or Belgium, where I baked the bread? There's no obvious answer.

Accounting tricks

As rising taxes met increasing globalisation in the 1920s, the League of Nations devised protocols for handling such questions. They allow companies some leeway to choose where to book their profits.

There's a case for that, but it opened the door to some dubious accounting tricks.

Image copyright Getty Images Image caption Did a company in Trinidad really sell pens to a sister company for $8,500 (£6,600) apiece?

One widely reported example may be apocryphal, but illustrates the logical extreme of these practices.

A company in Trinidad apparently sold ballpoint pens to a sister company for $8,500 (£6,600) apiece, resulting in more profit booked in low-tax Trinidad and less in higher-tax regimes elsewhere.

Most such tricks are less obvious, and consequently harder to quantify.

More from Tim Harford

The simple steel box that changed global trade

The warrior monks who invented banking

What makes gambling wrong but insurance right?

Do passports restrict economic growth?

Still, Zucman estimates that 55% of US-based companies' profits are routed through some unlikely looking jurisdiction such as Luxembourg or Bermuda, costing the US taxpayer $130bn (£100bn) a year. Another estimate puts the losses to developing country governments at many times the amount they get in foreign aid.

Solutions are conceivable: profits could be taxed globally, with national governments devising ways to apportion which profit is deemed taxable where.

Political desire

A similar formula already exists to apportion national profits made by US companies to individual states.

But that would need political desire to tackle tax havens. And while recent years have seen some initiatives, notably by the Organisation for Economic Co-operation and Development (OECD), they've so far lacked teeth.

Perhaps this shouldn't surprise us, given the incentives involved. Clever people can earn more from exploiting loopholes than trying to close them.

Individual governments face incentives to compete to lower taxes, because a small percentage of something is better than a large percentage of nothing.

For tiny, palm-fringed islands, it can even make sense to set taxes at 0%, as the local economy will be boosted by the resulting boom in law and accounting.

Perhaps the biggest problem is that tax havens mostly benefit financial elites, including some politicians and many of their donors. Meanwhile, pressure from voters for action is limited by the boring and confusing nature of the problem.

Sandwich, anyone?

Tim Harford writes the Financial Times's Undercover Economist column. 50 Things That Made the Modern Economy is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.