# Eigen Value and Eigen Vector of a matrix by Iterative Method- C++ Program

```#include
#include
#include
using namespace std;
int main()
{
cout.precision(2);
cout.setf(ios::fixed);
int n,i,j;
cout<<"\nEnter the order of the matrix:\n";        //Get the order of the square matrix
cin>>n;
double a[n][n],b[n],c[n],k,eps,y;            //declare arrays and other variables to be used
cout<<"\nEnter the elements of matrix row-wise:\n";
for (i=0;i>a[i][j];
cout<<"\nEnter the initial values of the eigen-vector:\n";
for (i=0;i>b[i];
cout<<"\nEnter the accuracy desired:\n";
cin>>eps;
k=b[0];                            //Assign some initial value to the eigen value, 'k'
do
{
y=k;
for (i=0;ik?abs(c[i]):k;        //Find the largest element of c and assign it to k where k is the eigen value
for (i=0;ieps);                    //Check if the error in eigen value is within the tolerance limit
cout<<"The eigen-value is: "<
Sample Output

Get Article as PDF

Manas SharmaPh.D. researcher at Friedrich-Schiller University Jena, Germany. I’m a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
manas.bragitoff.com/Share this:Click to share on Facebook (Opens in new window)Click to share on Twitter (Opens in new window)Click to share on WhatsApp (Opens in new window)Click to share on Pinterest (Opens in new window)Click to share on Reddit (Opens in new window)Click to share on LinkedIn (Opens in new window)Click to email a link to a friend (Opens in new window)Click to print (Opens in new window)Click to share on Tumblr (Opens in new window)Click to share on Pocket (Opens in new window)Click to share on Telegram (Opens in new window)Like this:Like Loading...

Related

[wpedon id="7041" align="center"]

```

## One thought on “Eigen Value and Eigen Vector of a matrix by Iterative Method- C++ Program”

1. Hi My name is Milad, I need code c++ for computing sparse matrix and Eigenvalue and eigenvector, can you help me?

This site uses Akismet to reduce spam. Learn how your comment data is processed.