如何准确计算矩阵的逆

如何准确计算矩阵的逆

本文介绍了如何准确计算矩阵的逆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算矩阵 P 的逆矩阵,但是如果我乘以 inv(P)*P,MATLAB 不会返回单位矩阵.这几乎是身份(10^(-12) 顺序的非对角线值).但是,在我的应用程序中,我需要更高的精度.

在这种情况下我该怎么办?

解决方案

仅当您明确需要您使用的矩阵的逆


作为10^(-12) 数量级误差的旁注,除了上述 inv() 函数的不准确性外,还有浮点数准确性.这篇关于 MATLAB 问题的帖子非常有见地,上面有一篇更一般的计算机科学帖子此处.基本上,如果您正在计算数字,请不要担心(至少是过度担心)小 12 个数量级的错误.

I'm trying to compute an inverse of a matrix P, but if I multiply inv(P)*P, the MATLAB does not return the identity matrix. It's almost the identity (non diagonal values in the order of 10^(-12)). However, in my application I need more precision.

What can I do in this situation?

解决方案

Only if you explicitly need the inverse of a matrix you use inv(), otherwise you just use the backslash operator .

The documentation on inv() explicitly states:

This is because the backslash operator, or mldivide() uses whatever method is most suited for your specific matrix:

Just so you know what algorithm MATLAB chooses depending on your input matrices, here's the full algorithm flowchart as provided in their documentation


As a side-note about error of order of magnitude 10^(-12), besides the above mentioned inaccuracy of the inv() function, there's floating point accuracy. This post on MATLAB issues on it is rather insightful, with a more general computer science post on it here. Basically, if you are computing numerics, don't worry (too much at least) about errors 12 orders of magnitude smaller.

这篇关于如何准确计算矩阵的逆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:21