Just do x = A \ b
— it gives you the minimum-norm solution by default when A
has more columns than rows. If you need to solve a sequence of right-hand sides for the same A
, use the pivoted QR factorization:
QR = qr(A, Val(true))
x = QR \ b
If you search discourse for “minimum norm” you will find more discussions of these topics.