A bond's yield to maturity, or YTM, is the annual rate of return you'll receive if you hold a bond until it matures.
Governmental entities and corporations issue bonds as a way to borrow money. The investor surrenders the bond and receives a preset amount  the bond's face value  from the issuer on the maturity date. Regular bonds pay periodic interest at a fixed rate. Because the interest is fixed, the price of the bond must adjust so the YTM equals the current prevailing interest rate demanded by investors in similar bonds. Prices are inversely related to YTM: The higher the price, the lower the YTM.
Assumptions
The calculation of YTM is accurate only if certain assumptions hold:

The investor will hold the bond until it matures.

The issuer will shell out all interest and principal payments in full and on time.

The investor will reinvest the received interest payments at the YTM rate.
 The calculation does not include the effects of taxes and commissions.
Accurate values for YTM allow investors to compare a bond's return to that of other investments.
Warning

Some experts dispute the assumption that interest payments must be reinvested at the YTM rate.
Present Value
Present value is used in the YTM calculation to account for the time value of money. Money you have now is worth more than money you receive later, because it doesn't risk nonpayment, it can earn interest and it doesn't suffer from inflation, which reduces the buying power of money. Present value uses a discount rate to cut the value of future cash flows, such as interest and principal payments, to equal an equivalent amount received immediately. YTM is the discount rate that sets the present value of the bond equal to its current price.
YTM Factors
The factors you need to calculate YTM are:

Settlement date: The starting date for the calculation, normally the day on which you did or would take ownership of the bond.

Maturity: The date upon which the bond matures.

Rate: The annual interest rate of the bond.

Price per $100 face: The price of the security, expressed in units of $100 face value. For example, if the price of a bond with a $1,000 face value is $1,020, divide the price by ($1,000/$100) to get a price per $100 face, equal to $102.

Redemption value: The face value expressed in $100 units. For example a bond with a $1,000 face is divided by ($1,000/$100) to get a redemption value of $100,
 Frequency: The number of interest payments per year.
Solving with Excel
Trying to solve the equation "by hand" would be a tedious guessing game. You plug a discount rate into the present value calculation of the bond's cash flows and compare the result to the bond's current market price. You have to repeat the procedure with different discount rates until you find one that provides a good match to the market price; this is the approximate YTM.
Excel software makes things easier. You simply enter the YTM factors into the YIELD function on the "Formula" menu to get the YTM. You may have to adjust another optional factor called basis, which is the convention the bond uses to express the number of days in a month and year.