Precise Matrix Power: A^k

9 ビュー (過去 30 日間)
Eric Schöneberg
Eric Schöneberg 2019 年 10 月 14 日
コメント済み: Eric Schöneberg 2019 年 10 月 15 日
Hello,
I am currently fighting with (more than) double-precision numerics, with which I am not familiar, so the answer probably lies within this topic. I would like to calculate
with and but obviously the precision of will be bad for big k. Is there a datatype of which I am not aware, or any other trick that will help me? Thanks in advance. :)

採用された回答

Rik
Rik 2019 年 10 月 14 日
It will probably be helpfull to use the Symbolic Math Toolbox, and use the tips explained here. For mod(a^b,k) there is a direct function, but for your use case there doesn't seem to exist one.
  1 件のコメント
Eric Schöneberg
Eric Schöneberg 2019 年 10 月 15 日
I've generated the following function:
function A = matrixPower(Matrix, exponential, precision)
A = vpa(eye(size(Matrix)), precision);
for k=1:exponential
A = vpa(A*Matrix, precision);
end
A = double(A);
end
which seems to work. I've tested the method using this script:
A = magic(5);
precision = 100;
for k = 0:50
B = matrixPower(A, k, precision);
C = A^k;
Error = B-C
end
and the Error(-Matrix) was Zero for k=1:10 and grew to 1.0e+74*Matrix for k = 50. Thanks again for your input @Rik.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by