from mpmath import * u=mpi(0) def h(x): return iv.exp(u*(x-1)) def f_1(x,a): return h(x)*iv.exp(a*(x-1)) def h_1(x,y,a): return (1-y*(u+a))*f_1(x,a) def L_3(f): def g(x): return (x+3)/4 * f((x+2)/3)**3 + (x+2)/2 * ( f((x+1)/3)**2 - f((x+2)/3)*f((x+1)/3)**2 ) - (x+1)/4 * (f((x+2)/3)**2 * f(x/3) + 2*f((x+1)/3)*f(x/3) - 2*f((x+2)/3)*f((x+1)/3)*f(x/3) - f(x/3)) return g def H_3(f): def g(x): return (x+3)/4 * f((x+2)/3)**3 + (x+2)/3 * ( f((x+1)/3)**2 - f((x+2)/3)*f((x+1)/3)**2 ) - (x+1)/12 * (f((x+2)/3)**2 * f(x/3) + 2*f((x+1)/3)*f(x/3) - 2*f((x+2)/3)*f((x+1)/3)*f(x/3) - f(x/3)) return g def G_1(f): def G_1f(x): a=L_3(f)(x/2) b=L_3(f)((x+1)/2) c=H_3(f)(x/2) d=H_3(f)((x+1)/2) return (x/3)*a+((x+1)/3)*b**2-(x/3)*a*b+(1/3)*c+(1/3)*b*d-(1/3)*b*c return G_1f m=1 while m < 341: f_2=G_1(h) for a in map(mpi, [1/16,1/32,3/256]): for j in range(256): A = f_2( mpi(j/256) ) B = h_1( mpi(j+1)/256, mpi(1/256), a) if A.b>B.a: break else: break else: break print(m) m=m+1 u+=a print(m, u)