# Count the occurrence of a given digit within a given range of PI?

## Recommended Posts

I have a interesting question for you here:

I want to take PI, and allow the user to select a range, for instance from digit 50 to digit 200, and search for the number of times a certain digit appears in that range of PI's digits.

If the number searched for is not found in the range requested, error message, else display number of occurrences.

For instance, i should be able to tell the program to look at the range of 1st to 10th digits of PI, and have it look for 1, which should return the result of 2:
3.141592653 = 2 occurrences of 1 within range of 1-10

Ideally i would like to see this in BASIC / XB , but feel free to try this in any language you can run on the TI (Geneve users welcome to try also)

##### Share on other sites

I have a interesting question for you here:

I want to take PI, and allow the user to select a range, for instance from digit 50 to digit 200, and search for the number of times a certain digit appears in that range of PI's digits.

If the number searched for is not found in the range requested, error message, else display number of occurrences.

For instance, i should be able to tell the program to look at the range of 1st to 10th digits of PI, and have it look for 1, which should return the result of 2:

3.141592653 = 2 occurrences of 1 within range of 1-10

Ideally i would like to see this in BASIC / XB , but feel free to try this in any language you can run on the TI (Geneve users welcome to try also)

Are you looking to calculate the required digits or are you content with searching an array of digits stored in memory.

If the latter, the size of memory available for storage would obviously affect the number of searchable digits. You could extend the number of digits for the memory search procedure by storing the value of π in a file and reading in the necessary range(s).

If the former, do you have an algorithm in mind that can do the job on our TI-99/4A or is that part of the question?

...lee

##### Share on other sites
Posted (edited)

Storing the longest known correct calculation of PI in a file and accessing it from the main program as a external data file seems to make a decent amount of sense to me.

I suppose 1mb+ SAMS card users could calculate a fairly large( or not?) amount of PI though.

I really have/had nothing in mind. This was just to hopefully create a spark in somebody's mind that may or may not lead to something useful.

Edited by jrhodes

##### Share on other sites

For calculation of π, it is entirely possible that an algorithm exists that would take very little memory to calculate as many digits as desired. If it converges fast enough to ensure that a known number of calculated digits are not affected by subsequent calculations a known distance away, you could process the digits piecemeal without saving them for the next go-round. Of course, it is conceivable that the calculation would take too long to be tolerable. And, just because it might be doable is probably not a good enough justification for including the calculation when the point is counting digits regardless of the source of π, be it a computing algorithm or a file of digits.

...lee

##### Share on other sites

Algorithms to handle more than 16 bit counting will become necessary depending upon how many digits one wants to test........

##### Share on other sites

Isn't it fascinating to see that there is some connection between the circumference of a circle with diameter 1, and all odd numbers?

I once studied maths (already 24 years ago...), but at some points it is still a bit spooky.

##### Share on other sites

Isn't it fascinating to see that there is some connection between the circumference of a circle with diameter 1, and all odd numbers?

I once studied maths (already 24 years ago...), but at some points it is still a bit spooky.

Things like this and the fact the maths describe aspects of reality so accurately have lead some to think we are in a simulation.

##### Share on other sites

The series you show is not the one you reference.

π/4 = 1 - 1/3 + 1/5 - 1/7 + ...

is the Gregory–Leibniz series, which converges far two slowly to be of much use to us (2 digits in 300 rounds of calculation!).

The one you reference is the Spigot Algorithm of Rabinowitz and Wagon, which produces one digit per round of calculation, hence the name, I suppose:

,

which becomes

The Rabinowitz–Wagon series would be much more tractable for us.

There are series that converge even faster that we might be able to use. Numerical Recipes in C (Third Edition) has a quadratically convergent algorithm that might be interesting to try.

...lee

##### Share on other sites

Things like this and the fact the maths describe aspects of reality so accurately have lead some to think we are in a simulation.

The thing with mathematics is:

- If you were at school and think you know maths, forget it. This is just calculating.

- If you were at college and think you know maths, forgot it. This is just some formula juggling.

- If you got a bachelor of maths, you're getting closer. You learned to build the real numbers from natural numbers, and you learned that one can prove things.

- If you got a Ph.D. of maths, you may get a glimpse of what maths really is. You can describe knots in your shoe straps by topological parameters.

I had maths at school from the first to the 13th grade, and at university, everything we learned at school was refreshed in the first year. Every now and then, I read some maths articles in Wikipedia. Of course, my diploma study is already 24 years ago, but I still understand some texts (and I should). However, there are others that are complete non-understandable, even when you have a diploma. As an example, in 2018, Peter Scholze from Germany got the Fields medal (among 4 winners); many people here heard of that prize for the first time. I tried to understand what he did, and I gave up after 10 minutes.

These thoughts about the power of abstraction makes me sometimes believe that we humans could indeed be the most intelligent beings in the universe. I know this sounds silly; wait and don't wipe that thought away too early. My point is: Nature has optimized everything in all beings to a level that is perfectly appropriate for their niche. Why can be ponder infinite-dimensional functor spaces? This has no obvious advantage for our reproduction (don't try). Maybe you can have a limited amount of abstraction capabilities (as seen in other animals), and once you get past some threshold, you get the flat rate.

This argument lacks one important aspect: We have no reasonable definition of intelligence (which is even more confusing to think about: reasoning is a part of intelligence).

##### Share on other sites

<snip>

These thoughts about the power of abstraction makes me sometimes believe that we humans could indeed be the most intelligent beings in the universe. I know this sounds silly; wait and don't wipe that thought away too early. My point is: Nature has optimized everything in all beings to a level that is perfectly appropriate for their niche. Why can be ponder infinite-dimensional functor spaces? This has no obvious advantage for our reproduction (don't try). Maybe you can have a limited amount of abstraction capabilities (as seen in other animals), and once you get past some threshold, you get the flat rate.

This argument lacks one important aspect: We have no reasonable definition of intelligence (which is even more confusing to think about: reasoning is a part of intelligence).

Something I have pondered on intelligence is that I have, like you, encountered people smarter than myself. (per your Peter Scholze material)

So if that is true for me it can be true for the smarter people also.

So I see no reason to exclude the possibility that their can be entities in the universe smarter than the smartest person on our little blue ball.

As you say it is hard to define intelligence, but our current methods of measuring seem to correlate with , academic success, general life success and life span so we have some benchmarks.

Ongoing research in "general intelligence" AI may one day show us where we really stand in the universe or it could prove that your completely correct.

##### Share on other sites

Back to searching a database of the digits of π, two methods of storing the digits come to mind. A file of the desired number of digits could be stored in

1. ASCII format, i.e., the digits 0 – 9 would be stored as ASCII 48 – 57 (30h – 39h) or
2. BCD (Binary Coded Decimal) format, i.e., the digits 0 – 9 would be stored as the binary nybbles 0 – 9, storing twice as many digits as (1) for the same file size.

The most efficient file type would be DIS/FIX 128, which would use all of the file’s space and would load 128 characters into a work string for each record retrieved from the file. For both cases (1) and (2), the records would be read into strings that would then be parsed for the digits. The process is easier for (1) because each character in the string represents one digit of π. (2) would require a more extensive procedure to extract the two digits contained in each character read—not difficult, but more work, nonetheless. A 50 KiB file would store 51,200 digits for (1) and 102,400 digits for (2).

...lee

##### Share on other sites

I wrote a program a while back to calculate the first 5200 decimals of Pi, in XB If memory serves, I believe it's the longest number of decimals ever calculated using a vintage computer from the early 80's. I forget which formula I used and I'll have to look back at the listing and refresh my memory. The challenge was how to perform calculations on large numbers of digits accurately.

It's slow, but it works perfectly. Fred Kaal converted it to c99 and it runs much faster, but was limited to 2600 decimals only secondary to c99's limitations. Both programs are on the disk.

Here are all the calculated digits produced by the program:

