为什么x0=a/2.0?

使用迭代法求a的平方根。求平方根的迭代公式如下,要求计算到相邻两次求出的x的差的绝对值小于1E-5时停止,结果显示4位小数。

img

#include <stdio.h>
#include <math.h>
int main()
{
double a, x0, x1;

scanf("%lf", &a);
x0 = a/2.0;
x1 = 1.0/2*(x0+a/x0);
while(fabs(x0-x1)>=1e-5)
{
    x0 = x1;
    x1 = 1.0/2*(x0+a/x0);
}

printf("%.4lf", x1);

}