## Gradient of length

Have you seen our new book, Shell Structures for Architecture: Form finding and optimization? It has been co-edited with Sigrid Adriaenssens and Chris Williams, and features 37 authors from around the globe, both from practice and academia. You can order the book here.

In Chapter 6: Force Density Method by Prof. Em. Klaus Linkwitz, this well-known form-finding method is explained in thorough detail. However, page 64, eq. (6.23) simply gives the gradient of four branch lengths relative to the coordinates of their shared node. Here, we provide some additional detail on how the result of that equation is derived.

Eq. (6.22) defines a vector of four functions, each being the length of one branch

f(x) = l

The length is defined earlier in eq. (6.2):

l = \sqrt{(x_k-x_0)^2+(z_k-z_0)^2+(z_k-z_0)^2}

We wish to derive the gradient of the length w.r.t. the coordinate at point zero:

\frac{\partial{l}}{\partial{x_0}} = \frac{\partial{f(x)}}{\partial{x_0}}

To solve this problem, let us define a new function

f(x) = \sqrt{g(x)}

where

g(x) = (x_k-x_0)^2+(z_k-z_0)^2+(z_k-z_0)^2

Our gradient can now be expressed differently, and using the chain rule

\frac{\partial{f(x)}}{\partial{x_0}} = \frac{\partial{\sqrt{g(x)}}}{\partial{x_0}} = \frac{\partial{\sqrt{g(x)}}}{\partial{g}} \frac{\partial{g}}{\partial{x_0}}

We now solve the two derivatives separately, the first being

\frac{\partial{\sqrt{g(x)}}}{\partial{g}} = \frac{\partial{g^{1/2}}}{\partial{g}} = \frac{1}{2} g^{-1/2} = \frac{1}{2\sqrt{g}} = \frac{1}{2l}

and the second

\frac{\partial{g}}{\partial{x_0}} = \frac{\partial{((x_k-x_0)^2+(z_k-z_0)^2+(z_k-z_0)^2)}}{\partial{x_0}}

if I expand the first term (and for convenience already drop the terms in y- and z-directions)

\frac{\partial{g}}{\partial{x_0}} = \frac{\partial{(x_k^2-2x_{k}x_0+x_0^2)}}{\partial{x_0}} = -2x_k+2x_0 = -2(x_k-x_0)

so that finally

\frac{\partial{f(x)}}{\partial{x_0}} = \frac{1}{2l} \cdot -2(x_k-x_0) = -\frac{x_k-x_0}{l}

which appears in the answer of eq. (6.23) in our book. These are often called direction cosines, which we now see are the gradient of length w.r.t. coordinates. Had we taken the derivative w.r.t. the other node k, then

\frac{\partial{f(x)}}{\partial{x_k}} = \frac{1}{2l} \cdot 2(x_k-x_0) = \frac{x_k-x_0}{l}

so only the sign differs.