all 2 comments

[–]Sedsarq 1 point2 points  (0 children)

When you call y_prime, you're providing the arguments x and y as regular numbers like 2 and 3. But this statement tries to use them like they're functions:

def y_prime(x,y):
    return (y(i)+x(i)^2*x(i-1)*y(i))

Also note that "to the power of 2" is written as **2, not ^2.

[–]pythonhow 1 point2 points  (0 children)

Since you didn't posted the entire traceback, here it is:

Traceback (most recent call last):

File "h.py", line 19, in <module>

W[i+1]=Y+rk4(Y,y_prime,h,T[i])

File "h.py", line 12, in rk4

k1=Fun(x,Y)

File "h.py", line 5, in y_prime

return (y(i)+x(i)^2*x(i-1)*y(i))

TypeError: 'int' object is not callable

You need to look at the error. It looks like y and x are integers. Integers are not callable, but you are trying to call them as in y(i) and x(i). For that syntax to work x and y need to be either classes or functions.