The formula for convexity is: Convexity = (Σ [ (t^2 + t) * PV(CF_t) ] ) / (P * (1 + YTM)^2), where Σ represents the summation symbol, t is the time period, PV(CF_t) is the present value of the cash flow at time t, P is the bond price, and YTM is the yield to maturity.