Let
$$ d_{a}=\frac{1}{n}\sum_{i=1}^{n-1}d_{i}, $$
be the average length of the polyline given by vertices $(p_{1},...,p_{n})$ where $p_{i}=[x_{i},y_{i}]$ and $d_{i}=\left\Vert p_{i+1}-p_{i}\right\Vert _{2}$.
Let $\mathbf{x}$, (n,1) and $\mathbf{y}$, (n,1) be the column vectors, $\mathbf{\delta}=[1,...,1]$, (1,n-1), and
$$ \mathbf{D}=\left[\begin{array}{ccccccc} -1 & 1 & 0 & \cdots & 0 & 0 & 0\\ 0 & -1 & 1 & \cdots & 0 & 0 & 0\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ 0 & 0 & 0 & \cdots & -1 & 1 & 0\\ 0 & 0 & 0 & \cdots & 0 & -1 & 1 \end{array}\right] $$ be the difference matrix. In the matrix form, the formula can be rewritten using the Hadamard product as $$ d_{a}=\frac{1}{n}\mathbf{\delta}(diag(\mathbf{D}\mathbf{x})\mathbf{D}\mathbf{x}+diag(\mathbf{D}\mathbf{y})\mathbf{D}\mathbf{y})^{1/2}. $$ Are the partial derivatives $$ \frac{\partial d_{a}}{\mathbf{x}}=\frac{1}{n}\mathbf{\delta\mathit{(2}\mathbf{D}\delta^{\mathrm{\mathit{T}}}\mathbf{D}\mathbf{x}d^{\prime})}, $$ $$ \frac{\partial d_{a}}{\mathbf{y}}=\frac{1}{n}\mathbf{\delta\mathit{(2}\mathbf{D}\delta^{\mathrm{\mathit{T}}}\mathbf{D}yd^{\prime})}, $$ where $(\mathbf{d}^{\prime})^{T}=[1/d_{1},....,1/d_{n}]$ correct?
Thank you very much for your help.