It's difficult to rationalize the movements of the stock market sometimes. On the one hand, several mediocre businesses are trading at valuation multiples that make it terribly hard to generate a return over time. At the same time, some pretty high-quality companies are trading at considerable discounts for one reason for another. We certainly want to avoid those mediocre companies, especially when valuations run high. When stock prices for top-notch companies trade at low valuations, though, that's when we want to consider picking up shares. 

Two companies that stand out today as egregiously cheap stocks to buy are biotech giant Gilead Sciences (GILD -0.40%) and solar power company First Solar (FSLR -1.14%). Here's a quick look at why you may want to consider these cheap stocks for your portfolio.  

Magnifying glass aimed at dollar bills

Image source: Getty Images.

Research and development isn't a perfect science

The knock on Gilead Sciences for some time has been that its two cash cow treatments for the hepatitis C virus (HCV) have been on the decline lately. The patient pool for HCV treatments is shrinking thanks in part to the success of Gilead's treatments, but that is putting immense pressure on prices for the company's existing and new treatments for the disease. In fact, management estimates that 2017 revenue from its HCV treatments will decline 40% to 50% from last year's result . 

Test tubes on a laboratory desk

Image source: Getty Images.

The fear of Gilead losing its veritable cash-generating machine has a lot of investors and analysts running for the hills. The company's stock is down 26% over the past year. Currently, it trades at a price-to-earnings ratio of 6.8. What's more, Gilead has more than $32 billion in cash and investments on the books. If we were to back out the cash from its market cap, that P/E ratio is 4.1. 

Typically, a P/E ratio that low suggests there is no growth left in the stock, and that it's all downhill from here. That thinking heavily discounts two things, though: Gilead's development pipeline and its ability to deploy that cash horde. 

Gilead Sciences currently has 28 clinical trials under way for treatments in a wider range of diseases, the most lucrative of which is its non-alcoholic steatohepatitis (NASH) treatment. Of those clinical trials, 10 are in late-stage trials. Granted, we shouldn't expect many completed trials this year, and there is no guarantee that these will be blockbuster treatments like its suite of HCV treatments. All it takes is one treatment to become a blockbuster to move the needle, though. Gilead will spend heavily to complete this suite of late-stage trials in 2017.

The other thing that Gilead's stock price discounts is management's ability to use its cash on hand to make a significant acquisition. For a couple of quarters now, Gilead's management has said it is looking at potential acquisitions to boost its sales or its development pipeline. Again, with that much cash on hand and its existing portfolio of drugs cranking out solid cash flow, it can make some big acquisitions that could significantly improve its chances of developing the next major treatment. 

Perhaps 2017 won't be the year we see a significant turnaround for Gilead, but that's OK. Doubters give investors a long window to pick up shares of Gilead at a very reasonable price. 

A short cycle downturn on a long growth runway

Investing in the solar industry can be an incredibly frustrating endeavor. For all the talk of solar being the future of how we generate power and the massive growth potential, the industry is notoriously cyclical. Rapid technology improvements and the quick decline down the cost curve makes it a fast race to the bottom regarding pricing. These market dynamics can lead to ups and downs in panel prices and can do a real number on solar companies that aren't built to handle a cyclical market. 

Solar panel farm at sunset

Image source: Getty Images.

Today, we are in one of those market downturns. Back in 2015, investors were under the assumption that the investment tax credit and the production tax credit -- two things that boosted investment in solar installments -- would expire at the end of 2016. So most companies wanted to have their respective solar projects completed by the end of 2016 to reap the benefits of the tax credits. Those tax credits were extended, but not quickly enough for developers to fill their coffers with new projects. So today, the solar power industry is suffering from a bit of a hangover from this rapid expansion period. 

As a result, First Solar stock has taken it on the chin. Shares are down a whopping 58% over the past year and trade at an absurdly low enterprise value-to-EBITDA ratio of 1.6. Like Gilead, First Solar also has a lot of cash on the balance sheet. In fact, if you were to invest in First Solar's stock today, 66% of its market cap is in cash. 

Also, like Gilead, there isn't a whole lot of optimism over the short term for First Solar. The company expects a significant decline in earnings per share as it goes through a weak panel price environment and as it converts some manufacturing facilities to build its next-generation panels. 

If you extend your investment time horizon, though, there is a solid case to be made for investing in First Solar. One is that the company's research and development spending has produced fantastic results lately that have improved its panel efficiency well above the typical commodity product and have lowered manufacturing costs such that solar power is now cost-competitive with other sources of energy without tax credits. Also, First Solar anticipates it will more than double its panel production by 2020. 

The solar industry continues to grow in fits and starts, but the long-term potential becomes more attractive by the day as costs continue to decline. With shares of First Solar trading at such a discount, today now seems like a very opportune time to buy shares.