I am trying to calculate a value of function f_integ
, which is a result of integration of function f
from 0 to x_v
.
f = lambda x : x + 1
def f_integ(x_array):
int_result = np.zeros_like(x_array)
indexes = np.shape(x_array)[0]
for ind in range(indexes):
x_v = x_array[ind]
int_result[ind] = integ.quad(f, 0.0, x_v)[0]
return int_result
C = f_integ(1)
print "C", C
When I run this, I get the following error:
Traceback (most recent call last):
File "untitled.py", line 117, in <module>
C = f_integ(1)
File "scr1.py", line 110, in f_integ
indexes = np.shape(x_array)[0]
IndexError: tuple index out of range
I know that quad()
returns a tuple, but I can not figure out how to put a number as an argument in the result of integration. I'm new to Python, please help.