# How can I solve $Ax=y$ for nonsquare matrix $A$.

Say I have some nonsquare matrix $A$ and a vector $y$, how can I solve $Ax=y$? If $A$ was square, it would be simply $A^{-1}y=x$, but you can't invert a nonsquare matrix.

• What about gaussian elimination? – Javi Apr 16 '18 at 19:06
• Even if $A$ is square it need not be invertible. As Javi says Gaussian elimination is a standard way to solve any matrix equation $Ax=y$. – Dave Apr 16 '18 at 19:08
• If $A\mathbf{x}=\mathbf{b}$ admits one and only one solution, then you can prove that $A^{\top}A$ is invertible. Hence $\mathbf{x}=\left(A^{\top}A\right)^{-1}A^{\top}\mathbf{b}$. If $A\mathbf{x}=\mathbf{b}$ has infinitely many solution, I am afraid there is no explicit form for the general solution... – hypernova Apr 16 '18 at 19:10
• You have two completely different cases, according to the fact that $A$ is portrait or landscape (do you know these terms : more lines than columns for portrait, the contrary for lanscape ?). If $A$ is portrait, you have more constraints (equations) than you have unknowns : thus, in general, there are no solutions, unless you are in particular cases. On the contrary, for a landscape matrix, mith $n$ lines and $m$ columns $m>n$, you will have in general a solution depending for exemple on the $m-n$ ($m$ minus $n$) remaining unknowns. – Jean Marie Apr 16 '18 at 19:12
• @AlexLostado: You are right. That is why I mentioned "if $A\mathbb{x}=\mathbb{b}$ admits one and only one solution". If otherwise, this applies to the least square problem only. In addition, if $A\mathbb{x}=\mathbb{b}$ admits no solution, $A^{\top}A$ could also be singular, so it is hard to say that this formulation applies in general. – hypernova Apr 16 '18 at 19:24

In general, you can't invert (square) matrices. Look up "Properties of Invertible Matrices" to see what conditions must be satisfied for a matrix to be invertible.

A matrix has to be square to b e invertible, but this does not necessarily hold the other way around.

Gaussian elimination is, I would say, the most used process to determine solutions to the equation

$$A \mathbf{x} = \mathbf{b}$$

where:

$A$ is an $m \times n$ matrix, also written as $A_{m \times n}$ or $A \in \mathbb{M}^{m \times n}$

$\mathbf x$ is an $n \times 1$ vector, also written as $\mathbf{x} \in \mathbb{R}^n$

$\mathbf{b}$ is a $m \times 1$ vector, also written as $\mathbf{b} \in \mathbb{R}^m$