```Pi=3.
14159265 35897932 38462643 38327950 28841971 69399375 10582097 49445923 07816406
28620899 86280348 25342117 06798214 80865132 82306647 09384460 95505822
31725359 40812848 11174502 84102701 93852110 55596446 22948954 93038196 44288109
75665933 44612847 56482337 86783165 27120190 91456485 66923460 34861045
43266482 13393607 26024914 12737245 87006606 31558817 48815209 20962829 25409171
53643678 92590360 01133053 05488204 66521384 14695194 15116094 33057270
36575959 19530921 86117381 93261179 31051185 48074462 37996274 95673518 85752724
89122793 81830119 49129833 67336244 06566430 86021394 94639522 47371907
02179860 94370277 05392171 76293176 75238467 48184676 69405132 00056812 71452635
60827785 77134275 77896091 73637178 72146844 09012249 53430146 54958537
10507922 79689258 92354201 99561121 29021960 86403441 81598136 29774771 30996051
87072113 49999998 37297804 99510597 31732816 09631859 50244594 55346908
30264252 23082533 44685035 26193118 81710100 03137838 75288658 75332083 81420617
17766914 73035982 53490428 75546873 11595628 63882353 78759375 19577818
57780532 17122680 66130019 27876611 19590921 64201989 38095257 20106548 58632788
65936153 38182796 82303019 52035301 85296899 57736225 99413891 24972177
52834791 31515574 85724245 41506959 50829533 11686172 78558890 75098381 75463746
49393192 55060400 92770167 11390098 48824012 85836160 35637076 60104710
18194295 55961989 46767837 44944825 53797747 26847104 04753464 62080466 84259069
49129331 36770289 89152104 75216205 69660240 58038150 19351125 33824300
35587640 24749647 32639141 99272604 26992279 67823547 81636009 34172164 12199245
86315030 28618297 45557067 49838505 49458858 69269956 90927210 79750930
29553211 65344987 20275596 02364806 65499119 88183479 77535663 69807426 54252786
25518184 17574672 89097777 27938000 81647060 01614524 91921732 17214772
35014144 19735685 48161361 15735255 21334757 41849468 43852332 39073941 43334547
76241686 25189835 69485562 09921922 21842725 50254256 88767179 04946016
53466804 98862723 27917860 85784383 82796797 66814541 00953883 78636095 06800642
25125205 11739298 48960841 28488626 94560424 19652850 22210661 18630674
42786220 39194945 04712371 37869609 56364371 91728746 77646575 73962413 89086583
26459958 13390478 02759009 94657640 78951269 46839835 25957098 25822620
52248940 77267194 78268482 60147699 09026401 36394437 45530506 82034962 52451749
39965143 14298091 90659250 93722169 64615157 09858387 41059788 59597729
75498930 16175392 84681382 68683868 94277415 59918559 25245953 95943104 99725246
80845987 27364469 58486538 36736222 62609912 46080512 43884390 45124413
65497627 80797715 69143599 77001296 16089441 69486855 58484063 53422072 22582848
86481584 56028506 01684273 94522674 67678895 25213852 25499546 66727823
98645659 61163548 86230577 45649803 55936345 68174324 11251507 60694794 51096596
09402522 88797108 93145669 13686722 87489405 60101503 30861792 86809208
74760917 82493858 90097149 09675985 26136554 97818931 29784821 68299894 87226588
04857564 01427047 75551323 79641451 52374623 43645428 58444795 26586782
10511413 54735739 52311342 71661021 35969536 23144295 24849371 87110145 76540359
02799344 03742007 31057853 90621983 87447808 47848968 33214457 13868751
94350643 02184531 91048481 00537061 46806749 19278191 19793995 20614196 63428754
44064374 51237181 92179998 39101591 95618146 75142691 23974894 09071864
94231961 56794520 80951465 50225231 60388193 01420937 62137855 95663893 77870830
39069792 07734672 21825625 99661501 42150306 80384477 34549202 60541466
59252014 97442850 73251866 60021324 34088190 71048633 17346496 51453905 79626856
10055081 06658796 99816357 47363840 52571459 10289706 41401109 71206280
43903975 95156771 57700420 33786993 60072305 58763176 35942187 31251471 20532928
19182618 61258673 21579198 41484882 91644706 09575270 69572209 17567116
72291098 16909152 80173506 71274858 32228718 35209353 96572512 10835791 51369882
09144421 00675103 34671103 14126711 13699086 58516398 31501970 16515116
85171437 65761835 15565088 49099898 59982387 34552833 16355076 47918535 89322618
54896321 32933089 85706420 46752590 70915481 41654985 94616371 80270981
99430992 44889575 71282890 59232332 60972997 12084433 57326548 93823911 93259746
36673058 36041428 13883032 03824903 75898524 37441702 91327656 18093773
44403070 74692112 01913020 33038019 76211011 00449293 21516084 24448596 37669838
95228684 78312355 26582131 44957685 72624334 41893039 68642624 34107732
26978028 07318915 44110104 46823252 71620105 26522721 11660396 66557309 25471105
57853763 46682065 31098965 26918620 56476931 25705863 56620185 58100729
36065987 64861179 10453348 85034611 36576867 53249441 66803962 65797877 18556084
55296541 26654085 30614344 43185867 69751456 61406800 70023787 76591344
01712749 47042056 22305389 94561314 07112700 04078547 33269939 08145466 46458807
97270826 68306343 28587856 98305235 80893306 57574067 95457163 77525420
21149557 61581400 25012622 85941302 16471550 97925923 09907965 47376125 51765675
13575178 29666454 77917450 11299614 89030463 99471329 62107340 43751895
73596145 89019389 71311179 04297828 56475032 03198691 51402870 80859904 80109412
14722131 79476477 72622414 25485454 03321571 85306142 28813758 50430633
21751829 79866223 71721591 60771669 25474873 89866549 49450114 65406284 33663937
90039769 26567214 63853067 36096571 20918076 38327166 41627488 88007869
25602902 28472104 03172118 60820419 00042296 61711963 77921337 57511495 95015660
49631862 94726547 36425230 81770367 51590673 50235072 83540567 04038674
35136222 24771589 15049530 98444893 33096340 87807693 25993978 05419341 44737744
18426312 98608099 88868741 32604721 56951623 96586457 30216315 98193195
16735381 29741677 29478672 42292465 43668009 80676928 23828068 99640048 24354037
01416314 96589794 09243237 89690706 97794223 62508221 68895738 37986230
01593776 47165122 89357860 15881543

```

Picalc.dsk

##### Share on other sites

I wrote a program a while back to calculate the first 5200 decimals of Pi, in XB If memory serves, I believe it's the longest number of decimals ever calculated using a vintage computer from the early 80's. I forget which formula I used and I'll have to look back at the listing and refresh my memory. The challenge was how to perform calculations on large numbers of digits accurately.

