Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(2) [20pt] Power Method and Inverse Iteration. (a) Implement the Power Method fo

ID: 3281845 • Letter: #

Question

(2) [20pt] Power Method and Inverse Iteration. (a) Implement the Power Method for an arbitrary matrix A Rnxn and an initial vector Zo Rn (b) Use your code to find an eigenvector of 2 1 41 4 1 -2 starting with Zo = (1,2,-1)T and x,-(1,2, 1)T. Report the first 5 iterates for each of the two initial vectors. Then use MATLAB's eig(A) to examine the eigenvalues and eigenvectors of A. Where do the sequences converge to? Why do the limits not seem to be the same? (c) Implement the Inverse Power Method for an arbitrary matrix A ERn, an initial vector xo E R" and an initial eigenvalue guess 0 ER (d) Use your code from (c) to calculate all eigenvectors of A. You may pick appropriate values for and the initial vector as you wish (obviously not the eigenvectors themselves). Always report the first 5 iterates and explain where the sequence converges to and why. Please also hand in your code.

Explanation / Answer

a) and b) Power Method of a matrix source code in c

//header files inclusion

#include<stdio.h>

#include<conio.h>

#include<math.h>

//main function start

void main()

{

    int i,j,n;

    float A[40][40],x[40],z[40],e[40],zmax,emax;

    printf(" Enter the order of matrix:");

    scanf("%d",&n);

//printing to the output screen

    printf(" Enter matrix elements row-wise ");

//nested for loop

    for(i=1; i<=n; i++)

    {

        for(j=1; j<=n; j++)

        {

            printf("A[%d][%d]=", i,j);

            scanf("%f",&A[i][j]);

        }

    }

    printf(" Enter the column vector ");

    for(i=1; i<=n; i++)

    {

        printf("X[%d]=",i);

        scanf("%f",&x[i]);

    }

    do

    {

        for(i=1; i<=n; i++)

        {

            z[i]=0;

            for(j=1; j<=n; j++)

            {

                z[i]=z[i]+A[i][j]*x[j];

            }

        }

        zmax=fabs(z[1]);

//for loop

        for(i=2; i<=n; i++)

        {

            if((fabs(z[i]))>zmax)

                zmax=fabs(z[i]);

        }

        for(i=1; i<=n; i++)

        {

            z[i]=z[i]/zmax;

        }

        for(i=1; i<=n; i++)

        {

            e[i]=0;

            e[i]=fabs((fabs(z[i]))-(fabs(x[i])));

        }

        emax=e[1];

        for(i=2; i<=n; i++)

        {

            if(e[i]>emax)

                emax=e[i];

        }

        for(i=1; i<=n; i++)

        {

            x[i]=z[i];

        }

    }

    while(emax>0.001);

    printf(" ...The required eigen value is %f",zmax);

    printf(" ....The required eigen vector is : ");

    for(i=1; i<=n; i++)

    {

        printf("%f ",z[i]);

    }

    getch();

}

Inverse Power Method

The eigen values of the matrix A bI for a scalar b are i b if and only if i are eigen values of A The

idea can be used to work on the matrix A bI instead of A with the hope that the ratio of the rst

two dominan t eigen values i b will become smaller This is called a shifted power method

The application is very limited.