python方法求开方牛顿、拉复生方法,python牛顿,Python求开方牛顿、
python方法求开方牛顿、拉复生方法,python牛顿,Python求开方牛顿、
Python求开方牛顿、拉复生方法
def SquarerootNR(x,eplison): assert x>=0, 'x must be non negtive not'+str(x) assert eplison>0,'eplison must be positive not'+str(eplison) x=float(x) guess=x diff=guess**2-x ctr=1 while abs(diff)>eplison and ctr<=100: guess=guess-diff/(2*guess) diff=guess**2-x ctr+=1 assert ctr<=100 ,'the times of iteration is too much' print 'NR method:' print 'guess: %f iteration: %d' %(guess,ctr) return guess
编橙之家文章,
相关内容
- Python UTF8文件去BOM方法示例,,Python UTF8文
- 初学python怎么用while循环笔记分享,pythonwhile,下面是我
- Python修改文件名的简单实现,python修改文件名,Python修改
- 用python实现SGMLParser模块解析网页示例,pythonsgmlparser,这
- 在线聊天室python 服务器端代码片段,,以下python代码是
- 寻找质数方法Python2.7版本,寻找质数python2.7,这是个人的
- 度换算成度分秒的Python操作方法,成度python,度换算成度
- 判断某个整数是否在二维数组中的python方法,二维数组
- Python模拟实现单链表源码示例,python单链,Python模拟实现
- 读取tomcat日志并打印日期的正则表达式,tomcat正则表达
评论关闭