i have a question about this, if anyone wants to find the time. How many decimal places of accuracy will perl allow? This algorithm gets more accurate after every iteration, but perl stops at about 10 or 11 places of accuracy and the rest is off, which makes me wonder. It's not obfuscated except for the algorithm...
#!/usr/local/bin/perl -w
use strict;
my($s,$a)=(5*(-2+sqrt 5),.5);sub a{5/(pop)-1}
sub b{(a(pop)-1)**2+7}sub c{my$s=pop;(a($s)/2
*(b($s)+sqrt(b( $s )**2-4*a($s)**3)))**(1/5)}
sub d{my$s=pop;25/((c($s)+a($s)/c($s)+1)**2*$
s)}sub e{my ($s,$a,$m)=
@_;($s**2*$ a)-5**$m*((
($s**2-5)/2 )+sqrt$s*($
s**2-(2*$s) +5))}my($x,
$n)= (shift ||10,0);do{
$a=e($s,$a, $n);$s=d($s
)}while$n++ <$x;print""
,(1/$a),$/;
jynx
In reply to tasty pi
by jynx
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.