100% found this document useful (3 votes)
39 views

An Introduction to Scientific Computing with MATLAB and Python Tutorials 1st Edition Sheng Xu download

The document is an introduction to scientific computing using MATLAB and Python, authored by Sheng Xu, published by CRC Press in 2022. It covers fundamental concepts such as errors in scientific computing, algorithm properties, and direct methods for linear systems. The document also includes various exercises and programming problems to enhance understanding of the material.

Uploaded by

suggskhoja1u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
39 views

An Introduction to Scientific Computing with MATLAB and Python Tutorials 1st Edition Sheng Xu download

The document is an introduction to scientific computing using MATLAB and Python, authored by Sheng Xu, published by CRC Press in 2022. It covers fundamental concepts such as errors in scientific computing, algorithm properties, and direct methods for linear systems. The document also includes various exercises and programming problems to enhance understanding of the material.

Uploaded by

suggskhoja1u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

An Introduction to Scientific Computing with

MATLAB and Python Tutorials 1st Edition Sheng Xu


install download

https://ebookmeta.com/product/an-introduction-to-scientific-
computing-with-matlab-and-python-tutorials-1st-edition-sheng-xu/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Introduction to Engineering and Scientific Computing


with Python 1st Edition David E. Clough

https://ebookmeta.com/product/introduction-to-engineering-and-
scientific-computing-with-python-1st-edition-david-e-clough/

Python for Astronomers An Introduction to Scientific


Computing 3rd Edition Imad Pasha

https://ebookmeta.com/product/python-for-astronomers-an-
introduction-to-scientific-computing-3rd-edition-imad-pasha/

An Introduction to Scientific Computing Fifteen


Computational Projects Solved with MATLAB 2nd 2nd
Edition Ionut Danaila Pascal Joly Sidi Mahmoud Kaber
Marie Postel
https://ebookmeta.com/product/an-introduction-to-scientific-
computing-fifteen-computational-projects-solved-with-
matlab-2nd-2nd-edition-ionut-danaila-pascal-joly-sidi-mahmoud-
kaber-marie-postel/

Linux Mint 20 Self Help Guide 2nd Edition Unofficial


and Compatible With All Linux Mint 20 Versions
Partridge

https://ebookmeta.com/product/linux-mint-20-self-help-guide-2nd-
edition-unofficial-and-compatible-with-all-linux-
mint-20-versions-partridge/
Archaeological Theory in Practice 2nd Edition Patricia
A Urban Edward Schortman

https://ebookmeta.com/product/archaeological-theory-in-
practice-2nd-edition-patricia-a-urban-edward-schortman/

Everyday Data Cultures 1st Edition Jean Burgess

https://ebookmeta.com/product/everyday-data-cultures-1st-edition-
jean-burgess/

ZEB Police Officer Virgin Curvy Woman Suspense Rescued


