本文整理汇总了Python中function.Function.fnf方法的典型用法代码示例。如果您正苦于以下问题:Python Function.fnf方法的具体用法?Python Function.fnf怎么用?Python Function.fnf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类function.Function
的用法示例。
在下文中一共展示了Function.fnf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: map
# 需要导入模块: from function import Function [as 别名]
# 或者: from function.Function import fnf [as 别名]
import function
if __name__=="__main__":
print "please input the number that a,b,c,d for function"
a,b,c,d = map(int, raw_input('input a,b,c,d=').split(","))
func=Function(a,b,c,d)
func.showinfo()
while True:
print "input l,r | l<r & f(l)*f(r)<0"
l,r = map(float,raw_input('input l,r=').split(","))
if (func.fnf(l)<func.fnf(r)) and (func.fnf(l)*func.fnf(r)<0):
print "correct"
break
else:
print "wrong numbers (l>r or f(l)*f(r)>=0)"
th = float(raw_input('please input threshold:'))
k=0
results=[]
while r-l >= th:
k+=1
print("{0:4d},{1:8.5f},{2:8.5f},{3:8.5f}".format(k,l,r,r-l))
center = (l+r)/2.0
results.append((k,center))
示例2: map
# 需要导入模块: from function import Function [as 别名]
# 或者: from function.Function import fnf [as 别名]
from function import Function
import function
if __name__ == '__main__':
print "please input the number that a,b,c,d for function"
a,b,c,d = map(int, raw_input('input a,b,c,d=').split(","))
func=Function(a,b,c,d)
func.showinfo()
while True:
print "input x,r | x<r & f(x)*f(r)<0"
x,r = map(float,raw_input('input x,r=').split(","))
if (func.fnf(x)<func.fnf(r)) and (func.fnf(x)*func.fnf(r)<0):
print "correct"
break
else:
print "wrong numbers (x>r or f(x)*f(r)>=0)"
th = float(raw_input('please input threshold:'))
k=0
print "number of process, approximation, diff"
print("{0:4d},{1:8.5f},{2}".format(k,x,"---"))
approximations=[]