Apple (AAPL 0.52%) and Alphabet (GOOG -1.96%) (GOOGL -1.97%) are among the most powerful companies of our times. The two tech titans compete against each other in key industry areas such as mobile, and they both make massive amounts of money for investors. Which one is a better buy right now: Apple or Alphabet?

Apple looks undervalued
Apple is the biggest publicly traded corporation in the world, but the stock still looks quite cheap when looking at the business fundamentals. Apple trades at a price-to-earnings ratio around 13 times earnings, a substantial discount versus the average P/E ratio for companies in the S&P 500 index (currently greater than 19).

The company delivered impressive financial performance for the third quarter, with sales growing 22% year over year to $51.5 billion and earnings per share jumping by a staggering 38% over the year-ago quarter.

Source: Apple.

However, Wall Street analysts are forecasting that sales will increase by only 3.6% in the December quarter due to maturation in the iPhone business and modest growth contribution from other segments. Management seems to agree: The company is expecting revenue in the range of $75.5 billion to $77.5 billion during the quarter, only a slight increase from $74.6 billion during the same quarter last year.

Apple stock is cheap for a reason: The consensus is that growth will slow down considerably in the coming quarters. The company has proven time and again that it can outperform expectations, but investors need to know that Apple's financial performance over the coming quarters is hard to predict at this stage. 

Alphabet is a top-notch business
Alphabet is the global king in online advertising. According to estimates by eMarketer, the company owns 55% of the search ad market thanks to the popularity and ubiquity of its Google search engine. In addition, Alphabet owns many of the most valuable services and applications in the online world, including Android, Chrome, Maps, and YouTube, among several others.

Alphabet is performing really well from a financial point of view. Revenue came in at $18.7 billion last quarter, a year-over-year increase of 21% on a constant-currency basis. The business model is remarkably profitable: The company makes operating margins in the neighborhood of 25% of sales on a GAAP basis and adjusted operating margin is around 33% of revenue.

Source: Motley Fool.

Alphabet stock is priced at above-average levels, carrying a P/E ratio greater than 30 times earnings. This does not necessarily mean that Alphabet is overvalued. A superior company merits a superior valuation, and Alphabet is a top-notch business with plenty of opportunities to profit from growing online advertising demand in the years ahead. Even at these prices, Alphabet can deliver solid gains for investors, but the stock simply is not as cheap as Apple.

Apple or Alphabet?
I really think both companies are great investments to hold for the long term. I own both Apple and Alphabet in my personal portfolio. In fact, they're the two biggest positions in my account. Still, it's important to consider the differences between the two businesses and what they offer in terms of risk versus potential reward.

Apple is priced at very attractive levels since Wall Street is expecting a big deceleration in growth over the coming quarters. If performance turns out to be better than expected on the back of sustained iPhone growth and/or growing revenue from other segments, then the stock should offer big upside potential from current levels. On the other hand, if Apple stagnates due to maturation in the smartphone industry and lackluster growth in other areas, investors in the company could get disappointing returns.

Apple is more of a hit-or-miss investment right now. Things could go really well for investors, or the stock could create a major drag on portfolio performance. It mostly depends on what kind of growth the company can deliver in the coming quarters

Alphabet, on the other hand, looks far more predictable. The company is an undisputed powerhouse in online advertising. The stock is priced at a premium versus the overall market, but it's not unreasonably valued considering the company's quality and growth prospects. There is a fairly good chance that Alphabet will continue delivering strong returns for investors over the years ahead, but I wouldn't expect explosive gains from the company in the coming months.

If you believe Apple will outperform expectations in the coming quarters, then it has superior upside potential than Alphabet at current prices. Alphabet, however, offers more predictable returns and more visibility when it comes to financial performance in the future. I do believe both companies will beat the market over the long term, but Apple provides both more uncertainty and higher potential for gains. Depending on your own investing philosophy, you may want to go with Apple, Alphabet, or -- why not? -- both.