<s>
Methods	B-Library
of	I-Library
computing	I-Library
square	I-Library
roots	I-Library
are	O
numerical	B-General_Concept
analysis	I-General_Concept
algorithms	O
for	O
approximating	O
the	O
principal	O
,	O
or	O
non-negative	O
,	O
square	O
root	O
(	O
usually	O
denoted	O
,	O
,	O
or	O
)	O
of	O
a	O
real	O
number	O
.	O
</s>
<s>
Many	O
iterative	O
square	B-Library
root	I-Library
algorithms	I-Library
require	O
an	O
initial	O
seed	B-Algorithm
value	I-Algorithm
.	O
</s>
<s>
The	O
absolute	O
and	O
relative	B-Algorithm
error	I-Algorithm
for	O
these	O
will	O
differ	O
.	O
</s>
<s>
This	O
estimate	O
has	O
maximum	O
absolute	B-Algorithm
error	I-Algorithm
of	O
at	O
a	O
=	O
100	O
,	O
and	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
of	O
100%	O
at	O
a	O
=	O
1	O
.	O
</s>
<s>
,	O
an	O
absolute	B-Algorithm
error	I-Algorithm
of	O
246	O
and	O
relative	B-Algorithm
error	I-Algorithm
of	O
almost	O
70%	O
.	O
</s>
<s>
It	O
has	O
a	O
maximum	O
absolute	B-Algorithm
error	I-Algorithm
of	O
1.2	O
at	O
a	O
=	O
100	O
,	O
and	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
of	O
30%	O
at	O
S=	O
1	O
and	O
10	O
.	O
</s>
<s>
The	O
approximation	O
(	O
rounded	O
or	O
not	O
)	O
using	O
a	O
single	O
line	O
spanning	O
the	O
range	O
is	O
less	O
than	O
one	O
significant	O
digit	O
of	O
precision	O
;	O
the	O
relative	B-Algorithm
error	I-Algorithm
is	O
greater	O
than	O
1/22	O
,	O
so	O
less	O
than	O
2	O
bits	O
of	O
information	O
are	O
provided	O
.	O
</s>
<s>
The	O
maximum	O
absolute	B-Algorithm
errors	I-Algorithm
occur	O
at	O
the	O
high	O
points	O
of	O
the	O
intervals	O
,	O
at	O
a	O
=	O
10	O
and	O
100	O
,	O
and	O
are	O
0.54	O
and	O
1.7	O
respectively	O
.	O
</s>
<s>
The	O
maximum	O
relative	B-Algorithm
errors	I-Algorithm
are	O
at	O
the	O
endpoints	O
of	O
the	O
intervals	O
,	O
at	O
a	O
=	O
1	O
,	O
10	O
and	O
100	O
,	O
and	O
are	O
17%	O
in	O
both	O
cases	O
.	O
</s>
<s>
It	O
has	O
maximum	O
absolute	B-Algorithm
error	I-Algorithm
of	O
1.58	O
at	O
100	O
and	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
of	O
16.0	O
%	O
at	O
10	O
.	O
</s>
<s>
has	O
maximum	O
absolute	B-Algorithm
error	I-Algorithm
of	O
0.0408	O
at	O
=	O
2	O
,	O
and	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
of	O
3.0	O
%	O
at	O
=	O
1	O
.	O
</s>
<s>
which	O
has	O
maximum	O
absolute	B-Algorithm
error	I-Algorithm
of	O
0.086	O
at	O
2	O
and	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
of	O
6.1	O
%	O
at	O
=	O
0.5	O
and	O
=	O
2.0	O
.	O
</s>
<s>
,	O
so	O
the	O
estimate	O
has	O
an	O
absolute	B-Algorithm
error	I-Algorithm
of	O
19	O
and	O
relative	B-Algorithm
error	I-Algorithm
of	O
5.3	O
%	O
.	O
</s>
<s>
The	O
relative	B-Algorithm
error	I-Algorithm
is	O
a	O
little	O
less	O
than	O
1/24	O
,	O
so	O
the	O
estimate	O
is	O
good	O
to	O
4+	O
bits	O
.	O
</s>
<s>
An	O
estimate	O
for	O
good	O
to	O
8	O
bits	O
can	O
be	O
obtained	O
by	O
table	O
lookup	O
on	O
the	O
high	O
8	O
bits	O
of	O
,	O
remembering	O
that	O
the	O
high	O
bit	O
is	O
implicit	O
in	O
most	O
floating	B-Algorithm
point	I-Algorithm
representations	I-Algorithm
,	O
and	O
the	O
bottom	O
bit	O
of	O
the	O
8	O
should	O
be	O
rounded	O
.	O
</s>
<s>
This	O
is	O
a	O
quadratically	B-Architecture
convergent	I-Architecture
algorithm	O
,	O
which	O
means	O
that	O
the	O
number	O
of	O
correct	O
digits	O
of	O
the	O
approximation	O
roughly	O
doubles	O
with	O
each	O
iteration	O
.	O
</s>
<s>
The	O
same	O
idea	O
can	O
be	O
extended	O
to	O
any	O
arbitrary	O
square	B-Library
root	I-Library
computation	I-Library
next	O
.	O
</s>
<s>
such	O
that	O
for	O
all	O
with	O
initialization	O
When	O
the	O
exact	O
square	O
root	O
has	O
been	O
found	O
;	O
if	O
not	O
,	O
then	O
the	O
sum	O
of	O
s	O
gives	O
a	O
suitable	O
approximation	O
of	O
the	O
square	O
root	O
,	O
with	O
being	O
the	O
approximation	B-Algorithm
error	I-Algorithm
.	O
</s>
<s>
The	O
numbers	O
are	O
written	O
similar	O
to	O
the	O
long	B-Algorithm
division	I-Algorithm
algorithm	O
,	O
and	O
,	O
as	O
in	O
long	B-Algorithm
division	I-Algorithm
,	O
the	O
root	O
will	O
be	O
written	O
on	O
the	O
line	O
above	O
.	O
</s>
<s>
Pocket	O
calculators	B-Application
typically	O
implement	O
good	O
routines	O
to	O
compute	O
the	O
exponential	O
function	O
and	O
the	O
natural	O
logarithm	O
,	O
and	O
then	O
compute	O
the	O
square	O
root	O
of	O
S	O
using	O
the	O
identity	O
found	O
using	O
the	O
properties	O
of	O
logarithms	O
(	O
)	O
and	O
exponentials	O
(	O
)	O
:	O
</s>
<s>
The	O
same	O
identity	O
is	O
used	O
when	O
computing	B-Library
square	I-Library
roots	I-Library
with	O
logarithm	O
tables	O
or	O
slide	O
rules	O
.	O
</s>
<s>
This	O
,	O
however	O
,	O
is	O
no	O
real	O
limitation	O
for	O
a	O
computer	O
based	O
calculation	O
,	O
as	O
in	O
base	B-Algorithm
2	I-Algorithm
floating	I-Algorithm
point	I-Algorithm
and	O
fixed	O
point	O
representations	O
,	O
it	O
is	O
trivial	O
to	O
multiply	O
by	O
an	O
integer	O
power	O
of	O
4	O
,	O
and	O
therefore	O
by	O
the	O
corresponding	O
power	O
of	O
2	O
,	O
by	O
changing	O
the	O
exponent	O
or	O
by	O
shifting	O
,	O
respectively	O
.	O
</s>
<s>
This	O
method	O
was	O
developed	O
around	O
1950	O
by	O
M	O
.	O
V	O
.	O
Wilkes	O
,	O
D	O
.	O
J	O
.	O
Wheeler	O
and	O
S	O
.	O
Gill	O
for	O
use	O
on	O
EDSAC	B-Device
,	O
one	O
of	O
the	O
first	O
electronic	O
computers	O
.	O
</s>
<s>
The	O
following	O
are	O
iterative	O
methods	O
for	O
finding	O
the	O
reciprocal	B-Library
square	I-Library
root	I-Library
of	O
S	O
which	O
is	O
.	O
</s>
<s>
If	O
the	O
initial	O
value	O
is	O
not	O
close	O
to	O
the	O
reciprocal	B-Library
square	I-Library
root	I-Library
,	O
the	O
iterations	O
will	O
diverge	O
away	O
from	O
it	O
rather	O
than	O
converge	O
to	O
it	O
.	O
</s>
<s>
This	O
converges	B-Architecture
cubically	I-Architecture
,	O
but	O
involves	O
five	O
multiplications	O
per	O
iteration	O
:	O
</s>
<s>
If	O
using	O
floating-point	B-Algorithm
,	O
Halley	O
's	O
method	O
can	O
be	O
reduced	O
to	O
four	O
multiplications	O
per	O
iteration	O
by	O
precomputing	O
and	O
adjusting	O
all	O
the	O
other	O
constants	O
to	O
compensate	O
:	O
</s>
<s>
Goldschmidt	O
's	O
algorithm	O
finds	O
faster	O
than	O
Newton-Raphson	O
iteration	O
on	O
a	O
computer	O
with	O
a	O
fused	O
multiply	O
–	O
add	O
instruction	O
and	O
either	O
a	O
pipelined	O
floating	B-Algorithm
point	I-Algorithm
unit	O
or	O
two	O
independent	O
floating-point	B-Algorithm
units	O
.	O
</s>
<s>
As	O
an	O
iterative	O
method	O
,	O
the	O
order	B-Architecture
of	I-Architecture
convergence	I-Architecture
is	O
equal	O
to	O
the	O
number	O
of	O
terms	O
used	O
.	O
</s>
<s>
To	O
maximize	O
the	O
rate	B-Architecture
of	I-Architecture
convergence	I-Architecture
,	O
choose	O
N	O
so	O
that	O
is	O
as	O
small	O
as	O
possible	O
.	O
</s>
<s>
The	O
relative	B-Algorithm
error	I-Algorithm
is	O
0.17	O
%	O
,	O
so	O
the	O
rational	O
fraction	O
is	O
good	O
to	O
almost	O
three	O
digits	O
of	O
precision	O
.	O
</s>
<s>
the	O
Lucas	B-Algorithm
sequence	I-Algorithm
of	O
the	O
first	O
kind	O
Un(P,Q )	O
is	O
defined	O
by	O
the	O
recurrence	O
relations:and	O
the	O
characteristic	O
equation	O
of	O
it	O
is:it	O
has	O
the	O
discriminant	O
and	O
the	O
roots:all	O
that	O
yield	O
the	O
following	O
positive	O
value:so	O
when	O
we	O
want	O
,	O
we	O
can	O
choose	O
and	O
,	O
and	O
then	O
calculate	O
using	O
and	O
for	O
large	O
value	O
of	O
.	O
</s>
<s>
A	O
number	O
is	O
represented	O
in	O
a	O
floating	B-Algorithm
point	I-Algorithm
format	I-Algorithm
as	O
which	O
is	O
also	O
called	O
scientific	O
notation	O
.	O
</s>
<s>
A	O
computer	O
using	O
base	O
sixteen	O
would	O
require	O
a	O
larger	O
table	O
,	O
but	O
one	O
using	O
base	O
two	O
would	O
require	O
only	O
three	O
entries	O
:	O
the	O
possible	O
bits	O
of	O
the	O
integer	O
part	O
of	O
the	O
adjusted	O
mantissa	O
are	O
01	O
(	O
the	O
power	O
being	O
even	O
so	O
there	O
was	O
no	O
shift	O
,	O
remembering	O
that	O
a	O
normalised	B-Algorithm
floating	B-Algorithm
point	I-Algorithm
number	I-Algorithm
always	O
has	O
a	O
non-zero	O
high-order	O
digit	O
)	O
or	O
if	O
the	O
power	O
was	O
odd	O
,	O
10	O
or	O
11	O
,	O
these	O
being	O
the	O
first	O
two	O
bits	O
of	O
the	O
original	O
mantissa	O
.	O
</s>
<s>
Thus	O
,	O
6.25	O
=	O
110.01	O
in	O
binary	O
,	O
normalised	B-Algorithm
to	O
1.1001	O
22	O
an	O
even	O
power	O
so	O
the	O
paired	O
bits	O
of	O
the	O
mantissa	O
are	O
01	O
,	O
while	O
.625	O
=	O
0.101	O
in	O
binary	O
normalises	O
to	O
1.01	O
2−1	O
an	O
odd	O
power	O
so	O
the	O
adjustment	O
is	O
to	O
10.1	O
2−2	O
and	O
the	O
paired	O
bits	O
are	O
10	O
.	O
</s>
<s>
For	O
example	O
,	O
Fortran	B-Application
offers	O
an	O
EXPONENT(x )	O
function	O
to	O
obtain	O
the	O
power	O
.	O
</s>
<s>
The	O
technique	O
that	O
follows	O
is	O
based	O
on	O
the	O
fact	O
that	O
the	O
floating	B-Algorithm
point	I-Algorithm
format	I-Algorithm
(	O
in	O
base	O
two	O
)	O
approximates	O
the	O
base-2	O
logarithm	O
.	O
</s>
<s>
So	O
for	O
a	O
32-bit	O
single	O
precision	O
floating	B-Algorithm
point	I-Algorithm
number	I-Algorithm
in	O
IEEE	O
format	O
(	O
where	O
notably	O
,	O
the	O
power	O
has	O
a	O
bias	B-Algorithm
of	O
127	O
added	O
for	O
the	O
represented	O
form	O
)	O
you	O
can	O
get	O
the	O
approximate	O
logarithm	O
by	O
interpreting	O
its	O
binary	O
representation	O
as	O
a	O
32-bit	O
integer	O
,	O
scaling	O
it	O
by	O
,	O
and	O
removing	O
a	O
bias	B-Algorithm
of	O
127	O
,	O
i.e.	O
</s>
<s>
An	O
additional	O
adjustment	O
can	O
be	O
added	O
to	O
reduce	O
the	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
.	O
</s>
<s>
where	O
a	O
is	O
a	O
bias	B-Algorithm
for	O
adjusting	O
the	O
approximation	B-Algorithm
errors	I-Algorithm
.	O
</s>
<s>
With	O
a	O
=	O
0x4B0D2	O
,	O
the	O
maximum	O
relative	B-Algorithm
error	I-Algorithm
is	O
minimized	O
to	O
±	O
3.5	O
%	O
.	O
</s>
<s>
The	O
integer-shift	O
approximation	O
produced	O
a	O
relative	B-Algorithm
error	I-Algorithm
of	O
less	O
than	O
4%	O
,	O
and	O
the	O
error	O
dropped	O
further	O
to	O
0.15	O
%	O
with	O
one	O
iteration	O
of	O
Newton	O
's	O
method	O
on	O
the	O
following	O
line	O
.	O
</s>
<s>
Some	O
VLSI	O
hardware	O
implements	O
inverse	B-Library
square	I-Library
root	I-Library
using	O
a	O
second	O
degree	O
polynomial	O
estimation	O
followed	O
by	O
a	O
Goldschmidt	O
iteration	O
.	O
</s>
