Engel expansion: Difference between revisions

m
→‎{{header|Phix}}: js version of mpfr_ceil() improved, so undid the lopping of 10 digits from pi.
m (→‎{{header|Phix}}: js version of mpfr_ceil() improved, so undid the lopping of 10 digits from pi.)
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: #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.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384"</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>
Line 154:
<!--</lang>-->
{{out}}
I could only get pi accurate to 125 decimal places and root2 to 87, so cut the input strings accordingly, and later .<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>
You may or may not have better luck with completely rewriting this to use mpq (rationals).
Line 179 ⟶ 178:
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 460586654424342175 10179250672147483647 16267395912147483647 2147483647 2147483647
Number of terms : 70, places : 115125 (115125 correct)
Back to rational: 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384
Back to rational: 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823
 
Rational number : 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642743
7,806

edits