More

    Python Program to Find Eigenvalues and Eigenvectors

    Program Code

    import numpy as np
    
    A = np.array([[1,2,3],[4,5,6],[7,8,9]])
    
    eigenvalues, eigenvectors = np.linalg.eig(A)
    
    print(f"The eigenvalues are {eigenvalues}")
    print(f"The eigenvectors are {eigenvectors}")

    Expected Output:

    The eigenvalues are [ 1.61168440e+01 -1.11684397e+00 -1.30367773e-15]
    The eigenvectors are [[-0.23197069 -0.78583024 0.40824829]
    [-0.52532209 -0.08675134 -0.81649658]
    [-0.8186735 0.61232756 0.40824829]]

    Code Explanation

    1. We import the numpy library as np.
    2. We create a 3×3 matrix A.
    3. We use the eig() function to calculate the eigenvalues and eigenvectors of A.
    4. We print the eigenvalues and eigenvectors.
    Disclaimer: While we make every effort to update the information, products, and services on our website and related platforms/websites, inadvertent inaccuracies, typographical errors, or delays in updating the information may occur. The material provided on this site and associated web pages is for reference and general information purposes only. In case of any inconsistencies between the information provided on this site and the respective product/service document, the details mentioned in the product/service document shall prevail. Subscribers and users are advised to seek professional advice before acting on the information contained herein. It is recommended that users make an informed decision regarding any product or service after reviewing the relevant product/service document and applicable terms and conditions. If any inconsistencies are observed, please reach out to us.

    Latest Articles

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Join our newsletter and stay updated!