One needs to develop a special algorithm that runs only through the elements of the upper triangular matrix \( \mathbf{g} \) and have \( k \) as an index.
The expression to be derived in the following is of interest when computing the quantum force and the kinetic energy. It has the form
$$ \frac{\mathbf{\nabla}_i\Psi_C}{\Psi_C} = \frac{1}{\Psi_C}\frac{\partial \Psi_C}{\partial x_i}, $$for all dimensions and with \( i \) running over all particles.