I seem to be facing an issue with a code I wrote trying to solve a population growth problem using the Euler Method. I've tried adjusting all the parameters in the code, but I still am met with the error: (34, 'numerical result out of range'). How can I solve this problem?
def f(N,t):
return a*N - b*N**2
a = float(input('birth rate = ')) #10
b = float(input('death rate = ')) #3
#bounds
c = 0.0
d = 100.0
# spacing for points
n = 1000
h = (d-c)/n
# initial population x(t=0)
N = float(input('initial population:')) #50
tpoints = arange(c,d,h)
xpoints = []
for t in tpoints:
xpoints.append(N)
N += h*f(N,t)
plot(tpoints, xpoints,'b-')
xlabel("time")
ylabel("population")
Thanks! :)