Forward kinematics

The point of forward kinematics is to calculate the position of the endpoints on the leg based on the actual state of the robot and its dimensions.

Usually, we are interested in finding the position of the tip point on the leg (the point which touches the ground). Our state is defined as a set of angles for the joints of the leg.

More formally, we are interested in a function f \left( \alpha, \text{Attr} \right) that returns coordinations of the tip of the leg given angles \alpha and a set of attributes for the leg \text{Attr}.

We decided to use a standard cartesian coordinate system to represent points and quaternions to represents rotations in space.

To properly define our context, we define quaternion Q representing the rotation of angle \beta around axis v as follows:

Q &= \left[ \cos \beta/2 , v \sin \beta \right/2] \\
Q &= \cos \beta/2 + i v_x \sin \beta/2 + j v_y \sin \beta/2 + k v_z \sin \beta/2

The rotation of quaternion Q applied to quaternion (or point) X results in X’, which represents X rotated angle \beta around axis v

X' = Q X Q^{-1}

Segment formula

We can devise a specific formula for each type of leg or robot. However, that is impractical for the implementation of the robot. We decided to use one generic formula to define just one segment of the robot’s leg - it represents only one rotational joint and attached linkage. It is expected that leg is composed of multiple different segments. This should cover the majority of the estimated use cases.

This formula is designed in a way, that it can be composed easily to represent the entire leg.

f \left( \text{axis}, \alpha, P, Q, x \right) = P + Q \left[ \cos\alpha/2, \text{axis}\sin\alpha/2 \right] x {\left[ \cos\alpha/2, \text{axis}\sin\alpha/2 \right]}^{-1} Q^{-1}

Formula f represents a segment of leg, that has something attached to it and that is itself attached to something. These attachments represent coordinate system of the segment and coordinate system of what is attached to the segment.

Given that x represents a point in coordinate system relative to what is attached to the segment, the function tranforms the coordinate to the coordinate system of this leg segment. If we transform x=(0,0,0), we specifically get where is the tip of the segment relative to it’s base. Parameters \text{axis}, P, Q represents dimensions of the leg, \alpha is state of the leg.

\text{axis} and \alpha represents the rotational joint of the segment that is present at the end of the segment. Following segments attached to this segment are attached directly to this rotational joint.

P and Q represents offset of the rotational joint from the base of the segment. Key is to realize that rotational joint is rotated by Q and than it is moved by offset P (where P is vector in cartesian coordinate system).

Leg formula

The segments are composed in chain of rotational joints. Except for the last segment, which is just a point relative to it’s base. The coordinate of the point represents tip of the leg, which is point on the model of the leg at which the leg should step on.

g(\alpha_0, \alpha_1, \alpha_2) = f \left( \text{axis}_0, \alpha_0, P_0, Q_0, f \left( \text{axis}_1, \alpha_1, P_1, Q_1, f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)  \right) \right)

Inverse kinematics

The forward kinematics is simple math, what is more problematic is an abillity to get an inverse of the function. In what state the leg has to be, so it’s tip is at position X ?

There are specific formulas to get this solution for simple robotic arms, this get’s however extensively diffcult in case of more complex setups. Given that we want somehow generall code, we decided to find a solution to IK for the segment-based approach we used for the FK.

The simplest algorithm used in literature for this is based on derivation of the FK function - Jacobian. The idea expects that we have an estimate (or starting) position for the solution, and we iterativelly improve are solution for the problem - numeric method.

The numeric methods defines a step of the computation, which is repeated until limit of repetitions is met or the solution is close enough. The step is fairly simple for the basic method:

\alpha_{i+1} = \alpha_{i} + J^{-1}_g(\alpha_i) \left( T - g\left( \alpha_{i} \right) \right)

T represents target point we would like to position the arm at, J is jacobian of the g formula given angles \alpha{i} Note that we are talking about Jacobian which represents derivation by the angles of the leg.

Given that in our case can to analytically found the jacobian for the FK formula, we believe that this is the right approach for us. In the rest of this section, we properly described how we can calculate the jacobian.

