牛顿迭代求根法,自己去查一下公式,这里我给出C语言代码,可自行修改一下。
double sqrt_db(double theInput){ double si=1; uint16_t times=0; if (theInput==0) { return 0; } do { si+=theInput/si; si/=2; times++; } while (times<12);//12次足矣(具体精度自己定) return si;}