Scientific Programming Clanguage Algorithms And Models In Science Luciano M Barone
Scientific Programming Clanguage Algorithms And Models In Science Luciano M Barone
Scientific Programming Clanguage Algorithms And Models In Science Luciano M Barone
Scientific Programming Clanguage Algorithms And Models In Science Luciano M Barone
1. Scientific Programming Clanguage Algorithms And
Models In Science Luciano M Barone download
https://ebookbell.com/product/scientific-programming-clanguage-
algorithms-and-models-in-science-luciano-m-barone-4947508
Explore and download more ebooks at ebookbell.com
2. Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Python Programming Versatile Highlevel Language For Rapid Development
And Scientific Computing Mastering Programming Languages Series Edet
https://ebookbell.com/product/python-programming-versatile-highlevel-
language-for-rapid-development-and-scientific-computing-mastering-
programming-languages-series-edet-71592228
Real Time Programming Languages Specification Verification 1st R K
Shyamasundar
https://ebookbell.com/product/real-time-programming-languages-
specification-verification-1st-r-k-shyamasundar-2531382
Introduction To Windows And Graphics Programming With Visual C With
Companion Media Pack Roger Mayne
https://ebookbell.com/product/introduction-to-windows-and-graphics-
programming-with-visual-c-with-companion-media-pack-roger-
mayne-56311528
Introduction To Windows And Graphics Programming With Visual Cnet
Roger Mayne
https://ebookbell.com/product/introduction-to-windows-and-graphics-
programming-with-visual-cnet-roger-mayne-1230602
3. Introduction To Windows And Graphics Programming With Visual C 2nd
Edition Roger Mayne
https://ebookbell.com/product/introduction-to-windows-and-graphics-
programming-with-visual-c-2nd-edition-roger-mayne-230947836
Scientific Programming Numeric Symbolic And Graphical Computing With
Maxima 1st Edition Jorge Alberto Calvo
https://ebookbell.com/product/scientific-programming-numeric-symbolic-
and-graphical-computing-with-maxima-1st-edition-jorge-alberto-
calvo-34588190
Learning Scientific Programming With Python 1st Edition Christian Hill
https://ebookbell.com/product/learning-scientific-programming-with-
python-1st-edition-christian-hill-7018158
Learning Scientific Programming With Python 2nd Edition Christian Hill
https://ebookbell.com/product/learning-scientific-programming-with-
python-2nd-edition-christian-hill-12135000
Introduction To Scientific Programming And Simulation Using R 1st
Edition Owen Jones
https://ebookbell.com/product/introduction-to-scientific-programming-
and-simulation-using-r-1st-edition-owen-jones-55441006
7. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
8. NEW JERSEY • LONDON • SINGAPORE • BEIJING • SHANGHAI • HONG KONG • TAIPEI • CHENNAI
:RUOG6FLHQWLÀF
SCIENTIFIC
PROGRAMMING
C-Language, Algorithms and Models in Science
Luciano Maria Barone • Enzo Marinari
Giovanni Organtini • Federico Ricci-Tersenghi
“Sapienza” Università di Roma, Italy
8842.9789814513401_tp.indd 2 18/6/13 10:52 AM
10. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
For Rossella
so patient with me and much more
For Margherita,
a flower indeed,
and for Chiara,
fair by name and by nature
For Federica, Lorenzo and Giulia
“the summum bonum was in the gifts of nature,
in those of fortune, in having many friends,
and many and good children”
Miguel de Cervantes Saavedra
“Don Quixote” (1615)
For my children Gaia and Marco
that make my life full of joy and fun,
bright colors and laughing sounds
...every day more and more!
v
11. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
19. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
xiv Scientific Programming: C-Language, algorithms and models in science
19.2.2 Convergence towards the asymptotic distribution 590
19.2.3 Detailed balance . . . . . . . . . . . . . . . . . . . 594
19.2.4 The Metropolis algorithm . . . . . . . . . . . . . . 596
19.2.5 Barriers ad ergodicity breaking . . . . . . . . . . . 599
19.3 The Ising model . . . . . . . . . . . . . . . . . . . . . . . 602
19.4 Code optimization . . . . . . . . . . . . . . . . . . . . . . 608
19.4.1 Use of look-up tables . . . . . . . . . . . . . . . . 610
19.4.2 Update in random or sequential order . . . . . . . 611
19.4.3 Optimizing the memory accesses . . . . . . . . . . 613
19.4.4 Optimizing the sequence of statements . . . . . . 616
20. How to use stochastic algorithms 621
20.1 Examples where Monte Carlo methods are needed . . . . 621
20.2 How to run a good Monte Carlo simulation . . . . . . . . 625
20.2.1 Convergence towards equilibrium . . . . . . . . . 627
20.2.2 Correlations at equilibrium . . . . . . . . . . . . . 631
20.2.3 How to identify a phase transition . . . . . . . . . 635
20.3 Data analysis . . . . . . . . . . . . . . . . . . . . . . . . . 637
20.3.1 Block averages . . . . . . . . . . . . . . . . . . . . 638
20.3.2 Jackknife . . . . . . . . . . . . . . . . . . . . . . . 642
20.3.3 Scaling laws and critical exponents . . . . . . . . 645
20.3.4 Finite size effects and rescaling . . . . . . . . . . . 649
20.4 Optimization with stochastic methods . . . . . . . . . . . 652
20.4.1 Genetic algorithms . . . . . . . . . . . . . . . . . 653
20.4.2 The simulated annealing method . . . . . . . . . . 660
A. The main C statements 665
B. The ASCII codes 671
Bibliography 673
Index 677
20. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Preface
A book teaching how to program should help its readers to learn with mini-
mal effort how to write properly working, efficient and interesting programs.
Its potential readers may have very different interests, and the books that
are currently available on the shelves generally do not take these needs into
account. They mostly address a generic reader, whose interests the author
is unaware of.
Books presenting a programming language in a specific context are much
more effective and nicer to read, since the reader learns at the same time
both the language and the basic concepts needed to formulate the prob-
lems one wants to solve. These books obviously address a more specialized
audience. However, in many cases they are very precious and they are the
right choice to teach professional and university courses.
The collection of programming manuals addressing a specialized audi-
ence is rather scarce and those dedicated to scientific programming even less
numerous. Since computers play an increasingly important role in modern
science this situation is very unfortunate. In many fields it is essential to
both being able to express ideas into words or formulas and to translate
them into a precise and rigorous programming language.
This book very nicely fills this gap in the current literature. The dif-
ferent parts of the C language are presented together with scientifically
interesting algorithms, each one of which is then put into practice. Of-
ten the algorithms are not at all basic, and their theoretical motivation
is explained in detail. Various implementations of a single algorithm are
discussed in depth, keeping the different, sometimes opposing needs into
account: precision, execution efficiency, code compatibility and readability.
In this way the reader learns how to tackle a new problem while keeping
these various aspects in mind, and how to select an optimal choice fitting
xv
21. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
xvi Scientific Programming: C-Language, algorithms and models in science
his needs.
The topics have been carefully selected and the problems are very accu-
rately discussed, as are the codes included in the book. Indeed, this book
is the result of years of experience in teaching academic courses in scientific
programming. Moreover, the authors have many years of experience ad-
dressing scientific problems with the use of the computer, introducing new
techniques and designing algorithms which have become commonly used.
It is hard to think of authors more qualified than the present ones to write
this kind of book.
The original setup and the authors’ extraordinary talent make this book
an excellent product, a reference point for all those interested in scientific
programming.
Rome, February 10, 2006
Giorgio Parisi
Giorgio Parisi is a full professor in Theoretical Physics at the Sapienza
University of Rome. He is a member of the the French and of the American
Academy of Sciences and of the Lincei Academy. For his work in theoretical
physics he received the International Feltrinelli prize in 1986, the Boltzmann
medal in 1992, the Dirac medal and prize in 1999, the Fermi medal in 2002,
the Nonino prize and the Dannie Heineman prize in 2005. the Galileo Prize
in 2006, the Microsoft European Science prize in 2007, the Lagrange in
2009 and the Max Planck medal in 2011. He wrote three books and over
500 scientific articles.
22. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Foreword
The decision to write a textbook is always a difficult and demanding choice
for scientists engaged full-time in research activities. It is a very time
consuming task, and it requires to have a clear idea about the direction to
take in order to produce an innovative book.
Fortunately, some years ago, we started teaching, together with some
other colleagues, a course about scientific computing to physics students of
the Mathematical, Physical and Natural Science Faculty of the Sapienza
University in Rome. These courses were a novelty. They were introduced
in the context of the recent Italian and European reform, the so-called three
plus two, aiming to provide students with skills which allow them to operate
professionally in a scientific and technological environment.
The subject of these courses is based on our computer programming
experience in various fields of scientific research. Throughout our teaching
we realized that many fundamental notions about computing for scientific
applications are never discussed in the standard manuals and textbooks.
We were not able to find an adequate textbook for these kind of courses.
Indeed, commonly used textbooks belong to one of the two following cate-
gories:
(1) programming language manuals;
(2) numerical analysis textbooks.
The former often contain examples on how to use a programming language
without considering the application context. They contain plenty of exam-
ples and exercises, which are more game-like or have a concern a manage-
rial context; the few examples written in a precise mathematical form are
too simple for a university student and are therefore not appropriate for
a scientific (engineering, mathematics, physics, chemistry, biology) faculty.
On the other hand, numerical analysis textbooks are appropriate for ad-
xvii
23. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
xviii Scientific Programming: C-Language, algorithms and models in science
vanced students and usually require a good knowledge of programming and
of mathematical and physical notions. Using two textbooks, one of each
category, does not solve the problem either, because the important topics
are not correlated as they do not follow the same track.
Finally, we became convinced of the fact that the current survey of text-
books does not include an introductory programming manual for scientific
university courses.
Forgetting all about the existing textbooks, we started working on an
innovative scheme which we considered adequate for the new university
courses. Moreover, the possibility to write a new textbook seemed interest-
ing. We also felt that the project we were working on had an international
feel and this stimulated us.
We conceived and built a scheme not just to teach students a program-
ming language, but rather to give them the ability to build models to solve
scientific problems by programming. The teaching method we chose takes
into account the student skills evolution in time. The examples given are
always accessible to the student. The first examples simply refer to mathe-
matical problems in infinitesimal calculus. In the second part fundamental
problems of both physics and mathematics are tackled, such as the study
of differential equations and their application to problems in dynamics. Fi-
nally, in the third part, we discuss rather complex optimization problems.
The textbook is structured in three parts, reflecting the three teaching
phases and corresponding more or less to three university courses. The
complete journey goes hand in hand with a complete engineering or sci-
entific graduate course. The three courses we propose are strongly linked,
and guide the student from the condition of illiterate in computer science
to an advanced and competent level. At the same time, the three parts
are rather independent and allow a teacher to select only certain parts for
particular courses.
The title of this textbook is short, but expresses various strong ideas.
The Programming expresses the fact that we teach techniques on how to
build models and generic algorithms to solve a problem, while creating a
good executable code. The Scientific has a double meaning: it partly refers
to the fact that we treat scientific problems, and partly refers to our way
of introducing programming methods. Methods, statements and models
are not given as recipes, but for each one of these we carefully examine
their raison d’etre, the mechanisms which make them useful, the possible
alternatives and their pro and cons.
24. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Foreword xix
What this book is not
As we already mentioned, this book is not a C manual: there are already
many manuals available in print and on the Internet. In Scientific Pro-
gramming we introduce the C language as a tool to learn how to program:
a process which is fully analogue to the one in which you learn how to talk.
Just like you need a language when you learn how to talk, you need one to
learn how to program. However, it is beyond the scope of this textbook to
analyze the C language in-depth in all its aspects. For this kind of analysis,
we refer the reader to the bibliography. Still, this textbook contains enough
information to introduce the reader to the language without having to refer
to a manual.
This textbook is not a generic programming manual either: no man-
agerial, graphics or multimedia applications are discussed in detail. The
scientific applications mainly consist in calculating and organizing data.
The results are often represented in a graphic way, but these were mostly
obtained with specialized programs. These programs are easily available
on the Internet, and we do not discuss their setup.
Nor is this book a numerical analysis manual. It includes many, some-
times advanced, computation algorithms, but they are always presented in
a simple and intuitive way. We do not want to discuss all aspects of nu-
merical analysis from a mathematical point of view. We refer the reader to
the bibliography for the proof of theorems, the detailed discussion of what
certain choices imply and the theoretical aspects. Nevertheless, a diligent
student will acquire all the tools needed to write complete, accurate and
efficient programs.
How to use this textbook
This textbook consists of three parts. Each part reflects the contents of the
courses we teach in the corresponding year of an undergraduate program.
Therefore, each part contains the material of a first level, 6 credits university
course.
The first part does not require any specific prior knowledge about pro-
gramming. The student is guided along a track including the knowledge
of the basic tools (the computer and the programming language), which is
essential to understand the techniques to design the solutions. In the first
part we aim to familiarize the student with the techniques by learning how
25. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
xx Scientific Programming: C-Language, algorithms and models in science
to use them in simple and interesting examples. The student learns the
elementary and fundamental C constructs and how to apply these in the
basic numerical techniques (derivatives, integrals, sorting).
In the second part, we focus on the design aspect. In each chapter we
consider the solution to a different problem. This is the right time to show,
with examples, the general techniques to solve problems, to thoroughly
analyze the advanced aspects of the language and to consider elements often
neglected, such as the program’s robustness and efficiency. The examined
problems are original and stimulating.
In the third part we assume the student fully masters the tools (in
particular the programming language). We discuss complex computation
problems, which are common in engineering or science, along with code
optimization techniques. Also in this part the topics we treat offer a generic
overview of the techniques in use, but we frequently examine new and lesser
known ones. In our opinion, the third part is more dense of what can be
reasonably treated in a standard course and the teacher is free to choose
which topics to discuss.
We hope that the student using this textbook becomes at least half as
enthusiastic as we were while writing it. In which case our book will turn
out to be, beyond any doubt, very useful.
Acknowledgments
At the end of this project, we first of all want to thank our colleagues, our
collaborators, our PhD students and all those who depend on us in one way
or the other, since in order to write the book we have taken away crucial
time from them.
A special thanks goes to the Director and the personnel of the Physics
Department of our University, and to the Directors and the personnel of the
National Institute of Nuclear Physics and the National Institute of Matter
Physics (now unfortunately no longer existing) Sections of Rome 1: without
their help our job would have been impossible.
Thanks to our colleagues Zhen’an Liu of Beijing and Wu Hao of Shang-
hai, for helping us write the citation in Chapter 3 and to Anna Malerba for
the citation in Chapter 2.
We also got some very important help from all our colleagues teaching
the programming courses in the Physics Graduate Program of the Sapienza
26. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Foreword xxi
University. The students attending our courses stimulated us and pressed
us with questions and discussions which were often very important for the
development of this textbook. Though they are far too many to quote them
all here, we are very grateful to all of them.
Some PhD students and young researchers helped us during our courses
throughout the years, and they corrected many, small and big, errors: we
sincerely thank Tommaso Castellani, Tommaso Chiarusi, Jovanka Lukic
and Valery Van Kerrebroeck.
Carlo Piano has been helping us with organizing the Italian version of
the book, and his help has been for us very important.
Lisa Ferranti has been somehow the real responsible of all this. As the
editor of the Italian version of the book she has believed in the book from
the first moment, she has helped us, she has pushed us, she has brought us
to print the book. We could not thank her more warmly.
Introduction to the English version
It took a little time, after we realized that we considered appropriate having
this book available in English, finding the strength to go ahead with the
project. We were indeed convinced it was a very good idea, since there is
here an original approach that we hope will be useful to many students ap-
proaching the world of scientific computing. Also we had signals from many
non-Italian colleagues, using the book (thanks to their brilliant knowledge
of our language) as a trace for their courses but being unable to really give
it, because of the language, as a source to the students.
We are very indebted to Valery Van Kerrebroeck that translated the text
from Italian, with passion and dedication: without her our effort would
probably have been vain. Many young colleagues close to our research
groups have helped us in a final revision of the translation; even if they are
too many to be quoted individually, they should know we are really grateful
to all of them.
Rome, June 7th, 2013.
Luciano M. Barone, Enzo Marinari, Giovanni Organtini, Federico Ricci-
Tersenghi.
27. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
28. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Technical note
This textbook was written using L
A
TEX[Mittelbach and Goosens (2004)]
version 3.141592-2.1 on a Linux operating system1
.
We used the emacs and nedit editors to write the text and the pro-
grams. We compiled the latter with gcc version 3.3.3. Generally we used
the -pedantic option which generates a message in case the code is not
compatible with the ANSI standard. We adopted this standard throughout
the complete textbook, except for a few cases which we mentioned explic-
itly.
The figures were generated with the L
A
TEX pstricks package or the
programs gnuplot and xfig, in Linux. We used different packages following
the common habit in scientific environment to choose the best tools for
a given problem; this is quite different from other environments, where
usually the choices are dictated by conventions, convenience or imposition.
This also allows us to show how versatile open source2
programs are.
Typographical Conventions
We have quoted the programming language constructs and the system
commands with a different font than the one used for the text. Its hor-
izontal dimension is constant (monospaced) and does not vary with the
character, as in
1Linux is a trademark registered by Linus Törvalds.
2Open source software is computer software whose source code is freely available and
provided under an open source license allowing it to be studied, copied, changed and
redistributed.
xxiii
29. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
xxiv Scientific Programming: C-Language, algorithms and models in science
while
ls -la
return 0;
for (i = 0; i 10; i++) {
We also used a similar font to represent URL names (Uniform Resource
Locator) of Websites:
http :// www. pearsoned.com
http :// www. scientificprogramming .org
Characters that possibly cause confusion in the middle of the text (es-
pecially punctuation marks) are represented with a gray background: ., ;,
{.
To show the syntax and the general definitions of commands, statements
and functions we used a different monospaced character, as in
#define symbol [value]
In this scope words in italics, such as symbol, represent generic elements
which have to be replaced by the actual ones. When they are included
between square brackets, as in [value], they represent optional elements
which may or may not be present. The example above describes several
possible alternatives, as in
#define _DEBUG
#define MAX 100
In the first example symbol is replaced by _DEBUG and the optional value
[value] is not present. In the second, symbol is replaced by the string
MAX and an optional value 100 is present, described as value in the syntax
example.
Program variable names are always chosen on the basis of what they
represent.
Generally, programmers use a US keyboard. The reason is simply be-
cause programming languages often use the symbols present in this type of
keyboard, which is considered to be international, and not in others. The
C language is no exception to this rule and uses curly brackets and the
tilde (). In case one does not have a US keyboard, the required symbols
can be created using certain combinations of the keys in order to avoid
having to redefine the keyboard.
In the Microsoft Windows operating systems, the opening curly brackets
can be obtained by holding the Alt key and pressing subsequently the keys
1, 2 and 3 of the numerical keypad. The closing curly bracket is obtained
30. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Technical note xxv
in the same way by pressing the keys 1, 2 and 5, while the tilde is composed
with the keys 1, 2 and 6. Please note that this might get very complicated
on portable computers which do not have the numerical keypad, but require
it to be activated with yet another combination of keys. The curly brackets
can alternatively be obtained by pressing the keys on which the square
brackets are present while holding the Alt Gr and Shift keys.
In the operating systems using the graphic system X (X11 or X11R6),
such as Linux or Cygwin in Windows, the opening and closing curly brackets
are obtained by holding the Alt Gr key and pressing, respectively, the keys
7 and 0 on the first line of keys in the standard keyboard (i.e., the keys,
respectively, on the left and right of the parentheses). The tilde can be
obtained by pressing the Alt Gr key together with the key.
There is a website accompanying this book at the web address http:
//www.scientificprogramming.org/, where one can find all the codes
discussed here, and additional material.
The program listings are subject to the GPL license (http://www.gnu.
org/licenses/licenses.html) allowing them to be copied, changed and
redistributed.
31. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
32. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Chapter 0
Programming to compute
It is true that software cannot exercise
its powers of lightness except through
the weight of hardware. But it is software
that gives the orders,
acting on the outside world
and on machines that exist
only as functions of software
Italo Calvino, Six memos for the next millennium (1984).
Students starting to program usually wonder about «How?» and «Why?».
This textbook aims to answer these two questions in a scientific applica-
tions context. Programming implies many things: to formalize a problem,
typically by reducing it into a series of smaller problems; to translate the for-
malization into a programming language, then writing the actual program;
to introduce checks which take all possible cases into account. Though
many university courses just follow a programming language manual, it is
fundamentally wrong to think that an expert programmer is someone who
knows well a programming language syntax.
In the majority of cases, a beginner immediately starts writing state-
ments in the selected (or required) language, before trying to logically for-
malize the problem to be solved. However, only those more able in rep-
resenting abstract concepts can write the code while defining the logical
flow of operations. Such an ability can be gained with practice. Beginners
should first write down the flow of operations needed to solve the given
problem. Coding comes only later. The study of algorithms, well defined
1
33. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
2 Scientific Programming: C-Language, algorithms and models in science
sequences of operations producing a result, is an important part of program-
ming and helps in the logical formalization. Algorithms can have different
levels of complexity. Despite some of them may appear as trivial, a careful
analysis always reveals interesting aspects even in the simplest algorithm;
their analysis is a good way to learn how to deal with more complicated
problems.
Once the logical scheme of a program is established, the code can be
written according to the rules of the selected language. Just like in any
other language, the syntax of a programming language requires discipline.
Even worse, in case of a programming language, discipline is mandatory as
errors are not tolerated by the programs which translate and execute the
code (the compiler and the operating system). Neglecting the syntactical
rules is one of the first difficulties encountered by a beginner. Following
these rules is sometimes boring, but there is no way out; the only solution
is to learn the syntax up to the point that respecting the language rules
becomes natural.
Finally, to become a good programmer one needs to know deeply several
other aspects: how a computer works, number representation, the time
needed for computation, the precision and approximation of mathematical
operations.
In this textbook, we answer the question «How?» not only discussing
the rules of a programming language (the C language in our case). We also
discuss number representation, rounding problems, algorithms, computing
efficiency and logical instruments. The student mastering these subjects
knows how to program. The best way to acquire this knowledge is con-
tinuous practice on more and more difficult problems. We therefore invite
the student to independently develop the topics treated in this textbook,
besides carrying out the lab exercises.
In the first part of the text, “Basic Programming in C”, we mainly focus
on the rules of the language, on elaborating numbers and on the logical
formulation of the problems.
At that point, the question «Why?» is still unanswered though. In
most environments, the computer is now used as if it were a “black box” for
graphic or multimedia office applications not requiring the least knowledge
on how the software (and also the hardware) works. Whoever knows how
to use an electronic sheet or an editor is considered literate in computer
science. Actually, such a user relates to the software as a driver to his car.
Indeed, owning a driver’s license is quite different from being a mechanic
or a car designer.
34. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Programming to compute 3
In a scientific research environment the computer is acknowledged as an
essential tool to investigate the most varied fields, from biology to physics,
from economy to engineering. The computer is a daily instrument in var-
ious disciplines and sometimes it is even the only way to study some phe-
nomena. As an example, think of simulating systems consisting of many
elementary particles: we cannot observe the single atoms and molecules,
but we can simulate their collective behavior and compare the properties
with the experimental macroscopic observations. The software developed
in scientific research is always very specific and continuously needs to be
updated to keep up with the rapidly changing demands. Apart from a few
general programs (for graphics, statistics and few other applications) it is
almost never possible to find commercial software adequate for scientific
applications. The best solution to these problems certainly is being able to
autonomously write programs for scientific applications.
Moreover, in several research fields, the computational approach has
become a true alternative. It is considered a third possible way of inves-
tigating Nature, next to the more traditional theoretical and experimental
approach. Whoever chooses this third way has to have a solid base in
scientific programming. This textbook has the ambition to fill this gap,
providing technical and logical tools to develop original scientific programs.
Obviously it is not possible to treat exhaustively all scientific applications.
Instead, it is possible to discuss the most important algorithms, explain how
to translate them in computing code and progressively shape the mentality
needed to face problems and algorithms not reported in this textbook. We
hope to teach people how to fish, rather than to hand out them fishes.
The student applying himself to writing programs and solving exercises
will be able to find a software solution to a scientific problem not explicitly
discussed in this textbook. As a result, the student will be able to under-
stand the meaning of the quote from Italo Calvino it is the software that
gives the orders.
35. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
36. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
PART 1
Basic programming in C language
5
37. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
This page intentionally left blank
This page intentionally left blank
38. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Chapter 1
Numbers and non-numbers
Novem figure indorum hae sunt
9 8 7 6 5 4 3 2 1
Cum his itaque novem figuris, et cum hoc signo 0,
quod arabice zephirum appellatur, scribitur quilibet
numerus, ut inferius demonstratur.
Fibonacci, Liber Abaci (1202).
In this chapter we show how to represent data (whether numerical or not) in
the computer memory. The first step towards the creation of an automatic
data manipulating machine is representing the information. The basic in-
formation, especially in case of scientific computation problems, consists of
numbers. The representation of data of any other nature (characters, im-
ages, sounds, etc.) is based on that of numbers. Therefore, a considerable
part of this chapter is dedicated to the ways of representing the latter.
1.1 Numeral systems
A numeral system is the set of rules determining how to graphically express
numbers.
We need to distinguish between the abstract concept of number and the
symbol representing it: symbols are called numerals. The number five, e.g.,
can indeed be written in various ways: 5 in Arab characters (those com-
monly used) or V in Roman numbers; Maya represented it as a horizontal
dash —; the ancient Greeks as Π and so on. Whichever symbol is chosen,
the number remains the same.
7
39. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
8 Scientific Programming: C-Language, algorithms and models in science
The first ingredient of a numeral system is a finite number of symbols or
characters. These are then combined in different ways such that all num-
bers, which on the contrary are infinite, can be written. These characters
are called digits. A numeral system also defines the digit composition rules
and their sequence.
In the decimal numbering system there are 10 digits (from 0 to 9), and
the number sequence is as following:
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
......
90 91 92 93 94 95 96 97 98 99
100 101 102 103 104 105 106 107 108 109
......
The first sequence is obtained by writing all available digits in a given,
arbitrary, order (the first line of the series). Subsequently, this sequence is
repeated while placing the number of repetitions before each digit. In this
way 12 corresponds to the number obtained by counting all digits from 0 to
9 a first time and, next, repeating the digits up to number 2 one more time;
24 corresponds to the number obtained by counting up to 2 repetitions of
the digit sequence, stopping at the number 4 during the second repetition;
106 is obtained by counting up to 10 repetitions of the digit sequence from
0 to 9, stopping at the number 6 during the last repetition, and so on.
Though this system might seem obvious, it is a mistake to think this
way: this impression is due to habit. Every numeral system can arbi-
trarily define its own rules. For example, in the Roman numeral system,
the numbers are obtained by algebraically adding the values of the digits,
considering those preceding one with a larger value to be negative (the
number four is written as IV (−1 + 5 = 4), while seven is represented as
VII (5 + 1 + 1 = 7)).
1.2 Positional systems
The decimal numeral system has been borrowed from the Arabs who in
turn took it from the Indians and Babylonians. It prevailed over the Ro-
man one due to serious limitations of the latter. To figure out which are
those limitations, try to add two Roman numbers or to write a very large
40. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 9
number in this system. The problems you encounter are due to the fact
that the Roman numeral system is not positional. In positional systems
the value attributed to the digits depends on their position in the sequence
representing the number: they have an increasing weight when moving in
the leftward direction. For example, the numeral 1492 indicates the number
obtained by carrying out the expression
1 × 103
+ 4 × 102
+ 9 × 101
+ 2 × 100
.
The numbers are expressed as a sum of digits multiplied by a power of
10, which grows from right to left. The explicit writing of these powers is
omitted and only their coefficients are listed in the sequence. Such a system
is said to be positional as the weight attributed to each digit depends on
its position in the numeral.
In positional systems it is sufficient to choose a finite and arbitrary
number b of digits (called base) to whom we assign a progressive value
starting from 0. In the decimal system there are 10 digits and therefore,
b = 10. In these systems the value of an integer number a is determined as
a =
M−1
i=0
cibi
, (1.1)
where M is the number of digits composing a, ci is the value of a digit
and b is the base of the positional system. The corresponding numeral is
indicated by writing the sequence of coefficients ci. The rightmost digits
are called the least significant, while the leftmost are the most significant.
Elementary operations, such as addition and subtraction, are simple
to perform in these systems. Thanks to the distributive property of the
multiplication with respect to the addition, we just need to align numbers
in columns, while aligning the rightmost digits:
M−1
i=0
αibi
+
M−1
i=0
βibi
=
M−1
i=0
(αi + βi) bi
. (1.2)
Indeed, to add the number 1492 to the number 48, we start by adding the
rightmost digit of the first addend to the corresponding digit of the second
one as both of these express coefficients of the same power. In practice
(Figure 1.1) this operation can be expressed as
1492 + 48 =
1 × 103
+ 4 × 102
+ 9 × 101
+ 2 × 100
+
4 × 101
+ 8 × 100
= 1 × 103
+ 4 × 102
+ (9 + 4) × 101
+ (2 + 8) × 100
.
41. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
10 Scientific Programming: C-Language, algorithms and models in science
The operation 2+8 between parentheses multiplying the power 100
produces
a number which needs to be carried. Indeed, the result is 10 × 100
=
1 × 101
. Thus, the digit 1 is, again thanks to (1.2), added to the digits of
the respective addends with the same weight, namely 9 and 4. A similar
technique is adopted for the subtraction where the digits on the right borrow
an order of magnitude from those on the left. In this way, we add a number
equal to the base value to the digit from which to subtract and subtract a
unit from the lending column.
Fig. 1.1 The column addition operation starts at the right. Extra digits, if any, are
placed at the top so they can be added to the corresponding powers. When adding the
rightmost digits we obtain a number composed of two digits. The extra digit must be
added to those multiplying the same power of the base. This is why it is carried to the
line on top. The same occurs when adding the digits on the third column.
1.2.1 The binary system
The binary system takes its name from the fact that it uses only two digits:
0 and 1. The two digits of the binary system are called bits, short for binary
digits. The base is b = 2 and the counting rule is the same as in the decimal
system: first the available digits are written and then repeated. At each
repetition they are preceded by the number of repetitions. The sequence
starts with:
0 1
The digits are then repeated preceding each of them by the number of
repetitions (one):
0 1
10 11
42. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 11
The numeral 10 correspond to the number two, 11 to three. At this point,
we need to repeat the sequence 0 1 a second time (recall that in binary two
is indicated as 10) to continue counting:
0 1
10 11
100 101
and so on
0 1
10 11
100 101
110 111
1000 1001
1010 1011
1100 1101
1110 1111
Thus, the binary string 1101 is equivalent to the string 13 in the decimal
system as both represent the number thirteen:
1101 =
3
i=0
ci2i
= 1 × 23
+ 1 × 22
+ 0 × 21
+ 1 × 20
= 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1
= (8 + 4 + 0 + 1) × 100
= 13 × 1 = 13 .
For clarity, where the base is not evident from the context, we shall
indicate it as a subscript: 112 is thus equivalent to the number 310. There
are two rather simple ways to express decimal numbers in binary1
. Let us,
for example, express the number 1010 in base 2.
The fastest way consists in identifying the power of 2 which is closest
to, though smaller than the number that is to be converted (8 = 23
, in our
case) and write a 1 in the position corresponding to this power in a binary
number (in our case, the fourth starting from the right). Next, subtract
this power from the original number and perform the same operation on
the difference until this subtraction results in zero. For each missing power,
a 0 is written. For the example under consideration, we wrote a 1 in the
1Both methods can actually easily be generalized to any other base
43. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
12 Scientific Programming: C-Language, algorithms and models in science
fourth position. Next we calculate the difference 10 − 8 = 2, resulting in
a 0 in the third position and a 1 in the second. Subtracting 2 from 2 we
have 0. Thus, after placing a 0 at the first position, we have terminated
the conversion: 10102.
A second, more algorithmic, method consists in iteratively dividing the
number by 2, writing the remainders of these divisions from right to left,
until the quotient is zero. In this way, we can express the number as a sum
of multiples of 2, which is the representation we were looking for. Thus,
to convert the number 1010 in base 2, we start by dividing it by this base:
10/2 = 5 (or rewriting it as 10 = 5 × 2), with remainder 0. Next, we divide
the result again by 2: 5/2 = 2 with remainder 1 (5 = 2 × 2 + 1). The
integer part of the quotient (2), still needs to be divided by 2, giving the
result 1, with remainder 0 (2 = 1 × 2). The latter, divided by 2, results to
be 0 with remainder 1 (1 = 0 × 2 + 1). At this point we just need to write
these remainders from right to left to obtain 10102. Indeed, the method
is generally valid as the number Ni that is to be converted in base b can
always be written as Ni = bNi+1 +ri, with ri ∈ [0, b) and, in turn, Ni+1 can
be rewritten in the same way; the procedure can be iterated up to when we
obtain a certain Nk b. For example, for k = 3, we have N0 = bN1 + r0,
N1 = bN2 + r1 up to N3 = r3 for which
N0 = b (b (b (r3) + r2) + r1) + r0 = r3b3
+ r2b2
+ r1b1
+ r0b0
, (1.3)
where b is the base in which the number is to be converted. From (1.3) it
is clear that the sequence of remainders is exactly the desired number in
base b.
The addition and subtraction operations in base 2 are executed similarly
to those in base 10. Let us add two binary numbers, by writing them in
columns: 11011 and 00101. Starting the addition from the right, the result
should be 12 + 12 = 102. Since this number consists of 2 digits it needs
to be carried. Indeed, the magnitude of the value of the left digit 1 of 102
is a successive power of 2 and needs to be added to the digits of the same
weight. Therefore, we carry it to the appropriate column at the top line:
1
11011 +
00101 =
0
44. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 13
Adding the second column, we have the same result, and the same occurs
in the third and fourth column:
11 1111
11011+ 11011+
00101 = 00101 =
00 0000
The last column requiring addition again results in 102. However, as no
other digits need to be added, this result can immediately be included on
the line of the sum:
1111
11011 +
00101 =
100000
Let us now check the result: 110112 = 2710, 001012 = 510, 10 00002 = 3210.
Indeed, 2710 + 510 = 3210. We leave the subtraction as an exercise to the
reader.
Exercise 1.1 - Binary addition and subtraction
Perform the following addition and subtraction operations in the
binary system, without converting them beforehand. Check the
result by converting the numbers into decimals only after having
performed the operations: 1100+0011; 1110+0101; 1010+0111;
1100 − 0011; 1110 − 0101; 1010 − 0111.
1.2.2 The hexadecimal system
As we see in Section 1.3, the binary system is convenient to represent num-
bers in electronic machines, however it is not very concise. To write down
a relatively small number such as 2710 we need 5 digits! The number of
digits increases at each power of 2.
Though the selected base is a completely arbitrary number, it is true
that some are more convenient than others. If we choose the base to be a
sufficiently high power of 2, we combine two advantages:
(1) if the base is larger than 10, writing numbers requires less digits
than there are required in the decimal system;
45. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
14 Scientific Programming: C-Language, algorithms and models in science
(2) if the base is a power of 2, it is easy to convert the numbers in
binary (which is the fundamental one used by computers).
The power of 2 larger than and closest to 10 is 16. In base 16 we need
16 symbols to represent the numbers. We can choose them freely, but the
following are the most common choice:
0 1 2 3 4 5 6 7 8 9 A B C D E F
Obviously, the symbol A equals 10, B equals 11 and so on until F which
equals 15. This numeral system is called hexadecimal.
Again, counting is achieved by repeating the digits and indicating the
number of repetitions:
0 1 2 3 4 5 6 7 8 9 A B C D E F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
...
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
...
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
The number FF is followed by the number 10016 and the counting continues.
Let us try to convert the number 9616 using (1.1) to find out its value:
9616 =
1
i=0
ci16i
= 9 × 161
+ 6 × 160
= 9 × 16 + 6 × 1 = 15010 . (1.4)
So, a number requiring three digits in decimal can be represented with
only two symbols in hexadecimal. One digit less might appear a meager
saving, however the real advantage of using the hexadecimal notation is
that numbers can easily be rewritten in terms of powers of 2.
Analogously to what happens in base 10, if we multiply a hexadecimal
number by a power p of 16, it moves p places to the left and p zeros need
to be added on the right. The same occurs in base 2 where, multiplying
a number by 2q
, is equivalent to adding q zeros on the right. Now, we
also have that 16 = 24
= 100002. Thus, moving a hexadecimal digit to
the left is equivalent to moving its binary representation four places to the
left. Moreover, all digits of the hexadecimal system can be expressed in
binary using exactly four bits. Thus, by regrouping the digits of a binary
46. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 15
number in groups of four starting from the right, each of these represents the
hexadecimal digit which corresponds to the same number and vice versa.
Multiplying the digit 9 (1001 in binary) by 1610 (10 in hexadecimal and
10000 in binary), we have 9016, as we are multiplying the number 9 by a
power of the base; the result can be expressed by the number followed by
an amount of zeros equal to this power (one in case of base 16 and four in
base 2). If we add 6 (0110 in binary) to 9016 we have 9616 (1001 0110 in
base 2). So, to convert a number from hexadecimal to binary it is enough
to write each digit in its binary notation using always 4 digits.
The other way round, given the number 1001 01102, it is enough to
regroup its digits in 1001 and 0110 to transform them into hexadecimal. The
desired representation follows easily by simply associating to each group the
corresponding hexadecimal digit: 9 and 6, respectively.
The hexadecimal notation is used when it is important to highlight the
composition of a number in terms of bits by means of a compact notation.
Hands on 1.1 - Conversion between numbers in different bases
q [
; ’
/
]
Choose few numbers between 0 and 2000 and express them
in base 2 and base 16. Compare the numbers written
in binary notation to those expressed in hexadecimal, by
regrouping the binary digits in groups of 4 starting from
the right. Next, choose some random sequences of 8 bits and transform
them in decimal and hexadecimal notation. The ancient Babylonians had
a numeral system in base 60. Can you transform the chosen numbers into
this base? What problem could you encounter in this new representation?
Can you figure out the maximum number of digits required in this base for
your numbers?
Exercise 1.2 - The creative Minister
A creative Minister of the Economy needs to make sure that the
law he prepared governing the annual budget and demanding an
extra effort of overall 43 billion euro from the taxpayers, gets ap-
proved. Confident that his colleagues know little about numeral
systems, he writes the following Art. 1: «The quantities stated in the cur-
rent law are all expressed in base 12». Which is the overall amount stated
in the law?
47. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
16 Scientific Programming: C-Language, algorithms and models in science
Exercise 1.3 - License plates
The license plates of Italian cars have the format AA BBB AA
where AA are two letters of the alphabet and BBB are three
digits. Assuming all possible combinations of letters and numbers
can be used, how many vehicles can be registered in this system?
Exercise 1.4 - The planet Htrae: numbers in base 12
The inhabitants of the planet Htrae have six fingers per limb and
count in base 12. Write the first 50 numbers. A greengrocer
of Htrae sold a customer a nolem and a bunch of ananabs (two
types of local fruit). Their prices, displayed on the goods, are 77
and 870 orue (the local money), respectively. How many orues does the
customer have to pay?
1.3 Representation systems
Deciding which numeral system is the more appropriate depends on the
application. Once the base is determined, rules defining how to represent
digits in practice and how to interpret their sequence to assign their mean-
ing, need to be established. This set of rules defines the representation
system.
In the usual typographic convention, as an example, digits are repre-
sented by adopting conventional graphic marks: for the negative numbers
the symbol − precedes the digit sequence; a dot separates the decimal part
of rational numbers from the integer one, and so on. However, this set of
rules is completely arbitrary and can be superseded if we have to represent
numbers in a different environment.
Suppose, for example, we were playing cards on a beach and needed
some way to represent the scores of the two players throughout different
games. Without any pen or paper, we could use a different representation
system. Gathering a dozen of shells, we could decide to use base 2. Each
team is given 6 shells. We represent the digit 0 by an upright shell and the
digit 1 by one that is upside down. In this way we can represent the scores
of each player up to a maximum of 26
− 1 = 63. In this representation
48. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 17
the number of digits is finite, and only a finite amount of numbers can be
expressed.
The representation system of a computer works in base 2 as it is easy
to construct devices assuming just two states: a switch can be open or
closed, a capacitor is either charged or discharged, a transistor can either
conduct or be disabled, and so on. Each of the two states can represent a
binary digit. For example, the current RAM memories are nothing but large
batteries of tiny capacitors etched on a silicon layer. As in the example of
the card players on the beach, also in the case of computers it is impossible
to represent all numbers. Indeed, computer memories are necessarily finite.
In order to simplify its management it is organized such that each number is
represented by a finite amount of digits. For historical reasons, the number
of bits is usually a multiple of 8 (32 and 64 are the most common values,
nowadays): a set of 8 bits is called a byte and is indicated by B. An adjacent
group of bytes with a length in bit equal to n is called a word of n bits. If
the length is not specified the term word indicates a group of bytes whose
size is equal to that of the largest CPU register2
.
We also note that since the possible states of these devices are strictly
two and not more, the various numbers can only be represented by means
of just two symbols. The minus sign and a dot are not allowed and we
need to represent them in a different way. As the numerals are of the
binary type, using exactly n, and no more than n digits, we can represent
integer positive numbers starting from 0 up to a value Nmax = 2n
− 1.
Larger numbers require more digits and cannot be represented as there is
no memory available to store all of them. Moreover, the amount of digits
representing each number is constant. The numbers requiring less digits
than those available are represented by adding an appropriate number of
non-significant digits 0 to the left of the first significant digit. Any attempt
to represent a number larger than the number Nmax gives an overflow error.
Exercise 1.5 - The birthday cake
If you have only 6 candles of two different colors, could you display
your age on a birthday cake? Could lady Lisa, who is 96 years
old and makes great cakes, use the same trick? Having numeral
shaped candles, could she make use of a different base, to appear
younger?
2A word is commonly identified with a group of 32 or 64 bits, depending on the size of
the largest register in modern computers.
49. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
18 Scientific Programming: C-Language, algorithms and models in science
Computer measurement units
The size of a computer memory is measured in bytes, whose multiples are
defined adopting the commonly used prefixes (k = 103
, M = 106
, G =
109
), which are adjusted in order to become powers of 2. For example,
1 kB = 1024 B; 1 MB = 1024 kB = 1048 576 B and 1 GB = 1024 MB =
1073 741 824 B.
A unit for the process speed is the FLOPS (FLoating point OPerations
per Second ), measuring the number of operations on floating point num-
bers (see Sec. 1.3.4) that the CPU is able to perform in one second . In
most cases, however, the performance of a computer strongly depend not
only on the CPU FLOPS, but also on the general architecture, the size
of the RAM and the particular application. To define the performance
of a computer taking into account all those aspects, SPEC (Standard
Performance Evaluation Corporation) has been created: a non-profit or-
ganization defining a series of standard algorithms, called benchmarks, to
evaluate the performance of computers by measuring their relative execu-
tion time (http://www.spec.org). From these execution times, metrics
depending on a particular aspect for which the algorithm was designed,
are derived. For example, the SPEC CINT2006 measures the overall pro-
cess velocity on benchmarks performing operations on integer numbers.
In Table 1.1 on page 25 we display the minimum and maximum num-
bers that can be represented on a 32 bit architecture, using the techniques
described in the next sections.
1.3.1 Representing negative numbers
We already noted that it is not possible to use a third symbol to represent
the sign of a number, as all information must be conveyed in a unique
way by means of the only two possible states of the devices composing the
computer architecture. The sign of a number must then be represented
with the same symbols 0 and 1 used to store the digits (i.e., with the two
states of the physical device representing them): we could establish that the
number is positive if the most significant bit is 0 and negative otherwise.
In this way, assuming that all numbers have a sign, the largest number
that can be represented on an 8 bit architecture is 0111 1111 (equal to
50. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 19
+12710), while the smallest is 1111 1111 (equal to −12710). The zero
would have two possible representations: 0000 0000 e 1000 0000.
More generally, n bits can represent positive and negative numbers rang-
ing from −(2n−1
−1) to (2n−1
−1) with two possible representations of zero.
1.3.2 Complement representation
At the end of this section it will be clear that representing relative numbers
with a sign is not the best solution on a computer. Remember that a fixed
number n of bits allows us to represent numbers from 0 to 2n
− 1. We
could choose to divide this interval of representable numbers in two and
interpret the numbers in one subinterval as positive numbers and the others
as negative ones. The most common solution for representing negative
numbers on computers is the two’s complement representation.
To gain a better understanding of this type of representation it is useful
to start from a visual model. Suppose we have a tape with the numbers
from 0 to 99 printed on it, similar to a tailor’s meter. If we fold the tape on
itself, creating in this way a ring (Figure 1.2), we can interpret the numbers
on the left of the zero as negative and the ones on the right as positive. Of
course, as the tape is limited, both the positive and the negative numbers
finish at a certain point, namely in the point that is diametrically opposed
to the zero. Actually, what we do is we divide the interval of representable
numbers into two sub–intervals and agree to use the upper half for negative
numbers.
Fig. 1.2 A numbered tape folded onto itself to create a closed curve is an efficient way
to visualize the representation of negative numbers in the base’s complement.
It is easy to express a negative number with this notation, given that
the sum of equidistant numbers from the zero (as 99 + 1, 98 + 2, etc.) is
always equal to bn
where b is the base and n is the maximum number of
digits composing the numbers under consideration. We also observe that
51. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
20 Scientific Programming: C-Language, algorithms and models in science
bn
is always written as 1 followed by n zeros for each b and thus takes n+1
digits. If the number of digits under consideration is limited to n, we can
ignore the excess digit 1, and the sum will in fact always be 0.
The complement k of a number m, in a certain base b, represented by
a fixed number n of digits, is the number obtained from the relation
m + k = bn
. (1.5)
For example, in the decimal system, the ten’s complement of the number
32 using 4 digits is
k = 104
− 32 = 9968 .
Obviously, 9968 + 32 = 10 000. However, if the number of digits is limited
to 4, the leftmost digit 1 of the sum is omitted and the result is equal to
0. The same occurs in base 2 (102). The complement of the number 0110,
with four digits, is
k = 104
2 − 01102 = 100002 − 01102 = 10102 .
Again, we have, in the appropriate base, 1010+0110 = 1 0000, such that the
sum is a 5 digit number. If we ignore the first digit the result is equivalent
to 0000.
The complement k of a number m is easily obtained rewriting (1.5) as
k = bn
− m = (bn
− 1) + 1 − m .
Note, in particular, that (bn
− 1) is always expressed as a sequence of digits
which are all equal to each other and to the last digit of the system in use (9
in base 10, 1 in base 2). So, to obtain k it is enough to write for each digit
of m what is missing to reach the last digit of the base b (the complement
to the base) and finally add 1. For example, in base 10, the complement
of 0032 is the number 9968, obtained by adding 1 to 9967 which, in turn,
is determined by noting that 9 is the complement of 0, 6 of 3 and 7 of 2.
In base 2 things are even simpler as the last digit of the base is 1. Thus,
the complement of 0 is 1 and that of 1 is 0. Thus, we just need to invert
the digits to obtain the intermediate result; the two’s complement of 0110
is obtained by inverting the digits (1001) and adding 1: 1001 + 1 = 1010.
The interval of numbers that can be represented with this technique
starts at −bn
2 and ends at bn
2 − 1: in base 10, with 4 digits, this is from
52. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 21
−5000 to +4999; in base 2, with 8 digits, from −128 to +127. In this case
there exists only one representation of 0. Taking this into account, it is
easy to distinguish positive numbers from negative ones: in base 10 positive
numbers start with a digit between 0 and 4 (9968 is a negative number and
cannot be confused with +9968, which does not exist in this representation);
in base 2 the negative numbers always have the most significant bit equal
to 1.
Let us now also consider the fact that CPUs are equipped with electronic
circuits to perform elementary functions. The number and size of these
circuits are one of the parameters determining the amount of dissipated
energy, the physical size of the CPU and its speed. Thus, it is clear that
the representation of negative numbers in two’s complement is extremely
convenient. Indeed, the inversion operation of the digits can be done with
a very simple circuit, and the subtraction operation is executed with the
same, also relatively simple, circuit used for the addition. The advantages
of this type of representation can be appreciated by those who solved the
subtraction exercise of Section 1.2.1.
1.3.3 Excess-N representation
An alternative to the two’s complement is the excess-N notation. The latter
consists in representing the negative numbers by one part of the available
numbers and the remaining part represent the zero and positive numbers.
This just means that the origin of the axis of natural numbers is shifted
and the negative numbers are represented by the numerals preceding this
new origin.
In an n-bit representation we can write 2n
numbers (from 0 to 2n
− 1)
in total: by moving the origin N places, the bit sequence usually indicating
the number N, represents the number 0. The sequences of digits preceding
the origin indicate negative numbers, while those following express positive
numbers, similarly to what has been done in two’s complement. This rep-
resentation is called excess-N. The value of each bit sequence is obtained
by subtracting N from the number the sequence represents in binary. In
this way all numbers from −N up to 2n
− (N + 1) can be represented.
For example, in case n = 8, numbers from 0 to 255 (for a total of
256 numbers) can be represented. With N = 127 the numeral interval is
divided in two. The numerals that in the usual notation represent numbers
from 0 to 126 (0111 1110) represent negative numbers from −127 to −1, the
numeral 127 (0111 1111) represents 0 and the remaining ones the positive
53. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
22 Scientific Programming: C-Language, algorithms and models in science
numbers from 1 to 128. As N is arbitrary, the excess-N notation is preferred
over the two’s complement when it is necessary or suitable to freely choose
the position of the origin on the numeral axes.
There exist other possible representations of negative numbers. Still, as
they are only rarely used in practice, we do not cover them in this textbook.
Exercise 1.6 - Negative numbers in complement and excess-N
Write the opposite of the following numbers in base 10 with the
3-digits complement and the excess-127 notation: 2, 28, 57, 128.
Repeat the exercise in base 2, using an appropriate number of
digits. Finally, express the given numbers in an uncommon rep-
resentation such as excess-96.
1.3.4 Rational number representation
In the decimal system the integer part of rational numbers is generally sep-
arated from the fractional part by means of a dot or decimal point. The
formula (1.1) is easily extended to include the case of rational numbers con-
sidering the fact that the weight of the digits to the right of the point are
negative powers of the base that decrease as we move further to the right.
A number a with N digits right of the point and M on the left equals to
a =
M−1
i=−N
cibi
. (1.6)
For example, 45.127 has a value equal to
1
i=−3
cibi
= 7 × 10−3
+ 2 × 10−2
+ 1 × 10−1
+ 5 × 100
+ 4 × 101
.
As usual, the same is valid in base 2; the number 110.01101 is equal to
2
i=−5
cibi
= 1 × 2−5
+ 0 × 2−4
+ 1 × 2−3
+ 1 × 2−2
+ 0 × 2−1
+
+ 0 × 20
+ 1 × 21
+ 1 × 22
= 6.406 2510 .
Analogously to base 10, dividing or multiplying a binary number by a power
of 2 means moving the point an appropriate number of places. For an ar-
chitecture in which the K digits composing a number are fixed it could be
54. June 7, 2013 14:50 World Scientific Book - 9in x 6in ScientificProgramming
Numbers and non-numbers 23
convenient to reserve N of those digits to represent the integer part and the
remaining ones, i.e., M = K − N, the fractional part. Fixing the number
of digits after the point in this way is a waste though (all zeros follow-
ing the last significant digit are useless). Indeed, it limits the potentially
representable numbers to a rather low value, more or less equal to 2N
.
A better solution is offered by the floating–point representation, which
expresses the numbers as in scientific notation. Indeed, the number 45.127
can always be written as 4.5127 × 101
or 0.451 27 × 102
. In scientific nota-
tion the number is written as a product of a mantissa (for example, equal
to 4.5127) and an appropriate power of the base (1 in the given case). The
base is the one of the adopted numeral system. Obviously, the possible
floating–point representations are infinite: it is enough to choose a differ-
ent power of 10 and change the mantissa correspondingly to change the
representation. By convention, a standard notation has a mantissa with
value always between 0 and the base and an as low as possible exponent.
In this way the only proper representation is 4.5127 × 101
.
This same representation, in base 2, is used in computers: each ratio-
nal number is expressed as a product of an appropriate power of 2 and a
mantissa. Having only a limited number of bits available (suppose 32), we
reserve a certain (few) number ne of bits for the exponent and the remaining
ones (nm = 32 − ne) for the mantissa. Again, the possible representations
are infinite. This is why a standard defined by an international organiza-
tion, i.e., the IEEE 754, is followed, prescribing the following conventions:
• The most significant bit represents the mantissa sign (0 if positive,
1 if negative).
• The subsequent 8 bits represent the exponent of 2 in excess-127
notation.
• The last 23 bits represent the mantissa in normal form. This form
is defined such that it represents C + m with m ∈ [0, 1) and C a
constant, which does not require to be represented. Therefore, the
23 available bits represent only m. In the so–called normal form
C = 1. However, if the exponent consists of 8 zeros (−127), C = 0
and it is more convenient to assign the value −126 to the exponent
(denormalized form)3
.
3In the normalized form the smallest absolute value that can be represented is
1.000 . . . 001 × 2−127 = 2−127 + 2−232−127 2−127. Instead, in the denormal-
ized form, 1.000 . . . 001 × 2−127 becomes 0.111 . . . 111 × 2−126, and values up to
0.000 . . . 001 × 2−126 = 2−232−126 = 2−149 can be represented.
56. the flour slid off to the ground. And Brave Horatius and I went to
prayers in the cathedral, and so went Thomas Chatterton Jupiter
Zeus and Menander Euripides Theocritus Thucydides. And Mathilde
Plantagenet did wait waits at the pasture-bars.
57. CHAPTER XXXVI
Of Taking-Egg Day, and the Remarkable Things that Befell
thereon.
To-day was taking-egg day. Taking-egg day comes mostly one time
a week. It is the day the mamma does send me straight to take eggs
to the folks here about and yonder. First she does send me to take
them yonder, before she does send me to take them hereabout. This
she does because she knows if she sends me first to take them to
the folks that live hereabout, I do stay so long with the folks that live
in the nursery and hospital that there is n’t time enough left to take
eggs unto the people that live yonder.
As quick as I did eat my breakfast, the mamma did set out the
lard-pail on the wash-bench with a dozen eggs in it. As quick as she
did so, I put on my sun-bonnet. It is blue and has a ruffle on it.
Sometimes I wear it on my head, but most times it hangs back over
my shoulders. And often I carry it over my arm with things in it—
earthworms for baby birds, bandages for the folks that get hurt, and
mentholatum in quinine boxes. Then too on exploration trips my
chums ride in it. Sometimes it’s a mouse and sometimes it’s a beetle.
Very often it is toads and caterpillars—only they don’t ride in the
sun-bonnet at the same time, because I have learned toads like to
eat caterpillars for breakfast. Sometimes Thomas Chatterton Jupiter
Zeus, that most dear velvety wood-rat, snuggles up in my sun-
bonnet. He most fills it up. A sun-bonnet is a very useful garment.
58. After I did tie my bonnet-strings under my chin in the proper way
the mamma thinks they ought to be tied, I walked over to the wash-
bench in hippity-hops to get that bucket of eggs. Before I took up
the bucket, I did look long looks at those eggs. They were so plump
and so white, and they did have so nice a feel. I think being a hen
must be a very interesting life. How thrilling it must be to cackle
after one lays an egg. And then it must be a big amount of
satisfaction to have a large number of children hatch out at the
same time and follow one about. I think I would like to be a hen in
the daytime, but I would n’t like to roost in the chicken-house at
night.
When the mamma saw me looking long looks at those eggs, she
gave to me a shoulder-shake and told me to get a hurry on me and
take those eggs straight to Mrs. Limberger yonder. That
Mrs. Limberger is the quite plump wife of that quite big man that
lives in a quite big house that is nice but is n’t as nice as his lane. I
thought I’d go straight to Mrs. Limberger’s in along that lane from
out along the field; but first I did go by to get Felix Mendelssohn.
When I got to where he was, it was very near unto the altar of
Good King Edward I. And being as this was the day of his crowning
in 1274, I thought I would just go a little farther, to see if the crown
I planted in little plants there on the altar were growing in a nice
way. They were. When I planted them there from the woods in
spring days, I did hope they would burst into bloom on this his
crowning day and make a crown of flowers on his altar. But the dear
little things got in a hurry, and did bloom more than a month ago.
But they were saying to-day beautiful things with their leaves. I
heard them as I did kneel to pray to thank God for Good
King Edward I.
59. After I did pray quite a long time and Felix Mendelssohn got a little
fidgety, I started on to take the eleven eggs that were left straight to
Mrs. Limberger. The other egg I could not take because when I did
kneel to pray, in some way it did roll out of the bucket, and before I
was through my prayers a little gray rock by my hand just rolled off
the altar and met the egg. There are a lot of little gray rocks on the
altar. It is mostly made up of little rocks and some big ones. While I
was making that altar, the man that works at the mill and wears gray
neckties and is kind to mice came along. And the big rocks that were
too big he did lift and place on the altar there. And then he did help
me to plant mosses in between some of the rocks. That made me
happy. Men are such a blessing to have about.
To-day I did go from the altar to the field. Along the way I
stopped to talk to the trees and to watch the birds and to get berries
for the nursery. I put them in the bucket with the eggs. I most lost
my bonnet climbing over the fence, and I did lose three more of
those eggs and some of the berries for the nursery. I picked up the
berries and put them back in the lard-pail, but the eggs I could not
pick up. I did n’t put my sun-bonnet back on my head again, but I
did give the strings a little tie in front so it would n’t come off. Very
soon after I saw a little snake. He was crawling along. When I see
snakes, I like to stop and watch them. The dresses they wear fit
them tight. They can’t fluff out their clothes like birds can, but
snakes are quick people. They move in such a pretty way. Their eyes
are bright and their tongues are slim.
When that snake crawled away where I could n’t see him any
more, I walked over to talk to a flower. After we did have
conversation for some time, I happened to think the mamma did say
to hurry; so I said good-bye, and when I did, I put my nose to the
flower to smell it. It had a pleasant odor. I went on. Pretty soon I
60. felt something on my nose. I wiped it off. It was pollen from that
flower. I put it on an egg in the lard-pail. That gave that egg a
flowery look. I showed it to an ear of corn, and then, as I did go
along, I stopped to take the clods away from the roots of some of
the corn-plants so the toes of their roots could have some fresh air.
They quivered appreciations, and some did bow down most to the
ground to thank me after I was done.
I proceeded. The day was most warm. When I did cross the creek
I looked down it and up it. There were fairy demoiselles near unto
the water. Their wings did shimmer in the sunlight. All along its
edges the willows were dabbling their toes. Some had waded in a
little bit—about enough to get their ankles wet. I looked long looks
at them. I knew just how they did feel inside while they were
dabbling their toes in the water. It is such a nice feel to have.
I started on. I looked back. I started on. I turned and came back a
little ways—just to take a good-bye look. The willows waved their
hands to me. They called to me, “Petite Françoise, petite Françoise.”
I hurried on with the eggs. I had got twice as far as I did get before.
Then I started back to the creek. I ran all the way. When I arrived I
took off my shoes. I hung my stockings on a willow branch. Then I
sat on the edge of the bank and dabbled my toes. One drinks in so
much inspiration while one is dabbling one’s toes in a willow creek.
And one does hear the talkings of plants that dwell near unto the
water.
While I was dabbling my toes, my legs did have longings to go in
wading, but I went not in. Something might have happened to what
was left of that dozen eggs the mamma was sending straight to
Mrs. Limberger, and that was why I did not go. And I did not take
Felix Mendelssohn out of the pocket he was riding in, that he might
dabble his toes. I took him not out, for he has no longings to dabble
61. his toes in a brook. He has prefers to dabble his toes in cheese.
Though I do feel most certain one does n’t get near so much
inspirations when one dabbles one’s toes in cheese as one gets
when one dabbles one’s toes in waters that sing. After I did take in a
goodly amount of inspirations, I drew my toes away from the water
and let the sun dry my feet so I could put my stockings on. While I
was lacing my shoes up, I looked looks around to see what was near
about. A little way distant was a haystack.
When I did have my shoes most laced up to the top, I gave the
strings a tuck in and started on. I saw a bourdon. He was plump in
body and he did give a plump buzz. I did halt to screwtineyes him
and to listen to more of those plump buzzings of his. They were cool
sounds. What ones I did hear were so. He was a bourdon in a hurry,
and he went on in a quick way. And I went on in a slow way. The
sun was so hot. It made me squint my eyes, so I put my bonnet on.
That made things better. Pretty soon I met Elizabeth Barrett
Browning. Then we went walking across the field. I took off my sun-
bonnet and tied it on Elizabeth Barrett Browning so the sun would
n’t bother her eyes. And she did go her way and I did go mine. We
shall meet again at the pasture-bars when comes even-time.
When I did say good-bye to Elizabeth Barrett Browning, I went the
way that leads to this haystack. And here I have stopped. A haystack
is such an interesting place. It’s a nice place to explore. I think so.
Mice think so. Sometimes—quite often—when I am crawling back in
a haystack, I do meet a mouse, which is very nice, for mice are nice
folks to know. And now to-day, when I did crawl back away under
the straw I did find something. What I did find made me feel
gratitudes from my curls to my toes. It was a nest full of eggs and
nobody had used an egg from it. There are—there were just fifteen
eggs under the hay. They are not near so white as are those eight
62. eggs the mamma is sending straight to Mrs. Limberger, but they do
have more smooth feels. Oh, such satin feels! They are so slick they
came most slipping right out of my hands, but they did n’t.
Four and two I have took. I have put them here in the pail. I do
know Mrs. Limberger does so like to have things with satin feels
about her. I have heard her expressions so when I was taking eggs
to her before. Now I think she will beam delights all over her
plumpness when she does see the satin feel eggs in this pail. I have
placed them on top so she will see them first of all. Too, I think her
eyes will kink when she finds she has got a dozen eggs and two. I
wonder what she will be doing with those two extra eggs. Now I’ll
just get a hurry on me and take them straight to her. And I will hide
these printings of to-day in a little box here in the haystack until
comes eventime. And I will come back again for them when I come
to meet Elizabeth Barrett Browning at the pasture-bars.
I’m back again. I did go straight from this haystack with the two
and dozen eggs to the door of the house of Mrs. Limberger. When I
did get there she was talking with a woman. The woman was the
beautiful Sadie McKibben, and she wore upon her a new dress like
the blossoms of avalon growing in the marshes, and there were
freckles on it like the freckles on her face, and both were beautiful.
Also did Mrs. Limberger wear a new dress. It was black and had a
yellow stripe in it like unto one of those yellow stripes the garter-
snake wears on his back.
When I did walk soft upon the porch they were so busy talking
they heard me not. I reached out the eggs. Yet they were so busy
talking they saw them not. Then I did edge over to Sadie McKibben.
I gave her sleeve a little pull. She looked down at me and smiled.
She went on talking. She gave each one of my curls a smooth-out
while she talked on. When she did get most done with her part of
63. the conversation, Mrs. Limberger did happen to see the eggs I was
holding out to her. She reached and took them. I was glad, but my
arm was the most glad part of me because it did have a tired feeling
from holding the bucket out so long.
She did n’t even notice those satin eggs on top. She did begin to
talk about the many ribbons and the many ruffles the new woman
wears that lives up the corduroy road. She talked on and on, and I
did wait on for the lard-pail the eggs were in. And I did get fidgety,
for she was n’t holding the bucket straight by the middle of its loop
as a bucket ought to be held. I had a little fear she would drop that
bucket. That would make a dent in it. And I knew what a spanking I
would get if I took that pail home with a dent in it. I did stick my
finger in my mouth to keep from speaking to her about it.
Just when I had feels how that spanking was going to feel, she did
take a firm hold on the handle. But she did n’t take it in the middle.
That did make the bucket to tip. She went on talking. She took a big
breath and two of those satin-feel eggs did roll out. They bounced.
They broke. Mrs. Limberger kinked her nose quick. She put her new
black dress to it. Sadie McKibben too did put her new dress to her
nose in a quick way. And my apron so did I put to my nose. Now this
I know for there I learned, an egg with a satin feel may feel proper,
but inside it is not so, and if it gets a fall, it is only a queer odor that
one does have longings to run away from.
But Mrs. Limberger made me stay right there and carry water
from the pump and scrub all the bad odors off her back porch. I
think some of them odors was n’t from the two eggs with satin feels.
When I confided my feelings about the matter to Felix Mendelssohn,
Mrs. Limberger did tell me to go on scrubbing. She said whatever
smells might have been there you could n’t get a whiff of, on
account of the multiplications of smells that came from the two
64. eggs. Sadie McKibben did help me to scrub. She did ask
Mrs. Limberger not to mention the matter to the mamma. Also she
said she was going by that way to-morrow and would bring the four
eggs to make up the dozen.
When I started home Sadie McKibben did give to me a good-bye
kiss on each cheek. She knew how I do long for kisses, and how the
mamma has n’t time to give me any. When I walked by
Mrs. Limberger I did look the other way. As I passed she gave me a
pat, and when she did, Felix Mendelssohn squeaked. When she gave
me the pat, it went through my dress onto the back of the head of
Felix Mendelssohn in a pocket in my underskirt. And he being a
mouse of a musical tendency does object to being patted on the
back of the head. He prefers to have pats on his throat. And he
won’t let anybody give them but me.
I went on in a hurry to home. The mamma came a little ways
from the door to meet me. Behind her was a switch. I saw both
ends sticking out. I did give my skirt a shake so Felix Mendelssohn
would get out and away. It would be awful for him to get hurt by a
whipping. It might hurt his soul. After the mamma did tend to me as
usual, I put some mentholatum on the places where the whip did hit
most hard. Then I did go to take eggs to the folks that live
hereabout. I went in a hurry. After that there were baby clothes to
be washed and wood to be brought in. Then the mamma told me to
go find my sun-bonnet and not to come back until I did find it. I
went again to the altar of Good King Edward I to pray. Then I went
to the nursery and the hospital and came again here where I print.
Now I do see Elizabeth Barrett Browning at the pasture-bars. And
she has got my sun-bonnet on. I knew we would meet again at
eventide at the pasture-bars, for often we do and often on hot days
65. she wears my sun-bonnet until we meet again. It does so help to
keep the sun from hurting her beautiful eyes.
66. CHAPTER XXXVII
Of the Strange Adventure in the Woods on the Going-Away Day of
Saint Louis.
Very early on the morning of to-day I did go unto the cathedral,
for this is the going-away day of Saint Louis in 1270. I went there to
sing a thank song for his goodness and to say prayers. I did sing the
song of Saint Louis that Angel Father did teach me to sing. The little
leaves on the bushes growing there under the grand trees—their
little leaves did whisper little whispers. I have thinks those little
whispers were thank songs for the goodness of Saint Louis.
Sometimes I did hear little bird voices in between the singing of the
songs. I have thinks they were singing the same thank song I did
sing—only they were singing it in their way. And when I came again
home, the brook was singing the same song.
After other works was done at the house we live in on this
morning, the mamma did have me to stand on a box on a chair and
give to the windows some washes. Then she did have me to give the
steps some scrubs. While I so did, I looked looks about. On the
porch-end was a little spider. He made moves in a little quick way. A
guêpe came near unto him. She made no stops. She came on to
him. She did carry that spider away.
Pretty soon I did have those steps all clean—nice and clean. Then
the mamma did have me to help her to take the children to the
house of her mamma. She and they stayed there all day. I so did not
67. do. When they were come to the door of the ranch-house, I did go
goes in the way that goes to the pasture-bars. I so did go to tell the
folks in the pasture what day it was.
It was most warm when I was come to the far end of the pasture.
The folks of the pasture were not out in the sun. They were in
shade. Elizabeth Barrett Browning was under a big chêne tree. She
did look gentle looks at me. And I did put my arm around her neck
and tell her all about whose day it was. Then I went on to tell the
gentle Jersey cow. She was near some more chêne trees. I went on.
She followed after. She did come with me as far as the brook. I
watched her take a long drink. The day—it was so warm. Elizabeth
Barrett Browning did come for a drink. I had thinks of Aphrodite in
the pig-pen. I looked looks about for the little bucket I do carry
drinks of water in to my friends. I found it where I did hide it by the
willow bush. Then I did go to take a drink of cold water to Aphrodite
in the pig-pen. These warm days she does have longings for a drink
of cold water. She did grunt grunts of appreciations. Then she did
grunt another grunt. I have thinks that other grunt was to tell me
not to have forgets to take a drink of cold water to Cassiopée. I so
did. Cassiopée is a pig that does belong to the man that our lane
does belong to.
After I did tell them all about it being the going-away day of
Saint Louis, I did go my way to the garden. The golden rod did nod,
“It is good that he is born.” The tall sunflowers in the garden there
did say, “It is his day, it is his day.” I went adown the carrot-rows.
They were all whispering soft whispers. I have thinks they were
saying little thank prayers for the goodness of Saint Louis. The
cabbage-plants were all smiling as I passed them by. I think they are
right glad for the drink of water I gave each one of them last night.
68. From the garden I did go to tell other folks. I did sing the little
song of Saint Louis as I did go along. The sun, it was hot down on
my head. I took two big maple leaves and they did some help to
keep its warmness from my head. I went on. Once at the edge of
the near woods I met with my dear Thomas Chatterton Jupiter Zeus.
We went on together. I did carry him in one arm, and I did hold a
maple leaf over him with the other hand. A long way we went, in
about and out about, and many little folks we did tell about this day
being the going-away day of Saint Louis.
By-and-by, after it was a very long time, there was no sun. The
warmness did have a different feel. There were gray clouds in the
sky. Some were darkness. I did go in hurry steps. I went not from
the road. I did go the way it went around the bend. More dark
clouds did roll across the sky. More grayness was over all. Thomas
Chatterton Jupiter Zeus in my bonnet did make a move. I did almost
drop him. I made a stop to wrap him more up in the sun-bonnet.
Then I did hurry on. I climbed the lane gate. It was more quick to so
do than to pull the plug out that swings the gate open. I went on.
There was a great noise. Thomas Chatterton Jupiter Zeus poked his
nose out of the sun-bonnet. He cuddled up against me. The great
noise came again. I whispered to him, “Il tonne.” We went on. In-
between times there was fire in the sky. It made moves in a quick
way. After it was the coming of the great noise. Every time I did
whisper to Thomas Chatterton Jupiter Zeus, “Il tonne.” I so did, so
he would not have thinks the great noise was something else.
When we were come near the ending of the lane, there was some
very big pats of rain. One fell on my nose, and it did roll off onto the
back of Thomas Chatterton Jupiter Zeus. I cuddled him up more
close as more loud noises did come. When we were at the ending of
69. the lane, there was Brave Horatius waiting for us. I have thinks he
had been on looks for us. His looks did look like he had.
We went on together. We was just a-going to start down the path
that does lead to our house when we did hear a calling. It was a
mournful sound. I had thinks some little life was much hurt and did
have needs of my help. I felt for the little box of mentholatum in my
pocket. It was there, and some bandages too. The sound came
again. Somewhere in the near woods a voice was calling. I followed
it after. Once I did have thinks it came from a root. And then it was
like it did come from a big tree. It was a pain-voice like someone
calling someone to come. Then it was like a lost voice trying to find
its way among the ferns. It was not a word-voice. It was just a voice
without words.
I did have wonders what voice it was. I followed after its queer
callings. Brave Horatius followed after me. He would stop and look
queer puzzle-looks at nowhere. We did go on. The voice sound came
again. Then it was like a voice lost from the person it did belong to.
It was a clear low cry, like a ripple of gray ribbon. We were more
near to it. We followed it around a big tree. There it was come from
the man on the stump, between that tree and the big tree that was
beyond it. The man, he did throw back his head and the voice came
out his throat and went to nowhere. It came again like little bits of
queer green fire flame, and then it was low and again like a ripple of
gray ribbon. As it was so he did turn his face about. It was the face
of the husband of Sadie McKibben; but the look—the look in his eyes
was a queer wild look that looked looks at nowhere.
70. CHAPTER XXXVIII
How Opal Makes Prepares to Move. How she Collects All the
Necessary Things, Bids Good-bye to Dear Love, and Learns that
her Prayer has been Answered.
We are going to move to the mill town. For a whole week, every
morning now after the morning works is done the mamma does
have me to help her make prepares to move; and after I do be helps
to the mamma, then I do work at making prepares for moving my
belongings when we go goes to the mill town.
I have made begins a week ago. I have been carrying my
belongings to inside an old log a little way away from the house we
do live in. Moving is a big amount of problem. But mostly now I do
have my prepares done. I am going to take with me when we go
goes to the mill just my necessary things—the mamma does say
none but my necessary things can go. She said that was my blue
calico apron and my gray calico apron and the clothes that goes
under them and my two pair of stockings and the shoes I have on
and my sun-bonnet and my slate and Cyr’s Reader.
But I have some more necessary things that the mamma has not
knows of. There is my two books that Angel Mother and Angel
Father did write in and I do study in every day, and the pictures of
mother and père and the pictures of grandmère and grandpère and
tante and oncle, and all the others that I do love much every day;
and to-day there was needs to give the dear picture of père a wash
71. in the brook because last time on yesterday, when I did kiss him, a
little piece of jam from my bread and butter got on his dear face
that does look so like him. And after I did come from the brook I put
them all away in a careful way in the box I do keep them in, and I
said a little prayer.
And I went to bring to the old log the willow whistle the shepherd
did make for me when it was the borning time of the lambs, and the
two flutes he did make of reeds. And now I do have most of my
necessaries in the hollow log. There by it is the lily plant the soul of
Peter Paul Rubens has loves for to be near. And I have planted it in a
little flower-pot Sadie McKibben has given to me. And when we are
moved moves to the mill town I will put the lily plant under the
window of the room I do have sleeps in, so that what the soul of
Peter Paul Rubens does love to be near will be near unto where I
am.
And in the hollow log there is the old logging boot of the husband
of Dear Love, that he has given me to keep some of my rock
collections in. And there is the bath-towel of Thomas Chatterton
Jupiter Zeus that Dear Love has made for him. And there is the color
pencils that the fairies did bring to the moss-box. And there is many
brown papers that Sadie McKibben has given me to print prints on.
And there is the cushion Lola did make for Lucian Horace Ovid Virgil
to sit on in my desk at school. And there is all the patches I do pin
on my underskirt for my animal friends to ride in. And there is the
track of Elizabeth Barrett Browning that I did dig up in the lane. It
has so much of poetry in it. And there is one of the gray neckties of
the man that wears gray neckties and is kind to mice, that he did
give to me for Brave Horatius to wear. And there is the bib of Elsie’s
baby that Elsie did give me for Menander Euripides Theocritus
Thucydides to wear when he was nursing the bottle.
72. And there is seven of the tail-feathers of Lars Porsena that he did
lose when he did lose his tail. And there is four old horse-shoes of
William Shakespeare that the blacksmith did have allows for me to
have when he was putting new shoes onto William Shakespeare.
And there is the thimble of Dear Love that she has given me to carry
drinks of water to the folks in the hospital. And there is the little bell
of Peter Paul Rubens that he did use to wear to service in the
cathedral. And there is Elsie’s baby’s little old shoe that got worn out
and she gave it to me for Nannerl Mozart to sleep in. And there is
the lid of Sadie McKibben’s coffee-pot that she did give me when it
came off. She always did sing over that lid when cooking-time was
come. And there is the traveling-case of Minerva that the pensée girl
with the far-away look in her eyes did make for me to carry all the
christening robes of Minerva’s children in, and more pieces of white
cloth and little ribbons the pensée girl did put into Minerva’s traveling
case for christening-time come next year. And there is the egg-shells
Ben Jonson and Sir Francis Bacon and Pius VII and Nicholas Boileau
and Edmund Spenser and Oliver Goldsmith and John Fletcher and
Francis Beaumont and Cardinal Richelieu and Sir Walter Raleigh and
the rest of Minerva’s children hatched out of. I have thinks there is
needs for me to carry those egg-shells in my apron when we go
moves to the mill town, so they will not have breaks. And there is
the little gray shawl Sadie McKibben so made for Nannerl Mozart.
And there is the little cap that Dear Love did make for my Louis II,
le Grand Condé. It has got a feather in it. He did nibble the end off
the feather, and he had mouse-wants to chew the tassel that she did
put on the bag she did make for me to carry him in. And there is the
ribbon bow off Elsie’s garter she did give me for Felix Mendelssohn
to wear. I have heard the women folks at the farmhouse say this
world would be a nice world if there were n’t any mice in it. I think it
73. would be a most lonesome place. And there is the big handkerchief
of the man of the long step that whistles most all of the time that he
did give to me for Brave Horatius to wear around his neck. And there
is Elsie’s old lace collar that Elizabeth Barrett Browning does wear to
cathedral service. And there is one of the whiskers of Thomas
Chatterton Jupiter Zeus that he did lose.
And there is all the portraits of my friends on poker-chips. And
there is the other white poker-chips that are waiting waits for
pictures to be drawed on them. And there is the blue and the red
poker-chips that is the breakfast and supper plates of the folks in the
nursery and the hospital. And there is Minerva’s white cap that she
does wear to cathedral service with the ruffles on it like are on the
morning cap of Jenny Strong. And there is the long green string I
pulled my tooth with. And there is the split jacket of Padre Martini,
that he did last wear before he was become a grown-up cigale. And
there is the bottle of Menander Euripides Theocritus Thucydides—
the bottle that used to be a brandy bottle. And there is the skins of
the caterpillars they did grow too big for when they were growing
into papillons and phalènes. And there is the two tail-feathers of
Agamemnon Menelaus Dindon. And there is Solomon Grundy’s
christening robe. And there is the little fleur watering-pot the fairies
did bring that I do give my friends shower-baths with. And there is
the cocoon that Charlotte Brontë, the big velvet brown phalène, did
hatch out of; and there is more cocoons that other phalènes did
hatch out of. And there is the ribbon bow Elsie has given me off her
other garter for the pet squirrel Geoffroi Chaucer that the cat did
hurt but is well again. And there is a whole new box of mentholatum
that Sadie McKibben has given me for the little folks I find with hurts
in the mill town. And there is the four vaseline bottles that got
empty after the young husband of Elsie did use all the vaseline in
74. them to keep his pumpadoor smooth. I have uses for those vaseline
bottles to keep food in for the folks of the nursery.
These things I have now in the log. Others of my necessary things
I will bring this eventime and on to-morrow and the next day and
the day after that.
Some of us go to the mill town, but not all of us so go. Dear
Solomon Grundy is sold to a man that does live at one of the edges
of the mill town. Aphrodite is going to stay stays here, and so is
Mathilde Plantagenet and Elizabeth Barrett Browning and Anthonya
Mundy and the gentle Jersey cow and Savonarola and Agamemnon
Menelaus Dindon; and Plato and Pliny are going to live on in the
barn. Brave Horatius is going goes with Aidan of Iona come from
Lindisfarne, and too Menander Euripides Theocritus Thucydides is
going with the shepherd to the blue hills.
Minerva is going to town with us, and so is Sir Francis Bacon and
Ben Jonson and Pius VII and Nicholas Boileau and Sir Walter Raleigh
and all the rest of her dear children, and Clementine and Napoleon
and Andromeda. And by-and-by Thomas Chatterton Jupiter Zeus is
coming comes to the mill town, and so is Felix Mendelssohn and
Louis II, le Grand Condé, and Nannerl Mozart and some of her
children, and Lucian Horace Ovid Virgil and Geoffroi Chaucer and the
caterpillar folks in the nursery. All are when I do have homes fixed
for them about the house we are going to live in in the mill town.
Until then Thomas Chatterton Jupiter Zeus is going to stay with
Dear Love and her husband, and, too, Dear Love does say Lucian
Horace Ovid Virgil can live under her doorsteps until I do have a
place fixed for him under the doorstep of the house we are going to
live in in the mill town. And Sadie McKibben is going to take care of
Geoffroi Chaucer and bring him in to me at the house we are going
75. to live in at the mill town. And the man that wears gray neckties and
is kind to mice is going to take care of all my mouse friends in his
bunk-house, and he is going goes to feed the folks in the nursery
and the hospital.
And often it is I am going to come comes back again here to
cathedral service and talks with them I know, and to leave letters for
the fairies in the moss-box. I have thinks about the mill town. Maybe
in the fields over on the other side of the mill town—maybe there
there will be étourneau and ortolan and draine and durbec and loriot
and verdier and rossignol and pinson and pivoine. When I am come
to the mill town, I will go explores to see, and I will build altars for
Saint Louis. Now I go to see Dear Love.
When I was come near unto her little house, I had seeing of Dear
Love. She was sitting on the steps by her door drying her hair in the
sun. It did wave little ripples of light when the wind did go in a
gentle way by. She let me have feels of its touches. And she did give
me a kiss on each cheek and one on the nose when she lifted me
onto her lap. And then Dear Love did tell me a secret. It’s hers and
her husband’s secret that the angels did let them know ahead—they
are going to have a baby soon.
I felt a big amount of satisfaction. It is about time that prayer was
answered. Some prayers you pray a little while and answers come.
Some prayers you pray more times and answers don’t come. I have
not knows of why. But prayers for babies get answered soon—most
always they do. The time is so long I have been praying prayers for
Dear Love to have a baby soon. And now the angels have told her
it’s going to come in about five months. I have thinks that is quite a
time long to wait waits.
76. And Dear Love has showed me the clothes the angels did tell her
to make ahead for its coming. And there is two little shirts and
bands, and very long underskirts with feather stitches in them, and
there’s a little cream kimona with a blue ribbon bow on it. I looked
looks at it a long time. And Dear Love said she was going to make
one just like it for Thomas Chatterton Jupiter Zeus. I am glad. And
there was more little clothes, and while we was looking at them the
husband of Dear Love did come in the door and he did look adores
at Dear Love. It’s just our secret—just Dear Love’s and her
husband’s and mine. Nobody knows it but just us three, and Thomas
Chatterton Jupiter Zeus and Brave Horatius and Edward I and lovely
Queen Eleanor of Castile and Michael Angelo Sanzio Raphael and
Aphrodite and Lucian Horace Ovid Virgil and Felix Mendelssohn and
Plato and Pliny and Minerva and her chickens and Menander
Euripides Theocritus Thucydides and Louis II, le Grand Condé, and
the willows that grow by Nonette.
Now Brave Horatius and me and Thomas Chatterton Jupiter Zeus
are going to prayers in the cathedral. The great pine tree is saying a
poem, and there is a song in the tree-tops.
77. POSTSCRIPT
After this I lived in a great many other lumber camps, and there
were new people and new animal friends and new nurseries and
other cathedrals. I studied in the woods and wrote down what I saw
and heard. In the spring of 1918 I went from Oregon to Southern
California, to do more research work in natural science, earning my
way by teaching nature classes. In the winter of 1918 I published
my first nature-book, paying for it by taking orders for it in advance.
In the summer of 1919 I came East, hoping to be able to get
another nature-book published. In my going to see publishers, I
came to the editor of the Atlantic. While I was telling the editor
about this book, he asked me if I never kept a diary, and this is the
answer.
After the seventh year and far on into other years I continued the
diary; but perhaps some other time the story of all these things will
be pieced together and made into another book.
78. Transcriber’s Notes
Some page numbers do not appear due to removed blank pages.
In Contents, “xxi” was changed from “xvii”.
Errors in punctuation were repaired.
Except for the following changes, spelling and hyphenation have been
preserved as printed in the original.
Page 17, “thought” changed from “though” (I thought that a walk).
Page 33, “fairies” changed from “faires” (if the fairies yet).
Page 48, “would n’t” changed from “wouldn’t” (ham would n’t be cut up).
Page 50, “maybe” changed from “may be” (thinks maybe his teeth).
Page 87, “that” changed from “what” (baby that has satisfaction).
Page 100, “Grand” changed from “Grande” (le Grand Condé, was asleep).
Page 139, “do” changed from “bo” (I do sing it).
Page 149, duplicated “to” deleted (to go away).
Page 154, “pancake” changed from “pankcake” (and the pancake-turner).
Page 167, “asfiditee” changed from “asafiditee” (piece of asfiditee I did).
Page 170, “Nicholas” changed from “Nicolas” (Nicholas Boileau and Jean).
Page 194, “Plantagenet” changed from “Plantagenent” (is enough for
Mathilde Plantagenet).
Page 218, “could n’t” changed from “couldn ’t” (we could n’t play
together).
Page 218, “By-and-by” changed from “By and-by” (By-and-by I did hear
Solomon).
Page 245, “oléandre” changed from “oleandre” (cornope, oléandre, iris).
Page 252, “mentholatumed” changed from “metholatumed” (I have
mentholatumed).
Page 276, duplicated “and tante” deleted (and tante and oncle).
80. *** END OF THE PROJECT GUTENBERG EBOOK THE STORY OF
OPAL: THE JOURNAL OF AN UNDERSTANDING HEART ***
Updated editions will replace the previous one—the old editions
will be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.
START: FULL LICENSE
82. PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the
free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only
be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
83. 1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E. Unless you have removed all references to Project
Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
84. Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.
1.E.2. If an individual Project Gutenberg™ electronic work is
derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg™ electronic work is
posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files
85. containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
1.E.7. Do not charge a fee for access to, viewing, displaying,
performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.
1.E.8. You may charge a reasonable fee for copies of or
providing access to or distributing Project Gutenberg™
electronic works provided that:
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
86. payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You provide a full refund of any money paid by a user who
notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.
• You provide, in accordance with paragraph 1.F.3, a full refund of
any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.E.9. If you wish to charge a fee or distribute a Project
Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
87. law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except
for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you
discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
88. Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com