Good morning,
The value of x
is a decrease of 1.0 - 0.01
asi, the first value of x=0.99
the second x=0.98
and the third x=0.97
The first value is x1=1.0
The problem is the update of x1
and that the loop uses the new value x=0.98
My code is as follows:
import scipy.optimize
from scipy import optimize
import numpy as np
n=763.0
s=762.0
y=0.5673
b=0.0026
x=[0.99,0.98,0.97]
x1=1.0
i=1
for iteration in range(1,3):
def l(x, x1, b,n,y,s):
def p(x):
return 1.0/(x*(b*n+y*np.log(x)-s*b*x))
ds = scipy.integrate.fixed_quad(p, x, x1, args=(), n=5)
return (ds[0]-1)
def t(x, x1, b, n, y, s):
x1=scipy.optimize.brentq(l, x, x1, args=(b, n, y, s))
return x1
x=x1
i=i+1
print x
The output is wrong and it is:
1.0
1.0
I appreciate the help.