Linear Algebra: Practice Programs in Python and C Languages

Computation of Eigen Values and Eigen Vectors Using Python (Linear Algebra: Linear Transformation and Diagonalization)

Linear Algebra: Practice Programs in Python and C Languages: Linear Algebra: Linear Transformation and Diagonalization: Computation of Eigen Values and Eigen Vectors Using Python

Linear Algebra

PROGRAMMES IN PYTHON AND C LANGUAGES

UNIT − II: LINEAR TRANSFORMATION AND DIAGONALIZATION


COMPUTATION OF EIGEN VALUES AND EIGEN VECTORS USING PYTHON

The computation of eigenvalues and eigenvectors of a 3×3 matrix in Python can be efficiently performed using the numpy library, specifically the numpy.linalg.eig function.

Here's how to do it: import numpy.

Python

import numpy as np

Define the 3×3 Matrix.

Create a NumPy array representing your 3×3 matrix.

Python

matrix_A = np.array([all, a12, a13],

[a21, a22, a23]

[a31, a3a, a33]])

Replace all, a12, etc., with the actual numerical values of your matrix elements. Compute Eigenvalues and Eigenvectors.

Use the np.linalg.eig() function, which returns two values: an array of eigenvalues and a 2D array where each column is an eigenvector.

Python

eigenvalues, eigenvectors = np.linalg.eig (matrix_A)

Display the Results

Print the computed eigenvalues and eigenvectors.

Python

print ("Eigenvalues of the matrix: ")

print (eigenvalues)

print ("\nEigenvectors of the matrix (columns correspond to eigenvalues):")

print (eigenvectors)

Example

Python

import numpy as np

#Define a sample 3 x 3 matrix

matrix_B = np.array([[4,2,0],

[1,3,0];

[0,0,5]])

# Compute eigenvalues and eigenvectors

eigenvalues, eigenvectors = np.linalg.eig (matrix_B)

#Print the results

print ("Eigenvalues of the matrix:")

print (eigenvalues).

print ("\nEigenvectors of the matrix (columns correspond to eigenvalue): ")

print (eigenvectors)

In the output, eigenvalues will be a 1D array containing the eigenvalues. Eigenvectors will be a 2D array where each column represents an eigenvector, and the order of the eigenvectors corresponds to the order of the eigenvalues in the eigenvalues array.

 

Linear Algebra: Practice Programs in Python and C Languages : Tag: maths, mathematics : - Computation of Eigen Values and Eigen Vectors Using Python (Linear Algebra: Linear Transformation and Diagonalization)


Linear Algebra: Practice Programs in Python and C Languages



Under Subject


Linear Algebra

MA25C02 2nd Semester | 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Transforms and its Applications

MA25C03 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (CE) II

PH25C02 2nd Semester Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (EE) II

PH25C04 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Physics (ME) II

PH25C05 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Chemistry (CE) II

CY25C02 2nd Semester Civil Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Applied Chemistry (ME) II

CY25C03 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Electron Devices

EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Civil and Mechanical Engineering

GE25C01 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures and Algorithms

CS25C04 2nd Semester EEE Dept | 2025 Regulation


Circuits and Network Analysis

EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Mechanics

ME25C02 2nd Semester Mech, Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation