Re: How to invert the sigular matrix.



"saowalak saengkae" <saengkae@xxxxxxxxxxx> wrote in message <hf4qv9$frb$1@xxxxxxxxxxxxxxxxxx>...
I want to inverse singular matrix (9x9 or 16x16) which was created from polynomial fuction. I know that it is impossible to invesre directly and althought I try to change the order of polynomail, I still can not get the answer or get just the approximated value as the matlab show:
"Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 2.124003e-018."

While pinv will solve the symptoms, it will not
actually solve the problem. The problem is one
of several things.

Your data may simply be insufficient to estimate a
polynomial of this order. If this is an interpolation
problem, it is a terrible thing to do. You should
NEVER be estimating a 15'th order polynomial
interpolant. Use a interp1 instead to build an
interpolant. Or use spline or pchip, or the splines
toolbox. Even a 9x9 matrix, which would imply
a polynomial with 9 terms, therefor an 8th order
polynomial is too large. You should almost never
use interpolating polynomials at all, when splines
are available as an option.

If this is a least squares problem, then you are
doing something almost as bad. The factthat you
are trying to form the inverse of a square matrix
means that you are using the normal equations to
solve the least squares problem! This is a very poor
way to solve the linear least squares problem!!!!!!!
That is, to solve the problem

A*x = y

where A has more rows than columns, many people
will tell you to use

x = inv(A'*A) * A' * y

This is a solution that is numerically very poor to
use when A is even remotely poorly conditioned,
and polynomial models almost always generate
poorly conditioned systems of equations. Instead,
solve the problem using either

x = A\y;

or

x = pinv(A)*y;

Either of these solutions is much more well behaved
than using the matrix inverse.

Next, very often a cause of poorly conditioned
polynomial models is the scaling of your data.
That scaling, combined with a high enough order
model, will create numerical problems in the linear
algebra. If so, then a simple prescaling of your
independent variable so that the variable is on the
order of unity will often result in a well conditioned
matrix.

A better solution anyway is to use a spline again.
High order polynomial models are again a terrible
thing to do to your data!!!! Instead, use a good
tool to build that model. A least squares spline is
such a tool. You can find a least squares spline in
the splines toolbox, or in my SLM toolbox on the
file exchange. (You will need the optimization
toolbox to use it though.) Find SLM here:

http://www.mathworks.com/matlabcentral/fileexchange/24443

Be good to your data. It deserves friendly treatment.
Use a spline.

John
.



Relevant Pages

  • Re: Accurate numerical differentiation in MATLAB?
    ... Yes, I showed how to do interpolating polynomials, in one of my blogs, but I will never recommend anything ... continuity of the derivatives. ... One solution is a cubic interpolating spline. ...
    (comp.soft-sys.matlab)
  • Re: accurate polynomial approximation
    ... Interpolation makes use of information ... which should result in such a high precise approximation cannot be ... What concerns the piecewise use of least squares polynomials: ...
    (sci.math.num-analysis)
  • Re: Accurate numerical differentiation in MATLAB?
    ... Yes, I showed how to do interpolating polynomials, in one of my blogs, but I will never recommend anything ... continuity of the derivatives. ... One solution is a cubic interpolating spline. ...
    (comp.soft-sys.matlab)
  • On limitations of the Mautsch Principle (was Re: ineqality)
    ... > squares. ... I would prove the homogeneous polynomial inequality ... polynomials (which would necessarily have to be linear combinations ... So symmetry on the way in does not imply symmetry on the way out. ...
    (sci.math)
  • Re: Polynomial Fit Program
    ... Does anybody know an open source code for a one dimensional polynomial ... least squares fit program? ... In the simplest case (polynomials of moderate degree), ...
    (sci.math.num-analysis)