Souriau method for Characteristic Polynomial

放肆的年华 提交于 2019-12-11 11:23:41

问题


Does anyone know the Souriau method for finding the characteristic polynomial of any n × n matrix? I found out the first coefficient, is obvious, but how can I find out the other coefficients? After I need to inverse the matrix but I know how.

#include <iostream> 
#include <fstream>
using namespace std;

double trace(double a[5][5],int n){ 
        int i;
        double trace=0;
        for(i=0;i<n;i++) 
            trace+=a[i][i]; 
        return trace;
}
double prod(double a[5][5],double b[5][5],int n) {
    double c[5][5];
    int i,j,k;
    cout << "\nProd:\n"; 
    for(i=0;i<n;++i){ 
        for(j=0;j<n;++j){ 
            c[i][j]=0; 
            for(k=0;k<n;++k) 
                c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
                cout << c[i][j] << " "; 
        } 
        cout << "\n"; 
    } 
    return c[i][j]; 
}
double theta(double a[5][5], int n){
    int i;
    double theta[5];
    theta[1]=-trace(a,n);
    for(i=0;i<n;i++)
        cout << "Theta[" << i+1 << "]=" << theta[i+1] << "\n";
    return theta[i+1];
}

int main(){ 
    ifstream f("a.txt"); 
    ifstream g("b.txt");
    double a[5][5],b[5][5];
    int i,j,n; 
    f >> n; 
    g >> n; 
    for(i=0;i<n;++i) 
        for(j=0;j<n;++j) 
            f >> a[i][j]; 
    cout << "Matrix A:"<<endl;
    for(i=0;i<n;++i){
        for(j=0;j<n;++j) 
            cout << a[i][j] << " ";
            cout << endl;
    }
    cout << endl;
    for(i=0;i<n;++i) 
        for(j=0;j<n;++j) 
            g >> b[i][j]; 
    cout << "Matrix B:" << endl;
    for(i=0;i<n;++i){ 
        for(j=0;j<n;++j) 
            cout << b[i][j] << " ";
            cout << endl;
    }

        cout << endl;
        cout << "Trace = ";
        cout << trace(a,n);
        cout << endl;
        prod(a,b,n);
        cout << endl;
        theta(a,n);
    }

回答1:


Taken from https://math.stackexchange.com/a/405975/115115 by J. M.

C=A;
for k=1,…,n

    if k>1
        C=A*(C+c[n−k+1]*I);

    c[n−k]=−tr(C)/k;

end for

If you can read the german, there is a wiki page with extended pseudo-code algortihm at https://de.wikipedia.org/wiki/Algorithmus_von_Faddejew-Leverrier (add 2017: or the equally good english version https://en.wikipedia.org/wiki/Faddeev%E2%80%93LeVerrier_algorithm)

If you want to directly compute the inverse matrix, then you have, as in the wiki page, use the matrix B that is related to the matrix C above via C=AB. This gives, as can be seen in the wiki page, a slightly more complicated algorithm. However, then the last matrix B satisfies AB=-c[0]*I, so that the inverse matrix, if there is one, can be directly computed.



来源:https://stackoverflow.com/questions/23937481/souriau-method-for-characteristic-polynomial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!