..  pinv(M[, tol])

Computes the Moore-Penrose pseudoinverse.

For matrices ``M`` with floating point elements, it is convenient to compute
the pseudoinverse by inverting only singular values above a given threshold,

The optimal choice of ``tol`` varies both with the value of ``M``
and the intended application of the pseudoinverse. The default value of
``tol`` is ``eps(real(float(one(eltype(M)))))*maximum(size(A))``,
which is essentially machine epsilon for the real part of a matrix element
multiplied by the larger matrix dimension.
For inverting dense ill-conditioned matrices in a least-squares sense,
``tol = sqrt(eps(real(float(one(eltype(M))))))`` is recommended.

For more information, see [issue8859]_, [B96]_, [S84]_, [KY88]_.

.. [issue8859] Issue 8859, "Fix least squares",
.. [B96] Åke Björck, "Numerical Methods for Least Squares Problems",
   SIAM Press, Philadelphia, 1996, "Other Titles in Applied Mathematics", Vol. 51.
   `doi:10.1137/1.9781611971484 <>`_
.. [S84] G. W. Stewart, "Rank Degeneracy", SIAM Journal on
   Scientific and Statistical Computing, 5(2), 1984, 403-413.
   `doi:10.1137/0905030 <>`_
.. [KY88] Konstantinos Konstantinides and Kung Yao, "Statistical analysis
   of effective singular values in matrix rank determination", IEEE
   Transactions on Acoustics, Speech and Signal Processing, 36(5), 1988,
   `doi:10.1109/29.1585 <>`_


The pinv function in Julia computes the Moore-Penrose pseudoinverse of a matrix M. It is used to calculate the inverse of matrices, particularly for those that are ill-conditioned or singular.

julia> M = [1 2 3; 4 5 6];
julia> pinv(M)
3×2 Array{Float64,2}:
 -1.0000000000000002   2.0
  0.9999999999999998  -1.0
  0.0                 -0.0

In this example, the pseudoinverse of matrix M is computed using pinv function.

The tol parameter is an optional argument that specifies the threshold for singular values. It determines which singular values are considered significant enough to be inverted. If not provided, the default value is calculated based on machine epsilon and the size of the matrix.

julia> M = [1 2; 3 4; 5 6];
julia> pinv(M, 0.1)
2×3 Array{Float64,2}:
 -0.6666666666666669  -0.3333333333333333   0.0
  0.6666666666666666   0.33333333333333326  0.0

In this example, the tol value is set to 0.1, meaning only singular values above 0.1 are inverted.

Please note that the pinv function is mainly used for advanced linear algebra applications and should be used with caution.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: