Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 498 Bytes

牛顿迭代法求平方根.md

File metadata and controls

18 lines (17 loc) · 498 Bytes

迭代公式推导

    • 这边是2次,所以直接以y=x^2化简了

实现它

def get_ans(nums,count=10000):
    ans = nums
    if not ans:
        return ans
    Times = 0
    while Times<count:
        ans = 0.5*(ans+nums/ans)
        Times+=1
    return ans