speed up derivative_W_sparse