François Viète's approximation to π

11

3

How do I program the approximation to π devised by François Viète, which is given by

2 * 2/Sqrt[2] * 2/Sqrt[2 + Sqrt[2]] * 2/Sqrt[2 + Sqrt[2 + Sqrt[2]]] * ... 

using some of these functions: Nest, For, Module, Product, Do?

Xavier

Posted 2018-04-18T01:14:47.907

Reputation: 111

I appreciate all of your answers, but these commands are not in the list I posted... Right now, I have come to this: PieApprox[n_] := 2/Nest[Sqrt[# + 2] &, Sqrt[2], n]. So I was thinking if someone could help me plug in the Product fonction to finish it, because I can't figure out how to do it. – Xavier – 2018-04-18T16:33:03.997

@Xavier please see https://mathematica.stackexchange.com/help/merging-accounts

– Kuba – 2018-04-18T18:44:21.423

Answers

16

You could use

VietePiApprox[n_] := (Times @@ NestList[Sqrt[2 + #] &, Sqrt[2], n])/ 2^(n + 1)
SetAttributes[VietePiApprox, Listable]

which approximates Pi as follows.

N[VietePiApprox[Range[5]] - 2/\[Pi]]

{0.0166617, 0.00410909, 0.0010238, 0.000255735, 0.0000639204}

KennyColnago

Posted 2018-04-18T01:14:47.907

Reputation: 14 269

9

Well, FoldList also can finish this job:

2/Times @@ (1/2 FoldList[Sqrt[2 + #] &, ConstantArray[Sqrt[2.], 10]])

By the way, by putting the one half just before NestList, FoldList can save one's effort for counting the number of twos in the denominators.

Αλέξανδρος Ζεγγ

Posted 2018-04-18T01:14:47.907

Reputation: 8 492

6

Clear[VietePiApprox];
VietePiApprox[n_] := Product[FunctionExpand[Cos[Pi/2^(i + 1)]], {i, 1, n}];
Table[VietePiApprox[i], {i, 1, 10}]
% - 2.0/Pi

{0.070487, 0.0166617, 0.00410909, 0.0010238, 0.000255735, \ 0.0000639204, 0.0000159792, 3.99476*10^-6, 9.98687*10^-7, 2.49671*10^-7}

matrix89

Posted 2018-04-18T01:14:47.907

Reputation: 5 796