timotheetremblais
New Coder
I have defined those three functions:
```
def deriv(y,x) :
dx = 10**(-5)
dx2 = dx/2
return ((y(x+dx2)-y(x-dx2))/(dx))
def fex(y,x) :
y_0 = y(x)
return (np.sqrt(1 + deriv(y,x)**2))/(np.sqrt(2*9.81*(y_0-y(x))))
def tang(y,a,x):
y_a= y(a)
return(y_a+deriv(y,a)*(x-a))
```
I am using numpy and `x` is a list of numbers that is generated by this command: `x = np.linspace(0,1,100)` that creates a list of 100 numbers between zero and one.
My goal is to have a list of numbers that represent the values on the tangent that correspond to the elements of the `x` list.
So I wrote that in my code:
tang(fex(y,x),a, x)
But my problem goes as follows: When the computer tries to find `y(a)` in the tangent function he do not understand that I am looking for `fex(y,a)` so it there is an error wich is `TypeError: 'numpy.ndarray' object is not callable`. So i figured out that the `fex` element that recieve `tang` is a list wich is no problem for the rest of the program but just for this `y(a)` thing it is.
```
def deriv(y,x) :
dx = 10**(-5)
dx2 = dx/2
return ((y(x+dx2)-y(x-dx2))/(dx))
def fex(y,x) :
y_0 = y(x)
return (np.sqrt(1 + deriv(y,x)**2))/(np.sqrt(2*9.81*(y_0-y(x))))
def tang(y,a,x):
y_a= y(a)
return(y_a+deriv(y,a)*(x-a))
```
I am using numpy and `x` is a list of numbers that is generated by this command: `x = np.linspace(0,1,100)` that creates a list of 100 numbers between zero and one.
My goal is to have a list of numbers that represent the values on the tangent that correspond to the elements of the `x` list.
So I wrote that in my code:
tang(fex(y,x),a, x)
But my problem goes as follows: When the computer tries to find `y(a)` in the tangent function he do not understand that I am looking for `fex(y,a)` so it there is an error wich is `TypeError: 'numpy.ndarray' object is not callable`. So i figured out that the `fex` element that recieve `tang` is a list wich is no problem for the rest of the program but just for this `y(a)` thing it is.