diff --git a/Schenk_Brandenberger_S10_Aufg1.pdf b/Schenk_Brandenberger_S10_Aufg1.pdf new file mode 100644 index 0000000..4cfd7b1 Binary files /dev/null and b/Schenk_Brandenberger_S10_Aufg1.pdf differ diff --git a/Schenk_Brandenberger_S10_Aufg1.py b/Schenk_Brandenberger_S10_Aufg1.py new file mode 100644 index 0000000..a28bedf --- /dev/null +++ b/Schenk_Brandenberger_S10_Aufg1.py @@ -0,0 +1,25 @@ +import numpy as np + + +print("*********Jacobi-Verfahren*********") +def Jacobi(A,b,x,steps): + L = np.tril(A,k=-1) + D = np.diag(np.diag(A)) + R = np.triu(A, k=1) + for steps in range(steps): + x = -np.linalg.inv(D) @ (L + R) @ x + np.linalg.inv(D) @ b + #print(np.linalg.norm((-np.linalg.inv(D) @ (L + R)),np.inf)) + return x + + + +A = np.array([[8,5,2],[5,9,1],[4,2,7]]) +b = np.array([[19],[5],[34]]) +x = np.array([[1],[-1],[3]]) +steps = 3 +print(Jacobi(A,b,x,steps)) +print("Sum of vector:") +#print(np.sum(Jacobi(A,b,x,steps))) +#print(np.linalg.norm(Jacobi(A,b,x,3)-Jacobi(A,b,x,2),np.inf)*7) +print(np.linalg.norm(Jacobi(A,b,x,3)-Jacobi(A,b,x,2),np.inf)) +print((0.0001*0.125)/0.7693452380952384) \ No newline at end of file