It's slow, but it works perfectly. Fred Kaal converted it to c99 and it runs much faster, but was limited to 2600 decimals only secondary to c99's limitations. Both programs are on the disk.

Here are all the calculated digits produced by the program:

```Pi=3.
14159265 35897932 38462643 38327950 28841971 69399375 10582097 49445923 07816406
28620899 86280348 25342117 06798214 80865132 82306647 09384460 95505822
31725359 40812848 11174502 84102701 93852110 55596446 22948954 93038196 44288109
75665933 44612847 56482337 86783165 27120190 91456485 66923460 34861045
43266482 13393607 26024914 12737245 87006606 31558817 48815209 20962829 25409171
53643678 92590360 01133053 05488204 66521384 14695194 15116094 33057270
36575959 19530921 86117381 93261179 31051185 48074462 37996274 95673518 85752724
89122793 81830119 49129833 67336244 06566430 86021394 94639522 47371907
02179860 94370277 05392171 76293176 75238467 48184676 69405132 00056812 71452635
60827785 77134275 77896091 73637178 72146844 09012249 53430146 54958537
10507922 79689258 92354201 99561121 29021960 86403441 81598136 29774771 30996051
87072113 49999998 37297804 99510597 31732816 09631859 50244594 55346908
30264252 23082533 44685035 26193118 81710100 03137838 75288658 75332083 81420617
17766914 73035982 53490428 75546873 11595628 63882353 78759375 19577818
57780532 17122680 66130019 27876611 19590921 64201989 38095257 20106548 58632788
65936153 38182796 82303019 52035301 85296899 57736225 99413891 24972177
52834791 31515574 85724245 41506959 50829533 11686172 78558890 75098381 75463746
49393192 55060400 92770167 11390098 48824012 85836160 35637076 60104710
18194295 55961989 46767837 44944825 53797747 26847104 04753464 62080466 84259069
49129331 36770289 89152104 75216205 69660240 58038150 19351125 33824300
35587640 24749647 32639141 99272604 26992279 67823547 81636009 34172164 12199245
86315030 28618297 45557067 49838505 49458858 69269956 90927210 79750930
29553211 65344987 20275596 02364806 65499119 88183479 77535663 69807426 54252786
25518184 17574672 89097777 27938000 81647060 01614524 91921732 17214772
35014144 19735685 48161361 15735255 21334757 41849468 43852332 39073941 43334547
76241686 25189835 69485562 09921922 21842725 50254256 88767179 04946016
53466804 98862723 27917860 85784383 82796797 66814541 00953883 78636095 06800642
25125205 11739298 48960841 28488626 94560424 19652850 22210661 18630674
42786220 39194945 04712371 37869609 56364371 91728746 77646575 73962413 89086583
26459958 13390478 02759009 94657640 78951269 46839835 25957098 25822620
52248940 77267194 78268482 60147699 09026401 36394437 45530506 82034962 52451749
39965143 14298091 90659250 93722169 64615157 09858387 41059788 59597729
75498930 16175392 84681382 68683868 94277415 59918559 25245953 95943104 99725246
80845987 27364469 58486538 36736222 62609912 46080512 43884390 45124413
65497627 80797715 69143599 77001296 16089441 69486855 58484063 53422072 22582848
86481584 56028506 01684273 94522674 67678895 25213852 25499546 66727823
98645659 61163548 86230577 45649803 55936345 68174324 11251507 60694794 51096596
09402522 88797108 93145669 13686722 87489405 60101503 30861792 86809208
74760917 82493858 90097149 09675985 26136554 97818931 29784821 68299894 87226588
04857564 01427047 75551323 79641451 52374623 43645428 58444795 26586782
10511413 54735739 52311342 71661021 35969536 23144295 24849371 87110145 76540359
02799344 03742007 31057853 90621983 87447808 47848968 33214457 13868751
94350643 02184531 91048481 00537061 46806749 19278191 19793995 20614196 63428754
44064374 51237181 92179998 39101591 95618146 75142691 23974894 09071864
94231961 56794520 80951465 50225231 60388193 01420937 62137855 95663893 77870830
39069792 07734672 21825625 99661501 42150306 80384477 34549202 60541466
59252014 97442850 73251866 60021324 34088190 71048633 17346496 51453905 79626856
10055081 06658796 99816357 47363840 52571459 10289706 41401109 71206280
43903975 95156771 57700420 33786993 60072305 58763176 35942187 31251471 20532928
19182618 61258673 21579198 41484882 91644706 09575270 69572209 17567116
72291098 16909152 80173506 71274858 32228718 35209353 96572512 10835791 51369882
09144421 00675103 34671103 14126711 13699086 58516398 31501970 16515116
85171437 65761835 15565088 49099898 59982387 34552833 16355076 47918535 89322618
54896321 32933089 85706420 46752590 70915481 41654985 94616371 80270981
99430992 44889575 71282890 59232332 60972997 12084433 57326548 93823911 93259746
36673058 36041428 13883032 03824903 75898524 37441702 91327656 18093773
44403070 74692112 01913020 33038019 76211011 00449293 21516084 24448596 37669838
95228684 78312355 26582131 44957685 72624334 41893039 68642624 34107732
26978028 07318915 44110104 46823252 71620105 26522721 11660396 66557309 25471105
57853763 46682065 31098965 26918620 56476931 25705863 56620185 58100729
36065987 64861179 10453348 85034611 36576867 53249441 66803962 65797877 18556084
55296541 26654085 30614344 43185867 69751456 61406800 70023787 76591344
01712749 47042056 22305389 94561314 07112700 04078547 33269939 08145466 46458807
97270826 68306343 28587856 98305235 80893306 57574067 95457163 77525420
21149557 61581400 25012622 85941302 16471550 97925923 09907965 47376125 51765675
13575178 29666454 77917450 11299614 89030463 99471329 62107340 43751895
73596145 89019389 71311179 04297828 56475032 03198691 51402870 80859904 80109412
14722131 79476477 72622414 25485454 03321571 85306142 28813758 50430633
21751829 79866223 71721591 60771669 25474873 89866549 49450114 65406284 33663937
90039769 26567214 63853067 36096571 20918076 38327166 41627488 88007869
25602902 28472104 03172118 60820419 00042296 61711963 77921337 57511495 95015660
49631862 94726547 36425230 81770367 51590673 50235072 83540567 04038674
35136222 24771589 15049530 98444893 33096340 87807693 25993978 05419341 44737744
18426312 98608099 88868741 32604721 56951623 96586457 30216315 98193195
16735381 29741677 29478672 42292465 43668009 80676928 23828068 99640048 24354037
01416314 96589794 09243237 89690706 97794223 62508221 68895738 37986230
01593776 47165122 89357860 15881543

```

