# [Numpy-discussion] Problem in LinearAlgebra? A solution?

Tue Nov 4 02:21:05 CST 2003

```The condition of the matrix is about 1.0E7 and its dimensions are
10000x36: This is not a stable linear system, at least not for a simple
solvers. Thus, I estimate that the solver is not of a high quality, but
not buggy either.

But the solution to the polynomial fit turns to be much simpler:
In the "fitPolynomial" function the 5th and the 4th lines before the end
are commented. These lines uses the "generalized_inverse" procedure to
solve the set of equations. just uncomment these lines and comment the
two lines the follows, thats it. The solution to the 5x5 fit now seems
OK at the first glance.

On Mon, 2003-11-03 at 15:47, Konrad Hinsen wrote:
> On Sunday 02 November 2003 14:21, Nadav Horesh wrote:
>
> >       * Polynomials fit is relatively very simple --- you may write one
> >         of you own in less then a one day work. Since, as I said, the
> >         problem is, in many cases, unstable, you'll have the chance to
> >         implement more stable linear-equation solvers.
>
> The polynomial fit is indeed simple, and the routine from ScientificPython
> that Rob uses is only 20 lines long, most of that for error checking and
> setting up the arrays describing the system of linear equations.
>
> Looking at the singular values in Rob's problem, I see no evidence for the
> problem being particularly unstable. The singular values range from 1e-6 to
> 1, that should not pose any problem at double precision. Moreover, for a
> lower-order fit that gives reasonable results, the range is only slightly
> smaller. So I do suspect that something goes wrong in linear_least_squares.
>