keisoku

Pi Calculator (Viete Formula)

Approximate pi using Viete infinite product formula. Enter the number of terms to see each partial product and the error against the true value of pi.

Input

Approximate pi using the Viete formula (an infinite product). Enter the number of terms to use.

Enter a whole number from 1 to 60.

Result

Approximation of pi with 10 terms

3.141591421511

Error from true pi

0.000001232079

Terms

10

True pi

3.14159265359

Convergence of partial products

Each row shows the factor of that term, the partial product from the first term, and the approximation of pi at that point.

TermFactorPartial productPi approximation
10.7071067811870.7071067811872.828427124746
20.9238795325110.6532814824383.061467458921
30.9807852804030.6407288619353.121445152258
40.9951847266720.6376435773363.136548490546
50.9987954562050.6368755077223.140331156955
60.9996988186960.6366836927263.141277250933
70.9999247018390.6366357516153.141513801144
80.9999811752830.6366237671273.141572940367
90.999995293810.6366207710543.141587725277
100.9999988234520.6366200220393.141591421511

The factors of 2/pi = (sqrt(2)/2)(sqrt(2+sqrt(2))/2)(sqrt(2+sqrt(2+sqrt(2)))/2)... are multiplied in order, and the approximation is 2 divided by the partial product.

How it works

  • Viete formula expresses 2/pi as an infinite product of nested square roots.
  • Each factor is a(k)/2, where a(1) equals the square root of 2 and a(k) equals the square root of 2 plus a(k-1).
  • Given the partial product P(n), the approximation of pi is 2 divided by P(n).
  • The more terms you add, the faster the approximation converges to the true pi.
  • The error is shown as the absolute difference between the approximation and the true pi.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Pi Calculator (Viete Formula)