资源简介
进退法确定区间
代码片段和文件信息
# -*- coding: utf-8 -*-
import numpy as np
#x = np.array([0.0][0.0])
x=0.0
h = 1
c = 0.2
Cov = 1
u=1
Llist = 0
v=2
f1 = lambda x:3 * (x ** 3) - 4 * x + 2
f = lambda Llist:abs( Cov-(u*(1+v+2*u)-Llist*(1+v+u-u**2))/(1+u))
def init(x h):
x0 = x
print(“ h0=%r“%h)
print(“ x0=%r“%x0)
h0 = h
x1 = x0 + h0
print(“ x1=x0+h0=%r“%x1)
print(“ f(x0)=%rf(x1)=%r“%(f(x0)f(x1)))
if f(x0) < f(x1):
print(“ 由于f(x0) x2 = x0 - h0
print(“ x2=x0-h0%rf(x2)=%r“%(x2f(x2)))
if f(x2) > f(x0):
print(“ 此时f(x2)>f(x0)且f(x0) return [x2 x1]
elif f(x2) < f(x0):
print(“ 由于f(x2) x1 = x2
h0 = -h0
while f(x0) > f(x1):
print(“ 由于f(x0)>f(x1)方向正确,加大步长继续探索“)
x2 = x1 + 2 * h0
print(“ x2=x1+2h0=%rf(x2)=%r“ % (x2 f(x2)))
if f(x2) > f(x1):
- 上一篇:自适应(项目反应理论)算法-python
- 下一篇:numpy 使用
评论
共有 条评论