Viète's Formula for PI
|
06-17-2020, 05:06 PM
(This post was last modified: 06-17-2020 08:55 PM by pinkman.)
Post: #1
|
|||
|
|||
Viète's Formula for PI
Hi,
Once again, I had another discussion with my cousin about PI (it's either PI or prime numbers...). He told me about the beauty of the Viète's formula : History here: link This video shows the formula entered in CAS, and yes! I find it beautiful: https://youtu.be/BEYDBl94UpM Regards, Thibault |
|||
06-17-2020, 09:37 PM
Post: #2
|
|||
|
|||
RE: Viète's Formula for PI
Cool! Really beautiful to see in the CAS the pi approximation in action! :-)
Ramón Valladolid, Spain TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2 |
|||
06-18-2020, 12:51 PM
(This post was last modified: 06-18-2020 02:49 PM by pinkman.)
Post: #3
|
|||
|
|||
RE: Viète's Formula for PI
And the convergence speed is acceptable : for p(18) we have 10 digits.
p(18) means Σ(x,x,1,18) = 171 iterations. Compared to Wallis formula (https://www.hpmuseum.org/forum/thread-14...ght=wallis), it's absolutely fast! |
|||
06-19-2020, 09:00 PM
Post: #4
|
|||
|
|||
RE: Viète's Formula for PI
very nice, thank you!
tiny tip: in CAS, for algebraic or fractional input, the a.b/c key also runs approx(); one less key-stroke than shift-enter. Cambridge, UK 41CL/DM41X 12/15C/16C DM15/16 17B/II/II+ 28S 42S/DM42 32SII 48GX 50g 35s WP34S PrimeG2 WP43S/pilot/C47 Casio, Rockwell 18R |
|||
06-19-2020, 11:12 PM
Post: #5
|
|||
|
|||
RE: Viète's Formula for PI
(06-18-2020 12:51 PM)pinkman Wrote: Compared to Wallis formula (https://www.hpmuseum.org/forum/thread-14...ght=wallis), it's absolutely fast! Yes, but it pales in comparison to the Wallis-Wasicki formula :-) +---+---------------------+---------------------+ | N | 2*W | 2*W*C | +---+---------------------+---------------------+ | 2 | 2.84444444444444444 | 3.14385964912280701 | | 4 | 2.97215419501133786 | 3.14158816337302932 | | 6 | 3.02317019200136082 | 3.14159266276745771 | | 8 | 3.05058999605551092 | 3.14159265357083669 | |10 | 3.06770380664349896 | 3.14159265358983256 | |12 | 3.07940134316788626 | 3.14159265358979314 | |14 | 3.08790206983111306 | 3.14159265358979321 | +---+---------------------+---------------------+ Only 7 iterations (or 14, depending on how you implement the algorithm) for 18 correct decimal digits (21697209162666264236130304/6906436179074198667175275 = 3.141592653589793238[633]...). The Pascal code is available here. It should translate easily into the Prime programming language, but probably no joy with only 12 significant digits... |
|||
06-23-2020, 06:39 PM
Post: #6
|
|||
|
|||
RE: Viète's Formula for PI
(06-18-2020 12:51 PM)pinkman Wrote: And the convergence speed is acceptable : for p(18) we have 10 digits. For faster convergence, you might want to try this algorithm: Code:
+---+----------------------+----------------------+ | k | 2*v | ~ pi | +---+----------------------+----------------------+ | 1 | 2.828427124746190098 | 3.077994223988500989 | | 2 | 3.061467458920718174 | 3.137427049842311165 | | 3 | 3.121445152258052286 | 3.141329731135014592 | | 4 | 3.136548490545939264 | 3.141576182507746574 | | 5 | 3.140331156954752913 | 3.141591623553754287 | | 6 | 3.141277250932772868 | 3.141592589203296386 | | 7 | 3.141513801144301077 | 3.141592649565492850 | | 8 | 3.141572940367091385 | 3.141592653338272210 | | 9 | 3.141587725277159701 | 3.141592653574073140 | |10 | 3.141591421511199975 | 3.141592653588810732 | |11 | 3.141592345570117743 | 3.141592653589731833 | |12 | 3.141592576584872667 | 3.141592653589789401 | |13 | 3.141592634338562990 | 3.141592653589793000 | |14 | 3.141592648776985670 | 3.141592653589793224 | |15 | 3.141592652386591346 | 3.141592653589793238 | +---+----------------------+----------------------+ |
|||
06-23-2020, 09:58 PM
Post: #7
|
|||
|
|||
RE: Viète's Formula for PI
Quote:Yes, but it pales in comparison to the Wallis-Wasicki formula :-) Here is a quick PPL port of your Wallis-Wasicki implementation: Code:
The terminal output is not well formatted, but still easy to read. I’m also porting your 314 pi digits algorithm, I had to stop (work...) but it will be ready in a few hours (if I find the time). |
|||
06-23-2020, 10:04 PM
Post: #8
|
|||
|
|||
RE: Viète's Formula for PI
(06-23-2020 06:39 PM)Gerson W. Barbosa Wrote:(06-18-2020 12:51 PM)pinkman Wrote: And the convergence speed is acceptable : for p(18) we have 10 digits. Yes! But... I really love to see the CAS in action, even if it reaches its limit in terms of recursivity. |
|||
06-23-2020, 10:52 PM
(This post was last modified: 07-15-2020 05:07 PM by Gerson W. Barbosa.)
Post: #9
|
|||
|
|||
RE: Viète's Formula for PI
(06-23-2020 06:39 PM)Gerson W. Barbosa Wrote: ... The following appears to be better (more tests required) . Only one line has been changed. Anyway, here is it again: Code: Program Viete; +---+----------------------+----------------------+ | k | 2*v | ~ pi | +---+----------------------+----------------------+ | 1 | 2.828427124746190098 | 3.140960508696045357 | | 2 | 3.061467458920718174 | 3.141593674140638978 | | 3 | 3.121445152258052286 | 3.141592707164788547 | | 4 | 3.136548490545939264 | 3.141592654569488290 | | 5 | 3.140331156954752913 | 3.141592653605653769 | | 6 | 3.141277250932772868 | 3.141592653590043215 | | 7 | 3.141513801144301077 | 3.141592653589797153 | | 8 | 3.141572940367091385 | 3.141592653589793300 | | 9 | 3.141587725277159701 | 3.141592653589793240 | |10 | 3.141591421511199975 | 3.141592653589793239 | +---+----------------------+----------------------+ P.S.: This yields 1.8 digits per iteration, three times as much when compared to the plain Viète's formula. P.P.S.: This new formula is easier to program and will yield slightly more than two digits per term: \(\pi \approx 2\left ( \frac{4}{3} \times \frac{16}{15}\times \frac{36}{35}\times\frac{64}{63} \times \cdots \times \frac{ 4n ^{2}}{ 4n ^{2}-1}\right )\cdot \left ( 1+\frac{2}{8n+3+\frac{3}{8n+4+\frac{15}{8n+4+ \frac{35}{8n+4 + \frac{63}{\dots\frac{\ddots }{8n+4+\frac{4n^{2}-1}{8n+4}}} }}} } \right )\) TurboBCD program: Code:
+---+---------------------+---------------------+ | N | 2*W | 2*W*C/(C-2) | +---+---------------------+---------------------+ | 1 | 2.66666666666666666 | 3.14074074074074073 | | 2 | 2.84444444444444446 | 3.14159848961611078 | | 3 | 2.92571428571428570 | 3.14159260997123044 | | 4 | 2.97215419501133786 | 3.14159265392705764 | | 5 | 3.00217595455690690 | 3.14159265358714120 | | 6 | 3.02317019200136082 | 3.14159265358981426 | | 7 | 3.03867362888341912 | 3.14159265358979309 | | 8 | 3.05058999605551094 | 3.14159265358979325 | +---+---------------------+---------------------+ In this table N is the number of terms, W is the Wallis Product evaluated to N terms and C/(C - 2) is the correction factor. |
|||
06-23-2020, 11:00 PM
Post: #10
|
|||
|
|||
RE: Viète's Formula for PI
(06-23-2020 09:58 PM)pinkman Wrote:Quote:Yes, but it pales in comparison to the Wallis-Wasicki formula :-) Thank you very much for the PPL port! Perhaps it's time I should get myself a Prime. But I think I will wait until a good arbitrary precision package is available, either built-in or third-party. Gerson. |
|||
06-24-2020, 01:15 PM
Post: #11
|
|||
|
|||
RE: Viète's Formula for PI
The port of the 200-314-997 decimals will need the CAS, which has capabilities for manipulating big integers but not arbitrary precision decimal numbers.
I’ll check if I can avoid using decimals by calculating on a base of estimated_pi * 10^200 (or less, depending on CAS limit). Need a few hours more! |
|||
06-29-2020, 05:52 AM
Post: #12
|
|||
|
|||
RE: Viète's Formula for PI
I wish the extremely fast HP Prime had the LongFloat Library integrated.
- - VP |
|||
06-29-2020, 10:54 PM
Post: #13
|
|||
|
|||
RE: Viète's Formula for PI
Me too!
Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co |
|||
06-30-2020, 03:05 PM
(This post was last modified: 07-09-2020 04:07 AM by compsystems.)
Post: #14
|
|||
|
|||
RE: Viète's Formula for PI
There must be some open source LongFloat library, if so Xcas could include it.
https://keisan.casio.com/ |
|||
07-16-2020, 04:42 PM
Post: #15
|
|||
|
|||
RE: Viète's Formula for PI
(06-23-2020 09:58 PM)pinkman Wrote: Here is a quick PPL port of your Wallis-Wasicki implementation: Gerson sent me a PM to thank me for having posted this code to hpcalc.org, but in fact I did not post anything, I guess Eric did. Funny, and good idea, but the credits come to Gerson and his continuous fraction quick convergence for Wallis product. Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)