Numerical singular values of a matrix
This functionality does not run in MATLAB.
numeric::singularvalues(A
, <Hard  HardwareFloats  Soft  SoftwareFloats
>)
numeric::singularvalues(A)
returns numerical
singular values of the matrix A
.
The singular values of an m×n matrix A are the p = min(m, n) real nonnegative square roots of the eigenvalues of A^{H} A (for p = n) or of A A^{H} (for p = m). The Hermitian transpose A^{H} is the complex conjugate of the transpose of A.
numeric::singularvalues
returns a list of
real singular values [d_{1},
…, d_{p}] sorted
by numeric::sort
,
i.e., d_{1} ≥
… ≥ d_{p} ≥
0.0.
All entries of A
must be numerical. Numerical
expressions such as
etc.
are accepted and converted to floats. Nonnumerical symbolic entries
lead to an error.
Cat::Matrix
objects,
i.e., matrices A
of a matrix domain such as Dom::Matrix(…)
or Dom::SquareMatrix(…)
are
internally converted to arrays over expressions via expr(A)
.
Note:
Singular values are approximated with an absolute precision
of
where r is
largest singular value of 
Singular values may also be computed via map ( numeric::eigenvalues(
A A^{H}), sqrt )
or map
( numeric::eigenvalues( A^{H} A ),
sqrt )
, respectively. The use of numeric::singularvalues
avoids
the costs of the matrix multiplication. Further, the eigenvalue routine
requires about twice as many DIGITS
to compute small singular values
with the same precision as numeric::singularvalues
.
Cf. Example 2.
The function is sensitive to the environment variable DIGITS
,
which determines the numerical working precision.
The singular values of A and A^{H} coincide:
A := array(1..3, 1..2, [[1, 2*I], [2, 3],[3, sqrt(2)]]):
numeric::singularvalues(A)
The Hermitian transpose B = A^{H}:
B := array(1..2, 1..3, [[1, 2, 3], [2*I, 3, sqrt(2)]]):
numeric::singularvalues(B)
delete A, B:
We use numeric::eigenvalues
to
compute singular values:
A := matrix([[1/15, 2/15*I], [PI, 314159265358980/50000000000000*I], [2, 4*I]]):
The Hermitian transpose B = A^{H} can
be computed by the methods conjugate
and transpose
of
the matrix domain:
B := A::dom::conjugate(A::dom::transpose(A)):
Note that A^{H} A is positive semidefinite and cannot have negative eigenvalues. However, computing small eigenvalues is numerically illconditioned, and a small negative value occurs due to roundoff:
numeric::eigenvalues(B*A)
Consequently, an (incorrect) imaginary singular value is computed:
map(%, sqrt)
We have to increase DIGITS
in order to compute this value
more accurately:
DIGITS := 22: map(numeric::eigenvalues(B*A), sqrt)
With numeric::singularvalues
, the standard
precision suffices:
DIGITS := 10: numeric::singularvalues(A, SoftwareFloats)
numeric::singularvalues(A, HardwareFloats)
delete A, B:
We demonstrate the use of hardware floats. Hilbert
matrices are notoriously illconditioned: the computation of
the small singular values is subject to severe roundoff effects. In
the following results, both with HardwareFloats
as
well as with SoftwareFloats
, the small singular
values are dominated by numerical roundoff. Consequently, the results
with HardwareFloats
differ from those with with SoftwareFloats
:
numeric::singularvalues(linalg::hilbert(13))
A := linalg::hilbert(15): numeric::singularvalues(A, HardwareFloats); numeric::singularvalues(A, SoftwareFloats)
delete A:

A numerical matrix of domain type 

With With Compared to the If no If the result cannot be computed with hardware floats, software arithmetic by the MuPAD kernel is tried. If the current value of There may be several reasons for hardware arithmetic to fail:
If neither If Note that The trailing digits in floatingpoint results computed with

Ordered list of real floatingpoint values.
The code implements standard numerical algorithms from the Handbook of Automatic Computation by Wilkinson and Reinsch.