ADVANCE MATHEMATICS FOR BUSINESS ANALYTICS
Name: Sanaullah Fayyaz
Registration Number: SP23-BBD-083
Section: BDA-4B
Assignment No: 2
PART A:
import numpy as np
def verify_eigenvalues(matrices, expected_eigenvalues):
for i, matrix in enumerate(matrices):
eigenvalues, _ = np.linalg.eig(matrix)
print(f"Matrix {i + 1}:")
print(f"Computed Eigenvalues: {eigenvalues}")
print(f"Expected Eigenvalues: {expected_eigenvalues[i]}")
print()
# Define the matrices
matrices = [
np.array([[-4, 2], [3, 1]]),
np.array([[1, -3], [-4, 5]]),
np.array([[4, 1], [3, 6]]),
np.array([[4, 0, 1], [-2, 1, 0], [-2, 0, 1]]),
np.array([[4, 0, -1], [3, 0, 3], [2, -2, 5]]),
np.array([[-4, 1, 1], [2, -3, 2], [3, 3, -2]]),
np.array([[5, 0, -1, 0], [1, 3, 0, 0], [2, -1, 3, 0], [4, -2, -2, 4]])
]
# Define the expected eigenvalues
expected_eigenvalues = [
[-5],
[-1, 7],
[3, 7],
[1, 2, 3],
[3],
[-5],
[4]
]
# Verify eigenvalues
verify_eigenvalues(matrices, expected_eigenvalues)
PART B:
1)
A= [
−4 2
], λ=−5
3 1
Compute A−λI
−4 + 5
2
1 2
A−(−5)I=A+5I= [
]=[
]
3
1+5
3 6
Solve (A−λI)x⃗=0
1
[
3
2 𝑥
0
][ ]=[ ]
6 𝑦
0
x+2y=0
x=−2y
−2
Eigenvector = y [ ]
1
2)
A= [
1 −3
] λ=−1, 7
4 5
Compute A−(−1)I=A+I
2 −3
]
4 6
−3 𝑥
0
][ ]= [ ]
6 𝑦
0
A+I= [
2
[
4
2x-3y = 0
X=3/2y
3
Eigenvector = y [ 2 ]
1
For λ=7
1−7
A−7I= [
4−7
−3 − 7
]
5−7
-6x -10y = 0
X= 5/3 y
5
Eigenvector = y[ 3 ]
1
3)
A= [
4 1
] λ=3, 7
3 6
For λ=3
4−3
1
1
[
]=[
3
6−3
3
1
]
3
x+y = 0
x= -y
Eigenvector = y[
−1
]
1
For λ=7
4−7
1
−3 1
[
]=[
]
3
6−7
3 −1
-3x + y= 0
x= 1/3 y
1
Eigenvector= [ 3 ]
1
4)
4 0
A= −2 1
−2 0
1
0
1
λ=1,2,3
4−1
0
−2 1 − 1
−2
0
1
0 =
1−1
For λ=1
3 0 1
−2 0 0
−2 0 0
Row-Reduce Method:
1 0 1/3
0 0
0
0 0
0
Let x3= z and x2=u
x1+ 1/3z = 0
x1= -1/3z
1
0
−3
Eigenvector = z[ 0 ] + s[1]
0
1
For λ=2
4−2
0
−2 1 − 2
−2
0
1
0
1−2
Using Row reduce method
1
0
2 ‖0‖
0 −1 1
0
0 0 0
1
0
From row 2: -y+z = 0
Y=z
From row 1:
2
0
1
= −2 −1 0
−2 0 −2
X+1/2z= 0
x= -1/2z
1
−2
Eigenvector = z[ 1 ]
1
5)
4 0 −1
A= 3 0
3 λ=3
2 −2 5
4−3
0
3
0−3
2
−2
−1
1 0 −1
3 = 3 −3 3
5−3
2 −2 2
Row-Reducing Method:
R2 = R2-3R1
R3 = R3-2R1
Then R3= R3-(2/3)R2
We get:
1 0 −1
0 1 −2
0 0 0
From R2: y-2z=0
y= 2z
From R1: x−z=0
x=z
1
Eigenvector = z[2]
1
6)
−4 1
1
A= 2 −3 2
3
3 −2
We get;
λ=−5
A-(-5)I= A+5I
1 1 1
2 2 2
3 3 3
Row-Reducing method:
R2= R2-2R1
R3= R3-3R1
We get:
1 1 1
0 0 0
0 0 0
From R1: x+y+z=0
x=−y−z
Let y=s and z=t
−1
−1
Eigenvectors= s[ 1 ] + t [ 0 ]
0
1
0
0
]
0
4
λ=4
7)
5 0 −1
1 3
0
A= [
2 −1 3
4 −2 −2
After using (A-4I) we get;
1 0 −1 0
1 −1 0 0
[
]
2 −1 −1 0
4 −2 −2 0
Using Row reduce method:
R2= R2-R1
R3= R3-2R1
R4= R4-4R1
R3= R3-R2
R4=R4-2R2
We get:
1 0 −1 0
0 −1 1 0
[
0 0
0 0
0 0
0 0
From R2: −y+z=0
y=z
From R1: x−z=0
x=z
let z=t and w=s
1
0
1
0
Eigenvector= t[ ] + s[ ]
1
0
0
1
0
0
]
0
0