Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this quiz you must write a function which takes a Matrix as it\'s argument a

ID: 3910577 • Letter: F

Question

For this quiz you must write a function which takes a Matrix as it's argument and computes and prints the QR factorization using the modified Gram-Schmidt algorithm, All functions in your script which take either 2 vectors, or a matrix and a vector, must check to make sure that they are of compatible dimensions and contain numbers(remember that in python 3 we have 3 types of numbers, int, float, and complex.) As usual, all functions must include both comments and a docstring The only built in functions you are allowed to use are the absolute value, .append, and print functions. Use of functions such as max or zip will result in a grade of 0 for code and specifications followed.

Explanation / Answer

Hello,

QR factorization using the modified Grmm-Schmidt algorithm can be solved easily in python3. The code can be seen below.

#QR Factorization

def NormTwo(VEC):
InStat = True
for i in range(len(VEC_1)):
    if ((type(VEC_1[i]) != int) and (type(VEC_1[i]) != float) and (type(VEC_1[i]) != complex)):
      InStat = False
      print("Invalid Input")
      if InStat == True:
          Result = 0
          for i in range(len(VEC_1)):
              Result = Result + (VEC_1[i]**2)
          Result = Result**(1/2)
          return Result
def QR(MAT):
    r[i][i] = NormTwo(VEC_1)
    return [VEC_1 * (1/(NormTwo(VEC_1)) for i in MAT]
    for j in range(len(MAT)):
        r[i][j] = q[i] * VEC_2[i]
        VEC_2 = VEC_2[i] - (r[i][j] * q[i])
MAT = [[1, 2], [0, 1], [1, 0]]
VEC_1 = [1, 0, 1]
VEC_2 = [2, 1, 0]

Hope, I have solved your problem.:)

Thank you :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote