It's been one challenge after another lately for Applied Materials (AMAT -0.16%). Between a demand slowdown caused by COVID-19, disruption of neon gas supplies (crucial for chip manufacturing) caused by the war in Ukraine, and rising production costs caused by inflation, 2022 was a terrible year. The stock slumped 38%.

Although many conditions from 2022 still exist in 2023, the stock is off to a great start, rising 39% compared to the S&P 500's return of 12%. With the stock sitting near its 52-week high of $138.80, should you buy it today or wait for a pullback in this terrible economic environment? Here's why long-term investors should see it as an excellent time to buy.

A bright, long-term future on several fronts

Several industry analysts predict the semiconductor industry will see robust secular growth until the end of the decade when the market could exceed $1 trillion. Research firm Fortune Business Insights projects the global semiconductor market will reach $1.4 trillion by 2029 from $573 billion in 2022, reflecting a compound annual growth rate of 12.2%. Demand for the Internet of Things (IoT), communications, and automotive should drive much of this growth.

IoT refers to physical objects such as buildings, vehicles, and devices equipped with software, sensors, and network connectivity to collect and share data. With the rapid rise of IoT applications, semiconductor demand should increase materially since each connected device will require distinct semiconductor components like memory, processors, and sensors.

The communications industry should also produce growing demand thanks to new technologies such as 5G and Wi-Fi 6, advancements that drive massive demand for new and advanced semiconductor components. 5G is the latest cellular network technology, offering faster speeds and lower latency than 4G. Wi-Fi 6 is next-generation Wi-Fi that enhances the performance and speed of connected devices.

The significance of semiconductors in the automotive industry has increased considerably with the advent of connected and autonomous vehicles. Vehicle manufacturers equip connected cars with sensors and software that facilitate communication with other vehicles, infrastructure, and the cloud. Autonomous vehicles require even more advanced semiconductor components than connected vehicles as they can operate independently of human intervention.

Despite the downturn in the semiconductor market over the past year, Applied Materials CEO Gary Dickerson observed that the market he refers to as ICAPS (IoT, communications, automotive, power, and sensors) is hot. During the second-quarter 2023 earnings call, he announced that the company is revising its 2023 ICAPS estimates higher.

But consumer electronics demand is still weak

Demand for consumer electronic devices such as personal computers (PCs) and smartphones has declined in recent years due to a slowing economy and lower consumer spending -- crushing demand for memory chips. Dickerson observed on the company's latest earnings call:

Weakness in PCs and smartphones is a key factor for memory customers who have significantly reduced their investments in 2023. Measured as a percentage of total wafer fab equipment, memory spending is tracking at its lowest level in more than a decade .... We see these changes as timing adjustments as these companies remain fully committed to their long-term roadmaps to win the race for technology leadership.

A massive problem for the company is that it relies heavily on the memory market. For example, in 2022 the memory business accounted for 34% of its total revenue, enough to be vulnerable to declining growth in the memory market.

If you look at the company's quarterly year-over-year revenue and net income growth over the last three years on the chart below, you can see it starting to drop in late 2021, coinciding with the decline in the memory chip market.

Chart showing Applied Materials' revenue and net income down since mid-2021.

AMAT Revenue (Quarterly YoY Growth) data by YCharts

Until the downdraft in the PC and smartphone market ends, the company will face a drag on its performance.

So is it a buy?

Investors may have little appetite to push the stock much higher in the short term. It sells at a price-to-earnings ratio of 18, only slightly below its median ratio of 18.6 over the past 10 years. Meanwhile, according to analysts' consensus estimates, the company will produce little earnings growth through 2025.

Many investors are concerned about Applied Materials' business performance in a weak memory market. Gartner analysts predict that memory demand will continue to weaken through much of 2023, with a recovery not expected until 2024. So, short-term investors have little incentive to buy the stock.

However, Applied Materials is a fantastic long-term investment. It is a leading semiconductor equipment supplier with a strong track record of innovation. As a result, it's well-positioned to profit from the secular growth of the chip industry. It has a great balance sheet and a history of generating strong cash flow, which means it's a financially sound company that can invest in its future growth.

Finally, Applied Materials has a history of growing its dividend, providing investors with a steady income stream and making it attractive to investors who desire a blend of growth and income.

Charts showing Applied Materials' dividend and free cash flow rising overall since 2019.

AMAT Dividend data by YCharts

Suppose you're a patient investor with an investing timeline of three to five years and can withstand temporary drops in this volatile market. In that case, Applied Materials is an excellent stock to buy for the long term.