When I try to run your code, I get an incorrect answer for the root. I think the problem is in the exponent. The exponents are
$root and
($root - 1), respectively.
When I run this code:
timethese( 100, {
'Root' => '$x = Root( 100, 3 )',
'Root2' => '$y = Root2( 100, 3 )',
});
print <<END;
Root: $x
-----
Root2: $y
END
I get this for output:
Benchmark: timing 100 iterations of Root, Root2...
Root: 29 wallclock secs (28.39 usr + 0.00 sys = 28.39 CPU) @ 3
+.52/s (n=1 00)
Root2: 20 wallclock secs (20.03 usr + 0.00 sys = 20.03 CPU) @ 4
+.99/s (n=1 00)
Root: 4.6415888336127788924100763542328778501807372125002714
-----
Root2: 0.6664902595019951166742874561807256134735
___________________
Kurt
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.