Yield To Maturity exact meaning From investopedia: "YTM is the total return anticipated on a bond if the bond is held until it matures"

I have also seen this interpretation used in other sources however this seems wrong to me.

More specifically the I don't see how the anticipated rate of return can be independent from the cost of capital. 

What I get from the math is that YTM expresses the cost of capital required for the net present value to be zero.

If the YTM is low then I can probably use a higher discount rate when calculating the present value of the bond. But using a higher discount rate than the YTM, by it's definition means a lower present value and therefore a negative net present value.

If the YTM is high enough then I will most likely use a lower discount rate, meaning a  higher present value and therefore a positive net present value.

Is my understanding correct?
The yield to maturity is the internal rate of return on the bond assuming no default. Given a series of promised cashflows in the future, to quote Prof. John Cochrane, "... the yield is just a convenient way to quote the price." 

In the case of a zero-coupon bond with price $p_0$ and face value $c_t$ due $t$ periods in the future, the yield to maturity is the fictional, constant interest rate $y$ that solves the equation:

$$ p_0 = \frac{c_t}{(1 + y)^t} $$

More generally in the case of a non-negative series of payments $(c_1, \ldots, c_T)$, the yield to maturity is the fictional, constant interest rate $y$ that solves:

$$ p_0 = \sum_{t=1}^T \frac{c_t}{\left(1 + y\right)^t}$$

Given a series of promised coupon payments and the bond's face value, listing either a bond price or bond yield conveys the same information.

The yield to maturity does not tell you the expected return because you don't know the probability of default, recovery rate, etc....

Problems/errors with Investopedia's definition

The Investopedia definition you quoted is flawed because it's missing the critical phrase, "assuming no default." I've seen other sloppy, incomplete, or confused definitions on Investopedia and prefer Wikipedia.

Problems with your statements on the cost of capital

The yield to maturity has an unambiguous, widely agreed upon definition and is easily computable. On the other hand, the cost of capital is a more nebulous concept. Different practitioners or academics often use somewhat different definitions for the cost of capital and estimate these somewhat different notions of the cost of capital in different ways.

If you define the cost of capital as the return expected to be earned by investors, then yield to maturity is not the cost of capital over the period because the yield to maturity ignores the probability of default. (That said, it appears common practice in corporate finance to just ignore default probabilities and use yields as the cost of debt.)