# Derivation of convexity formula

Let's say that I have a bond that pays coupon on a semi-annual basis. Therefore, the price of this bond can be calculated using the following formula:

$$P = \sum_{i=1}^N \frac{CF_i}{(1 + YTM/2)^{2t_i}}$$

First derivative of the above is:

$$\frac{\partial P}{\partial YTM} = \frac{1}{(1 + YTM/2)} \sum_{i=1}^N \frac{-2t_iCF_i}{(1 + YTM/2)^{2t_i}}$$

Second derivative (aka convexity) of the Price function is:

$$\frac{\partial^2 P}{\partial YTM} = \frac{1}{(1 + YTM/2)^2} \sum_{i=1}^N \frac{({4t_i}^2+2t_i)CF_i}{(1 + YTM/2)^{2t_i}}$$

And the generalized form of the convexity formula for bonds that pay multiple coupons per year is:

$$\frac{\partial^2 P}{\partial YTM} = \frac{1}{(1 + YTM/f)^2} \sum_{i=1}^N \frac{({(ft_i)}^2+ft_i)CF_i/f}{(1 + YTM/f)^{ft_i}}$$

I am getting slightly different results when I compare my results with Bionic Turtle. Is there any mistake in my derivation?

Thank you!

• Your starting formula for $P$ should be $P=\sum_{t=1}^{2T}\frac{Coupon/2}{(1+YTM/2)^{t}}+\frac{100}{(1+YTM/2)^{2T}}$ – noob2 Nov 20 '17 at 15:16
• You left out one term (the face value) and you are not "stepping" the exponent in the denominator of the 1st term correctly. – noob2 Nov 20 '17 at 15:18
• I just made some modifications to avoid the confusion regarding the Face Value -- let's call all the receivables cash flow ($CF_i$). But I am still not too sure about the time periods that are used ... – AK88 Nov 21 '17 at 3:30

First derivative should be: $$\frac{\partial P}{\partial YTM} = \frac{1}{2(1+YTM/2)} \sum_{i=1}^N \frac{-2 t_i CF_i}{(1+YTM/2)^{2 t_i}}$$
Second derivative should be: $$\frac{\partial^2 P}{\partial YTM^2} = \frac{1}{4(1+YTM/2)^2} \sum_{i=1}^N \frac{(4 t_i^2 + 2t_i) CF_i}{(1+YTM/2)^{2 t_i}}$$
With the "f" instead of "2": $$\frac{\partial^2 P}{\partial YTM^2} = \frac{1}{f^2(1+YTM/f)^2} \sum_{i=1}^N \frac{(( f t_i)^2 + f t_i) CF_i}{(1+YTM/f)^{2 t_i}}$$