Yield to maturity is calculated using the trial and error method by substituting different rates into the current value part of the formula. The investor arrives at the correct YTM when the price equals the security's current market price.