本文整理匯總了Python中function.Function.diff方法的典型用法代碼示例。如果您正苦於以下問題:Python Function.diff方法的具體用法?Python Function.diff怎麽用?Python Function.diff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類function.Function
的用法示例。
在下文中一共展示了Function.diff方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: numbers
# 需要導入模塊: from function import Function [as 別名]
# 或者: from function.Function import diff [as 別名]
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=[]
while True:
k+=1
xn = x - func.fnf(x)/func.diff(x)
print("{0:4d},{1:8.5f},{2:8.5f}".format(k,xn,xn-x))
temp=(k,x)
approximations.append(temp)
if(math.fabs(xn-x) < th):
break
else:
x=xn
print "number of process = {0:4d}".format(k)
print "the solution = {0:10.6f}".format(xn)
function.write_csv("newton_results.csv",approximations)