Question: why is this code not working, I cannot figure out please help! import numpy as np # Given values x 1 = 2 . 9
why is this code not working, I cannot figure out please help! import numpy as np
# Given values
x
x
x
x
# Constructing matrix A
A nparray
# Constructing vector b
b nparrayx x x xdtypefloat
def householderA:
m n Ashape
Q npeyem
for k in rangen:
u Ak: kcopy
u npsignu nplinalg.normu
u nplinalg.normu
Ak: k: npouteru u @ Ak: k:
Qk: : npouteru u @ Qk: :
return Q
#Apply the Householder transformation to A
Q householder A
R Q A
#Implement the backward substitution
def backwardSubstitutionA b:
n Ashape
x npzerosn
for i in rangen :
xibi npdotAi i : xi : Ai i
return x
#tep : Solve for the best values of the altitudes using backward substitution.
xhat backwardSubstitution R QT @ b
dx xhat nparray x x x x
#Step : Print the required values
printMatrix A:
printA
print
Calculated Altitudes xhat:
printxhat
print
Differences dx:
printdxI got the response but it st
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
