## 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

\begin{equation}

f(x) = l

\end{equation}

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

\begin{equation}

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

\end{equation}

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

\begin{equation}

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

\end{equation}

To solve this problem, let us define a new function

\begin{equation}

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

\end{equation}

where

\begin{equation}

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

\end{equation}

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

\begin{equation}

\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}}

\end{equation}

We now solve the two derivatives separately, the first being

\begin{equation}

\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}

\end{equation}

and the second

\begin{equation}

\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}}

\end{equation}

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

\begin{equation}

\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)

\end{equation}

so that finally

\begin{equation}

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

\end{equation}

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

\begin{equation}

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

\end{equation}

so only the sign differs.