# How can two matrices cancel each other out when there is a matrix in between?

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?

• Dividing by matrices is completely insane (undefined) in every context I'm aware of, FYI. It might be a misunderstanding. Are we sure these are not dot products, or something of that nature? Jan 18, 2017 at 2:57
• I believe the (A^T)A on the denominator is also interpreted as (A^T)A inverse. Jan 18, 2017 at 3:44
• The term on the right doesn’t look right for another reason: If $A$ is a matrix and $b$ a column vector the product $bA$ doesn’t make much sense, either. Also, are $B$ and $b$ meant to be the same object? I’m with @TheCount: if this is about the Gram-Schmidt process, then all of the variables in your question are likely vectors. If so, then $A^TA$ is a scalar (well, a $1\times1$ matrix, which you can treat as a scalar most of the time), so you can move it around and divide by it all you like.
– amd
Jan 18, 2017 at 7:40
• @eriche the problem with that interpretation is that it doesn't specify if the inverse is supposed to be on the right or on the left of the expression:)
– Ant
Jan 18, 2017 at 12:09 Note that $\mathrm A, \mathrm B$ are vectors, not matrices!! In other words, the question makes no sense whatsoever.