can somebody help me? I don’t understand how to fix the error in this case. I’ve already tried with numpy array, but the problem still presents.
What I’m trying to do is: to calculate the runge function with the x for n iterations. For making this, I think that I have do put every single x in a list, and I do this with the fill_cheby function. After this, I want to use the numbers in list1 as arguments of lagrange function in runge_interpolate. Here the code and the complete traceback:
def fill_cheby(list1,n,x): if n==0: return n, x else: for i in range(0,n): x=np.cos(((2*(n-i)+1)*3.14)/(2*(n+1))) list1.append(x) return list1 def runge_interpolate(n): p=lagrange(list1, runge(x)) print("Il polinomio è ", p) return x, p list1= n=5 x=0 fill_cheby(list1,n,x)
Traceback (most recent call last):
File “arraycheby.py”, line 33, in
File “arraycheby.py”, line 19, in fill_cheby
TypeError: descriptor ‘append’ requires a ‘list’ object but received a ‘numpy.float64’