Skip to main content

Section 2.7 Python Code for Matrix

Problem 2.7.1.

To solve problem like Example 2.4.12 excute the following code in python shell
Solution.
import numpy as np
A=np.array([[6,-3,0],[-3,12,5],[0,5,11]])
B= np.array([5,10,5])
I =np.linalg.solve(A,B)
I
Answer.
array([ 1.45488029, 1.24309392, -0.11049724])

Problem 2.7.2.

To solve problem like Example 2.6.4 excute the following code in the python shell
Solution.
import numpy as np
A=np.array([[3,1],[2,2]])
E,v=np.linalg.eig(A)
print(’E-value:’, E)
print(’E-vector’, v)
Answer.
E-value: [4. 1.]
E-vector [[ 0.70710678 -0.4472136 ] [ 0.70710678 0.89442719]]

Problem 2.7.3.

Solution.
import numpy as np
A=np.array([[2,-1,1],[-1,2,-1],[1,-1,2]])
E,v=np.linalg.eig(A)
print(’E-value:’, E)
print(’E-vector’, v)