That is very impressive! I checked a few blocks of those digits and they were all correct except for the last three digits, which should be “617”. If a reliable algorithm for calculating π gets any digits wrong, I would expect the problem to be in the trailing digits.

...lee

##### Share on other sites

I wrote a program a while back to calculate the first 5200 decimals of Pi, in XB If memory serves, I believe it's the longest number of decimals ever calculated using a vintage computer from the early 80's. I forget which formula I used and I'll have to look back at the listing and refresh my memory. The challenge was how to perform calculations on large numbers of digits accurately.

It's slow, but it works perfectly. Fred Kaal converted it to c99 and it runs much faster, but was limited to 2600 decimals only secondary to c99's limitations. Both programs are on the disk.

Here are all the calculated digits produced by the program:

```Pi=3.
14159265 35897932 38462643 38327950 28841971 69399375 10582097 49445923 07816406
28620899 86280348 25342117 06798214 80865132 82306647 09384460 95505822
31725359 40812848 11174502 84102701 93852110 55596446 22948954 93038196 44288109
75665933 44612847 56482337 86783165 27120190 91456485 66923460 34861045
43266482 13393607 26024914 12737245 87006606 31558817 48815209 20962829 25409171
53643678 92590360 01133053 05488204 66521384 14695194 15116094 33057270
36575959 19530921 86117381 93261179 31051185 48074462 37996274 95673518 85752724
89122793 81830119 49129833 67336244 06566430 86021394 94639522 47371907
02179860 94370277 05392171 76293176 75238467 48184676 69405132 00056812 71452635
60827785 77134275 77896091 73637178 72146844 09012249 53430146 54958537
10507922 79689258 92354201 99561121 29021960 86403441 81598136 29774771 30996051
87072113 49999998 37297804 99510597 31732816 09631859 50244594 55346908
30264252 23082533 44685035 26193118 81710100 03137838 75288658 75332083 81420617
17766914 73035982 53490428 75546873 11595628 63882353 78759375 19577818
57780532 17122680 66130019 27876611 19590921 64201989 38095257 20106548 58632788
65936153 38182796 82303019 52035301 85296899 57736225 99413891 24972177
52834791 31515574 85724245 41506959 50829533 11686172 78558890 75098381 75463746
49393192 55060400 92770167 11390098 48824012 85836160 35637076 60104710
18194295 55961989 46767837 44944825 53797747 26847104 04753464 62080466 84259069
49129331 36770289 89152104 75216205 69660240 58038150 19351125 33824300
35587640 24749647 32639141 99272604 26992279 67823547 81636009 34172164 12199245
86315030 28618297 45557067 49838505 49458858 69269956 90927210 79750930
29553211 65344987 20275596 02364806 65499119 88183479 77535663 69807426 54252786
25518184 17574672 89097777 27938000 81647060 01614524 91921732 17214772
35014144 19735685 48161361 15735255 21334757 41849468 43852332 39073941 43334547
76241686 25189835 69485562 09921922 21842725 50254256 88767179 04946016
53466804 98862723 27917860 85784383 82796797 66814541 00953883 78636095 06800642
25125205 11739298 48960841 28488626 94560424 19652850 22210661 18630674
42786220 39194945 04712371 37869609 56364371 91728746 77646575 73962413 89086583
26459958 13390478 02759009 94657640 78951269 46839835 25957098 25822620
52248940 77267194 78268482 60147699 09026401 36394437 45530506 82034962 52451749
39965143 14298091 90659250 93722169 64615157 09858387 41059788 59597729
75498930 16175392 84681382 68683868 94277415 59918559 25245953 95943104 99725246
80845987 27364469 58486538 36736222 62609912 46080512 43884390 45124413
65497627 80797715 69143599 77001296 16089441 69486855 58484063 53422072 22582848
86481584 56028506 01684273 94522674 67678895 25213852 25499546 66727823
98645659 61163548 86230577 45649803 55936345 68174324 11251507 60694794 51096596
09402522 88797108 93145669 13686722 87489405 60101503 30861792 86809208
74760917 82493858 90097149 09675985 26136554 97818931 29784821 68299894 87226588
04857564 01427047 75551323 79641451 52374623 43645428 58444795 26586782
10511413 54735739 52311342 71661021 35969536 23144295 24849371 87110145 76540359
02799344 03742007 31057853 90621983 87447808 47848968 33214457 13868751
94350643 02184531 91048481 00537061 46806749 19278191 19793995 20614196 63428754
44064374 51237181 92179998 39101591 95618146 75142691 23974894 09071864
94231961 56794520 80951465 50225231 60388193 01420937 62137855 95663893 77870830
39069792 07734672 21825625 99661501 42150306 80384477 34549202 60541466
59252014 97442850 73251866 60021324 34088190 71048633 17346496 51453905 79626856
10055081 06658796 99816357 47363840 52571459 10289706 41401109 71206280
43903975 95156771 57700420 33786993 60072305 58763176 35942187 31251471 20532928
19182618 61258673 21579198 41484882 91644706 09575270 69572209 17567116
72291098 16909152 80173506 71274858 32228718 35209353 96572512 10835791 51369882
09144421 00675103 34671103 14126711 13699086 58516398 31501970 16515116
85171437 65761835 15565088 49099898 59982387 34552833 16355076 47918535 89322618
54896321 32933089 85706420 46752590 70915481 41654985 94616371 80270981
99430992 44889575 71282890 59232332 60972997 12084433 57326548 93823911 93259746
36673058 36041428 13883032 03824903 75898524 37441702 91327656 18093773
44403070 74692112 01913020 33038019 76211011 00449293 21516084 24448596 37669838
95228684 78312355 26582131 44957685 72624334 41893039 68642624 34107732
26978028 07318915 44110104 46823252 71620105 26522721 11660396 66557309 25471105
57853763 46682065 31098965 26918620 56476931 25705863 56620185 58100729
36065987 64861179 10453348 85034611 36576867 53249441 66803962 65797877 18556084
55296541 26654085 30614344 43185867 69751456 61406800 70023787 76591344
01712749 47042056 22305389 94561314 07112700 04078547 33269939 08145466 46458807
97270826 68306343 28587856 98305235 80893306 57574067 95457163 77525420
21149557 61581400 25012622 85941302 16471550 97925923 09907965 47376125 51765675
13575178 29666454 77917450 11299614 89030463 99471329 62107340 43751895
73596145 89019389 71311179 04297828 56475032 03198691 51402870 80859904 80109412
14722131 79476477 72622414 25485454 03321571 85306142 28813758 50430633
21751829 79866223 71721591 60771669 25474873 89866549 49450114 65406284 33663937
90039769 26567214 63853067 36096571 20918076 38327166 41627488 88007869
25602902 28472104 03172118 60820419 00042296 61711963 77921337 57511495 95015660
49631862 94726547 36425230 81770367 51590673 50235072 83540567 04038674
35136222 24771589 15049530 98444893 33096340 87807693 25993978 05419341 44737744
18426312 98608099 88868741 32604721 56951623 96586457 30216315 98193195
16735381 29741677 29478672 42292465 43668009 80676928 23828068 99640048 24354037
01416314 96589794 09243237 89690706 97794223 62508221 68895738 37986230
01593776 47165122 89357860 15881543

```

