I'm watching videos of Gilbert Strang's linear algebra lectures. In lecture 17, where he goes over orthonormal bases and the Gram-Schmidt process, he proves
$$ A^TB = A^T\left( b - \frac{A^Tb} {(A^TA)} A\right) = 0 $$
by having
$$ A^T \frac{A^Tb} {(A^TA)} A $$ cancel out into ATb. I don't know how the ATA on the top was allowed to cancel out with the ATA on the bottom if there is an ATb sandwiched in between the AT and the A on the numerator. Shouldn't the AT and the A on the numerator not be allowed to multiply each other?
I wondered if the AT on the numerator can cancel out with the AT on the denominator and the same for the two A's, but I do not know if this violates the order of operations for matrix multiplication. If I were to write (ATA)-1 rather than have the (ATA) on the denominator below the (ATb), where would it go?