This is the part of the program it comes from. I thought all the math stuff would be Math::Something so I didn't know about that combinatorics module! That sounds very interesting. I wonder if/how it could be applied here? It runs through all the possible polynomials of a certain form and spits out the ones whose derivatives have (approximately) integer roots.

# $lep means smallest nonzero root in the interval [0, $rep] # $rep means right endpoint of the interval [0, $rep] my $lep = int 1; my $rep = int 100; foreach my $x ($lep+2 .. $rep ) { foreach my $y ($lep+1 .. $x-1 ) { foreach my $z ($lep .. $y-1 ) { foreach my $s (1..$rep/4) { unless ($y == $x + $s && $z == $y + $s ) { # assigns a truth value to whether or not it is wi +thin 0.0001 of an integer (1=true, 0=false) sub is_approximately_an_integer { my $eps = 0.0001; while( my $w = shift ) { # need to use "round", "int" does not work! return 0 if abs( $w-round($w) ) > $eps; } return 1 } } } push @wants, map { { join(', ', $x, $y, $z) => $_ } } grep { is_approximately_an_integer( @$_ ) } [ poly_roots( poly_derivative( # expanded form of x*(x - $x)*(x - $y)*(x +- $z) 1, -$x - $y - $z, $x*$y + $x*$z + $y*$z, - +$x*$y*$z, 0 ) ) ]; } } }

In reply to Re^2: help with simplifying program by crunch_this!
in thread help with simplifying program by crunch_this!

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.