Very nice.

By "the disk" do you mean the C99 disk?

Could you post the code here?

Based on Lee's analysis I guess we have to restate your record to 5187 digits , but I suspect your record is still very secure.

TI really went above and beyond with the math package in the 99.

##### Share on other sites

That is very impressive! I checked a few blocks of those digits and they were all correct except for the last three digits, which should be “617”. If a reliable algorithm for calculating π gets any digits wrong, I would expect the problem to be in the trailing digits.

...lee

Huh... I thought I had verified all the digits at the time and all were correct. I'll have to double check you on that one I don't know if I kept any notes on the algorithm used. I do recall however spending a couple of weeks researching the process, particularly large number operations.

##### Share on other sites

Very nice.

By "the disk" do you mean the C99 disk?

Could you post the code here?

Based on Lee's analysis I guess we have to restate your record to 5187 digits , but I suspect your record is still very secure.

TI really went above and beyond with the math package in the 99.

Here's the XB code.

```10 REM  PI CALCULATOR
20 REM  BY WALID MAALOULI
30 REM  AUGUST 2007
40 REM
100 CALL CLEAR
110 OPTION BASE 1
120 DIM SUM(652),SUM1(652),TERM(652),TEMP(652)
130 DISPLAY AT(1,:"Pi Calculator" :: DISPLAY AT(3,6):"By Walid Maalouli" :: DISPLAY AT(5,9):"August 2007"
140 DISPLAY AT(10,2)BEEP:"# of decimals (mult. of 8)" :: DISPLAY AT(11,2):"(Maximum of 5200 decimals)" :: ACCEPT AT(13,12)VALIDATE(DIGIT)
150 IF D>5200 THEN 140
160 ITR=INT(D/1.4) :: D=INT(D/8)+2
170 SUM(1)=3 :: SUM(2)=20000000 :: TERM(1)=0 :: TERM(2)=20000000 :: S=0 :: DENOM1=3 :: TBASE=25 :: MULT=16
180 FOR N=1 TO ITR+1
190 IF FLAG=0 THEN DISPLAY AT(20,5):"Term 1 iteration #";N;" " ELSE DISPLAY AT(20,5):"Term 2 iteration #";N;" "
200 IF N=1 THEN 220
210 FOR I=1 TO D :: TERM(I)=TEMP(I) :: NEXT I
220 DENOM=TBASE :: REMAINDER=0
230 GOSUB 1050
240 FOR I=1 TO D :: TEMP(I)=TERM(I) :: NEXT I
250 DENOM=DENOM1 :: REMAINDER=0
260 GOSUB 1050
270 FOR I=1 TO D
280 IF S=0 THEN 300
290 SUM(I)=SUM(I)+MULT*TERM(I) :: GOTO 310
300 SUM(I)=SUM(I)-MULT*TERM(I)
310 NEXT I
320 IF S=0 THEN S=1 ELSE S=0
330 FOR I=D TO 2 STEP-1
340 IF SUM(I)>=100000000 THEN 350 ELSE IF SUM(I)<0 THEN 390 ELSE 420
350 QUOTIENT=INT(SUM(I)/100000000)
360 SUM(I)=SUM(I)-QUOTIENT*100000000
370 SUM(I-1)=SUM(I-1)+QUOTIENT
380 GOTO 420
390 QUOTIENT=INT(SUM(I)/100000000)+1
400 SUM(I)=SUM(I)-(QUOTIENT-1)*100000000
410 SUM(I-1)=SUM(I-1)+QUOTIENT-1
420 NEXT I
430 IF FLAG=2 THEN 680
440 DENOM1=DENOM1+2
450 NEXT N
460 IF FLAG=1 THEN 620
470 TBASE=57121 :: DENOM1=3 :: MULT=4
480 FOR I=1 TO D
490 SUM1(I)=SUM(I)
500 SUM(I)=0 :: TERM(I)=0
510 NEXT I
520 TERM(1)=4
530 DENOM=239 :: REMAINDER=0
540 GOSUB 1050
550 FOR I=1 TO D
560 SUM(I)=TERM(I) :: TERM(I)=0
570 NEXT I
580 DENOM=239 :: TERM(1)=1 :: REMAINDER=0
590 GOSUB 1050
600 FLAG=1 :: S=0
610 GOTO 180
620 PRINT :: PRINT "Finalizing calculations..." :: PRINT
630 FOR I=1 TO D
640 SUM1(I)=SUM1(I)-SUM(I) :: SUM(I)=SUM1(I)
650 NEXT I
660 FLAG=2
670 GOTO 330
680 CALL CLEAR :: DISPLAY AT(2,3)BEEP:"Calculations complete!"
690 DISPLAY AT(5,3):"Send results to:" :: DISPLAY AT(8,5):"1- Screen" :: DISPLAY AT(10,5):"2- Printer (PIO)" :: DISPLAY AT(12,5):"3- File"
700 CALL KEY(0,K,ST) :: IF ST=0 THEN 700
710 IF K<49 OR K>51 THEN 700
720 ON K-48 GOTO 730,860,950
730 CALL CLEAR :: PRINT "Pi=3."
740 FOR I=2 TO D-1
750 SUM\$=STR\$(SUM(I))
760 IF LEN(SUM\$)=8 THEN 780
770 SUM\$="0"&SUM\$ :: GOTO 760
780 PRINT SUM\$;" ";
790 L=L+1 :: IF L=64 THEN 800 ELSE 830
800 PRINT :: PRINT :: DISPLAY AT(24,1)BEEP:"Press any key to continue" :: L=0
810 CALL KEY(0,K,ST) :: IF ST=0 THEN 810
820 CALL CLEAR
830 NEXT I
840 PRINT :: PRINT :: DISPLAY AT(24,1)BEEP:"End. Press any key to exit"
850 CALL KEY(0,K,ST) :: IF ST=0 THEN 850 ELSE STOP
860 OPEN #1:"PIO"
870 PRINT #1:"Pi=3."
880 FOR I=2 TO D-1
890 SUM\$=STR\$(SUM(I))
900 IF LEN(SUM\$)=8 THEN 920
910 SUM\$="0"&SUM\$ :: GOTO 900
920 PRINT #1:SUM\$;" ";
930 NEXT I
940 CLOSE #1 :: END
950 DISPLAY AT(22,1)BEEP:"Enter path.filename:" :: ACCEPT AT(24,1):FL\$
960 OPEN #1:FL\$,OUTPUT,VARIABLE 80
970 PRINT #1:"Pi=3."
980 FOR I=2 TO D-1
990 SUM\$=STR\$(SUM(I))
1000 IF LEN(SUM\$)=8 THEN 1020
1010 SUM\$="0"&SUM\$ :: GOTO 1000
1020 PRINT #1:SUM\$;" ";
1030 NEXT I
1040 CLOSE #1 :: END
1050 REM  DIVIDE SUBROUTINE
1060 FOR I=1 TO D
1070 DIVIDEND=REMAINDER*100000000+TERM(I)
1080 TERM(I)=INT(DIVIDEND/DENOM)
1090 REMAINDER=DIVIDEND-TERM(I)*DENOM
1100 NEXT I
1110 RETURN

```

