Assignment 8
Assignment 8
Assignment 8
ipynb - Colaboratory
import numpy as np
import cmath
U = np.array([0.5, 0.4, 0.4, 0.5, 0.1, 0.4, 0.1])
V= np.array([-1,-2, 1,-2, 3, 1,-5])
Umag = np.linalg.norm(U)
Vmag = np.linalg.norm(V)
print('Magnitude of U', Umag)
print('Magnitude of V', Vmag)
Magnitude of U 1.0
Magnitude of V 6.708203932499369
v = (1, 2, 5, 2,-3, 1, 2, 6, 2)
u = (-4, 3, -2, 2, 1, -3, 4, 1, -2)
w = (3, 3, 3, -1, 6,-1, 2,-5,-7)
import numpy as np
import cmath
U= np.array([-4, 3, -2, 2, 1, -3, 4, 1, -2])
V = np.array([1, 2, 5, 2,-3, 1, 2, 6, 2])
W= np.array([3, 3, 3, -1, 6,-1, 2,-5,-7])
Umag = np.linalg.norm(U)
Vmag = np.linalg.norm(V)
# Calculate the dot product
dot_product1 = np.dot(V,W)
dot_product2 = np.dot(U,V)
dot_product3 = np.dot(W,U)
# Print the result
print("Dot Product of V and W:" dot product1)
https://colab.research.google.com/drive/1DKH4FlQCWyxGAm7HRIXi-7oAmmaXUteO?auth… 1/4
06/11/2023, 16:17 Assignment8.ipynb - Colaboratory
print( Dot Product of V and W: , dot_product1)
print("Dot Product of U and V:", dot_product2)
print("Dot Product of W and U:", dot_product3)
if(dot_product1==0):
print("V and W are orthogonal vectors")
if(dot_product2==0):
print("U and V are orthogonal vectors")
if(dot_product3==0):
print("w and u are orthogonal vectors")
Code Text
import numpy as np
import cmath
B = np.array([[4,4,4],
[-2,3,-7],
[2,5,-7]])
C = np.array([[4,-1,2],
[-8,2,-4],
[2,1,-4]])
# i. Evaluate ATB
result1 = np.dot(np.transpose(A), B)
print("Transpose of A ")
https://colab.research.google.com/drive/1DKH4FlQCWyxGAm7HRIXi-7oAmmaXUteO?auth… 2/4
06/11/2023, 16:17 Assignment8.ipynb - Colaboratory
print( Transpose of A )
print(np.transpose(A))
print()
# ii. Evaluate C + B
result2 = C + B
full_rank_A = is_full_rank(A)
full_rank_B = is_full_rank(B)
full_rank_C = is_full_rank(C)
Transpose of A
[[ 2 -3 5]
[-2 1 -3]]
ATB:
[[ 24 24 -6]
[-16 -20 6]]
C + B:
[[ 8 3 6]
[-10 5 -11]
[ 4 6 -11]]
Inverse of B:
[[-0.11666667 -0.4 0.33333333]
[ 0.23333333 0.3 -0.16666667]
[ 0.13333333 0.1 -0.16666667]]
https://colab.research.google.com/drive/1DKH4FlQCWyxGAm7HRIXi-7oAmmaXUteO?auth… 3/4
06/11/2023, 16:17 Assignment8.ipynb - Colaboratory
https://colab.research.google.com/drive/1DKH4FlQCWyxGAm7HRIXi-7oAmmaXUteO?auth… 4/4