9

1

I'm not a mathematician, and I'm not even going to pretend that I understand anything of the ECM. But I know it can be a fast method for factorization.

I benchmarked the factorization of $$798645312654798147285393218574111453126547981472185139328574111781$$

by Mathematica against this online applet, where the applet was 75 % faster (16 seconds versus 65 for Mathematica). Other factorizations were up to 6 times faster.

Does Mathematica use ECM for factorization of certain cases? If yes, how comes performance is so different?

**Additional information**

We can investigate in the above problem by calling `FactorInteger[..,Automatic]`

on the large number:

```
FactorInteger[
798645312654798147285393218574111453126547981472185139328574111781,
Automatic] // AbsoluteTiming
(* {5.647210,
{{61, 1}, {67, 1}, {74729, 1},
{2614930428035201342411278280525965452621044417207937542347, 1}}}
*)
```

This takes only a fraction of the time, but finds only *simple* factors. So it seems the rest of the time Mathematic tries to factor the last big number. And in fact:

```
FactorInteger[2614930428035201342411278280525965452621044417207937542347] // AbsoluteTiming
(*
{43.717204,
{{97913387938680010938335707, 1}, {26706566722753457593818813677521, 1}}}
*)
```

*(feel free to edit tags if needed)*

@rm-rf Java applets use your own PC to operate, they are client-side technology and require Java to be installed on your machine. – Leonid Shifrin – 2012-09-29T18:23:22.227

@LeonidShifrin Ok, in that case I stand corrected :) – rm -rf – 2012-09-29T18:24:05.643

@rm-rf - But do you see the same difference? – stevenvh – 2012-09-29T18:24:34.473

@stevenvh I'm running the applet now. I didn't know they were client-side and so assumed I'd get the same timing of 16s. – rm -rf – 2012-09-29T18:25:37.780

Yes, I see a huge difference. 5s applet vs. 30s for mma. One explanation could be that the applet uses all the available cores, whereas mma doesn't. – rm -rf – 2012-09-29T18:28:11.180

@rm-rf Applets are an obsolete technology, as far as I understand. They had their glory days when Flash and javascript were not really used much, but this is different now. Particularly because js is so fast now with the new JIT compilers in modern browsers, and HTML5 will soon make Flash go away too, it seems. – Leonid Shifrin – 2012-09-29T18:29:24.700

@Leonid - well, that dated technology doesn't seem to do so bad :-). And Flash's focus is on animation; I'm not sure it's the right tool for a complex mathematical program (read: has the right function library for it). – stevenvh – 2012-09-29T18:32:36.917

5FactorInteger uses ECM and several other methods. Timings can vary for any of several reasons. I'll name the ones that come to mind. (1) Time spent on other methods earlier, e.g. Pollard p-1 and rho. (2) Weaker tuning and/or implementation of ECM. (3) Possibility that ECM is parallelized in the other implementation (it is not in Mathematica). (4) The heuristics might be such that ECM simply fails for this example and we move on to the quadratic sieve. Item (1) is not the issue for the example posted. Item (4) is implicated. Items (2) and (3) might also be involved here. – Daniel Lichtblau – 2012-09-29T20:17:58.410

Just so you know, once upon a time, there was this package.

– J. M.'s ennui – 2012-09-30T02:12:03.7573http://reference.wolfram.com/mathematica/tutorial/SomeNotesOnInternalImplementation.en.html says

`FactorInteger`

switches between trial division, Pollard $p-1$, Pollard rho, elliptic curve, and quadratic sieve algorithms. – ziyuang – 2012-09-30T05:39:05.373