##### Share on other sites

OK I found my original post in the Yahoo group, which gives details. I later optimized the code to go from 3260 to 5200 decimals.

```I just uploaded to the swpb group on Yahoo an XB program that can
calculate up to 3260 decimals of Pi. It is based on Machin's formula:

Pi=16*ATN(1/5)-4*ATN(1/239, where ATN(1/x)=1/x-1/3x^3+1/5x^5-...

This arctan series converges rather slowly with about 1.4 decimal per
arctan term, so it takes the stock TI about 2 1/2 hours to calculate
the first 250 decimals. The full 3260 decimals will take upward of 32
hours to calculate! The results can be sent to the screen, printed or
save in a file.

The program uses only integer math in base 10000, and is really only
limited by the amount of memory available (and time...).

I can probably optimize it a bit more and squeeze a couple thousand
decimals more. We'll see.

```

##### Share on other sites

Something I have pondered on intelligence is that I have, like you, encountered people smarter than myself. (per your Peter Scholze material)

So if that is true for me it can be true for the smarter people also.

So I see no reason to exclude the possibility that their can be entities in the universe smarter than the smartest person on our little blue ball.

As you say it is hard to define intelligence, but our current methods of measuring seem to correlate with , academic success, general life success and life span so we have some benchmarks.

Ongoing research in "general intelligence" AI may one day show us where we really stand in the universe or it could prove that your completely correct.

