Professional Documents
Culture Documents
Introduction To Computer Science Mathematics - Jamison, Robert V - 1973 - New York, McGraw-Hill - 9780070322769 - Anna's Archive
Introduction To Computer Science Mathematics - Jamison, Robert V - 1973 - New York, McGraw-Hill - 9780070322769 - Anna's Archive
J
7
phbbipetteapety
* Oo
= < whet
Peserenan ;
: TESS UMBUMOCE
SFE LESTE
BOD LATE
IO EP SERNETEATE TARR
2s ATS OATTIS LAR IRAESSEMRA
https//archive.org/details/introductiontoco0000jami
Robert V. Jamison
Northrop Institute of Technology
Introduction to
Computer Science Mathematics
The editors for this book were Robert Flowers and Cath-
erine Kerr, the designer was Marsha Cohen, and its
production was supervised by James E. Lee. It was set
in Palatino by Progressive Typographers. It was printed
and bound by Kingsport Press Inc.
Contents
Preface
Vii
Index 269
vi CONTENTS
Preface
This book is designed to present those special topics which are generally con-
sidered fundamental to the fields of data processing, computer programming,
and computer design. Its level is that of a first course with one year of algebra
considered prerequisite. The material is suitable for all students who will do
any kind of computing, whether they will ultimately specialize in business or
scientific and engineering applications or whether their interest will lie in strict
computer science and computer design applications.
Finite mathematics concepts are covered in two chapters on the decimal
number system and on other number systems, including the binary system. A
comprehensive study of arithmetic in all these number systems is presented.
The function concept is used throughout. Linear, quadratic, polynomial,
exponential, and logarithmic functions and equations are included. Addition-
ally, they are linked together through the general topic of curvefitting. Numer-
ical and useful semigraphical methods are explained and used extensively.
Particular attention is paid to the linear function by means of such topics as
linear equations, simultaneous linear equations, linear inequalities, linear
programming, and matrix methods. Set theory is used throughout rather than
being presented as a separate topic. Further topics in algebra should be
studied by means of a full course in college algebra.
Matrices and determinants and their applications are discussed in a
separate chapter. Included are applications of the method of elementary row
operations to the finding of matrix inverses and to the solution of simultaneous
linear equations.
Symbolic programming languages are discussed. A complete presenta-
tion is made of a somewhat shortened version of the Fortran IV language.
Fortran was chosen as the language most suitable for the solution of the types
of problems presented in this book. Basic Fortran IV is presented, including
such topics as real and integer constants, arithmetic statements, input and out-
put statements with Format, and control statements. Subprogramming is not
discussed. Complete executable Fortran programs can be written following the
study of this material. The topics of program planning and flowcharting are
presented, and Fortran programs are used to solve problems throughout the
subsequent portion of the book. Once again, those who will specialize in
programming to solve advanced problems in the scientific and engineering
fields can then undertake a full course in Fortran programming and with this
background should succeed with great ease.
The rather extended chapter on Boolean algebra proceeds from the basic
physical properties of the simple switching circuit to a full study of the theory
and further applications of Boolean algebra. Such topics as Boolean identities,
truth tables, and normal forms for Boolean expressions are covered. Karnaugh
vii
maps are used extensively as the main method for simplifying Boolean expres-
sions. Throughout, logic blocks are used to design logic circuits that imple-
ment Boolean functions. Functionally complete logic blocks such as NAND
and NOR are explained and employed. An insight into the design of the arith-
metic unit of a digital computer is provided by the section on half- and full-
adders.
Problem sets are interwoven throughout the chapters immediately fol-
lowing the presentation of the topics to which they apply. Answers to selected
exercises appear at the end of the book.
The author is indebted to Robert D. Chenoweth, County College of
Morris, Robert L. Monsees, Meramec Community College, and Forrest L.
Barker, Los Angeles City College, for their critical reviews of the original manu-
script and their valuable suggestions for its improvement.
Robert V. Jamison
viii PREFACE
Introduction to
Computer Science Mathematics
.
; 7 sh oe! Ca ral
oa e)> : 5
MARR
; : S _——
SS
The Decimal Number System
The first chapter of this book is about decimal numbers because they are the
objects that we write, manipulate, and combine in various ways to do all the
computations that are required to solve problems. We do not intend to discuss
the theoretical and abstract nature of numbers. Instead, we shall often assume
that you are familiar with many of the properties of numbers simply because
you have used them so often in presumably reasonable and useful applica-
tions. Sometimes, though, we shall present interesting properties of numbers
in unusual ways in order to provoke some new thinking on your part. It is
extremely important that we understand the properties of numbers and the
rules of arithmetic before we undertake the study of algebra. After all, algebra
is simply a generalization of the arithmetic of numbers in which nonnumeric
symbols are often used to represent numbers.
No matter how delightfully descriptive (or mischievously deceptive)
the language in which a problem in science, engineering, business, or other-
wise is stated, the words must be translated into algebraic and other kinds of
relations and equations among the numbers and symbols representing num-
bers. To make this possible, we shall always require that the problem be in-
herently amenable to mathematical solution; that is, it must be well posed.
This translation must accurately restate the problem in mathematical form. It
therefore seems fairly evident that careful reading and logical analysis of the
problem as well as familiarity with applicable mathematical language are abso-
lutely essential for making the correct mathematical interpretation.
ALGEBRAIC
MATHEMATICAL WORD
WORD FORMULATION
SOLUTION SOLUTION
PROBLEM OF THE
PROBLEM
Fig. 1.1
With all the rhetoric then removed, the problem becomes one on which
is, the
the principles and techniques of applied mathematics can be used, that
and computin g you will learn here and in later courses in
tools of analysis
applied mathematics. The solution of the problem can then be translate d back
into the language in which it was originally stated.
The process just described can be graphically represented by the block
diagram of Fig.1.1. All problems from whatever source must be translated into
the form shown in block II and solved by mathematical techniques indicated
by block III without any consideration as to the original meaning of the num-
bers, symbols, and relations involved. In this sense, applied mathematics is
abstract. Much of your work will be concerned with the achieving of the solu-
tion required in block III after the problem has been properly stated mathe-
matically. Experience through much practice is the only reasonable way of
acquiring the facility in thought and deed necessary to achieve proper and
accurate results.
Any number is constructed from a (usually) small set of basic numbers called
digits. As you recall, the digits of the decimal number system are the 10 inte-
gers 0,1, 2,3, 4,5, 6, 7,8, and 9. It is from the number of digits that the sys-
_ tem takes its name. If we include the three symbols + (the plus sign), — (the
_ minus sign), and . (the decimal point), we can construct every number of the
decimal number system. Any number of the system is simply a sequence of
these digits and symbols formed by placing them horizontally and in close
proximity, that is, next to each other. Of course, a few rules must be followed.
The minus sign, as you already know, need not occur at all and if it does, it
must appear as the first symbol of the number and can occur only once in each
number. The decimal point need not appear either but if it does, it can occur
only once and can be in any position in the sequence. Thus, we can have the
numbers —43.7000, 0.1324, 8475663, and —3.002.
Numbers whose first symbol is the minus sign are called negative num-
bers; for example, —3.56 and —4567723 are negative numbers. Those num-
bers that do not start with the minus sign are called positive numbers; for ex-
ample, 0.0098 and 2345.7 are positive numbers. Sometimes the positiveness of
| PEM
a 16) ee)
8| 6 4 4
has value 8 X 10? +6 Xx 107+ 4 x 10'+ 4 x 10° = 8000 + 600 + 40 +4, which
we read “eight thousand six hundred forty-four.’’ This is the value of the
number that we write, using only the digits underlined, as 8644.
The method just used gives the value of numbers which either are inte-
gers or have a decimal point immediately after their last digit. Let us now see
how we find the value of numbers that have zero integral part. Recall that
1 1 i
—_ = 0:17.10 a100
10 1 =— 10 1000 = 0.001, and so forth, so that
0.01, 10 —3 — ———_
a nonzero number with zero integral part can have its digits placed in the
following diagram:
et >
Now, the positional value of a digit in position —1 (called the tenths position)
is 10-'= 0.1; the positional value of a digit in position —2 (called the hun-
dredths position) is 10-?=0.01; similarly, a digit in position —3 (called the
thousandths position) has positional value 10 *= 0.001; we can continue in the
same way until we reach the last digit of the number and its positional value
is assigned. Thus,
EXERCISES
1.1 Represent each of the following rational numbers in the form of
infinitely repeating decimals. Use the abbreviated notation de-
scribed in the text. Example: 2./3. = 0.(6).
(a) 16./11.
(b) 53./15.
(c) 4./7.
(d) —17./23.
(e) 35./4.
(f) 11./9.
1.2 The repeating decimal 1.(63) can be represented as the ratio of two
integers by following this procedure: Let p = 1.63636363 . . . ; then
100p = 163.63636363 . . . . By subtraction, 99p =162. Therefore,
p = 162/99 = 18/11. Use this procedure to represent the following
repeating decimals as the ratio of two integers:
(a) 0.(23)
(b) 1.6(4)
(c) —0.0(325)
(d) 0.0000(87)
1.3 The notation [x] is often used to denote the greatest integer con-
tained in the real number x. Thus, [4.32] =4, [0.37] =0, and
[72.999] =72. Show that if x is not negative, [x] is the integral
part of x. What is [—13.72]? [—0.0678]?
1.4 Use the power-of-10 method to write the value of the following
numbers. Example: 87.3 = 8 X 10'+7 x 10°+3 x 1071.
(a) 67995
(b) 0.009506
(c) 4.586
(a) 736.947
(e) 50.009
(f) 12.12125
eGR ES Pe +) 0| 2
and
The number in the first block in each case is called the mantissa of the number;
the second number (with its sign) is called the characteristic of the number.
This mantissa and characteristic method (and standard form) enables
one to write very large or very small numbers without using all the zeros that
might be necessary in ordinary decimal form. For instance, 765540000000000.
can be written as 0.76554 x 10’ and 0.0000000000000013401 can be written as
0.13401 x 107".
We shall later see that in the computer language called Fortran a special
code is used to indicate a number written in the form of mantissa and charac-
teristic. There we shall write 0.86732 X 10* as .86732E+04 and 0.1025 x 10-8 as
.1025E — 08. Clearly, the combination of symbols E+04 is replacing the multi-
plier x 10*, and E — 08 is replacing X 10°.
Up to now we have been writing numbers of all sorts and sizes without
any information about their source—that is, without knowing or caring about
what is sometimes called the accuracy of the number. When we write 17.38,
there is absolutely no way of telling how “accurate’’ the number is by merely
looking at it. However, if we knew that this number resulted from a rounding
off of another number previously known exactly, then we would have some
1. If the roundoff digit is 4 or less, simply omit the roundoff digit and
the remaining sequence of digits:
and
but
Note again that most digital computers do not use built-in symmetric
rounding but instead automatically round off by the simple process of trun-
cating, that is, cutting off the sequence of digits. It is possible, of course, for
a program to be written and stored in the computer which will allow one the
option of symmetric rounding.
EXERCISES
1.6 Express each of the following numbers in standard form:
(a) 4862.47
(b) —0.007053
(c) 337.0 x 10°
(d) 42832. x 10-7
(e) 93470000000000000000.
(f) 0.000000000045688
(g) —4785.003
1.7 Find the mantissa and the characteristic of each of the following
numbers:
(a) 869.37
(b) 4283000.
(c) 625 x 10"
(d) 6
(e) 497 x 10°
(£) 0.00098907
1.8 Express each of the numbers of Exercise 1.6 using the Fortran E
notation.
(a) 17.320
(b) 0.008326
(c) —13.227
(d) 98300.7
(e) 93902
(£) 1.00467
(g) 100.001
(h) 1.1111
(i) 78
(ayn 2258(4)
(b) 887.12 (1)
(c) 0.003295 (2)
(d) 637.5 (3)
(e) 985435 (5), (4), (3), (2)
(f) 14.5678 (2), (3)
(g) 789.07 (4), (2)
1.11 Express each of the numbers of Exercise 1.10 to the given number
of significant figures using truncation.
1.4 OPERATIONS
We shall assume that you are perfectly capable of doing the arithmetic involved
when you perform the operations of addition, subtraction, multiplication, and
division of real numbers. Some confusion seems to exist, however, about
the accuracy of the result when numbers are combined using these operations.
Suppose someone asked you to add 8.37, 4.2, and 863. You undoubt-
edly would place the numbers in a column with the decimals lined up and
add as usual:
S37,
4.2
863.
S705,
ei). Ebr
is the way a register looks when it contains the number 0.123 x 10°.
Suppose that the multiplicand and multiplier registers contain, re-
spectively,
(representing 0.123 x 10°? and 0.469 x 10°). Now let us suppose that the
computer takes these two numbers to some internal calculating area where
there is plenty of room to perform the multiplication carrying all figures,
rounds off the product to three significant figures (by cutting off the proper
terminal digits), and returns to the product register the result in standard
form. Then the following occurs internally:
0.123 x 10-2
0.469 x 10°
1107
738
492
0.057687 X 102 = 57.687 = 0.57687 X 10°
in
Notice that the first product is found by multiplying as usual the numbers
of the two registers and supplying the decimal point in the re-
the first parts
sult as usual in arithmetic. The numbers that appear in the second part of
5|7| 6 |+] 0] 2
86.3 x 10°
1.25 x 10°
87.55 X 10°
Note that now the characteristics are treated in a different manner. First,
the characteristics must be the same before the numbers are added. In the
example just above, we have made the characteristics both zero by writing
0.863 X 10? as 86.3 X 10° and 0.125 X 10! as 1.25 xX 10°. We then add the new
mantissas and multiply the result by this common power of 10. We could just
as well have written 0.863 < 10” as 0.0863 < 10% and 0.125 X 10! as 0.00125 x 103,
and then have added in this way:
0.0863 x 10°
0.00125 x 10°
0.08755 X 10° = 87.55 (as before)
Example. Compute (8.2 X 17.9 + 2.87) X 3.7. Presume the numbers are exact
and round off the result to three significant figures.
Method 1: Exact calculation carrying all figures throughout.
Result: 553.
Method 2: Use the computer method with roundoff (truncation) as re-
quired at the end of each operation.
= “|1|4|e +] 0] 3|
= i[4[s elpede ae
1/4] 8 a o| 3 | x 3| 7 0 |+] 0 1|
os Se Ne sire )+[0 3
EXERCISES
1.12 Assume that each of the numbers given below is exact. Perform
the indicated operations by hand carrying all figures. Round the
final result to three significant figures using truncation (cutting off).
Oheeeces— =
1 89.0
13.
467
wey
1.13 Assume that a computer has a four-digit register for the storage
1.15 For each of the parts of Exercise 1.13, compute exactly each oper-
ation using all figures throughout. Then find the error in each
answer of Exercises 1.13 and 1.14.
In the next chapter we shall introduce real-number systems with bases other
than 10. The four arithmetic operations in these systems will prove new,
fascinating, and, interestingly enough, very practical. Several of these sys-
tems, namely the binary, octal, and hexadecimal, are particularly important
in computer applications.
: ~
;
4
™ F
-
i]
f
> =
S
“
7
™
by
>
“Ne
Nondecimal Number Systems
Any positive integer greater than 1 can be used as the base of a number system.
The digits of a number system using a base b which is 10 or less are 0, 1, 2,
3, ...,b-—1. For example, the digits of number base 8 are 0,1, 2,3, 4,5, 6,
and 7. We shall see in a moment how we handle the situation of the digits
of a number system with base more than 10. In any case, the numbers of the
system are then constructed in exactly the same way we used for the decimal
system except, of course, that the digits used are restricted to those belonging
to the system. Thus, 630.72 is a very respectable number in the base 8 num-
ber system. As before, 630 is the integral part of the number and .72 is its
fractional part. And, even though the system is no longer decimal, the “deci-
mal point” which, in a sense, joins the two parts of the number is used.
Systems with certain bases, because of their importance in computer
applications, have been given specific names (like decimal for base 10). Some
of these are the binary system (base 2), the ternary system (base 3), the octal
system (base 8), and the hexadecimal system (base 16). Systems with bases
other than these must be referred to by giving the base itself.
One notices immediately that if the number 630.72 is standing alone,
out of any context which indicates the base being used, it would only be natural
to assume that the number is decimal. So some way must be found to desig-
nate the base if it is necessary for clarity. The method we shall use here is
to follow the number by a subscript indicating the base; thus we would write
630.72.) to indicate that the number is in the octal system. Generally, if no
subscript follows a number, we shall presume that the number is decimal.
The binary system, base 2, is of such paramount importance that much
attention will be paid to it in the following discussions in this chapter and in
later chapters when specific applications are explained. It has the neat prop-
erty of requiring only two digits, 0 and 1. So, 110111011.1101 could be a
number in the binary system.
Suppose, however, that one wants to use a base greater than 10, say 12.
Then the digits we shall use will be 0, 1, 2, 3, 4, 5,6,7,8,9, A,and B. Notice
that since 12 digits will be required and there are only 10 decimal digits, we
have used the single symbol A to stand for the decimal number 10 and B to
stand for the decimal 11. A39B1.8A is a number in this system. We shall
not use numbers of base greater than 16, but, in general, the digits for a num-
ber of base greater than 10 could be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F,
G,.... In the hexadecimal system, base 16, the first 16 of these are used,
so that A, B, C, D, E, and F stand for the decimal numbers 10, 11, 12, 13, 14,
and 15, respectively, but are digits in the hexadecimal number system. Thus,
39F7E.4BA is a hexadecimal number.
Number oy B®
Positional
value a
We notice, of course, the direct analogy with the positional values we discussed
in Chap. 1 for decimal numbers. Here, however, the positional values are
powers of 7 and not of 10. Now we come to the rule for calculating the
deci-
mal value of the number: The decimal value of a number is found
by multi-
plying each of its digits by its respective positional value and adding
these
products. Here the multiplication and addition required are
done using the
ordinary decimal arithmetic. Thus, to find the decimal value of 3205,,), we have
Example. The decimal value of 3E5Bi,,) is found by multiplying each of its digits
by its respective positional value and adding these products. Thus,
3E5Bas)= 3 X 16° + E X 167 +5 X 161+ BX 16°
= 3(4096) + 14(256) + 5(16) + 11(1)
= ihets) = Sisters = te) ae ll
= 15963(40)
— 15963
Note that to find these products, we have replaced E by 14 and B by 11. Re-
call that the first 16 decimal whole numbers 0, 1, 2, 3, 4,5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15 are designated as 0, 1,2, 3,4,5,6,7,8,9, A, B, C, D, E, F in the hexa-
decimal system.
Example
An—14y—2On—-3 * * * Asdyd,dy
Here the superscripts represent the usual algebraic exponents, that is, powers
of the base b. ;
As you would expect, the decimal value of the fractional part of a num-
ber to a nondecimal base is determined by a process entirely analogous to the
decimal case. For instance, suppose we have 0.20314). We associate with
each digit the positional value as shown below:
Number 2 0 3 1
Positional
value A AR A ae
So, clearly,
0.2031q) = 2X 47+0x424+3x4341x4-4
2 Sel
1
=_—
3 0
eel
ad ——
Example
Sle 2200-0694)
= 11.319(4)
=11.3194444 ...
EXERCISES
(a) 43256)
(b) 11101111.)
(c) 2AF3q¢)
(d) 675,g)
(e) 120202)
(£) 1A31¢1)
(g) 1234.)
(h) 12346)
(i) 1001435)
2.2 Determine the decimal value of the following. Express each ex-
actly as a fraction, in the form of a decimal with repeating terminal
digits, and also as a decimal truncated to five significant figures.
(a) 0.25,7)
(b) 0.010101¢)
2.3 Determine the decimal value of the following. Express the frac-
tional part as a repeating decimal.
(a) 102.12()
(b) 32.023,4)
(c) 34.221 5)
(d) FE.FBus)
(e) 173.465.)
(f) 1101111.1101(.)
(g) 344.36)
(h) 50.2024)
(i) ABC.914q3)
So far we have learned how to find the decimal value of a number in a non-
decimal base. Now we present a method for changing decimal numbers into
numbers in other bases. We will show the method in two parts—one for an
integer decimal number and one for a purely fractional decimal number. Sup-
pose we have a decimal integer N and desire to transform it into base b. Here
is the general procedure. Let us divide N by b. Let g, be the quotient and
r, the remainder. Now divide q, by b and let q, be the quotient and r, the
remainder. Now divide q, by b and let qs be the quotient and r; the remainder.
(Note the natural use we are making of subscripted variables to describe the
procedure.) Now we continue in the same manner until the quotient is zero.
Suppose that at that step the remainder is r,. Then,
We note, of course, that the base b equivalent of the decimal integer N is com-
posed of the remainders generated but in exactly the reverse of the order in
which they were generated. The first remainder r; is the last digit of the
b N |4 deeds Weds oe PO
|Ty > Ts 14 Tk ae Tr
The arrow on the right side of the model is to emphasize that the remainders
are to be taken in reverse order.
5 |861 |172 34 | 6 1 |o |
+
Lea 2| 4 i
{
11 597 | 54
|
|
- 0
3 |
A) 4
|
EXERCISES
2.5 Use the method just presented to transform the following given
decimal integers to the bases called for:
2.6 The number 837%) can be transformed into base 5 by first finding
the decimal value of 837() using the method of Sec. 2.1 and then
transforming this decimal integer into base 5 using the method of
this section. Transform 837() into base 5.
2.7 Following the plan of Exercise 2.6, transform the numbers below
(with nondecimal bases) to the bases called for:
Let us now turn to fractional decimal numbers. Again, let the number
be n and the base be b. Multiply n by b. Let p, be the integral part of the
product and f; be its fractional part. Multiply f, by b. Let p. be the integral
part of the product and let fy be its fractional part. Continue in the same
manner as long as desired or until a repeating pattern emerges. Then
b n |f
o P2 | P3
8 37 4 | 0
S| 2
2.8 Express each of the following decimal numbers in the bases given.
In each case, if the result is not terminating, carry to at least six
figures or indicate the repeating pattern.
2.9 Express each of the following decimal numbers in the base given.
In each case truncate the fractional part to five significant figures.
Example. Transform the binary number 1100110.111 into base 4. We mark off
as prescribed: 1 (ge Digit 1 0. Leh 1 0. Therefore, the result is
1212.32(4). Note that the first pair is Q 1.
Now consider the related base 8. The digits of the octal system are 0,
1, 2,3,4,5,6,and 7. Each one of them can be expressed as a binary number
of three binary digits. These are, respectively, 000, 001, 010, 011, 100, 101,
110,and111. A binary number can easily be transformed into base 8 by mark-
ing off (starting from the decimal point and moving left and right) sets of three
binary digits. If each group is replaced by its decimal equivalent, the result
will be the octal representation of the original binary number.
It should be clear from the discussion above that any number in a base
related to 2 can very easily be expressed in base 2. One simply replaces each
of its digits by the corresponding binary equivalent. Thus,
A C 5 Eqs
=1010 1109 Q10J 1119 = 1010110001011110.)
AS OMe ae
EXERCISES
2.10 Use the method of this section to transform the following binary
numbers to base 4, to base 8, and to base 16:
(a) 11011011
(b) 11111110110111100
(c) 10100111101.1101
(d) 10101101001.10010011
2.11 Use the method of this section to transform the following numbers
to base 2:
(a) 32231204)
(b) FA8Cas)
(c) 0.77466;
(d) 1010337%)
(e) OO DEV Ge)
(f) 3003312.2.4)
2.14 Since 9 = 3”, base 9 is related to base 3. Use the method described
in Exercise 2.13 to transform 12102122;,) into base 9.
2.5.1 Addition
First, let us consider the basic operation of addition. The rule for addition
of number base b is: Add the numbers of the rightmost column as usual using
decimal addition. Transform this partial sum into its base b equivalent. The
rightmost digit of this partial sum (in base b) is called the sum digit. Put down
the sum digit in the sum as in ordinary addition and prepare for the carry oper-
ation. For example, if the partial sum is 67, then 7 is the sum digit and 6 is
the carry digit; it would be carried and added to the next column to be added.
However, if, for example, the sum is 112, then 2 is the sum digit, and the set
of digits 11 are to be carried. These are carried over the next two columns,
one in each column. After this, each column is added as described above.
CO
I W
ouN
OUONs fF
nooNY
NN
&N
Add the digits of the right column; the sum is 15 (decimal). This is 1%), and
so 7 is the sum digit and 1 is the carry digit. Place the 7 and carry 1 to the next
column. Add the digits of the next column. The sum is 16 (decimal). This
is 20). Place the sum digit 0 and carry 2. If you carry on in the same manner,
the next partial sum is 17 = 21.) and the last partial sum is 23 = 27). The
final sum is 27107,g).
Check:
13.214
202.434
123.433
400.021
1300.212
In this problem, note that 12 = 22(5), 11 = 215), 10 = 20(5),5 = 10), and 8 = 13s).
111011011
101111011
1101010110
2
1
11
11
2122
1022
10012
20122
10002
21021
12122
1002201
EXERCISE
2.5.2 Subtraction
4025
— 2346
Start from the right as usual. Since 6 is greater than 5, borrow 1 from 2 (leav-
ing 1), add 7 to5 and have12. Now subtract 6 from 12 = 6, the righthand digit
of the remainder. Proceed to the next column. Again 4 is greater than 1, so
borrow 1 from the 4, add 7 to the 0, borrow 1 from the 7 (leaving 6), and add
7 to 1=8. Now subtract 4 from 8=4. The rest of the subtraction proceeds
without further borrowing. The remainder is 1346). This example can be
expressed as follows:
Gos
ep VA Fe avi
Ise
eo 4 6
eh PEWS
in which the / indicates the borrowing maneuvers and the numbers above the
upper line are part of the work involved.
201210
= PRA?
134103
2012A9
— 22129
102011
Check:
Thus, 102011,;).
Let us now turn to the second method for subtracting, the b — 1 comple-
ment method. It turns out that some version of this method is precisely the
one used by digital computers to subtract, particularly binary numbers. If
the base is J, first subtract each digit of the subtrahend from b—1. Then add
this result to the minuend. If a carry digit (defined below) appears, add this
carry digit to the result; this process is often called an end-around carry. If no
carry digit appears, the answer (the difference) is negative and is found by
recomplementing the result. Examples will demonstrate the procedure.
6132
— 4158
9999
4158
5841
Each digit is simply subtracted from b—1=9. Now add this to 6132.
carry digit
(end-around 1
carry)
1974 result, which is easily checked
9247
aeLOOSS
09247
84316
0}93563
There is no carry digit, so that the result is the 9s complement, that is, —6436.
The result is negative.
3240
— 1434
The 4s complement of 1434 is clearly 3010, the result of subtracting each digit
in 1434 from 4. Adding this to 3240, we have:
3240
3010
1 {1300 addition is in base 5, of course
1
1301 result
639AF2
mee 295
639AF2
+ F6836A
1 5A1E5C
1
5AILE5D result
Example. Base 7:
02503
— 61445
02503
ar Wye
0)11024
il
eee LOOT
001100
and this is exactly the same as changing each 0 to 1 and each 1 to 0 in the
original number.
Example. Base 2:
1101100
— 0110111
Example. Base 2:
1101 001101
— 110011 + 001100
0)011001
EXERCISES
2.5.3 Multiplication
Now for the operation of multiplication. Perhaps a detailed, worked-out ex-
ample would be instructive. Consider this problem: Multiply, using base 6,
325 X 43.
325
x
43
1423
2152
23343
Analysis: First place the numbers under each other as in usual multiplication
in decimal system. Multiply 3 by 5 as decimals. The result is 15 which we
place in base6as23. Putdownthe3and carry the2. Now2X3=6,6+2=8
(decimal). Place 8 in base 6 as 12(,. Put down the 2 and carry the 1. Now
3X3=9, 9+1=10, and 10(9)= 144). As shown, the first intermediate
product is 1423. Shift one to the left as is usual in this type of multiplication.
Multiply 4 by 5. Result is 20 = 32(,. Put down the 2 and carry the 3 as ex-
pected. Now4x2=8,8+3=11, and 11=15¢). Put down 5 and carry 1.
Then 4 X 3=12,12+1=13= 21). This completes the second intermediate
product as 2152). Now add base 6. The result, the product, is 23343,).
We check this result. First, we leave it to you to show that 325(6) = 125,19)
and that 43(g) = 2740). Then we multiply these two base 10 equivalents for a
product of 3375. Now
|6 |3375 562 93 | 15 | 2
3 amlteasit 3 2 a
21022
Zi?
202M
21022
21022
112121
200101011
Check the details of this multiplication; recall that 3 = 10(3), 4 = 11(3), 5 = 12(g),
6=20q), and 7= 21). Verify the result by showing that 21022(3)= 197(0),
2112 = 6849), the decimal product is 13396, and 13396) = 200101011().
3A7
x B9
20DF
28 2D
2A3AF
Again, you should check the multiplication itself, and if you care to, verify
the result by following the steps as outlined above.
11011
x 11101
11011
11011
11011
11011
1100001111
The partial products in this example are, of course, very easy to calculate.
Some intricacies occur during the addition of these partial products using
binary addition. When the (decimal) sum of a column is 4, the binary equiv-
EXERCISE
2.5.4 Division
32) 123221
2
32) 123221
11442
Carry down the next digit as usual. Clearly 32 goes into 42 once. We now
have
21
32) 123221
114
42
32
102
Clearly, 32 goes into 102 only once, so we now have
211
32) 123221
114
hy,
32
102
32
201
113
32) 123221
114
42
32
102
This example is, of course, the result of lots of trial and error in the trial
divisors. We have chosen to stop the division as shown and indicate the re-
mainder. One could have supplied a decimal point and continued by insert-
ing zeros in the dividend. We check the result of this division problem.
1F8
X 3A8
FCO
13B0
5E8
3220
se° AUS remainder
734AC check
Example. Divide 8041 by 17 (base 10) using the method of repeated subtraction.
First we set up a four-digit register in which to store the quotient. In
addition to the ordinary process of subtraction, we shall require that the com-
puter (or you if you are doing the division by hand) be able to count how many
times the divisor 17 is subtracted during the process. This means that each
position in the four-digit register we have set up is actually a counter. Here
is how we proceed. To determine the first digit in the quotient, take the first
digit of the dividend and subtract 17 (the divisor):
8
mls
=f)
Since the remainder —9 is negative, do not advance the first counter by 1 but
80
VE
63
Since the difference is positive, advance the counter 2 by 1. The register now
looks like this:|0|1]0]|0|. Proceed (using the second counter):
46 (advance counter 2 by 1)
2) (advance counter 2 by 1)
eal?
12 (advance counter 2 by 1)
=.)
Since this last remainder is negative, do not advance the counter. The register
now looks like this: |0] 4 | 0[ 0].
Now move back to the previous remainder 12, bring down the next digit
of the dividend, and advance to the third counter. Proceed as before:
124
en VS
~ 107 (advance counter 3 by 1)
me LA
~ 90 (advance counter 3 by 1)
ahd.
Ve (advance counter 3 by 1)
made
56 (advance counter 3 by 1)
ail
39 (advance counter 3 by 1)
eee
22 (advance counter 3 by 1)
ae
5 (advance counter 3 by 1)
eer
== 12. (do not advance counter 3)
0321) 123103
OUD
(end-around ( 1} 0303
carry) 1
0310 (advance counter 4 by 1)
+3012
3322
Recall that since the last addition results in no carry digit, this means that the
last difference is actually —0011. We do not advance counter 4 but instead
recover the previous difference 310, bring down the next digit of the dividend,
proceed to counter 5, and restart the process on the number 3100. The re-
mainder of the process goes like this:
3100
TOOL
1)2112
(advance counter 5 by 1)
32 (advance counter 6 by 1)
12
Considering all the work involved in the two previous examples, you
can see why one does not employ this method when computing by hand.
But an electronic computer can perform at a dizzying pace. It performs all
arithmetic operations using only one basic operation—addition. Wehaveseen
that we can subtract by adding, for example, the b—1 complement. Clearly,
multiplication can be achieved by repeated addition. And now we see how
division can be done using only the arithmetic operation of addition. The
computer does not mind doing all the required additions, the setting up and
advancing of counters in registers, the shifting left or right as required by the
operations of multiplication and division. Circuits have been devised to
do all these things and myriads of other required tasks. As far as arithmetic
operations are concerned, it is much simpler to make the computer able to do
only one operation but at a fantastically rapid pace. The circuits required to
perform addition are very simple to design. To have separate circuits de-
signed for each operation would terrifically complicate the computer.
EXERCISES
2.19 Divide using the direct method. Carry to at least one fractional
digit if the division is not even. State the remainder in each case.
You note, of course, that this particular coding does not associate any decimal
digit with its corresponding binary equivalent. Any decimal number can
now be coded using this code by following this rule: Replace each digit of the
decimal number by the corresponding four-digit binary number according to
the code.
The 12-digit coded result 101000100001 is, naturally, not the ordinary binary
equivalent of the decimal number 862. [862(19)= 1101011110]. Thus, as
you can see, once the code has been selected, it is very easy to code any deci-
mal number.
The problem of consequence arises once the computer has coded a set
of decimal numbers and then must perform the operation of addition upon
them, retranslate the sum to ordinary decimal, and output the result. To see
this difficulty more clearly, suppose we code the decimal numbers 2 and 4
using code 1 and add these numbers using binary addition. We have
2 0001
4 1101
1110
The result is 1110. According to our code this corresponds to decimal 9. But
clearly 9 is not the sum of 2 and 4. Ina rather arbitrary coding like this one
we have just chosen, there is no simple way to figure out just how we would
ever make the result 0010, which is the code for decimal 6, the proper result.
A commonly used code which we shall call code 2 associates each deci-
mal digit with its four-digit binary equivalent. That is,
0 0000 OO
1 0001 6 0110
2 0010 7 O111
Cm OOM 8 1000
4 0100 9 1001
0110
0101
lon
a 1011
The correct result is decimal 11, a number of two digits, while the binary addi-
tion of the coded decimals is of four digits, cannot represent a two-digit num-
ber, and besides is not one of the allowable four-digit numbers of code2. But
notice this. Suppose that to this result (1011) we add 0110, which is 6 in code2.
Thus,
6 0110
5 0101
1011
+ 0110 (binary equivalent of decimal 6)
00010001
Lovee
We have inserted three zeros to the left of the first 1 to complete the four-digit
requirement of the code. Then, as if by magic, after translating back to deci-
mal digits using the code, we have decimal 11, the correct result. This can
be expressed in the following rule: If the sum of the coded digits is more than
the binary equivalent of 9, add 0110 to the sum, then decode as shown above.
Let us now try adding two decimal numbers of several digits.
Example. Add
We have shown the code 2 coding of the given decimal numbers slightly spread
apart for clarity. The procedure is to now add (using binary addition) but to
be careful to note whenever the sum of a set of two numbers is greater than
the binary equivalent of 9. Otherwise, we add as usual carrying carry digits
as we ordinarily do. This is what occurs:
Example
1 2 5 6 8
We shall not proceed any deeper into the further intricacies of the properties
of binary coding of decimal numbers. Perhaps you can figure out, for this
particular coding, why the addition of 0110 to the proper sums makes the
process work.
EXERCISES
2.22 Construct a binary code different from the two used in this section
and use it to code the following decimal numbers:
(a) 8142
(b) 93047
(c) 63415
(d) 3999
2.23 Use code 2 of this section to code the following decimal numbers,
then add them using the rules given. Follow the presentation
plan
used in the text, that is,
(b) 75
23
(c) 75
48
(d) 325
299
(e) 1473
9243
(f) 2837
48796
(g) 8007
3998
(h) 437
245 +
938
| _ -
e
y 7
y - ie
: aes
AA
«
as
-
=
~
: . ;
ry
7°
x a
Sa
~~
x
/5 -
.
‘ i
¥
e =
>
‘¢
a
:* A
od
airy
a
e a)
a|
Maar
' 5o¢ 1
ve
Ut
Algebra: Linear Functions
53
write the constant first. Thus, it is 4y and not y4. This is an example of
algebraic etiquette. As you recall, if a variable or constant is multiplied by
itself, we use the symbol representing power or exponentiation. Thus, we
write, if we want to, a X a as a?,a X aX aasa*,andso forth. As we shall see
in the next chapter, the symbolic programming language called Fortran uses
the asterisk * as the symbol for the operation of multiplication. There we
shall write A * B instead of a X b (or ab). Note also the use of nonitalic capital
letters in this example. For the operation of division the symbols / or
are the most common. The symbol + used sometimes in arithmetic is rarely
used. Some examples of expressions using division symbols are a/b (a di-
vided by b), 2 and 4.5/3.7. The slash symbol / is the one most used in com-
1. Exponentiation
2. Multiplication and division
3. Addition and subtraction
Let us now consider some expressions that do not contain parentheses and
determine the order of performance of the operations they contain.
The symbol = (read ‘is equal to”) is used to equate two expressions.
The resulting algebraic statement is called an equation. Thus, the equation
x+y =7 is read ’’x plus y equals 7” or “the sum of x and y is 7.” Note the
difference between an expression and an equation. An algebraic expression
is a mathematical phrase; an algebraic equation is a mathematical sentence.
An equation is said to be satisfied for a certain set of values of the vari-
ables it contains if the two expressions equated become identical when the
values of the variables are substituted into them. For example, the equation
x+y =7 is satisfied ifx=5 and y=2. Itis not satisfied for x = 3 and y = 8.
Evidently many sets of values for x and y satisfy the equationx+y=7. As
you recall, many equations are satisfied by a unique value of the variable con-
tained. Thus, x +3=8 is satisfied only when x=5. In such an equation,
finding the unique value that satisfies it is called solving the equation.
EXERCISES
3.1 Evaluate each of the following expressions for the values of the
variables given:
(a) ae 7,8 = 3, X= 7
(b) a/b + cd,a=3,b=2,c=4,d=1.25
3
(h) & + xy, a=10,x=—6, y= 30
(a) 3x +7=7
(b) 2—x=8
(C2
Oe =D ae
bea. 28
a Ste PIR
3.4 (a) Find at least five sets of values for x and y each of which satis-
fies the equation x + 3y = 8.
(b) Solve the equation x = 16.
(c) Show that x=2 does not satisfy the equation x° + 7x? — 8x
— 67=0.
(d) If x=0, y =7, evaluate the expression xy, the expression x + y,
the expression y/x, the expression 3x° + 7xy + 8y’.
3.5 Solve the following linear equations for x if all the constants and
the variable x are in the given base. All operations required to
solve for x are thus to be performed in that base.
The last example contains what are called nested parentheses, one set of paren-
theses within another set. In such an expression, we follow this rule: To evalu-
ate an expression containing parentheses, proceed to the innermost parentheses
and evaluate the expression they contain according to the usual hierarchy rules.
Then move to the next outer pair of parentheses, evaluate, and so on. Con-
sider the expression (a+ d(b+c))/e. Since the innermost parentheses en-
close b + c, we calculate this sum first. We then proceed to the outer pair,
multiply b + c by d, and add the result to a. Finally we divide by e. For ex-
ample, ifa=3,b=6,c=8,d=4,ande=2,b+c=14,d(b+c) =4(14) =56,
at+d(b+c)=3+56=59, and (a+d(b+c))/e=*%2=29.5. In algebra
other symbols of grouping such as brackets[ ]andbraces{_ } are sometimes
used. In most computing applications the parentheses are the only symbols
of grouping that are permitted, no matter how nested they have to become.
In addition to possibly redirecting the order of operations, parentheses can
be used to provide clarity even when they are not actually required. It is per-
fectly permissible to write (ab) + (c/d) even though ab + c/d means exactly
the same thing. However, some expressions cannot be written without using
parentheses. For example, to divide r by the quantity a + b, we must write
r/(a + b); we cannot write r/a + b.
EXERCISE
3.6 If a=2, b=3, c=8, and d=2, evaluate each of the following
expressions:
(a) a+ bic
(b) (a+ b)/c
(jias- bile+rd
(d) (a+ b)/(c+4)
(e) a+ (b+c)d
(f)a — bj(e+a)
(g) (a—b)/c+d
(h) (a— b)/(c
+ a)
(i) (3a — 4b)/(bc)
(j) (3a — 4b)/be
(k) 12a/bc
(1) 12/1/b
3.2 FUNCTIONS
3x + 7y=8+w (3.1)
contains the variables x, y, and w. Suppose we solve for y. This means that
we want to, without in any way altering the mathematical content or meaning
of the equation, write the equation in the form y= .... Clearly, 7y=8
+ w— 3x, and y= (8+ w-—3x)/7. (Note the use of parentheses; the result
is not y=8+w-—3x/7.) The value that y will have is determined uniquely
if specific values are given to w and x. We say that the variable y is a single-
valued function of the variables x and w. Since the value of y is dependent
upon the values assigned to x and w, the variable y is called the dependent
variable. The two variables x and w are independent variables since, presum-
ably, any values may be assigned to them.
A short glance back to Eq. (3.1) is sufficient to make one realize that
any of the three variables it contains can be regarded as a function of the other
two. We can solve for w explicitly. Thus, w=3x+7y—8. Here w is the
dependent variable and x and y are independent. Again, w is a single-valued
function of x and y since it is clear that there is one and only one value of w
for each selection of the pair of values for x and y.
It is conventional to represent functions by a certain notation called,
appropriately enough, functional notation. We write, for example, y = f(x)
(read ‘’y is f of x” or “y is a function of x, the function is named f”) to express
the fact that the value of the dependent variable y depends on the independent
variable x. Note the use of parentheses to enclose the x, often called the argu-
ment of the function. The equation y = f(x) does not give explicitly the pro-
cedure one is to follow to determine y if a value of x is prescribed. When one
actually substitutes a specific value of x into the expression f(x), one denotes
this by replacing the x within the parentheses by the specific value of x. For
example, if x =a, we write f(a); if x =—2, we write f(—2). Suppose f(x) =
x*—7x+3. Then f(3) =3?—7(3) +3=9—21 +3 ==9; and f(—b) = 0)"
—7(—b) +3=b?+7b+3. Similarly, f(2/x) = (2/x)? —7(2/x) +3 =4/x? — 14/x
Example.
ee ArUe eel lie 5)
Let h(a,b,@) eelnengy
2a0 ENS (est p)i—
ren SSS
or
EXERCISES
Fi 2
3.11 If g(p) =e find ¢(5); g (7) g(s—5); ¢(4); Te
Fig. 3.1
—+—_}—_+—_}—_ ieee
3 5
line. Plot a few more points and see if you can verify this. You recall, though,
that a straight line is determined if two distinct points which lie on it are pre-
scribed. It would appear, then, that the line itself could easily be drawn by
simply plotting very carefully two points on it and then extending the line
segment joining these two points indefinitely in both directions. The points
(1,10) and (—2,1) satisfy the equation and thus lie on the line. The graph is
shown in Fig. 3.3. If you employ this two-point method for graphing straight
lines, it would be best if the two points chosen are not too close to each other.
In general, the graph of the linear equation y = ax + b is a straight line.
a and DB are constants.
Some lines have peculiar equations. Consider the line with equation
y=2. Clearly, whatever x one chooses, the corresponding y is 2. Two points
on the line are, for example, (3,2) and (—7,2). Evidently, y = 2 is the equation
Fig. 3.3
ew t4++++
Yo Wi
Ui emma) (3.2)
Xy
— X4
or, equivalently,
Vip Un
Wa ce od(ie x5) (3.3)
1
Note that x and y are the variables here and that x,, x2, y;, and y»2 are constants.
The resulting equation is linear and hence represents a straight line. Using
the first version, we now verify that both (x,,y,) and (x2,y2) lie on the line.
Veo Yoel
=U Ue
Fig. 3.4
Y — Yi = m(x— x) (3.4)
This version of the equation of a straight line is called the point-slope form
since it allows one to find the equation of the line if its slope m and a point
(x,,y,) on the line are given.
Example. Find the equation of the straight line which passes through the points
(4,2) and (—3,5).
Ome.
y—-2= (ets)
pe sea A
y-2=— (x4)
7y — 14=—3x
+ 12
Example. Find the equation of the straight line whose slope is —4 and which
passes through the point (3,6).
We note that if m is positive, the line rises as it moves to the right; if m is nega-
tive, the line falls as it moves to the right; and if m = 0, the line is parallel to
the x axis. The slope of a vertical line is not defined.
Example. Find the equation of the line whose slope is 3 and whose y intercept
iSO!
Solution: Using the slope-intercept form with m=3 and b=—5, we have
y = 3x—5.
EXERCISES
3.14 Find the equation of the line which passes through the points
(a) (3,4) and (—2,5)
(b) (—4,0) and (5,6)
(c) (4,1) and (—3,1)
(d) (0,0) and (—6,2)
(e) (5,6) and (5,0)
(f) (11,0) and (0,4)
(a) y=3x+4
(Diva4
(c) x+y=3
(d) 3x—2y=5
(e) x=5
(t) y= 4x
(g) y=—3x+4
(h) y=x
(a) y=x
(b) 3x +5y =7
SIV Find the equation of the line with the following properties:
3.18 The line y= mx +7 passes through the point (6,7). What is its
slope?
a219 Two variables F and C are related linearly, that is, F+ bC=d,
where b and d are constants. If F=32 when C=O, and F= 212
when C = 100, find b and d.
3.20 The linear equation of Exercise 3.19 represents the relation between
Fahrenheit and Celsius temperatures. (a) Use the result of this
exercise to find the Celsius temperature C corresponding to the
Fahrenheit temperature F= 450°. (b) Use the result of Exercise
3.19 to find the temperature at which F=C.
We suppose you have already learned how to solve two simultaneous linear
equations like
x+2y=5 (3.5)
i aed
So, recall that a suitable method is called the method of elimination. First, we
eliminate the variable x by multiplying the first equation of (3.5) by —2, then
—2x — 4y =—10
26a er
= oY =>3
3
I>5
Then, using the first equation of (3.5), x=5—2y. Substituting y = %/s5, we
have x =5— %s=1%s. One easily verifies that substituting x= 1%5, y = 9/5
into (3.5) satisfies both equations; i.e., they form a solution set.
From our discussion in Sec. 3.3 we note that each of the equations of
(3.5) can be represented geometrically as a straight line. To solve the equa-
tions algebraically corresponds geometrically to finding the coordinates of the
point at which the two lines intersect. Figure 3.5 shows these lines and their
point of intersection.
There are occasions, of course, when the two lines do not intersect. If
the lines are distinct and parallel to each other, they will have no point of
intersection. Consider
eee
2x + 8y = 17
If we follow the usual procedure and try to eliminate x from the two equations
by multiplying the first equation through by —2 and adding, we have
Fig. 3.5
Both variables are eliminated, and the false result 0=3 ensues. As you can
check, the two lines represented by the equations are parallel.
It is possible that the two linear equations actually represent the same
line. Consider
al Sy =7
4x —10y
= 14
Xr eYrisz5 (3.6a)
x + 2y a (3.6b)
2x = BU! (3.6c)
LY js — oO
6x ee 4 (3.6d)
TE¥ Sh
Now combining (3.64) with (3.6b) which already contains only x and y,
we have
—14x — 2y = —34
gar AY = i
—=13x = —33
33
7G
Using (3.6b), which is x + 2y = 1, we have 2y =1—x=1— 99/13 = (13 — 33) /13 =
—%3; therefore, y=—1%s. Now using (3.6c), which is 2x —z=4, gives
Z=2x—4=2(3)/13) —4 = 6/13 — 52/33 — 1443: therefore, z=141s. Thus, the
solution set is x = 99/13, y= —1%13, z= 14/13.
EXERCISES
2 Eee
y=7
2x + Sy = 12
a {x—7y=-—2
() {a+b=3
2a + b=13
| 3x + 4y = 16
ie
6x + 8y = 32
eae
(e) [ey
ieee!
BaP AD ap Bye == DS
(a3) 4c — = 36
lies
ie ame
| Rep ek
0.03v + 0.05u = —0.04
3x + 4y + 5z=6
o| 2Y 32 — 4.
2z=7
Consider the coordinate system of Fig. 3.6. Note that two points labeled a
and b are marked on it. Clearly, b is greater than a because it is farther to the
right on the coordinate system than a is. We write this as b > a (read “b is
greater than a’’). At the same time, of course, a is less than b since it is farther
to the left than b is. We write this as a < b (read “a is less than b’’). Note
that a < b is just another version of b > a read (and written) from right to left.
The two statements b >a and a < b are examples of inequalities. Here are
some examples of inequalities that are evidently true:
It seems fairly evident that if a and b are any two real numbers, exactly
one of the following must hold: a < b,a > b, ora=b.
We now proceed to geometrically interpret some linear inequalities in
one variable.
Solution: Draw the one-dimensional coordinate system for the variable x and
mark on it all numbers that are greater than 2:
This is evidently the set of all numbers to the right of 2; that this set does
not include 2 itself is designated on Fig. 3.7 by the (, the opening parenthesis,
at 2.
Example. Show the set of all x such that x <3. We read this inequality ‘x is
less than or equal to 3.” The set includes 3 and is shown in Fig. 3.8. The
symbol | indicates that x = 3 is to be included in the set of values.
We read 2 < x <5 as “x is greater than 2 and (at the same time) less
than 5.” Figure 3.9 shows this set of values of x. This is called an open in-
terval—it contains all values of x between 2 and 5 but does not include the end
points 2 and 5 themselves. Figure 3.10 shows geometrically the set of values
of x satisfying —3 <x <2. This is another interval but it contains the left
end point —3; it is called half-closed. Another notation for the set of values
of x between 2 and 5 is (2,5), which is read ‘the open interval from 2 to 5.”
Context is used so that this notation is not confused with the same notation
used for coordinates of a point. If an interval contains its left end but not the
right end, it is written with a square bracket on the left, as in [3,7).
Finally, the notation [2,12] is used to represent the closed interval (all
x such that x is greater than or equal to 2 and is less than or equal to 12). If
an interval extends indefinitely to the right, we write (a,~), meaning all x
such that x is greater than a. We also write such expressions as (—~,5] for
—° <x <5, meaning all x which are less than or equal to 5. We never close
the interval at © since © is not a number but is used to indicate indefinite ex-
tension to the left or right. It is the infinity symbol.
The notion of absolute value is of some importance in many applied
problems. We write, for example, |a| and read “the absolute value of a.”
The absolute value of a is simply a itself if a is zero or positive, i.e., if a > 0.
Fig. 3.8
ae
Oe
Fig. 3.9
e+ C++ x
(Oy af sh GE Te
Fig. 3.10
i 16 6x1 ys
= eS Se 32— 115 e738
Thus, x = ¥3 or 15/3. Either of these values of x, and none other, satisfies the
equation |7 — 3x| = 6.
Inequalities can involve absolute value. Consider the inequality |x| < 3.
Clearly, x could equal 2, —1, —2.5, 1.7, etc. But a check reveals that x cannot
be greater than 3 or less than —3. Thus, |x| <3 is exactly the same set of
values of x as —3 < x < 3, that is, the open interval (—3,3). In general, if the
absolute value of an expression is less than a, then the expression itself must
be between —a and a. Example. |7 — 5x| < 8 is equivalent to—8 < 7 —5x < 8.
Consider the inequality |x —3| >5. Values of x like 12, —7, 347, etc.,
satisfy this inequality. A check reveals that for this inequality to hold, the
quantity x — 3 must be either greater than 5 or less than—5. This means that
x >8orx<-—2. This set of values of x is not an interval on the x axis, as
Fig. 3.12 reveals.
Fig. 3.12
—+ -+++ + +++€-—>
2, 0 8
ee:
=) S37
We leave it to you to show that the second inequality is equivalent tol <x <5.
Figure 3.14 shows the plot of these inequalities. Thus, thesolutionis1 <x <4.
EXERCISES
3.24 Using the method illustrated in Figs. 3.7 and 3.8, show geomet-
rically the set of all x such that
(a)
x 24
(D)i
2 aie = 4
(Cyt
(dyel
=a <7
(e) 3=x< 0
y
(i) 2 SZ el
5
3.25 Express each of the intervals of Exercise 3.24 using the notation
described after Fig. 3.10.
(a) |x +1/=5
(b) |4—5x| =7
(c) |2x-7|=0
3.27 Solve the following linear inequalities for the variable contained:
ORS ee
(b) 2—7x
< 12
sey
(es qr 5
(d)iG ope=10
(Ce ORS 0
aie
(PROFS 2 bt aL
3 2 Ox 7 9
(8) 3 -=
8 5
<-
(Dy eee
(i) -7 <1—Y%eaw <-3
3.28 Use the semigraphical method of the text to solve the following
simultaneous linear inequalities:
(a) eabenes
O<x+2<9
2
O<x+3
< 10
Ole |
5) Ss eee hee 115
= 8 SEG)
(d) |jx+7|>3
(e) |7—3x| >4
Fig. 3.15
ei
ab
DXi Vi a, iF
ae 2x+3y=7
~
ae
Example. Find and sketch the region determined by the inequalities x + y < 2,
x—y>—5, and 2x+4y>5. The three lines x+y=2, x—y=—5, and
2x + 4y =5 are shown in Fig. 3.17. We leave it to you to show that the half-
plane below the line x + y = 2, the half-plane above the line 2x + 4y = 5, and
the half-plane to the right of the line x — y=—5 are the proper half-planes
and that the shaded area shown in Fig. 3.17 is the region required.
Fig. 3.17
EXERCISES
3.30 Plot and shade the half-plane determined by each of the following
inequalities:
(Gl) ese) Ss
(b) 3x + 4y < 12
(Ceo
(d) y>3
(ce) 23 — oy 15
3.31 Plot and shade the region determined by each of the following
sets of inequalities:
|
Ly
SS 3%
(a) Shear
Guy 2 Als
36 SP
(b)
(ee 2c A?
714
Wear
Bil <I
(d) Sh aU ee
5x + 6y > 60
(e) Aga iit & io)
2% AO ea
(a) |4x + 3y > 12
Cia OU eto
—2¢- oy = 0
(b) Ax oy 012
645
— 3a lo
fr
(c) Se
Na eae
DG TA IanO,
(d) [stay >
3x + 4y < 12
y <4
Ye
“|De y = 12
— on eye 10
=sr 2 22
gar Se
(f) NY ee
Abe Sy) > il
Linear programming is a subject that we can pursue only through its elemen-
tary ideas and applications but which plays an extremely important role in
many decision problems of business and industry. It is often concerned with
optimum allocation of certain resources to meet certain commitments and
objectives but subject to definite restrictions. Interestingly enough, as you
could guess from the word linear in its name, it is concerned mathematically
entirely with such problems as the solution of simultaneous sets of equations
and inequalities; so, at least to start, it should not be beyond our understanding.
The main idea is that a linear expression (which could be representing
such a thing as profit) is to be maximized when the variables it contains are
not specifically given but are to be determined subject to restrictions in the
form of linear equations and/or linear inequalities that these variables must
satisfy. Another way to say this is that the given linear expression, often
called the object function, is to be optimized by choosing values for the vari-
ables that it contains but that these variables are themselves subject to severe
es
a
Kika
ape PAY) KN
NW (any
KV ==)
Male
hoa)
This will at least display the region in the xy plane we shall be restricted to.
Figure 3.18 shows this plot and the region R.
To find the region R, we have, of course, followed exactly the method
Fig. 3.18
5x + 11y =—22
EXERCISES
8x + 5y < 40
[s—ay = 6
4x—9y =< 36
3.34 Find the maximum value of z= 42x + 17y + 16 under the condi-
tions x <7, 6y —5x < 30. Recall that x > 0 and y 2 0.
x—4y <8
Loy= 6
x—4y =—8
Ss 12
Let us plot these points (1,2), (2,3), (3,5), (4,8), (6,9). Clearly the points
do not lie on a straight line. We do not know any function y = f(x) whose
graph contains all the points—at least any simple function. It might be pos-
sible, though, to find a straight line L which even if it cannot possibly pass
through all the points will pass “reasonably” close to the points. Such a line
can be sketched by “eyeballing” as we have done in Fig. 3.19. Notice that
this first approximation does not go through any of the points. We wonder
whether there might not be an analytic way to determine what might be called
the best-fitting line. There are many ways that people use to define what is
meant by best fitting. Perhaps the most often used notion is called the method
of least squares. It is used to fit data to many different kinds of curves, and
Fig. 3.19
|
|
@(x4, Yq)
a+ bx2
(x1, ¥1)
X2
Fig. 3.20
we shall be using it again in a later chapter. For now we present the method
as it applies to fitting data to a straight line. Let us generalize the process so
that it will be necessary to use general symbols for the data, the x’s and the
corresponding y’s. Thus, the data will be represented by (x;,,y;), that is, by
(X1,Y1), (X22), (%3,Y3), - . - + (Xn-Yn), 1 points in all. On the graph in Fig.
3.20 we have shown some of these points.
We have also shown a line, whose properties are yet to be stated, which
we want to be the best-fitting line. Now we want the line to pass relatively
near if not go through the points, and it is this closeness that we must make
precise. Suppose we let the equation of the line be y=a+bx. The points
on the line which lie directly above (or below) the given data points have co-
ordinates (x,, 0 + bx,), (%5,.4-4- bx2),. = . ; (X,,a + bx,),; since the y coordi-
nate of the point corresponding to x; is clearly a + bx; using the equation of
the line. We look at the vertical deviations of the data points from the cor-
responding point on the line. This deviation is simply the difference in the y
coordinates of the two points. Thus, the first point deviates a+ bx,— yj, the
second point deviates a + bx, — yz, and the third point deviates yz — (a + bxs),
etc. Now we come to the central notion of the method of least squares. We
shall impose the condition that the sum of the squares of each deviation shall
be minimum. The best-fitting line is that line for which this sum is minimum.
It is from the squaring and minimum ideas that the method of least squares
takes its name. Thus we want the sum S, expressed in the equation
Sea (a te ye)
ger
te) (a bx)
to be as small as possible. In this expression for S, all the x; and y; are known,
being the data, so we must choose a and b in sucha way as to minimize S. Once
Before we can proceed, the notations used in Eq. (3.7) require some
explanation. Consider
xX;
o.i] mn
The symbol % is the (capital) Greek letter sigma, and in mathematics it stands
for sum. The x; are of course the one-dimensional array of the given x values
of the points of the data, that is, x,, X2, X3, X4, . . . , Xp. The notation
means that we are to sum the x; as i (called the index) runs through integers
from 1 to n, inclusive. Thus,
xX;
oHIl mt
Ayr Ag ge pe tee
ay
i=1
Similarly,
yt yt ety.
Sun yt
and
Before we turn back to our problem of fitting a line to data, a few more
remarks and examples on this summation notation in general might be appro-
priate. Consider
5
ney 3)
1
This means that we are to evaluate the function f(j) = 2j +.3 for jrunning from
1 to 5 and sum these values. Thus
oO
Similarly,
10
ete is 451 Oty Oe toa 9 4510
1
= 55
the sum of the first 10 integers (greater than 0). Finally, take note of this
example:
8
Nth UE ills Uhm Vt
= 35
yy) 5 Df iH ile
{5a + 16b = 27
16a + 66b = 109
Multiplying the first equation through by 16 and the second through by —5,
we have
Adding, we arrive at —74b =—113, b=1*¥/74._ Then using the first equation
again, we have 5a = 27 — 16b = 27 — 16(12/74) = 27 — 113(¥/37) = 27 — 94/37 =
(999 — 904) /37 = %/s7. Thus, a = 1%/s7.
: eae 19% 413 :
The equation of the line is therefore y = 37° 74 x «We leave it to
you to check that none of the given points lies on this line. As a small check,
let us find the point on the line whose x coordinate is 4. Substituting x = 4
into the equation, we have y = 1%/s7 + 113(7/s7) = 24/37 = 6.62. Note that
the data call for y to be 8 when x = 4.
Some final remarks may be helpful here. If the given data are collinear
(that is, if they actually lie on a straight line), the method of least squares will
give that line as the best fitting. Note that a line can be fitted to any data, no
matter how many points it contains and no matter whether the points, when
plotted, even appear to be vaguely collinear. In the latter case, it seems evi-
dent that the choice of the straight line would be highly inappropriate. Some
other standard curve could undoubtedly be found which would fit the data
much better than a straight line. As mentioned before, in later chapters we
shall have more to say about the selection of other curves for fitting use and
how to determine them by the method of least squares.
Bion Show that the three points (0,7), (1,15), and (3,31) lie on the line
y=7-+ 8x. Now use the method of least squares to determine the
best-fitting line for the given data.
3.38 Use the method of least squares to fit a line to the following data:
Jae
ple |"
Maedice
Shee) Plot the data points given in the following table:
| |
3.40 Fit the following to a straight line using the method of least squares:
2 eee ee
spe ycirioa| | 9 |fs
Recall the sum of squares called S in the text. Use the equation
of the line you have just found to compute the value of S (that is,
the minimum value that the sum of the squares of the deviations
will have).
Use the method of least squares to fit these data to the linear equa-
tion V=a+bR. Recall that I was held constant. Suppose I is
known to be /2 amp. Compare and discuss your resulting linear
equation with Ohm’s law, V = IR.
Every digital computer combines basic components called the input, storage,
arithmetic-logic, and output units. They are arranged as shown in Fig. 4.1.
In this chapter we shall not be concerned with the actual design of the
components that make up the computer; we shall, however, in Chap. 8 present
some basic notions that are involved in the design of the arithmetic-logic unit.
A brief description of the functions of these components would now be appro-
priate. As you might suspect, the input unit is a device by means of which
the computer receives the set of instructions it is to subsequently follow and
the data, if any, on which the instructions are to act. This information can
be fed in via (IBM) cards, from a disk, from a typewriter keyboard, or from a
magnetic or paper tape. Once the instructions are stored in the memory unit
of the computer, the command is given to start executing the instructions. If
all is well and the input has been presented in proper form for the computer
to understand, the execution proceeds. The execution can call for the reading
in (again by means of an input unit) of data, that is, the numerical values of
variables, on which the arithmetic-logic unit is to operate. Following the
stored instructions precisely, the control unit passes data and results back
and forth between the storage unit and the arithmetic-logic unit where arith-
metic calculations are done until all the instructions have been executed. The
89
STORAGE
OUTPUT:
INPUT: CARD
CARD DISK
KEYBOARD CONTROL PRINTER
DISK TAPE
TAPE TYPEWRITER
[anrtanenc-toote |
Fig. 4.1
set of instructions should contain the commands necessary to cause the com-
puter to select an output device and to put out the desired results on that device.
As noted above, the computer is an extremely intricate electronic device
so engineered and constructed that it will receive, store, and execute your in-
structions. These instructions must be written and presented to the computer
in a manner that it can understand. The only language it can actually under-
stand is called machine language. In this language the instructions are a spe-
cially coded sequence of (usually) binary digits, and the computer has been
constructed to react to these coded instructions in a certain very specific way.
Sooner or later if you progress far and deep enough into the design and use
of computers, you will have to learn how to write programs in either machine
language or a slightly more sophisticated version called assembly language.
Both of these languages are relatively difficult and tedious to write. To solve
problems in applied mathematics and for business and engineering applica-
tions, there are many so-called symbolic languages that are currently in use by
programmers. Among these are Fortran, Cobol, APL, PL1, and myriads of
others. All these higher-level languages have the following basic property
in common: their use allows the programmer to write his instructions in easy-
to-use English and ordinary mathematical words and symbols. This, of
course, relieves the programmer from the extremely painstaking work involved
when writing in machine language. In order that such symbolic languages
can be understood by the computer, it is absolutely necessary that the state-
ments of the program be converted into machine language so that the com-
puter can do its job. So, for each of the languages mentioned above, a special
program in machine language has been written by experts which converts
the statements of the symbolic language into machine language. This program
is called a compiler. Suppose a Cobol program, that is, a program written
using the Cobol language, has been written and punched in the proper way
onto cards. Now, the computer itself can previously have had stored on its
disk or in its core memory the Cobol compiler we have just mentioned, whose
We shall not be able to discuss the details of programming in all these sym-
bolic languages, but we do want to introduce enough details of the basic
Fortran IV language so that you can write programs that can actually be run
on acomputer. In this presentation we cannot go into the important subject
of control cards, that set of special cards designed to give the computer such
information as the language in which the program is written, the number of
significant digits the computer should carry in its computations, whether a
printed copy of the program should be produced, and many other similar con-
trol situations. The format of control cards, which precede and/or follow the
program itself, is different for each computer even though the symbolic pro-
gram itself is written in exactly the same way for different computers. The
Fortran programs that we shall learn to write can be executed on any computer
that has available to it the proper Fortran compiler. The control cards re-
quired for the execution can be supplied by the computer center.
A Fortran program is a sequence of carefully written and ordered Fortran
statements. These statements are classed into five categories:
cea
TTLrT
HH ttt Hf I
|
de
ie
i
ab
pied
a
-=
Zz
(nS
jr|oe
uo |<
a)>
=
x\|d
hiss
oo |
SY
aa 7 LI fet flail Gott - 4
| | 1} }+} +i JN N
t
ee | nae LTT Taltal [=| Giclees,
‘eae
fx x
loi=|"[i|-[x|*[*[s]-|z/«
-| [xi*|“[a) [+] [z[*[x|x/*|“[e] [=| [a
wlalxlel Tht (+! Iai |
lelwlelxialziael=) xi (all
|_t +
| ae Pt +
PE os ;
Sik
om ee
(C55 eaa
|
it
1
+.
il
S|)
) st
a"
jtiolelyl
julojsl
wiViain]
jalwiatyl
TE
[aldie
Ee]
Sie
DlFi
=>
=>
yn
HES
7
wD
eas
=
=
aa
INAWALVLS
c~@
>|
tu
ive)
ce
cc
a
a.
ei
wm
NVaLdOs
=
JON3INOIS
>
D
=
IN3W31V1S
o}
¥38WNN
IdILN3GI
NOVO
—I
SNOILONYISNI CLO Yi ‘a4 sivo] dSIWWYe99d £o) J YN 44D WWE Oud
ONIKONNd
DIHdVYS GQHLIW S.NOLMIN WvsOud
Wal
uuog Burpo) NYYLYOI
econ GanTier ot
4. Specification statements are used to provide information about the
data that the program is to process. These statements are covered
in conjunction with input-output statements in Sec. 4.4.
5. Subprogram statements are used to define and provide linkage to
and from subprograms. We shall not discuss this type of statement
in this book.
OORT! CHOOTAVOOOOOONDONSOOOVOTOTOTOOOOOTOTOOOCOSONOFTVOOCOTINDOOcL OCU soOoOrD $3 ED615269 GFCS BFG705 63707) 12)73 74 75 76 77 78 25 £0|
6 Ly 5 VG 5512.19 14-95 16 47 $8 19 2021 2229:24 ZS2B27 ZB29-9221 32-39 S435 3627 38-394 41 AZ AL44-454047 4B49 50St 52 53.54 Sr $657 52
‘ HOU DUNTUID AOA ATOM IDNA APT UO Ue TT ae ee Pet D tT Pe at
2i22.2.21022222222M22222222022220222222222222222222222222222222222222222222202020022
H i]
3
313.3.3-713:933333339339M033333303333399339339339393393393393393993393939939339333393
SS
SISSSSSISSSSSSSSSSSSSSSSSSSSSMSMSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSIOSSSS5SSSSSSS
OSES
SeGENGGGSRSSGSESNGESSESSCESSSEGRSSEGEGSEGESSEGSOSSSESSSESSSESESSSSEECSSOEEES
PE DO
BS SESEEBS
GBH HGHIGHBB
gigce sie SGM GMM GMs oMoMccMceMsBssccasssssissaCGBBSHAEREHBBSBB
i !
919999 ig 999999999999999999N99995999999999999999999
112.34 516! 8 HNN IBIMIRBAMBHTIBAMIND
RBUSH 6m uBat as Age "
E 7 STANDARD FORM 823157
Addition, symbolized by +
Subtraction, symbolized by —
Multiplication, symbolized by *
Division, symbolized by /
Exponentiation (raising to a power), symbolized by **
We have already discussed in some detail in Sec. 3.1 the important sub-
jects of hierarchy of operations and the use of parentheses. They both apply
to Fortran expressions, so review that material if necessary. Arithmetic ex-
pressions are easy to write in Fortran; the only difference from mathematical
expressions is that multiplication must be denoted by the asterisk *, division
by the slash /, and exponentiation by the double asterisk **. The following
examples should be easy to follow:
AP B/C a -! +a
AS BIC DY) ac ss
eas
az
AY 2/3. + B a ie)
b 3
A> (B/Cj#3 (Nae ’)
a+b
(Ace By (ee) eT,
One final note concerning blanks before you try the next set of exercises.
As you have undoubtedly noticed in the source program of Fig. 4.2 and in
many of the example expressions we have written, use has been made of
(empty) spaces or blanks so as not to crowd the characters of the expressions
together and to provide more clarity and neatness. When the blanks in an
expression or statement you write on a Fortran coding sheet are transferred to
the corresponding IBM card, the card contains no character at all in that col-
umn; no punch appears on the card in the column corresponding to the blank.
Blanks in expressions and statements are ignored by the compiler so that, un-
less a statement is already too long, blank columns can be used to space it. For
instance, the statement X=A*B+C/D can be written X = A * B+ C/ D,
and the statement GO TO(12,13,14,15),M can be written GO TO (12, 13, 14,
15), M. One should not insert blanks in the middle of a number; one should
not write X = 8 3.0 when one means, algebraically, x = 83. And, of course,
one cannot have blanks in the name of a variable since the computer then con-
siders the blank to be a special character.
EXERCISES
4.1 Identify each of the following as a real or an integer constant. If
the constant is not acceptable (according to the criteria given in the
text), state why.
(a) —457
(b) 0
(c) 0.0034
(d) 328.8934
(e) 67.E+03
(£) —677308
(g) +87
(h) 3.E—89
4.2 Write each of the following real numbers in exponent form with
the decimal point just preceding the first significant nonzero digit.
(a) .0678E+04
(b) 876.1
(a) re ics
5 (?—— 1)3 _7
(b) oy
(C)5a crt Bare)
(d) Vue + v4
la) fel
Nas araie
b
(f) a— Ak = 9%
ib (esr@ J
uel +k)
Bye (Qh)
(h) Vs
3470 7856
(i)
d* a 17r
(k) 14+x4+
224+ x3 + x!
45,678 + p
(h) 5557—, (15.678. + P)/5,557.—Q
(a) I+ 2/NXX
(b) X*Y + 34.5/P78
fa) 0s 9g SEO)
(d) 13+ (N+5)/X
(e) 456 — NNNN + NP/6
(f) X*3r— X"'2. + 5*BIG
We have finally arrived at the main objective of the section— the writing
of Fortran arithmetic statements. Every Fortran arithmetic statement has the
following form: variable = expression. The variable may be real or integer
(and, naturally, is not a constant or an expression), and the expression may be
a variable, a constant, or any properly formed Fortran arithmetic expression.
Thus, V= X*Y**4 and N= X+ M-—7.8 are correctly formed statements, but
4=X and C+ D=P**3 are not. Note that C + D cannot be the name of a
variable since it contains the special characters blank and +.
This is the way an arithmetic statement is executed. The expression
A= 4.0
M=3
A=A+ 2*M
When these statements are executed, the value of A will be initially set at 4.0,
the value of M initially set at 3. The righthand side of the third statement
will now be executed: the current value of A (namely, 4.0) will be added to
2*M (which is 6) with the result 10.0. Then, since A is the variable on the left
side of the statement, the new value of 10.0 will be stored at A, erasing the
old value of 4.0. stored there by the first statement.
This last sequence of statements has made us realize that Fortran arith-
metic statements are not equations in the algebraic sense. Rather, they con-
tain what is to be calculated and where the result of the calculations is to be
stored. The algebraic equation n =n + 1 is not true for any n. But the For-
tran statement N = N + 1 is not only perfectly valid but turns out to be rather
It should be clear to you now that all the numbers the computer uses
to calculate with are rational numbers. If you ask the computer to calculate
V31 by writing 31.**.5, the six-significant-figure rational approximation 5.56776
will be the best effort of the computer. As you recall from the discussion in
Chap. 1, even some rational numbers like 1./3. require infinitely many digits
to be represented exactly whether they are stored as decimal numbers or binary
numbers, and since only a finite number of these digits can be used to repre-
sent the number, calculated results will contain errors due to truncation. Ex-
actly the same kind of error due to truncation occurs in any computing device
because all computers have only a finite number of storage places to store the
digits of a number.
We have learned in this section how to properly write Fortran arith-
metic statements that will cause the calculations of the operations of addition,
subtraction, multiplication, division, and exponentiation to be performed when
a program containing them is executed. We have also seen the use of arith-
metic statements to assign values to variables. The prime way, however, of
assigning values to variables is to read in numerical data during the execution
of the program. In the following section we show how one prepares data
cards, and we present the input Fortran statements that will be required in
the program so that data cards can be read in at the appropriate time. We
shall then discuss the outputting of results. After the introduction of just a
few more essential Fortran statements, we shall finally employ all we have
learned to write complete Fortran programs.
(a) X=2"6 +3
(b) I= 2740/6
(c) 1= 2/40*6
(d) X = 2*40/6 + 3
(e) X= 50/3
(f) X=2. +37/5
(g) X = 15/6 + 17/2
th) 1=3.7 + 8.7— 4/3
(a) y= V2x +7
5x
Oe aa
(c) v = 3.141591?
(d) v =; (3.14159)
r2h
_ Gar V6
(f) ic ve
(g) r= V2 V2+5
mat aioe
ES ONT
@) a=5 (ee
—4)
We have seen that variables can be assigned values by using arithmetic state-
ments in the program itself. Every time such a program is run, the same
values will be assigned to the same variables, and the results of the program
A=47
X = 8.32
C= A*2 + X*3
one could write the input statement READ (2, 5) A, X followed by the state-
ment C= A**2 + X**3. A card containing the values of A and X would be
read by the card reader, and these values used to calculate C. Then, if this
sequence of statements is executed again, it is perfectly possible that the new
card will have different values of A and X punched on it. The card being
read which contains the values of A and X is called a data card. Notice that
the data cards are not part of the source program; they are read and entered
by the computer after the program itself has been written, punched, compiled,
and stored and is in the process of being executed.
In this section we shall learn how to prepare data cards, how to properly
write input READ statements and their associated FORMAT statements. We
shall also have to learn to write proper output statements in order to discover
the results of the calculations of the program; we shall describe various output
WRITE statements and their associated FORMAT statements. In this book
we shall be concerned only with the input and output of numerical data. A
full description of the Fortran IV language would include a presentation of
the input and output of alphanumeric data, that is, data that could contain
alphabetic and special characters as well as numeric characters. In keeping
with the fundamental character of our entire presentation, we shall restrict
even our discussion of input and output to basic essentials. We shall assume
throughout that the input device being used is the card reader and that the
output device is the printer.
The input statement has the form
Notice that within the parentheses of the FORMAT statement there are seven
specifications, one for each variable of the list. The commas which separate
the specifications are mandatory punctuation. Let us first explain the special
code letters F, E, and I which occur in this statement. F identifies a real
number written in ordinary decimal form; E identifies a real number written
with the exponential notation; I identifies an integer number. As you look
over the FORMAT statement, notice that each real variable of the list has either
an E or F specification and that each integer variable of the list has an I speci-
fication. This correspondence is required. The integral part of each number
that follows these code letters indicates the number of columns of the card the
corresponding punched number may occupy. Thus, the 6 in F6.2 shows that
the value of the variable P is contained in 6 columns of the card.. Four columns
are used for M, and so on across the card. Thus, the sequence 6, 4, 6, 10, 2,
12, 3 of these integral parts divides the card into consecutive sets of columns
each containing the value of the corresponding variable. The card could look
like the card of Fig. 4.4. The values of the variables appear on the card
in
this way: P in columns 1 to 6, M in columns 7 to 10, Z in columns 11
to 16, W
2222/21222222222222222222222022222222222222M2222222222222222222222222 222222222222
313339)39H39939399333339M0N9339933333N39N339339339939993393993999399399999999993993
OUUE ORUCEPECCUrereerel £1 COVERT ET) EP) PEER VERY OV EVE O reeVer yer erreryey) evr rer)
'
SISMSSSSSSMSSHSSSSSSSSSSSSHSSSSSSSSSSSSSSSSSSSSSSHSHSSSSSSSSSSSSSSSSSSS SSIS SSSSSD
|
BESCEMEGHSESSEE CES ESEGEEGCREGSEEOCEE GEESE EEGESEGSS FSFE SE EGB EEG EG BSB GECGEES
7777777777877777077777777777777877808977979777797777977979997297997979
77:94:
I
eHesceeMSceceeerMsesssessecsesoMessceees ees RHE RRR AB RHR B RES REHEARSE DABS
9999999999999999999995999999
WURIKSCIBINADDKSAIBVAMDHNNVHSEN
STANCARD FORM 883157
with a blank (no punch at all) in column 10, the computer would automatically
assume a zero in column 10 and would read the value of M as 890. To avoid
such errors, it is best for all the numbers punched on the card to be right-justi-
fied so that the last digit of the number appears in the last column of the field
of columns assigned for that number. Thus, if Z were 8.32, we would have
(i
cell ccl6
Evidently, one space will occur in the printout just before the value of X is
printed, 30 spaces will occur between the printing of the values of X and of Y.
The printed line has a maximum number of printing positions, usually 120.
The FORMAT statement just given will cause the values of X, Y, and N to be
printed on one line.
The material presented so far concerning input and output is sufficient
for our immediate purposes. More willbe revealed in the chapter on arrays
and matrices.
We introduce just one more Fortran statement before we start writing
some complete programs. Some method must be found to signal the com-
Example 4.1. Write a complete Fortran program to assign the value 6.789 to the
variable X, 7 to the variable M, —34.66 to the variable P, compute and output
the value of the variable Y if y= Vx? + p + (x—p)”.
Analysis: The plan of this program is direct and simple. We shall use arith-
metic statements to assign the values of the variables, write an arithmetic
statement to compute y, and follow it by an appropriate output statement to
print the value of y, as follows.
X = 6.789
M = 7
P = —34.66
2 a ORLOX oP) ae CP) eM
WRITE -G, 45) -Y
45 FORMAT (3X, E13.6)
END
Example 4.2. Write a complete Fortran program to read a card containing the
values of the variables A, B, C, and D, compute x= a/(b +c) and y=d? +c?
+ 4x, and print the values of a, b, c, d, x, and y on one line.
Analysis: Since the FORMAT of the card must be known, let us assume that
someone has informed us that the value of A is punched in the first 10 col-
umns, the value of B in the next 12 columns, the value of D in the next 10
columns, and the value of C in the next 8 columns, and that each is in decimal
form with the decimal point punched. The program appears as follows.
The input format statement should be clear. The computer then knows
the values of a, b, c, and d when it comes to the third statement. It also knows
the value of x when it is asked to calculate the value of y. We have used E15.6
as the output specification for all the variables, since it allows for horizontal
spacing without the use of the X specification. It is possible, though not
necessary, to simplify this FORMAT statement by writing it this way: 568
FORMAT (6E15.6). The 6 preceding E15.6 merely indicates that the speci-
fication E15.6 is to be repeated six times. Notice that the entire program has
been written without the knowledge of the actual values of A, B, C, and D.
If desired, then, this program can be run over and over again with each run
using a different set of values for these variables, that is, with different data
cards.
Example 4.3. Write a complete Fortran program to solve the following set of
simultaneous linear equations:
‘eon
dx + ey =f
The values of a, b, c, d, e, and f are to be read on two cards, the first card con-
taining the values of a, b, and c punched in format 3F7.2, the second card con-
taining the values of d, e, and f punched in format 3F10.0. Print the values of
x and y on consecutive lines.
Analysis: We leave it to you to show that the value of x is (ce — bf)/(ae — bd)
and the value of y is given by (af—cd)/(ae— bd). We shall assume that
ae—bd #0. We first present the program and then give a discussion of
some of its interesting facets.
With the simplified version we are presenting, the two READ statements are
necessary since we are to read the data from two separate cards.
The above set of two statements can replace the first four original
statements. The slash (/) in the input FORMAT statement is a code to the
computer that the reading of the card is to end at that point and another card
is to be read for more data. In this context / does not mean division. The
use of this additional coding merely simplifies the writing of the input state-
ments for the program and we can get along without it.
Note that the expression ae — bd occurs in the denominators of both x
and y. It is good practice to compute this quantity separately once (here it
is called DENOM), rather than to compute it twice, once when x is calculated
and another time when y is calculated.
It is not clear why the two WRITE statements will cause X and Y to be
printed on consecutive lines. The 1X which appears in the FORMAT state-
ment numbered 3 is a special code to the printer that a new line of printing is
to be initiated. We shall continue to use this printer signal 1X as the first
item of the output FORMAT statements we write in order to ensure that print-
ing will always occur on new lines. The 1X code we use here may not be the
code for every computer or compiler.
Another way to write the set of two WRITE statements is as follows:
This set of statements will cause the printing of X and Y on separate lines.
First, X will be printed (on a new line because of the specification 1X). The
specifications are now all used up, and there appears to be no specification for
the variable Y. However, when this occurs, the FORMAT statement will be
again entered at the left parenthesis and the specification will be reread and
used for the variable Y. Evidently, the 1X will cause the printer to space verti-
cally so that the value of Y will be printed on a new line. If there were more
In this case, each time the FORMAT statement is reentered, a new card must
be read. Thus, this set of statements will cause the reading of four cards; each
of the cards should contain the value of the corresponding variable in the first
10 columns of the card, and each card is read under the specification F10.0.
In the program above the output FORMAT statement numbered 3 is
referred to by both the WRITE statements. This is perfectly legal. In addi-
tion, FORMAT statements need not necessarily follow the READ or WRITE
statement that refers to them. All the FORMAT statements of the program
may be placed in a set at the beginning of the program. We prefer the natural
order as used here.
Let us present the rewritten program above using the simplifications
just remarked on.
Again, note that this program can be used to solve many sets of simul-
taneous linear equations. The first two cards read can be different on each
run of the program. At this point, however, the only way the program can
be rerun is to start again from the reading in of the source deck and proceeding
through compiling and execution each time. In the following section we shall
present control statements that can be inserted in this program and which will
cause the immediate rerunning, in essence, of the program. As you recall,
control statements can alter the usual order of execution of statements.
EXERCISES
4.9 Figure 4.5 shows a punched data card which is read using the
statement READ (2, 4) A, B, N, X, Y, M. What are the
values assigned to these variables if the corresponding FORMAT
aaa TORU RU RUCECE! POCO VeLECE! PUeee rere reer rv rrrUrerrrrVrOrrVUVreVrEll VrrrrEr|
vt
7770077777777777877977987777797979777779779979999777797977777999777797740
090720
\
cssshss sess SS SyPRSRSFHLHHHSSKRHBKHSHHKHSGHGHHRHGHGHHHBGHRHBHSHSHE
SB B8B BEBE
J9sgggggsggsgaggggaggsMMasagagggggssggggggggsggggagggagggS 99999999
7 8 8 WO4 1213 141516-9718192021Z2Zo24BE 77 BW79-WIH WH BSBI BW 4D4142-49444S46478 485ST 525)345556STS559 6051 D'S 731475787 78780
STANCARD FORM 889157
statement is:
4.11 Write a complete Fortran program to assign the value 4.72 to the
variable X, —12.73 to the variable Y, 7 to M, and —5 to N, compute
Z=x + y"* and q= Vz + (x" + y")/17, print z and q on one line.
4.14 Write a complete Fortran program to read three cards with the
values of A, B, and C, each punched F9.0. A, B, and C are all
positive numbers and represent the lengths of the sides of a tri-
angle. Compute the semiperimeter and area of the triangle using
the formulas S = (a+ b+ c)/2 and AREA = Vs(s—a)(s—b)(s—c).
Print A, B, and C on one line. Print S and AREA on the next line.
Control statements in Fortran are those that will enable you to control the
course of the program. As you recall, statements are normally executed se-
quentially; after one statement is executed, the statement immediately follow-
ing it is executed. It is often more useful to alter the sequence of the state-
ments of the program, as we shall soon see. In this section we shall present
the two basic control statements (unconditional) GO TO and IF. There are
additional control statements in the expanded version of Fortran.
The GO TO statement provides a means of transferring control immedi-
ately to some other statement of the program. This is often immediate
branching. It is written in the form
GO TO n
When executed, this program will first cause a card with the values of
X and Y to be read, the value of Z calculated and printed. Then control is
transferred by means of the statement GO TO 75 to the statement numbered
75. This means that the READ statement will be executed next, a new card
will be read, a new value of Z calculated and printed. Again control is trans-
ferred to the READ statement and the process will be repeated. Since now a
loop has been created, the process will be repeated over and over again as long
as there are cards supplied to be read. Note that the presence of the END
statement has no effect on the looping; it does not cause the program to end.
We shall return to this program once again to see how we can limit the number
of cards that will be read, if that is our plan.
In any case, the GO TO n statement alters the sequence of statement
execution unconditionally; the transfer of control is immediate and does not
depend at all on any values computed in the program. Then in the GO TO
n statement must be the statement number of some executable statement in
the program; if no statement is numbered n, the GO TO is rather pointless,
and its presence in the program reveals a certain degree of poor planning on
the part of the programmer. Note that it is not permissible to transfer control
to a nonexecutable statement like FORMAT or END.
Before we present some more examples of the use of GO TO and in-
troduce the IF statement, we consider the concept of the flowchart. A flow-
chart is a graphical presentation of the order of execution of the statements
of a program. It should be carefully drawn for each program in order to plan
the logical flow of the program before writing out the statements of the pro-
gram in detail. Figure 4.6 shows the graphical symbols we shall use to create
the flowchart. To illustrate the use of the flowchart, we diagram the last illus-
trative program in Fig. 4.7. Note the arrow indicating the return to read a new
card. Note also that the complete statements of the program itself are not
given in the diagram. The intricate details of the actual written program are
to be supplied by the programmer after he has planned the desired flow of
execution with a flowchart. You realize, of course, that we wrote the pro-
gram without the aid of a flowchart since it was so simple in its flow. Butin
even moderately complex problems the various interrelationships within the
ee DECISION-MAKING STEP
INPUT-OUTPUT STEP
STOP
program often become very difficult to keep clear without the use of some
visual scheme. In addition, appending the flowchart to a complex program is
a valuable aid in communicating to others the actual operation of the program-
ming. The flowchart is thus a part of the documentation of the program.
A CONTROL statement that involves decision making is the IF state-
ment. It has the form
Here E stands for any expression, and n,, n,, and n; are statement numbers
(and are thus unsigned integer constants). This is the way the statement
works.
Fig. 4.7 Flowchart
READ X, Y
COMPUTE
Z= Ko ax
WRITE Z
Solution: IF (N — 9) 18, 7, 7
TH GY ee VV) melo, 2
Since the expression has the value 4(8) — 7(6) =—10 <0, control will be
transferred to statement number 17.
Fig. 4.9
The Flowchart:
COMPUTE
COMPUTE q=7p*
q=5p*
The Program:
36 READ (2, 6) A, B, C, P
6 FORMAT (4F8.0)
[EAB = 5.%A2C)758,.8
70=7,*pt*3
GOTO9
8Q=5.*P**4
9 WRITE (3, 19) O
19 FORMAT (IX, E13.6)
END
Set
counter
at 1
READ X,Y, Z, N
COMPUTE
COMPUTE kia Vaan Zs
s=Veety2+z27| |S>~ 3
Advance
counter
by 1
Is
counter The Program:
>9? 1=1
7 READ (2, 1) X, Y, Z, N
1 FORMAT (3F 10.0, 13)
IE(NES2)2,354
ZS — SORT (X= 2 2 ee 2)
GOTO5
4S=(X+Y+2)/3.
5 WRITE (3, 6)S
6 FORMAT (1X, E13.6)
Si =e
IES 9)7eeee8
8J=40
WRITE (3, 9) J
9 FORMAT (1X, 14)
END
Fig. 4.10
COMPUTE
y= xe dE 3x? =
7x + 10
ADVANCE
x
by .05
The Program:
X= 1.0
2 NG KISS de oa 2 Xo 10;
WRITE (3, 1) X, Y
1 FORMAT (1X, F5.2, 4X, E13.6)
NE Xe5)) 2220s
3 CONTINUE
END
Fig. 4.11
EXERCISES
For each of the following exercises construct a flowchart and write the pro-
gram itself on Fortran coding sheets.
fest ae
dx + ey =f
4.18 Write a complete Fortran program to read a card with the numbers,
all positive, A, B, C, and D, punched 4F10.0. Determine and print
the value of the variable BIG if BIG is the largest of A, B, C, and D.
4.19 Write a complete Fortran program to read a card with the positive
numbers A, B, C, and D, punched 4F10.0, read another card with
the value of N, punched I[2. Let BIG be the largest of A, B, C, and
D and SMALL be the smallest of A, B,C, and D. If N = 0, deter-
mine and print BIG; if N # 0, determine and print SMALL.
4.21 Write a complete Fortran program to read a card with the values
of N, R, and S, punched 14, 2F10.0. If m=1 andr <s, compute
z= 4r— 3s and print z; ifn = 1-andr = s, compute z = 3s — 4r and
print z; if n ~ 1, print the number 567.
4.22 Write a complete Fortran program to read a card with the value
of k >0 and A, C, and X (14, 3F10.0). If k=1, compute d=
A set of singly subscripted variables like {x,, x, x3, x4, . . . , Xn} is called a
one-dimensional array. Each variable uses the common array name x and has
one integer subscript. In Fortran these subscripted variables are written X(1),
AZ ieAS) om 4) a XUN):
Recall the expression
which means that the variables x,, %., . . . , X, are to be added. Let us now
consider how we could find such a sum as part of a Fortran program. Sup-
pose that the numerical values of the 80 variables X(1), X(2), . . . , X(80) are
known to the computer and we want to calculate the sum of these 80 values.
Consider first the following set of instructions:
I=1
SUM = 0.
SUM = SUM + X(I)
initially. The third
The first two statements set the values of I and of SUM
SUM (now 0) is added
statement’s righthand side is now evaluated. Thus, to
Then this result is stored atSUM. Now
X(1), that is, X(1) since I is now 1.
the array X has thus
SUM contains the value of X(1). The first element of
been stored in SUM. Now suppose we extend the set of statements above to
I=1
SUM = 0.
16 SUM=SUM + X(I)
I=I+1
GO TO 16
say:
The first three statements are as before. Then the next two statements
Add 1 toI Now I= 2) and GOTO 16. Statement 16 says: Add to SUM [which
now contains X(1)] the value of X(I) [that is, X(2) since now I = 2]; store the
result in SUM. It is clear that now SUM has stored in it the sum of X(1) and
X(2). Then the process will be repeated; 1 will be added to I (now I= 3), GO
TO 16, etc. A nice loop has been set up. However, this process cannot be
permitted to go on indefinitely because X(80) is the last element of the array
which we desire to add on. This situation is easily taken care of by telling
the computer to stop repeating the process as soon as I becomes 81. We thus
extend the previous partial program to the following:
I=1
SUM = 0.
16 SUM=SUM+ X()
I=I+1
IF (I— 80) 16, 16, 18
18 WRITE (3, 19) SUM
19 FORMAT (1X, E13.6)
As you can see, when the IF statement tests the value of I and finds it is 81,
SUM will contain the sum of the 80 elements of the array X. The partial pro-
gram then calls for this value to be printed.
We have assumed throughout this last discussion that somehow the
80 values of the elements of the array had been stored and thus were known
to the computer. We now present a method to read in and store the elements
of a one-dimensional array. First, the computer must know, before it en-
counters arrays in the body of a program, the name and number of elements
of the arrays so that it can reserve in advance the storage positions required.
We inform the computer of this by using a DIMENSION statement. The
DIMENSION statement identifies the names of the arrays and indicates the
EXERCISES
5.1 Write a complete Fortran program to read and store the 30 elements
of the one-dimensional array X, punched one per card F10.0, 30
cards in all. Compute and print the sum of the squares of the
elements
READ
X (1)
COMPUTE
SUM =
SUM + X(I)
INCREMENT
| by 1
The Program:
DIMENSION X(80)
SUM = 0.
1=0
PRINT SUM 10 READ (2, 12) X(1)
12 FORMAT (F10.0)
SUM = SUM + X(I)
=!+1
IF (1 — 80) 10, 10, 24
24 WRITE (3, 25) SUM
25 FORMAT (1X, E13.6)
END
Fig. 5.1
50
=> (yay)
7-1
24
Print the elements of the array D, one per line, then print the value
Of:
40 } 1/2
— (Ss3?)
i=1
Brings
5.2 MATRICES
The set of subscripted variables {x,,,, X21, X1,2, X2,9, X32, . . .} is called a two-
dimensional array; each variable uses the common array name x and two integer
subscripts. In Fortran, these variables are written X(1,1), X(2,1), X(1,2), X(2,2),
X(3,2), . . . . Variables with two subscripts are usually placed in geometric
rectangular arrangements called matrices. For example,
is a 4 X 3 matrix; it has four rows and three colunns. Note that the first sub-
script indicates the number of the row in which the element occurs, the second
subscript indicating the number of the column in which the element occurs.
A matrix may be 1 X n and thus have 1 row and n columns; it is then called,
appropriately enough, a row matrix. Similarly, an n X 1 matrix has n rows
and 1 column and is called a column matrix. A matrix is square if m =n, that
(square) matrix. The set of elements of a square matrix which lie along the
diagonal extending from the upper left element to the lower right element is
called the principal diagonal of the matrix. The elements 3, 4,5 of the matrix
St Be ae
: 4 j
an” ee
constitute its principal diagonal. A square matrix with all its elements below
the principal diagonal equal to zero is called upper triangular. Thus, the
matrix
Stee nO
OR 2a 3 aah
OO) 4b ile
0 @ OO 8
is upper triangular. Similarly, a matrix with all its elements above the prin-
cipal diagonal equal to zero is called lower triangular. A matrix which is
both lower and upper triangular is called a diagonal matrix. For example,
x0 0
Oo aA wo ©
? 0 @ ©
oY © @ =7
A matrix all of whose elements are equal to zero is called_a zero matrix.
Ore 0 ,
E 0 4 is the 2 X 3 zero matrix.
As you have noted above, we often give a matrix a single letter name,
usually the common variable name, like A. We also write A = [a;,,;| for short-
hand. We write equations concerning matrices at two levels. On one level
is a matrix equation in which each letter represents a matrix and the operation
symbols are matrix operations, such as A+ 3B=CXD. On the other level
we can write a numerical equation involving the elements of the matrices, as
Ci;= b;7 + 6, where c;,; and b;,; represent elements of the matrices C and B,
respectively. For example, as we shall soon see in detail, when one is asked
to multiply the matrices A and B, that is, find A x B, the actual calculations
consist of ordinary arithmetic operations on the elements of the matrices A
and B.
Two matrices are equal if they are identical, that is, if they have the same num-
ber of rows and the same number of columns and if each element of one is
equal numerically to the corresponding element of the other.
We shall first define the operations of addition and subtraction of two
matrices. We write C= A+B, and the elements of C are defined by c=
a;,;+b;;. In order that two matrices may be added or subtracted, they must
have the same number of rows and the same number of columns. The sum
matrix C then has for its elements simply the sum (or difference) of the cor-
responding elements of A and B. Obviously, the order of C will be the same
as the common order of A and B. Here are some examples. Suppose
Jo aa A
A=[} —5 “4
and
B=|) 4 5
Ae =
Then
De I ANE)
c=a+B=|) 0 |
=a-B=| 2 -1 ge
De ~ |-1 —10 9
20)
5X = c 5
ORS
We can now form linear combinations of matrices, like A —3B-+ 4C, pre-
suming, of course, that A, B, and C are all of the same size.
The operation of matrix multiplication is rather peculiar and at first
glance seems involved. If C is the product of two matrices A and B, we write
C=AXB. We first point out that a certain kind of compatibility must be
satisfied by the matrices A and B if they are to be multiplied. The number
of columns of A must be the same as the number of rows of B. Thus, if A is
an i X j matrix, then B must be aj X k matrix. The product matrix C will then
be ani Xk matrix. Thus, if A is 3 X 5 and B is 5 X 7, then C will be 3 X 7.
Two matrices which do not satisfy this criterion cannot be multiplied.
The operation of matrix multiplication is not commutative. In general,
A XB is not equal to BX A. One must therefore keep good track of the
order of the multiplication. In the product A xX B we often say that A pre-
multiplies B, or equivalently that B postmultiplies A.
Suppose we have the m X p matrix A and the p X n matrix B. The ele-
ments of the product matrix C= A X B are found in the following way: the
elements c;,; are computed by multiplying the elements of the ith row of A
by the elements of the jth column of B and adding these products. That is,
Pp
k
= A,1b1,3 + Aeobe,3 + 2,303.3 + Ar 4D43
Note, again, that cy; is found by summing the products of the elements of the
second row of A by the third column of B. Similarly, c,,; is found by summing
the products of the elements of the first row of A by the fifth column of B. It
is clear now why, to multiply the matrices A and B, the number of columns of
A must equal the number of rows of B. If this were not so, the required prod-
ucts of elements could not be found.
Example.
If
epee PR eh ge!
e=[0 4 2 mmel
3 il
then
GAeas
mg A AS al
eyed Alene
2 a
ee gs as nied
for 42963 + 10-8
my o2e 24
= & a
If the elements are simple numbers like these, one usually performs the prod-
ucts and sums in one’s head and simply enters the result in the proper position
in the product matrix. A two-finger method can be used. Run your left
index finger across the first row of A and at the same time run your right in-
dex finger down the first column of B, multiply corresponding elements, and
add as you go. The result will be the element c,,, in the product matrix C;
place it in the proper place in C. Then again run your fingers across the first
row of A and down the second column of B, multiply and add as you go. Place
this result in the position c,. in C. Continue in the same way across each
row of A and down each column of B, being sure to place the respective re-
sults in the proper place in C.
If A is a square matrix and U is the unit matrix of the same size as A,
then one can easily verify that AX U=UXA=A. That is, multiplying by
2S
Zao a
xX A=
exaz[oalx[ x 3
3 4
535580) 9102
= © 10 ‘
ie BY Be
E xample.le. 3 5 pe iit 4
Le Let A= E A , B B= E AY
; then A X B = 1 A while
1 B X A =
ee
1 |
7 Again,
gain, AXB#B x A.
EXERCISES
: 8) © =8)
a CG iven 1 — E 4,B=
B - |;
5.8 Given
B=[1 2-5 4}
ilps al
C=/4 1 1
0 6
Woondl
136 INTRODUCTION TO COMPUTER SCIENCE MATHEMATICS
GN
N NF
oF
The matrix
= 2) 371
FeTOR ANIwoes
a te Ue
Merle sees I
of the coefficients of the four variables is called the coefficient matrix. Now
consider this matrix equation:
Smee =A! Xs 7
i 1 Te ais Ti By
x =
ae eee A 0 ks =3} ne
Aya 8 1 58" 38
The matrix equation (5.2) is equivalent to the original set of equations (Ss)
To see this, we multiply the left-side matrices. The product is the column
matrix
I
Pf
their corresponding elements must be equal. If you write all this down, you
will clearly have just the original set of linear equations (5.1). Now since
the matrix equation (5.2) is equivalent to the set of equations (5.1), we wonder
whether we can solve the set of equations written in the matrix form (5.2)
using only matrix methods. Let us generalize (5.2) to the following form:
AX (5.3)
where A is the coefficient matrix, X is the column matrix of unknowns whose
values we are to find in order to solve the set of equations, and B is the column
matrix of the righthand members of the equations.
Suppose we could find a matrix, say C, which would have the remark-
able property that C x A=U, where U is a unit matrix. We could then pre-
multiply each side of Eq. (5.3) by C and get
C(AX) = CB
Multiplying, we have
bee Hee | |
ce+dg cf+dh} [0 1
ae+bg=1
af +bh=0
ce +dg=0 (5.4)
cf +dh=1
Solving the second equation for f, we have f=—bh/a. Substituting this for
f in the fourth equation, we have (—bc/a)h + dh = 1, or h(d— bc/a) = 1 and
eet
h
~ d—bcela
ae a
~ ad—be
We also have f =—bh/a =—b/(ad— bc). Again, solving the third equation
for e, we have e =—dg/c. Substituting into the first equation, we have
ad ad 1 mh c me ==
ei st g(b-“)=1 ea ~ be-ad ad—be
c
d =D
a UC Od pC eee 1 dab
SE a ere mie a
il (Xe (= lee
3 4
= = |
then
ie Lo7
ee 4
s 29 be |
mi be i, al
~ 29/29
i
<Am
AXA = 5 4
Example. Solve
{ ox + 4y=) 7
—2x + 7y = 12
ie 7|A a ka
Thus,
In the first step we have multiplied the first row by 3, and in the second we
have interchanged the two rows.
3 4 1
bare? ae
ALP PS oof
and we fix the second row, then add two times this row to row 1. We now
have
[s : |
1B ts
a 2 7
which is equivalent to
3.4 1
By 2 |
el was
a-|s |
4 1 3
Sr Gl 5
by appending on the right of A the 3 X 3 unit matrix. Then as you pick out
and apply the sequence of elementary row operations that will transform A
into U, instead of applying them only to A, you apply them to the entire row
of the augmented matrix. So, in effect, you are automatically applying ex-
actly the same sequence of elementary row operations to U. Thus, when
A—U,U—A‘™. That is, the 3 X 3 matrix on the right will be exactly the
inverse of A. We shall have an example of this in a moment.
Now suppose you have a set of linear equations like
ce z= 8
ariiar we 7
ee Ups ge 8,
i @ @ @
:0 \
O50 Lec
oe Yate 2 ae
2X ea Ieee 2 — el
x+4y—2z= 11
use the matrix method just described to solve the equations and at the same
time find the inverse of the coefficient matrix.
1 1 1 | {1 0 0
E eal UA eA TRO
1 A =P iOO al
by appending to the coefficient matrix both the column matrix of the right-
hand sides of the equations and the 3 X 3 unit matrix. We now proceed to
apply a sequence of elementary row operations which will transform A into
the unit matrix U, but we apply each operation to the entire row at each step.
Ds 219]
0-3. =1.—> 5 —2,-1 0
ju e
ee ee ee Oo 00iL
1 1 1 2 i @ @
|:= =) =) —27 I wv
0 2 =) =i © il
‘ee ee | 0 O
|:i Ya Fe 4% =We ©
Yo = 2 =i © il
Ge Se Bal 0 O
|:1 Ys Fs Y%3 —YV3 j
0 @ =f 4 =3 7 il
i a fl D 1 0 0
|:il Ye % 4 =Ye |
0 @ f@ =i So =. =e
|: 0 4% %Ys Ys Ee)
Od 8h Js Fe =p 0
0 © t S Y Ya —Yal
DO ae saree ce Ld
fi 0 2 ie Ya Vie
Oa Oe Le ees ae
i © @ | 1 |—"/6 Wo Ve
f ile) | 2 | S/o Wa |
O01 Seas
—V¢ Vy Ve
t=] S12 —Wq a
Ya —Ye —Ya
Hil tet. 2
rd) ogee 1
23 so,
A quick check on your part will reveal that A X A“ is in fact U, and so what
we are calling A“ here is truly the inverse of A.
You should study this example and take note of the systematic way the
matrix A is transformed into U. This method can easily be applied to any
number of equations, but as the number gets larger, the manual work, though
arithmetically simple, becomes almost tedious even when the numbers in the
original matrix are simple integers. If the coefficients are rational numbers
in decimal form with a large number of significant figures, then one could
not hope to do the operations manually. Obviously, one would seek the help
of the computer. We hope that in your later work in computer programming
you will be able to write a Fortran program with ease which will solve any
reasonable number of simultaneous linear equations using the method of ele-
mentary row operations and which will also invert a matrix of not too unreason-
able size.
EXERCISES
5.9 Write the following set of simultaneous linear equations in the
matrix form AX=B. Use the method of matrix inverse to solve
this matrix equation for X and thus solve the set of equations:
ee 7
Dieta
i NS
2 Jan O
F 3a00
0 0 4
ie eee 2,
a-| ik i
Aw 2F 2.
to
ee oe ee Lee)
eg eee a
Ame 2/2 Ses One
hie ea ee 7/
[2 y + 5z= 16
4x+2y+2z=11
i 2 ih att
Py Sl ell
2 Ps 5 i
i .©@ © «
O) Gk 0) fe
OO Flere
5.3. DETERMINANTS
Associated with any square matrix A is anumber called its determinant. (Non-
square matrices do not have determinants.) We abbreviate this number
det A. We shall soon give some rules for finding this number and then by
means of some applications try to present some notions as to the reasons for
these rules. The determinant associated with a matrix A is the square array
of the very same elements of the matrix except that the square brackets hold-
ing the matrix elements together are changed to straight bars on each side.
: Ay 4 7
For example, the 2 X 2 matrix A= E 5 has determinant det A= 3 5
ela, ee bz Cra ee ee ae
ie Bie 15 + 28 = 13 and i 3 O58 8.
Evaluation of 3 X 3 determinants can be done by a slightly fancier rule.
Suppose the determinant is
i lo
dae
Crain d
ey ab.
45 6
i 8)
3 il ome
4 5 Go 4S
ih 2d SY A
The first sum is clearly 3(5)(—3) + (1) (6) (1) + (2) (4) (2) =—45+6+16=
—23. The second sum is (2)(5)(1) + (3)(6)(2) + (1) (4) (—3) = 10 + 36
—12=34. The value of the determinant is thus —23 — 34 =—57.
Before we turn to higher-order determinants, let us present an intro-
duction into the reason for these peculiar methods for evaluating 2 X 2 and
3 X 3 determinants. Consider the set of simultaneous linear equations:
ea ae
dx + ey =f
earners a
bd x + be y = bf
© 10
a)Rien gO
~ ge—bdla b
d e
ac
_la_f
Lo. as
de
Example. Solve
fe Oe
s+ 5t=17
12 —7
Pires
oe ye,
_
hl
60 — (119)
~ 15— (-7)
_ 179
Ts
Sani?
i
F e
22
ot
a?
_39
>
Example. Solve
x+ 3y+4z= 17
0a Ae eae)
YS 2.
17 3 4
3a 1
ro 2 1S]
1 3 4
2 il
0 ik eal
34 + 12 —6-— (16—-9+17)
2+4+0-—(-3+0+1)
40-24
~~ GID
_ 16
<8
=2
eo he
ih”
_lo -2 -1
z 8
__—3-—8-— (-17—2)
a 8
_-11+19
pele
=1
liye ee Abe
i peer
as:
8
_4+17—- (-64+3)
i 8
2143
= ere
3
We note in passing that Cramer’s rule will be in some trouble if the de-
nominator determinant has value zero. In fact, if this determinant is zero and
any of the numerator determinants is not zero, the set of equations has no
solution. On the other hand, if the denominator determinant is zero and all
the numerator determinants are also zero, the set of equations has infinitely
many solutions.
Unfortunately, these simply mechanical rules for evaluating second-
and third-order determinants do not extend to higher orders. In numerical
analysis determinants of higher order are not evaluated by any extension of
mechanical rules, but interestingly enough their values can be found as by-
products of the elementary row operation techniques we presented in the last
section. Cramer’s rule is very seldom used in numerical analysis. Sets of
many simultaneous linear equations are solved by the process of elimination,
iteration, or by the matrix methods using elementary row (or column) opera-
tions! Cramer’s rule is often used by people who have only two or three
simultaneous equations to solve.
EXERCISES
eee
(a) |4 5 6
WH ws &
ie pee wee
(b) |2 3 4
De Se
3 —2 -6
(a) a-| iene d
=) ee?
45 6
a= 2 3
65 90.12
5.17 For the following matrices A and B, find det A, det B, det (A + B),
det (A X B), det A + det B, det A X det B:
wa-[f 3] [29
5.18 Use Cramer’s rule to solve the following:
3x + 5y = 56
Eaoeeraee,
6s + 5t = 23
(b) ee
Bee PAY) a eye ———
o fa Y= 26
5x + 7y + 4z= 23
r+4s—5t= 0
(d) [s+ t=—6
4r+3s+5t= 14
3x+ 5y= 7
o fem ae
has no solutions;
b
2X liso,
J
( eet aes
det At =
det A
DPM RSE
ope ee a
a-| 4 1 :
=, 22 1S
We shall call f(x) a polynomial function of degree n if it has the form a,x”
+ Ayyx" 1+ + > + + a,x + a,x + dy, where n is a positive integer. In mathe-
matical analysis, the coefficients a; are real numbers. But, as you recall, in
numerical analysis all real numbers must be approximated by a rational number
in decimal form found by truncating the decimal form of the real number after
a suitable number of significant figures. Thus, in actual practice the coeffi-
cients in the polynomial function are decimal rational numbers approximating,
if necessary, the real coefficients. For example, the function V2x° +5 ae:
155
6.2 COMPLEX NUMBERS
(a+ bi)+(c+di)=(at+c)+(b+4)i
Thus, the sum is a complex number whose real part is the (real) sum of the
real parts of the two numbers and whose imaginary part is the (real) sum of
the imaginary parts of the two numbers. For example,
Example
Note that all positive integral powers of i must be one of the numbers
1,—1, i, or—i. In particular, i} =i, i?=—1,i?=—i,i*=1. High powers of
i can be easily calculated by taking note of the fact that i*=1. Thus, i?” =
17473 = (is) or = 13 = —] and 7 482 = j 48072 = —1.
Example
34+i 3+i2+3i
2-31 2-—312+3i
LAS
ee ay
ee 13
o. eek.
B13.
Example
5 = OA
SS ae hai 5
72 4
5DWe”
Example. Solve, by factoring, 3x” — 19x + 20=0. Factoring, we have the fol-
lowing equation:
(3%—
4) (+ —5):=0
Hence, x= “/s or x=5. The method of factoring is useful if the factors can
easily be determined. But consider 2x7—7x+13=0. The left side of this
equation is evidently not easily factored.
b\?
ee b?—4ac
eS
(x | 4a?
b We
== Bile
x+—=+
2a 2a
Thus
(@=1)@—n)=(x-7-i-G 1 BY 24 5) ac
No wonder we could not easily solve this equation by factoring.
pai VASHON 2 8
The quantity b? — 4ac that occurs in the quadratic formula is called the
discriminant of the equation. Since Vb? — 4ac occurs in the formula, it is clear
that the roots r,; and r2 will be real and unequal if b? — 4ac > 0 and will be com-
plex if b> —4ac <0. In the case b? — 4ac = 0, the roots are real and double.
Example. Solve x? —6x +9 using the quadratic formula. a=1, b=—6, and
c=9. Hence, x= (6+ V36
— 36)/2=(6+0)/2. The roots are then
(6+ 0)/2=3 and (6—0)/2=3. Clearly, 3 is a double root. The equation
has two equal roots.
Example. Solve 1/x* + 4/x?—21=0. We let f(x) be 1/x?, and the equation is in
quadratic form. Then 1/x?= (—4+ V16 + 84)/2 = (—4+10)/2. Thus, we
have either 1/x?=3 or 1/x?=—7. In the first case, x» =Y3 and x= +V3/3.
In the second case, x? = —¥7 and x = +(V7/7)i.
Example. Solve 15/x —9 V3/x +4=0. This equation can be written 5(V3/x)?
— 9(V3/x) +4 and hence is in quadratic form with f(x) = V3/x. Using the
quadratic formula, we have V3/x = (9 + V81 — 80)/10 = (9+1)/10. There-
fore, V3/x=1 or V3/x=4%s. In the first case, 3/xk=1 and x=3. In the
second case, 3/x = 1%25 and x =75/16. You can check that each of these is a
root by substituting it into the original equation.
Y — Yo = p(X — x)?
When the equation is written in this form, the point with coordinates (%,Yo)
is the vertex. If p is greater than zero, the parabola opens upward; if p is
negative, the parabola opens downward.
Fig. 6.1
Fig. 6.2
crosses the coordinate axes are useful. Clearly, the parabola above crosses
the x axis at the point where y=0. Setting y=0 in the equation, we solve
for x and discover that the points (0,0) and (—4,0) are the x intercept points.
Similarly, setting x = 0 in the equation, we discover that the curve crosses the
y axis at (0,0). The sketch of the graph of y—4=—(x + 2)” appears in Fig. 6.2.
We note that the line x = —2 is now the axis of symmetry of the parabola.
Example. Find the vertex and intercepts of the parabola y = 4x” — 8x +5 and
sketch it.
We place the equation in standard form as follows: y = 4(x* — 2x) +5=
A(x = 2x-+ 1) +5 —4=4(y = 1)? > Thus, y— l= 4(e— 1)*, the vertexas
at (1,1), and the parabola opens upward, since p=4>0. As for the inter-
cepts, when x = 0, y=5, and so the point (0,5) is the y intercept point. But
now when y = 0, we have 4x” — 8x + 5=0, so that x= (8 + 4i)/2, using the
quadratic formula. This nonreal value for x is algebraic evidence that the
parabola does not intersect the x axis. The sketch in Fig. 6.3 substantiates
this evidence geometrically.
x
| ae =! 0 1 2 3
|
|
4
y 3 1 0 1 1 3
The points are plotted in Fig. 6.4, and a reasonable parabola has been sketched
in just to see whether the idea is feasible. It evidently is. The technique we
now describe will, of course, determine the unique parabola which is “best
fitting’’ by the method of least squares and will undoubtedly not be at all the
parabola we have just sketched in.
Just a note about the use to which one would be able to put the equation
of the best-fitting parabola y=ax’+bx+c. It can be used to interpolate
values of x, that is, to approximate the value y would have for values of x in
the domain [—2,3] which are not data values.
Suppose the parabola we seek has equation y = ax? + bx +c. The co-
efficients a, b, and c of the best-fitting parabola are found by solving the fol-
lowing set of simultaneous linear equations for a, b, and c.
Me& Me & aT
Me iS ° I
wo w
~) + >
<a
ll = as =
o.i] -
ey
pe (——SI
2.] mo eee =i
i] mn
‘%if ]=
LS
ut oi] -
Here the (x;,y;) are the given data points, and n is the number of data
points. The various summations that occur must be computed from the data,
and then the three simultaneous linear equations resulting must be solved for
a,b, and c. To facilitate finding all these sums, the following tabular method
is displayed for the data just given (n=6):
x y x? xe x! xy xy
=? 3 4 =8 16 =6 12
= 1 1 al 1 =I 1
0 0 0 0 0 0
1 1 1 1 1 1 1
2 1 4 8 16 2. “
3 3 9 27, 81 9 27
3 9 19 27 115 5 45
The entries in the last row are the various sums that are requested as
coefficients in the equations above. We then have the following set of equa-
tions to solve:
ee + 105b = 99
35a + 35b= 1
Multiplying the second equation through by 3 and subtracting from the first
equation, we easily eliminate b. We then have 224a = 96, that is, a= %/7.
Then substituting into a+ b= '/s5s, we have b = 35 — 9/7 = —7/s. Now sub-
stituting both a and b into the first original equation, 19a + 3b + 6c =9, we
have 57/7 — &s + 6c =9, from which c = 1%/3s.
The best-fitting parabola has the equation y = 3x?/7 — 2x/5 + 1%7/ss.
More analysis of this example is requested in the exercise set that follows.
EXERCISES
(a) z, + 3z,
(b) i2z12¢ 42,
(c) Z3°
ZOOL
(4) ee ai D2
Ga aes
(e) Phe va
(f) 4iz, — 51z, + 61z3
(g) (23/2)*7
(ajax Aye 30
(b) 22—t=21
(c) 10x2 — 11x -6 =0
(d) 45? = 205.4421
=.0
(e) 9ye 52 y 4.30 —0
(ajar = Ox 40— 0
(b) x2+3x—10=0
(c) 42—4t+1=0
(dy Az 7
(6) Bi, ir
(f) 7x2 -4x +3=0
(g) 2+ 4x+6=0
(h) yy=—7y
(i) 4q2+9=0
Ge ere
i a!
—+=+3=0
(a) a2 2 58
(b) x—2Vx—8=0
48 20 a
Olea elo p=)
(d) #=3F —10=0
(e) x3 — 10x27 +9=0
x—1\? x-—1
20
nS en
6.6 Refer to the parabola y = 3x?/7 — 2x/5 + 1/35 which was the best-
fitting parabola for the curvefitting example given in the text.
Place this equation in standard form and thus determine its vertex.
Then sketch the parabola on a graph which also contains the orig-
inal data points.
6.8 Use the parabola of Exercise 6.6 to estimate y when x = ¥/2 and
when x =—YVa.
6.9 Use the method of least squares to fit each of the following data
sets to the parabola y = ax? + bx +c:
(x3, f(x3))
(X2, f(x2))
Fig. 6.6
If it is 0, then x3 is the root and our work is done. But if f(x3) > 0, the root
must be between x; and x, since f(x.) <0. Similarly, if it had turned out that
f(x3) had been negative, the root r would be between x, and xg [since f(%1) is
positive]. In any case we have somewhat closed in on the root. If we carry
on, following the graph of Fig. 6.6 as our example, we would then proceed to
repeat the process. Again, bisect the interval in which we know the root lies,
this time the interval between x3; and x,. Suppose we let x;= (x, + x3)/2.
Again we calculate f(x,) and by observing its sign decide whether the root now
lies between x3; and x, or between x, and x,. The process consists of repeated
bisection operations as often as desired. Clearly, we shall close down on the
root, and even though the process may be slow and laborious, it cannot fail
to converge to the root. As usual, when laborious but well-defined calcula-
tions confront us, we immediately think of making use of a computer to do
the work. However, let us present just a few steps of the method of bisection
as it is used to solve the cubic equation x* — 3x” — 7x + 5 = 0 originally given
for the root between 0 and 1.
Let us start with x, = Y2,x,=1. Recall that f(#/2) = 0.875 and f(1) =—4.
Now x3 = Y2(x, + x2) =0.75.
We calculate f(0.75) as —1.52. Thus the root
must be between 0.5 and 0.75. Again, we calculate x,= ¥2(0.5 + 0.75) = 0.625.
Now f(0.625) =—0.30 so that the root must be between 0.5 and 0.625, since
f(0.5) = 0.875. Perhaps you will care to proceed and show that the root is
approximately 0.599.
A very useful iterative procedure, which is often used since it converges
to the root rather rapidly, is called Newton's method. The formula we are about
to give is based on the differential calculus and will not be derived here. It
will be sufficient to note first that associated with each polynomial function
if CeCe 5 Ure
2 ek a eas ean Ayx* + a,x + dy is another polynomial function
Now suppose that f(x) =0 has a real root near x, This fact is to be
determined earlier as we did in the previous method. Then, Newton’s method
consists of evaluating the iterative formula
f(x;)
Mee = T= 2 3 RAs
f(%)
The sequence x2, x3, X4, . . . thus generated presumably converges to the root
desired. One naturally takes x, as the first approximate value.
Let us take an example for which we can find the root by analytic
methods just so we can check the result. Let f(x) =x*—3x+1=0. Since
f(2) =—1 and f(3) = 1, this equation has a real root between x = 2 and x =3.
Let us take x, =3 and apply Newton’s method. Now, f(x) =x*—3x+1 so
that f’(x) =2x—3. Newton’s formula for this problem is
ee = 3x; == il
Xi441 —— oes
: : Deg}
x=3
octamer tae
ep = She) Heal
= Oral
13
63
=.
3
Then, i= 2 and
ree ie — Shear Al
ar 2x»
—3
eo 78 ocr
1 16/5
—3
_ 99
21
EXERCISES
6.13 Other iterative methods can be concocted depending upon the in-
genuity of the concocter. For example, to solve x° + 3x—5=0
for the root near 1, one could dream up the iterative formula
xP ar 3X; =)
Xin = Xj tp
10
6.14 To solve x4 + 3x2 — 7 =0, one could maneuver the equation into
Ti FF 1/2
x2 (x? + 3) =7 iC — r= (=)
To find the root near 1, one uses this last formula in an iterative
manner by writing it
7
ET tae br
reer Xj ape)
el
6.16 Write a complete Fortran program to solve the cubic equation given
in Exercise 6.13 using the iterative formula given there.
The function y=a*, a>0O, a #1, is called the exponential function. The
domain of this function is the set of all real numbers, that is, x € (~,—°).
Let us discover some properties of this function by drawing its graph. First,
let a >1. For example, y=2%. We easily calculate the following table of
values:
x y
—2 227= Ya
=i] 21=Y¥e2
0 2=1
1 2'=2
D 2=4
3 27>=8
We plot these points and draw the graph in Fig. 7.1. From the graph we note
that y is positive for all x.y is always increasing with x; that is, the graph
rises continuously as x moves from left to right. y increases rather rapidly
as x becomes more positive and larger. Evidently y = 1 is the y intercept, and
the graph has no x intercept. As x becomes more and more negative, y be-
173
Fig. 7.1
comes closer and closer to zero. We say that a line like y = 0 is a horizontal
asymptote.
Now, suppose 0 <a <1; for example, y= (1/3)”. A table of values
and the graph follow.
x y
=y (/s)?=
al (Ys)4 =3
0 (/3)°=1
1 Cass
2 (7/3)? = Yo
ata’ = qzuty
fee —— r—-y
a
(av)¥ = qty
Fig. 7.3
EXERCISES
7.1 Find y if
(a) y = log, 27
(b) y = log, (7/49)
(c) y = logiy 0.001
(d) y = logs), 16
(e) y = logy 3
(f) y = log; 0.008
These examples and exercises have used special numbers so that the
result would be easy to find by inspection. Suppose one were to be asked,
“What is log; 7?’ In other words, to what power must 3 be raised to give 7?
This power is an irrational number, and the best we can do is to find a rational
approximation to it. Possibly this rational answer appears in some kind of
a table of logarithms. You have already seen an entirely similar situation occur
in trigonometry. Although the sine of 30° and the sine of 45° are easily found
without using trigonometric tables, it is not easy to approximate the sine of
17° without a table (or at least a slide rule). So, as we suspect, tables of the
values of the logarithmic functions have been constructed, and from them we
can read approximate values of both the logarithmic and exponential functions.
We observe that since there are infinitely many bases we could use, probably
we should restrict the bases used in tables to just one or two special ones.
This is precisely what has been done, the bases chosen being 10 and e. The
latter is a very special irrational number which has been given a special name,
as has 7. Logarithms using base 10 are called common logarithms, and those
using base e are called natural logarithms.
We can find the logarithm of N to any base b if we know its common logarithm
and the logarithm of 10 to the base b.
Since most conversions of bases are between bases 10 and e, it would
be sufficient to know that log, 10 = 2.30259 and logiy e = 0.43429.
A
loga ae log, A — log, B (722)
In essence, Eq. (7.1) reduces the problem of multiplying two real num-
bers to that of adding their logarithms and then finding the real number which
EXERCISES
7.3 Suppose p = 14.7 e°-18°. Use natural logarithm tables to find the
elevation h (in miles) at which p is 7.35 lb/in.”.
7.4 Suppose i= 5.0 e**". Use exponential tables to find i when t = 1.5.
else amperes, ¢ in seconds.
Recall that a reasonable method for solving certain types of equations is the
iterative process in which we write the equation in the form x = g(x),
finda
good starting approximation for the root we desire, call it x, and iterate using
the formula
Xi+1 = B(x) 1 3
X= 2.5
I=0
5 X= ALOG(20. — 3.*X)
I=I+1
TE (l= 20) 55,6
6 WRITE (3, 1) X
1 FORMAT (1X, E13.6)
END
EXERCISES
7.5 Write a complete Fortran program using the same iterative formula
to solve the equation e’ + 3x = 20. Again, let x,=2.5. This time,
however, print x after each five iterations. Iterate a total of 20 times.
x= V10 — logy 3x
1 2
or in the form x = 3 GOP =>).
Recall Newton’s method for solving the equation f(x) = 0 for the real
root near X;:
If f(x) has a term be", then the corresponding term in f'(x) is bae*”. If f(x)
has a term b In(ax), then f'(x) contains the term b/x. Recall that f’(x) con-
tains the term anx""' for each term ax" contained in f(x). For example, sup-
pose f(x) = 4e* — 5x3 +3Inx. Thenf’(x) = 8e?* —15x*+ 3/x. The equation
4e?* — 5x3 + 3 In x= 0 has a real root nearx=1. Newton’s iterative formula
is, therefore,
Ne ot 3} In xy Spay
Xin, = Xj y=
ea a Sie, — Iheyer
EXERCISE
Log and semilog graph paper is often used in applications where the graphing
of exponential or logarithmic functions is involved. To understand its con-
struction and use, let us start with a logarithmic coordinate scale instead of the
ordinary uniform scale we have used up to now. As we know, the uniform
scale is one in which each unit length represents the same change in the value
of the variable. A logarithmic scale looks like this:
8 uN
7 te
6 3
4 Ali
;
3
2
1
Se ee
If both coordinate scales of a two-dimensional coordinate system are
logarithmic, it is called log (or log-log). It could look like this:
: aly
ta pea
1 2 3 45576878)
S10
Note, once again, that a point whose coordinates are (5,7) on this type
of graph paper is actually (log 5, log 7) numerically. What the logarithmic
scales do, then, is to automatically take the logarithm of whatever number
is plotted.
These coordinate systems are extremely useful on many occasions.
We shall be presenting some applications to curvefitting, especially to curves
of type y = ab” and y = ax".
First, consider the exponential curve with equation y= ab". We have
already seen in Sec. 7.1 the graph of such a function using the ordinary uni-
form x and y coordinate system. Now suppose we take logarithms base b of
both sides of the equation. Then, log, y = log,(ab") = log, a+ log, b™=
log,a+x. That is, log, y=log,a+x. Now, let y’ = log, y,a=log,a,x' =x.
Then we have the equation y’=a+x’. This is the equation of a straight
line with slope 1 in the (x’,y’) coordinate system. But, since y’ = log, y, if
the (x,y) coordinates of points lying on the curve y = ab” were to be plotted
on semilog graph paper with the y axis logarithmic, the resulting curve would
be a straight line.
= (=)
oO 160
PON
200
160
Semilog and log-log graph paper can often be of assistance in the process
of fitting data toacurve. Recall that any set of data can be fitted to any curve,
and the method of least squares will be of considerable use in finding the best-
fitting curve of the type selected. We still have the important preliminar
y
problem of selecting the type of curve the data should be fitted to. Obviously,
data like the following would not be well fitted by a straight line:
ot -
Even so, a straight line can be fitted, but the deviations of the line from the
data points will be so large as to obviate any further practical use of the linear
equation. For these data, one would do better to select a parabolic type of
function like y = ax* + bx + c.since the data look, at least approximately, very
like a parabola.
The practical way to proceed in this selection process is to first plot the
data points on an ordinary uniform coordinate system. Glance casually at
this plot and select from a list of suitably fitting curves one which seems to
best fit the data. Then to get a very rough idea of the fitting equation, one
could sketch in by hand a curve of that type and, using points on this rough
sketch, find the equation of the curve. The equation would be very approxi-
mate, of course. The better idea would be, after selecting the type of curve
to be fitted, to call upon the good process of the method of least squares to
calculate the various parameters that occur in the equation. At least, one
would be getting the ‘“best” curve of that type.
We have already investigated fitting data to the straight line and to the
parabola, so that if the plotted data (on uniform scale coordinates) appear
either to be in a relatively straight line or to lie near a reasonable parabola,
our choice and further procedure are clear. We can now consider fitting data
to curves of two more types, y = ae” and y=ax". Thus, if we were not pleased
with the fitting to a line or parabola, we could proceed to plot the data on semi-
log paper. Then if the data show up as nearly in a straight line, we could con-
sider fitting the curve y = ae’”. Again we could proceed very roughly from the
straight line, drawn on the semilog plot, that approximates the data; perhaps
from the slope of the line and from its intercepts we could find rough values
for a and b. Or, more profitably, we could proceed directly to a modified ver-
x yi
ty
x4 Yi
, t
the method of least squares fits the data to the line with equation y’ = a + Bx’
if a and B are determined by solving simultaneously the equations
— 2 NX
FR
WN
OF
We discover that when these data are plotted on log-log paper, the points lie
approximately in a straight line. We decide to fit the data to a curve of the
type y= ax". Clearly, we must determine the parameters a and n. This is
how we proceed to linearize the problem. We first take the log of both sides
of y=ax". As before, we end with the linear equation y’ =a-+t Bx', where
y’ = log y, x’ =log x, B=n, and a=log a. We decide to use natural loga-
rithms. We want to use the method of fitting to a straight line that we have
just reviewed. The data used in that method are values of x’ and y’ (not
x
and y). Thus, we must first construct a new set of data from the original
set
in x and y, recalling that y’ = In y and x’ =In x. We construct the
following
new table:
{ 5a + 4.7876 = 12.838
4.787a + 6.2008 = 13.119
EXERCISES
7.9 Use the method of this section to fit the following data to the more
appropriate form of y = ax" and y = ae”:
y (b) x y (ex *
‘aa Je Se
|
(a) x y (D) # ex y
—3 | 5.64 0.1 6.69
S| ne 0.4 9.39
1 34s 0.6 | 10.60
Ose 2:83 0.8 | 12.90
Ds 78 1.0 | 18.00
Sale 1,42 11h. 10
4 erie 1.3 | 24.60
1.5 | 32.40
We note that as more terms are added on, the sum increases but at a much
slower pace. We would suspect (and you can verify this) that adding on the
next term of the series (0.2)°/625 would not affect the first four figures of our
present sum. In any case, we note that the number of terms that need be used
to approximate f(x) depends on what x is and also on the required degree of
accuracy. It appears that in our example f(0.2) = 0.20 to two significant fig-
ures [using the approximation f(x) = x], f(0.2) = 0.202 to three significant
figures [using the approximation f(x) = x + x°/5], f(0.2) = 0.2016 to four sig-
nificant figures [using the approximation f(x) = x + x3/5 + x°/25], and f(0.2) =
0.20161 to five significant figures (using the first four terms of the series).
These approximations, like f(x) = x + x?/5, are simply truncations of the series
and are simple polynomial approximations to f(x).
Suppose we desire the value off(x) to be accurate to four decimal places.
We could proceed like this. Start evaluating and adding the terms of the
series one by one. After each addition, see if the absolute value of the differ-
ence between the new approximate sum and the immediately preceding one is
less than 5 X 10°°. When this occurs, the new sum would have to be accurate
to four decimal places. In our example above, f,(0.2) =0.2, and f,(0.2) =
0.2 + 0.0016 = 0.2016. Now |f, — f,| = 0.0016, which is greater than 5 x 107°,
so we proceed to the next term. f3(0.2) =0.2016128. Now f; — f,=0.0000128,
which is less than 5 X 10-°. We stop and take 0.2016 as the result desired.
Such a general procedure would obviously be amenable to computer pro-
gramming.
x3 x? x7 (ail )ecneae
Ae Eee oreo
7.13 Calculate f(0.1) and f(0.5) correct to four decimal places if
eo he
La aura ate BHO © cae
2
(i= pete ele oe for0 <x <2
2! n!
in intervals of 0.1, that is, for x—0, 0.1,0.2, 0.3,.°. « ,1-9, 2.0.
Each value is to be correct to four decimal places. Print each x,
the corresponding value of f(x), and the value of e*. Recall the
Fortran library function EXP(X).
x? x4 x"
SAR we Saree ayo Py areal il ae lt a~°) (7.4)
Inx=(x-1) -S54 ss 2
Go = 3
perineal VCE = n = n
|
nN
O<x<2 (75)
After each series its interval of convergence is given. We have included series
for the trigonometric functions sin x and tan”! x to show how extensive the
series representation of functions canbe. You note that series (7.4) is precisely
the one used in Exercise 7.14.
A polynomial can be obtained by truncating any of these power series
after a suitable number of terms. This polynomial can then serve as an ap-
proximation to the function. As you recall, the number of terms one should
use depends on the value of x to be substituted and how accurate the resulting
approximation is required to be. It can be shown that at least 12 terms of
series (7.4) will be required to achieve an accuracy of 10 8if—1 <x <1. This
is not too distressing, but some series, although they surely converge, do it
so slowly that a very much larger number of terms must be used to achieve
accuracy like this. Recall that because of roundoff-error accumulation this
could lead to an almost guaranteed severe loss of accuracy.
It would be very useful if there were more condensed series still repre-
senting f(x) which would converge more rapidly, at least over a certain range
of x, and still ensure the same accuracy. In fact, the computer makes use of
such economized power series rather than the usual power series we have just
given above. We cannot here present how they are derived, but we can point
out some typical examples. Perhaps you will make a further study of this
matter in a course in numerical analysis. For example, the series forIn(1 + x) =
x — 22/2 + x9/3 + x4/4+ - + + ,—1 <x <1, which is obtained from series (7.5)
by replacing x by x +1, is very, very slow to converge. Many hundreds of
terms would be required to achieve any reasonable accuracy, and even then
the result would be suspect because of accumulated roundoff error. C. Hast-
ings, Jr. in “Approximations for Digital Computers,” Princeton University
Press, 1955, has shown that the following polynomial approximates In(1 + x)
to an accuracy of 0.0000015 for all x in the interval 0 < x <1:
Formulas like this are the sort that are actually used in the library function
subprograms of Fortran to compute very efficiently functions like In(1 + x)
and all the other elementary functions like sin x, cos x, tan™' x, and e”.
193
may take on only one of the two values 0 or 1. We note, of course, that these
values are precisely the two digits which are used in binary numbers.
Although we are using the simple switch as our physical realization of
the Boolean variables A, B,C, . . . , any device which operates in two distinct
states can be used. Such devices are called two-state devices, and many of them
are in current use. These include diodes, transistors, and other electronic
components. In these, on and off, the two states, vary from one device to an-
other. We thus have such states as on-off, closed-open, conducting-noncon-
ducting, charged-discharged, magnetized-not magnetized, high voltage-low
voltage, and so forth.
Let us first consider a series circuit of two switches shown in Fig. 8.1. It
seems obvious that current will flow from input to output only if both switches
A and B are closed. Current cannot flow if either A or B is open or if they are
both open.
Associated with each switching circuit is a function of the variables it
contains. This function is called the switching function. The value of this
Boolean function is to reflect the state of the entire circuit—its value will be 1
if the entire circuit is closed and 0 if the entire circuit is open. Clearly, the
switching function depends upon the states of the various switches that com-
pose it. Our first project is to figure out how to write the switching function.
For the series circuit shown in Fig. 8.1 we introduce the operation of
multiplication, and we write the switching function asf=A-B. Wecanread
this function “A and B.” From physical considerations we see that f = 1 only
if both A and B are 1. It is O for all other combinations of states of the switches
A and B. A table of functional values for f can be easily constructed. In this
table we display the value of f for all possible combinations of states of the
switches A and B. Recall that A and B can take on only values 0 or 1. We
have the following table:
A B f= AB
0 0 0
0 1 0
1 0 0
1 1 1
Fig. 8.1
>
4
194 INTRODUCTION TO COMPUTER SCIENCE MATHEMATICS
A
Fig. 8.2
We note that this multiplication table is exactly the same as for ordinary arith-
metic multiplication of binary digits.
We now move naturally to the logic block corresponding to the same
state of affairs. We introduce the AND block as shown in Fig. 8.2.
The AND block has two “wires” to carry in the two inputs and one
“wire” to carry out one output. Signals appear at the two input terminals.
They have “values” of either 0 or 1. In later applications we shall call these
signals binary signals. Recall that we are idealizing an actual circuit, and
actual signals could be, for example, a voltage of some measurable magnitude
appearing at terminal A, none appearing at terminal B. We would say that
A=1, B=0 at this time. The block contains the components (electronic or
otherwise) that react to the two inputs and as a result output A- B. Note that
an output appears only if both A and B have signals. It is this property that
leads us to call this block the AND logic block. The multiplication table given
above for the series circuit switches clearly is to apply.
Consider now the parallel switching circuit shown in Fig. 8.3. Clearly,
a current will be conducted through the circuit if either A or B is on or if they
are bothon. The only way current will not be conducted from input to output
is if A and B are both off. For this circuit, we introduce the operation of addi-
tion, and we associate the switching function f= A+B. We can read this
function “A or B.’’ From physical consideration, the following addition table
is evident:
A B f=A+B
0 0 0
0 1 1
1 0 it
1 1 1
Fig. 8.3
The OR logic block has two input “wires” and one output “wire.” Again
binary signals (0 or 1) appear at the input terminals, and the OR block circuit
outputs the value of f = A + B as given in the addition table above.
The third essential operation in Boolean algebra is that of imversion.
We write A’ and read “not A.” The value of f= A’ is 0 if A is 1 and is 1 if
Ais0. The table is simply
This operation simply inverts the signal and is called inversion. The inver-
sion logic block is
To review, in Boolean algebra there are two constants 0 and 1, any num-
ber of variables denoted by letters like A,B,C,D,..., and three basic oper-
ations: multiplication (AND), addition (OR), and inversion (I). Recall that
a variable can take on different values (either 0 or 1) at different times. At
any given time it has one of the values 0 or 1. We note that 0 and 1 are the
binary digits from which numbers in the binary system are constructed, and
we are looking forward eagerly to see how logic blocks and other logic circuits
can be used to store and manipulate binary numbers and possibly add them.
Finally, physically a binary signal (digit) can be thought of as appearing on a
We have already accepted the following identities for the constants 0 and 1:
0'=
v=
0+0=0
0+1=1+0
=1+1
1:-1=
0O:-1= 0
=0-0
Example. f = AB + C’
A B
A B
A Cc
& D
(AB)
(AB + C)
f = A(AB +
+
C + C’'D)
I
(AB +C+C’'D)
(CD)
So that you may trace the development of the function, we have shown the
output of each block. The presence of both C and C’ in the switching circuit
diagram means that a switch is in essence ganged or coupled from two switches
that operate together but oppositely so that when one is open the other is
closed. Note that we read the figures from left to right; thus arrows indicating
the flow direction are not necessary.
Oe
THE LOGIC BLOCK DIAGRAM
In the switching circuit the presence of two switches named A (or B) indicates
that these two switches are ganged and act together simultaneously either both
open or both closed. The block diagram shows two A, B, C, D inputs in order
to simplify the geometry of the diagram. Actually, the signal on A appears
simultaneously at both input wires labeled A. For these diagrams suppose
that at a certain time A=1,B=1,C=1,andD=0. We find the value of f
in different ways.
f = ABCD’ + C(AB + D)
= (1) (1) (1) (0) +1(1 - 1+ 0)
ha hot boa ees eG oom vee Beg
=1+1+0
=]
A+0=A
Dual: A:1=A
A | f=A+0
0 0
1 1
Aas 0i—10
DvalwAcle—sl
A O
A f=A-0
0 0
1 0
A:-A=A
Dual: A+A=A
A f=A-A
0 0
1 1
Ansa
Dual:
A: A'’=0
A’
A
Peet
Notice that if A is closed, the circuit is closed regardless of the state of B.
If A is open, the circuit is open, again regardless of the state of B.
OO
CO
pe FP
Oro
Recall that to use a truth table with two variables, we must list every
combination of possible values of the variables. There are four such combi-
nations as shown. This law will be used quite often in the simplification
procedures that we shall be eventually concerned with.
0 Ono 0 0 0 0 0
0 OR 1 0 0 0 0
0 ee 1 0 0 0 0
0 Hal 1 0 0 0 0
1 One) 0 0 0 Oe 0
1 al 1 1 0 1 1
1 iO 1 1 1 0 1
1 eal 1 1 1 il 1
The two preceding examples are given to show how some of the identi-
ties already covered can be used to simplify Boolean expressions. In Sec. 8.5
we present a much more satisfactory method for the simplification process,
one which does not require complicated selective choices of identities but
which instead automatically uses identities by means of a semigraphical pro-
cedure. This is the method of Karnaugh maps.
Now we present some more identities concerning inversion. First,
we want to allow expressions to be inverted such as (A+ B’ + C)’ and we
A A’ |A”
0 1 0
1 0 1
A B AB (AB)’ A’ B' Ai + B:
>)
ll Pp
©
OF =) FP
He
or Ff
coor
orFoOor KF
eS
or
Since the entries in the column headed (AB)’ and those in the column headed
A' + B’ are identical for every set of values of A and B, De Morgan’s law,
(AB)' = A’ + B’, is an identity. It and its dual are very important and useful
identities. The laws naturally extend to finding the inverse of the sum of
any number of variables or the inverse of the product of any number of vari-
ables. For example, (A+B+C+D+E)'=A'B'C'D'E' and (ABCD)'=
A' + B'+C'+D'. Using De Morgan’s law and the distributive law, one can
multiply out a complicated expression like [C(A+D)' + E’]’ into a simple
sum form. Thus,
Now only three switches are needed, a saving of four switches. This is a re-
duction in cost of whatever physical element the switches represent. Recall
that they may be mechanical switches, diodes, transistors, or other types of
devices, and still we represent their operation, circuit, and simplification as
we have done for simple, manually operated on-off switches.
The process of simplifying a function to its absolute minimum form is
a major and most important phase in design. However, often several equiv-
alent minimum forms result. If the expression to be simplified is not too
EXERCISES
8.1 Draw switching circuits which realize each of the following Boolean
functions:
(a)f=A+B'C
OFC Gay
(c) f= (ABCD + E+ F)G
(d) f= (AB! + A’B + AB) (A+ B+C)
(ec) f=D(A' +B +C’)+E(C'+D’) +F
8.2 Draw logic block diagrams using [+], [-], and [I ] which realize
each of the Boolean functions of Exercise 8.1.
8.3 Draw logic block diagrams which realize each of the following
Boolean functions. Do not simplify first.
8.4 Write the switching function f for each of the following switching
circuits:
8.5 Draw the logic block diagram corresponding to each of the switch-
ing circuits of Exercise 8.4.
8.7 Use the truth table method to verify the following identities:
(a) (A+B)(A'+B)=B
(b) B(B+C)=B
() A(A+B+C)=A
(dy (A> BC)’ — ABC
Example. The expression AB + A’B’ is in sum normal form in the two variables
A and B. But, clearly, the expression A+ AB is not. Also, ABC + AB’C
+ A’BC’ is in sum normal form in the three variables A, B, and C. (A+C)’
+ BC is not. First we show how any expression can be put into sum normal
form. The importance and the uses of the form will become evident as we
proceed. Several examples follow which reveal the procedure.
Example. Place the expression A+B in sum normal form in the variables A
and B.
We note that the first term A does not contain the variable B. But
A=A-+1=A(B+ B’) = AB + AB’ is equivalent to A and contains terms each
of which has both of the variables A and B. Similarly, B= (A+ A’)B=
AB+A'B. The result is A+B=AB+ AB’ + AB+ A’B=AB+ AB’'+A’B,
the sum normal form.
Example. Place the expression A + B in sum normal form in the three variables
JAN, 183, aiael (C-
A=A-1-1
= A(B+B')(C+C’)
= ABC + ABC’ + AB’C + AB’C’
B=B-1-1
=B(A+A’')(C+C’)
= ABC + ABC’ + A'BC + A'BC’
Thus,
A B Cc
1 0 0
0 1 0
0 1 1
A B Cc f
0 il il 1
il 0 1
0 0 0 1
and f is 0 otherwise.
An interesting note: If f is written in sum normal form, then f’ consists
of those terms of the complete sum normal form which are not present in f.
Thus, if f= AB’ + A'B + A’B’, then f’=AB. You may check this by other
means. If the values of f are read from a truth table, then f’ consists of those
terms for which f has value 0.
There is the dual normal product form in which the function is represented
as the product of factors, each of which contains the sum of each of the vari-
ables in either inverted or noninverted form. For example, (A + B)(A’ + B’)
is in product normal form in the two variables A and B; A+ B’(A + B) is not.
Similarly, (A + B+ C’)(A' + B’ +C’')(A +B’ +C) is in product normal form;
A+ BC’ isnot. Since we shall not be making use of this form, which is equiv-
alent to the sum form for a given function f, we shall not discuss its properties
further.
EXERCISES
8.8 Place each of the following functions in sum normal form in two
variables, A and B:
(a) A
(b) “CAC Es
(@) Adar ley
8.9 Place each of the functions in Exercise 8.8 in sum normal form in
three variables, A, B, and C.
8.10 Place each of the following functions in sum normal form in three
variables, A, B, and C:
(a)-B +c’
(b) A+ B'C
(a) BC'+D
(b) ABC + C'D
(c) A+ BCD'
(d) (AB'C)’
(ec) A+B+C+D'
One of the most used methods to simplify Boolean functions is the Karnaugh
map. This method provides a definite procedure, a specific way, to simplify
any Boolean expression.
Recall that if f is a function of two variables, we can display it as in the
following truth table:
A B f
iT
0 0 1
0 if 0
1 0 0
1 1 1
Note the 2” = 4 squares to allow for the four possible terms in the complete
sum normal form for a function of two variables. The values of A are read
across the top, B down the left. The upper block is thus the space for A = 0,
B=0. We place a 1 in those blocks corresponding to those pairs of values
of A and B for which f has value 1. It is common practice to assume that for
all blocks left empty the function has value 0.
For three variables we shall require a map with 2?=8 blocks. The
A
BC Q a
OO
Omar
Let
i ©
——
Again it is clear that the importance of the sum normal form emerges. In
order to fill in the appropriate squares to represent a function, the function
must first have been expressed in sum normal form. Each block of the map
represents a certain term in the complete sum normal form. A 1 is placed in
each block which corresponds to the occurrence of a term of the sum normal
form of f.
For four variables, 16 blocks are necessary. The map is as follows:
AB
CD OG Ost ai 1
ORO
Ot
1 1
Lt @
Although we shall not use them here, Karnaugh maps can be constructed
for functions of five or six variables rather easily. Here is the map for five
variables:
A 0 1
BC BC
DE 0 Ott Sitter tO DE OO "Ud Lt ooo
O20 0 O
ap a i aaat
Pal
lope 1ae
| | | |
176 Peed
Example
Xo
BC
ORO
0 1
heen
ORES eel
Le: 1
ik XY a
f= AlB'C + ABC
Example
AB
CD ORO Oe ie 1 30
T ir ]
ie ie) |
0 1 | | 1
tea va es |
FPO | |
We have two basic problems: (1) Reading into the map any function no
matter what form it is originally in, and (2) reading out the most simplified
equivalent form for f. Let us consider the first problem, first for functions of
three variables. Any function of three variables after having been freed of
all parentheses by the use of De Morgan’s law, the double complementation
law, and the distributive law, will then contain terms of three kinds: Terms
which contain only one variable, terms which contain two variables, and terms
which contain all three variables. For each of the terms containing three vari-
ables we simply mark a 1 in the corresponding square of the map. For the
two- and one-variable terms we could proceed algebraically, expanding them
to three-variable terms, that is, placing f in sum normal form. Thus, if the
term is AB, we could write AB = AB(C + C’) = ABC + ABC’ and then place a
1 in each of the squares corresponding to ABC and ABC’. However, we want
0 0
a) 4 earive’
hoi 1
il © 1
Ae eal
A
BC 0 lia
OmO
Ome
Le ie 1
i @ | a 1
A
BC @ il
oy @ | 4 1
(dy al il
iho A 1
i 1
We note that a three-variable term requires only one block to display it, a two-
variable term requires two blocks, and a one-variable term requires four blocks.
The term ACD will be read in by placing a 1 in two blocks, the two blocks for
which A= 1, C=1, D=1, regardless of what B is. Now consider the func-
tion f=A+CD. It maps as follows:
AB
CD OA Ora ah al ai)
0 0 | | il 1
0 1 | 1 1
We note that the two terms generate 1s in some of the same squares. A single
1 is placed in the squares where they overlap. In the example above, the A
term causes the eight 1s appearing in the third and fourth columns; the CD
term causes the four 1s appearing in the third row. They overlap in the third
and fourth columns.
1 1 |
mil) |
1 0 il 1 il il
EXERCISES
CO ere
(b) f=A+t+B’
(c) f= AB! + A'B
(d) f=AB+ A’ +B’
(a) f=A+B
(b) f=A+BC’
(c) f= ABC’ + A'C’
(d)f=A+B'+C
(e) f= AB+A'C
+ BC’
(a)f=A+D
(b) f= AB+C'D + AB'C
(c) f= ABCD’ + A’ + BIC
(d) f=A+B+C+B'D+CD'
(e) f= ABCD’ + AB'C’D + A'BC'D
(a)f=C+D+E'
(b) f= AE + CDE
(c) f= ABCE’ + A'D + C'
(d) f= E+ (CD! + ABC + AB'CDE'
(e) f= ABC'DE + AB'C'D'E’ + A'B'CD'E
We now turn to the essential part of this section—the reading out of the
most simplified form of a function that has been plotted on a Karnaugh map.
This is equivalent, of course, to simplifying a given function, a process most
important in logic design.
1 0 1
Notice that when two 1s are adjacent, the terms corresponding to the 1s
differ in just one variable. For the marked two-loop, the terms are ABC’D’
and ABC’D—they differ in the D’s only. Note that ABC’D' + ABC'’D =
ABC'(D + D') = ABC’ so that this looped pair of 1s is read out as ABC’ (which
contains the same variables which did not change in the two adjacent squares).
For the bottom loop, the two terms are A’B'CD’ and AB’CD’. Thus, they add
up to B’CD’. We note that the read-out of a two-loop always contains one
less variable than the total number of variables of the map.
A 4-loop contains four 1s which are adjacent in the sense that the terms
corresponding to the four 1s contain two variables which remain constant.
Here are some examples of four-loops.
AB
CD 6 0801. 1h 1:0
0 0 (1)
a wo 1
+
ie 1
1 0 Ly
AB
CD COU ESa es Nu
OO
Oneal
ew
I [ 1
dye Oe t 1 1 1)
Clearly, C and D’ remain constant. Hence, f=CD’. Let us check this read-
out algebraically. First,
AB
CD OOD ON ees TO
an)
Om
AB
CD Ot Oe
0 0 1 il
0 il it 1
1 1
1 0
f= AC’
Note that the example below is not a 4-loop; however, it is two 2-loops. Thus,
f=B'C'’D' + B'CD.
AB
CD sae ns ae ie I ar
Te mS 1G
|
0 1
tc a ieee
T) | r
Ta se |
L
It is clear that the read-out of a 4-loop contains two less variables than
the total number of variables in the map.
An 8-loop (in a map containing three or more variables) is a set of eight
1s which are adjacent in the sense that the terms corresponding to the 1s have
one variable which remains constant. Here are some examples.
AB
CD eg As Os Oe OL
0 O
T =
‘ae (a 1 1 a
Teas 1 1 Thal
tad
fae
fe.
The read-out of an 8-loop contains three less variables than the total
number of variables in the map.
Note that the following is not an 8-loop:
AB
CD OO O@2 17 1
Oo OE 1 1 ig)
Pee tercs i 1 1)
Then, following the read-out schemes given above, proceed to read out
the terms represented by the loops. f is the sum of such terms, and if the loops
Sy Zak
oe
BCU ad
6 0}@)
ch melee.
11 |@pa
inea
AB
Cu Wietinie Sa 30
Cael hl dhl
Cae g leis
i!
a0
AB
CD OO O22 Lt 1g
|
OF ec at
QO 1 a)
1 1
je ot 1D) a
01 10
o~ 0 (1) (1)
Ce are) oy
eet 8 1
1 0 1
AB
CD Te: Pee a es
0 0 |
Cm
eS
ae
O41 Muse
A A A A
BC 0 1 BC a! BC 0 1 BC 0 1
0 0 1 Om 0 0 OR Om met
1 0 1 ik © 1 1 i @ 1 0)
a ee pee
Normally, of course, the separate terms of f are read in directly on the final map
of this sequence—here we are displaying each term’s map for initial clarity.
Then, the read-out of f from the last map is f= A+ B’+C’.
AB
EXERCISES
8.16 Use the looping method to read out the (most) simplified version
of f if its Karnaugh map is:
8.17 Use the looping method to read out the simplified version of f if
its Karnaugh map is:
0 i 1 1 Oo 41
1 1 1 1 1 1
1
1 0 1 il it
AB (d) AB
CD oo 01 i 10 CD OO O88 2th 10
OO 1 1 ORO i
0 if 1 1 il 1 Ol 1 1 1
4
1 1 1 1 1 1 1 1 1
+
1 0 1 i © (|
a
(e) AB (f) AB
CD (OMe Onis) ele 1a0 CD
OREO 1 1 1 oe
0 1 1 1 Ome!
if 1 1
ioe 10 1 1 hy
(g) AB (h) AB
SD, ‘oe a Se) Dp
in
ORO a 1 of O @ 1 1
One! 1 1 One 1 1 1
1 1 1 1 1 L | 1
i 1 i) 1
AB (j) AB
CD CeO Geral at aE ie CD
0 60 1 1 1 0 860
Ome! it Oe il il il
1 1 1 i 1 1 1 1 1
0 1 1 1 1 1
8.21 Write the switching function directly for each of the following
switching circuits. Read f into an appropriate Karnaugh map,
read out simplified f, and draw the corresponding simplified
switching circuit.
We have seen that any Boolean function can be realized (that is, constructed)
from the three elemental logic blocks AND, OR, and INVERTER. In fact,
however, just the two blocks AND and INVERTER are sufficient. To show
that this is so, we make good use of De Morgan’s law: (A’B’)' = (A’)' + (B')' =
A+B. Thus,
0 f=(A’ B’)’'=A+B
and A+B can be constructed using the operations of - and inversion. Ina
similar way, the blocks OR and INVERTER are sufficient, since (A' + B')'=
(A')'(B')' = AB, so that
f= AB
A B f
0 0 1
0 i 1
1 0 1
1 1 0
from which we read (simplified) f as A’ + B’. Thus, the single NAND block
diagram
AO
The output of the first NAND block is A’ + B’ and that of the second block is
the inversion of its input, namely, (A’ + B’)’ which reduces to AB. Therefore,
NAND is functionally complete.
Incidentally, OR can also be implemented using NAND alone. Alge-
braically, A ++ B= (A')’ + (B’)’ so that
We can realize any Boolean function using NAND alone. For example,
consider f= A+BC’. A+BC'=(A')'’+ (B'+C)’, and we should therefore
NAND A’ and B’+C. We know how to get A’. As for B’ + C, itis B’ + (C’)’
and is thus formed by NANDing B and C’. We can easily construct C’, so
=A+ BC’
Ao
N+ o ¢ and f has the following Karnaugh map:
Bo
A
B Oa
@ | i 0
i | 0
Thus, f = A’B’, the dual of A’ + B’. Again we show that NOR is functionally
complete by showing that INVERT and AND can be implemented using NOR
alone.
First, Ao N+ O A’
O f= (a’)' (B')' = AB
Any Boolean function can be implemented using NOR alone. Many times a
judicious use of De Morgan’s laws can reduce the number of NOR blocks nec-
essary to implement a function. Consider f= A’B+C. We could construct
this function directly by simply using developments for + and - given above.
We would then have
But now consider that A’B + C can be written as [(A’B)'C’]’ and this can be
written {[A’(B’)']’C’}. Thus we have the following circuit:
A'(B')' [A'(B’)']'C’
0 A'B+C
A
B Oe al
0 1
pti) a
EXERCISES
8.22 Recall the EXCLUSIVE OR logic block [E+ discussed above:
A
(a) AD B=BQA
(b) A(B G) C) = (AB) G (AC)
(c) A+ (BGC) = (A+B) @ (A+C)
8.23 Prove that the set {[E+], |+]} is functionally complete. Assume
that constants 0 and 1 are available as inputs.
Oo f=A+B
0 1 1
1 1 1 1 1 1
| a
1 0 1 1
(a) Draw the logic circuit which realizes f using the logic blocks
Pad [eiand {1}.
(b) Draw a logic circuit using ee and only.
(c) Draw a logic circuit using only.
8.27 A logic block called IMPLICATION denoted by IMP has two in-
puts denoted by Aand B. The output is 1 unless A = 1 and B= 0.
We write algebraically A — B.
(a) Place the values of f= A-— B in a Karnaugh map and show
that f= A’ + B.
(b) Assuming that constants 0 and 1 are available as inputs, show
that is functionally complete.
(c) Draw a logic circuit which realizes f=A’ + BC using [IMP]
only.
We now turn to some of the ways Boolean algebra and logic block circuits are
used to design circuits that perform arithmetic in the digital computer. Addi-
tion is the basic operation; binary numbers are used. Recall that the other
operations can all be reduced to addition. We first reinterpret the values 0
and 1 that Boolean variables take on. Let us now consider that when a signal
appears on a “wire” the binary digit or bit 1 is present at that input position,
and when no signal appears on a wire the binary bit 0 is present.
We first construct what is called a half-adder. It is a logic circuit which
actually adds two binary bits. Recall the arithmetic of adding binary digits:
+t or + ANS + Se
S
i oO (=)= Ooeat > So
A
B 0 1
® |@ 1
i | at 0
From this table we read out the sum digit function fs = AB’ + A’B. We can
implement f; in various ways using the methods of Sec. 8.6. Any functionally
complete set of logic blocks can be used. We note, incidentally, that AB’ + A’B
recalls the logic block EXCLUSIVE OR, E+]. However, we shall here revert
to the more basic set {|+ iy -|,|I}}. We thus have the following logic circuit
for fs:
O fy = AB’ + A’'B
In this diagram we have repeated the inputs A and B rather than introduce
“wires’’ that cross each other.
The lefthand digit in the sum above is called the carry digit. We can
plot its values in a table:
A
B Oma
0
1 1
from which we read the carry function fc = AB. The simple logic circuit
which realizes this function appears thus:
fe
fs
110111
+ 111001
A
BC Oma
0 0 1
@) ih ia
ih 1
i @ | a
0 0
Omi
al =a
iy
1 0 1
Using the three 2-loops, we read out fe = AC + BC+ AB. The full-adder is
denoted thus:
O fo (= AC + BC + AB)
We now want to construct the logic block diagram for the full-adder. We
first
present a circuit drawn directly from the function for f; and fc given
above.
This last sum is precisely f; except for the term ABC. In our new circuit we
plan to first construct f¢,as we did above. Then we shallimplement A + B+ C
and f; and, making use of the algebra just shown, implement all f; except for
the term ABC. This term will be implemented separately and addedin. This
is the new circuit:
Oie | fo
oO O
io)
We have now used just one inverter, five ANDs, and three ORs, a total of six
less of these blocks.
Our last project will be to put together a collection of adders to com-
pose a circuit which will add two binary numbers. Suppose we take two
four-digit binary numbers which we shall denote by X4Xs%2X, and Y4Ys¥oY1,
+ YaYsYo¥i
G5 iss
Example
1011
+ 1001
10100
There are many ways to construct such a circuit. We shall show two ways.
The first method uses just one full-adder over and over again. An important
facet of the process that we shall not be able to discuss is the timing and se-
quencing of the appearance of the various signals to the input of the adder.
To make this first method work properly will evidently require an elaborate
network of preliminary timing and sequencing circuits. The proper alloca-
tion of the output of the adder will also be required so as to produce the cor-
rect sum. Here is how this method works. Ata certain appropriate time t,,
the signals representing 0, x,, and y, appear at the input terminals of the full-
adder. The sum digit output s, is transmitted away and saved. At the next
appropriate time ft, (after a certain delay), the carry digit output c, is moved to
the input of the adder and at the same time the next two digit signals x, and
Y2 are inputted to the adder. Once again the sum digit s, is transmitted and
saved; once again the carry digit c, is fed into the adder together with the next
two digits x, and y;. This occurs again, after a suitable delay, at time t;. The
process is repeated until s, has been transmitted and saved. At this time the
carry digit c, is actually the sum digit s;._ It can then be transmitted as s, and
the sum 555453535, displayed. Another method would be to carry c, once again
as input to the adder and cause 0 and 0 to also be fed in as input. The output
would then be s, with carry digit 0. A pictorial view of this method follows.
Note that only one FA is used.
The second scheme uses as many full-adders as there are digits in the
sum. All the digits of both of the numbers to be added are fed in to the set
of full-adders at one time instead of sequentially. The pictorial view we have
just given can be used for this method, too. The sequencing times f; will not
appear, however. Instead, at the appropriate time t, preceding circuitry will
cause all the x; and y; and the required Os to appear at the designated input
terminals. The signals would then be held until the output signals s; appear.
At time tg:
At time tg:
At time tq:
Different preliminary circuitry and five full-adders are used in this method.
The careful sequencing of sets of digits we used in the previous method is
eliminated but at the expense of supplying four additional full-adders.
EXERCISES
8.30 Think about how the circuit of full-adders (either version) which
adds two four-digit binary numbers could be used to subtract two
binary numbers. Recall the subtraction methods presented in
Chap. 1.
Chapter 1
243
(2) co29 (i) 89.5 104769250
3)987 335. 46.7. 13) 136.2
329, 136.2
6.389 10.47692 . . . 0.906
335.389 — 9.57
0.90692...
1.13 (a) 64280. 64300. [6]
3] 7] 2][+]0]0[5
23.75 — 575
64303.75 63725
(cman Si Slee
7) 8.27 1.181 8] 0] 8] 2] [+ [0] 0 [o
— 0.3728
0.8082
(e) 8.37 9.027 26.40 1[ 2] 4] 6] [+ Jo Jo [3 |
0.6578 17.379 4.72
9.0278 26.406 5280
18480
10560
124.6080
(g) 56.78 125.5 171.1 34.075
68.79 45.68 — 34.77 4)136.3
125.57 171.18 136.33
3] 4] 0] 7|[+]o[o[2
1.14 (a) [6]3|7]|+| 015 (c) [8{ 0] 7]|[+[o][o]
(e) [1]
2] 4][+]0]3 (gs) [3] 3]7][+]0]2
1.15 (a) [6]41712]181 (41015 () [8[ 0[ 8 [6] 0] [+]0 Jo]
(e) [12] 4[6[3][+[0[3] (g) [8] 4/1]2] 0] [4]
0] 2]
Chapter2
2.1 (a) 989 (c) 10995 (e) 425. = (g) 194 (i):317
2.2 (a) ?%/49 = 0.(591836734693879) = 0.59183
(c) 195°/3125 = 0.62688 (0) = 0.62688
(e) 2999/4096= 0.732177 . . . = 0.73217
(g) 9/243 = 0.374485 . . . = 0.37448
(i) 18/128 = 0.1015625(0) = 0.10156
2.3 (a) 11.(5) — (c):19.488(0) ~(e) 123.60351 ... = (g) 136.5(0)
(i) 1845.69822 .. .
2.5 (a) 10011110112), 213234), 10020(5) (c) 110111204), 110110(), 23346.)
(e) 10000221100(3), 355523(7), 42467 (41)
0001
0110
0010
0110
0011
1 a 3
(e) Decimal Binary coded
[47 3 0001 0100 0111 #0011
Dee eo 1001. 0010 0100 0011
102 nantes 6 1010#%# 0110 1011#% 0110
0110 OLl0 sr
0001 0000 0111 0001 # 0110
1 0 7 1 6
Chapter 3
3.8 Y= x — 6,x=4(6 + y) 1?
3.10 f(x +h) — f(x) = 2xh + h?
ms = Oe: 4(5+ 1)
3,11 2(5)
= Yio; (e— 5 y=
é =
8 8 See tr) jd!
(1.2) ih il
=—6;h (7,5) =2—4
Lo 4
3.12 h(1,2) =—6; h (-, =)=——= ; + a;(3,0)
= =2%
3.13 G(0,0,2) = 4; G(1,0,s) = 1+ s G(—1,—1—3) =13
3.14 (a) x + 5y = 23 (c) y=1 (e) x=5
3.16 (a) m=1 (c) m=1 (e) m=0
oh
Onl7 CR So (c) y=6x+4 > (6). Se —=3y 19 =0
ard) P= 432
2) 0
(c), ————4$—4+4+— x
0 2 V2
(fp) ———— + +
=o) a 2 5 uf
a oe ee ey ae i)
=3 2 Ye
(c) 9f DES FAS Y/
Yj VY,
les
Zz
(c)
[iS
=i DG ee 4a+ 4b=—10
Con 1 0 Pere 4a + 14b = —36
Me tg far Te ys y=04—2.6x
5.8 89 Boe pay
See 45-108 14a a=0.4
3.40 x y x xy
Gy ose IS ara S
7. & S49 0035
Chapter 4
Chapter 5
Be DIMENSION A(40)
I=]
25 READ Y(27 1) ACI)
1 FORMAT (F6.0)
=f BN)
ASB
x B= lis x B) =— 1184
4 det(A X
5.19 (a)x=Mal
ie aly) le Eb)
y= ita
(0-7), (4.1), (42.0), (8-1)
eae. eagle | a =|
5.21 Let A= k a: Then A1t= ee ee |=
d —b
ad—bce ad—bce De hdd ts
=e a peo ede: ~ (ad—bc)?
ad—be deta
dd ve sad— pe
Chapter 6
F : ils} ia =
Galea) lO; (C321 (e B 13! (g) -1
(ye) 0) Gps
64 (a) x=—43,x=—1 (c) = 3/19, x = Yo (e) x=27,x=1
69) y=artey-Z
6.11 (c) f(x) = x° — 87, f(4) =—23, f(5) = 38
f(4.5) = (4.5)3 — 87 = 91.125 — 87 = 4.125
f(4.75) = 20.17
f(4.37) = —3.55
f(4.43) = —0.062
f(4.46) = 1.717
f(4.45) = 1.121
f(4.44) = 0.528
Thus, x = 4.43
6,120 (a): x =13% 315i OS Ce) ee a eo ee
right side of Newton’s formula is, therefore,
aie ame1D
33 Ves aaa?)
ee aetrelo
Japa! 3 (x? pm 1)
x,=3
We then have
so that x = 2.869.
ee H. |
6.14 x i+1 — x? wa 3 ; xy — ile Thus, Xo>= ve
4 = 1BB23) ey i: i A
a iee
X4
oo
4.475
Ros re
Sy, oa ee 4.56
7
1.24, x5=
a
4.53 = 1.241.
Thus,
x= 1.241. Check: x4+3x2—-7=0,x NF an
so that x = 1.24.
6.15 X=1.
is!
1 OS (CA ODS Ses)
I=I+1
[EAT 10) tl 72
2VVRUTEA (373) eX
3 FORMAT (1X, E13.6)
END
Chapter 7
Chapter 8
8.1 (a) A
ele 1 0 1 1
al || ae 1 0 0 0
OF et 1 1 1 1
O | ol 1 1 0
ce f
Oo) Ow 0 0
1 Of © 1 1
il Osi al 1 1
1 it || 6 1 1
1 Tom 1 1
0 ila iV 1 0
0 Lalo 1 0
0 | 0 1 1 0
(ioe i)
| |
(e) Aa BePAB A Al ABs) (Ala AB) 4 Ba AB’
(fi
Teil ail 1 0 1 0 0 0
fells Ola 0) 0 0 1 1 1
ON etal G 1 if 0 0 0
ON Os) 0 1 1 0 1 0
fee
eee Sie
(g)
A\B\C|A+B+C/| A‘ B’\A’ +B'| A’ +B’ +C|(A+B+C)(A’ + B’ + C)| AB’ AB) AB’ + A’B|A'B+ A'B+C
i
Gea Fe
0} 0|0 0 tae 1 1 0 ON 0 0 0
1 0; 1 1 1 1 1 0 il 1
1} 0/0
1}0}1 1 0; 1 x 1 iL 1 0 1 1
1 0/0 0 0 0 0 0 0 0
1; 1/0
if 0; 0 0 1 1 0 0 0 1
Ds
1/0 1 1 1 0 1 ‘il is
0} 1)1 1
1} 0) 1 1 if 0 1 1 1
0/ 1/0 1
iy) Gl 1 1 1 0 0 0 if
0} 0} 1 1
4 i
Omar 1 1 il 1 Oem v1 1 1
=P .
i il 1 1 1 1 th al 1 1 1
‘ee 0 1 1 10 1 1 il 1
(e) AB
CD OO) Ghat wba asd
0 0
|
® 8 1 1
aie +
ee
1
tO 1
ail
OF ow 1 lee 00 1 |1
0 1 1 1 1 1 01 1 1 | 1 1
t =!)
1 1 1 1 1 an 1 il ie il i
1 0 i) © 1 1
0 0 1 0 0
01 1 01
en
tots Lim
see sae | a 1 0
(Ace f=AC+ BC
8.20 (a) AB
CD UL Gok sos Sey)
Ce ene! 1 1 1
4
0 1 1 1 P= Der CAA
A
BC Om 1 A
0 0 1
GP oe em alia! f=At+C =
= re
Le et 1 a
1 0 1
(c)
A’ + (B’+C')'=A'+BC
Of
Of=A’'+BC
8.25 (a) Clearly the output is 1 only if A=1 or B=1 or both A and B
are 1. This is equivalent to A + B. (c) f= AB= (A' + B’)'’
N+ Of
AB'C
A
Ao N+ AB’
N+ N+
8127 (a). SA
=A'+B
1 1 1 f
269
Division of numbers to various bases, Fractional part of number, 3
43-46 decimal value of, 22
using method of repeated Full-adders, 238-242
subtraction, 44—46 Functional notation, 58
Duality, principle of, 201 Functions:
exponential, 173-174
linear, 59
E specification: logarithmic, 175-177
in input, 106 polynomial, 155
in output, 109-110 of several variables, 59
Elementary row operations on
matrices, 140-145
End-around carry, 36 Ganged switches, 199
END statement in Fortran, 111 GO TO statement in Fortran, 116-117
Equation: Graph of a function, 60
definition of, 55 Graph paper, log and semilog,
matrix, 133 181-185
satisfying of, 55 Greatest integer function, 7
Error due to roundoff, 15-16 Grouping, symbols of, 56
Exclusive OR logic block, 230
Exponential functions, 173-174
Exponentiation, 54 Half-adders, 235-237
laws of, 175 Hexadecimal number system, 19
Expressions: digits of, 20
algebraic, 53-55 Hierarchy of operations, 54
integer, in Fortran, 97
mixed, in Fortran, 97
Extended precision, 15 I specification in Fortran, 106
IF statement in Fortran, 118-120
Inequalities, 69-77
F specifications in Fortran, 106, 109 linear: in one variable, 69-73
Flowcharts, 117-118 in two variables, 75-77
symbols used in, 118 Infinity, 70
Format statements in Fortran: Input-output statements in Fortran,
position in programs of, 114 91, 104-110
with READ statement, 106 Input unit of computer, 89
with WRITE statement, 108 Integer constants in Fortran, 94—95
Fortran: Integer mode in Fortran, 98
arithmetic statements in, 94-103 Integer variables in Fortran, 95—96
coding sheets for, 92-93 Integers, 3
control statements in, 116-123 Integral part of numbers, 3, 19
input and output statements in, Intercepts, 64
104-110 IBM cards, 93-94
programs in, 92, 111-114 Interval of convergence of power
Fractional decimal numbers into series, 188
other bases, 26-28 Intervals, 70
270 INDEX
Inverse matrix, 138-145 Logic blocks:
Inverter logic block, 196 AND, 195
Irrational numbers, 4, 9 exclusive OR, 233
Iterative methods, 169-172 functionally complete set of, 230
solution of equations using, IMP, 233
178-179 inverter, 196
MAJ, 232
NAND, 230
Karnaugh maps, 213-226 NOR, 232
loops in, 219-222 OR, 196
Loops in Karnaugh maps, 219-222
rules concerning, 222
rules concerning, 222
plotting function in, 215-217
reading functions out from,
218-226
Machine language, 90
standard forms of, 213-214
MAJ logic block, 234
Keypunch, 93
Mantissa of number, 8
Matrices, 131-147
addition of, 133-134
Language, machine and symbolic, column, 132
90-91 diagonal, 132
Laws of exponents, 175 elementary row operations on,
Least squares, method of, 32, 82-84, 140-145
102, 185 equivalent, 141
Line: inverse of, 138-145
fitting data to, 82-86 lower triangular, 132
point-slope form of equation of, 63 multiplication of, 134-136
slope of, 63 row, 132
slope-intercept form of equation of, scalar multiple of, 134
64 unit, 132, 142-143
two-point form of equation of, 62 upper triangular, 132
Linear equations: zero, 133
matrix solution of, 137-138 Method of least squares, 32, 82-84,
simultaneous, 65-68 102, 185
Linear functions, 59 Multiplication:
Linear inequalities, 69-77 of decimal numbers, 13
in one variable, 69-73 of matrices, 134-136
simultaneous, 73 of numbers to various bases, 39-41
solution of, 72-73
in two variables, 75-77
Linear programming, 78-81 NAND logic block, 230
Logarithmic functions, 175-179 Natural logarithms, 176-179
Logarithms, 176-177 Nested parentheses, 57
common, 176 Newton’s method for solution of
laws of, 177 equations, 169-171, 180
natural, 176 NOR logic block, 232
INDEX 271
Normal forms of Boolean expressions, Power series, 188-191
210-212 economized, 191
Number systems: Principal diagonal of a matrix, 132
bases of, 19 Principle of duality in Boolean
binary, 19 algebra, 201
decimal, 2-6 Programming:
hexadecimal, 19 Fortran, 91-123
nondecimal, 19-51 linear, 78-81
octal, 19
Numbers:
accuracy of, 9-10
Quadratic form, equations in, 160
characteristic of, 8
Quadratic formula, 158-160
complex, 156-158
Quadratic functions, 158
fractional part of, 3
integral part of, 3
irrational, 4
mantissa of, 8 Rational numbers, 14
negative, 2 READ statement in Fortran, 105
positive, 2-3 Real constants in Fortran, 94-95
rational, 4 Real numbers, 4
standard form of, 7-8 operations on, 12-16
value of, 4 Real variables in Fortran, 95-96
Related bases, 28-30
Repeated subtraction, 43-46
Octal number system, 19 Repeating decimal numbers, 3
One-dimensional arrays, 21, 127-129 Roots of polynomial equations,
sum of elements of, 127-128 167-171
Open interval, 70 by bisection method, 168-169
Operations: location of, 167-168
in Fortran, 97 by Newton’s method, 169-171
hierarchy of, 54, 97 Rounding off numbers, 10
OR logic block, 196
272 INDEX
Statement numbers in Fortran, 93-94 Ternary number system, 19
Straight lines, 61-64 Truncation:
equations of, 61-64 of numbers, 10
parallel, 67 of power series, 188
point-slope form of equation of, 63 Truth tables, 197, 202
slope of, 63 Two-state devices, 194
slope-intercept form of equation of,
64
two-point form of equation of, 62 Unit matrix, 132, 142-143
Subprogram statements in Fortran, 93
Subscripted variables, 21, 127
Subtraction of numbers: Value of numbers, 4-6, 20-22
method of b-1 complement, 35-38 Variables:
method of borrowing, 34 in algebra, 53
repeated, 43-46 dependent, 58
in various bases, 34-38 in Fortran, 95-96
Sum normal form of Boolean independent, 58
expressions, 210-212, 215 subscripted, 21, 127, 194
complete, 212
Summation, 84—85
Switching, 193, 199 WRITE statement in Fortran, 108-109
Switching circuits, 193-196, 206-208
series-parallel, 194-196
simplification of, using Boolean X specification in Fortran, 110
algebra, 206-208
Switching function, 194
Symmetric roundoff, 10 Zero matrix, 133
INDEX 273
7 be
a
>*
: &
: a
a ‘
*
< ¥~
~~
:
4
a
oe: i | foe hes
ee: A SeOe ~. ] OFT. CR
_. ==
| E
ly, mad
get a"we 7cp a‘a @ Se a, . ©.
D.
ab
—& A a
—y
Ot
Jy. _
ns
Sr
ey)
. >
[>