At first we show simple derivations for quaternions, in the rest of the document we expand on it to show derivation of the g formula for FK/

derivation of quaternion rotation - rotate by unrelated angle

The idea is to get a derivation by angle \alpha of rotation of two quaternions - X,Q. X is quaternion that represents rotation with angle \alpha around some axis. Q is quaternion that represents rotation unrelated to angle \alpha - we can consider it being arbitrary rotation

We want to prove that following following equation holds:

\frac{\partial}{\partial \alpha} QXQ^{-1} = Q \frac{\partial}{\partial \alpha} \left( X \right) Q^{-1}

Let’s start with simple expansion of original formula:

\frac{\partial}{\partial \alpha} QXQ^{-1} &= \frac{\partial}{\partial \alpha} \left(QX\right)Q^{-1} \\
    &= \left(\frac{\partial}{\partial \alpha}QX\right)Q^{-1} + QX\frac{\partial}{\partial \alpha}Q^{-1}

Given that Q is unrelated to \alpha we can assume derivation of it by \alpha is also zero - right side of the equation is dropped

&= \left(\frac{\partial}{\partial \alpha}QX\right)Q^{-1} \\
&= \left(\left(\frac{\partial}{\partial \alpha} Q \right) X + Q \frac{\partial}{\partial \alpha} X\right)Q^{-1}

In same way as before, we can drop the part that has derivation of Q by \alpha - it has to be zero.

&= \left(  Q \frac{\partial}{\partial \alpha} X \right) Q^{-1} \\
&= Q \left( \frac{\partial}{\partial \alpha} X \right) Q^{-1}

In the and we got to the desired state of equation with stnadard steps - it’s correct.

derivation of one leg segment

At first phase we will devise a derivation of one segment by it’s own angle. Keep in mind that axis,P,Q and x are unrelated to the angle itself.

\frac{\partial}{\partial \alpha} f & \left( \text{axis}, \alpha, P, Q, x \right) \\
    &= \frac{\partial}{\partial \alpha} \left( P + Q \left[ \cos\alpha/2, \text{axis} \sin\alpha/2 \right] x \left[ \cos\alpha/2, \text{axis} \sin\alpha/2 \right]^{-1} Q^{-1} \right)

To simplify this formula, we will introduce substitution that will be used:

W_\alpha &= \left[ \cos \alpha/2, \text{axis}\sin\alpha/2 \right]

W is quaternion that uses angle \alpha which we use for derivation. This simplifies the formula a bit:

\frac{\partial}{\partial \alpha} f \left( \text{axis}, \alpha, P, Q, x \right)
    &= \frac{\partial}{\partial \alpha} P + Q W_\alpha x W_\alpha^{-1}Q^{-1} \\
    &= \frac{\partial}{\partial \alpha} Q W_\alpha x W_\alpha^{-1}Q^{-1}

Given the rule about derivation of quaternions rotations described above, we can make one step for free.

\frac{\partial}{\partial \alpha} f \left( \text{axis}, \alpha, P, Q, x \right)
    &= Q \left( \frac{\partial}{\partial \alpha} W_\alpha x W_\alpha^{-1} \right)Q^{-1}

To continue the work on this, let’s process only the inner part of the equation:

\frac{\partial}{\partial \alpha} W_\alpha x W_\alpha^{-1}
    &= \frac{\partial}{\partial \alpha} \left( W_\alpha x\right)W_\alpha^{-1} \\
    &= \left( \frac{\partial}{\partial \alpha} W_\alpha x \right) W_\alpha^{-1} + W_\alpha x \frac{\partial}{\partial \alpha} W_\alpha^{-1}

In this equation, we are now only interested in the left part in summation, as that is the last problematic thing. We also want to only focus on the left part of the multiplication, as the right one is trivial.

\frac{\partial}{\partial \alpha} W_\alpha x
   &= \left( \frac{\partial}{\partial \alpha} W_\alpha \right)x + W_\alpha \frac{\partial}{\partial \alpha} x

