2
雖然在試圖計算從下面的函數x(n+1) = 1 -a*x(n)**2 + y(n); y(n+1) = b*x(n)
的雅可比矩陣點積,我得到以下錯誤:vec1 = J*vec1 TypeError: can't multiply sequence by non-int of type 'list'
乘法
import numpy as np
a, b = 1.2, 0.4
x, y = 0., 0.
vec1 = [[1], [0]]
vec2 = [[0], [1]]
for i in range(500):
x1 = 1. - a*x**2 + y
y1 = b*x
x = x1
y = y1
J = [[-2.*a*x, 1], [b, 0]]
vec1 = J*vec1
vec2 = J*vec2
dotprod1 = np.dot(vec1,vec1)
dotprod2 = np.dot(vec1,vec2)
print(dotprod1)
print(dotprod2)