I have a square matrix $A\in\mathbb{R}^{n\times n}$, it has a LU decomposition. $L$ and $U$ are triangular and $L$ has ones on the main diagonal.
I'm counting the number of operations for $(U^TL^TLU)\mathbf{x} = \mathbf{b}$, which is $A^TA\mathbf{x} = \mathbf{b}$.
What is the correct number of operations for this system? There are two back and two forward substitutions in the process as one can solve this as
$$U^T \mathbf{x_1}=\mathbf{b}\quad (1)$$ $$L^T \mathbf{x_2}=\mathbf{x_1}\quad (2)$$ $$L \mathbf{x_3}=\mathbf{x_2}\quad (3)$$ $$U \mathbf{x_4}=\mathbf{x_3}\quad (4)$$
where $\mathbf{x_4} = \mathbf{x}$.
My solutions are $n^2-n$ for solving equations 2 and 3 (because of ones on the diagonal) and $n^2$ for 1 and 4, that equals $2(n^2-n)+2n^2$ operations.
But the official solution to this problem is $2n^2$. what am I doing wrong?
I count operations like this, for example $$(k_1\cdot\alpha + k_2\cdot\beta) + \gamma = \delta$$ does two multiplications and two summations, therefore four operations to calculate $\delta$.