If you have extra cash to invest, Taiwan Semiconductor Manufacturing (TSM 1.26%) and Apple (AAPL -0.35%) are two stocks that should deliver satisfactory returns over the next five years and beyond.

Taiwan Semiconductor Manufacturing, or TSMC as it is also known, has a bright future providing advanced computing chips for the world's leading semiconductor companies. Apple is one of the most valuable brands in the world, generating $385 billion annually in revenue from products and services.

If you have $3,000 available to invest that isn't needed to pay monthly bills, bolster an emergency fund, or pay off short-term debt, you might want to consider investing $1,500 in each of these two tech stocks as part of a diversified portfolio. Here's why.

1. Taiwan Semiconductor Manufacturing

TSMC is the world's leading chip foundry with a 58% market share, according to Statista. As such, it is in business to manufacture processors for other semiconductor companies.

Increasing demand, especially in data centers, has driven tremendous growth for the business in recent years. Over the last 10 years, revenue rose 15% per year, with earnings up nearly 20%. However, slowing demand from macroeconomic headwinds pressured results this year. Despite revenue increasing 29% in 2022, the stock fell hard, as the market anticipated slowing demand heading into 2023. This materialized as expected, with revenue in the month of June down 11% over May.  

Still, the stock price has been rising, up 35% year to date. This is largely based on the long-term demand for products that will require more-advanced chips, especially in 5G wireless products and high-performance computing (e.g., data centers). Management previously stated that it believed the second quarter would represent the bottom of the recent sales slump. In fact, demand for artificial intelligence (AI) applications might only expand the company's growth potential, since AI requires tremendous amounts of computing power.

New technologies are a long-term catalyst for the leading foundry in the world. TSMC is currently producing the latest 3-nanometer chip technology that will go to market in the second half of the year. The company is also working on the next-generation 2nm technology planned for production in 2025. 

TSMC's ability to invest in future technologies to stay ahead of the curve is a key advantage and explains why it commands such a high share of the foundry industry. It is extremely profitable, generating nearly a 44% margin. With so much profit, TSMC can stay on the cutting edge of innovation for customers.

Despite the rebound in the stock, it is still trading at an attractive valuation. Its forward price-to-earnings (P/E) ratio of 20 represents a discount to the S&P 500's 25 multiple, suggesting Taiwan Semiconductor might be undervalued considering the long-term secular demand for advanced chips across every sector of the global economy. It also pays an above-average dividend yield of 1.77%.  

2. Apple

Apple stock has surged to new highs this year, which might surprise investors, considering total sales fell nearly $10 billion year over year to $212 billion through the first half of the fiscal year. The lower sales translated to a small dip in profits, too, but reports about the upcoming iPhone 15's pricing might have investors expecting a return to growth next year.

Over the last 10 years, Apple increased revenue by nearly 10% per year, with earnings rising nearly 15%. Apple's brand strength and pricing power should allow the company to grow enough over the next decade for the stock to climb in line with the broader market, if not outperform it.

Apple is reportedly planning to hike the price of the iPhone 15 Pro models, according to Haitong International Securities analyst Jeff Pu. This follows similar price increases in international markets last year, but apparently, the company is preparing to further separate the pricing between the high-end models and the standard version.

While some might expect lower demand as a result of the price hikes, it could be good news for shareholders. The company reported a March-quarter record for iPhone and services last quarter. Demand outstripped supply after the launch of the iPhone 14 last year due to supply shortages from China, but a similar story could play out this year for different reasons. Apple has been adding enough features to the Pro models in recent years to drive up demand for the more expensive versions. It can ask a higher price while giving customers more improvements, such as extending the battery life, adding more advanced health tracking features, and including other upgrades that build more pricing power into the business.

A price increase of $100 to $200 for the Pro models might amount to a $5 to $10 increase per month for customers who buy their phones with Apple's interest-free financing. In return, the company can pad its top and bottom lines.

The stock is not cheap, trading at a forward P/E of 31 with a low dividend yield of 0.5%. But even Warren Buffett was buying more shares in the first quarter. Companies that can raise prices on their products are worth more than the average business.