Diamond Ridge Mountain Men Book 1 1st Edition Brynn
Hale [Hale

https://ebookmeta.com/product/zeb-police-officer-virgin-curvy-
woman-suspense-rescued-diamond-ridge-mountain-men-book-1-1st-
edition-brynn-hale-hale/

The Trouble With Her (Forbidden Love #4) 1st Edition


Kat T. Masen

https://ebookmeta.com/product/the-trouble-with-her-forbidden-
love-4-1st-edition-kat-t-masen/

Inside Afghanistan Routledge Contemporary South Asia


Series 1st Edition Timor Sharan

https://ebookmeta.com/product/inside-afghanistan-routledge-
contemporary-south-asia-series-1st-edition-timor-sharan/
The Bathysphere Book 1st Edition Brad Fox

https://ebookmeta.com/product/the-bathysphere-book-1st-edition-
brad-fox/
An Introduction to
Scientific Computing
with MATLAB® and
Python Tutorials
An Introduction to
Scientific Computing
with MATLAB® and
Python Tutorials

Sheng Xu
MATLAB ® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks
does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion
of MATLAB ® software or related products does not constitute endorsement or sponsorship by The
MathWorks of a particular pedagogical approach or particular use of the MATLAB ® software.

First edition published 2022


by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742

and by CRC Press


4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN

© 2022 Sheng Xu

CRC Press is an imprint of Taylor & Francis Group, LLC

Reasonable efforts have been made to publish reliable data and information, but the author and pub-
lisher cannot assume responsibility for the validity of all materials or the consequences of their use.
The authors and publishers have attempted to trace the copyright holders of all material reproduced
in this publication and apologize to copyright holders if permission to publish in this form has not
been obtained. If any copyright material has not been acknowledged please write and let us know so
we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, access www.copyright.
com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA
01923, 978-750-8400. For works that are not available on CCC please contact mpkbookspermis-
[email protected]

Trademark notice: Product or corporate names may be trademarks or registered trademarks and are
used only for identification and explanation without intent to infringe.

ISBN: 978-1-032-06315-7 (hbk)


ISBN: 978-1-032-06318-8 (pbk)
ISBN: 978-1-003-20169-4 (ebk)

DOI: 10.1201/9781003201694

Typeset in Nimbus Roman


by KnowledgeWorks Global Ltd.

Publisher’s note: This book has been prepared from camera-ready copy provided by the authors
To my family and friends.
Contents

Preface xiii

Author xv

1 An Overview of Scientific Computing 1


1.1 What Is Scientific Computing? . . . . . . . . . . . . . . . . . . . . 1
1.2 Errors in Scientific Computing . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Absolute and Relative Errors . . . . . . . . . . . . . . . . . 3
1.2.2 Upper Bounds . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Sources of Errors . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Algorithm Properties . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Taylor’s Theorem 9
2.1 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Polynomial Evaluation . . . . . . . . . . . . . . . . . . . . 10
2.2 Taylor’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 Taylor Polynomials . . . . . . . . . . . . . . . . . . . . . . 12
2.2.2 Taylor Series . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3 Taylor’s Theorem . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Alternating Series Theorem . . . . . . . . . . . . . . . . . . . . . 19
2.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 22

3 Roundoff Errors and Error Propagation 25


3.1 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.1.1 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Floating-Point Numbers . . . . . . . . . . . . . . . . . . . . . . . 26
3.2.1 Scientific Notation and Rounding . . . . . . . . . . . . . . 27
3.2.2 DP Floating-Point Representation . . . . . . . . . . . . . . 29
3.3 Error Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.1 Catastrophic Cancellation . . . . . . . . . . . . . . . . . . 32
3.3.2 Algorithm Stability . . . . . . . . . . . . . . . . . . . . . . 33
3.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 37

vii
viii Contents

4 Direct Methods for Linear Systems 43


4.1 Matrices and Vectors . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2 Triangular Systems . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.3 GE and A=LU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.3.1 Elementary Matrices . . . . . . . . . . . . . . . . . . . . . 51
4.3.2 A=LU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3.3 Solving Ax = b by A=LU . . . . . . . . . . . . . . . . . . 55
4.4 GEPP and PA=LU . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.4.1 GEPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.4.2 PA=LU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.4.3 Solving Ax = b by PA=LU . . . . . . . . . . . . . . . . . . 65
4.5 Tridiagonal Systems . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.6 Conditioning of Linear Systems . . . . . . . . . . . . . . . . . . . 69
4.6.1 Vector and Matrix Norms . . . . . . . . . . . . . . . . . . . 72
4.6.2 Condition Numbers . . . . . . . . . . . . . . . . . . . . . . 76
4.6.3 Error and Residual Vectors . . . . . . . . . . . . . . . . . . 77
4.7 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.9 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 82

5 Root Finding for Nonlinear Equations 85


5.1 Roots and Fixed Points . . . . . . . . . . . . . . . . . . . . . . . . 86
5.2 The Bisection Method . . . . . . . . . . . . . . . . . . . . . . . . 90
5.3 Newton’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.3.1 Convergence Analysis of Newton’s Method . . . . . . . . . 96
5.3.2 Practical Issues of Newton’s Method . . . . . . . . . . . . . 99
5.4 Secant Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.5 Fixed-Point Iteration . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.6 Newton’s Method for Systems of Nonlinear Equations . . . . . . . 109
5.6.1 Taylor’s Theorem for Multivariate Functions . . . . . . . . 110
5.6.2 Newton’s Method for Nonlinear Systems . . . . . . . . . . 114
5.7 Unconstrained Optimization . . . . . . . . . . . . . . . . . . . . . 117
5.8 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
5.10 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 127

6 Interpolation 131
6.1 Terminology of Interpolation . . . . . . . . . . . . . . . . . . . . . 132
6.2 Polynomial Space . . . . . . . . . . . . . . . . . . . . . . . . . . 133
6.2.1 Chebyshev Basis . . . . . . . . . . . . . . . . . . . . . . . 135
6.2.2 Legendre Basis . . . . . . . . . . . . . . . . . . . . . . . . 138
6.3 Monomial Interpolation . . . . . . . . . . . . . . . . . . . . . . . 141
6.4 Lagrange Interpolation . . . . . . . . . . . . . . . . . . . . . . . . 143
6.5 Newton’s Interpolation . . . . . . . . . . . . . . . . . . . . . . . . 145
6.6 Interpolation Error . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Contents ix

6.6.1Error in Polynomial Interpolation . . . . . . . . . . . . . . 150


6.6.2Behavior of Interpolation Error . . . . . . . . . . . . . . . 153
6.6.2.1 Equally-Spaced Nodes . . . . . . . . . . . . . . . 153
6.6.2.2 Chebyshev Nodes . . . . . . . . . . . . . . . . . 156
6.7 Spline Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.7.1 Piecewise Linear Interpolation . . . . . . . . . . . . . . . . 159
6.7.2 Cubic Spline . . . . . . . . . . . . . . . . . . . . . . . . . 161
6.7.3 Cubic Spline Interpolation . . . . . . . . . . . . . . . . . . 163
6.8 Discrete Fourier Transform (DFT) . . . . . . . . . . . . . . . . . . 167
6.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
6.10 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 177

7 Numerical Integration 183


7.1 Definite Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
7.2 Numerical Integration . . . . . . . . . . . . . . . . . . . . . . . . 187
7.2.1 Change of Intervals . . . . . . . . . . . . . . . . . . . . . . 189
7.3 The Midpoint Rule . . . . . . . . . . . . . . . . . . . . . . . . . . 191
7.3.1 Degree of Precision (DOP) . . . . . . . . . . . . . . . . . . 192
7.3.2 Error of the Midpoint Rule . . . . . . . . . . . . . . . . . . 195
7.4 The Trapezoidal Rule . . . . . . . . . . . . . . . . . . . . . . . . . 200
7.5 Simpson’s Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
7.6 Newton-Cotes Rules . . . . . . . . . . . . . . . . . . . . . . . . . 209
7.7 Gaussian Quadrature Rules . . . . . . . . . . . . . . . . . . . . . . 209
7.8 Other Numerical Integration Techniques . . . . . . . . . . . . . . . 216
7.8.1 Integration with Singularities . . . . . . . . . . . . . . . . . 216
7.8.2 Adaptive Integration . . . . . . . . . . . . . . . . . . . . . 217
7.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
7.10 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 221

8 Numerical Differentiation 225


8.1 Differentiation Using Taylor’s Theorem . . . . . . . . . . . . . . . 225
8.1.1 The Method of Undetermined Coefficients . . . . . . . . . 227
8.2 Differentiation Using Interpolation . . . . . . . . . . . . . . . . . 229
8.2.1 Differentiation Using DFT . . . . . . . . . . . . . . . . . . 231
8.3 Richardson Extrapolation . . . . . . . . . . . . . . . . . . . . . . 232
8.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.5 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 235

9 Initial Value Problems and Boundary Value Problems 237


9.1 Initial Value Problems (IVPs) . . . . . . . . . . . . . . . . . . . . 238
9.1.1 Euler’s Method . . . . . . . . . . . . . . . . . . . . . . . . 239
9.1.1.1 Local Truncation Error and Global Error . . . . . 242
9.1.1.2 Consistency, Convergence and Stability . . . . . . 244
9.1.1.3 Explicit and Implicit Methods . . . . . . . . . . . 247
9.1.2 Taylor Series Methods . . . . . . . . . . . . . . . . . . . . 248
x Contents

9.1.3 Runge-Kutta (RK) Methods . . . . . . . . . . . . . . . . . 249


9.2 Boundary Value Problems (BVPs) . . . . . . . . . . . . . . . . . . 252
9.2.1 Finite Difference Methods . . . . . . . . . . . . . . . . . . 253
9.2.1.1 Local Truncation Error and Global Error . . . . . 254
9.2.1.2 Consistency, Stability and Convergence . . . . . . 255
9.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
9.4 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 259

10 Basic Iterative Methods for Linear Systems 261


10.1 Jacobi and Gauss-Seidel Methods . . . . . . . . . . . . . . . . . . 263
10.1.1 Jacobi Method . . . . . . . . . . . . . . . . . . . . . . . . 264
10.1.2 Gauss-Seidel (G-S) Method . . . . . . . . . . . . . . . . . 267
10.2 Convergence Analysis . . . . . . . . . . . . . . . . . . . . . . . . 270
10.3 Other Iterative Methods . . . . . . . . . . . . . . . . . . . . . . . 272
10.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
10.5 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 274

11 Discrete Least Squares Problems 277


11.1 The Discrete LS Problems . . . . . . . . . . . . . . . . . . . . . . 278
11.2 The Normal Equation by Calculus . . . . . . . . . . . . . . . . . . 281
11.3 The Normal Equation by Linear Algebra . . . . . . . . . . . . . . 284
11.4 LS Problems by A=QR . . . . . . . . . . . . . . . . . . . . . . . . 286
11.5 Artificial Neural Network . . . . . . . . . . . . . . . . . . . . . . 287
11.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
11.7 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 292

12 Monte Carlo Methods and Parallel Computing 295


12.1 Monte Carlo Methods . . . . . . . . . . . . . . . . . . . . . . . . 297
12.2 Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . 298
12.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
12.4 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 302

Appendices 305

A An Introduction of MATLAB for Scientific Computing 307


A.1 What is MATLAB? . . . . . . . . . . . . . . . . . . . . . . . . . . 307
A.1.1 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . 307
A.1.2 MATLAB as an Advanced Calculator . . . . . . . . . . . . 308
A.1.3 Order of Operations . . . . . . . . . . . . . . . . . . . . . 308
A.1.4 MATLAB Built-in Functions and Getting Help . . . . . . . 309
A.1.5 Keeping a Record for the Command Window . . . . . . . . 310
A.1.6 Making M-Scripts . . . . . . . . . . . . . . . . . . . . . . 310
A.2 Variables, Vectors and Matrices . . . . . . . . . . . . . . . . . . . 311
A.2.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
A.2.2 Suppressing Output . . . . . . . . . . . . . . . . . . . . . . 312
A.2.3 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . 312
Contents xi

A.2.4 Special Matrices . . . . . . . . . . . . . . . . . . . . . . . 313


A.2.5 The Colon Notation and linspace . . . . . . . . . . . . . 314
A.2.6 Accessing Entries in a Vector or Matrix . . . . . . . . . . . 315
A.3 Matrix Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . 317
A.3.1 Scalar Multiplication . . . . . . . . . . . . . . . . . . . . . 317
A.3.2 Matrix Addition . . . . . . . . . . . . . . . . . . . . . . . 317
A.3.3 Matrix Multiplication . . . . . . . . . . . . . . . . . . . . . 318
A.3.4 Transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
A.3.5 Entry-wise Convenience Operations . . . . . . . . . . . . . 320
A.4 Outputting/Plotting Results . . . . . . . . . . . . . . . . . . . . . 321
A.4.1 disp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
A.4.2 fprintf . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
A.4.3 plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
A.5 Loops and Decisions . . . . . . . . . . . . . . . . . . . . . . . . . 325
A.5.1 for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . 325
A.5.2 Logicals and Decisions . . . . . . . . . . . . . . . . . . . . 327
A.5.3 while Loops . . . . . . . . . . . . . . . . . . . . . . . . . 329
A.6 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
A.6.1 M-Functions . . . . . . . . . . . . . . . . . . . . . . . . . 330
A.6.2 Anonymous Functions . . . . . . . . . . . . . . . . . . . . 332
A.6.3 Passing Functions to Functions . . . . . . . . . . . . . . . . 333
A.7 Creating Live Scripts in the Live Editor . . . . . . . . . . . . . . . 334
A.8 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . 335
A.9 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 336

B An Introduction of Python for Scientific Computing 339


B.1 What is Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
B.1.1 Starting Python . . . . . . . . . . . . . . . . . . . . . . . . 339
B.1.2 Python as an Advanced Calculator . . . . . . . . . . . . . . 340
B.1.3 Python Programs . . . . . . . . . . . . . . . . . . . . . . . 342
B.2 Variables, Lists and Dictionaries . . . . . . . . . . . . . . . . . . . 342
B.2.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
B.2.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
B.2.3 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . 345
B.3 Looping and Making Decisions . . . . . . . . . . . . . . . . . . . 347
B.3.1 for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . 347
B.3.2 if Statements . . . . . . . . . . . . . . . . . . . . . . . . . 349
B.3.3 while Loops . . . . . . . . . . . . . . . . . . . . . . . . . 351
B.3.4 break and continue in Loops . . . . . . . . . . . . . . . 352
B.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
B.4.1 Passing Arguments . . . . . . . . . . . . . . . . . . . . . . 355
B.4.2 Passing Lists . . . . . . . . . . . . . . . . . . . . . . . . . 357
B.5 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
B.5.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
B.5.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
xii Contents

B.5.3 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . 362


B.5.4 Objects as Attributes . . . . . . . . . . . . . . . . . . . . . 364
B.6 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
B.7 numpy, scipy, matplotlib . . . . . . . . . . . . . . . . . . . . . . . 370
B.7.1 numpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
B.7.2 scipy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
B.7.3 matplotlib . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
B.8 Jupyter Notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
B.9 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . 376
B.10 Programming Problems . . . . . . . . . . . . . . . . . . . . . . . 376

Index 379
Preface

Features of the Book


We write this book to have the following features.
• We cover fundamental numerical methods in the book. The book can be used as a
textbook for a first course in scientific computing. The prerequisites are calculus
and linear algebra. A college student in science, math or engineering can take the
course in sophomore year.
• We write this book for students. We present the material in a self-contained
accessible manner for a student to easily follow and explore. We use motivating
examples and application problems to catch a student’s interest. We add remarks
at various places to satisfy a student’s curiosity.
• We provide short tutorials on MATLAB® and Python. We give pseudocodes of
algorithms instead of source codes. With the tutorials and pseudocodes, a student
can enjoy writing programs in MATLAB or Python to implement, test and apply
algorithms.
• We balance the underlying idea, algorithm implementation and performance analy-
sis for a fundamental numerical method so that a student can gain comprehensive
understanding of the method.
• We review necessary material from calculus and linear algebra at appropriate
places. We also make the connection between the fundamental numerical methods
with advanced topics such as machine learning and parallel computing.
• We design paper-and-pen exercises and programming problems so that stu-
dents can apply, test and analyze numerical methods toward comprehensive
understanding and practical applications.

Sample Syllabi
Below is a sample syllabus for a two-semester course sequence.

Semester 1
1. Appendix A or B: MATLAB or Python Tutorial

xiii
xiv Preface

2. Chapter 1: An Overview of Scientific Computing


3. Chapter 2: Taylor’s Theorem
4. Chapter 3: Roundoff Errors and Error Propagation
5. Sections 5.1–5.5: Root Finding for Nonlinear Equations
6. Sections 6.1–6.6: Interpolation
7. Sections 7.1–7.6: Numerical Integration
8. Chapter 8: Numerical Differentiation

Semester 2
1. Chapter 4: Direct Methods for Linear Systems
2. Sessions 5.6–5.7: Nonlinear Systems and Optimization
3. Sessions 6.6–6.7: Spline Interpolation and DFT
4. Sessions 7.7–7.8: Gaussian Quadrature Rules
5. Chapter 9: IVPs and BVPs
6. Chapter 10: Iterative Methods for Linear Systems
7. Chapter 11: LS Problems
8. Chapter 12: Monte Carlo Methods and Parallel Computing

Acknowledgments
We acknowledge our colleagues Daniel Reynolds and Johannes Tausch for detailed
critiques of this first edition. We would appreciate any comments, suggestions and
corrections that readers may wish to send us using the email address [email protected].
Author

Sheng Xu is associate professor of mathematics at Southern Methodist University


(SMU). He holds a Ph.D. in mechanical engineering from Cornell University. He
conducts research on development and application of computational methods for
problems in fluid mechanics, including aerodynamics of insect flight, two-fluid flows,
supersonic turbulence, and turbulence control. His published work has appeared in
Journal of Computational Physics, SIAM Journal on Scientific Computing, Physics of
Fluids, and Journal of Fluid Mechanics.

xv
1
An Overview of Scientific Computing

In this chapter, we address what scientific computing is about and why it is important.
We give a brief introduction to algorithms and errors. We emphasize the importance
of error upper bounds.

1.1 What Is Scientific Computing?


Let’s consider two examples first.
Example 1.1 (Apple in free fall) An apple falls from a tree under gravity. How long
does it take to reach the ground (or Newton’s head)?
[Solution:] Assume that the apple has a zero initial velocity and falls without drag.
Denote the height of the apple as H and Earth’s gravity as g. By Newton’s second law,
the time T that the apple takes to reach the ground satisfies
1 2
gT = H
2
This equation can be solved exactly (analytically) to give
s
2H
T=
g


Example 1.2 (Particle chasing) Two particles A and B move from the same location
along a straight path in the same direction. The particle A moves with the constant
speed 2, and the particle B starts with a zero speed and accelerates with a time-
dependent speed et − 1, where t is the time. How long does the particle B take to catch
the particle A?
[Solution:] When the particle B catches up with the particle A at t = T > 0, they
travel the same distance. TheRdistance traveled by the particle A is 2T , and the distance
traveled by the particle B is 0T (et − 1)dt. The time T therefore satisfies
Z T
2T = (et − 1)dt, T >0
0

DOI: 10.1201/9781003201694-1 1
2 An Overview of Scientific Computing

which gives
3T + 1 = eT , T >0
This equation cannot be solved analytically using elementary functions, but we
clearly know it has a positive real solution from the physics intuition or the plots of
f (T ) = 3T + 1 and g(T ) = eT in Fig. 1.1. 

20
y=3t+1
18 y=e
t

16

14

12

10
y

0
0 0.5 1 1.5 2 2.5 3
t

FIGURE 1.1
Graphs of f (T ) = 3T + 1 and g(T ) = eT for T ∈ [0, 3].

In the first example, we can find an analytical solution of the equation. An


analytical solution is a closed-form expression for an unknown variable in terms
of the known variables. However, the analytical solutions of many mathematical
problems may not be available or may be difficult to obtain, such as in the second
example. We therefore resort to scientific computing to find numerical solutions of
those mathematical problems. A numerical solution is an approximate solution of a
problem, and it appears as numerical values instead of closed-form expressions.
Scientific computing involves the development and study of step-by-step proce-
dures to find numerical solutions of mathematical problems. The step-by-step pro-
cedures are called (numerical) algorithms. A numerical/computational method
refers to both the idea underlying an algorithm and the fulfillment of the idea as an
algorithm. We sometimes do not distinguish a method with an algorithm.
For the second example above, we may devise an algorithm to approximate
the solution as follows. We notice that the solution is between 1 and 3 because
f (1) = 3 × 1 + 1 > g(1) = e1 while f (3) = 3 × 3 + 1 < g(3) = e3 (the solid curve
is above the dashed curve at 1 while below at 3 in Fig. 1.1). We can then bisect
Errors in Scientific Computing 3

the interval [1, 3] by the middle point 2 and look at the two subintervals [1, 2] and
[2, 3]. We can use the same strategy to narrow down the solution to one subinterval,
in this case [1, 2]. We can repeatedly apply this strategy until we find a subinterval
that contains the solution and is small enough such that its middle point is a good
approximation of the solution. Actually, this procedure is called bisection iteration,
which will be learned in more details later in Section 5.2 of Chapter 5.
Scientific computing, theoretical study and experiments are three pillars to support
scientific research and technological applications. The diagram in Fig. 1.2 shows
where scientific computing comes into play.
Experiments Computers

modeling scientific
Real−world Problems Mathematical Models Numerical Solutions
computing

physics, engineering, biology, ... understanding, analysis, prediction, design, ...

FIGURE 1.2
Scientific computing in solving real-world problems.

With the advancement of modern computers, scientific computing plays a heavier


and heavier role in almost all areas. This introductory text will give you a taste of
scientific computing and prepares you for your broader and deeper exploration and
application of scientific computing.

1.2 Errors in Scientific Computing


The results from scientific computing are typically approximate. One important goal
in scientific computing is to ensure that the approximate results are close enough to
the true/exact results.

1.2.1 Absolute and Relative Errors

Definition 1.1 Let T denote the true/exact value of a scalar/number, and A an


approximation of the scalar. We define the error E, the absolute error |E| and the
relative error R of the approximation A as follows, respectively
• The error: E = T − A
• The absolute error: |E| = |T − A|
|T − A| |E|
• The relative error: R = = , if T 6= 0
|T | |T |
4 An Overview of Scientific Computing

The relative error is often used to compare approximations of numbers of widely


different scales.
Example 1.3 (Absolute and relative errors) The absolute errors in the measure-
ments of the thickness of a book 5 cm thick and a paper 0.2 mm thick are both
0.1 mm. Are the two measurements of the same quality? Which one is better?
[Solution:] The absolute errors are the same, but the relative errors are quite differ-
ent. The relative error in the measured book thickness is 0.1/50 = 0.002 = 0.2%,
which is much smaller than the relative error in the measured paper thickness,
0.1/0.2 = 0.5 = 50%. The two measurements are not of the same quality, and the
measurement of the book thickness has better quality. 

1.2.2 Upper Bounds


In real practice, we know the approximation but do not know the true value (otherwise
we may not need the approximation), and we therefore do not know the exact value of
an error (absolute or relative), but we can find an upper bound for the absolute or
relative error, which is a value that the error cannot exceed. The error may reach an
upper bound if the upper bound is sharp. For example, if we know the absolute error
in an approximation ranges in [0, 1] and can be 1, then 1 is a sharp upper bound, and
it is true that the absolute error is also less than the upper bound 100, but the upper
bound 100 may not be quite useful. So we want to find an upper bound as sharp as
possible (i.e. the minimum upper bound).
Example 1.4 (Upper bounds) Let A = 3.14 be an approximation of π. Find a mean-
ingful upper bound of the absolute error in the approximation.
[Solution:] The true value of π is

π = 3.14159 · · ·

The approximation A is
A = 3.14
The absolute error |E| in the approximation is

|E| = |π − A| = |3.14159 · · · − 3.14| = 0.00159 · · · < 0.0016

We can choose 0.0016 to be an upper bound, which is “sharper” (“better”) than an


upper bound 0.002. An upper bound 0.1 is not wrong, but not meaningful. 

1.2.3 Sources of Errors


Where are errors from? According to their sources, we can categorize errors into the
following three types.
Algorithm Properties 5

• Modeling errors: the errors due to the simplifications and hypotheses in the
modeling process that convert a real-world problem into a mathematical model.
For example, the error due to the neglect of air resistance in the apple’s free fall
problem above. Modeling errors are not in the scope of scientific computing.
• Mathematical approximation errors: the errors due to the approximation of an
actual quantity by an approximate formula.
Example 1.5 We know that f 0 (a), the derivative of f (x) at x = a, is the slope of
f (a + h) − f (a)
the tangent line to the curve y = f (x) at x = a; and , where h is
h
finite, is the slope of the secant line through the points (a, f (a)) and (a + h, f (a +
h)) on the curve y = f (x). If we approximate the tangent slope T = f 0 (a) by
f (a + h) − f (a)
the secant slope A = , we have the mathematical approximation
h
error:
f (a + h) − f (a)
|T − A| = f 0 (a) −
h
Later, we will analyze how this error depends on the value of h using Taylor’s
theorem and introduce the big-O notation to describe this dependence. 
• Roundoff errors: the errors due to finite-precision representation of real numbers.
Example 1.6 Let x̂ = 1.2345679 be a 8-digit representation of x = 1.23456789.
The absolute error |x − x̂| = 0.00000001 = 10−8 is caused by rounding x to x̂ and
is the roundoff error in the representation. Later, we will describe how computers
represent real numbers and learn that roundoff errors are inevitable in computer
representations. 

1.3 Algorithm Properties


A numerical algorithm is a step-by-step procedure to find the numerical solution of a
mathematical problem. We care about the following three properties of a numerical
algorithm.
Accuracy Accuracy concerns about the magnitude of the error in a numerical solution.
The error needs to be controlled in an acceptable range.
Efficiency Efficiency includes time efficiency and storage efficiency. Time efficiency
depends on how many arithmetic operations are needed in an algorithm. Storage
efficiency depends on how many memory space is needed to execute an algorithm.
Stability An algorithm is stable if small errors (inevitable in practice) introduced in
the algorithm stay small. If the small errors get amplified to be out of control, the
algorithm is unstable.
Later we will use specific algorithms to illustrate and discuss these properties.
6 An Overview of Scientific Computing

1.4 Exercises
Exercise 1.1 A1 is an approximation of T1 = 1 with the absolute error 1, and A2 is
an approximation of T2 = 100 with the absolute error 1. Which approximation (A1 or
A2 ) has better accuracy? Why?

Exercise 1.2 (1) Suppose the true value T = 2, and the relative error of its approx-
imation A is less than 5%. What is the range for A? (2) Suppose an approximation
A = 99, and the relative error in A is 10%. What are the possible values of the true
value T ?

Exercise 1.3 If A = 10 is an approximation of a true value T which is in the range


8 ≤ T ≤ 11, find an upper bound for the absolute error and an upper bound for the
relative error of the approximation.

1 n
 
Exercise 1.4 Euler’s number e can be defined as e = lim 1 + . It is a famous
n→∞ n
transcendental number with infinitely many digits e = 2.718282828459.... Suppose
1 2
 
one approximates e by A = 1 + with n = 2. (1) Find a meaningful upper bound
2
for the absolute error of the approximation. (2) Find a meaningful upper bound for
the relative error of the approximation.

Exercise 1.5 If the function y = sin(x) is approximated by the function y = x for


x ∈ [−π/2, π/2], which type does the error of the approximation belong to? How
does the absolute error change as |x| increases toward π/2?

Exercise 1.6 Let Ah be an approximation of the true value T . Suppose the approxima-
tion Ah depends on a small parameter h, and the absolute error |T − Ah | depends on h
as |T − Ah | = Ch p , where C > 0 and p > 0 are constants. (1) To make the error small,
do we want a small or large value of p? (2) If we double the value of h, how many
times larger does the absolute error become for p = 1, p = 2 and p = 3, respectively?

Exercise 1.7 Count the total number of multiplications in the nested loops of the
following pseudocodes.
(1)
for m = 1 to 20 do
for n = 1 to 20 do
bm = bm − Gm,n bn
end for
end for
(2)
for m = 1 to 20 do
for n = m to 20 do
bm = bm − Gm,n bn
Exercises 7

end for
end for

Exercise 1.8 If you are asked to evaluate p4 (x) = 1 + 2x + 3x2 + 4x3 + 5x4 at a given
value of x, how many multiplications do you use? (Note that evaluating xn as x ·x · · · · ·x
needs n − 1 multiplications.) Can you use less?
2
Taylor’s Theorem

In this chapter, we presents Taylor’s theorem, which is used later for development
and analysis of some numerical methods. We show how to approximate functions by
Taylor polynomials and how to analyze the errors in such approximations. The big-O
notation is introduced to describe efficiency and accuracy.

2.1 Polynomials
A polynomial pn (x) in the variable x of degree n, where n is a non-negative integer,
can be written in the general form as

pn (x) = c0 + c1 x + c2 x2 + · · · + cn−1 xn−1 + cn xn (2.1)

where c0 , c1 , c2 ,...,cn−1 and cn are constant coefficients (if cn 6= 0, n is the true/exact


degree). The summation in pn (x) can be written in the sigma notation as
n
c0 + c1 x + c2 x2 + · · · + cn−1 xn−1 + cn xn ≡ ∑ ck x k (2.2)
k=0

Note that pn (x) is built from constant coefficients and the variable x using only
addition, multiplication and exponentiation of x to non-negative integer powers (re-
peated multiplication). So polynomials can be easily evaluated, differentiated and
integrated, and are good candidates to approximate functions or data.
The polynomial pn (x) can be regarded as a linear combination of the monomial
basis functions 1, x, x2 , ..., xn−1 and xn using the constant weights c0 ,c1 , ..., cn−1 and
cn , respectively. Later we will construct a polynomial of degree at most n as a linear
combination of other basis functions.
A polynomial centered at the number a has the form

pn (x) = c0 + c1 (x − a) + c2 (x − a)2 + · · · + cn−1 (x − a)n−1 + cn (x − a)n (2.3)

Below are a few examples of polynomials


• z(x) = 0: a zero polynomial (of undefined degree)
• p0 (x) = −5: a constant polynomial (of degree 0)

DOI: 10.1201/9781003201694-2 9
10 Taylor’s Theorem

• p1 (x) = 2 + 3x: a linear polynomial (of degree 1)


• p2 (x) = π + 1.3x − 2.7x2 : a quadratic polynomial (of degree 2)
• p3 (x) = −6 + 2(x − 7) − 5(x − 7)2 + (x − 7)3 : a cubic polynomial (of degree 3)
centered at 7
• p4 (x) = c0 + c1 x + c2 x2 + c3 x3 + c4 x4 : a polynomial of degree ≤ 4 (= 4 if c4 6= 0)
Later, we will define the orthogonality of polynomials and introduce special
polynomials such as Chebyshev polynomials and Legendre polynomials.
A very important theorem regarding polynomials is the fundamental theorem of
algebra.

Theorem 2.1 (Fundamental theorem of algebra) Let pn (x) = cn xn +


cn−1 x n−1 2
+ · · · + c2 x + c1 x + c0 , cn 6= 0, be a polynomial of degree n.
Then pn (x) can be factorized as

pn (x) = cn (x − r1 )(x − r2 ) · · · (x − rn ) (2.4)

i.e. the polynomial equation pn (x) = 0 has n roots r1 , r2 , ... , rn .

Remark The roots can be repeated and can be complex numbers. The theo-
rem can be proved using complex analysis.

2.1.1 Polynomial Evaluation


Let’s count the numbers of additions and multiplications in evaluating

p4 (x) = 1 + 2x + 3x2 + 4x3 + 5x4

at a given value of x using different methods.


Naive method: xk , k = 2, 3, 4, in p4 (x) is calculated as x · x · · · · · x, the repeated
multiplication of x for k − 1 times. So the term ck xk needs k multiplications. The total
number of multiplications in evaluating p4 (x) is
4
0+1+2+3+4 ≡ ∑ k = 10.
k=0

The total number of additions in evaluating p4 (x) is 4.


Horner’s method: We can reduce the number of multiplications by calculating xk
as xk−1 · x if xk−1 is known. To use this fact, we can write p4 (x) in the form of nested
multiplication
p4 (x) = 1 + x · (2 + x · (3 + x · (4 + 5 · x)))
Taylor’s Theorem 11

where only 4 multiplications are required. The number of additions is still 4. The
evaluation procedure using nested multiplication is known as Horner’s method.
The above analysis can be easily extended to a polynomial of degree n, pn (x) =
∑nk=0 ck xk , for which the naive method needs
n
n(n + 1)
∑ k = 0+1+2+3+···+n = 2
(2.5)
k=0

multiplications and n additions, while Horner’s method requires n multiplications and


n additions. So Horner’s method is more efficient (in terms of computational time).
We may use the big O notation to describe the efficiency of a method. Denote
the size of a problem as n and the computational time of a method for the problem as
w. We say that the computational time is of order f (n), i.e.

w = O( f (n)) (2.6)

which means that the growth of the computational time w is bounded from above for
large enough n as
w ≤ C f (n) (2.7)
where C is a positive constant. For example, the computational time of the naive
method for polynomial evaluation is O(n2 ), while Horner’s method is O(n), where n
is the degree of a polynomial.
The polynomial pn (x) centered at a in the form of nested multiplication is

pn (x) = c0 +(x−a)·(c1 +(x−a)·(c2 +· · ·+(x−a)·(cn−1 +(x−a)·cn ) · · · )) (2.8)

which can be evaluated by Horner’s method by starting with the innermost parentheses
and working outward. The pseudocode of Horner’s method is

Algorithm 1 Horner’s method to evaluate the polynomial pn (x) = c0 + c1 (x − a) +


c2 (x − a)2 + · · · + cn−1 (x − a)n−1 + cn (x − a)n
p ← cn
z ← x−a
for k from n − 1 down to 0 do
p ← ck + z · p
end for

2.2 Taylor’s Theorem


Taylor’s theorem is very important for us in scientific computing to construct and
analyze numerical approximations. Below we distinguish Taylor polynomials and
Taylor series, and then review Taylor’s theorem.
12 Taylor’s Theorem

2.2.1 Taylor Polynomials


Let f (x) be a function with continuous first n derivatives (i.e. continuous f 0 , f 00 , . . .,
f (n) ) in an interval I containing the number a (we may say f ∈ CIn , where CIn denotes
the function space consisting of all functions with continuous first n derivatives in
the interval I). The Taylor polynomial of degree n for the function f (x) about a is

f 00 (a) f (n) (x)


Tn (x) = f (a) + f 0 (a)(x − a) + (x − a)2 + · · · + (x − a)n
2! n!
n
f (k) (a)
≡ ∑ (x − a)k (2.9)
k=0 k!

where k! = 1 · 2 · · · · · k is the factorial of k and 0! := 1.

Remark T1 (x) = f (a) + f 0 (a)(x − a) is the linearization of f (x) at a (the


tangent line equation).

The Taylor polynomial Tn (x) is constructed using the derivatives of f (x) at a such
that Tn (x) and f (x) satisfy the following matching conditions at a

Tn (a) = f (a) (2.10)


Tn0 (a) = f 0 (a) (2.11)
Tn00 (a) = f 00 (a) (2.12)
···
T (n) (a) = f (n) (a) (2.13)

Example 2.1 (Taylor polynomials) Find the Taylor polynomial of degree 2 for
f (x) = 1 + 2x + 3x2 about a = 1.
[Solution:] In this problem, f (x) = 1 + 2x + 3x2 and a = 1. The Taylor polynomial is

f 00 (1)
T2 (x) = f (1) + f 0 (1)(x − 1) + (x − 1)2
2!
We have

f (x) = −1 + 2x + 3x2 , f (1) = 4


f 0 (x) = 2 + 6x, f 0 (1) = 8
f 00 (x) = 6, f 00 (1) = 6

So the Taylor polynomial is

T2 (x) = 4 + 8(x − 1) + 3(x − 1)2


Taylor’s Theorem 13

2.2.2 Taylor Series


If f (x) is infinitely differentiable over an interval containing the number a, we can
write down Taylor series/expansion of f (x) about a as

f 00 (a) ∞
f (k) (a)
f (x) ∼ f (a) + f 0 (a)(x − a) + (x − a)2 + · · · ≡ ∑ (x − a)k (2.14)
2! k=0 k!

Note that
(1) the Taylor series (on the right) can be regarded as limn→∞ Tn (x), and a Taylor
polynomial is a truncated Taylor series;
(2) the symbol ∼ is used to indicate that the Taylor series may not equal f (x); If the
Taylor series converges to f (x) for any x in an interval, we can replace ∼ by =
with the specification of the convergence interval;
(3) the Taylor series is also called the Maclaurin series if a = 0.
Below are some familiar convergent Maclaurin series with their convergence
intervals.
x2 x3 ∞ k
x
ex = 1 + x + + +··· ≡ ∑ , |x| < ∞ (2.15)
2! 3! k=0 k!

x3 x5 x7 ∞
(−1)k x2k+1
sin x = x − + − +··· ≡ ∑ , |x| < ∞ (2.16)
3! 5! 7! k=0 (2k + 1)!

x2 x4 x6 ∞
(−1)k x2k
cos x = 1 − + − +··· ≡ ∑ , |x| < ∞ (2.17)
2! 4! 6! k=0 (2k)!


1
= 1 + x + x2 + x3 + · · · ≡ ∑ xk , |x| < 1 (2.18)
1−x k=0

x3 x5 x7 ∞
(−1)k x2k+1
tan−1 x = x − + − +··· ≡ ∑ , |x| ≤ 1 (2.19)
3 5 7 k=0 2k + 1

x2 x3 x4 ∞
(−1)k−1 xk
ln(1 + x) = x − + − +··· ≡ ∑ , −1 < x ≤ 1, (2.20)
2 3 4 k=1 k

p(p − 1) 2 p(p − 1)(p − 2) 3


(1 + x) p = 1 + px + x + x +···
2! 3!
∞  
p k
≡ ∑ x , |x| < 1 (2.21)
k=0 k
14 Taylor’s Theorem

In the last binomial series, the power p is real, and the binomial notation is defined by
 
p p(p − 1) · · · (p − k + 1)
:= (2.22)
k k!
We may substitute x by new variables in the above series or integrate or differenti-
ate the above series to obtain new series.
Example 2.2 Substitute x by −t 2 in the Maclaurin series for ex , we get
2 t4 t6 ∞
(−1)k t 2k
e−t = 1 − t 2 + − +··· ≡ ∑ , |t| < ∞ (2.23)
2! 3! k=0 k!

Example 2.3 Substitute 1 + x by t in the Maclaurin series for ln(1 + x), we get the
Taylor series of lnt about a = 1 as
(t − 1)2 (t − 1)3 (t − 1)4
lnt = (t − 1) − + − +···
2 3 4

(−1)k−1 (t − 1)k
≡ ∑ , |t − 1| < 1 (0 < t < 2) (2.24)
k=1 k


2.2.3 Taylor’s Theorem


Polynomials can be easily evaluated with only additions, subtractions and multipli-
cations. In addition, polynomials can be easily √differentiated and integrated. Many
other functions, for example sin x, ex , ln x and x, cannot be evaluated exactly using
only these arithmetic operations. It is thus desirable to approximate a function by
a polynomial. Here we approximate a function by its Taylor polynomials and use
Taylor’s theorem to analyze the errors. Later, we will also approximate a function by
other kinds of polynomials.
Fig. 2.1 shows the graphs of y = cos x and the Taylor polynomials T0 (x), T2 (x) and
T4 (x) of the degrees 0, 2 and 4, respectively, for f (x) = cos x about a = 0 on [−π, π],
where
T0 (x) = 1
x2
T2 (x) = 1 −
2!
x2 x4
T4 (x) = 1 − +
2! 4!
which are obtained by truncating the Maclaurin series of y = cos x. In this case, the
Taylor polynomials approximate f (x) well if x is close to a; and a higher-order Taylor
polynomial approximates f (x) better for a fixed value of x on [−π, π].
The accuracy of Taylor polynomial approximation can be analyzed using Taylor’s
theorem.
Taylor’s Theorem 15

Taylor polynomials of f(x)=cos(x) at 0


2
y=cos(x)
T 0 (x)
1 T 2 (x)
T 4 (x)

-1
y

-2

-3

-4
-3 -2 -1 0 1 2 3
x

FIGURE 2.1
Approximations of y = cos x, x ∈ [−π, π] by its Taylor polynomials of different
degrees.

n+1
Theorem 2.2 (Taylor’s Theorem) Assume f (x) ∈ C[α,β ]
, and let a be a number
in (α, β ). Then

f (x) = Tn (x) + Rn (x), x ∈ [α, β ] (2.25)

where
n
f (k) (a)
Tn (x) = ∑ (x − a)k (2.26)
k=0 k!
is the n-th order Taylor polynomial of f at a, and Rn (x) is called Taylor’s
remainder (or the error term in approximating f (x) by Tn (x)). Taylor’s remainder
Rn (x) in Lagrange mean value form is

f (n+1) (c)
Rn (x) = (x − a)n+1 (2.27)
(n + 1)!

where c is a point (generally unknown to us) between a and x.


16 Taylor’s Theorem

Remark Taylor’s theorem can be proved by repeatedly applying Rolle’s


theorem to the function
(t − a)n+1
g(t) = f (t) − Tn (t) − ( f (x) − Tn (x))
(x − a)n+1

which is a function of t that satisfies g(a) = g0 (a) = · · · = g(n) (a) = 0 and g(x) =
0.
Remark Taylor’s remainder Rn (x) also has an integral form as
Z x n+1
f (t)
Rn (x) = (t − x)n dt (2.28)
a n!
which can be revealed using integration by parts as follows
Z x Z x
f (x) = f (a) + f 0 (t)dt = f (a) + f 0 (t)(t − x)0 dt
a a
Z x
= f (a) + f 0 (a)(x − a) − f 00 (t)(t − x)dt
a
0
(t − x)2
Z x 
0 00
= f (a) + f (a)(x − a) − f (t) dt
a 2
(x − a)2 (t − x)2
Z x
= f (a) + f 0 (a)(x − a) + f 00 (a) + dt f 000 (t)
a 2 2
0
(x − a)2 (t − x)3
Z x 
0 00 000
= f (a) + f (a)(x − a) + f (a) + f (t) dt
2 a 3!
(x − a)2 (x − a)3 (t − x)3
Z x
0 00
= f (a) + f (a)(x − a) + f (a) + f 00 (a) + f (4) (t) dt
2 3! a 3!
Z x n+1
f (t)
= · · · = Tn (x) + (t − x)n dt
a n!

Remark There is also Taylor’s theorem for multivariate functions in high


dimensions (see Section 5.6.1 of Chapter 5).

Below are a few notes regarding the theorem.


• Considering n = 0 in Taylor’s theorem, we get

f (x) − f (a)
f (x) = f (a) + f 0 (c)(x − a) or = f 0 (c) (2.29)
x−a
Taylor’s Theorem 17

which is the mean value theorem (MVT). The MVT has a clear geometry
interpretation: existence of a tangent line parallel to the secant line through the
two ending points.
• Let h = x − a, then x = a + h and we can write Taylor’s theorem in the form in
terms of h as
n
f (k) (a) k f (n+1) (c) n+1
f (a + h) = ∑ h + h (2.30)
k=0 k! (n + 1)!
where c is an unknown point between a and a + h.
Similarly, if we let h = a − x, then x = a − h (and x − a = −h) and we can write
Taylor’s theorem in the form in terms of h as
n
f (k) (a) f (n+1) (c)
f (a − h) = ∑ (−h)k + (−h)n+1 (2.31)
k=0 k! (n + 1)!

• Taylor series limn→∞ Tn (x) converges to f (x) if limn→∞ Rn (x) = 0.


Below are two examples in which Taylor’s theorem is applied to analyze errors in
mathematical approximations.

Example 2.4 (Approximation by a Taylor polynomial) f (x) = ex is approximated


by Tn (x), the n-th order Taylor polynomial of f about 0, for x ∈ [−2, 2]. (1) Find an
upper bound of the absolute error in terms of only the degree n. (2) Then determine
the degree n such that the absolute error is at most 10−4 .
[Solution:] According to Taylor’s theorem, the absolute error | f (x) − Tn (x)| is given
by Taylor’s remainder (the error term) as

f (n+1) (c) ec
| f (x) − Tn (x)| = (x − 0)n+1 = |x|n+1
(n + 1)! (n + 1)!

where the unknown number c is between 0 and x.


(1) For x ∈ [−2, 2] and a = 0, we have
• c ∈ (−2, 2), i.e. c falls in the same interval [−2, 2] as x, as illustrated in Fig. 2.2,
and thus ec < e2 .
• |x| ≤ 2 and thus |x|n+1 ≤ 2n+1
c

α a x
β

FIGURE 2.2
Relative positions of a, x and c if a ∈ [α, β ] and x ∈ [α, β ].

So we obtain the upper bound of the absolute error in terms of only n as

ec e2
| f (x) − Tn (x)| = |x|n+1 < 2n+1
(n + 1)! (n + 1)!
18 Taylor’s Theorem

(2) If we set the upper bound be at most 10−4 :


e2
2n+1 ≤ 10−4
(n + 1)!
then we can guarantee the absolute error is at most 10−4 for x ∈ [−2, 2] as
e2
| f (x) − Tn (x)| ≤ 2n+1 ≤ 10−4
(n + 1)!
Since 2n+1 /(n + 1)! is decreasing with n for n = 1, 2, 3, . . . (see Exercise 2.14), the
inequality can be satisfied if n is large enough, and in this case we require n ≥ 11. 
Example 2.5 (Finite difference approximation) We can approximate T = f 0 (a)
(the slope of a tangent line) by the so-called forward finite difference (more on
such approximations in Chapter 8)
f (a + h) − f (a)
A=
h
which is the slope of a secant line, where h > 0 is a small spatial step (if h < 0, then it
2
is called backward finite difference). Assume f (x) ∈ C[a,a+h] . Use Taylor’s theorem to
determine how the absolute error in the approximation depends on the spatial step h.
[Solution:] We use Taylor’s theorem in the form in terms of h, i.e. Eq. (2.30), with
2
n + 1 = 2 (note that f (x) ∈ C[a,a+h] is twice differentiable):
f 00 (c) 2
f (a + h) = f (a) + f 0 (a)h + h
2!
where c ∈ (a, a + h). We therefore obtain the dependence of the absolute error on h as
f (a + h) − f (a) | f 00 (c)|
|T − A| = − f 0 (a) = h
h 2!
Note that if h is sufficiently small, then f 00 (c) ≈ f 00 (a) as c ∈ (a, a+h) and the absolute
error is approximately | f 00 (a)|h/2 (a constant multiple of h). 
Previously we used the big O notation to present the efficiency of a method. We
can also use the big O notation to present the accuracy of a method. If the absolute
error e of the approximation in a method depends on a small parameter h, we say the
absolute error is of order g(h), i.e.
e = O(g(h)) (2.32)
which means that the absolute error e is bounded from above as
e ≤ Cg(h) (2.33)
for some constant C > 0 when h is small enough. In the last example above, we have
the absolute error
f (a + h) − f (a) | f 00 (c)|
|T − A| = − f 0 (a) = h ≤ Ch (2.34)
h 2!
where C = maxa≤x≤a+h | f 00 (x)|/2. So we can say the absolute error in this example is
of O(h).
Alternating Series Theorem 19

2.3 Alternating Series Theorem


An alternating series is a series whose terms alternate in signs. It has the form
∞ ∞
b0 − b1 + b2 − b3 + · · · ≡ ∑ (−1)k bk or − b0 + b1 − b2 + b3 − · · · ≡ ∑ (−1)k+1 bk
k=0 k=0

where bk > 0, k = 0, 1, 2, . . .. Looking at the Maclaurin series listed in Section 2.2.2,


we recognize that the Maclaurin series of ex for x < 0, sin x and cos x for |x| < ∞,
1/(1−x) for −1 < x < 0, tan−1 x for |x| < 1, and ln(1+x) for 0 < x < 1 are convergent
alternating series.

Theorem 2.3 The alternating series



b0 − b1 + b2 − b3 + · · · ≡ ∑ (−1)k bk (2.35)
k=0

or

−b0 + b1 − b2 + b3 − · · · ≡ ∑ (−1)k+1 bk (2.36)
k=0

where bk > 0, k = 0, 1, 2, . . ., is convergent if

b0 > b1 > b2 > b3 > · · · > 0 (2.37)

and

lim bk = 0 (2.38)
k→∞

Let the sum of the convergent alternating series be S, i.e.


∞ ∞
S= ∑ (−1)k bk or S = ∑ (−1)k+1 bk (2.39)
k=0 k=0

Let the partial sum Sn (the truncated series) be


n n
Sn = ∑ (−1)k bk or Sn = ∑ (−1)k+1 bk (2.40)
k=0 k=0

Then

|S − Sn | ≤ bn+1 (2.41)
20 Taylor’s Theorem

The Maclaurin series mentioned above satisfy the condition of the alternating
series theorem for x in the specified intervals and are therefore convergent (as we have
already known from Taylor’s theorem).
The alternating series theorem provides an upper bound bn+1 for the error in
approximating the sum S by the partial sum Sn of a convergent alternating series that
satisfies the conditions in the theorem.

Example 2.6 (Approximation by an alternating series) If we use the partial sum


of the Maclaurin series of cos x to approximate cos 1, at which term (included) should
we stop in the partial sum to make the absolute error less than 10−6 ?
[Solution:] The Maclaurin series of cos x is
x2 x4 x6 ∞
(−1)k x2k
1− + − +··· ≡ ∑ , |x| < ∞
2! 4! 6! k=0 (2k)!

which converges to the sum S(x) = cos x. Suppose we stop the partial sum Sn (x) right
at the term (−1)n x2n /(2n)! (included). (Note that Sn (x) is the Taylor polynomial of
degree 2n for f (x) = cos x about a = 0.) By the alternating series theorem, we have

|x|2(n+1)
|S(x) − Sn (x)| = | cos x − Sn (x)| ≤
(2(n + 1))!
So the absolute error in approximating cos 1 by the partial sum Sn (1) is bounded as
1
| cos 1 − Sn (1)| ≤
(2n + 2)!

Let 1/(2n + 2)! < 10−6 , we obtain n ≥ 4. Note that S4 (x) and S4 (1) are

x2 x4 x6 x8 1 1 1 1
S4 (x) = 1 − + − + , S4 (1) = 1 − + − +
2! 4! 6! 8! 2! 4! 6! 8!


2.4 Exercises
Exercise 2.1 Write the polynomial p4 (x) = 1 + 5x + 4x2 + 3x3 + 2x4 in the form
of nested multiplication. Then evaluate p4 (2) using the nested form (i.e. Horner’s
method). How many multiplications and additions are used in your evaluation?

Exercise 2.2 How to evaluate p(x) = 2 + 3x3 − 4x6 + 8x9 − 11x12 at a given value of
x using only 6 multiplications?

Exercise 2.3 Count how many multiplications (in terms of n) are used in the following
pseudocode (at the beginning of next page). Write down the number of multiplications
in the big O notation. Hint: ∑nk=1 k2 = n(n + 1)(2n + 1)/6.
Exercises 21

for k from 1 to n − 1 do
for i from k + 1 to n do
for j from k + 1 to n do
Ai j ← Ai j − Ak j Aik /Akk
end for
end for
end for

Exercise 2.4 Find the Taylor polynomial T3 (x) of degree 3 for f (x) = 1 + 4x + 3x2 +
2x3 about a = 1. Show that T3 (x) = f (x) in this case by simplifying T3 (x) or by
applying Taylor’s theorem.
√3
Exercise 2.5 Find the Taylor polynomial T1 (x) of degree 1 for f (x) = x5 about
a = 0. Sketch the graphs of T1 (x) and f (x) in the same plot. Can you find the Taylor
polynomial T2 (x) of degree 2 for f (x) about a = 0?

Exercise 2.6 Write down the Taylor polynomial T4 (x) of degree 4 for f (x) about a.
(k)
Verify that T4 (a) = f (k) (a) for k = 0, 1, 2, 3, 4. Note that we define the 0-th derivative
of a function as the function itself.

Exercise 2.7 Let Tn (x) be the Taylor polynomial of degree n for the polynomial
pn (x) = c0 + c1 x + c2 x2 + · · · + cn xn about a. Prove that Tn (x) = pn (x).

Exercise 2.8 Derive the Maclaurin series for f (x) = ln(1 − x) by two ways: (1)
finding f (k) (0)/k!, k = 0, 1, 2, 3, . . .; (2) using a substitution in an existing Maclaurin
series. State the range of x on which the series converges to f (x) = ln(1 − x).

Exercise 2.9 Let θ = (1/55 · · · 5)◦ be a small angle in degrees, where the denominator
has n fives. (1) Compute sin θ for n = 3, 5, 7, 10 and write down the results in scientific
notation. Do you see something unusual? (2) Why sin θ has more and more same
decimal digits in the same order as π when n increases? (Hint: What is the truncated
degree-1 Maclaurin series of sin x? Is x in the series in degrees or radians?)

Exercise 2.10 Let Tn (x) be the n-th order Taylor polynomial for f (x) = ex about
a = 0. (1) Find the expression for Tn (x). (2) If T9 (x) is used to approximate f (x) = ex
for −2 ≤ x ≤ 1, find an upper bound of the error. (3) If Tn (x) is used to approximate
f (x) = ex for −1 ≤ x ≤ 1 with the absolute error at most 10−3 , how large should n
be?

Exercise 2.11 Let f (x) = sin x, a = π. (1) Derive the degree-3 Taylor polynomial
T3 (x) for f (x) at a. (2) If f (x) is approximated by T3 (x) for π − 1 ≤ x ≤ π + 1, find
an upper bound for the error of this approximation using Taylor’s Theorem.

Exercise 2.12 Derive the degree-2 Taylor polynomial T2 (x) for f (x) = ln x at a = 1. If
f (x) is approximated by T2 (x) for 0.5 ≤ x ≤ 1.5, find an upper bound for the absolute
error of this approximation using Taylor’s remainder.
22 Taylor’s Theorem

Exercise 2.13 Prove Taylor’s theorem. (Hint: See remarks for Theorem 2.2.)
Exercise 2.14 Show 2n+1 /(n + 1)! is decreasing with n for n = 1, 2, 3, . . . using proof
by induction.
Exercise 2.15 Use the alternating series theorem to determine the value of n in the
Taylor polynomial
n
(−1)k x2k
T2n (x) = ∑
k=0 (2k)!
for cos x about 0 such that cos 1 is approximated by T2n (1) with the absolute error less
than 10−6 .
Exercise 2.16 Approximate T = f (a) by A = f (a + h), where h is small, and f (x)
has continuous first derivative in an interval containing a and a + h. (1) Use Taylor’s
theorem to find an expression of the absolute error |T − A| in terms of h. (2) Write the
absolute error in big-O notation. (3) What is the limit of the error as h → 0?
Exercise 2.17 If f (a) is approximated by
f (a + h) + f (a − h)
f (a) ≈
2
where h is a small value, and f (x) has continuous second derivative everywhere, (1)
find the absolute error of the approximation in terms of h using Taylor’s theorem
f = Tn + Rn with n = 1; (2) write the absolute error in big-O notation.
Exercise 2.18 f (x) ∈ C2 near a. Approximate f 0 (a) as
f (a) − f (a − h)
f 0 (a) ≈
h
where h is a small positive value. Use Taylor’s theorem to show that the error of the
approximation is O(h).

2.5 Programming Problems


Problem 2.1 Write the MATLAB m-function
function [p] = nest(c,x,a)
to implement Horner’s method (not the Naive method) for evaluating the degree-n
polynomial centered at the number a:
pn (x) = c0 + c1 (x − a) + c2 (x − a)2 + · · · + cn (x − a)n .
The n + 1 coefficients c0 , c1 , ..., cn are entries of the input vector c. The values of the
independent variable x are passed as a vector.
Test your m-function by evaluating p3 (x) = 1 + 3(x + 1) − 2(x + 1)3 at x = 0.
Programming Problems 23

Problem 2.2 Let Tn (x) be the Taylor polynomial of degree n for f (x) = ln(1 + x) at
a = 0. Write a MATLAB m-script to use your function nest in the previous problem
to evaluate T4 (x) and T9 (x) at

x = −0.5, −0.49, −0.48, ..., 0.48, 0.49, 0.5.

(1) Plot f (x), T4 (x) and T9 (x) in one figure using the MATLAB command plot.
(2) Plot the Taylor’s remainders (the error terms) | f (x) − T4 (x)| and | f (x) − T9 (x)|
in another figure using the MATLAB command semilogy (use help semilogy to
learn what semilogy does and how to use it).
(3) Derive an upper bound of | ln(1 + x) − T9 (x)| for −0.5 ≤ x ≤ 0.5 using Taylor’s
theorem. Is the absolute error | ln(1 + x) − T9 (x)| in your second plot less than your
derived upper bound?
3
Roundoff Errors and Error Propagation

In this chapter, we explains why roundoff errors are inevitable in scientific computing
and how roundoff errors are propagated in arithmetic and algorithms. We use exam-
ples to illustrate and analyze the stability of algorithms.

Let’s start by running the following MATLAB demo code


a = 0;
n = 0;
while a~=1 && n<20
a = a+0.1;
n = n+1;
end
frpintf(’a = %18.16f after addition of 0.1 for %d times\n’,a,n)
The output of the code is
a = 2.000000000000000444 after addition of 0.1 for 20 times
We might expect that the while loop would end when a could have reached 1 (to
violate the condition a˜=1) after n = 10 additions of 0.1, but it stops only when n
goes to 20 (to violate the condition n<20).
Why is the repeated addition of 0.1 for 10 times not equal to 1 in this demo? The
reason is that the innocent looking real number 0.1 cannot be exactly represented
by computers. As we will see shortly, a computer can exactly represent only a finite
number of real numbers which are called machine numbers. Most likely, a real number
(for example 0.1) cannot be represented exactly by a computer and is represented
inexactly as a nearby machine number, introducing the so-called roundoff error.

3.1 Numbers
We have seen the following different types of numbers.
• natural numbers: N = {1, 2, 3, . . .}
• integers: Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . .}
• rational numbers: Q = {p/q|, p ∈ Z, q ∈ Z, q 6= 0}

DOI: 10.1201/9781003201694-3 25
26 Roundoff Errors and Error Propagation

• real numbers: R = set of all the numbers on the real number line, including
√ rational
numbers (such as 0.1 and 1/3) and irrational numbers
√ (such as 2, π and e).
• complex numbers: C = {a + bi|a ∈ R, b ∈ R, i = −1}
The above sets of numbers expand from top to bottom: N ⊂ Z ⊂ Q ⊂ R ⊂ C.
A computer stores a number in a physical unit such as registers, RAMs, or disk
drives which may be regarded as an ordered list of switches. Each switch has 2
statuses: on and off. We assign the on and off statuses the values 1 and 0, respectively,
and call such a switch a bit. So a computer represents a number as a pattern of ordered
bits (for example 01101010). The mapping between a bit pattern and a number is
determined by the IEEE (Institute of Electrical and Electronics Engineers, pronounced
as I-triple-E) standards. Below we describe how a computer represents integers and
real numbers.

3.1.1 Integers
Signed integers are commonly used in computations. An 8-bit (1-byte) signed integer
is stored as the bit pattern
b7 b6 b5 b4 b3 b2 b1 b0
which corresponds to the value

(−b7 )×27 +b6 ×26 +b5 ×25 +b4 ×24 +b3 ×23 +b2 ×22 +b1 ×21 +b0 ×20 (3.1)

With 8 bits, only 28 = 128 signed integers −128, −127, . . . , 126, 127 can be repre-
sented.
We also use unsigned integers in indexing (for example, row and column indices
of a matrix) and in the representing real numbers (soon later). An 8-bit unsigned
integer is stored as the bit pattern

b7 b6 b5 b4 b3 b2 b1 b0

which corresponds to the value

b7 × 27 + b6 × 26 + b5 × 25 + b4 × 24 + b3 × 23 + b2 × 22 + b1 × 21 + b0 × 20 (3.2)

With 8 bits, only 28 = 128 unsigned integers 0, 1, . . . , 254, 255 can be represented.

3.2 Floating-Point Numbers


Real numbers are represented by a computer as floating-point numbers, including
64-bit double precision (DP) type and 32-bit single precision (SP) type (by default,
MATLAB use DP floating-point numbers for real number arithmetic). What are
floating-point numbers? Let’s look at scientific notation first to answer this question.
Floating-Point Numbers 27

3.2.1 Scientific Notation and Rounding


We are familiar with decimal numbers. The decimal number system is a base-10
system in which the place values are integer powers of 10 (for example, 234.56 =
2 × 102 + 3 × 101 + 4 × 100 + 5 × 10−1 + 6 × 10−2 ).

Definition 3.1 The scientific notation of a decimal number T is

T = σ · T̄ · 10e (3.3)

where
• σ = +1/ − 1: sign of T
• 1 ≤ T̄ < 10: significand/mantissa of T
• e: integer exponent

The mantissa T̄ has the form

T̄ = d1 .d2 d3 · · · (3.4)

where di ∈ {0, 1, 2, . . . , 9} (i = 1, 2, 3, . . .) except d1 6= 0. The leftmost nonzero digit d1


in the mantissa corresponds to the largest place value and is called the first significant
digit (the most significant digit), the second digit d2 from left in the mantissa is called
the second significant digit, and so on.
A floating-point representation A of the number T in the decimal system has the
same form as scientific notation:

A = σ · Ā · 10E (3.5)

but the number of digits in the mantissa is limited. If the mantissa Ā of a floating-point
representation allows only t decimal digits, then it can be written as

Ā = d˜1 .d˜2 d˜3 · · · d˜t−1 d̃t (3.6)

It is called floating-point representation because the decimal point is always floating


between d˜1 and d˜2 with the help of the power 10E . If the mantissa T̄ of the number T
in scientific notation has more than t digits:

T̄ = d1 .d2 d3 · · · dt dt+1 · · · (3.7)

then its floating-point representation A can be obtained by rounding. The rule for
rounding is “round to nearest, ties to even” by comparing the digit dt+1 (the first digit
to be discarded) with 5 (half of the base value 10) as follows.
• “Round to nearest”: If dt+1 < 5, round T̄ down to Ā by simply chopping off
all the less significant digits to the right of dt . If dt+1 > 5, round T̄ up to Ā by
discarding all the digits to the right of dt and adding 1 to the digit dt , which
28 Roundoff Errors and Error Propagation

may lead to carrying (or even the adjustment of the exponent e to E = e + 1). If
dt+1 = 5 but is not the rightmost nonzero digit (i.e. there are other nonzero digits
after it), round T̄ up.
• “Ties to even”: If dt+1 = 5 and is the rightmost nonzero digit, then when dt is
even, round T̄ down; and when dt is odd, round T̄ up. In either case, the digit d̃t
is even.

Example 3.1 (Rounding) The fixed-point numbers

3.1416, −124.63, −43.652, 0.002375, −0.2385

can be written in scientific notation as

+3.1416 × 100 , −1.2463 × 102 , −4.3652 × 101 , 2.375 × 10−3 , −2.385 × 10−1

respectively. If the mantissa of a floating-point representation (in base 10) can have
only 3 significant digits, then the floating-point representations of these numbers are
obtained by rounding as

+3.14 × 100 , −1.25 × 102 , −4.37 × 101 , 2.38 × 10−3 , −2.38 × 10−1

respectively. 

So the floating-point representation A can be an approximation of the decimal num-


ber T . We say A is a t-digit approximation of T , meaning A has t correct/significant
digits. The error induced by rounding is called roundoff error. The rounding rule
implies that the absolute roundoff error is bounded by 5 times the place value at the
digit dt+1 :

|T − A| ≤ 5 · 10−t · 10e (3.8)

Since |T | ≥ 1 · 10e , the relative roundoff error is bounded as

|T − A| 5 · 10−t · 10e 10−(t−1)


≤ e
= = 5 · 10−t (3.9)
|T | 10 2
If the relative error in an approximation A of a number T does not exceed 5 · 10−t , we
say A has t correct/significant decimal digits.

Example 3.2 (Significant digits) The floating-point representation with a 3-digit


mantissa for the number −1.2463 × 102 is −1.25 × 102 . The absolute roundoff error
in the representation is

|(−1.2463 × 102 ) − (1.25 × 102 )| < 0.005 × 102

and the relative error is


|(−1.2463 × 102 ) − (1.25 × 102 )| 0.005 × 102
< = 5 × 10−3
| − 1.2463 × 102 | 102
The representation has 3 significant decimal digits. 
Discovering Diverse Content Through
Random Scribd Documents
Page 14, ligne 18, ans, un monocle dans l’œil, très brun, la
moustache roulée en pointes aiguës, l’air insolent, dédaigneux et
fat...
Page 14, ligne 26, bras, après avoir rajusté son monocle...
Page 15, ligne 1, duelliste, celui qui a écrit le beau traité
d’escrime française «l’Escrime nationale». Il vient de corriger ses
épreuves. Wolff, Scholl et lui...
Page 16, ligne 20, Forestier surpris prononça:
Page 17, ligne 4, demie, 21, rue...
Page 18, ligne 17, enfin, il prononça:
Page 19, ligne 3, L’autre prononça d’un...
Page 19, ligne 6, saluèrent avec respect. Celui
Page 19, ligne 11, battants tendus de cuir vert, et ils...
Page 24, ligne 3, parfums violents des...
Page 27, ligne 10, Elle prononça avec...
Page 28, ligne 7, Il se sentait un peu...
Page 31, ligne 9, vêtements. Et puis ce laquais avait...
Page 33, ligne 29, elle prononça, en...
Page 34, ligne 16, s’élança vers elle:
Page 35, ligne 16, luisait, ciré depuis longtemps par...
Page 35, ligne 20, Sa cravate, nouée comme une corde, ne
semblait pas à sa première sortie; un bouton manquait à sa
chemise...
Page 36, ligne 4, domestique annonça:
Page 37, ligne 16, affaire. Et il rajustait à tout moment après
l’avoir essuyé avec sa serviette son monocle qui tenait mal et
tombait sans cesse dans son assiette. Duroy n’osait...
Page 41, ligne 8, peuples civilisés.
Page 47, ligne 6, son futur directeur...
Page 48, ligne 24, regardait au fond des yeux sa...
Page 49, ligne 6, elle, la protéger, la défendre...
Page 61, ligne 9, attendant quelqu’un sans...
Page 62, ligne 6, Forestier prononça en souriant avec malice...
Page 63, ligne 2, de prendre des notes...
Page 65, ligne 27, gentil ça... Duroy murmura: Oui, madame...
Page 67, ligne 10, l’eut fait parler...
Page 72, ligne 20, est drôle et gentille...
Page 73, ligne 29, cet homme,...
Page 74, ligne 25, antichambre du plus parisien et du plus
mondain des journaux du matin.
Page 78, ligne 17, salles de composition que...
Page 78, ligne 29, directeur regarda brusquement...
Page 79, ligne 28, Walter recommençait une partie...
Page 84, ligne 12, penser à rien, le...
Page 89, ligne 19, luisant comme ses joues, écrivait...
Page 93, ligne 23, de drôle ou de...
Page 94, ligne 3, vous. Dans le journalisme, monsieur Montelin il
faut savoir accumuler...
Page 94, ligne 14, ressucée de Scholl. Puis...
Page 103, ligne 14, moustache frisée du...
Page 103, ligne 27, parcourant sans fin de l’œil les colonnes
imprimées avec l’espoir d’avoir mal vu et de trouver...
Page 104, ligne 16, pas jugé suffisant...
Page 105, ligne 27, députés, ainsi que ceux des ministères, les
figures importantes et niaises des...
Page 107, ligne 5, aisance. Mais ce truc il ne le découvrait point
et il...
Page 109, ligne 13, parfois traité avec...
Page 110, ligne 4, au cinquième...
Page 110, ligne 28, peignoir tout rouge et elle s’écria:
Page 111, ligne 15, pris de l’air...
Page 112, ligne 4, peignoir rose, moins...
Page 127, ligne 29, voudrez, je m’en fiche...
Page 132, ligne 16, sourire attendri qu’elles...
Page 133, ligne 5, désirais, depuis longtemps, dit-il...
Page 143, ligne 25, jours pendant la reprise intermittente de la
comédie conjugale. Quelle...
Page 157, ligne 15, Il y a, il y a... que je...
Page 158, ligne 9, chéri, pardonne-moi... pardonne-moi... et elle
pleurait suffoquée par les larmes, répétant: mon pauvre chéri... mon
pauvre chéri... si j’avais su!
Page 160, ligne 26, demain, nom de Dieu! Elle...
Page 166, ligne 14, attendant son moment.
Page 176, ligne 8, qui m’aiment, toute relation...
Page 176, ligne 28, même dangereux pour...
Page 186, ligne 2, n’arrive loin.
Page 191, ligne 8, Boisrenard, dont les cheveux blancs, étaient...
Page 193, ligne 4, une grande joie...
Page 194, ligne 24, Ces roulures-là...
Page 196, ligne 5, fut rempli d’étonnement...
Page 200, ligne 23, Marelle était là tout près...
Page 210, ligne 7, bêtes. Montesquieu a dit: «Toutes les lois
établies sur ce que notre machine est d’une certaine façon, seraient
différentes si notre machine n’était pas de cette façon. Il en est de
même de nos divinités et de nos croyances.
Toutes nos croyances ne viennent que des conditions d’existence
où nous nous trouvons depuis le simple préjugé mondain jusqu’à ce
que nous appelons «Les Vérités éternelles».
Vérité en deçà des Pyrénées erreur au delà.
Vérité sur la terre erreur au-dessus.
Vérité pour nos organes erreur à côté.
La règle deux et deux font quatre doit cesser d’être applicable
par delà l’atmosphère de la terre.
Car toutes nos idées ne dépendent que des propriétés de nos
sens. Les couleurs n’existent que parce que nous avons un œil qui
voit ainsi, le son parce que nous avons un tympan qui change en
bruit des vibrations. Donc c’est la conformation de nos organes qui
détermine pour notre jugement, les propriétés apparentes de la
matière.
Rien n’est vrai, rien n’est sûr. Et encore nous n’avons pour
observer avec ces instruments trompeurs, qu’un point insignifiant
dans l’espace, sans notion sur tout ce qui l’entoure, et qu’au
moment insaisissable dans la durée sans soupçon de ce qui fut ou
de ce qui sera! Et penser qu’un être humain, si songeur et si
tourmenté, n’est qu’un imperceptible grain de la poussière de vie
semée sur notre petite terre qui n’est elle-même qu’un grain dans la
poussière des mondes.»
La mort seule.
Page 230, ligne 19, talent. M. Duroy n’est qu’un drôle. «Et...
Page 231, ligne 28, correct, et le monocle dans l’œil.
Page 238, ligne 19, pâle. Il restait debout en face du miroir, il tira
la langue comme pour constater l’état de sa santé et tout d’un
coup,...
Page 238, ligne 23, furieusement. «Demain à cette heure-ci je
serai peut-être mort. Cette femme en face de moi, ce moi que je
vois dans cette glace ne sera plus. Comment? me voici, je me
regarde, je me sens vivre, et, dans douze heures je serai couché
dans ce lit, mort, les yeux fermés, froid, inanimé, disparu.» Il se
retourna...
Page 239, ligne 6, retourner vers sa couche. Ses...
Page 242, ligne 11, effet de ne penser à rien.
Page 245, ligne 26, casser le bras!...
Page 247, ligne 18, voix s’éleva dans...
Page 248, ligne 29, Les quatre témoins...
Page 249, ligne 6, tous ensemble sur...
Page 250, ligne 10, mon adoré.
Page 253, ligne 28, vieux bonze et de...
Page 257, ligne 1, timbre, comme il faisait toujours, et il...
Page 288, ligne 28, dans un lit, tout...
Page 289, ligne 19, mirant le mort au...
Page 304, ligne 1, Il attendit, espérant...
Page 304, ligne 28, oreille et comme un parfum dans la poitrine.
Page 307, ligne 16, que la cérémonie se...
Page 307, ligne 19, lendemain faire une visite aux vieux...
Page 307, ligne 26, époux, après un court passage à la mairie et
une courte messe à Notre-Dame de Lorette, rentrèrent...
Page 315, ligne 21, bohème des journalistes.
Page 321, ligne 15, ondulations de serpent.
Page 325, ligne 16, d’une cocotte, cette...
Page 334, ligne 26, bout frisé de...
Page 359, ligne 23,—Oui, reprit-il, c’est bon, c’est bon, quand on
a rien de mieux à faire!
Page 360, ligne 21, étaient plus froides que du marbre.
Page 360, ligne 24, marches de Tortoni.
Page 366, ligne 4, Mais Madeleine ne croyait pas qu’on pût
réduire la vertu de Mme Walter;
Page 366, ligne 12, bon! Et le père!...
Page 373, ligne 17, Elle avait un peu rougi:
Page 375, ligne 13, partir quand une voix lui dit tout bas dans le
dos:
—Bonjour Bel-Ami!
Il se retourna brusquement. C’était Madame de Marelle assise sur
la seconde banquette.
—Vous ici? dit-il.
—Oui, moi-même. J’ai voulu voir... vous voir.
Ils avaient passé l’après-midi de la veille ensemble, rue de
Constantinople, sans qu’elle lui eût avoué son projet d’assister à
l’assaut chez Rival. Il pensa: «Est-ce qu’elle m’espionnerait?» Il
s’était incliné avec cérémonie, il murmura:
—Je suis obligé...

Page 375, ligne 16, Mais Mme de Marelle et Mme Walter s’étant
saluées, Clotilde prononça:
—Si nous le gardions près de nous madame, il nous nommera les
tireurs et les gens connus. Il peut bien demeurer debout au coin de
ce banc.

Et Mme Walter demanda: «Oh oui, restez ici monsieur... monsieur


Bel-Ami.

Page 380, ligne 12, Mme de Marelle, car Mme Walter les
connaissait presque tous. C’étaient...

Page 381, ligne 4, Mme de Marelle souriait. Mme Walter...


Page 385, ligne 11, Du Roy, escortant la famille Walter, attendait
son landau. Mme de Marelle ne l’avait point quitté: «Est-ce qu’elle
voudrait me cramponner» pensait-il. Elle demanda:
—Auriez-vous une petite place pour moi. Vous seriez bien gentil
de me ramener après ces dames.
Mme Walter avait entendu.
—Mais oui certainement, chère amie, nous nous mettrons trois
dans le fond.
Du Roy trouvait cette demande de mauvais goût.
Quand il eut ramené la Patronne et ses filles il demeura seul avec
sa maîtresse. Elle lui prit aussitôt la main:
—Oh! comme je t’aime, comme je t’aime!
Il s’étonna de cet élan de tendresse. Elle répétait:
—Tu ne te figures pas combien je t’aime.
Il trouvait cette démonstration exagérée et inopportune, car il ne
se sentait point dans un moment d’émotion.
Elle demanda:
—Si nous faisions un tour avant de rentrer?
Il répondit vivement:
—Mais je n’ai pas le temps, il faut que je travaille, moi.
Elle murmura:
—Comme tu as l’air mauvais.
—Non, je suis pressé.
—Veux-tu nous voir demain, chez nous?
Il hésita, puis prononça avec le seul désir de la contrarier.
—Je ne peux pas, je ne suis point libre demain.
Elle se tut, puis arrivée devant sa porte:
—Quand veux-tu nous revoir alors?
—Mais... je ne sais pas... il faut que j’examine ce que j’ai à faire.
Je t’enverrai un télégramme.
Elle descendit de voiture lentement, les yeux un peu humides,
puis lui tendant la main:
—A bientôt, à bientôt.
Dès qu’il se retrouva seul, il murmura: «Ça ne me disait rien
aujourd’hui. Et puis je ne veux pas qu’elle se mette sur ce pied-là.
Les femmes ont besoin d’être matées».
Madeleine l’attendait.
Page 386, ligne 1, Du Roy, qui était d’humeur querelleuse,
feignit...
Page 390, ligne 21, Clotilde.
«Demain deux heures chez nous, n’est-ce pas.»
Il signa «Bel-Ami» comme il faisait avec elle depuis la reprise de
leur amour. En rentrant...
Page 395, ligne 11, lentement...
—Non. Pas du tout.
Page 397, ligne 15, douteuse. Des passants parfois s’arrêtaient
pour le regarder passer avec envie.
La lance des arroseurs donnait des désirs de douche et le pavé
de bois fumait un peu sous la pluie tiède qui s’évaporait aussitôt. Du
Roy tira...
Page 400, ligne 16, Où donc? Une phrase de Norbert de Varenne
lui retraversa l’esprit: «Les insectes qui vivent quelques heures, les
mouches qui vivent quelques jours, les bêtes qui vivent quelques
mois, les hommes qui vivent quelques ans, les mondes qui vivent
quelques siècles, ne sont que de l’imperceptible poussière de vie
perdue dans la poussière infinie des univers. La bestiole qui s’agite
quelques minutes, et la terre ce grain de sable qui tourne dans
l’espace, ne demeurent-ils pas également insignifiants dans
l’ensemble illimité de ce qui est? La mort de l’une, la fin de l’autre,
ne passent-ils pas également inaperçus dans l’éternel
renouvellement? Et Du Roy que le silence...
Page 400, ligne 18, Jugeant de haut la création, prononça du
bout des lèvres: «C’est petit l’homme.»
Page 410, ligne 28, la muraille, les portes...
Page 412, ligne 1, Debout sur les degrés du portail...
Page 420, ligne 2, il l’étreignit comme...
Page 421, ligne 9, Maroc, demeuraient menaçantes.
Page 426, ligne 9, cherchait s’il n’avait plus rien à dire. N’ayant...
Page 427, ligne 28, bandeaux de garçon coiffeur. Il...
Page 432, ligne 2, dis, mon chéri.
Page 432, ligne 16, si tard...
Page 437, ligne 3, d’abord.» Et si elle m’en demande la raison...
quelle raison invincible puis-je lui donner?
Il cherchait un motif tel qu’elle n’eut rien à répondre, un
argument sans réplique et sans échappatoire, mais lequel?
Il s’arrêta net. Il avait trouvé et il riait de son idée.
«Je vais lui dire que je suis amoureux fou de Suzanne! Je verrai
bien ce qu’elle pourra répondre à cela!»
Et il entra chez lui pour attendre...
Page 451, ligne 4, elle prononça: Oh! cochon, tu as...
Page 500, ligne 14, Il articula durement:
Page 536, ligne 26,—Et comme on voudra vous faire taire vous
déclarerez que vous êtes prête à tout pour devenir ma femme. Le
ferez-vous?
—Je le ferai.
—Et en sortant...
Page 541, ligne 3, loin. Un grand frisson lui passa sur les
membres, quand...
Page 557, ligne 14, digue de sa fureur se fut rompue, elle...
Page 569, ligne 14, L’évêque prononçait:
OPIN ION DE LA PR ESSE
SUR

BEL-AMI .

Nouvelle Revue, 1er avril 1887 (Raoul Frary).

«M. de Maupassant... aime à courir droit au but, il raconte vite et


ne décrit qu’en passant, avec une merveilleuse netteté de contour...
M. de Maupassant semble être entré dans la vie avec une puissance
de mépris que cinquante ans d’expériences justifieraient à peine...
Bel-Ami est le chef-d’œuvre de ce jeune pessimiste, un modèle de
satire en action, un tableau tout en repoussoirs. Jamais on n’a
raconté avec tant de verve, le triomphe d’un gredin qui n’est pas
même un homme de talent dans son métier: la vraisemblance y perd
même un peu.»

Revue Bleue, 23 mai 1885 (Maxime Gaucher).

«C’est une œuvre très forte, très puissante, mais d’une vérité
cruelle et légèrement répulsive, le Bel-Ami de M. de Maupassant...
Ce misérable réussit avec une chance si constante et il accepte le
succès comme chose due avec une si imperturbable sérénité que
cela en devient exaspérant... Et cependant, une fois ce livre bleu
entre les mains, je ne l’ai pas lâché, mais j’ai lu tout d’une haleine,
non pas le dévorant, mais le savourant. Que voulez-vous? Cela est à
la fois irritant et exquis.»
Nouvelle Revue, juin 1885 (Francisque Sarcey).

«Je ne sais guère d’ouvrage dont la lecture soit à la fois plus


attirante et plus malsaine. En même temps qu’il remue au fond de
notre cœur la boue des curiosités perverses, il désenchante de
l’humanité et décourage de la vie. A quoi sert de demeurer sur cette
terre, si elle n’est peuplée que de bas gredins et de coquines
infâmes?... L’écœurante médiocrité de la race humaine,... M. Guy de
Maupassant l’étale à nos yeux avec l’indifférence d’un philosophe...
Ce que je reprocherais à M. Guy de Maupassant, c’est qu’ayant jugé
à propos de transplanter son Georges Duroy dans ce milieu du
journalisme, qu’il doit bien connaître, il n’ait pas pris la peine d’en
reproduire fidèlement l’aspect véritable. Les salles de rédaction qu’il
dépeint m’ont paru de pure fantaisie; ce ne sont pas là nos
habitudes, nos mœurs, ni nos façons de parler.»
Au le cte u r

Cette version numérisée reproduit dans son


intégralité la version originale. La ponctuation n’a pas
été modifiée hormis quelques corrections mineures.
L’orthographe a été conservée. Seuls quelques
mots ont été modifiés. Ils sont soulignés par des tirets.
Passer la souris sur le mot pour voir le texte original.
En cliquant sur les liens suivants, vous accédez
directement aux livres français publiés sur
gutenberg.org et qui sont classés par popularité,
genre, auteurs.
*** END OF THE PROJECT GUTENBERG EBOOK ŒUVRES
COMPLÈTES DE GUY DE MAUPASSANT - VOLUME 13 ***

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


T H E F U L L P R OJ E C T G U T E N B E R G
LICENSE
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.
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 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 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
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 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. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many

You might also like