import time
start=time.clock()
q=0
O=input()
x=[1,2,3,4]
y=[1,1,1,1]
n=len(x)
A=[[1 for k in range(n)]for k in range(n)]
for i in range(n):
for j in range(n):
A[i][j]=x[i]**j
X=np.matrix(A)
Y=np.array([[y[i]] for i in range(n)])
a=X**-1*Y
for i in range(n):
q=q+a[i][0]*(O**i)
print q
>>> X
matrix([[ 1, 1, 1, 1],
[ 1, 2, 4, 8],
[ 1, 3, 9, 27],
[ 1, 4, 16, 64]])
>>> Y
array([[1],
[1],
[1],
[1]])
>>> ================================ RESTART ================================
>>>X**-1 *Y
[[ 1.00000000e+00]
[ -6.66133815e-16]
[ 0.00000000e+00]
[ -2.77555756e-17]]
沒有留言:
張貼留言