Connect via MCP →

Enter Calculation

Approximates pi from a 4-gon up to a 2^(n+1)-gon. Double-precision rebuild resolves about 15 significant digits.

Formula

Formula: Viete's Formula Pi Calculator
Show calculation steps (1)
  1. Iterative form

    Iterative form: Viete's Formula Pi Calculator

    Running cosine half-angle product; s_k = cos(pi/2^(k+1)), pi = 2 divided by the product of all s_k.

Advertisement

Results

Approximation of pi
3.14159265358979
via Viete's infinite product
Iterations actually used 28
Requested display digits 26
Reference pi 3.14159265358979

What is Viete's Formula?

In 1593 the French mathematician Francois Viete published the first known infinite product that expresses the constant pi in closed analytic form. It is built entirely from nested square roots of one half. This calculator evaluates that product up to a chosen number of terms and shows how quickly the value converges to \(3.14159265358979\). It is pure mathematics and gives the same answer anywhere in the world.

$$\frac{2}{\pi} = \sqrt{\tfrac12} \cdot \sqrt{\tfrac12 + \tfrac12\sqrt{\tfrac12}} \cdot \sqrt{\tfrac12 + \tfrac12\sqrt{\tfrac12 + \tfrac12\sqrt{\tfrac12}}} \cdots$$
Sequence of nested square root terms multiplied together converging to a value near a target line
Each successive nested-radical factor nudges the running product closer to \(2/\pi\).

How to use it

Enter a loop count (the number of product terms to evaluate, default 100) and pick how many display digits you want. Each extra term corresponds to doubling the number of sides of an inscribed regular polygon, going from a 4-gon up to a \(2^{(n+1)}\)-gon. Because this rebuild uses standard IEEE 754 double precision, pi is resolved to about 15 significant digits; the display-digits selector simply rounds the output to that many figures.

The formula explained

Start with \(s = 0\) and \(y = 1\). For each step \(k\), update \(s\) to the square root of \((1 + s) / 2\), then multiply that into the running product \(y\). Each factor equals \(\cos(\pi / 2^{(k+1)})\), and the product of these cosines tends to \(2/\pi\). Therefore pi is approximated by 2 divided by the running product \(y\). The estimate rises toward pi from below, gaining roughly one correct binary digit per term.

$$s_k=\sqrt{\tfrac{1+s_{k-1}}{2}},\quad y_k=\prod_{i=1}^{k}s_i,\quad \pi=\frac{2}{y_k}$$
Advertisement
Nested square root structure showing one half plus one half times another square root repeated
The terms are built by repeatedly nesting \(\sqrt{1/2 + 1/2\,x}\) inside itself.

Worked example

\(k=1\): \(s = \sqrt{0.5} = 0.70710678\), \(y = 0.70710678\), \(\pi \approx 2.82842712\). \(k=2\): \(s = 0.92387953\), \(y = 0.65328148\), \(\pi \approx 3.06146746\). \(k=3\): \(\pi \approx 3.12144515\). \(k=4\): \(\pi \approx 3.13654849\). By \(k=20\) the value already matches pi to 14 decimals, and any loop count of about 30 or more locks in \(3.14159265358979\) in double precision.

FAQ

Why does increasing display digits beyond 15 not help? Standard double-precision floating point only holds about 15 to 16 significant digits, so the underlying math cannot resolve more than that regardless of the selector.

Why does a tiny loop count give a poor estimate? The product converges geometrically; with only a handful of terms you are still approximating a low-sided polygon, so the value is noticeably below pi.

Does the result ever overshoot pi? No. Every factor is a cosine less than 1, so \(2/y\) always approaches pi from below as an under-estimate.

Last updated: