I'm trying to get an array from an f(x) function this way:
array=list()
for i in range(x):
parameter= z+(i*change)
array=f(parameter)
Note that x is an integer, z and change are floats established in my code.
The next thing I want is to use simpson's rule using the simps function in scipy. I tried this:
Simpsons= integrate.simps(array, dx=change)
It says there is an error How can I solve this?
The problem line is array=f(param)
. You're assigning array
to the result of f
, not appending it. You should do array.append(f(param))
.