Over the last few years, the stock market has been on a roller-coaster ride. Equities have swung from a bear market in 2022 to a booming recovery in 2023. Thankfully, the bull run looks set to continue.

According to an analysis of the Nasdaq Composite going back to 1971, this tech-heavy index has soared by an average of 19% each year after a recovery year like 2023. Though the past doesn't guarantee what's going to happen in the future, this information has buoyed investor optimism.

Let's explore why Nvidia (NVDA -3.89%) and Amazon (AMZN 2.29%) could turn a $1,000 investment into much more over the long term for those who have $1,000 that they don't need for anything in the immediate- or near-term that they are ready to invest.

Nvidia

If you thought Nvidia's performance in 2023 was impressive, wait until you see what 2024 could have in store. With shares already up by a staggering 45% year to date, the iconic chipmaker continues to soar as it dominates the AI hardware opportunity. The stock's valuation remains reasonable, considering its spectacular operational momentum.

Analysts and investors are becoming increasingly confident in Nvidia's ability to maintain its explosive growth rate, even as industry competition increases. The company's economic moat comes from its technical lead. While rivals are struggling to match Nvidia's flagship artificial intelligence (AI) graphics processing units (GPU), the H100 and H200, the chipmaker is already working on a more advanced product called the B100 that could put it even further ahead of the pack when it launches in 2025.

Nvidia's large share in the AI chip market (estimated at above 80%) has also given it a robust developer community that's used to working with its hardware and will be reluctant to switch to alternatives.

With a forward price-to-earnings (P/E) multiple of 35, Nvidia trades at a slight premium to the Nasdaq-100 estimate of 30. This looks fair, considering the company's profits grew 12-fold in the third quarter.

Amazon

With shares up 67% over the last year, Amazon is another tech giant helping power the Nasdaq to new highs. The company's ambitious cost-cutting efforts will help it pivot to new opportunities in AI.

Under the leadership of CEO Andy Jassy, who took over from founder Jeff Bezos in 2021, Amazon has begun prioritizing efficiency through workforce reductions and optimizing its fulfillment network. The efforts are paying off in a big way. While fourth-quarter net sales increased by a modest 14% to $170 billion, operating income surged almost fivefold to $13.2 billion, mainly because of dramatically higher margins in the North American and international e-commerce segments.

A person smiling while looking at stock charts on a computer screen.

Image source: Getty Images.

The cost-cutting comes at an excellent time for Amazon because it gives management leeway to make expensive investments in new growth opportunities like AI, where a $4 billion investment in OpenAI rival Anthropic could give it access to advanced large language models (LLMs) and a fast-growing client for its cloud service platform, Amazon Web Services (AWS).

Amazon is also weaving AI technology into its e-commerce platform through a new shopping tool called Rufus, which is designed to boost sales rates by answering customer questions and facilitating product discovery.

Trillion-dollar companies didn't get there by accident

Nvidia and Amazon have one big thing in common: massive market capitalizations. With both worth nearly $1.8 trillion, they are among the most valuable companies in the world.

They didn't get there by accident. Both tech giants have been able to quickly capitalize on new opportunities after their original businesses (video game chips and e-commerce) matured.

Artificial intelligence promises to unlock the next leg of long-term growth for both companies. Their stocks have the potential to turn a $1,000 investment into significantly more over the long term.