# Closed form for duration formula

so I was trying to prove this closed form for bond duration formula: D=1+$$\frac{1}{r}$$ + $$\frac{T(r-c)-(1+r)}{c((1+r)^T-1)+r}$$ where r- yield to maturity, c-coupon rate,T-time to maturity. I made some steps and got to the expression: 1+$$\frac{1}{r}$$ $$-(1+r)× \frac{cT(1+r)^{-T-1} +(1+r)^{-T} -rT(1+r)^{-T-1}}{c(1-(1+r)^{-T}) +r(1+r)^{-T}}$$ . So how I should get closed-form equation from this expression? I tried several ways how to simplify it, but always faced a problem to factor out $$(1+r)^{-T}$$in denominator. Do you have any ideas? Thanks in advance.

$$1 + \cfrac1r - (1+r) \cdot \cfrac{cT(1+r)^{-T-1} +(1+r)^{-T} -rT(1+r)^{-T-1}}{c(1-(1+r)^{-T}) +r(1+r)^{-T}} \\ = 1 + \cfrac1r - (1+r) \cdot \cfrac{cT(1+r)^{-T-1} +(1+r)^{-T} -rT(1+r)^{-T-1}}{c-c(1+r)^{-T} +r(1+r)^{-T}} \cdot \cfrac{(1+r)^T}{(1+r)^T} \\ = 1 + \cfrac1r - (1+r) \cdot \cfrac{cT(1+r)^{-1} +1 -rT(1+r)^{-1}}{c(1+r)^T-c +r} \\ = 1 + \cfrac1r - \cfrac{cT +(1+r) -rT}{c(1+r)^T-c +r} \\ = 1 + \cfrac1r + \cfrac{T(r-c) -(1+r) }{c((1+r)^T-1) +r}$$