Monday 2 April 2018

Importance of eigenvalues and eigenvectors

Hello there,
In this post, I am going to talk about the importance of eigenvalues and eigenvectors. For those who don't know what are eigenvalues and eigenvectors:
Suppose you have a square matrix  A of size n x n, λ be the eigenvalue and X be the eigenvector of size n x 1. Then the equation :
AXλX      ---(1)
holds true.
How eigenvalues and eigenvectors are calculated isn't the aim of this post. If you want to learn the way eigenvalues and eigenvectors are calculated, go to this link.

So coming back to the main topic of this post i.e the importance of eigenvalues and eigenvectors, I would like to give a definition of eigenvalues and eigenvectors in a different way.
The eigenvalue is a value and the Eigenvector is a vector hiding in a matrix. Both are useful to solve systems of linear equations and to find differentiation of vectors.  In the equation above X is a vector.
Suppose you have λ, as well as X with you for a particular matrix A. Can you find out the eigenvalue and eigenvector for the A^2 matrix? 
The answer is: 
The eigenvector of A^2 is same as the eigenvector of A. The eigenvalue for A^2 is  λ^2. The same goes for the nth power of the matrix

Ok, enough of formulae and definition. The question still remains the same. What is the use of it? How it works in the real world?
For answering these questions, let's dive deeper.

Let's understand what is a transformation.
A transformation is a change in the current shape of the object.  It can either be in single dimension or in multiple dimension.

1.

 2.
3.

Obviously, I am not talking about the transformation in picture number 1 😅😅😅. 
In the transformation in picture number 2, you can see that the direction of the blue arrow remains the same but the direction of the red arrow changes. The length of the blue arrow increases with some constant.
Eigenvectors are those vectors whose direction does not change even after the transformation. They only change their length when subjected to any transformation. The constant by which the length of these eigenvector changes is called as it's eigenvalue.
Similarly, in the picture number 3, you can see that the direction of the red vector remains same while that of the blue vector changes.












1 comment:

  1. Aaasssssrdssssffgc#include

    using namespace std;

    int minimumCost(int *arr,int n)
    {
    multimap > sumMap;
    multimaphashMap;
    for(int i =0;i p(i,n-1);
    int sum = arr[0] + arr[n-1];
    sumMap.insert({sum, p});
    hashMap.insert(pair(i,sum)) ;
    hashMap.insert(pair(n-1,sum));
    sum = arr[i] + arr[i+1];
    p.first = i;
    p.second = i+1;
    sumMap.insert({sum,p});
    hashMap.insert(pair(i,sum)) ;
    hashMap.insert(pair(i+1,sum));
    }
    else
    {
    pair q(i,i+1);
    int sum = arr[i] + arr[i+1];
    sumMap.insert({sum,q});
    hashMap.insert(pair(i,sum)) ;
    hashMap.insert(pair(i+1,sum));
    }

    }
    int ans = 0;
    while(sumMap.size()!=1)
    {
    int sumVal = sumMap.begin()->first;
    cout<p = sumMap.begin()->second;
    int key1 = p.first;
    int key2 = p.second;
    sumMap.erase(sumMap.begin());
    typedef multimap::iterator MMAPIterator;
    pair result1 = hashMap.equal_range(key1);
    pair result2 = hashMap.equal_range(key2);
    int sum1,sum2;
    // Iterate over the range
    for (MMAPIterator it = result1.first; it != result1.second; it++)
    {
    sum1 = it->second;
    if(sum1 != sumVal )
    {
    hashMap.erase(it);
    break;
    }

    }
    int index1;
    typedef multimap >::iterator MMAPIPAIRterator;
    pair result3 = sumMap.equal_range(sum1);
    for (MMAPIPAIRterator it = result3.first; it != result3.second; it++)
    {
    pairq;
    q = it->second;
    if(q.first == key1 || q.second ==key1)
    {
    index1 = q.first;
    if(index1 == key1)
    {
    index1 = q.second;
    }
    sumMap.erase(it);
    int newSum = arr[index1] + sumVal;
    pairpair1(0,index1);
    sumMap.insert({newSum,pair1});
    break;
    }

    }

    for (MMAPIterator it = result2.first; it != result2.second; it++)
    {
    sum2 = it->second;
    if(sum2 != sumVal )
    {
    hashMap.erase(it);
    break;
    }

    }
    int index2;
    pair result4 = sumMap.equal_range(sum2);
    for (MMAPIPAIRterator it = result4.first; it != result4.second; it++)
    {
    pairq;
    q = it->second;
    if(q.first == key2 || q.second ==key2)
    {
    index2 = q.first;
    if(index2 == key2)
    {
    index2 = q.second;
    }
    sumMap.erase(it);
    int newSum = arr[index2] + sumVal;
    pairpair1(0,index2);
    sumMap.insert({newSum,pair1});
    break;
    }
    }

    }
    return ans;
    }

    int main() {
    int t;
    cin>>t;
    while(t--)
    {
    int n;

    cin>>n;
    int arr[n];
    for(int i=0;i>arr[i];
    }
    cout<<minimumCost(arr,n)<<endl;
    }
    return 0;
    }

    ReplyDelete