This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Numerical singular values of a matrix

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


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 AHA (for p = n) or of AAH (for p = m). The Hermitian transpose AH is the complex conjugate of the transpose of A.

numeric::singularvalues returns a list of real singular values [d1, …, dp] sorted by numeric::sort, i.e., d1 ≥ …dp ≥ 0.0.

All entries of A must be numerical. Numerical expressions such as etc. are accepted and converted to floats. Non-numerical 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).


Singular values are approximated with an absolute precision of where r is largest singular value of A. Consequently, large singular values should be computed correctly to DIGITS decimal places. The numerical approximations of small singular values are less accurate.

Singular values may also be computed via map ( numeric::eigenvalues( A   AH), sqrt ) or map ( numeric::eigenvalues( AH  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.

Environment Interactions

The function is sensitive to the environment variable DIGITS, which determines the numerical working precision.


Example 1

The singular values of A and AH coincide:

A := array(1..3, 1..2, [[1, 2*I], [2, 3],[3, sqrt(2)]]):

The Hermitian transpose B = AH:

B := array(1..2, 1..3, [[1, 2, 3], [-2*I, 3, sqrt(2)]]):

delete A, B:

Example 2

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 = AH can be computed by the methods conjugate and transpose of the matrix domain:

B := A::dom::conjugate(A::dom::transpose(A)):

Note that AHA is positive semi-definite and cannot have negative eigenvalues. However, computing small eigenvalues is numerically ill-conditioned, and a small negative value occurs due to roundoff:


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:

Example 3

We demonstrate the use of hardware floats. Hilbert matrices are notoriously ill-conditioned: 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:


A := linalg::hilbert(15):
numeric::singularvalues(A, HardwareFloats);
numeric::singularvalues(A, SoftwareFloats)

delete A:



A numerical matrix of domain type DOM_ARRAY, DOM_HFARRAY, or of category Cat::Matrix


Hard, HardwareFloats, Soft, SoftwareFloats

With Hard (or HardwareFloats), computations are done using fast hardware float arithmetic from within a MuPAD® session. Hard and HardwareFloats are equivalent. With this option, the input data are converted to hardware floats and processed by compiled C code. The result is reconverted to MuPAD floats and returned to the MuPAD session.

With Soft (or SoftwareFloats) computations are dome using software float arithmetic provided by the MuPAD kernel. Soft and SoftwareFloats are equivalent. SoftwareFloats is used by default if the current value of DIGITS is larger than 15 and the input matrix A is not of domain type DOM_HFARRAY.

Compared to the SoftwareFloats used by the MuPAD kernel, the computation with HardwareFloats may be many times faster. Note, however, that the precision of hardware arithmetic is limited to about 15 digits. Further, the size of floating-point numbers may not be larger than approximately 10308 and not smaller than approximately 10- 308.

If no HardwareFloats or SoftwareFloats are requested explicitly, the following strategy is used: If the current value of DIGITS is smaller than 16 or if the matrix A is a hardware float array of domain type DOM_HFARRAY, then hardware arithmetic is tried. If this is successful, the result is returned.

If the result cannot be computed with hardware floats, software arithmetic by the MuPAD kernel is tried.

If the current value of DIGITS is larger than 15 and the input matrix A is not of domain type DOM_HFARRAY, or if one of the options Soft, SoftwareFloats or Symbolic is specified, MuPAD computes the result with its software arithmetic without trying to use hardware floats first.

There may be several reasons for hardware arithmetic to fail:

  • The current value of DIGITS is larger than 15.

  • The data contains symbolic objects.

  • The data contains numbers larger than 10308 or smaller than 10- 308 that cannot be represented by hardware floats.

If neither HardwareFloats nor SoftwareFloats is specified, the user is not informed whether hardware floats or software floats are used.

If HardwareFloats are specified but fail due to one of the reasons above, a warning is issued that the (much slower) software floating-point arithmetic of the MuPAD kernel is used.

Note that HardwareFloats can only be used if all input data can be converted to floating-point numbers.

The trailing digits in floating-point results computed with HardwareFloats and SoftwareFloats may differ.


For ill-conditioned matrices, the result is subject to roundoff errors. The results returned with HardwareFloats and SoftwareFloats may differ! See Example 3.

Return Values

Ordered list of real floating-point values.


The code implements standard numerical algorithms from the Handbook of Automatic Computation by Wilkinson and Reinsch.

Was this topic helpful?