If I add print statements to olgss(x)
, like so:
def olgss(x) :
print "alpha is", alpha
print "x is", x
numg = ((1-alpha)*A*x**alpha)/(1+n)
deng = (1+(1/(beta**(sigma)))*(1+alpha*A*x**(alpha-1))**(1-sigma))
olgk = x - numg/deng
return olgk
I get the following output:
alpha is 0.3
x is 0.2
alpha is 0.3
x is 0.0126300785572
alpha is 0.3
x is -0.0251898297413
Traceback (most recent call last):
File "globals.py", line 36, in ?
state = olgss(state)
File "globals.py", line 13, in olgss
numg = ((1-alpha)*A*x**alpha)/(1+n)
ValueError: negative number cannot be raised to a fractional power
So, it looks like the third call to olgss()
is returning a negative value, which then feeds back into the next call and causes the error.