# Linear equations with errors

I have a system of $n^2$ homogeneous linear equations in $n^2$ variables. Each equation is sparse and only involves $2n$ variables.

I create a list of equations and use solve(). I only get the "all-zero" solution. This is because of inaccuracies in the equations. I know (from theory) that there is be a nonzero kernel.

So, I'd like to find an approximate solution. That is - a solution of norm 1, which "almost fulfills" the equations. Behind the scenes I probably need the SVD decomposition of the matrix describing the equations (or at least, the input vectors corresponding to the small singular values).

- Do I have to create a matrix to represent the equations, or can I use my equations directly?
- Can it be a sparse matrix?
- Do I have to use an SVD routine, or is there some convenient way to solve my problem directly?
- Do you have an example of how to do it?

Indeed, generic matrices are invertible. Before going further, when you speak about the theory, what sort of real numbers are your entries (the coefficients of your equation) ? Integer, rational, algebraic, real symbolic (like pi+sqrt(2), real numeric (like 0.123) ?

Could you provide your equations or the code you use to create them?

@tmontiel: The numbers are real numeric.

Update: I created a matrix $M$ with rows representing the equations, used M.SVD(), and took the vectors corresponding to the very small singular values. It worked.