<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
algorithm	O
(	O
QS	O
)	O
is	O
an	O
integer	O
factorization	O
algorithm	O
and	O
,	O
in	O
practice	O
,	O
the	O
second	O
fastest	O
method	O
known	O
(	O
after	O
the	O
general	B-Algorithm
number	I-Algorithm
field	I-Algorithm
sieve	I-Algorithm
)	O
.	O
</s>
<s>
It	O
is	O
still	O
the	O
fastest	O
for	O
integers	O
under	O
100	O
decimal	O
digits	O
or	O
so	O
,	O
and	O
is	O
considerably	O
simpler	O
than	O
the	O
number	B-Algorithm
field	I-Algorithm
sieve	I-Algorithm
.	O
</s>
<s>
The	O
algorithm	O
attempts	O
to	O
set	O
up	O
a	O
congruence	O
of	O
squares	O
modulo	O
n	O
(	O
the	O
integer	O
to	O
be	O
factorized	O
)	O
,	O
which	O
often	O
leads	O
to	O
a	O
factorization	O
of	O
n	O
.	O
The	O
algorithm	O
works	O
in	O
two	O
phases	O
:	O
the	O
data	O
collection	O
phase	O
,	O
where	O
it	O
collects	O
information	O
that	O
may	O
lead	O
to	O
a	O
congruence	O
of	O
squares	O
;	O
and	O
the	O
data	O
processing	O
phase	O
,	O
where	O
it	O
puts	O
all	O
the	O
data	O
it	O
has	O
collected	O
into	O
a	O
matrix	B-Architecture
and	O
solves	O
it	O
to	O
obtain	O
a	O
congruence	O
of	O
squares	O
.	O
</s>
<s>
The	O
data	O
collection	O
phase	O
can	O
be	O
easily	O
parallelized	B-Operating_System
to	O
many	O
processors	O
,	O
but	O
the	O
data	O
processing	O
phase	O
requires	O
large	O
amounts	O
of	O
memory	O
,	O
and	O
is	O
difficult	O
to	O
parallelize	O
efficiently	O
over	O
many	O
nodes	O
or	O
if	O
the	O
processing	O
nodes	O
do	O
not	O
each	O
have	O
enough	O
memory	O
to	O
store	O
the	O
whole	O
matrix	B-Architecture
.	O
</s>
<s>
The	O
block	O
Wiedemann	O
algorithm	O
can	O
be	O
used	O
in	O
the	O
case	O
of	O
a	O
few	O
systems	O
each	O
capable	O
of	O
holding	O
the	O
matrix	B-Architecture
.	O
</s>
<s>
This	O
is	O
roughly	O
the	O
basis	O
of	O
Fermat	B-Algorithm
's	I-Algorithm
factorization	I-Algorithm
method	I-Algorithm
.	O
</s>
<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
is	O
a	O
modification	O
of	O
Dixon	B-Algorithm
's	I-Algorithm
factorization	I-Algorithm
method	I-Algorithm
.	O
</s>
<s>
To	O
factorize	O
the	O
integer	O
n	O
,	O
Fermat	B-Algorithm
's	I-Algorithm
method	I-Algorithm
entails	O
a	O
search	O
for	O
a	O
single	O
number	O
a	O
,	O
,	O
such	O
that	O
the	O
remainder	O
of	O
a2	O
divided	O
by	O
n	O
is	O
a	O
square	O
.	O
</s>
<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
consists	O
of	O
computing	O
the	O
remainder	O
of	O
a2/n	O
for	O
several	O
a	O
,	O
then	O
finding	O
a	O
subset	O
of	O
these	O
whose	O
product	O
is	O
a	O
square	O
.	O
</s>
<s>
This	O
is	O
a	O
linear	B-Language
algebra	I-Language
problem	O
since	O
the	O
ring	O
can	O
be	O
regarded	O
as	O
the	O
Galois	O
field	O
of	O
order	O
2	O
,	O
that	O
is	O
we	O
can	O
divide	O
by	O
all	O
non-zero	O
numbers	O
(	O
there	O
is	O
only	O
one	O
,	O
namely	O
1	O
)	O
when	O
calculating	O
modulo	O
2	O
.	O
</s>
<s>
It	O
is	O
a	O
theorem	O
of	O
linear	B-Language
algebra	I-Language
that	O
with	O
more	O
vectors	O
than	O
each	O
vector	O
has	O
entries	O
,	O
a	O
linear	O
dependency	O
always	O
exists	O
.	O
</s>
<s>
It	O
can	O
be	O
found	O
by	O
Gaussian	B-Algorithm
elimination	I-Algorithm
.	O
</s>
<s>
However	O
,	O
simply	O
squaring	O
many	O
random	O
numbers	O
mod	O
n	O
produces	O
a	O
very	O
large	O
number	O
of	O
different	O
prime	O
factors	O
,	O
and	O
so	O
very	O
long	O
vectors	O
and	O
a	O
very	O
large	O
matrix	B-Architecture
.	O
</s>
<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
searches	O
for	O
smooth	O
numbers	O
using	O
a	O
technique	O
called	O
sieving	O
,	O
discussed	O
later	O
,	O
from	O
which	O
the	O
algorithm	O
takes	O
its	O
name	O
.	O
</s>
<s>
To	O
summarize	O
,	O
the	O
basic	O
quadratic	B-Algorithm
sieve	I-Algorithm
algorithm	O
has	O
these	O
main	O
steps	O
:	O
</s>
<s>
Use	O
linear	B-Language
algebra	I-Language
to	O
find	O
a	O
subset	O
of	O
these	O
vectors	O
which	O
add	O
to	O
the	O
zero	O
vector	O
.	O
</s>
<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
attempts	O
to	O
find	O
pairs	O
of	O
integers	O
x	O
and	O
y(x )	O
(	O
where	O
y(x )	O
is	O
a	O
function	O
of	O
x	O
)	O
satisfying	O
a	O
much	O
weaker	O
condition	O
than	O
x2	O
≡	O
y2	O
(	O
mod	O
n	O
)	O
.	O
</s>
<s>
The	O
quadratic	B-Algorithm
sieve	I-Algorithm
speeds	O
up	O
the	O
process	O
of	O
finding	O
relations	O
by	O
taking	O
x	O
close	O
to	O
the	O
square	O
root	O
of	O
n	O
.	O
This	O
ensures	O
that	O
y(x )	O
will	O
be	O
smaller	O
,	O
and	O
thus	O
have	O
a	O
greater	O
chance	O
of	O
being	O
smooth	O
.	O
</s>
<s>
The	O
most	O
obvious	O
is	O
by	O
trial	B-Algorithm
division	I-Algorithm
,	O
although	O
this	O
increases	O
the	O
running	O
time	O
for	O
the	O
data	O
collection	O
phase	O
.	O
</s>
<s>
Another	O
method	O
that	O
has	O
some	O
acceptance	O
is	O
the	O
elliptic	B-Algorithm
curve	I-Algorithm
method	I-Algorithm
(	O
ECM	O
)	O
.	O
</s>
<s>
(	O
This	O
is	O
where	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
gets	O
its	O
name	O
:	O
y	O
is	O
a	O
quadratic	O
polynomial	O
in	O
x	O
,	O
and	O
the	O
sieving	O
process	O
works	O
like	O
the	B-Algorithm
Sieve	I-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
.	O
)	O
</s>
<s>
The	O
information	O
about	O
exactly	O
which	O
primes	O
divide	O
y(x )	O
has	O
been	O
lost	O
,	O
but	O
it	O
has	O
only	O
small	O
factors	O
,	O
and	O
there	O
are	O
many	O
good	O
algorithms	O
for	O
factoring	O
a	O
number	O
known	O
to	O
have	O
only	O
small	O
factors	O
,	O
such	O
as	O
trial	B-Algorithm
division	I-Algorithm
by	O
small	O
primes	O
,	O
SQUFOF	B-Algorithm
,	O
Pollard	B-Algorithm
rho	I-Algorithm
,	O
and	O
ECM	O
,	O
which	O
are	O
usually	O
used	O
in	O
some	O
combination	O
.	O
</s>
<s>
This	O
example	O
will	O
demonstrate	O
standard	O
quadratic	B-Algorithm
sieve	I-Algorithm
without	O
logarithm	O
optimizations	O
or	O
prime	O
powers	O
.	O
</s>
<s>
Since	O
smooth	O
numbers	O
Y	O
have	O
been	O
found	O
with	O
the	O
property	O
,	O
the	O
remainder	O
of	O
the	O
algorithm	O
follows	O
equivalently	O
to	O
any	O
other	O
variation	O
of	O
Dixon	B-Algorithm
's	I-Algorithm
factorization	I-Algorithm
method	I-Algorithm
.	O
</s>
<s>
as	O
a	O
matrix	B-Architecture
yields	O
:	O
</s>
<s>
This	O
demonstration	O
should	O
also	O
serve	O
to	O
show	O
that	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
is	O
only	O
appropriate	O
when	O
n	O
is	O
large	O
.	O
</s>
<s>
Trial	B-Algorithm
division	I-Algorithm
or	O
Pollard	B-Algorithm
rho	I-Algorithm
could	O
have	O
found	O
a	O
factor	O
with	O
much	O
less	O
computation	O
.	O
</s>
<s>
This	O
approach	O
(	O
called	O
MPQS	B-Algorithm
,	O
Multiple	B-Algorithm
Polynomial	I-Algorithm
Quadratic	I-Algorithm
Sieve	I-Algorithm
)	O
is	O
ideally	O
suited	O
for	O
parallelization	B-Operating_System
,	O
since	O
each	O
processor	B-General_Concept
involved	O
in	O
the	O
factorization	O
can	O
be	O
given	O
n	O
,	O
the	O
factor	O
base	O
and	O
a	O
collection	O
of	O
polynomials	O
,	O
and	O
it	O
will	O
have	O
no	O
need	O
to	O
communicate	O
with	O
the	O
central	O
processor	B-General_Concept
until	O
it	O
is	O
finished	O
with	O
its	O
polynomials	O
.	O
</s>
<s>
Until	O
the	O
discovery	O
of	O
the	O
number	B-Algorithm
field	I-Algorithm
sieve	I-Algorithm
(	O
NFS	O
)	O
,	O
QS	O
was	O
the	O
asymptotically	O
fastest	O
known	O
general-purpose	O
factoring	O
algorithm	O
.	O
</s>
<s>
Now	O
,	O
Lenstra	B-Algorithm
elliptic	I-Algorithm
curve	I-Algorithm
factorization	I-Algorithm
has	O
the	O
same	O
asymptotic	O
running	O
time	O
as	O
QS	O
(	O
in	O
the	O
case	O
where	O
n	O
has	O
exactly	O
two	O
prime	O
factors	O
of	O
equal	O
size	O
)	O
,	O
but	O
in	O
practice	O
,	O
QS	O
is	O
faster	O
since	O
it	O
uses	O
single-precision	O
operations	O
instead	O
of	O
the	O
multi-precision	B-Algorithm
operations	O
used	O
by	O
the	O
elliptic	B-Algorithm
curve	I-Algorithm
method	I-Algorithm
.	O
</s>
<s>
The	O
data	O
processing	O
phase	O
took	O
45	O
hours	O
on	O
Bellcore	O
's	O
(	O
now	O
Telcordia	O
Technologies	O
)	O
MasPar	B-Device
(	O
massively	O
parallel	O
)	O
supercomputer	O
.	O
</s>
<s>
is	O
a	O
fast	O
implementation	O
of	O
the	O
self-initialising	O
multiple	B-Algorithm
polynomial	I-Algorithm
quadratic	I-Algorithm
sieve	I-Algorithm
written	O
by	O
William	O
Hart	O
.	O
</s>
<s>
It	O
provides	O
support	O
for	O
the	O
large	O
prime	O
variant	O
and	O
uses	O
Jason	O
Papadopoulos	O
 '	O
