本文整理匯總了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=[]