Long-term investing is one of the keys to sustainable returns in the stock market. This strategy overlooks near-term volatility, giving time for a company's fundamental qualities to shine through.

With shares up by almost 20,000% over the previous decade, Nvidia (NVDA 6.98%) is an excellent example of these principles. Let's see if the chipmaker has what it takes to continue beating the market over the next three years.

The best artificial intelligence (AI) stock

It's hard to imagine a better AI company than Nvidia, the top producer of the graphics processing units (GPUs) needed to train and run these complex algorithms. Business is booming, with fourth-quarter revenue up 265% to $22.1 billion, and profits up 769% to $12.3 billion.

While rivals can sometimes replicate Nvidia's products in raw performance, it protects its position through CUDA, a programming platform and software solution optimized for Nvidia hardware.

Despite these strong fundamentals, the stock trades for a forward price-to-earnings (P/E) multiple of just 37. This valuation is moderately higher than the Nasdaq 100 average of 29 but much cheaper than comparable chipmakers like Advanced Micro Devices, which has a P/E of 43 despite growing revenue by only 2% to 5.47 billion in its most recent quarter. Make no mistake about it, Nvidia stock is cheap.

Why is the market putting a discount on Nvidia?

Nvidia's risks don't seem to have much to do with the company itself. The chipmaker has successfully created a moat around its GPUs and has a technological lead over rivals. And it is expanding its addressable market through software and a massive push into custom chips for clients.

Within the AI chip market, the company seems to have done everything right. That said, it has become alarmingly overexposed to this one industry.

In the fourth quarter, the data center segment (which is dominated by AI GPU sales) generated $18.4 billion, or 83% of total revenue. And the company's gaming segment -- formerly its core -- now barely moves the needle with just $2.8 billion in sales. The worsening lack of diversification makes it uncomfortably vulnerable to changes in the consumer market for AI.

A person looking closely at a computer screen with stock information

Image source: Getty Images.

As AI-related hype begins to fade over the next three years, companies will have to generate substantial earnings and cash flow to justify the billions they are spending on Nvidia's AI hardware.

According to The Washington Post, AI chatbots like ChatGPT lose money on every query because of the high cost of building and operating large language models (LLMs).

Another challenge will come from open-source AI platforms like Elon Musk's Grok, which allows anyone to build projects on its source code for free -- potentially eroding the profit potential in the industry. All this could make it less financially appealing for Nvidia's clients to continue spending so much on its high-priced GPUs.

How will Nvidia perform over the next three years?

With its high growth rate and reasonable valuation, Nvidia can continue outperforming the market over the next three years. And over the very long term (think decades), the chipmaker's technological lead in GPU design could help it expand to more industries like automaking or virtual reality, which could fix its problem with a lack of diversification. That said, investors who buy the stock now face substantial near-term risks if the AI industry doesn't live up to expectations.