Here we know that derivation of x by \alpha is zero, as the x is unrelated to that angle. This implies that the right side of the sum is 0, so we can simplify:

\frac{\partial}{\partial \alpha} \left( W_\alpha x \right)
   &= \left( \frac{\partial}{\partial \alpha} W_\alpha \right)x

Rewind

\frac{\partial}{\partial \alpha} f \left( \text{axis}, \alpha, P, Q, x \right)
    &= \frac{\partial}{\partial \alpha} P + Q W_\alpha x W_\alpha^{-1}Q^{-1} \\
    &= Q \left( \frac{\partial}{\partial \alpha} W_\alpha x W_\alpha^{-1} \right)Q^{-1} \\
    &= Q \left( \left( \frac{\partial}{\partial \alpha} W_\alpha x \right) W_\alpha^{-1} + W_\alpha x \frac{\partial}{\partial \alpha} W_\alpha^{-1} \right) Q^{-1} \\
    &= Q \left( \left( \frac{\partial}{\partial \alpha} W_\alpha \right)x W_\alpha^{-1} + W_\alpha x \frac{\partial}{\partial \alpha} W_\alpha^{-1} \right) Q^{-1}

This gives us our desired reslt:

W_\alpha &= \left[ \cos \alpha/2, \text{axis}\sin\alpha/2 \right] \\
\frac{\partial}{\partial \alpha} f \left( \text{axis}, \alpha, P, Q, x \right)
    &= Q \left( \left( \frac{\partial}{\partial \alpha} W_\alpha \right)xW_\alpha^{-1} + \left(W_\alpha x\right) \frac{\partial}{\partial \alpha} W_\alpha^{-1} \right) Q^{-1}

derivation of FK for specific leg

At first phase, let’s define how FK for some specific leg looks, 3DOF:

g(\alpha_0, \alpha_1, \alpha_2) =
    f \left( \text{axis}_0, \alpha_0, P_0, Q_0,
        f \left( \text{axis}_1, \alpha_1, P_1, Q_1,
            f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)  \right) \right)

The jacobian - derivation of this equation is defined as follows:

\frac{\partial}{\partial \alpha} g \left( \alpha \right) = \left(
    \frac{\partial}{\partial \alpha_0} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_1} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_2} g \left( \alpha \right)
\right)

We will solve this for each derivation separatedly, idea is that if we solve this on equation of specific leg, we can abstract it for more general case.

derive by \alpha_0

The equation for the first derivation looks like this:

\frac{\partial}{\partial \alpha_0} g (\alpha_0, \alpha_1, \alpha_2) =
    \frac{\partial}{\partial \alpha_0}
    f \left( \text{axis}_0, \alpha_0, P_0, Q_0,
        f \left( \text{axis}_1, \alpha_1, P_1, Q_1,
            f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)  \right) \right)

As first step, we use substitution for the recursive calls, keep in mind that they do not contain \alpha_0 - we do not have to derivate them, derivation is zero. This fullfills our original assumption about x.

x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1,
            f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)
        \right) \\
\frac{\partial}{\partial \alpha_0} g (\alpha_0, \alpha_1, \alpha_2) &=
   \frac{\partial}{\partial \alpha_0}
    f \left( \text{axis}_0, \alpha_0, P_0, Q_0, x_0 \right)

Given that we know the result:

x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1,
            f \left( \text{axis}_2, \alpha_2, P_2, Q_2, (0,0,0) \right)
        \right) \\
W_{\alpha_0} &= \left[ \cos \alpha_0/2, \text{axis}_0 \sin\alpha_0/2 \right] \\
\frac{\partial}{\partial \alpha_0} g \left( \alpha_0, \alpha_1, \alpha_2 \right)
    &= Q_0 \left( \left( \frac{\partial}{\partial \alpha_0} W_{\alpha_0} \right) x_0 W_{\alpha_0}^{-1} + \left(W_{\alpha_0} x_0 \right) \frac{\partial}{\partial \alpha} W_{\alpha_0}^{-1} \right) Q_0^{-1}

derive by \alpha_1

The equation for the second derivation looks like this:

