Bocher 공식

카테고리 없음 2011. 12. 29. 16:27 Posted by mathboy

임의의 6x6 행렬의 고유방정식. 역행렬 구하기

케일리-해밀턴의 정리와 Bocher의 공식을 이용한 Faddev-Leverrier 알고리즘 사용.

function [p,Ainv,B]=fadlev(A)

%

% FADLEV Faddeev-Leverrier approach to generate coefficients of the

% characteristic polynomial and inverse of a given matrix

% Uasage: [p,Ainv,B]=fedlev(A)

%

% Input: A - the given matrix

% Output: p - the coefficient vector of the characteristic polynomial

% B - a cell array of the sequency of matrices generated, where

% B{1} = A p(1)=trace(B{1})

% B{2} = A*(B{1}-p(1)*I) p(2)=trace(B{2})/2

% .....

% B{n} = A*(B{n-1}-p(n-1)*I) p(n)=trace(B{n})/n

%

% Ainv - The inverse of A calculated as

% Ainv = (B{n-1}-p(n-1)*I)/p(n)

%

% Example:

%{

A=magic(5);

[p,B]=fadlev(A);

fprintf('Check inverse: norm(B-inv(A))=%g\n',norm(B-inv(A)));

fprintf('Check polynomial: norm(p-poly(A))=%g\n',norm(p-poly(A)));

%}

% By Yi Cao on 17 August 2007 at Cranfield University

%

% Reference:

% Vera Nikolaevna Faddeeva, "Computational Methods of Linear

% Algebra," (Translated From The Russian By Curtis D. Benster), Dover

% Publications Inc. N.Y., Date Published: 1959 ISBN: 0486604241.

%

 

[n,m]=size(A);

if n~=m

error('The given matrix is not square!');

end

 

[B{1:n}]=deal(A);

p=ones(1,n+1);

for k=2:n

p(k)=-trace(B{k-1})/(k-1);

B{k}=A*(B{k-1}+p(k)*eye(n));

end

p(n+1)=-trace(B{n})/n;

Ainv=-(B{n-1}+p(n)*eye(n))/p(n+1);

 

 

>> A=[1 2 3 4 5 6; 2 3 5 6 12 2; 3 23 4 6 12 23; 2 5 24 6 43 2; 3 12 54 5 1 2; 12 3 5 2 1 3]

 

A =

 

1 2 3 4 5 6

2 3 5 6 12 2

3 23 4 6 12 23

2 5 24 6 43 2

3 12 54 5 1 2

12 3 5 2 1 3

 

>> [p,Ainv,B]=fadlev(A)

 

p =

 

1 -18 -1405 -26815 -263490 -212314 *

 

 

Ainv =

 

-148/7879 -67/7061 -258/46063 31/6878 -125/15789 1831/20548

-975/4492 519/4615 241/4878 -87/4384 154/19527 -107/9168

377/9736 -78/1969 -122/13761 73/8453 51/3025 -5/80231

74/2301 689/3007 -291/14494 -191/3099 139/16468 -587/21201

-95/9764 -14/919 35/15581 99/3505 -30/2767 23/29071

319/1523 -317/2030 118/287291 93/4870 -99/15637 31/4513

 

 

B =

[6x6 double] [6x6 double] [6x6 double] [6x6 double] [6x6 double] [6x6 double]