Question: Implement a function, solve-qrX, y), which uses the QR-based algorithm to estimate . To solve the triangular system, use Scipy's specialized function, available as sp.linalg.solve_triangular0)

Implement a function, solve-qrX, y), which uses the QR-based algorithm to estimate . To solve the triangular system, use Scipy's specialized function, available as sp.linalg.solve_triangular0) import scipy.linalg def solve qr (x, y): #* YOUR CODE HERE theta-qr solve-qr ( x, y) = print("Comparing your QR solution to the true solution:") show_2vecs_tibble (theta qr, theta true, xname-'theta qr, yname-'theta true',error-True) print("Residual norm:" calc_residual_norm(X, y, theta gr) # Test cell: solvegrtest import re - - try del np.linalg.1stsq solve qr (X, y) if re.findall('1stsq',n.args[0]): raise n except NameError as n: print("**Double-check that you did not try to use 1stsg) except AttributeError as a: if re.findall('1stsq',a.args[0]): raise a np . linalg. 1stsq = SAVE-LSTSQ print("**Double-check that you did not try to use 1stsq) finally assert np.isclose (theta qr, theta true).all,"Your QR-based solution should be closer to the true solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
