<s>
In	O
numerical	B-General_Concept
analysis	I-General_Concept
,	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
is	O
the	O
phenomenon	O
that	O
subtracting	O
good	O
approximations	O
to	O
two	O
nearby	O
numbers	O
may	O
yield	O
a	O
very	O
bad	O
approximation	O
to	O
the	O
difference	O
of	O
the	O
original	O
numbers	O
.	O
</s>
<s>
These	O
may	O
be	O
good	O
approximations	O
,	O
in	O
relative	B-Algorithm
error	I-Algorithm
,	O
to	O
the	O
true	O
lengths	O
:	O
the	O
approximations	O
are	O
in	O
error	O
by	O
less	O
than	O
2%	O
of	O
the	O
true	O
lengths	O
,	O
.	O
</s>
<s>
Catastrophic	B-Algorithm
cancellation	I-Algorithm
is	O
n't	O
affected	O
by	O
how	O
large	O
the	O
inputs	O
areit	O
applies	O
just	O
as	O
much	O
to	O
large	O
and	O
small	O
inputs	O
.	O
</s>
<s>
Catastrophic	B-Algorithm
cancellation	I-Algorithm
may	O
happen	O
even	O
if	O
the	O
difference	O
is	O
computed	O
exactly	O
,	O
as	O
in	O
the	O
example	O
aboveit	O
is	O
not	O
a	O
property	O
of	O
any	O
particular	O
kind	O
of	O
arithmetic	O
like	O
floating-point	B-Algorithm
arithmetic	I-Algorithm
;	O
rather	O
,	O
it	O
is	O
inherent	O
to	O
subtraction	O
,	O
when	O
the	O
inputs	O
are	O
approximations	O
themselves	O
.	O
</s>
<s>
Indeed	O
,	O
in	O
floating-point	B-Algorithm
arithmetic	I-Algorithm
,	O
when	O
the	O
inputs	O
are	O
close	O
enough	O
,	O
the	O
floating-point	B-Algorithm
difference	O
is	O
computed	O
exactly	O
,	O
by	O
the	O
Sterbenz	O
lemmathere	O
is	O
no	O
rounding	O
error	O
introduced	O
by	O
the	O
floating-point	B-Algorithm
subtraction	O
operation	O
.	O
</s>
<s>
Formally	O
,	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
happens	O
because	O
subtraction	O
is	O
ill-conditioned	B-Algorithm
at	O
nearby	O
inputs	O
:	O
even	O
if	O
approximations	O
and	O
have	O
small	O
relative	B-Algorithm
errors	I-Algorithm
and	O
from	O
true	O
values	O
and	O
,	O
respectively	O
,	O
the	O
relative	B-Algorithm
error	I-Algorithm
of	O
the	O
difference	O
of	O
the	O
approximations	O
from	O
the	O
difference	O
of	O
the	O
true	O
values	O
is	O
inversely	O
proportional	O
to	O
the	O
difference	O
of	O
the	O
true	O
values	O
:	O
</s>
<s>
Subtracting	O
nearby	O
numbers	O
in	O
floating-point	B-Algorithm
arithmetic	I-Algorithm
does	O
not	O
always	O
cause	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
,	O
or	O
even	O
any	O
errorby	O
the	O
Sterbenz	B-Algorithm
lemma	I-Algorithm
,	O
if	O
the	O
numbers	O
are	O
close	O
enough	O
the	O
floating-point	B-Algorithm
difference	O
is	O
exact	O
.	O
</s>
<s>
But	O
cancellation	O
may	O
amplify	O
errors	O
in	O
the	O
inputs	O
that	O
arose	O
from	O
rounding	O
in	O
other	O
floating-point	B-Algorithm
arithmetic	I-Algorithm
.	O
</s>
<s>
is	O
subject	O
to	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
when	O
and	O
are	O
close	O
in	O
magnitude	O
,	O
because	O
the	O
subtraction	O
can	O
expose	O
the	O
rounding	O
errors	O
in	O
the	O
squaring	O
.	O
</s>
<s>
avoids	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
because	O
it	O
avoids	O
introducing	O
rounding	O
error	O
leading	O
into	O
the	O
subtraction	O
.	O
</s>
<s>
However	O
,	O
is	O
not	O
a	O
binary64	O
floating-point	B-Algorithm
number	I-Algorithm
;	O
the	O
nearest	O
one	O
,	O
which	O
x	O
will	O
be	O
initialized	O
to	O
in	O
this	O
fragment	O
,	O
is	O
.	O
</s>
<s>
Although	O
the	O
radix	O
conversion	O
from	O
decimal	O
floating-point	B-Algorithm
to	O
binary	B-Algorithm
floating-point	I-Algorithm
only	O
incurs	O
a	O
small	O
relative	B-Algorithm
error	I-Algorithm
,	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
may	O
amplify	O
it	O
into	O
a	O
much	O
larger	O
one	O
:	O
</s>
<s>
The	O
relative	B-Algorithm
errors	I-Algorithm
of	O
x	O
from	O
and	O
of	O
y	O
from	O
are	O
both	O
below	O
,	O
and	O
the	O
floating-point	B-Algorithm
subtraction	O
y	O
-	O
x	O
is	O
computed	O
exactly	O
by	O
the	O
Sterbenz	B-Algorithm
lemma	I-Algorithm
.	O
</s>
<s>
But	O
even	O
though	O
the	O
inputs	O
are	O
good	O
approximations	O
,	O
and	O
even	O
though	O
the	O
subtraction	O
is	O
computed	O
exactly	O
,	O
the	O
difference	O
of	O
the	O
approximations	O
has	O
a	O
relative	B-Algorithm
error	I-Algorithm
of	O
over	O
from	O
the	O
difference	O
of	O
the	O
original	O
values	O
as	O
written	O
in	O
decimal	O
:	O
catastrophic	B-Algorithm
cancellation	I-Algorithm
amplified	O
a	O
tiny	O
error	O
in	O
radix	O
conversion	O
into	O
a	O
large	O
error	O
in	O
the	O
output	O
.	O
</s>
<s>
Cancellation	O
is	O
sometimes	O
useful	O
and	O
desirable	O
in	O
numerical	B-General_Concept
algorithms	I-General_Concept
.	O
</s>
<s>
For	O
example	O
,	O
the	O
2Sum	B-Algorithm
and	I-Algorithm
Fast2Sum	I-Algorithm
algorithms	O
both	O
rely	O
on	O
such	O
cancellation	O
after	O
a	O
rounding	O
error	O
in	O
order	O
to	O
exactly	O
compute	O
what	O
the	O
error	O
was	O
in	O
a	O
floating-point	B-Algorithm
addition	O
operation	O
as	O
a	O
floating-point	B-Algorithm
number	I-Algorithm
itself	O
.	O
</s>
<s>
itself	O
is	O
well-conditioned	B-Algorithm
at	O
inputs	O
near	O
.	O
</s>
