| Preface |
|
xv | |
| Foreword |
|
xvii | |
| Technical note |
|
xxiii | |
|
|
|
1 | (4) |
|
Basic programming in C language |
|
|
5 | (234) |
|
1 Numbers and non-numbers |
|
|
7 | (30) |
|
|
|
7 | (1) |
|
|
|
8 | (8) |
|
|
|
10 | (3) |
|
1.2.2 The hexadecimal system |
|
|
13 | (3) |
|
1.3 Representation systems |
|
|
16 | (9) |
|
1.3.1 Representing negative numbers |
|
|
18 | (1) |
|
1.3.2 Complement representation |
|
|
19 | (2) |
|
1.3.3 Excess-N representation |
|
|
21 | (1) |
|
1.3.4 Rational number representation |
|
|
22 | (3) |
|
1.4 The approximation problem |
|
|
25 | (3) |
|
1.5 Non-numbers on computers |
|
|
28 | (1) |
|
1.6 Logical value representation |
|
|
28 | (3) |
|
|
|
29 | (2) |
|
1.7 Character representation |
|
|
31 | (2) |
|
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
33 | (1) |
|
1.8 Representing other information |
|
|
33 | (4) |
|
|
|
37 | (28) |
|
2.1 The necessity of a programming language |
|
|
37 | (6) |
|
2.2 High-level languages and elementary statements |
|
|
43 | (2) |
|
2.2.1 The assembly language |
|
|
44 | (1) |
|
2.3 The role of the compiler |
|
|
45 | (4) |
|
2.3.1 Interpreters and compilers |
|
|
48 | (1) |
|
|
|
49 | (3) |
|
2.5 Procedural and object-oriented languages |
|
|
52 | (3) |
|
|
|
55 | (2) |
|
2.7 History and characteristics of the C language |
|
|
57 | (1) |
|
2.8 C compilers in their environment |
|
|
58 | (7) |
|
|
|
60 | (1) |
|
2.8.2 A first example, in Linux: gcc |
|
|
61 | (3) |
|
2.8.3 Compiling C in Windows |
|
|
64 | (1) |
|
|
|
65 | (28) |
|
|
|
66 | (1) |
|
3.2 Statements, variables, types |
|
|
67 | (4) |
|
|
|
71 | (9) |
|
3.3.1 Arithmetic Operators |
|
|
71 | (6) |
|
|
|
77 | (1) |
|
|
|
78 | (2) |
|
3.4 Input/Output for beginners |
|
|
80 | (4) |
|
3.5 Preprocessor directives |
|
|
84 | (3) |
|
3.6 Notes on library functions |
|
|
87 | (2) |
|
|
|
89 | (4) |
|
|
|
93 | (30) |
|
|
|
94 | (3) |
|
|
|
96 | (1) |
|
|
|
97 | (5) |
|
|
|
99 | (3) |
|
4.2.2 The selection operator |
|
|
102 | (1) |
|
|
|
102 | (12) |
|
|
|
108 | (1) |
|
|
|
109 | (4) |
|
4.3.3 Searching prime numbers |
|
|
113 | (1) |
|
4.4 Deprecated statements |
|
|
114 | (2) |
|
|
|
116 | (7) |
|
5 Fundamental data structures |
|
|
123 | (26) |
|
5.1 One-dimensional arrays |
|
|
124 | (2) |
|
5.2 Algorithms with arrays |
|
|
126 | (6) |
|
5.2.1 Sorting: Bubblesort |
|
|
128 | (2) |
|
|
|
130 | (2) |
|
5.3 Multidimensional arrays |
|
|
132 | (1) |
|
5.4 Solving systems of linear equations |
|
|
133 | (4) |
|
5.5 Generating random numbers |
|
|
137 | (3) |
|
|
|
140 | (9) |
|
|
|
140 | (1) |
|
5.6.2 I/O of character strings |
|
|
141 | (2) |
|
5.6.3 Multidimensional strings and arrays |
|
|
143 | (6) |
|
|
|
149 | (28) |
|
6.1 Pointers and pointed variables |
|
|
149 | (4) |
|
6.2 Arrays and pointers in C |
|
|
153 | (6) |
|
6.2.1 The const qualifier |
|
|
156 | (2) |
|
|
|
158 | (1) |
|
|
|
159 | (3) |
|
|
|
162 | (1) |
|
6.5 Multidimensional arrays and pointers |
|
|
163 | (4) |
|
|
|
165 | (2) |
|
|
|
167 | (1) |
|
6.7 Input/Output with files |
|
|
168 | (9) |
|
|
|
174 | (3) |
|
|
|
177 | (34) |
|
7.1 Declaration and definition |
|
|
177 | (7) |
|
|
|
182 | (2) |
|
|
|
184 | (5) |
|
7.3 Pointers and array parameters |
|
|
189 | (9) |
|
7.3.1 Array in input and output |
|
|
190 | (4) |
|
7.3.2 Passing multidimensional arrays |
|
|
194 | (3) |
|
7.3.3 Global and local variables |
|
|
197 | (1) |
|
|
|
198 | (8) |
|
|
|
198 | (5) |
|
7.4.2 Computing the x2 of a distribution |
|
|
203 | (2) |
|
7.4.3 Programming style and reusability |
|
|
205 | (1) |
|
7.5 Pointers to functions |
|
|
206 | (1) |
|
7.6 Functions of functions |
|
|
207 | (4) |
|
8 Numerical interpolation and integration |
|
|
211 | (28) |
|
|
|
211 | (10) |
|
8.1.1 Determining the parameters of a function |
|
|
213 | (4) |
|
8.1.2 Interpolation with Lagrange polynomials |
|
|
217 | (4) |
|
8.2 Numerical integration |
|
|
221 | (13) |
|
|
|
223 | (2) |
|
8.2.2 The midpoint method |
|
|
225 | (1) |
|
|
|
226 | (3) |
|
8.2.4 Other integration methods |
|
|
229 | (5) |
|
8.3 The Monte Carlo method |
|
|
234 | (5) |
|
|
|
236 | (3) |
|
Advanced programming and simple algorithms |
|
|
239 | (194) |
|
9 Integrating differential equations |
|
|
241 | (30) |
|
9.1 The harmonic oscillator |
|
|
241 | (3) |
|
9.2 Integration algorithms |
|
|
244 | (15) |
|
9.2.1 Euler and Euler-Cromer: convergence and stability |
|
|
246 | (6) |
|
9.2.2 Other methods: midpoint and leapfrog |
|
|
252 | (2) |
|
9.2.3 Physical results of a simple integration |
|
|
254 | (5) |
|
|
|
259 | (3) |
|
9.4 A complete program as a simple example |
|
|
262 | (9) |
|
10 In-depth examination of differential equations |
|
|
271 | (30) |
|
|
|
271 | (8) |
|
10.1.1 Verlet and velocity Verlet |
|
|
272 | (2) |
|
10.1.2 Predictor-corrector and Runge-Kutta |
|
|
274 | (2) |
|
10.1.3 Stability analysis |
|
|
276 | (3) |
|
10.2 system, malloc and typedef |
|
|
279 | (7) |
|
10.2.1 The interaction with the operating system: the function system |
|
|
279 | (1) |
|
10.2.2 Dynamic memory allocation: malloc and calloc |
|
|
280 | (5) |
|
10.2.3 Defining derived types: typedef |
|
|
285 | (1) |
|
|
|
286 | (3) |
|
10.4 Two planets revolving around the sun |
|
|
289 | (3) |
|
10.5 Software tools: gnuplot |
|
|
292 | (2) |
|
|
|
294 | (2) |
|
10.7 The pendulum and chaos |
|
|
296 | (5) |
|
11 (Pseudo)random numbers |
|
|
301 | (32) |
|
11.1 Generating random sequences |
|
|
302 | (2) |
|
|
|
304 | (9) |
|
11.2.1 Choosing the modulo |
|
|
308 | (1) |
|
11.2.2 Choosing the multiplier |
|
|
309 | (2) |
|
11.2.3 Purely multiplicative generators |
|
|
311 | (2) |
|
11.3 Some examples of generators and a first test |
|
|
313 | (3) |
|
|
|
316 | (9) |
|
|
|
317 | (5) |
|
11.4.2 The Kolmogorov-Smirnov test |
|
|
322 | (3) |
|
|
|
325 | (5) |
|
11.6 Generating nonuniform distributions |
|
|
330 | (3) |
|
|
|
333 | (36) |
|
12.1 A first simple crucial argument |
|
|
334 | (7) |
|
12.2 More than one dimension: the generating function |
|
|
341 | (12) |
|
|
|
353 | (11) |
|
12.4 Random walks in random environments |
|
|
364 | (5) |
|
13 Lists, dictionaries and percolation |
|
|
369 | (36) |
|
|
|
369 | (5) |
|
13.1.1 A virtual experiment |
|
|
372 | (2) |
|
|
|
374 | (14) |
|
13.2.1 Lists, strings and a dictionary |
|
|
375 | (7) |
|
13.2.2 Recursive functions: computing the factorial |
|
|
382 | (1) |
|
13.2.3 Binary trees and dictionaries |
|
|
383 | (5) |
|
|
|
388 | (5) |
|
|
|
393 | (7) |
|
13.5 An algorithm based on lists |
|
|
400 | (5) |
|
14 Bits and Boolean variables |
|
|
405 | (28) |
|
14.1 Single bit operators |
|
|
405 | (5) |
|
14.2 How to operate on bits |
|
|
410 | (3) |
|
14.3 A small multiple adder of bits |
|
|
413 | (3) |
|
14.4 Von Neumann and Ulam cellular automatons |
|
|
416 | (10) |
|
|
|
426 | (7) |
|
Programming advanced algorithms |
|
|
433 | (232) |
|
15 Recursion and data sorting |
|
|
435 | (34) |
|
15.1 Analysis of the performance of an algorithm |
|
|
436 | (5) |
|
15.2 A first sorting algorithm: Insertion sort |
|
|
441 | (8) |
|
15.2.1 Insertion sort analysis |
|
|
444 | (1) |
|
15.2.2 Improving Insertion sort |
|
|
445 | (2) |
|
15.2.3 Estimating the execution times |
|
|
447 | (2) |
|
15.3 The recursive "Divide and Conquer" strategy |
|
|
449 | (20) |
|
15.3.1 The recursive logic |
|
|
451 | (1) |
|
15.3.2 A recursive algorithm: Quicksort |
|
|
452 | (4) |
|
15.3.3 Representations of a recursive process |
|
|
456 | (2) |
|
15.3.4 How to write a good recursive function |
|
|
458 | (3) |
|
15.3.5 Quicksort analysis |
|
|
461 | (8) |
|
16 Dynamic data structures |
|
|
469 | (32) |
|
|
|
470 | (7) |
|
|
|
473 | (2) |
|
|
|
475 | (2) |
|
|
|
477 | (12) |
|
|
|
477 | (3) |
|
|
|
480 | (2) |
|
16.2.3 Maintaining a heap |
|
|
482 | (5) |
|
16.2.4 Sorting with a heap: Heapsort |
|
|
487 | (2) |
|
16.3 Elementary search methods |
|
|
489 | (12) |
|
16.3.1 Binary search trees |
|
|
489 | (3) |
|
16.3.2 Inserting and searching in a binary search tree |
|
|
492 | (4) |
|
16.3.3 Deleting elements from a binary search tree |
|
|
496 | (5) |
|
17 Graphs and graph algorithms |
|
|
501 | (38) |
|
17.1 Graph definition and its main properties |
|
|
502 | (5) |
|
17.2 From graphs to data structures |
|
|
507 | (4) |
|
|
|
508 | (1) |
|
|
|
509 | (2) |
|
|
|
511 | (10) |
|
|
|
511 | (4) |
|
17.3.2 Minimum spanning tree |
|
|
515 | (6) |
|
|
|
521 | (6) |
|
|
|
522 | (2) |
|
17.4.2 Percolation in random graphs |
|
|
524 | (3) |
|
17.5 Numerical percolation study |
|
|
527 | (12) |
|
17.5.1 What, how, how often and when to measure |
|
|
531 | (2) |
|
17.5.2 Numerical data analysis: finite size effects |
|
|
533 | (6) |
|
|
|
539 | (40) |
|
18.1 Functions of a single variable |
|
|
540 | (6) |
|
18.2 Minimizing functions of more variables |
|
|
546 | (13) |
|
18.2.1 Sequential descent rule |
|
|
547 | (1) |
|
18.2.2 The gradient method |
|
|
548 | (5) |
|
18.2.3 Functions with a variable number of arguments |
|
|
553 | (3) |
|
18.2.4 Conjugate gradient method |
|
|
556 | (3) |
|
|
|
559 | (9) |
|
18.3.1 Definition of the canonical problem |
|
|
560 | (1) |
|
18.3.2 The simplex method |
|
|
561 | (6) |
|
18.3.3 The simplex method in practice |
|
|
567 | (1) |
|
18.4 Optimization with discrete variables |
|
|
568 | (11) |
|
18.4.1 Satisfability problems |
|
|
569 | (1) |
|
18.4.2 Exhaustive enumeration |
|
|
570 | (3) |
|
18.4.3 A search by construction |
|
|
573 | (6) |
|
19 The Monte Carlo method |
|
|
579 | (42) |
|
19.1 Numeric integration with the Monte Carlo method |
|
|
580 | (5) |
|
19.1.1 Multidimensional integration |
|
|
581 | (1) |
|
|
|
582 | (2) |
|
19.1.3 Importance sampling |
|
|
584 | (1) |
|
19.2 The Markov chain Monte Carlo method |
|
|
585 | (17) |
|
|
|
586 | (4) |
|
19.2.2 Convergence towards the asymptotic distribution |
|
|
590 | (4) |
|
|
|
594 | (2) |
|
19.2.4 The Metropolis algorithm |
|
|
596 | (3) |
|
19.2.5 Barriers ad ergodicity breaking |
|
|
599 | (3) |
|
|
|
602 | (6) |
|
|
|
608 | (13) |
|
19.4.1 Use of look-up tables |
|
|
610 | (1) |
|
19.4.2 Update in random or sequential order |
|
|
611 | (2) |
|
19.4.3 Optimizing the memory accesses |
|
|
613 | (3) |
|
19.4.4 Optimizing the sequence of statements |
|
|
616 | (5) |
|
20 How to use stochastic algorithms |
|
|
621 | (44) |
|
20.1 Examples where Monte Carlo methods are needed |
|
|
621 | (4) |
|
20.2 How to run a good Monte Carlo simulation |
|
|
625 | (12) |
|
20.2.1 Convergence towards equilibrium |
|
|
627 | (4) |
|
20.2.2 Correlations at equilibrium |
|
|
631 | (4) |
|
20.2.3 How to identify a phase transition |
|
|
635 | (2) |
|
|
|
637 | (15) |
|
|
|
638 | (4) |
|
|
|
642 | (3) |
|
20.3.3 Scaling laws and critical exponents |
|
|
645 | (4) |
|
20.3.4 Finite size effects and rescaling |
|
|
649 | (3) |
|
20.4 Optimization with stochastic methods |
|
|
652 | (13) |
|
20.4.1 Genetic algorithms |
|
|
653 | (7) |
|
20.4.2 The simulated annealing method |
|
|
660 | (5) |
| A The main C statements |
|
665 | (6) |
| B The ASCII codes |
|
671 | (2) |
| Bibliography |
|
673 | (4) |
| Index |
|
677 | |