Buying strong companies when their shares are temporarily underpriced can be a powerful strategy for generating superior investment returns over the long term. The concept is quite simple, but implementation is the key, since the question of how to find undervalued stocks has no single easy answer. However, I would suggest that, based on their outlooks, Apple (NASDAQ:AAPL) and Gilead Sciences (NASDAQ:GILD) appear to be promising candidates for investors hunting for the best bargain stocks in the current market environment.

Image source: Getty Images.

Why Apple stock is undervalued

Apple stock is trading at aggressively low valuation levels. Shares of the iPhone maker trade at a price-to-earnings ratio around 12.7, while the average company in the S&P 500 index carries a much higher price-to-earnings ratio of nearly 20. On a price-to-free-cash-flow basis, Apple is in the neighborhood of 9.6 versus 12.5 for companies in the S&P 500. 

One of the main reasons for such a cheap valuation is that investors are concerned about the company's ability to sustain growth in the future. Apple reported a 14.5% decline in revenue during the quarter ended in June, which was mostly due to a tremendously challenging comparison versus booming revenue growth in the same quarter the previous year. 

Apple revenue. Data in thousands of dollars. Data source: SEC filings. 

On the other hand, the iPhone SE is attracting new customers to the Apple ecosystem, and year-over-year sales comparisons will get much easier in 2017. With this in mind, it doesn't sound unreasonable at all to expect the iPhone segment to stabilize and start growing again over the coming quarters. 

Besides, the services division, which includes revenue from the iTunes Store, the App Store, Apple Pay, and other services, is now the second-largest segment for Apple behind the iPhone, and it's firing on all cylinders. Apple produced nearly $6 billion in sales from this business last quarter, a vigorous increase of 19% versus the same period last year. According to CEO Tim Cook, the services division is on track to become "the size of a Fortune 100 company" next year.

In a nutshell, Apple stock is dirt-cheap thanks to concerns about declining revenue, but the iPhone segment could easily improve in the coming quarters, and the services division is looking like a powerful growth driver going forward. At these prices, Apple stock looks like a huge bargain for investors.

Why Gilead Sciences is a healthy biotech opportunity

Gilead Sciences is a market leader among biotech companies dedicated to curing infectious diseases. The company has an enormously valuable portfolio of drugs focused on treatments for HIV, hepatitis B, and hepatitis C. Gilead has made a series of acquisitions over the last several years, including names such as Corus Pharma, Myogen, CV Therapeutics, Arresto Biosciences, and Calistoga, and these moves have expanded the company's presence in areas such as pulmonary and cardiovascular diseases, as well as cancer.

The lion's share of revenue comes from hepatitis C treatments, and Gilead is facing declining sales in this division thanks to increasing competition from lower-cost drugs, which is hurting pricing power across the board. In this context, the company reported a 4.9% decline in revenue during the second quarter of 2016, to $7.65 billion.

On the other hand, sales of HIV products are still moving in the right direction. Gilead produced $3.1 billion in revenue from this segment last quarter, a vigorous increase of 15% year over year. Antiviral product sales were $7.1 billion during the period, so HIV products accounted for 44% of the total.

Total revenue could remain under pressure in the coming quarters, but Gilead has a promising pipeline of developments in areas such as HIV, oncology, rheumatoid arthritis, and nonalcoholic steatohepatitis, among others. Not only that, but Gilead is sitting on $24.6 billion in cash, cash equivalents, and marketable securities on its balance sheet, and the business produced almost $17 billion in free cash flow during the trailing-12-month period ended in June. This means Gilead has abundant financial resources with which to buy smaller industry players and find new growth opportunities via acquisitions over the coming years.

The company is aggressively repurchasing stock, and it has reduced the amount of shares outstanding by 19% of the total since January 2014. A shrinking share count increases earnings per share by reducing the denominator in the earnings per share calculation, so Gilead is flexing its financial muscle to increase earnings per share, even when net income is stagnant or declining.

GILD Average Diluted Shares Outstanding (Quarterly) Chart

GILD Average Diluted Shares Outstanding (Quarterly) data by YCharts.

Importantly, Gilead Sciences is trading at ridiculously cheap valuation levels. The stock carries a price-to-earnings ratio of 7.1, while the price-to-free-cash-flow ratio is roughly 6.5. This is not only a massive discount versus other stocks in the market, but also by Gilead's own historical standards. As a reference, the average price-to-earnings and price-to-free-cash-flow ratios for Gilead over the last five years are 21 and 24, respectively, according to data from Morningstar.

The bottom line

Apple and Gilead are facing declining revenue, and this is an important uncertainty factor to keep in mind. Nevertheless, both companies remain fundamentally solid from a long-term perspective, and they are trading at compellingly cheap prices. Buying undervalued companies can be remarkably profitable, but it also requires an independent mindset to find opportunities where most investors only see risks.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.