Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
printdx
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started