\frac{\partial}{\partial \alpha_1} g (\alpha_0, \alpha_1, \alpha_2) =
    \frac{\partial}{\partial \alpha_0}
    f \left( \text{axis}_0, \alpha_0, P_0, Q_0,
        f \left( \text{axis}_1, \alpha_1, P_1, Q_1,
            f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)  \right) \right)

For analysis of this equation, we will work with Y_0 and W_0 substitutions for the f function:

x_1 &= f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right) \\
x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \\
W_{\alpha_0} &= \left[ \cos \alpha_0 / 2, \text{axis}_0 \sin \alpha_0 / 2 \right] \\

\frac{\partial}{\partial \alpha_1} g (\alpha_0, \alpha_1, \alpha_2)
    &= \frac{\partial}{\partial \alpha_1} f \left( \text{axis}_0, \alpha_0, P_0, Q_0, x_0 \right)  \\
    &= \frac{\partial}{\partial \alpha_1} \left( P_0 + Q_0 W_{\alpha_0} x_0 W_{\alpha_0}^{-1}Q_0^{-1}  \right) \\
    &= \frac{\partial}{\partial \alpha_1} \left( Q_0 W_{\alpha_0} x_0 W_{\alpha_0}^{-1}Q_0^{-1}  \right)

We know that W_{\alpha_0} depends on \alpha_0, but we derive by \alpha_1 so we can work with W_{\alpha_0} as constant. This implies:

\frac{\partial}{\partial \alpha_1} g (\alpha_0, \alpha_1, \alpha_2)
    &= \frac{\partial}{\partial \alpha_1} \left( Q_0 W_{\alpha_0} x_0 W_{\alpha_0}^{-1}Q_0^{-1}  \right) \\
    &= Q_0 \frac{\partial}{\partial \alpha_1} \left( W_{\alpha_0} x_0 W_{\alpha_0}^{-1}  \right) Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_1} x_0 \right) W_{\alpha_0}^{-1}  Q_0^{-1}

This way we solved how first segments affects the rest of the equation in the derivation. Let’s revert the x_0 substitution:

\frac{\partial}{\partial \alpha_1} g (\alpha_0, \alpha_1, \alpha_2)
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_1} x_0 \right) W_{\alpha_0}^{-1}  Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_1} f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \right)  W_{\alpha_0}^{-1} Q_0^{-1}

This however is exactly the same as for derivation of the recursive functions by \alpha_0, so we can use same results:

W_{\alpha_1} &= \left[ \cos \alpha_1/2, \text{axis}_1 \sin\alpha_1/2 \right] \\
\frac{\partial}{\partial \alpha_1} f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right)
    &= Q_1 \left( \left( \frac{\partial}{\partial \alpha_1} W_{\alpha_1} \right) x_1 W_{\alpha_1}^{-1} + \left(W_{\alpha_1} x_1 \right) \frac{\partial}{\partial \alpha} W_{\alpha_1}^{-1} \right) Q_1^{-1}

Combined together, we get the final result for this formula:

x_1 &= f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right) \\
x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \\
W_{\alpha_0} &= \left[ \cos \alpha_0 /2, \text{axis}_0 \sin\alpha_0 /2 \right] \\
W_{\alpha_1} &= \left[ \cos \alpha_1 /2, \text{axis}_1 \sin\alpha_1 /2 \right] \\

\frac{\partial}{\partial \alpha_1} g (\alpha_0, \alpha_1, \alpha_2)
    &= \frac{\partial}{\partial \alpha_1} f \left( \text{axis}_0, \alpha_0, P_0, Q_0, x_0 \right)  \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_1} x_0 \right) W_{\alpha_0}^{-1}  Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_1} f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \right)  W_{\alpha_0}^{-1} Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}
         Q_1 \left( \left( \frac{\partial}{\partial \alpha_1} W_{\alpha_1} \right) x_1 W_{\alpha_1}^{-1} + \left(W_{\alpha_1} x_1 \right) \frac{\partial}{\partial \alpha} W_{\alpha_1}^{-1} \right) Q_1^{-1}
    W_{\alpha_0}^{-1} Q_0^{-1}

