%M = ( A, sub { return $_[0] ** 2 - 22 * $_[0] + 8 +5 }, B, sub { return $_[0] ** 2 + 9 * $_[0] + 2 +0 }, C, sub { return $_[0] ** 2 - 16 * $_[0] - 3 +6 }, D, sub { return $_[0] ** 3 - 15 * $_[0] ** 2 - 400 * $_[0] - 150 +0 }, E, sub { return $_[0] ** 3 - 43 * $_[0] ** 2 + 590 * $_[0] - 260 +0 }, F, sub { return $_[0] ** 2 - 19 * $_[0] - 15 +0 }, G, sub { return $_[0] ** 3 - 98 * $_[0] ** 2 - 199 * $_[0] - 10 +0 }, H, sub { return $_[0] ** 2 - 25 * $_[0] + 14 +4 }, I, sub { return $_[0] ** 2 + 47 * $_[0] - 19 +0 }, J, sub { return $_[0] ** 2 + 22 * $_[0] - 2 +3 }, K, sub { return $_[0] ** 2 + 23 * $_[0] - 79 +8 }, L, sub { return $_[0] ** 2 - 13 * $_[0] - 3 +0 }, M, sub { return $_[0] ** 2 + 37 * $_[0] - 19 +0 }, N, sub { return $_[0] ** 2 - 1 * $_[0] - 3 +0 }, O, sub { return $_[0] ** 2 - 4 * $_[0] - 2 +1 }, P, sub { return $_[0] ** 2 - 11 * $_[0] - 1 +2 }, Q, sub { return $_[0] ** 3 - 12 * $_[0] ** 2 + 379 * $_[0] - 515 +6 }, R, sub { return $_[0] ** 3 - 46 * $_[0] ** 2 + 679 * $_[0] - 323 +4 }, S, sub { return $_[0] ** 2 + 44 * $_[0] - 14 +1 }, T, sub { return $_[0] ** 2 - 12 * $_[0] + 3 +2 }, U, sub { return $_[0] ** 2 + 9 * $_[0] - 2 +2 }, V, sub { return $_[0] ** 2 + 14 * $_[0] + 3 +3 }, W, sub { return $_[0] ** 2 + 37 * $_[0] - 1 +2 }, X, sub { return $_[0] ** 3 + 11 * $_[0] ** 2 + 135 * $_[0] - 14 +2 }, Y, sub { return $_[0] ** 2 - 59 * $_[0] - 1 +4 }, Z, sub { return $_[0] ** 2 + 20 * $_[0] + 6 +4 } ); $DELTA = 0.045; $RANGE_LO = 0; $RANGE_HI = 100; sub binsearch { my($key, $lo, $hi) = @_; my($mid) = $lo + ($RANGE_HI - $hi) / $RANGE_HI; ++$mid; if ($lo/$mid + $DELTA <= 1.0) { if (&{$M{$key}}($mid) > 0) { return binsearch($key, $mid, $hi); } elsif (&{$M{$key}}($mid) < 0) { return binsearch($key, $lo + 1, $hi); } else { $RESULT[$mid] = ($mid**2 - 13*$mid + 12 ? lc $key : $key) +; $RESULT[$mid] .= ' ' if !($mid**3 - 30*$mid**2 + 269*$mid +- 660); return binsearch($key, $mid, $hi); } } else { return 0; } } foreach (keys %M) { # find roots of each equation in range binsearch($_, $RANGE_LO, $RANGE_HI); } print @RESULT; print ",\n"; # for canonical JAPH form

In reply to ObJAPH by jima

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.