Gauss–Legendre algorithm: Difference between revisions

Content deleted Content added
m Bot: Migrating 1 interwiki links, now provided by Wikidata on d:Q2448949
m Algorithm: Cleaned up using AutoEd
Line 6:
 
== Algorithm ==
# Initial value setting:<br /><math>a_0 = 1\qquad b_0 = \frac{1}{\sqrt{2}}\qquad t_0 = \frac{1}{4}\qquad p_0 = 1.\!</math>
 
2.# Repeat the following instructions until the difference of <math>a_n\!</math> and <math>b_n\!</math> is within the desired accuracy:<br /><math> \begin{align} a_{n+1} & = \frac{a_n + b_n}{2}, \\
1. Initial value setting:
 
:<math>a_0 = 1\qquad b_0 = \frac{1}{\sqrt{2}}\qquad t_0 = \frac{1}{4}\qquad p_0 = 1.\!</math>
 
2. Repeat the following instructions until the difference of <math>a_n\!</math> and <math>b_n\!</math> is within the desired accuracy:
 
<math> \begin{align} a_{n+1} & = \frac{a_n + b_n}{2}, \\
b_{n+1} & = \sqrt{a_n b_n}, \\
t_{n+1} & = t_n - p_n(a_{n}-a_{n+1})^2, \\
Line 19 ⟶ 13:
\end{align}
</math>
# π is then approximated as:<br /><math>\pi \approx \frac{(a_{n+1}+b_{n+1})^2}{4t_{n+1}}.\!</math>
 
3. π is then approximated as:
 
<math>\pi \approx \frac{(a_{n+1}+b_{n+1})^2}{4t_{n+1}}.\!</math>
 
The first three iterations give (approximations given up to and including the first incorrect digit):