Numerical Methods for Engineers and Scientists 3rd Edition Amos Gilat
Numerical Methods for Engineers and Scientists 3rd Edition Amos Gilat
Numerical Methods for Engineers and Scientists 3rd Edition Amos Gilat
Numerical Methods for Engineers and Scientists 3rd Edition Amos Gilat
1. Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.com
Numerical Methods for Engineers and Scientists 3rd
Edition Amos Gilat
https://ebookmeta.com/product/numerical-methods-for-
engineers-and-scientists-3rd-edition-amos-gilat/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
4. Numerical Methods
for Engineers and Scientists
An Introduction with
Applications using MATLAB
®
Third Edition
Amos Gilat
Vish Subramaniam
Department of Mechanical Engineering
The Ohio State University
5. Publisher: Don Fowley
Acquisition Editor: Linda Ratts
Editorial Assistant: Hope Ellis
Cover Designer: Wendy Lai
Associate Production Manager: Joyce Poh
Cover Image: The image on the cover shows a numerical simulation of an aluminum projectile penetrating a
composite plate. Courtesy of Dr. Kelly Carney, NASA Glenn Research Center, Cleveland, Ohio
This book was set in Times Roman by the authors. Printed and bound by R.R. Donnelley. The cover was printed by
R.R. Donnelley. This book is printed on acid free paper.
Founded in 1807, John Wiley & Sons, Inc. has been a valued source of knowledge and understanding for more than
200 years, helping people around the world meet their needs and fulfill their aspirations. Our company is built on a
foundation of principles that include responsibility to the communities we serve and where we live and work. In
2008, we launched a Corporate Citizenship Initiative, a global effort to address the environmental, social, economic,
and ethical challenges we face in our business. Among the issues we are addressing are carbon impact, paper
specifications and procurement, ethical conduct within our business and among our vendors, and community and
charitable support. For more information, please visit our website: www.wiley.com/go/citizenship.
Copyright 2014, 2011 John Wiley Sons, Inc. All rights reserved. No part of this publication may be
reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical,
photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United
States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment
of the appropriate per-copy fee to the Copyright Clearance Center, Inc. 222 Rosewood Drive, Danvers, MA 01923,
website www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, (201)748-6011, fax (201)748-
6008, website http://www.wiley.com/go/ permissions.
Evaluation copies are provided to qualified academics and professionals for review purposes only, for use in their
courses during the next academic year. These copies are licensed and may not be sold or transferred to a third party.
Upon completion of the review period, please return the evaluation copy to Wiley. Return instructions and a free of
charge return mailing label are available at www.wiley.com/go/returnlabel. If you have chosen to adopt this
textbook for use in your course, please accept this book as your complimentary desk copy. Outside of the United
States, please contact your local sales representative.
Library of Congress Cataloging-in-Publication Data
Gilat, Amos.
Numerical methods for engineers and scientists : an introduction with applications using matlab / Amos Gilat, Vish
Subramaniam, Department of Mechanical Engineering, the Ohio State University. -- Third edition.
pages cm
Includes bibliographical references and index.
ISBN 978-1-118-55493-7 (cloth)
1. MATLAB. 2. Numerical analysis--Data processing. 3. Engineering mathematics. I. Subramaniam, Vish. II.
Title.
QA297.G49 2014
518.0285'53--dc23
2013016217
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
6. iii
Preface
This textbook is intended for a first course in numerical methods for
students in engineering and science, typically taught in the second year
of college. The book covers the fundamentals of numerical methods
from an applied point of view. It explains the basic ideas behind the var-
ious methods and shows their usefulness for solving problems in engi-
neering and science.
In the past, a numerical methods course was essentially mathemati-
cal, emphasizing numerical analysis and theory. More recently, due to
the availability of powerful desktop computers and computing software
that is both affordable and powerful, the content and nature of a first
course in numerical methods for engineering and science students are
changing. The emphasis is shifting more and more toward applications
and toward implementing numerical methods with ready-to-use tools.
In a typical course, students still learn the fundamentals of numerical
methods. In addition, however, they learn computer programming (or
improve their programming skills if they have already been introduced
to programming), and use advanced software as a tool for solving prob-
lems. MATLAB is a good example of such software. It can be used by
students to write their own programs, and can be used as a tool for solv-
ing problems using its built-in functions. One of the objectives of a
course in numerical methods is to prepare students in science and engi-
neering for future courses in their areas of specialization (and their
future careers) where they will have to use computers for solving prob-
lems.
Main objectives of the book
To teach the fundamentals of numerical methods, with
emphasis on the most essential methods.
To provide students with the opportunity to enhance their pro-
gramming skills using the MATLAB environment to implement
algorithms.
To teach the use of MATLAB as a tool (using its built-in func-
tions) for solving problems in science and engineering, and
for checking the results of any programs students write them-
selves.
7. iv Preface
Features/pedagogy of the book
• This book is written in simple, clear, and direct language. Fre-
quently, bullets and a list of steps, rather than lengthy text, are used
to list facts and details of a specific subject.
• Numerous illustrations are used for explaining the principles of the
numerical methods.
• Many of the examples and end-of-chapter problems involve realis-
tic problems in science and engineering.
• MATLAB is integrated within the text and in the examples. A light
colored background is used when MATLAB syntax is displayed.
• Annotating comments that explain the commands are posted along-
side the MATLAB syntax.
• MATLAB’s built-in functions that are associated with the numeri-
cal methods are presented in detail.
• The homework problems at the end of the chapters are divided into
three groups:
(a) Problems to be solved by hand: Problems related to improving
understanding of numerical methods. In these problems the stu-
dents are asked to answer questions related to the fundamentals of
numerical methods, and to carry out a few steps of the numerical
methods by hand.
(b) Problems to be programmed in MATLAB: Problems designed to
provide the opportunity to improve programming skills. In these
problems students are asked to use MATLAB to write computer
programs (script files and user-defined functions) implementing
various numerical methods.
(c) Problems in math, science, and engineering: Problems in science
and engineering that have to be solved by using numerical methods.
The objective is to train the students to use numerical methods for
solving problems they can expect to see in future courses or in prac-
tice. Students are expected to use the programs that are presented in
the book, programs that they write, and the built-in functions in
MATLAB.
Organization of the book
Chapter 1: The first chapter gives a general introduction to numerical
methods and to the way that computers store numbers and carry out
numerical operations. It also includes a section on errors in numerical
solutions and a section on computers and programming.
Chapter 2: The second chapter presents a review of fundamental math-
ematical concepts that are used in the following chapters that cover the
numerical methods. It is intended to be used as a reminder, or a
refresher, of concepts that the students are assumed (expected) to be
8. Preface v
familiar with from their first- and second-year mathematics courses.
Since many of these topics are associated with various numerical meth-
ods, we feel that it is better to have the mathematical background gath-
ered in one chapter (and easier to find when needed) rather than be
dispersed throughout the book. Several of the topics that are covered in
Chapter 2 and that are essential in the explanation of a numerical
method are repeated in other chapters where the numerical methods are
presented. Most instructors will probably choose not to cover Chapter 2
as one unit in the class, but will mention a topic when needed and refer
the students to the chapter.
Chapters 3 through 11: These nine chapters present the various numer-
ical methods in an order that is typically followed in a first course on
numerical methods. These chapters follow the format explained next.
Organization of a typical chapter
An itemized list of the topics that are covered in the chapter is displayed
below the title of the chapter. The list is divided into core and
complementary topics. The core topics are the most essential topics
related to the subject of the chapter. The complementary topics include
more advanced topics. Obviously, a division of topics related to one
subject into core and complementary is subjective. The intent is to help
instructors in the design of their course when there is not enough time to
cover all the topics. In practicality, the division can be ignored in
courses where all the topics are covered.
The first section of the chapter provides a general background with
illustrative examples of situations in the sciences and engineering
where the methods described in the chapter are used. This section also
explains the basic ideas behind the specific class of numerical methods
that are described in the chapter. The following sections cover the core
topics of the chapter. Next, a special section discusses the built-in func-
tions in MATLAB that implement the numerical methods described in
the chapter, and how they may be used to solve problems. The later sec-
tions of the chapter cover the complementary topics.
The order of topics
It is probably impossible to write a text book where all the topics follow
an order that is agreed upon by all instructors. In the present book, the
main subjects are in an order that is typical in a first course in numerical
methods. Chapter 3 covers solution of nonlinear equations. It mostly
deals with the solution of a single equation, which is a simple applica-
tion of numerical methods. The chapter also includes, as a complemen-
tary topic, a section on the solution of a system of nonlinear equations.
Chapter 4 deals with the solution of a system of linear equations. Next,
Chapter 5 deals with eigenvalues and eigenvectors, and Chapter 6 cov-
ers curve fitting and interpolation. Chapter 7, which is new in the 3rd
edition, covers an introduction to Fourier methods. Chapters 8 and 9
9. vi Preface
cover differentiation and integration, respectively. Finally, solution of
ordinary differential equations (ODE) is presented in the last two chap-
ters. Chapter 10 deals with the solution of initial-value problems (first-
order, systems, and higher-order) and Chapter 11 considers boundary-
value problems.
The order of some of the topics is dictated by the subjects them-
selves. For example, differentiation and integration need to be covered
before ordinary differential equations. It is possible, however, to cover
the other subjects in different order than presented in the book. The var-
ious chapters and sections in the book are written in a self-contained
manner that make it easy for the instructor to cover the subjects in a dif-
ferent order, if desired.
MATLAB programs
This book contains many MATLAB programs. The programs are
clearly identified as user-defined functions, or as script files. All the
programs are listed in Appendix B. The programs, or the scripts, are
written in a simple way that is easy to follow. The emphasis of these
programs is on the basics and on how to program an algorithm of a spe-
cific numerical method. Obviously, the programs are not general, and
do not cover all possible circumstances when executed. The programs
are not written from the perspective of being shortest, fastest, or most
efficient. Rather, they are written such that they are easy to follow. It is
assumed that most of the students have only limited understanding of
MATLAB and programming, and presenting MATLAB in this manner
will advance their computing skills. More advanced users of MATLAB
are encouraged to write more sophisticated and efficient programs and
scripts, and compare their performance with the ones in the book.
Third edition
The main changes in the third edition are:
Fourier Methods: In response to many requests from professors that
use the book in their courses, a new chapter (Chapter 7) on Fourier
methods has been added to the book. The chapter covers Fourier series,
discrete Fourier series, Discrete Fourier Transform, and an introduction
to the Fast Fourier Transform (FFT) which are widely used in engineer-
ing for processing digital data.
Eignvalues and Eignvectors: This topic which was part of Chapter 4
(Solving a System of Linear Equations) in the first two editions of the
book is now covered in a separate chapter.
MATLAB: The third edition of the book is updated to MATLAB
R2012b. All the programs use anonymous functions and function han-
dles are used for passing functions into functions. Appendix A has been
updated to the current version of MATLAB.
Homework problems: About 50% of the problems have been added
or changed. Most of the Chapters have 40 or more problems.
10. Preface vii
Support material
The following is available on the instructor companion site at
www.wiley.com/college/gilat):
(a) for faculty who have adopted the text for use in their course, a fully
worked solution manual, triple checked for accuracy.
(b) suggested course syllabi with suggested assignments to help
quickly integrate the text into your course.
(c) conversion guides from other major numerical methods titles to
show where each section of your current text is covered in this new
text, helping you quickly convert from old to new.
(d) electronic versions of all the figures and tables from the text, for
creating lecture slides and quizzes/exams based on images from the
book.
(e) m-files of all the programs in the text.
Many people have assisted during the preparation of the first two
editions of the book. We would like to thank the reviewers and users for
the many comments and suggestions they have made.
Lawrence K. Agbezuge, Rochester Institute of Technology
David Alciatore, Colorado State University
Salame Amr, Virginia State University
John R. Cotton, Virginia Polytechnic Institute and State University
David Dux, Purdue University
Venkat Ganesan, University of Texas-Austin
Michael R. Gustafson II, Duke University
Alain Kassab, University of Central Florida
Tribikram Kundu, University of Arizona
Ronald A. Mann, University of Louisville
Peter O. Orono, Indiana University Purdue University Indianapolis
Charles Ritz, California State Polytechnic University-Pomona
Douglas E. Smith, University of Missouri-Columbia
Anatoliy Swishchuk, University of Calgary
Ronald F. Taylor, Wright State University
Brian Vick, Virginia Polytechnic Institute and State University
John Silzel, Biola University
James Guilkey, University of Utah
We would also like to thank Linda Ratts, acquisition editor, and
Renata Marchione, editorial assistant, from Wiley. Special thanks to
Professor Subramaniam’s daughters, Sonya and Priya, for typing early
drafts of some chapters and for proofreading them.
Our intention was to write a book that is useful to students and
instructors alike. We would like to thank users of previous editions of
the book who have sent us compliments and suggestions. We would
appreciate any comments that will help to improve future editions.
Amos Gilat (gilat.1@osu.edu)
Vish Subramaniam (subramaniam.1@osu.edu)
Columbus, Ohio
June 2013
11. To Yaela, Taly, and Edan
To my parents, Dr. K. S. Venkateswaran Seethalakshmy Venkateswaran,
and Deepa, Priya, and Sonya
12. ix
Brief Table of Contents
Preface iii
Chapter 1 Introduction 1
Chapter 2 Mathematical Background 23
Chapter 3 Solving Nonlinear Equations 57
Chapter 4 Solving a System of Linear Equations 99
Chapter 5 Eigenvalues and Eigenvectors 165
Chapter 6 Curve Fitting and Interpolation 193
Chapter 7 Fourier Methods 251
Chapter 8 Numerical Differentiation 303
Chapter 9 Numerical Integration 341
Chapter 10 Ordinary Differential Equations: Initial–Value
Problems 385
Chapter 11 Ordinary Differential Equations: Boundary–Value
Problems 471
Appendix A Introductory MATLAB 509
Appendix B MATLAB Programs 547
Appendix C Derivation of the Real Discrete Fourier Transform
(DFT) 551
Index 555
14. xi
Contents
Preface iii
Chapter 1 Introduction 1
1.1 Background 1
1.2 Representation of Numbers on a Computer 4
1.3 Errors in Numerical Solutions 10
1.3.1 Round-Off Errors 10
1.3.2 Truncation Errors 13
1.3.3 Total Error 14
1.4 Computers and Programming 15
1.5 Problems 18
Chapter 2 Mathematical Background 23
2.1 Background 23
2.2 Concepts from Pre-Calculus and Calculus 24
2.3 Vectors 28
2.3.1 Operations with Vectors 30
2.4 Matrices and Linear Algebra 32
2.4.1 Operations with Matrices 33
2.4.2 Special Matrices 35
2.4.3 Inverse of a Matrix 36
2.4.4 Properties of Matrices 37
2.4.5 Determinant of a Matrix 37
2.4.6 Cramer’s Rule and Solution of a System of Simultaneous Linear Equations 38
2.4.7 Norms 40
2.5 Ordinary Differential Equations (ODE) 41
2.6 Functions of Two or More Independent Variables 44
2.6.1 Definition of the Partial Derivative 44
2.6.2 Chain Rule 45
2.6.3 The Jacobian 46
2.7 Taylor Series Expansion of Functions 47
2.7.1 Taylor Series for a Function of One Variable 47
2.7.2 Taylor Series for a Function of Two Variables 49
2.8 Inner Product and Orthogonality 50
2.9 Problems 51
15. xii Contents
Chapter 3 Solving Nonlinear Equations 57
3.1 Background 57
3.2 Estimation of Errors in Numerical Solutions 59
3.3 Bisection Method 61
3.4 Regula Falsi Method 64
3.5 Newton’s Method 66
3.6 Secant Method 71
3.7 Fixed-Point Iteration Method 74
3.8 Use of MATLAB Built-In Functions for Solving Nonlinear Equations 77
3.8.1 The fzero Command 78
3.8.2 The roots Command 79
3.9 Equations with Multiple Solutions 79
3.10 Systems of Nonlinear Equations 81
3.10.1 Newton’s Method for Solving a System of Nonlinear Equations 82
3.10.2 Fixed-Point Iteration Method for Solving a System of Nonlinear Equations 86
3.11 Problems 88
Chapter 4 Solving a System of Linear Equations 99
4.1 Background 99
4.1.1 Overview of Numerical Methods for Solving a System of Linear Algebraic Equations 100
4.2 Gauss Elimination Method 102
4.2.1 Potential Difficulties When Applying the Gauss Elimination Method 110
4.3 Gauss Elimination with Pivoting 112
4.4 Gauss–Jordan Elimination Method 115
4.5 LU Decomposition Method 118
4.5.1 LU Decomposition Using the Gauss Elimination Procedure 120
4.5.2 LU Decomposition Using Crout’s Method 121
4.5.3 LU Decomposition with Pivoting 128
4.6 Inverse of a Matrix 128
4.6.1 Calculating the Inverse with the LU Decomposition Method 129
4.6.2 Calculating the Inverse Using the Gauss–Jordan Method 131
4.7 Iterative Methods 132
4.7.1 Jacobi Iterative Method 133
4.7.2 Gauss-Seidel Iterative Method 133
4.8 Use of MATLAB Built-In Functions for Solving a System of Linear Equations 136
4.8.1 Solving a System of Equations Using MATLAB’s Left and Right Division 136
4.8.2 Solving a System of Equations Using MATLAB’s Inverse Operation 137
4.8.3 MATLAB’s Built-In Function for LU Decomposition 138
4.8.4 Additional MATLAB Built-In Functions 139
4.9 Tridiagonal Systems of Equations 141
16. Contents xiii
4.10 Error, Residual, Norms, and Condition Number 146
4.10.1 Error and Residual 146
4.10.2 Norms and Condition Number 148
4.11 Ill-Conditioned Systems 15
4.12 Problems 155
Chapter 5 Eigenvalues and Eigenvectors 165
5.1 Background 165
5.2 The Characteristic Equation 167
5.3 The Basic Power Method 167
5.4 The Inverse Power Method 172
5.5 The Shifted Power Method 173
5.6 The QR Factorization and Iteration Method 174
5.7 Use of MATLAB Built-In Functions for Determining Eigenvalues and
Eigenvectors 184
5.8 Problems 186
Chapter 6 Curve Fitting and Interpolation 193
6.1 Background 193
6.2 Curve Fitting with a Linear Equation 195
6.2.1 Measuring How Good Is a Fit 195
6.2.2 Linear Least-Squares Regression 197
6.3 Curve Fitting with Nonlinear Equation by Writing the Equation in a Linear Form 201
6.4 Curve Fitting with Quadratic and Higher-Order Polynomials 205
6.5 Interpolation Using a Single Polynomial 210
6.5.1 Lagrange Interpolating Polynomials 212
6.5.2 Newton’s Interpolating Polynomials 216
6.6 Piecewise (Spline) Interpolation 223
6.6.1 Linear Splines 223
6.6.2 Quadratic Splines 225
6.6.3 Cubic Splines 229
6.7 Use of MATLAB Built-In Functions for Curve Fitting and Interpolation 236
6.8 Curve Fitting with a Linear Combination of Nonlinear Functions 238
6.9 Problems 241
Chapter 7 Fourier Methods 251
7.1 Background 251
7.2 Approximating a Square Wave by a Series of Sine Functions 253
7.3 General (Infinite) Fourier Series 257
7.4 Complex Form of the Fourier Series 261
3
17. xiv Contents
7.5 The Discrete Fourier Series and Discrete Fourier Transform 263
7.6 Complex Discrete Fourier Transform 268
7.7 Power (Energy) Spectrum 271
7.8 Aliasing and Nyquist Frequency 272
7.9 Alternative Forms of the Discrete Fourier Transform 278
7.10 Use of MATLAB Built-In Functions for Calculating Discrete Fourier Transform 278
7.11 Leakage and Windowing 284
7.12 Bandwidth and Filters 286
7.13 The Fast Fourier Transform (FFT) 289
7.14 Problems 298
Chapter 8 Numerical Differentiation 303
8.1 Background 303
8.2 Finite Difference Approximation of the Derivative 305
8.3 Finite Difference Formulas Using Taylor Series Expansion 310
8.3.1 Finite Difference Formulas of First Derivative 310
8.3.2 Finite Difference Formulas for the Second Derivative 315
8.4 Summary of Finite Difference Formulas for Numerical Differentiation 317
8.5 Differentiation Formulas Using Lagrange Polynomials 319
8.6 Differentiation Using Curve Fitting 320
8.7 Use of MATLAB Built-In Functions for Numerical Differentiation 320
8.8 Richardson’s Extrapolation 322
8.9 Error in Numerical Differentiation 325
8.10 Numerical Partial Differentiation 327
8.11 Problems 330
Chapter 9 Numerical Integration 341
9.1 Background 341
9.1.1 Overview of Approaches in Numerical Integration 342
9.2 Rectangle and Midpoint Methods 344
9.3 Trapezoidal Method 346
9.3.1 Composite Trapezoidal Method 347
9.4 Simpson’s Methods 350
9.4.1 Simpson’s 1/3 Method 350
9.4.2 Simpson’s 3/8 Method 353
9.5 Gauss Quadrature 355
9.6 Evaluation of Multiple Integrals 360
9.7 Use of MATLAB Built-In Functions for Integration 362
9.8 Estimation of Error in Numerical Integration 364
9.9 Richardson’s Extrapolation 366
18. Contents xv
9.10 Romberg Integration 369
9.11 Improper Integrals 372
9.11.1 Integrals with Singularities 372
9.11.2 Integrals with Unbounded Limits 373
9.12 Problems 374
Chapter 10 Ordinary Differential Equations: Initial-Value
Problems 385
10.1 Background 385
10.2 Euler’s Methods 390
10.2.1 Euler’s Explicit Method 390
10.2.2 Analysis of Truncation Error in Euler’s Explicit Method 394
10.2.3 Euler’s Implicit Method 398
10.3 Modified Euler’s Method 401
10.4 Midpoint Method 404
10.5 Runge–Kutta Methods 405
10.5.1 Second-Order Runge–Kutta Methods 406
10.5.2 Third-Order Runge–Kutta Methods 410
10.5.3 Fourth-Order Runge–Kutta Methods 411
10.6 Multistep Methods 417
10.6.1 Adams–Bashforth Method 418
10.6.2 Adams–Moulton Method 419
10.7 Predictor–Corrector Methods 420
10.8 System of First-Order Ordinary Differential Equations 422
10.8.1 Solving a System of First-Order ODEs Using Euler’s Explicit Method 424
10.8.2 Solving a System of First-Order ODEs Using Second-Order Runge–Kutta Method
(Modified Euler Version) 424
10.8.3 Solving a System of First-Order ODEs Using the Classical Fourth-Order Runge–Kutta
Method 431
10.9 Solving a Higher-Order Initial Value Problem 432
10.10 Use of MATLAB Built-In Functions for Solving Initial-Value Problems 437
10.10.1 Solving a Single First-Order ODE Using MATLAB 438
10.10.2 Solving a System of First-Order ODEs Using MATLAB 444
10.11 Local Truncation Error in Second-Order Range–Kutta Method 447
10.12 Step Size for Desired Accuracy 448
10.13 Stability 452
10.14 Stiff Ordinary Differential Equations 454
10.15 Problems 457
19. xvi Contents
Chapter 11 Ordinary Differential Equations: Boundary-Value
Problems 471
11.1 Background 471
11.2 The Shooting Method 474
11.3 Finite Difference Method 482
11.4 Use of MATLAB Built-In Functions for Solving Boundary Value Problems 492
11.5 Error and Stability in Numerical Solution of Boundary Value Problems 497
11.6 Problems 499
Appendix A Introductory MATLAB 509
A.1 Background 509
A.2 Starting with MATLAB 509
A.3 Arrays 514
A.4 Mathematical Operations with Arrays 519
A.5 Script Files 524
A.6 Plotting 526
A.7 User-Defined Functions and Function Files 528
A.8 Anonymous Functions 530
A.9 Function functions 532
A.10 Subfunctions 535
A.11 Programming in MATLAB 537
A.11.1 Relational and Logical Operators 537
A.11.2 Conditional Statements, if-else Structures 538
A.11.3 Loops 541
A.12 Problems 542
Appendix B MATLAB Programs 547
Appendix C Derivation of the Real Discrete Fourier Transform
(DFT) 551
C.1 Orthogonality of Sines and Cosines for Discrete Points 551
C.2 Determination of the Real DFT 553
Index 555
20. 1
Chapter 1
Introduction
1.1 BACKGROUND
Numerical methods are mathematical techniques used for solving math-
ematical problems that cannot be solved or are difficult to solve analyti-
cally. An analytical solution is an exact answer in the form of a
mathematical expression in terms of the variables associated with the
problem that is being solved. A numerical solution is an approximate
numerical value (a number) for the solution. Although numerical solu-
tions are an approximation, they can be very accurate. In many numeri-
cal methods, the calculations are executed in an iterative manner until a
desired accuracy is achieved.
For example, Fig. 1-1 shows a block of mass m being pulled by a
force F applied at an angle . By applying equations of equilibrium, the
relationship between the force and the angle is given by:
(1.1)
where is the friction coefficient and g is the acceleration due to grav-
ity. For a given value of F, the angle that is required for moving the
block can be determined by solving Eq. (1.1) for . Equation (1.1),
however, cannot be solved analytically for . Using numerical methods,
an approximate solution can be determined for specified accuracy. This
means that when the numerical solution for is substituted back in Eq.
(1.1), the value of F that is obtained from the expression on the right-
hand side is not exactly equal to the given value of F, but is very close.
Numerical techniques for solving mathematical problems were
developed and used hundreds and even thousands of years ago. Imple-
mentation of the numerical techniques was difficult since the calcula-
tions had to be carried out by hand or by use of simple mechanical
F
q
m
Figure 1-1: Motion of a block on
a surface with friction.
F
mg
cos
sin
+
--------------------------------
-
=
Core Topics
Representation of numbers on a computer (1.2).
Errors in numerical solutions, round-off errors and
truncation errors (1.3).
Computers and programming (1.4).
21. 2 Chapter 1 Introduction
computing devices, which limited the number of calculations that could
be carried out, as well as their speed and accuracy. Today numerical
methods are used with fast electronic digital computers that make it
possible to execute many tedious and repetitive calculations that pro-
duce accurate (even though not exact) solutions in a very short time.
Solving a problem in science and engineering
The process of solving a problem in science and engineering is influ-
enced by the tools (mathematical methods) that are available for solving
the problem. The process can be divided into the following steps:
Problem statement
The problem statement defines the problem. It gives a description of the
problem, lists the variables that are involved, and identifies the con-
straints in the form of boundary and/or the initial conditions.
Formulation of the solution
Formulation of the solution consists of the model (physical law or laws)
that is used to represent the problem and the derivation of the governing
equations that need to be solved. Examples of such laws are Newton’s
laws, conservations of mass, and the laws of thermodynamics. The
models that are used (chosen) to solve the problem need to be consistent
with the methods that are subsequently used for solving the equations.
If analytical methods are expected to be used for the solution, the gov-
erning equations must be of a type that can be solved analytically. If
needed, the formulation has to be simplified, such that the equations
could be solved analytically. If numerical methods are used for the solu-
tion, the models and the equations can be more complicated. Even then,
however, some limitations might exist. For example, if the formulation
is such that a numerical solution requires a long computing time, the
formulation might have to be simplified such that a solution is obtained
in a reasonable time. An example is weather forecasting. The problem
that is solved is large, and the numerical models that are used are very
complicated. The numerical simulation of the weather, however, cannot
outlast the period over which forecasting is needed.
Programming (of numerical solution)
If the problem is solved numerically, the numerical method that is used
for the solution has to be selected. For every type of mathematical prob-
lem there are several (or many) numerical techniques that can be used.
The techniques differ in accuracy, length of calculations, and difficulty
in programming. Once a numerical method is selected, it is imple-
mented in a computer program. The implementation consists of an
algorithm, which is a detailed plan that describes how to carry out the
numerical method, and a computer program, which is a list of com-
mands that allows the computer to execute the algorithm to find the
solution.
22. 1.1 Background 3
Interpretation of the solution
Since numerical solutions are an approximation (errors are addressed in
Section 1.4), and since the computer program that executes the numeri-
cal method might have errors (or bugs), a numerical solution needs to
be examined closely. This can be done in several ways, depending on
the problem. For example, if the numerical method is used for solving a
nonlinear algebraic equation, the validity of the solution can be verified
by substituting the solution back in the equation. In more complicated
problems, like a solution of a differential equation, the numerical solu-
tion can be compared with a known solution of a similar problem, or the
problem can be solved several times using different boundary (or ini-
tial) conditions, and different numerical methods, and examining the
subsequent differences in the solutions.
An illustration of the first two steps in the solution process of a
problem is shown in Example 1-1.
Example 1-1: Problem formulation
Consider the following problem statement:
A pendulum of mass m is attached to a rigid rod of length L,
as shown in the figure. The pendulum is displaced from the
vertical position such that the angle between the rod and the x
axis is , and then the pendulum is released from rest. For-
mulate the problem for determining the angle as a function
of time, t, once the pendulum is released. In the formulation
include a damping force that is proportional to the velocity of
the pendulum.
Formulate the solution for two cases:
(a) , and (b) .
SOLUTION
Physical law
The physical law that is used for solving the problem is
Newton’s second law of mechanics, according to which,
as the pendulum swings back and forth, the sum of the
forces that are acting on the mass is equal to the mass
times its acceleration.
(1.2)
This can be visualized by drawing a free body diagram
and a mass acceleration diagram, which are shown on the
right. The constant c is the damping coefficient. It should be pointed out that the mass of the rod is
neglected in the present solution.
q
m
x
y
L
t = 0
0
0 5
= 0 90
=
θ
T
FD=cLθ
mg
n
t
man=mθ2
L
n
t
mat=mLθ
FREE BODY
DIAGRAM
MASS ACCELERATION
DIAGRAM
Newton’s Second Law
F ma
=
23. 4 Chapter 1 Introduction
1.2 REPRESENTATION OF NUMBERS ON A
COMPUTER
Decimal and binary representation
Numbers can be represented in various forms. The familiar decimal sys-
tem (base 10) uses ten digits 0, 1, ..., 9. A number is written by a
sequence of digits that correspond to multiples of powers of 10. As
shown in Fig. 1-2, the first digit to the left of the decimal point corre-
Governing equation
The governing equation is derived by applying Newton’s second law in the tangential direction:
(1.3)
Equation (1.3), which is a second-order, nonlinear, ordinary differential equation, can be written in
the form:
(1.4)
The initial conditions are that when the motion of the pendulum starts ( ), the pendulum is at
angle and its velocity is zero (released from rest):
and (1.5)
Method of solution
Equation (1.4) is a nonlinear equation and cannot be solved analytically. However, in part (a) the ini-
tial displacement of the pendulum is , and once the pendulum is released, the angle as the
pendulum oscillates will be less than . For this case, Eq. (1.4) can be linearized by assuming that
. With this approximation, the equation that has to be solved is linear and can be solved ana-
lytically:
(1.6)
with the initial conditions Eq. (1.5).
In part (b), the initial displacement of the pendulum is and the equation has to be
solved numerically. An actual numerical solution for this problem is shown in Example 8-8.
Ft cL
d
dt
-----
-
– mg
sin
– mL
d
2
dt2
--------
-
= =
mL
d
2
dt2
--------
- cL
d
dt
-----
- mg
sin
+ + 0
=
t 0
=
0
0
0
=
d
dt
-----
-
t 0
=
0
=
0 5
=
5
sin
mL
d
2
dt2
--------
- cL
d
dt
-----
- mg
+ + 0
=
0 90
=
104
103
102
101
100
10-1
10-2
10-3
10-4
6 0 7 2 4 . 3 1 2 5
6 104
+ 0 103
+ 7 102
+ 2 101
+ 4 100
+ 3 10-1
+ 1 10-2
+ 2 10-3
+ 5 10-4
= 60,724.3125
Figure 1-2: Representation of the number 60,724.3125 in the decimal system (base 10).
24. 1.2 Representation of Numbers on a Computer 5
sponds to . The digit next to it on the left corresponds to , the
next digit to the left to , and so on. In the same way, the first digit to
the right of the decimal point corresponds to , the next digit to the
right to , and so on.
In general, however, a number can be represented using other bases.
A form that can be easily implemented in computers is the binary (base
2) system. In the binary system, a number is represented by using the
two digits 0 and 1. A number is then written as a sequence of zeros and
ones that correspond to multiples of powers of 2. The first digit to the
left of the decimal point corresponds to . The digit next to it on the
left corresponds to , the next digit to the left to , and so on. In the
same way, the first digit to the right of the decimal point corresponds to
, the next digit to the right to , and so on. The first ten digits
in base 10 and their representation in base 2 are shown in
Fig. 1-3. The representation of the number 19.625 in the binary system
is shown in Fig. 1-4.
Another example is shown in Fig. 1-5, where the number
60,724.3125 is written in binary form.
10
0
10
1
10
2
10
1
–
10
2
–
2
0
2
1
2
2
2
1
–
2
2
–
1 2 3 10
Base
10
Base 2
23
22
21
20
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1
2
3
4
5
6
7
8
9
10
Figure 1-3: Representation of
numbers in decimal and binary
forms.
2
4
2
3
2
2
2
1
2
0
2
-1
2
-2
2
-3
1 0 0 1 1 . 1 0 1
1 2
4
+ 0 2
3
+ 0 2
2
+ 1 2
1
+ 1 2
0
+ 1 2
-1
+ 0 2
-2
+ 1 2
-3
1 16 + 0 8 + 0 4 + 1 2 + 1 1 + 1 0.5 + 0 0.25 + 1 0.125 = 19.625
Figure 1-4: Representation of the number 19.625 in the binary system (base 2).
2
15
2
14
2
13
2
12
2
11
2
10
2
9
2
8
27
2
6
2
5
2
4
2
3
22
2
1
2
0
2
-1
2
-2
2
-3
2
-4
1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 1
1 2
15
+ 1 2
14
+ 1 2
13
+ 0 2
12
+ 1 2
11
+ 1 2
10
+ 0 2
9
+ 1 2
8
+ 0 2
7
+ 0 2
6
+ 1 2
5
+ 1 24 + 0 23 + 1 22 + 0 21 + 0 20 + 0 2-1 + 1 2-2 + 0 2-3 + 1 2-4 = 60,724.3125
Figure 1-5: Representation of the number 60,724.3125 in the binary system (base 2).
25. 6 Chapter 1 Introduction
Computers store and process numbers in binary (base 2) form. Each
binary digit (one or zero) is called a bit (for binary digit). Binary arith-
metic is used by computers because modern transistors can be used as
extremely fast switches. Therefore, a network of these may be used to
represent strings of numbers with the “1” referring to the switch being
in the “on” position and “0” referring to the “off” position. Various
operations are then performed on these sequences of ones and zeros.
Floating point representation
To accommodate large and small numbers, real numbers are written in
floating point representation. Decimal floating point representation
(also called scientific notation) has the form:
. (1.7)
One digit is written to the left of the decimal point, and the rest of the
significant digits are written to the right of the decimal point. The num-
ber 0.dddddd is called the mantissa. Two examples are:
written as
written as
The power of 10, p, represents the number’s order of magnitude, pro-
vided the preceding number is smaller than 5. Otherwise, the number is
said to be of the order of . Thus, the number is of the
order of , , and the number is of the order of
(written as ).
Binary floating point representation has the form:
. (b is a decimal digit) (1.8)
In this form, the mantissa is . , and the power of 2 is called the
exponent. Both the mantissa and the exponent are written in a binary
form. The form in Eq. (1.8) is obtained by normalizing the number
(when it is written in the decimal form) with respect to the largest
power of 2 that is smaller than the number itself. For example, to write
the number 50 in binary floating point representation, the number is
divided (and multiplied) by (which is the largest power of 2
that is smaller than 50):
Binary floating point form:
Two more examples are:
Binary floating point form:
Binary floating point form:
d dddddd 10
p
6519.23 6.51923 10
3
0.00000391 3.91 10
6
–
p 1
+ 3.91 10
6
–
10
6
–
O 10
6
–
6.51923 10
3
10
4
O 10
4
1 bbbbbb 2
bbb
bbbbbb
2
5
32
=
50
50
2
5
-----
- 2
5
1.5625 2
5
= = 1.1001 2
101
1344
1344
2
10
-----------
- 2
10
1.3125 2
10
= = 1.0101 2
1010
0.3125
0.3125
2
2
–
---------------
- 2
2
–
1.25 2
2
–
= = 1.01 2
10
–
26. 1.2 Representation of Numbers on a Computer 7
Storing a number in computer memory
Once in binary floating point representation, the number is stored in the
computer. The computer stores the values of the exponent and the man-
tissa separately, while the leading 1 in front of the decimal point is not
stored. As already mentioned, a bit is a binary digit. The memory in the
computer is organized in bytes, where each byte is 8 bits. According to
the IEEE1
-754 standard (1985), computers store numbers and carry out
calculations in single precision2 or in double precision.3 In single pre-
cision, the numbers are stored in a string of 32 bits (4 bytes), and in
double precision in a string of 64 bits (8 bytes). In both cases the first
bit stores the sign (0 corresponds to + and 1 corresponds to –) of the
number. The next 8 bits in single precision (11 bits in double precision)
are used for storing the exponent. The following 23 bits in single preci-
sion (52 bits in double precision) are used for storing the mantissa. This
is illustrated for double precision in Fig. 1-6.
The value of the mantissa is entered as is in a binary form. The
value of the exponent is entered with a bias. A bias means that a con-
stant is added to the value of the exponent. The bias is introduced in
order to avoid using one of the bits for the sign of the exponent (since
the exponent can be positive or negative). In binary notation, the largest
number that can be written with 11 bits is 2047 (when all 11 digits are
1). The bias that is used is 1023, which means that if, for example, the
exponent is 4, then the value that is stored is . Thus, the
1. IEEE stands for the Institute of Electrical and Electronics Engineers.
2. Precision refers to the number of significant digits of a real number that can be
stored on a computer. For example, the number 1/3 = 0.333333... can be represented
on a computer only in a chopped or rounded form with a finite number of binary dig-
its, since the amount of memory where these bits are held is finite. The more digits
to the right-hand side of the decimal point that are stored, the more precise is the
representation of the real number on the computer.
3. This is somewhat of a misnomer. The precision in a double-precision number is not
really doubled compared to a single-precision number. Rather, the “double” in dou-
ble precision refers to the fact that twice as many binary digits (64 versus 32) are
used to represent a real number than in the case of a single-precision representation.
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
. . . . . . . . . .
Exponent + bias
11 bits
Mantissa
52 bits
Sign
1 bit
20
21
210
29
28
2-1
2-2
2-3
2-50
2-51
2-52
Figure 1-6: Storing in double precision a number written in binary floating point representation.
4 1023
+ 1027
=
27. 8 Chapter 1 Introduction
smallest exponent that can be stored by the computer is , and the
largest is 1024 (which will be stored as 2047). However, the smallest
and largest values of the exponent plus bias are reserved for zero and
infinity (Inf) or not-a-number (NaN) due to invalid mathematical
operation. The 11 bits for the exponent plus bias store values between
and 1024. If the exponent plus bias and mantissa are both zero,
then the number actually stored is 0. If the exponent plus bias is 2047
the number stored is Inf if the mantissa is zero, and it is NaN if the
mantissa is not zero. In single precision, 8 bits are allocated to the value
of the exponent and the bias is 127.
As an example, consider storing of the number 22.5 in double preci-
sion according to the IEEE-754 standard. First, the number is normal-
ized: . In double precision, the exponent with the
bias is , which is stored in binary form as 10000000011.
The mantissa is 0.40625, which is stored in binary form as
.01101000....000. The storage of the number is illustrated in Fig. 1-7.
Additional notes
• The smallest positive number that can be expressed in double preci-
sion is:
This means that there is a (small) gap between zero and the smallest
number that can be stored on the computer. Attempts to define a
number in this gap causes an underflow error. (In the same way, the
closest negative number to zero is .)
• The largest positive number that can be expressed in double preci-
sion is approximately:
Attempts to define a larger number causes overflow error. (The same
applies to numbers smaller than .)
The range of numbers that can be represented in double precision is
shown in Fig. 1-8.
1023
–
1023
–
22.5
24
---------
-24 1.40625 2
4
=
4 1023
+ 1027
=
0 . . . .
Exponent + bias
11 bits
Mantissa
52 bits
Sign
1 bit
0 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Figure 1-7: Storing the number 22.5 in double precision according to the IEEE-754 standard.
2
1022
–
2.2 10
308
–
2.2 10
308
–
–
2
1024
1.8 10
308
2
–
1024
28. 1.2 Representation of Numbers on a Computer 9
• Since a finite number of bits is used, not every number can be accu-
rately written in binary form. In other words, only a finite number of
exact values in decimal format can be stored in binary form. For
example, the number 0.1 cannot be represented exactly in finite
binary format when single precision is used. To be written in binary
floating point representation, 0.1 is normalized: . The
exponent -4 (with a bias) can be stored exactly, but the mantissa 0.6
cannot be written exactly in a binary format that uses 23 bits. In
addition, irrational numbers cannot be represented exactly in any
format. This means that, in many cases, exact values are approxi-
mated. The errors that are introduced are small in one step, but when
many operations are executed, the errors can grow to such an extent
that the final answer is affected. These errors, as well as other errors,
are discussed in the next section.
• The interval between numbers that can be represented depends on
their magnitude. In double precision, the smallest value of the man-
tissa that can be stored is . This is also the smallest
possible difference in the mantissa between two numbers. The mag-
nitude of the real number that is associated with this mantissa, how-
ever, depends on the exponent. For numbers of the order of 1, the
smallest difference between two numbers that can be represented in
double precision is then . This value is also defined as
the machine epsilon in double precision. In MATLAB this value is
assigned to the predefined variable eps. As shown below, when the
name of the variable eps is typed (Command Window), the assigned
value is displayed.
eps
ans =
2.220446049250313e-016
Range of numbers that
can be represented
(+)
( ) 0
~2.2 10-308
~ -2.2 10-308
~1.8 10308
~ -1.8 10308
Range of numbers that
can be represented
Underflow
Overflow Overflow
Figure 1-8: Range of numbers that can be represented in double precision.
0.1 1.6 2
4
–
=
2
52
–
2.22 10
16
–
2.22 10
16
–
29. 10 Chapter 1 Introduction
1.3 ERRORS IN NUMERICAL SOLUTIONS
Numerical solutions can be very accurate but in general are not exact.
Two kinds of errors are introduced when numerical methods are used
for solving a problem. One kind, which was mentioned in the previous
section, occurs because of the way that digital computers store numbers
and execute numerical operations. These errors are labeled round-off
errors. The second kind of errors is introduced by the numerical method
that is used for the solution. These errors are labeled truncation errors.
Numerical methods use approximations for solving problems. The
errors introduced by the approximations are the truncation errors.
Together, the two errors constitute the total error of the numerical solu-
tion, which is the difference (can be defined in various ways) between
the true (exact) solution (which is usually unknown) and the approxi-
mate numerical solution. Round-off, truncation, and total errors are dis-
cussed in the following three subsections.
1.3.1 Round-Off Errors
Numbers are represented on a computer by a finite number of bits (see
Section 1.2). Consequently, real numbers that have a mantissa longer
than the number of bits that are available for representing them have to
be shortened. This requirement applies to irrational numbers that have
to be represented in a finite form in any system, to finite numbers that
are too long, and to finite numbers in decimal form that cannot be repre-
sented exactly in binary form. A number can be shortened either by
chopping off, or discarding, the extra digits or by rounding. In chop-
ping, the digits in the mantissa beyond the length that can be stored are
simply left out. In rounding, the last digit that is stored is rounded.
As a simple illustration, consider the number 2/3. (For simplicity,
decimal format is used in the illustration. In the computer, chopping and
rounding are done in the binary format.) In decimal form with four sig-
nificant digits, 2/3 can be written as 0.6666 or as 0.6667. In the former
instance, the actual number has been chopped off, whereas in the latter
instance, the actual number has been rounded. Either way, such chop-
ping and rounding of real numbers lead to errors in numerical computa-
tions, especially when many operations are performed. This type of
numerical error (regardless of whether it is due to chopping or round-
ing) is known as round-off error. Example 1-2 shows the difference
between chopping and rounding.
30. 1.3 Errors in Numerical Solutions 11
The magnitude of round-off errors depends on the magnitude of the
numbers that are involved since, as explained in the previous section,
the interval between the numbers that can be represented on a computer
depends on their magnitude. Round-off errors are likely to occur when
the numbers that are involved in the calculations differ significantly in
their magnitude and when two numbers that are nearly identical are
subtracted from each other.
For example, consider the quadratic equation:
(1.9)
for which the exact solutions are and . The solu-
tions can be calculated with the quadratic formula:
and (1.10)
Using MATLAB (Command Window) to calculate and gives:
Example 1-2: Round-off errors
Consider the two nearly equal numbers and . Use decimal floating point rep-
resentation (scientific notation) with three significant digits in the mantissa to calculate the differ-
ence between the two numbers, . Do the calculation first by using chopping and then by using
rounding.
SOLUTION
In decimal floating point representation, the two numbers are:
and
If only three significant digits are allowed in the mantissa, the numbers have to be shortened. If
chopping is used, the numbers become:
and
Using these values in the subtraction gives:
If rounding is used, the numbers become:
and (q is the same as before)
Using these values in the subtraction gives:
The true (exact) difference between the numbers is 3.8. These results show that, in the present prob-
lem, rounding gives a value closer to the true answer.
format long
a = 1; b = -100.0001; c = 0.01;
RootDis = sqrt(b^2 - 4*a*c)
RootDis =
99.999899999999997
p 9890.9
= q 9887.1
=
p q
–
p 9.8909 10
3
= q 9.8871 10
3
=
p 9.890 10
3
= q 9.887 10
3
=
q
– 9.890 10
3
9.887 10
3
– 0.003 10
3
3
= = =
p 9.891 10
3
= q 9.887 10
3
=
q
– 9.891 10
3
9.887 10
3
– 0.004 10
3
4
= = =
x2 100.0001x
– 0.01
+ 0
=
x1 100
= x2 0.0001
=
x1
b
– b
2
4ac
–
+
2a
--------------------------------------
= x2
b
– b
2
4ac
–
–
2a
-------------------------------------
-
=
x1 x2
31. 12 Chapter 1 Introduction
The value that is calculated by MATLAB for is not exact due to
round-off errors. The round-off error occurs in the numerator in the
expression for . Since b is negative, the numerator involves subtrac-
tion of two numbers that are nearly equal.
In many cases, the form of the mathematical expressions that con-
tain subtraction of two quantities that are nearly equal can be changed
to a different form that is less likely to cause round-off errors. In the
expression for in Eq. (1.10), this can be done by multiplying the
expression by :
(1.11)
Using Eq. (1.11) in MATLAB to calculate the value of gives:
Now the calculated value for is without an error. Another example
of round-off errors is shown in Example 1-3.
x1 = (-b + RootDis)/(2*a)
x1 =
100
x2 = (-b - RootDis)/(2*a)
x2 =
1.000000000033197e-004
x2Mod = (2*c)/(-b+RootDis)
x2Mod =
1.000000000000000e-004
Example 1-3: Round-off errors
Consider the function:
(1.12)
(a) Use MATLAB to calculate the value of for the following three values of x:
, , and .
(b) Use the decimal format with six significant digits to calculate for the values of x in part
(a). Compare the results with the values in part (a).
(c) Change the form of by multiplying it by . Using the new form with numbers in
decimal format with six significant digits, calculate the value of for the three values of x.
Compare the results with the values in part (a).
x2
x2
x2
b
– b
2
4ac
–
+
b
– b
2
4ac
–
+
x2
b
– b
2
4ac
–
–
2a
-------------------------------------
-
b
– b
2
4ac
–
+
b
– b
2
4ac
–
+
------------------------------------------
-
2c
b
– b
2
4ac
–
+
--------------------------------------
= =
x2
x2
f x
x x x 1
–
–
=
f x
x 10
= x 1000
= x 100000
=
f x
f x
x x 1
–
+
x x 1
–
+
----------------------------
-
f x
32. 1.3 Errors in Numerical Solutions 13
1.3.2 Truncation Errors
Truncation errors occur when the numerical methods used for solving a
mathematical problem use an approximate mathematical procedure. A
simple example is the numerical evaluation of , which can be
done by using Taylor’s series expansion (Taylor’s series are reviewed in
Chapter 2):
(1.14)
SOLUTION
(a)
format long g
x = [10 1000 100000];
Fx = x.*(sqrt(x) - sqrt(x-1))
Fx =
1.6227766016838 15.8153431255776 158.114278298171
(b) Using decimal format with six significant digits in Eq. (1.12) gives the following values for
:
This value agrees with the value from part (a), when the latter is rounded to six significant digits.
When rounded to six significant digits, the value in part (a) is .
When rounded to six significant digits, the value in part (a) is .
The results show that the rounding error due to the use of six significant digits increases as x
increases and the relative difference between and decreases.
(c) Multiplying the right-hand side of Eq. (1.12) by gives:
(1.13)
Calculating using Eq. (1.13) for , , and gives:
Now the values of are the same as in part (a).
f x
f 10
10 10 10 1
–
–
10 3.16228 3
–
1.62280
= = =
f 1000
1000 1000 1000 1
–
–
1000 31.6228 31.6070
–
15.8
= = =
15.8153
f 100000
100000 100000 100000 1
–
–
100000 316.228 316.226
–
200
= = =
158.114
x x 1
–
x x 1
–
+
x x 1
–
+
----------------------------
-
f x
x x x 1
–
–
x x 1
–
+
x x 1
–
+
----------------------------
-
x x x 1
–
–
x x 1
–
+
--------------------------------
-
x
x x 1
–
+
----------------------------
-
= = =
f x
x 10
= x 1000
= x 100000
=
f 10
10
10 10 1
–
+
-----------------------------------
10
3.16228 3
+
---------------------------- 1.62278
= = =
f 1000
1000
1000 1000 1
–
+
-----------------------------------------------
1000
31.6228 31.6070
+
--------------------------------------------
- 15.8153
= = =
f 100000
100000
100000 100000 1
–
+
-----------------------------------------------------------
1000
316.228 316.226
+
--------------------------------------------
- 158.114
= = =
f x
x
sin
x
sin x
x3
3!
----
-
–
x5
5!
----
-
x7
7!
----
-
–
x9
9!
----
-
x11
11!
-------
-
–
+ + +
=
33. 14 Chapter 1 Introduction
The value of can be determined exactly with Eq. (1.14) if an
infinite number of terms are used. The value can be approximated by
using only a finite number of terms. The difference between the true
(exact) value and an approximate value is the truncation error, denoted
by . For example, if only the first term is used:
If two terms of the Taylor’s series are used:
Another example of truncation error that is probably familiar to the
reader is the approximate calculation of derivatives. The value of the
derivative of a function at a point can be approximated by the
expression:
(1.15)
where is a point near . The difference between the value of the
true derivative and the value that is calculated with Eq. (1.15) is called a
truncation error.
The truncation error is dependent on the specific numerical method
or algorithm used to solve a problem. Details on truncation errors are
discussed throughout the book as various numerical methods are pre-
sented. The truncation error is independent of round-off error; it exists
even when the mathematical operations themselves are exact.
1.3.3 Total Error
Numerical solution is an approximation. It always includes round-off
errors and, depending on the numerical method, can also include trun-
cation errors. Together, the round-off and truncation errors yield the
total numerical error that is included in the numerical solution. This
total error, also called the true error, is the difference between the true
(exact) solution and the numerical solution:
(1.16)
The absolute value of the ratio between the true error and the true solu-
tion is called the true relative error:
(1.17)
This quantity which is non dimensional and scale-independent indicates
how large the error is relative to the true solution.
The true error and the true relative error in Eqs. (1.16) and (1.17)
cannot actually be determined in problems that require numerical meth-
6
--
-
sin
E
TR
6
--
-
sin
6
--
- 0.5235988
= = E
TR
0.5 0.5235988
– 0.0235988
–
= =
6
--
-
sin
6
--
-
6
3
3!
----------------
-
– 0.4996742
= = E
TR
0.5 0.4996742
– 0.0003258
= =
f x
x1
df x
dx
-------------
-
x x1
=
f x2
f x1
–
x2 x1
–
---------------------------------
-
=
x2 x1
TrueError TrueSolution NumericalSolution
–
=
TrueRelativeError TrueSolution NumericalSolution
–
TrueSolution
-------------------------------------------------------------------------------------------
-
=
34. 1.4 Computers and Programming 15
ods for their solution since the true solution is not known. These error
quantities can be useful for evaluating the accuracy of different numeri-
cal methods. This is done by using the numerical method for solving
problems that can be solved analytically and evaluating the true errors.
Since the true errors cannot, in most cases, be calculated, other
means are used for estimating the accuracy of a numerical solution.
This depends on the specific method and is discussed in more detail in
later chapters. In some methods the numerical error can be bounded,
while in others an estimate of the order of magnitude of the error is
determined. In practical applications, numerical solutions can also be
compared to experimental results, but it is important to remember that
experimental data have errors and uncertainties as well.
1.4 COMPUTERS AND PROGRAMMING
As mentioned earlier in Section 1.1, the fundamentals of numerical
methods for solving mathematical problems that cannot be solved ana-
lytically were developed and used many years ago. The introduction of
modern digital computers provided a means for applying these methods
more accurately, and to problems requiring a large number of repetitive
calculations. A computer can store a large quantity of numbers and can
execute mathematical operations with these numbers very quickly. To
carry out the calculations required for implementing a specific numeri-
cal method, the computer has to be provided with a set of instructions,
called a computer program. Since binary format is used in the mathe-
matical operations and for storing numbers, the instructions have to be
in this form, and require the use of what is called machine language. In
the early days of computers, computer programs were written in low-
level computer languages (a language called assembler). Programming
in this way was tedious and prone to errors because it had to be very
detailed, and it was done in a form much different from the form used in
everyday mathematics.
Later on, operating systems were introduced. Operating systems
may be viewed as interfaces or layers enabling easier contact and com-
munication between human users and the machine language of the com-
puter. The instructions written in the language of the operating system
are converted by the system to machine language commands that are
executed by the computer. Examples of operating systems are Unix
(written in the programming language called C), developed by Bell
Laboratories in the 1970s, and DOS (Disk Operating System), used by
Microsoft Inc. Although operating systems simplify communication
with the computer, they are still relatively difficult to use, require long
codes, and are not written for the special needs of engineers and scien-
tists.
Computer programs used by scientists and engineers are often writ-
ten in programming languages that operate on top of the operating sys-
35. 16 Chapter 1 Introduction
tem. These higher-level computer languages are easier to use and
enable the engineer or scientist to concentrate on problem solving rather
than on tedious programming. Computer languages that are often used
in science and engineering are Fortran, C, and C++. In general, for the
same task, computer programs that are written in high-level computer
languages are shorter (require less commands) than programs written in
lower-level languages. This book uses MATLAB, which is a high-level
language for technical computing. For example, multiplication of two
matrices in MATLAB is denoted by the regular multiplication opera-
tion, while other languages require the writing of a loop with several
lines of code.
Algorithm
When a computer is used for obtaining a numerical solution to a prob-
lem, the program carries out the operations associated with the specific
numerical method that is used. Some of the numerical methods are sim-
ple to implement, but sometimes the numerical procedures are compli-
cated and difficult to program.
Before a numerical method is programmed, it is helpful to plan out
all the steps that have to be followed in order to implement the numeri-
cal method successfully. Such a plan is called an algorithm, which is
defined as step-by-step instructions on how to carry out the solution.
Algorithms can be written in various levels of detail. Since the focus of
this book is on numerical methods, the term algorithm is used here only
in the context of instructions for implementing the numerical methods.
As a simple example, consider an algorithm for the solution of the
quadratic equation:
(1.18)
for which the solution in the case of real roots is given by the quadratic
formula:
(1.19)
Algorithm for solving for the real roots of a quadratic equation
Given are the three constants of the quadratic equation a, b, and c.
1. Calculate the value of the discriminant .
2. If , calculate the two roots using Eq. (1.19).
3. If , calculate the root , and display the message:
“The equation has a single root.”
4. If , display the message: “The equation has no real roots.”
Once the algorithm is devised, it can be implemented in a computer
program.
ax2 bx c
+ + 0
=
x1
b
– b
2
4ac
–
+
2a
--------------------------------------
= x2
b
– b
2
4ac
–
–
2a
-------------------------------------
-
=
D b
2
4ac
–
=
D 0
D 0
= x
b
–
2a
-----
-
=
D 0
36. 1.4 Computers and Programming 17
Computer programs
A computer program (code) is a set (list) of commands (operations) that
are to be executed by the computer. Different programming languages
use different syntax for the commands, but, in general, commands can
be grouped into several categories:
• Commands for input and output of data. These commands are used
for importing data into the computer, displaying on the monitor, or
storing numerical results in files.
• Commands for defining variables.
• Commands that execute mathematical operations. These include the
standard operations (addition, multiplication, power, etc.) and com-
mands that calculate values of commonly used functions (trigono-
metric, exponential, logarithmic, etc.).
• Commands that control the order in which commands are executed
and enable the computer to choose different groups of commands to
be executed under different circumstances. These commands are
typically associated with conditional statements that provide the
means for making decisions as to which commands to execute in
which order. Many languages have “if-else” commands for this pur-
pose, but many other commands for this purpose exist.
• Commands that enable the computer to repeat sections of the pro-
gram. In many languages these are called loops. These commands
are very useful in the programming of numerical methods, since
many methods use iterations for obtaining accurate solutions.
• Commands that create figures and graphical displays of the results.
A computer program can be written as one long list of commands,
but typically it is divided into smaller well-defined parts (subprograms).
The parts are self-contained programs that perform part of the overall
operations that have to be carried out. With this approach the various
parts can be written and tested independently. In many computer lan-
guages, the subprograms are called subroutines and functions.
As already mentioned, in this book numerical methods are imple-
mented by using MATLAB, which is a relatively new language for
technical computing. MATLAB is powerful and easy to use. It includes
many built-in functions that are very useful for solving problems in sci-
ence and engineering.
It is assumed that the reader of this book has at least some knowl-
edge of MATLAB and programming. For those who do not, an intro-
duction to MATLAB is presented in the appendix. It includes a section
on conditional statements and loops, which are the basic building
blocks of programming. For a more comprehensive introduction to pro-
gramming, the reader is referred to books on computer programming.
To help the reader follow the MATLAB programs listed in this book,
comments and explanations are posted next to the program listings.
37. 18 Chapter 1 Introduction
1.5 PROBLEMS
Problems to be solved by hand
Solve the following problems by hand. When needed, use a calculator or write a MATLAB script file to
carry out the calculations.
1.1 Convert the binary number 1010100 to decimal format.
1.2 Convert the binary number 1101.001 to decimal format.
1.3 Convert the binary number 10110001110001.01010111 to decimal format.
1.4 Write the number 45.0 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
1.5 Write the number 66.25 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
1.6 Write the number -0.625 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
1.7 Write the number 0.06298828125 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 32-bit single-precision string.
1.8 Write the number 38.8125 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
1.9 Write the number –30952.0 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
1.10 Write the number 0.197265625 in the following forms (in part (c), follow the IEEE-754 standard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
1.11 Write the number 0.001220703125 in the following forms (in part (c), follow the IEEE-754 stan-
dard):
(a) Binary form. (b) Base 2 floating point representation. (c) 64-bit double-precision string.
1.12 In single precision (IEEE-754 standard), 8 bits are used for storing the exponent (the bias is 127),
and 23 bits are used for storing the mantissa.
(a) What are the smallest and the largest positive numbers that can be stored in single precision?
(b) What is the smallest value of the mantissa that can be stored?
1.13 Suppose a new standard, the IDDD-643 standard, is developed for storing numbers in a string of 16
bits. The first bit is used for the sign of the number (0 if positive and 1 if negative). The next five bits store
the exponent plus the bias, and the remaining 10 bits store the mantissa. The bias is 15 and no bits are
reserved for any special purposes. What is the smallest exponent that can be stored?
38. 1.5 Problems 19
1.14 Write the number 581 in the 16-bit IDDD-643 standard that was introduced in Problem 1.13.
1.15 Write the number 256.1875 in the 16-bit IDDD-643 standard that was introduced in Problem 1.13.
Apply chopping if necessary.
1.16 What is the number that is actually stored in Problem 1.15? What is the round-off error?
1.17 Write the number 0.2 in binary form with sufficient number of digits so that the true relative error is
less than 0.01.
1.18 Consider the function .
(a) Use the decimal format with six significant digits (apply rounding at each step) to calculate (using a
calculator) for .
(b) Use MATLAB (format long) to calculate the value of . Consider this to be the true value, and
calculate the true relative error, due to rounding, in the value of that was obtained in part (a).
(c) Multiply by to obtain a form of that is less prone to rounding errors. With the
new form, use the decimal format with six significant digits (apply rounding at each step) to calculate
(using a calculator) for . Compare the value with the values in parts (a) and (b).
1.19 Consider the function .
(a) Use the decimal format with six significant digits (apply rounding at each step) to calculate (using a
calculator) for .
(b) Use MATLAB (format long) to calculate the value of . Consider this to be the true value, and
calculate the true relative error due to rounding in the value of that was obtained in part (a).
(c) Multiply by to obtain a form of that is less prone to rounding errors. With the
new form, use the decimal format with six significant digits (apply rounding at each step) to calculate
(using a calculator) for . Compare the value with the values in parts (a) and (b).
1.20 Consider the function .
(a) Use the decimal format with five significant digits (apply rounding) to calculate (using a calculator)
for .
(b) Use MATLAB (format long) to calculate the value of . Consider this to be the true value, and
calculate the true relative error due to rounding in the value of that was obtained in part (a).
1.21 The Taylor series expansion of is given by:
(1.20)
Use the first three terms in Eq. (1.20) to calculate the value of . Use the decimal format with six
significant digits (apply rounding at each step). Calculate the truncation error.
f x
1 x
cos
–
x
sin
------------------------
-
=
f x
x 0.007
=
f x
f x
f x
1 x
cos
+
1 x
cos
+
-------------------------
- f x
f x
x 0.007
=
f x
4 x
+ 2
–
x
------------------------
-
=
f x
x 0.001
=
f x
f x
f x
4 x
+ 2
+
4 x
+ 2
+
------------------------- f x
f x
x 0.001
=
f x
ex 1
–
x
-------------
=
f x
x 0.005
=
f x
f x
x
cos
x
cos 1
x2
2!
----
-
–
x4
4!
----
-
x6
6!
----
-
–
x8
8!
----
-
x10
10!
-------
-
–
+ + +
=
4
cos
39. 20 Chapter 1 Introduction
1.22 Taylor series expansion of the function is:
(1.21)
Use Eq. (1.21) to calculate the value of for the following cases. Use decimal numbers with six signifi-
cant numbers (apply rounding at each step). In each case calculate also the true relative error. Use MAT-
LAB with format long to calculate the true value of .
(a) Use the first four terms. (b) Use the first six terms. (c) Use the first eight terms.
1.23 Use the first seven terms in Eq. (1.21) to calculate an estimated value of e. Do the calculation with
MATLAB (use format long to display the numbers). Determine the true relative error. For the exact
value of e, use exp(1)in MATLAB.
1.24 Develop an algorithm to determine whether or not a given integer is a prime number. Recall that a
prime number is an integer larger than 1 and which is divisible only by itself and by 1.
1.25 Develop an algorithm for adding all prime numbers between 0 and a given number.
1.26 Develop an algorithm for converting integers given in decimal form to binary form.
1.27 Develop an algorithm to implement the IDDD-643 standard introduced in Problem 1.13 to store any
base 10 decimal number in binary form. Apply chopping, if necessary.
1.28 Develop an algorithm to implement the IDDD-643 standard introduced in Problem 1.13 to store any
base 10 decimal number in binary form. Apply rounding down.
1.29 Develop an algorithm to implement the IDDD-643 standard introduced in Problem 1.13 to store any
base 10 decimal number in binary form. Apply rounding up.
1.30 Develop an algorithm to add two integers expressed in binary form. The rules for adding binary
numbers are: , , , and carry 1. For example, is:
1.31 Suppose chopping is used to store the number 84.48 in the IDDD-643 standard of problem 1.13.
What is the number actually stored in binary form? What is the equivalent decimal number that is stored?
What is the absolute error?
Problems to be programmed in MATLAB
Solve the following problems using the MATLAB environment. Do not use MATLAB’s built-in functions for
changing the form of numbers.
1.32 Write a MATLAB program in a script file that determines whether or not a given integer is a prime
number by implementing the algorithm developed in Problem 1.24. The program should start by assigning
f x
ex
=
f x
ex 1 x
x2
2!
----
-
x3
3!
----
-
x4
4!
----
-
x5
5!
----
-
+ + + + + +
= =
e 2
–
e 2
–
0 0 0
+ 0 1 1
+ 1 0 1
+ 1 1 0
+ 5 12
+
1 1
0 0 1 0 1
0 1 1 0 0
1 0 0 0 1
+
(carried digits)
40. 1.5 Problems 21
a value to a variable x. When the program is executed, a message should be displayed that states whether
or not the value assigned to x is a prime number. Execute the program with , , and
.
1.33 Write a user-defined MATLAB function that adds all prime numbers between 0 and a given number
by implementing the algorithm developed in Problem 1.25. Name the function sp = sumprime(int),
where the input argument int is a number larger than 1, and the output argument sp is the sum of all the
prime numbers that are smaller than int. Use the function to calculate the sum of all the prime numbers
between 0 and 30.
1.34 Write a user-defined MATLAB function that converts integers written in binary form to decimal
form. Name the function d = binaTOint(b), where the input argument b is a vector with 1s and 0s that
represents the binary number to be converted and the output argument d is a number in decimal form. The
largest number that could be converted with the function should be a binary number with 20 1s. If a larger
number is entered for b, the function should display an error message. Use the function to convert the fol-
lowing numbers:
(a) 11010. (b) 10101100111. (c) 11100110001110101.
1.35 Write a user-defined MATLAB function that converts integers written in decimal form to binary
form. Name the function b = intTObina(d), where the input argument d is the integer to be converted
and the output argument b is a vector with 1s and 0s that represents the number in binary form. The largest
number that could be converted with the function should be a binary number with 20 1s. If a larger number
is entered as d, the function should display an error message. Use the function to convert the following
numbers:
(a) 81. (b) 30952. (c) 1500000.
1.36 Write a user-defined MATLAB function that converts real numbers in decimal form to binary form.
Name the function b = deciTObina(d), where the input argument d is the number to be converted and
the output argument b is a 30-element-long vector with 1s and 0s that represents the number in binary
form. The first 15 elements of b store the digits to the left of the decimal point, and the last 15 elements of
b store the digits to the right of the decimal point. If more than 15 positions are required in the binary form
for the digits to the right of the decimal point, the digits should be chopped. If the number that is entered as
d is larger than can be stored in b, the function should display an error message. Use the deciTObina in
the Command Window to convert the numbers 85.321, 0.00671, and 3006.42.
1.37 Write a user-defined MATLAB function that adds two integers in binary form according to the algo-
rithm of Problem 1.30. Name the function aplusb = addbin(a,b), where the input arguments a and b
are the numbers to be added in binary form (vectors with 1s and 0s that represent the binary numbers), and
the output argument aplusb is the result in binary form (a vector with 1s and 0s that represent the binary
number). The largest numbers that could be added with the function should be binary numbers with 15 1s.
Use the function in the Command Window to add 100111011 and 1100110.
1.38 Write a user-defined MATLAB function that adds two integers in decimal form. Name the function
c = adddec(a,b), where the input arguments a and b are the numbers to be added in decimal form, and
the output argument c is the result in decimal form. The addition is done in the following way: First, the
x 79
= x 126
=
x 367
=
41. 22 Chapter 1 Introduction
numbers a and b are converted to binary form by using the user-defined function intTObina written in
Problem 1.35. Then, the converted two numbers are added using the user-defined function addbin writ-
ten in Problem 1.37. Finally, the result is converted to decimal form by using the user-defined function
binaTOint written in Problem 1.34. The three user-defined functions intTObina, addbin, and
binaTOint can be written as subfunctions inside adddec. The numbers that are being added with the
function cannot be larger than 65,535 each. If a larger number is entered, an error message is displayed.
Use the function in the Command Window to add 60,000 and 12,087.
1.39 Write a user-defined MATLAB function that implements the IDDD-643 standard of problem 1.13.
Name the function n = iddd643(num), where the input argument num is any real number, and the out-
put argument n is a 16-element-long vector with 1s and 0s. Use chopping if necessary. Use iddd643 for
determining n for the following numbers:
(a) 81. (b) 256.1875.
1.40 Write a user-defined MATLAB function that determines the binary floating point representation of a
number written in decimal form. Name the function b = decTObinfloat(num), where the input argu-
ment num is a real number, and the output argument b is a two-element vector in which the first element is
the mantissa and the second element is the value of the exponent. Use the function to determine the binary
floating point representation of 55.6, 2143.75, and 0.00843.
1.41 The value of can be calculated with the series:
(1.22)
Write a MATLAB program in a script file that calculates the value of by using n terms of the series and
calculates the corresponding true relative error. (For the true value of , use the predefined MATLAB vari-
able pi.) Use the program to calculate and the true relative error for:
(a) . (b) . (c) .
1.42 The Taylor’s series expansion for is:
where x is in radians. Write a user-defined function that determines using Taylor’s series expansion.
For function name and arguments, use y=sinTaylor(x), where the input argument x is the angle in
degrees and the output argument y is the value for . Inside the user-defined function, use a loop for
adding the terms of the Taylor’s series. If is the nth term in the series, then the sum of the n terms is
. In each pass, calculate the estimated error E given by . Stop adding terms
when . Use sinTaylor for calculating:
(a) . (b) .
Compare the values calculated using sinTaylor with the values obtained by using MATLAB’s built-in
sind function.
4 1
–
n 1
– 1
2n 1
–
--------------
-
n 1
=
4 1
1
3
--
-
–
1
5
--
-
1
7
--
-
–
1
9
--
-
1
11
-----
-
–
+ + +
= =
n 10
= n 20
= n 40
=
x
sin
x
sin x
x3
3!
----
-
–
x5
5!
----
-
x7
7!
----
-
–
+ +
1
–
n
2n 1
+
!
---------------------
-x
2n 1
+
n 0
=
= =
x
sin
x
sin
an Sn
Sn Sn 1
– an
+
= E
Sn Sn 1
–
–
Sn 1
–
----------------------
-
=
E 0.000001
65
sin 195
sin
43. Fraudis versutias ‖ compellor experiri,
per quas nequitia ‖ vestra solet mentiri.
Sub forma veritas ‖ virtutis putabatur;
ostendit falsitas, ‖ quod forma mentiatur.
Per vos corrupta est ‖ fides Christianorum.
per me conteretur ‖ regnum simulatorum.
Plena sunt fraudibus ‖ munera deceptoris.
iniquus corruet ‖ per gladium ultoris.
Secum pecunia ‖ sit in perditionem, 10
gravem iniuria ‖ exspectat ultionem.
Tunc ypocritæ confusi redeunt et stantes coram Antichristo
c(antant):
O regni gloria ‖ caput totius mundi,
offensam aspice ‖ populi furibundi.
Certe predictum est ‖ per fidem antiquorum,
quod tu subities ‖ cervices superborum.
Si virtute tua ‖ totus orbis subsistit,
qua vi teotonicus ‖ furor tibi resistit?
Tuam Germania ‖ blasphemat dicionem,
extollit cornua ‖ contra religionem. 20
Respice igitur ‖ nostram confusionem,
in ea iudica ‖ tuam offensionem.
Tuam potentiam ‖ iniuria testatur,
cuius imperio ‖ ruinam comminatur.
Tunc Antichristus:
Consummabo uere ‖ gentem perditionis
pro tanto scandalo ‖ sanctæ religionis.
Ecce superbiam ‖ humanæ potestatis
teret potentia ‖ divinæ maiestatis.
44. {30} Tunc dirigit singulos nuntios ad reges dicens eis:
Ite congregantes ‖ facultates regnorum.
conculcent impetu ‖ furorem superborum.
Nuntii vero venientes coram regibus c(antant):
Ecce noster dominus ‖ et deus deorum
per nos exercitum ‖ convocavit suorum.
Ut per hos teotonicum ‖ condempnet furorem,
in bello martyrum ‖ consignabit cruorem.
Tunc reges conveniunt ante tronum Antichristi. Quibus ille:
Consummabo vere et c.
Ite Germaniæ ‖ terminos invadetis,
superbum populum ‖ cum rege conteretis.
Tunc omnes cantant:
Deus nobiscum est, ‖ quos tuetur potenter.
Pro fide igitur ‖ pugnemus confidenter.
{10} Et disponentes acies suas in occursum Teotonicorum
congrediuntur cum eis et superatur exercitus Antichristi. Tunc rex
Teotonicorum rediens et sedens in trono suo cantat:
Sanguine patriæ ‖ honor est retinendus,
Virtute patriæ ‖ est hostis expellendus.
Ius dolo perditum ‖ est sanguine venale.
sic retinebimus ‖ decus imperiale.
45. Tunc ypocritæ adducunt claudum coram Antichristo, quo sanato
rex Teotonicorum hesitabit in fide. Tunc iterum adducunt leprosum,
et illo sanato rex plus dubitabit. Ad ultimum important {20} feretrum,
in quo iacebit quidam simulans se in prelio occisum. Iubet itaque
Antichristus ut surgat dicens:
Signa semper querunt ‖ rudes et infideles.
surge velociter, ‖ quis sim ego reveles.
Tunc ille de feretro cantat:
Tu sapientia ‖ supernæ veritatis
virtus invicta es ‖ divinæ maiestatis.
Et ypocritæ secum c(antant):
Tu sapientia et c.
Tunc rex Teotonicorum videns signum seducitur dicens:
Nostro nos impetu ‖ semper periclitamur, 30
adversus dominum ‖ incauti preliamur.
In huius nomine ‖ mortui suscitantur
et claudi ambulant ‖ et leprosi mundantur.
Illius igitur ‖ gloriam veneremur
46. FRAU WELT.
HIMMEL UND HÖLLE.
[Scherer D. 87, E. 78.]
Aus einer Bamberger Handschrift des elften Jahrhunderts in der Königl.
Bibliothek zu München. Von einem Geistlichen verfasst, in vier mal
gehobenen Versen ohne Alliteration und Reim, wie sonst nur das
angelsächsische Ormulum. Herausgegeben in den Denkmälern Nr. 30.
47. In dero hello
dâ ist dôt âne tôt,
karôt unde jâmer,
al unfrouwida,
mandunge bresto,
beches gerouche,
der sterkiste svevelstank,
verwâzzenlîch genibile,
des tôdes scategruoba,
alles truobisales waga, 10
der verswelehente loug,
die wallenten stredema
viurîner dunste,
egilîch vinster,
diu iemêr êwente brunst,
diu vreissamen dôtbant,
diu betwungeniste phragina,
claga, wuoft âne trôst,
wê âne wolun,
wîzze âne restî 20
aller wênigheite nôt,
diu hertiste râcha,
der handegôste ursuoch,
daz sêrigẹ elelentduom,
aller bittere meist,
kâla âne vriste,
ungenâdône vlîz,
uppigiu riuwa,
karelîch gedôzze,
weinleiches ahhizôt,
alles unlustes
zâlsam gesturme,
forhtône bîba,
zano klaffunga,
aller wêskreio meist,
ê
48. diu iemêr werentẹ angest, 10
aller skandigelîch,
daz scamilîchestẹ offen
aller tougenheite,
leides unende
und aller wêwigelîch,
marter unerrahlîch
mit allem unheile,
diu wêwiglîche haranskara,
verdamnunga swereden
âne alle erbarmida, 20
iteniuwiu sêr
âne guot gedinge,
unverwandellîch ubel,
alles guotes âteil,
diu grimmigiste heriscaft,
diu vîantliche sigenunft,
griulîch gesemine,
der vûlidạ unsûbrigheit
mit allem unscône,
diu tiuvallîche anesiht, 30
aller egisigilîch,
alles bales unmez,
diu leitlîche heima,
der helle karkâre,
daz rîchiste trisehûs
alles unwunnes,
der hizze abgrunde,
unbigebenlîch flor,
der tiuvalo tobeheit,
der ursinniglîche zorn
und aller ubelwillo,
der ist dâ verlâzen
in aller âhtunga vlîz
und in alla tarahaftî
dero hella erbon, 10
â î
50. In der Hölle
Ist Tod ohne Tod,
Wehklage und Jammer,
Eitel Freudlosigkeit,
Der Seligkeit Abbruch,
Peches Rauchen,
Der stärkste Schwefelgestank,
Verfluchtes Nebelgewölk,
Des Todes Schattengrube,
Aller Trübsal Wiege, 10
Die verschlingende Lohe,
Die wallenden Strudel
Feuriger Dünste,
Entsetzliche Finsterniss,
Die ewigwährende Feuersbrunst,
Die furchtbaren Todesbande,
Die bekümmertste Drangsal,
Klage, Jammern ohne Trost,
Weh ohne Linderung,
Peinigung ohne Rast 20
Aller Kümmerniss Noth,
Die härteste Vergeltung,
Das schärfste Verhör,
Das schmerzliche Elend,
Die Summe aller Bitterniss,
Qual ohne Ende,
Der Ungnade Eifern,
Wuchernde Reue,
Trauriges Getöse,
Klageliedes Ächzen,
Aller Unlust
Gefahrvoll Getümmel,
Das Beben der Furcht,
Zähne Klappen,
Das durchdringendste Wehgeschrei,
51. Die immerwährende Angst, 10
Schmach und Schande,
Die beschämendste Offenbarung
Aller Geheimnisse,
Leides Unendlichkeit
Und jegliches Wehes,
Zahllose Marter
Mit allem Unheil,
Die schmerzliche Peinigung,
Der Verdammniss Qualen
Ohn all Erbarmen, 20
Unerhörte (ganz neue) Schmerzen
Ohne gute Hoffnung,
Unwandelbares Übel,
Alles Guten Untheilhaftigkeit,
Die grimmigste Herrschaft,
Der feindliche Sieg
Gräuliche Versammlung,
Der Fäulniss Unsauberkeit
Mit allem Unschönen,
Der teuflische Anblick 30
Aller Schrecknisse,
Alles Bösen Übermass,
Die leidvolle Heimat,
Der Hölle Kerker,
Das reichste Schatzhaus
Aller Unwonne,
Der Hitze Abgrund,
Unablässiges Verderben,
Der Teufel Toben,
Der unsinnige Zorn
Und jedes Übelwollen,
Das ist da losgelassen
Auf eifernde Verfolgung
Und zu jeder Schädigung
Der Hölle Erben, 10
53. DIE WIENER GENESIS.
[Scherer D. 82, E. 74.]
Enthält mehrere Stücke, die vermuthlich an Stelle von Predigten zum
Vorlesen bestimmt waren und zum Theil noch aus dem elften Jahrhundert
herrühren. Scherer unterscheidet sechs verschiedene Verfasser.
Herausgegeben von Graff ‘Diutisca’ III (1829); Hoffmann ‘Fundgruben II’
(1837); Massmann ‘Deutsche Gedichte des zwölften Jahrhunderts’ (1837).
54. Dô diu vrouwa Sâra
gelebete hundert jouch siben und zueinzich jâre,
dise werlt si begab.
Abrahâm choufte ir ein grab,
und bevalech si scône
mit stanch aller bîmentône. 20
vile harte er si chlagete:
ze lezzist er gedagite.
do begunde er sich trôsten:
waz mahte er dô bezzeres tuon?
sô tuot unser igelîch
sô ime gescihet samelîch.
Dô iz zuo diu cham,
daz Ysaac scolte gehîwan,
sîn vater Abrahâm
eiskôte sînen amman:
den hiez er suerigen,
sô in got muose nerigen,
daz er der liute,
dâ er under bûte,
niemmer wib ne gewunne
Ysaac sîneme chinde: 10
er hiez in dar varen,
dannen er geborn was,
zuo sines bruoder hûs Nachor,
daz ime Batuel gâbe sîne tohter,
die scônen Rebeccen,
Ysaac ze gebetten.
[Der scalch sprach] obe man ime ire niene gâbe,
waz er des mahte?
er ne scolte ouch sich des pelgen,
ob si ime ne wolte volgen. 20
[Abrahâm chod] ‘des eides sîs dû ledich,
ob dir ne volge diu magit.’
In deme ente
ô
55. luoder zewô olbenten
mit mislîchen dingen
der magide ze minnen.
alsô er dare cham,
er irbeizta bi einem brunnan.
dô der âbant zuo seich,
daz fihe man ze trenche treib. 30
er stuont bette
daz in got gewerte
daz er ime daz wîb erougte
diu sîneme hêrren scolte.
[Er chot] ‘nû wil ich haben ze zeichen
welihe got mir eiche,
suelehe maged ich pitte
daz si mir des wazzeres scepphe,
ob mir got verlîhit,
daz si mir des nieht verzîhet,
si ne heizze mich selben trinchen 10
jouch mîne olbenten:
diu scol mîneme hêrren
ze minnen jouch ze êren.’
Bi daz er daz gebet nider lie,
diu scône Rebecca zuo gie,
und manech maged anderiu,
der ire gelîch was neheiniu.
Er sprach ire zuo:
‘wande ne trenchest dû mich, vrouwa?’
ime selben si scanchte, 20
sîn olbenten si ouch tranchte.
got er gnâdôte
daz er in sô sciere erhôrte.
Er gab ir ze minnen
zuêne ôringe
und zuêne armpouge
ûz alrôteme golde,
und frâgete si sâre
â
56. wes tohter si wâre.
Si sprach, Abrahâm 30
wâre ir vater ôheim.
si bat in ze hûs,
sprah, dâ wâre vile houwes:
dâ mahten geste
haben guote reste.
Nieht si ne tualte
ê si ir vater al gezalte.
si begunde zeigan
ire bruoder Lâban
bouge unde ôringe
die si enphie von deme jungelinge.
er liuf dar sciere,
sprach, wand er ze hûs ne vuore? 10
Dô er dare cham,
dô ward er wole inphangan.
vile wole si in handelôten,
maniges si in vrâgôten,
nâh allem niumâre,
waz sîn gewerf wâre.
[Er chot] sîn hêrre hête in dare gesant
umb einen michelen ârant,
sîneme junchêrren umb ein wîb
diu guot wâre und êrlîch, 20
die scônen Rebeccen
deme hêrren Ysaac ze gebetten.
Sînen hêrren er lobete
waz er rîhtuomes habete,
fihis unde scatzes
manichvaltes nutzes;
und wie wole ire gescâhe
ob si in gnâme.
ob si iz wolten tuon,
daz si in des liezzen spuon:
ob si des ne wolten,
57. daz si in niene tualten.
Si sprâchen daz si gotes willen
niene wolten stillen:
‘hie ist unser tohter
ân aller slahte laster:
suie sciere dir gevalle,
var heim mit alle.’
Er wart vil vrô 10
solicher antwurtô.
silberîne napphe,
guldîne chopphe,
vile guot gewâte
ze chemenâten er brâhte:
er gébete zêriste
der junchvrouwen aller bezzeste;
deme vater und dere muoter
jouch ir bruoder.
Guot wâren die gebe, 20
wol geviel sîn rede.
si sâzen ze muose
mit vrôlîcheme gechôse.
dâ was spil unde wunne
under wîben unde manne.
vone benche ze benche
hiez man allûteren wîn scenchen;
si spilten unde trunchan
unz in iz der slâf binam.
Alsô der tach cham, 30
ûf was der Ysaachis man:
des urloubes er bat,
daz ime nieman ne gab:
si bâten daz er dâ wâre
zehen tage fristmâle.
daz dûhte in ze lenge:
[er chot] ze wiu si in scolten tuellen?
er bat sich lâzzen,
î ê
58. daz is sînen hêrren ieht dorfte irdrizzen.
Do si sînen ernist gesâhen,
die maged si frâgeten,
obe si ime wolte volgen 10
zuo eigenen seliden.
si sprach gerne vuore
suâ ire ieht guotes gescâhe.
Ze stete si ime se gâben
mit scônen mageden;
si gâben ir mite ir ammen,
daz si der daneverte deste min mahte erlangen.
Ze rosse si giengen,
mit âmare si scieden.
vater unde muoter 20
jouch ire bruoder,
si bâten unseren trehtîn
daz si sâlich muose sîn
ze tûsent tûsent jâren,
und alle die von ire châmen.
Isaac was ûz gegangen
zuo einem brunnen,
daz er ouch sâhe
waz tâten sîne snitâre.
Also iz zuo deme âbande seig, 30
sîn man mit dere junchvrouwen zuo reit.
Der hêrre ire gegen gie,
vil wole er si enphie.
er vie sie behende,
er gie mit ire spilende
uber daz scône velt:
er leite sie in sîn gezelt.
59. Als die Frau Sara
hundert und sieben und zwanzig Jahr gelebt hatte,
verliess sie diese Welt.
Abraham kaufte ihr ein Grab,
und bestattete sie schön
mit Weihrauch von allen Specereien. 20
er betrauerte sie gar sehr;
zuletzt schwieg er.
Da begann er sich zu trösten:
was konnte er da Besseres thun?
so thut ein jeglicher von uns,
wenn ihm Ähnliches geschieht.
Da es dazu kam,
dass Isaac heirathen sollte,
da heischte sein Vater
Abraham seinen Diener:
den hiess er schwören,
so ihn Gott erhalten müsse,
dass er von den Leuten,
darunter er wohnte,
nimmer ein Weib gewinne
für sein Kind Isaac. 10
Er hiess ihn dahin reisen,
von wo er geboren war,
zu seines Bruders Hause, Nachor,
dass ihm Batuel seine Tochter gäbe,
die schöne Rebecca,
Isaac zur Frau.
Der Diener sprach: Wenn man ihm sie nicht gäbe,
was er da machte?
Er sollte auch sich nicht darob erzürnen,
wenn sie ihm nicht folgen wollte. 20
Abraham sprach: Des Eides seiest du ledig,
wenn dir das Mädchen nicht folgt.
Zu diesem Zwecke
60. Belud er zwei Kameele
mit mannigfachen Dingen
dem Mädchen zur Liebe.
Als er dahin kam,
rastete er bei einem Brunnen.
Da der Abend sich senkte,
trieb man das Vieh zur Tränke. 30
Er begann zu beten,
dass ihm Gott gewährte,
dass er ihm das Weib zeige,
die für seinen Herrn sollte.
Er sprach: ‘Nun will ich zum Zeichen haben,
die mir Gott zueigne:
welches Mädchen ich bitte,
dass sie mir Wasser schöpfe,
so mir Gott verleihet
dass sie mir das nicht versagt,
mich selbst trinken heisse 10
und auch meine Kameele,
die soll meinem Herrn
zu Liebe und zu Ehren sein,’
Als er das Gebet beendigte,
kam die schöne Rebecca herzu,
und manche andere Mädchen,
von denen ihr keine gleich war.
Er sprach ihr zu:
Warum giebst du mir nicht zu trinken, Frau?
Sie schenkte ihm selber, 20
sie tränkte auch seine Kameele.
Er dankte Gott,
dass er ihn so schnell erhörte.
Er gab ihr aus Liebe
zwei Ohrringe
und zwei Armspangen
aus ganz rothem Golde
und fragte sie sogleich,
61. wes Tochter sie wäre.
Sie sprach, Abraham 30
wäre ihres Vaters Oheim.
Sie bat ihn nach Hause,
sprach, da wäre viel Heu:
da könnten Gäste
gute Rast haben.
Sie rastete nicht,
ehe sie ihrem Vater Alles erzählte.
Sie begann zu zeigen
ihrem Bruder Laban
die Spangen und Ohrringe,
die sie von dem Jüngling empfieng.
Er lief dahin schnell,
sprach, warum er nicht nach Hause käme? 10
Da er dahin kam,
da ward er wohl empfangen,
sie behandelten ihn sehr gut,
fragten ihn manches,
nach jeder Neuigkeit,
was sein Geschäft wäre.
Er sprach, sein Herr hätte ihn daher gesandt
wegen eines grossen Anliegens (errand)
wegen einer Frau für seinen jungen Herrn,
die gut wäre und ehrsam, 20
nämlich wegen der schönen Rebecca,
für den Herrn Isaac zur Gemahlin.
Er lobte seinen Herrn,
wie viel er Reichthum hätte,
an Vieh und Schätzen
mannigfachen Nutzens,
und wie wohl ihr geschähe,
wenn sie ihn nähme.
Wenn sie es thun wollten,
so sollten sie ihn das schnell thun lassen;
wenn sie es nicht wollten,
62. so sollten sie ihn nicht verzögern,
Sie sprachen, sie wollten Gottes Willen
nicht aufhalten:
hier ist unsre Tochter
ohne irgend welchen Tadel:
wie schnell es dir gefällt,
so fahre heim mit ihr.
Er ward sehr froh 10
über solche Antwort.
Silberne Schalen,
goldene Becher,
viel gute Gewänder
brachte er zur Kammer;
er gab zuerst
der Jungfrau das Allerbeste
dem Vater und der Mutter
und auch ihrem Bruder.
Gut waren die Gaben, 20
wohl gefiel seine Rede.
sie sassen zum Mahle
mit fröhlichem Gekose.
Da gab es Spiel und Freude
unter Frauen und Männern.
Von Tische zu Tische
liess man lauteren Wein schenken;
sie spielten und tranken,
bis der Schlaf es ihnen benahm.
Als der Tag kam, 30
auf war da der Diener Isaacs;
er bat um Urlaub,
den ihm aber Niemand gab:
sie baten ihn, das er da bliebe
zehn Tage Zeit.
Das däuchte ihm zu lange:
er sprach, wozu sie ihn verzögern wollten?
er bat, dass sie ihn entliessen,