Compare commits
	
		
			No commits in common. "6c893b33b04e45f4e52bef888982702bab9b1cee" and "6c4c492a453d172e417e32daffb93c5892d928d8" have entirely different histories.
		
	
	
		
			6c893b33b0
			...
			6c4c492a45
		
	
		
										
											Binary file not shown.
										
									
								
							|  | @ -1,25 +0,0 @@ | |||
| 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) | ||||
										
											Binary file not shown.
										
									
								
							|  | @ -1,21 +0,0 @@ | |||
| import numpy as np | ||||
| 
 | ||||
| print("*********Gauss Seidel*********") | ||||
| def Gauss_Seidel(A,b,x,steps): | ||||
|     L = np.tril(A,k=-1) | ||||
|     D = np.diag(np.diag(A)) | ||||
|     R = np.triu(A, k=1) | ||||
|     print(np.linalg.norm(-np.linalg.inv(D+L) @ R,np.inf)) | ||||
|     for steps in range(steps): | ||||
|         x = -np.linalg.inv(D+L) @ R @ x + np.linalg.inv(D+L) @ b | ||||
|     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(Gauss_Seidel(A,b,x,steps)) | ||||
| print("Sum of vector:") | ||||
| print(np.sum(Gauss_Seidel(A,b,x,steps))) | ||||
| print(np.linalg.norm(Gauss_Seidel(A,b,x,3)-Gauss_Seidel(A,b,x,2),np.inf)) | ||||
		Loading…
	
		Reference in New Issue