When we become smart enough to harness all the energy of our sun in our solar system with a Dyson sphere, then we can question the next evolution of being "smart" to harness all the energy of a universe.

I spent the last year or two reading Ian Douglas's novels on the evolution of man into the future with a fair amount of physic theories in his books. It's all science fiction, but it pretty much starts with nanobot technology which in the grand scheme of things, we aren't all that far from accomplishing now. When that level of technology is upon us, then that will open the door for nanobots to repair our bodies at the cellular level and interface our neural system to larger neural networks.

Beery

##### Share on other sites

When we become smart enough to harness all the energy of our sun in our solar system with a Dyson sphere, then we can question the next evolution of being "smart" to harness all the energy of a universe.

I spent the last year or two reading Ian Douglas's novels on the evolution of man into the future with a fair amount of physic theories in his books. It's all science fiction, but it pretty much starts with nanobot technology which in the grand scheme of things, we aren't all that far from accomplishing now. When that level of technology is upon us, then that will open the door for nanobots to repair our bodies at the cellular level and interface our neural system to larger neural networks.

Beery

His books are good reads, particularly the Star Carrier series, and the science is sound, although I don't care much for his political views.

##### Share on other sites

Hmm ... never heard of him. Could it be that he is mainly known in the US? The en Wikipedia entry only has a one other language link (German), and there the article is rather small and does not even mention Ian Douglas but William H. Keith Jr. (real name).

##### Share on other sites

Huh... I thought I had verified all the digits at the time and all were correct. I'll have to double check you on that one I don't know if I kept any notes on the algorithm used. I do recall however spending a couple of weeks researching the process, particularly large number operations.

Here are three references, all with “617” at that location:

Hopefully, they do not all resolve to the same reference!

...lee

##### Share on other sites

Here are three references, all with “617” at that location:

Hopefully, they do not all resolve to the same reference!

...lee

Unfortunately it looks like you are right... The last 3 decimals are wrong. I wonder if it's a limitation of the formula used or the computing technique itself...

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.