Amazon (AMZN 1.30%) has been one of the year's best-performing mega cap stocks. Year-to-date, shares of the online retailer have risen almost 6%. That doesn't sound like much, but it's been enough to outperform most of its peers and the broader S&P 500.

Of course, Amazon's rise over the last 19 years has been far more impressive. In May, 1997, Amazon went public at $18 per share in an IPO that valued the company at around $438 million. Since then, Amazon's stock has risen by an astronomical 47,582.67% as its market cap has broken above $335 billion. If you had invested $3,000 in Amazon's IPO (and held on to your investment), you'd have more than $1 million today.

Semitrailer with Prime logo on it

Image source: Amazon.

12 shares for the price of one

Buying $3,000 worth of Amazon stock in its IPO would've landed you 166 shares (with $12 left over). But today, you'd have many more shares than that. During the late 1990s, at the height of the dot-com boom, Amazon split its shares three times -- once in 1998, and then twice in 1999. A 2-for-1 split followed a 3-for-1 split and then another 2-for-1 split. All told, those 166 shares would've multiplied to become 1,992 shares. At around $715 per share, that's $1,424,280 -- a stunning return on investment with a compound annual growth rate of more than 38%.

If they couldn't get in on the IPO, investors still would've done amazingly well had they purchased shares on Amazon's first day of trading. On May 15, 1997 -- Amazon's first day as a publicly traded company -- Amazon shares hit a high of $29.25. They spent most of the day trading for considerably less than that, but even if you purchased at that price, $3,000 would've been enough to land you 102 shares. Those 102 shares would've become 1,224 shares, and today they'd be worth more than $875,000.

Even if you had bought at the height of the dot-com bubble, you still could've made an incredible return. The Nasdaq Composite hit a high in March, 2000, when Amazon shares were trading for around $75. At the time, $3,000 would've been enough to purchase 40 shares, which would be worth $28,600 today. If you waited for the dot-com bubble to bust, you could've scooped up 545 shares when Amazon was trading near $5.50 in October, 2001. That investment would be worth $389,675 today. 

An online bookstore becomes a retail and cloud computing giant

Amazon's business has evolved dramatically over the last 19 years. In its S1 filing, the company declares itself the "leading online retailer of books." (That's still true today, but Amazon has become the leading online retailer of many other things as well.) In the filing, Amazon writes about the global market for books, and the competition it could face within the space. It admits that it plans to expand into other verticals over time, but limits its ambitions to becoming "the leading online retailer of information-based products and services." Today, Amazon sells everything from food, to clothing, to electronics and toilet paper.

Amazon Web Services, which now generates more than $2.5 billion in revenue each quarter (about 8% of Amazon's revenue) and may be the single most compelling aspect of Amazon's business, didn't emerge until 2006 -- almost a decade after its IPO. In 1997, the Internet was in its infancy, and concepts like cloud computing were difficult to fathom.

Nevertheless, investors that had been willing to stick with Amazon through its evolution (through difficult quarters and occasional crashes) would be sitting on an impressive return -- a life-changing return.