Background
DCF is is a valuation method used to value a project, company or asset. In general, DCF uses future cash flow estimates and discounts them back to present day (using a discount rate).
Once future cash flows are discounted back to present value, one can determine whether or not a given investment is a good idea. When valuing a stock using DCF, you can estimae all future earnings of a company, and then use the discount rate to find the present value. The present value of a company's projected earnings is then considered the ‘fair market value’ of the stock. (keeping in mind the list of caveats at bottom)
Applying DCF to value Apple
The above can be hard to visualize - so, I made a small example to help explain what we're doing here. Imagine we're trying to use DCF to value Apple, given the following information:
Using the above, here's how Apple's earnings would look for the first 10 years (where earnings are growing at 17%) as well as years 11-infinity (where earnings growth has flattened off to 2% per year):
Now that we have a forecast of Apple's future earnings from years 1-10 and 11-infinity, we just need to take the present value of those earnings. We can do this using our discount rate (I'm using the S&P 500 return of 11% here). The discount rate is the cost of capital, or, in other words, the return we could have gotten by choosing a different investment (e.g. investing in S&P 500 instead of AAPl).
Simple enough, right? The difficult part here is really nailing the inputs, e.g.:
Nobody really knows the answers to the above, which is why this valuation method (and any stock valuation method) is just a guess.
Formula for valuing stock using DCF
Putting this DCF calculation into a formula would look something like this:
$$\sum_{0}^N \frac{E(1+g_0)^N}{(1+r)^N}+\frac{[E(1+g_0)^{N}\frac{(1+g_1)}{(r-g_1)}]}{(1+r)^N}$$
\(E =\) Earnings per share
\(g_0 =\) Earnings growth rate attached to first N years
\(g_1 =\) Terminal earnings growth rate from N+1 to \(\infty\) years. Should be around inflation.
\(r =\) Discount rate, desired rate of return. S&P 500 return is a good proxy.
\(N =\) # of years earnings will initially growth at rate \(g_0 =\) (before leveling off to rate \(g_1\) into perpetuity) .
As shown in the above formula, we are determining the 'fair market value' of the company by discounting two components back to present value:
Caveats/words of caution
This formula is just a single tool, and should not be used to solely make an investment decision. You can do all sorts of crazy things with how you define earnings (e.g. GAAP vs. FCF), and there are multiple different stances on the best way to value the terminal earnings component (e.g. EBIDTA exit multiple, limit terminal value to a # of years, etc).
The formula is best used as a framework to highlight core assumptions and check sensitivity to them. That said, below are some explicit words of caution to keep in mind when using this formula:
Calculator
Here is the calculator I made using the above methodology.