public double getSqrt(double input){
double x = 1;
double x1 = x - (x * x - input) / (2 * x);
while (x - x1 > 0.00000001 || x - x1 < -0.00000001){
x = x1;
x1 = x - (x * x - input) / (2 * x);
}
return x1;
}
[算法系列] x的平方根——牛顿迭代(Java)
![](https://img-home.csdnimg.cn/images/20240711042549.png)