Engel expansion: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: js version of mpfr_ceil() improved, so undid the lopping of 10 digits from pi.) |
|||
Line 130: | Line 130: | ||
<span style="color: #008080;">constant</span> <span style="color: #000000;">rats</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">rats</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span> |
||
<span style="color: #008000;">"3.14159265358979"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"2.71828182845904"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"1.414213562373095"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"7.59375"</span><span style="color: #0000FF;">,</span> |
<span style="color: #008000;">"3.14159265358979"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"2.71828182845904"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"1.414213562373095"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"7.59375"</span><span style="color: #0000FF;">,</span> |
||
<span style="color: #008000;">"3. |
<span style="color: #008000;">"3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384"</span><span style="color: #0000FF;">,</span> |
||
<span style="color: #008000;">"2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642743"</span><span style="color: #0000FF;">,</span> |
<span style="color: #008000;">"2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642743"</span><span style="color: #0000FF;">,</span> |
||
<span style="color: #008000;">"1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387"</span><span style="color: #0000FF;">,</span> |
<span style="color: #008000;">"1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387"</span><span style="color: #0000FF;">,</span> |
||
Line 154: | Line 154: | ||
<!--</lang>--> |
<!--</lang>--> |
||
{{out}} |
{{out}} |
||
I could only get pi accurate to 125 decimal places and root2 to 87, so cut the input strings accordingly |
I could only get pi accurate to 125 decimal places and root2 to 87, so cut the input strings accordingly.<br> |
||
had to lop another 10 dp off pi to avoid a crash under p2js.<br> |
|||
In fact the 1 digit error on desktop/Phix (below) don't happen in a browser. Increasing the precision helps but only up to a (relatively small) point. <br> |
In fact the 1 digit error on desktop/Phix (below) don't happen in a browser. Increasing the precision helps but only up to a (relatively small) point. <br> |
||
You may or may not have better luck with completely rewriting this to use mpq (rationals). |
You may or may not have better luck with completely rewriting this to use mpq (rationals). |
||
Line 179: | Line 178: | ||
Back to rational: 7.59375 |
Back to rational: 7.59375 |
||
Rational number : 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384 |
|||
Rational number : 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823 |
|||
Engel expansion : 1 1 1 8 8 17 19 300 1991 2492 7236 10586 34588 63403 70637 1236467 5417668 5515697 5633167 7458122 9637848 9805775 41840855 58408380 213130873 |
Engel expansion : 1 1 1 8 8 17 19 300 1991 2492 7236 10586 34588 63403 70637 1236467 5417668 5515697 5633167 7458122 9637848 9805775 41840855 58408380 213130873 424342175 2147483647 2147483647 2147483647 2147483647 |
||
Number of terms : 70, places : |
Number of terms : 70, places : 125 (125 correct) |
||
Back to rational: 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384 |
|||
Back to rational: 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823 |
|||
Rational number : 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642743 |
Rational number : 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642743 |