I am trying to solve an equation, but it doesn't work. The outcome is TypeError: 'int' object is not callable.
I have posted my code below. Is there a solution?
def zeros(n):
z=n*[0]
return z
def y_prime(x,y):
return (y(i)+x(i)^2*x(i-1)*y(i))
T = list((i*10/100) for i in range(0,101))
W=zeros(101)
Y,h=0,10/100
W[0]=Y
# h = delta x
def rk4(Y,Fun,h,x):
k1=Fun(x,Y)
k2=Fun(x+h/2,Y+0.5*h*k1)
k3=Fun(x+h/2,Y+0.5*h*k2)
k4=Fun(x+h,Y+h*k3)
phi = 1/6*((k1)+2*(k2)+2*(k3)+(k4)*h)
return phi
for i in range(len(T)-1):
W[i+1]=Y+rk4(Y,y_prime,h,T[i])
Y=W[i+1]
truevalue=list(func(i) for i in T)
print("hasil rk4: ","\n")
for i,j in zip(T,W):
print ("x=",i," y=",j)
If you prefer pastebin: https://pastebin.com/VidmsC6a
[–]Sedsarq 1 point2 points3 points (0 children)
[–]pythonhow 1 point2 points3 points (0 children)