23 lines
406 B
Python
23 lines
406 B
Python
|
import numpy as np
|
||
|
|
||
|
for n in [3,5,10,100,1000]:
|
||
|
A = np.zeros((n,n))
|
||
|
x = np.zeros((n,1))
|
||
|
y_c = np.zeros((n,1))
|
||
|
|
||
|
for i in range(0,n):
|
||
|
x[i] = i+1
|
||
|
y_c[i] = (i+1) * n;
|
||
|
|
||
|
for j in range(0,n):
|
||
|
A[i,j] =(i+1) / (j+1)
|
||
|
|
||
|
y = A@x
|
||
|
|
||
|
if n == 3 or n == 5:
|
||
|
print(x)
|
||
|
print(A)
|
||
|
print(y)
|
||
|
|
||
|
print("Fuer n =",n,":",np.linalg.norm(y - y_c))
|