block	O
Lanczos	O
code	O
for	O
the	O
linear	B-Language
algebra	I-Language
stage	O
.	O
</s>
<s>
SIMPQS	O
is	O
accessible	O
as	O
the	O
qsieve	O
command	O
in	O
the	O
SageMath	B-Application
computer	O
algebra	O
package	O
or	O
can	O
be	O
downloaded	O
in	O
source	O
form	O
.	O
</s>
<s>
a	O
by	O
Dario	O
Alpern	O
,	O
that	O
uses	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
if	O
certain	O
conditions	O
are	O
met	O
.	O
</s>
<s>
The	O
PARI/GP	B-Language
computer	O
algebra	O
package	O
includes	O
an	O
implementation	O
of	O
the	O
self-initialising	O
multiple	B-Algorithm
polynomial	I-Algorithm
quadratic	I-Algorithm
sieve	I-Algorithm
implementing	O
the	O
large	O
prime	O
variant	O
.	O
</s>
<s>
A	O
variant	O
of	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
is	O
available	O
in	O
the	O
MAGMA	B-General_Concept
computer	O
algebra	O
package	O
.	O
</s>
<s>
,	O
an	O
implementation	O
of	O
the	O
multiple	B-Algorithm
polynomial	I-Algorithm
quadratic	I-Algorithm
sieve	I-Algorithm
with	O
support	O
for	O
single	O
and	O
double	O
large	O
primes	O
,	O
written	O
by	O
Jason	O
Papadopoulos	O
.	O
</s>
<s>
,	O
written	O
by	O
Ben	O
Buhrow	O
,	O
is	O
probably	O
the	O
fastest	O
available	O
implementation	O
of	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
.	O
</s>
<s>
All	O
of	O
the	O
critical	O
subroutines	O
make	O
use	O
of	O
AVX2	O
or	O
AVX-512	B-General_Concept
SIMD	B-Device
instructions	O
for	O
AMD	O
or	O
Intel	O
processors	O
.	O
</s>
<s>
,	O
a	O
simple	O
Java	O
implementation	O
of	O
the	O
quadratic	B-Algorithm
sieve	I-Algorithm
for	O
didactic	O
purposes	O
.	O
</s>
<s>
The	O
contains	O
probably	O
the	O
fastest	O
quadratic	B-Algorithm
sieve	I-Algorithm
written	O
in	O
Java	O
(	O
the	O
successor	O
of	O
PSIQS	O
4.0	O
)	O
.	O
</s>
<s>
,	O
a	O
factorizer	O
written	O
entirely	O
in	O
C	O
containing	O
implementation	O
of	O
self-initialising	O
Quadratic	B-Algorithm
Sieve	I-Algorithm
.	O
</s>
<s>
The	O
package	O
by	O
Joseph	O
Wood	O
,	O
provides	O
an	O
efficient	O
implementation	O
of	O
the	O
multiple	B-Algorithm
polynomial	I-Algorithm
quadratic	I-Algorithm
sieve	I-Algorithm
for	O
the	O
R	O
programming	O
language	O
.	O
</s>
