
I am not sure how to derive from the second line to the third line, the best derivation I got is sum_{i, j} ui ortho(uj - ui). Also, if the third line is correct since the two vectors multiplied are orthogonal to each other, which leads the result to 0.