derive by \alpha_2

This would be repetitive calculations as in derivation for \alpha_1, the key principles are same, we just go “deeper”.

x_1 &= f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right) \\
x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \\
W_{\alpha_0} &= \left[ \cos \alpha_0/2, \text{axis}_0 \sin\alpha_0/2 \right] \\
W_{\alpha_1} &= \left[ \cos \alpha_1/2, \text{axis}_1 \sin\alpha_1/2 \right] \\
W_{\alpha_2} &= \left[ \cos \alpha_2/2, \text{axis}_2 \sin\alpha_2/2 \right] \\

\frac{\partial}{\partial \alpha_2} g (\alpha_0, \alpha_1, \alpha_2)
    &= \frac{\partial}{\partial \alpha_2} f \left( \text{axis}_0, \alpha_0, P_0, Q_0, x_0 \right)  \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_2} x_0 \right) W_{\alpha_0}^{-1}  Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}  \left( \frac{\partial}{\partial \alpha_2} f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \right)  W_{\alpha_0}^{-1} Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}   Q_1 W_{\alpha_1}  \left( \frac{\partial}{\partial \alpha_2} x_1 \right) W_{\alpha_1}^{-1}  Q_1^{-1} W_{\alpha_0}^{-1} Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}   Q_1 W_{\alpha_1}  \left( \frac{\partial}{\partial \alpha_2} f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right)  \right) W_{\alpha_1}^{-1}  Q_1^{-1} W_{\alpha_0}^{-1} Q_0^{-1} \\
    &= Q_0 W_{\alpha_0}   Q_1 W_{\alpha_1}
         Q_2 \left( \left( \frac{\partial}{\partial \alpha_2} W_{\alpha_2} \right) P_3 W_{\alpha_2}^{-1} + \left(W_{\alpha_2} P_3 \right) \frac{\partial}{\partial \alpha} W_{\alpha_2}^{-1} \right) Q_2^{-1}
    W_{\alpha_1}^{-1}  Q_1^{-1} W_{\alpha_0}^{-1} Q_0^{-1}

combined togehter

We are now able to combine previous results into the final equation:

x_1 &= f \left( \text{axis}_2, \alpha_2, P_2, Q_2, P_3 \right) \\
x_0 &=  f \left( \text{axis}_1, \alpha_1, P_1, Q_1, x_1 \right) \\
W_{\alpha_0} &= \left[ \cos \alpha_0/2, \text{axis}_0 \sin\alpha_0/2 \right] \\
W_{\alpha_1} &= \left[ \cos \alpha_1/2, \text{axis}_1 \sin\alpha_1/2 \right] \\
W_{\alpha_2} &= \left[ \cos \alpha_2/2, \text{axis}_2 \sin\alpha_2/2 \right] \\

\frac{\partial}{\partial \alpha} g \left( \alpha \right) &= \left(
    \frac{\partial}{\partial \alpha_0} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_1} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_2} g \left( \alpha \right)
\right) \\
&= ( \\
    & Q_0 \left( \left( \frac{\partial}{\partial \alpha_0} W_{\alpha_0} \right) x_0 W_{\alpha_0}^{-1} + \left(W_{\alpha_0} x_0 \right) \frac{\partial}{\partial \alpha} W_{\alpha_0}^{-1} \right) Q_0^{-1}, \\
    & Q_0 W_{\alpha_0}
         Q_1 \left( \left( \frac{\partial}{\partial \alpha_1} W_{\alpha_1} \right) x_1 W_{\alpha_1}^{-1} + \left(W_{\alpha_1} x_1 \right) \frac{\partial}{\partial \alpha} W_{\alpha_1}^{-1} \right) Q_1^{-1}
    W_{\alpha_0}^{-1} Q_0^{-1}, \\
    & Q_0 W_{\alpha_0}   Q_1 W_{\alpha_1}
         Q_2 \left( \left( \frac{\partial}{\partial \alpha_2} W_{\alpha_2} \right) P_3 W_{\alpha_2}^{-1} + \left(W_{\alpha_2} P_3 \right) \frac{\partial}{\partial \alpha} W_{\alpha_2}^{-1} \right) Q_2^{-1}
    W_{\alpha_1}^{-1}  Q_1^{-1} W_{\alpha_0}^{-1} Q_0^{-1} \\
    &)

