I have tried a code in python for Francis QR algorithm but didn't desire the result. I don't know if it is possible to code in maple.
Given that A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]].
1. Write a little program that computes 1 step of Francis QR and test your program by starting from
A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]] and compute A^1, A^2 ...A^6.
I expected to get:
A^0 = [[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]],
A^1 = [[3.5, -4.264, 0.2688], [-9.206, 1.577, 9.197], [0., -1.41, 1.923]],
... A^6 = [[8.056, 1.596, 8.584], [0.3596, -2.01, -7.86], [0., 2.576*10^(-16), 0.9542]].
But didn't get the same results.
Here is my python code:
# Import packages
import numpy as np
from numpy.linalg import qr # QR from Linear Algebra Library
import scipy.linalg # SciPy Linear Algebra Library
A = np.array([[3.0, 1.0, 4.0], [1.0, 2.0, 2.0], [0., 13.0, 2]])
p = [1, 2, 3, 4, 5, 6]
for i in range(30):
q, r = qr(A)
a = np.dot(r, q)
if i+1 in p:
print("Iteration {i+1}")
print(A)
I would really appreciate your help.
Thank you.