Jump to content

Arithmetic-geometric mean/Calculate Pi: Difference between revisions

Line 1,395:
} = \frac{\sqrt{n 10^{2N} / d}}{10^N}</math>
 
so that what we need is one square root of a big number that we'll truncate to its integer part. We'll computeuse the squaremethod rootdescribed ofin this[[Integer bigroots]] integerto by usingcompute the convergencesquare root of thethis recursivebig integer. sequence:
 
<math>u_{n+1} = \frac{1}{2}(u_n + \frac{x}{u_n})</math>
 
It's not too hard to see that such a sequence converges towards <math>\sqrt x</math>.
 
Notice that we don't get the exact number of decimals required : the last two decimals or so can be wrong. This is because we don't need <math>a_n</math>, but rather <math>a_n^2</math>. Elevating to the square makes us lose a bit of precision. It could be compensated by choosing a slightly higher value of N (in a way that could be precisely calculated), but that would probably be overkill.
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.