# Divide matrix using left division

In matlab, I defined

a=[1;2;3]
b=[4;5;6]

both a and b are not square matrix.

and execute a\b will return 2.2857

From various sources, we understand that a\b ~= inv(a)*b, but in my case, a is not a square matrix, thus we can't perform an inverse operation on it.

I am actually translating matlab code to c#, and I need to know how do left division between non-square matrix calculated.

Thanks!

In Matlab $a$\ $b =(a'a)^{-1}a'b$, i.e. $b$ is projected onto $a$.
A little bit more information: Consider, $$b \approx ax$$ where $x$ is unknown and there are no exact solutions i.e. $b$ and $a$ have many rows and few columns, then the typical way to solve this problem is to solve for $x$ by projecting $b$ onto $a$ or by taking the point on the space $a$, which is closest to be i.e. $b \approx P_ab=a(a'a)^{-1}a'b=ax$.