Solution (source code)

= Solution

The equation is solvable exactly when $b\in\operatorname{im}A$, the <image of a linear map>, equivalently when the <rank of a matrix> satisfies $\operatorname{rank}A=\operatorname{rank}[A\mid b]$. If it is solvable and $x_0$ is one solution, every solution is precisely
$$
x=x_0+v,\qquad v\in\ker A.
$$
Indeed differences of solutions lie in the <kernel of a linear map>, and adding a kernel <vector> preserves the equation. Hence \b[there are no solutions] when $b\notin\operatorname{im}A$; \b[one solution] when $A$ is invertible; and \b[infinitely many solutions] when $b\in\operatorname{im}A$ and $A$ is singular. In the last case the <rank-nullity theorem> gives a nonzero kernel <vector> $v$, and $x_0+tv$ gives distinct solutions for every real $t$. This proves that a finite number greater than one is impossible.