You are on page 1of 2

Code for eigen values and vectors:

# -*- coding: utf-8 -*-

"""

Created on Tue Jul 18 20:04:20 2023

@author: Divyanshi

codes to implement mathematical tools already known

"""

#to find eigen values and eigen vectors using numpy

"""

Syntax: numpy.linalg.eig()

Parameter: An square array.

Return: It will return two values first is eigenvalues and second is eigenvectors.

"""

import numpy as np

import math as m

#create matrix

M=np.array([[7,m.sqrt(6),-m.sqrt(3)],[m.sqrt(6),2,-5*m.sqrt(2)],[-m.sqrt(3),-5*m.sqrt(2),-3]])

#find eigen val and vector

v,w=np.linalg.eig(M)

#printing values

print("Eigen values are:",v)

print("Eigen vectors are:",w)


Output:
Eigen values are: [ 4. 10. -8.]

Eigen vectors are: [[-7.07106781e-01 7.07106781e-01 -1.07938350e-17]

[ 5.77350269e-01 5.77350269e-01 5.77350269e-01]

[-4.08248290e-01 -4.08248290e-01 8.16496581e-01]]

You might also like