CE 3101
Fall 2011
Thought Problem
Calculating a Square Root
Your brain receives, stores, and processes information, dispenses results, and controls your
biological equipment. When properly programmed, computers can do likewise, except that
they control electromechanical rather than biological equipment. Beyond these functional
similarities, computers and brains have virtually nothing in common.
John Shore (1940 )
Background
How do you calculate the square root of a number. I don’t know about you, but I take out my calculator
(which is a small computer), enter the number, and press the
square root
button. This response, of course,
begs the question: how does a computer calculate the square root of a number?
Problem
Come up with an
algorithm
that accepts a positive number as input and generates the square root of the
number (up to an acceptable level of precision). You may use the four basic arithmetic operations:
+
,

,
/
,
and
×
.
Iterative Substitution
Let the number that we are trying to compute the square root of be represented by
b
. For this discussion
we will assume that
b >
0. Our problem at hand is to find
x
such that
x
=
√
b
(1)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 Barnes
 Xn, John Shore

Click to edit the document details