# [Maxima] matrix 2-norm and associated matrix condition number

Wolfgang Lindner LindnerW at t-online.de
Thu Apr 26 14:19:00 CDT 2007

```Thanks for your helpful hints, Barton.

And nice to hear about eigens_by_jacobi, which it is not yet listed in the HTML-Index of
the Windows Help of wxMaxima. As I could see in the share lib you are also the author of
the function eigens_by_jacobi.lisp :) - thanks for that fine code.

For those, who are interested, my functions now looks like:

mat_norm2(A) := sqrt(lmax(eigenvalues(transpose(conjugate(A)).A)[1]));
mat_norm2(matrix([3,-1],[-1,3]));
--> 4

mat_norm2j(A) := sqrt(lmax(eigens_by_jacobi(transpose(conjugate(A)).A)[1]));
mat_norm2j(matrix([3,-1],[-1,3]));
--> 4.0

HTH Wolfgang

"Barton Willis" <willisb at unk.edu> schrieb:
> No, Maxima doesn't have an alternative to your function. Suggestions:
>
> (1) replace transpose(A).A  with transpose(conjugate(A).A.
>
> (2) replace sort with lmax.  The sort function sorts explicit numbers
> (things like 1.3 and 2/3) from least to greatest (I think), but it
> doesn't sort things like sqrt(3), %pi, 42... from least to greatest.
> So your sort function may return the wrong eigenvalue.
>
> For matrices larger that 3 x 3, it's unlikely that your function will
> work.  If you are interested in floating point, maybe you could
> use eigens_by_jacobi. Also, there is a recently added function (not
> sure of its name) for numerical eigenvalue problems that should be
> faster than eigens_by_jacobi.
>
> Barton
>
> maxima-bounces at math.utexas.edu wrote on 04/26/2007 10:39:00 AM:
>
> > Dear experts,
> >
> > AFAIK maxima currently has no matrix 2-norm and no matrix condition
> > number based on
> > 2-norm.
> > In teaching the 2-norm/2-condition sometimes matters.
> >
> > So I wrote simple beginners implementations of both concepts:
> >
> >
> > mat_norm2(A) := sqrt(last(sort(eigenvalues(transpose(A).A)[1])));
> > mat_norm2(matrix([3,-1],[-1,3]));  --> 4
> >
> >
> > mat_cond2(A) := mat_norm2(invert(A))*mat_norm2(A)\$
> > mat_cond2(matrix([3,-1],[-1,3]));  --> 2
> >
> > It works for me (and for some little tests), but I wonder if someone
> > has written
> > 'alternative' Maxima functions using other or better math or maxima
> concepts.
> > Any hints are very welcome.
> >
> > --
> > HTH  Wolfgang
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
```