Xn+1 = 2 * Xn - A * Xn2The significant digit is Doubles with each iteration.
hn = 1 - A * xnRecurrence formula for 1 / A of fourth-order convergence
xn+1 = xn * (1 + hn + hn2)
The number of significant digits is tripled with each repetition. hn is equal to the error of xn .
hn = 1 - A * xnRecurrence formula for 1 / A of fifth-order convergence
xn+1 = xn * (1 + hn) * (1 + hn2)
hn = 1 - A * xn
xn+1 = xn * (1 + (1 + hn2) * (hn + hn2))
Xn+1 = (Xn + A / Xn) / 2However, this formula has the disadvantage of having to perform each A / Xn division, which requires a lot of computation time.
Xn+1 = Xn * (3 - A * Xn2) / 2That is, the above equation (since 3/2 and 1/2 are constants) only requires multiplication.
hn = 1 - A * xn2Recurrence formula for 1 / √A of fourth-order convergence
xn+1 = xn * (1 + hn * (4 + 3 * hn) / 8)
The number of significant digits is tripled with each repetition. hn is equal to the error of xn .
hn = 1 - A * xn2Recurrence formula for 1 / √A of fifth-order convergence
xn+1 = xn * (1 + hn * (8 + hn * (6 + 5 * hn)) / 16)
hn = 1 - A * xn2Recurrence formula for 1 / √A of 6th-order convergence
xn+1 = xn * (1 + (64 * hn + hn2 * (48 + 40 * hn + 35 * hn2)) / 128)
hn = 1 - A * xn2
xn+1 = xn * (1 + hn * (1/2 + hn * (3/8 + hn * (5/16 + hn * (35/128 + hn * 63/256)))))
hn = 1 - A / xn2
xn+1 = xn * (1 - hn * (1/2 + hn * (1/8 + hn * (1/16 + hn * (5/128 + hn * 7/256)))))
hn = 1 - A * xn3
xn+1 = xn + xn * hn * (1/3 + hn * (2/9 + hn * (14/81 + hn * (35/243 + hn * 91/729))))
hn = 1 - A * xn4
xn+1 = xn + xn * hn * (1/4 + hn * (5/32 + hn * (15/128 + hn * (195/2048 + hn * 663/8192))))
Example of a C program with fourth-order convergence to find √x*note1 : It is better to expand the loop as current processors can calculate the contents while determining the jump condition of the loop. If the machine ε is about 10-16, three calculations are enough.
#include <stdio.h> #include <math.h> #ifndef DBL_EPSILON #define DBL_EPSILON 2.2204460492503131E-16 #endif double _sqrtinv(a) double a; { double x, h, g; int e; /* enhalf the exponent for a half digit initial accuracy */ frexp(a, &e); x = ldexp(1.0, -e >> 1); /* 1/sqrt(a), fourth-order convergence */ g = 1.0; while(fabs( h = 1.0 - a * x * x) < fabs(g)) { x += x * (h * (8.0 + h * (6.0 + 5.0 * h)) / 16.0); g = h; } return(x); } double sqrt(a) double(a); { if(a < 0){ fprintf(stderr, "sqrt: domain error\n"); return(0); } return(a * _sqrtinv(a)); }