note
tmoertel
<blockquote><em> Don't factor!</em></blockquote>
Indeed, factoring saves time only when almost all of the factors can be canceled. Otherwise, the factors will just be multiplied back together – at great cost – to arrive back at nearly the original terms (magnitude wise), which then must be multiplied with each other to yield the final product.
<p>For example, if we start with 12 and factor it into 2x2x3, do we win or lose if we can cancel only one term? Two BigInt multiplications (e.g., 2x3xN, where N is large) is probably more costly than the original single multiplication (12xN), which makes our factoring a net loss, even though 2x3=6 is smaller than 12. Simply put, when it comes to run time the number of multiplications is what matters most.
<p>We probably win only when we can cancel all or all but one of the factors. Given that our numerators and denominators are often greatly unbalanced, how often will that happen? Our emprical results suggest not enough to be worthwhile. More likely, we will end up with one side of the dividing line plagued with little factors, like aphids on a rosebud, each sucking up an expensive multiplication.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-109406">
<p><small><strong>Tom Moertel</strong> : <a href="http://community.moertel.com/">Blog</a> / <a href="http://community.moertel.com/ss/space/Talks">Talks</a> / <a href="http://search.cpan.org/~tmoertel/">CPAN</a> / <a href="http://community.moertel.com/LectroTest">LectroTest</a> / <a href="http://community.moertel.com/ss/space/PXSL">PXSL</a> / <a href="http://community.moertel.com/ss/space/A+Coder%27s+Guide+To+Coffee">Coffee</a> / <a href="http://community.moertel.com/ss/space/IMDB+Movie-Rating+Decoder+Ring">Movie Rating Decoder</a></small></p>
</div></div>
481987
483367