We are now even able to write this calculation as generic formula, as the pattern is quite obvious here.

implementation

Implementation wise, it is cruical to realize how the code works. In our case we want to load model of the robot at start of the application, and query it for solutions to IK for some set of angles.

This implies that \text{axis}_i, \alpha_i, P_i, Q_i are not known compile time, but are known when the application starts. Only thing that changes are the angles and desired point of end-effector.

In combined together, the final computation of derivation of g is based on W_i,Q_i,P_i variables, out of which only W_i can be computed at compile time.

Given that multiplication of quaternions is associative, we will define two new variables:

L_0 &= Q_0 \\
L_i &= L_{i-1} W_{\alpha_{i-1}} Q_{i} \\
\\
R_0 &= Q_0^{-1} \\
R_i &= Q_i^{-1} W_{\alpha_{i-1}}^{-1} R_{i-1}

These represent the recursive rotations that occur in derivation of g. That equation is now:

\frac{\partial}{\partial \alpha} g \left( \alpha \right) &= \left(
    \frac{\partial}{\partial \alpha_0} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_1} g \left( \alpha \right),
    \frac{\partial}{\partial \alpha_2} g \left( \alpha \right)
\right) \\
&= ( \\
    & L_0 \left( \left( \frac{\partial}{\partial \alpha_0} W_{\alpha_0} \right) x_0 W_{\alpha_0}^{-1} + \left(W_{\alpha_0} x_0 \right) \frac{\partial}{\partial \alpha} W_{\alpha_0}^{-1} \right) R_0, \\
    & L_1 \left( \left( \frac{\partial}{\partial \alpha_1} W_{\alpha_1} \right) x_1 W_{\alpha_1}^{-1} + \left(W_{\alpha_1} x_1 \right) \frac{\partial}{\partial \alpha} W_{\alpha_1}^{-1} \right) R_1, \\
    & L_2 \left( \left( \frac{\partial}{\partial \alpha_2} W_{\alpha_2} \right) P_3 W_{\alpha_2}^{-1} + \left(W_{\alpha_2} P_3 \right) \frac{\partial}{\partial \alpha} W_{\alpha_2}^{-1} \right) R_2 \\
    &) \\
&= ( \\
    & L_0 \left( \left( \frac{\partial}{\partial \alpha_0} W_{\alpha_0} \right) x_0 W_{\alpha_0}^{-1} + \left(W_{\alpha_0} x_0 \right) \frac{\partial}{\partial \alpha} W_{\alpha_0}^{-1} \right) R_0, \\
    &\ldots, \\
    & L_i \left( \left( \frac{\partial}{\partial \alpha_i} W_{\alpha_i} \right) x_i W_{\alpha_i}^{-1} + \left(W_{\alpha_i} x_i \right) \frac{\partial}{\partial \alpha} W_{\alpha_i}^{-1} \right) R_i \\
    &)

The following list represents order of operations to solve the equation calculated above:

  1. W_{\alpha_i}, W_{\alpha_i}^-1, \frac{\partial}{\partial \alpha_1}W_{\alpha_i}, \frac{\partial}{\partial \alpha_1}W_{\alpha_i}^-r
  2. x_{i-1} = P_i + Q_i W_{\alpha_i} x_i W_{\alpha_i}^{-1}Q_i^{-1}
  3. process 1./2. for all indexes in descending order
  4. L_i
  5. R_i
  6. process 3./4. for all indexes in ascending order
  7. For all indexes: L_i \left( \left( \frac{\partial}{\partial \alpha_i} W_{\alpha_i} \right) x_i W_{\alpha_i}^{-1} + \left(W_{\alpha_i} x_i \right) \frac{\partial}{\partial \alpha} W_{\alpha_i}^{-1} \right) R_i