       Re: How to solve the system of linear equations?

• To: mathgroup at smc.vnet.net
• Subject: [mg25512] Re: How to solve the system of linear equations?
• From: Alberto Ruiz <ARuiz at um.es>
• Date: Thu, 5 Oct 2000 23:50:30 -0400 (EDT)
• Organization: University of Murcia, Spain
• References: <8r17ui\$h8r@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Zak,

To solve an overconstrained system in the LMS sense

A x = b

you can use the pseudoinverse of matrix A,

x = Pseudoinverse[A].b

On the other hand, to solve an homogeneous system

A x = 0

for nonzero x you can use NullSpace,
if there is "no noise" in the equations and the rank
of A equals the number of vars - 1.

If A is of full rank and you still need a nonzero
solution for the homogeneous system, you can use
the singular value decomposition:
{u,d,v}=SingularValues[A],
x = Last[v]

this mininizes ||Ax|| for ||x||=1

In general it is a good idea to check the singular values of the matrix
to see if it has the expected (approximate) rank.

A hint:

If the smaller singular value is 0. then
SingularValues[A] does not return the required solution
vector.(SingularValues without options only returns the
nonzero singular values and associated vectors)
(In this case you can use NullSpace)

But you can also use
SingularValues[A,Tolerance->0]
to get all the vectors.

Concerning the problem of fitting ellipses, it can be solved
as an homogeneous system, or you can fix one of the coefficients
known to be nonzero (e.g we can fix the coefficient of x^2 to 1)
and then the system becomes nonhomogeneous.

There are some problems with this approach: a) you are really fitting
a generic conic (the ellipse constraint is nonlinear),
and the LMS minimizes the so-called algebraic distance, which
is different from the euclidean distance from the data points to the
curve.

If your points are not very noisy the simple LMS approach with
PseudoInverse
obtains very good results.

I hope this helps,

Alberto Ruiz
University of Murcia, Spain

Zak Levi wrote:
>
> Dear Mathematica experts,
>
> How to solve, in Mathematica, the system of linear equations,
>
> when a number of equations is larger than a number of variables.
>
> Another system easily pass to apply LSM in this case, but it seems to
> me that there is no such opportunity in Mathematica.
>
> As an application, given N>5 points at plane, how to calculate (the
> parameters) of best fitting ellipse.
>
> Thanks a lot,
> ZL

```

• Prev by Date: Re: Hold, HoldForm, ReleaseHold when Plotting multiple functions
• Next by Date: Re: Syntax
• Previous by thread: Re: How to solve the system of linear equations?
• Next by thread: Summary: List element manipulation