使用 scipy 进行矩阵求幂:expm、expm2 和 expm3 [英] Matrix exponentiation with scipy: expm, expm2 and expm3

查看:85
本文介绍了使用 scipy 进行矩阵求幂:expm、expm2 和 expm3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用scipy.linalg 库中的函数在python 中执行矩阵求幂,即expm、expm2、expm3.expm 使用 Pade 近似;expm2 使用特征值分解方法,expm3 使用默认项数为 20 的泰勒级数.

Matrix exponentiation can be performed in python using functions within the scipy.linalg library, namely expm, expm2, expm3. expm makes use of a Pade approximation; expm2 uses the eigenvalue decomposition approach and expm3 makes use of a Taylor series with a default number of terms of 20.

在 SciPy 0.13.0 发行说明中声明:

In SciPy 0.13.0 release notes it is stated that:

不推荐使用矩阵指数函数 scipy.linalg.expm2 和 scipy.linalg.expm3.所有用户都应该改用数值上更健壮的 scipy.linalg.expm 函数.

The matrix exponential functions scipy.linalg.expm2 and scipy.linalg.expm3 are deprecated. All users should use the numerically more robust scipy.linalg.expm function instead.

虽然 expm2expm3 自发布版本 SciPy 0.13.0 起已被弃用,但我发现在许多情况下这些实现比 expm.由此,出现了一些问题:

Although expm2 and expm3 are deprecated since release version SciPy 0.13.0, I have found that in many situations these implementations are faster than expm. From this, some questions arise:

在什么情况下 expm2 和 expm3 会导致数值不稳定?

In what situations could expm2 and expm3 result in numerical instabilities?

在什么情况下(例如稀疏矩阵、对称...)每种算法都更快/更精确?

In what situations (e.g. sparse matrices, symmetric, ...) is each of the algorithms faster/more precise?

推荐答案

这在很大程度上取决于对矩阵求幂的这些不同方法的实现细节.

This will depend a lot on the detail of the implementation of these different ways of exponentiating the matrix.

一般来说,我认为特征分解 (expm2) 不太适合稀疏矩阵,因为它可能会消除稀疏性.应用于非对称矩阵也将更加困难,因为这将需要使用复杂的算术和更昂贵的算法来计算特征分解.

In general terms, I would expect the eigen-decomposition (expm2) to be poorly suited to sparse matrices, because it is likely to remove the sparseness. It will also be more difficult to apply to non-symmetric matrices, because this will require the use of complex arithmetic and more expensive algorithms to compute the eigen-decomposition.

对于泰勒级数方法 (expm3),如果有固定数量的独立于矩阵范数的项,这听起来很危险.计算标量 x 的 e^x 时,泰勒级数中最大的项大约是 n 接近 x 的项.

For the Taylor-series approach (expm3), this sounds risky if there are a fixed number of terms independent of the norm of the matrix. When computing e^x for a scalar x, the largest terms in the Taylor series are around that for which n is close to x.

但是,这些(已弃用)函数的实现细节可能会使用对角加载矩阵等技巧,以提高这些级数展开的稳定性.

However, the implementation details of these (deprecated) functions may use tricks like diagonally loading the matrix so as to improve the stability of these series expansion.

这篇关于使用 scipy 进行矩阵求幂:expm、expm2 和 expm3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