SlideShare a Scribd company logo
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
COMPUTER-BASED
NUMERICAL & STATISTICAL
TECHNIQUES
LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY
The CD-ROM that accompanies this book may only be used on a single PC. This license
does not permit its use on the Internet or on a network (of any kind). By purchasing or
using this book/CD-ROM package(the “Work”), you agree that this license grants
permission to use the products contained herein, but does not give you the right of
ownership to any of the textual content in the book or ownership to any of the
information or products contained on the CD-ROM. Use of third party software
contained herein is limited to and subject to licensing terms for the respective products,
and permission must be obtained from the publisher or the owner of the software in
order to reproduce or network any portion of the textual material or software (in any
media) that is contained in the Work.
INFINITY SCIENCE PRESS LLC (“ISP” or “the Publisher”) and anyone involved in the
creation, writing or production of the accompanying algorithms, code, or computer
programs (“the software”) or any of the third party software contained on the CD-ROM
or any of the textual material in the book, cannot and do not warrant the performance or
results that might be obtained by using the software or contents of the book. The authors,
developers, and the publisher have used their best efforts to insure the accuracy and
functionality of the textual material and programs contained in this package; we,
however, make no warranty of any kind, express or implied, regarding the performance
of these contents or programs. The Work is sold “as is” without warranty (except for
defective materials used in manufacturing the disc or due to faulty workmanship);
The authors, developers, and the publisher of any third party software, and anyone
involved in the composition, production, and manufacturing of this work will not be
liable for damages of any kind arising out of the use of (or the inability to use) the
algorithms, source code, computer programs, or textual material contained in this
publication. This includes, but is not limited to, loss of revenue or profit, or other
incidental, physical, or consequential damages arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly limited to replacement
of the book and/or the CD-ROM, and only at the discretion of the Publisher.
The use of “implied warranty” and certain “exclusions” vary from state to state, and
might not apply to the purchaser of this product.
COMPUTER-BASED
NUMERICAL & STATISTICAL
TECHNIQUES
M. GOYAL
INFINITY SCIENCE PRESS LLC
Hingham, Massachusetts
New Delhi, India
Reprint & Revision Copyright © 2007. INFINITY SCIENCE PRESS LLC. All rights reserved.
Copyright © 2007. Laxmi Publications Pvt. Ltd.
This publication, portions of it, or any accompanying software may not be reproduced in any
way, stored in a retrieval system of any type, or transmitted by any means or media, electronic or
mechanical, including, but not limited to, photocopy, recording, Internet postings or scanning,
without prior permission in writing from the publisher.
Publisher: David F. Pallai
INFINITY SCIENCE PRESS LLC
11 Leavitt Street
Hingham, MA 02043
Tel. 877-266-5796 (toll free)
Fax 781-740-1677
info@infinitysciencepress.com
www.infinitysciencepress.com
This book is printed on acid-free paper.
M. Goyal. Computer-Based Numerical & Statistical Techniques.
ISBN: 978-0-9778582-5-5
The publisher recognizes and respects all marks used by companies, manufacturers, and developers
as a means to distinguish their products. All brand names and product names mentioned in this book
are trademarks or service marks of their respective companies. Any omission or misuse (of any
kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others.
Library of Congress Cataloging-in-Publication Data
Goyal, M.
Computer-based numerical & statistical techniques / M. Goyal.
p. cm.
Includes index.
ISBN 978-0-9778582-5-5 (hardcover with cd-rom : alk. paper)
1. Engineering mathematics – – Data processing. I. Title.
TA345.G695 2007
620.001’51 – – dc22
2007010557
07 6 7 8 9 5 4 3 2 1
Our titles are available for adoption, license or bulk purchase by institutions, corporations, etc. For
additional information, please contact the Customer Service Dept. at 877-266-5796 (toll free).
Requests for replacement of a defective CD-ROM must be accompanied by the original disc, your
mailing address, telephone number, date of purchase and purchase price. Please state the nature
of the problem, and send the information to INFINITY SCIENCE PRESS, 11 Leavitt Street, Hingham,
MA 02043.
The sole obligation of INFINITY SCIENCE PRESS to the purchaser is to replace the disc, based on defective
materials or faulty workmanship, but not based on the operation or functionality of the product.
CONTENTS
PART 1
Chapter 1 Introduction 3—30
1.1 Introduction to Computers 4
1.2 Definitions 4
1.3 Introduction to “C” Language 6
1.4 Advantages/Features of ‘C’ language 7
1.5 ‘C’ Character Set 7
1.6 ‘C’ Constants 8
1.7 “C” Variables 9
1.8 ‘C’ Key Words 10
1.9 “C Instructions” 10
1.10 Hierarchy of Operations 11
1.11 Escape Sequences 12
1.12 Basic Structure of ‘‘C’’ Program 12
1.13 Decision Making Instructions in “C” 14
1.14 Loop Control Structure 17
1.15 Arrays and String 18
1.16 Pointers 19
1.17 Structure and Unions 20
1.18 Storage Classes in ‘C’ 21
Chapter 2 Errors 31—76
2.1 Errors and Their Analysis 31
2.2 Accuracy of Numbers 32
2.3 Errors 34
2.4 A General Error Formula 42
2.5 Errors in Numerical Computations 43
2.6 Inverse Problems 46
v
vi CONTENTS
2.7 Error in a Series Approximation 56
2.8 Mathematical Preliminaries 60
2.9 Floating Point Representation of Numbers 61
2.10 Arithmetic Operations with Normalized Floating Point Numbers 63
2.11 Machine Computation 71
2.12 Computer Software 72
Chapter 3 Algebraic and Transcendental Equations 77—196
3.1 Bisection (or Bolzano) Method 77
3.2 Algorithm 78
3.3 Flow-Chart 79
3.4 Program Writing 80
3.5 Order of Convergence of Iterative Methods 80
3.6 Order of Convergence of Bisection Method 80
3.7 Convergence of a Sequence 81
3.8 Prove that Bisection Method Always Converges 81
3.9 Program to Implement Bisection Method 84
3.10 Iteration Method—(Successive Approximation Method) 94
3.11 Sufficient Condition for Convergence of Iterations 95
3.12 Theorem 95
3.13 Convergence of Iteration Method 96
3.14 Algorithm for Iteration Method 96
3.15 Flow-Chart for Iteration Method 98
3.16 Computer Program 99
3.17 The Method of Iteration for System of Non-Linear Equations 111
3.18 Method of False Position or Regula-Falsi Method 113
3.19 Algorithm 114
3.20 Flow-Chart 116
3.21 Convergence of Regula-Falsi Method 130
3.22 Secant Method 132
3.23 Lin-Bairstow’s Method or Method for Complex Root 135
3.24 Muller’s Method 141
3.25 Algorithm of Muller’s Method 142
3.26 Flow-Chart for Muller’s Method 144
3.27 The Quotient-Difference Method 152
3.28 Horner’s Method 156
3.29 Newton-Raphson Method 158
3.30 Convergence 159
CONTENTS vii
3.31 Order of Convergence 159
3.32 Geometrical Interpretation 161
3.33 Algorithm of Newton-Raphson Method 161
3.34 Flow-Chart of Newton–Raphson Method 162
3.35 Newton’s Iterative Formulae for Finding Inverse, Square Root 163
3.36 Rate of Convergence of Newton’s Square Root Formula 164
3.37 Rate of Convergence of Newton’s Inverse Formula 164
3.38 Definitions 182
3.39 Methods for Multiple Roots 182
3.40 Nearly Equal Roots 187
3.41 Comparison of Newton’s Method with Regula-Falsi Method 189
3.42 Comparison of Iterative Methods 189
3.43 Graeffe’s Root-Squaring Method 190
3.44 Ramanujan’s Method 195
PART 2
Chapter 4 Interpolation 199—390
4.1 Introduction 199
4.2 Assumptions for Interpolation 200
4.3 Errors in Polynomial Interpolation 200
4.4 Finite Differences 202
4.5 Other Difference Operators 205
4.6 Relation Between Operators 205
4.7 Differences of a Polynomial 207
4.8 Factorial Notation 225
4.9 To Show that (i) Δn[x]n = n ! (ii) Δn+1 [x]n = 0 225
4.10 Reciprocal Factorial 226
4.11 Missing Term Technique 227
4.12 Method of Separation of Symbols 234
4.13 Detection of Errors by Use of Difference Tables 234
4.14 Newton’s Formulae for Interpolation 243
4.15 Newton’s Gregory Forward Interpolation Formula 243
4.16 Newton’s Gregory Backward Interpolation Formula 262
4.17 Central Difference Interpolation Formulae 278
4.18 Gauss’ Forward Difference Formula 278
4.19 Gauss’ Backward Difference Formula 289
4.20 Stirling’s Formula 301
viii CONTENTS
4.21 Bessel’s Interpolation Formula 312
4.22 Laplace-Everett’s Formula 327
4.23 Interpolation by Unevenly Spaced Points 338
4.24 Lagrange’s Interpolation Formula 339
4.25 Error in Lagrange’s Interpolation Formula 357
4.26 Expression of Rational Function as a Sum of Partial Fractions 359
4.27 Inverse Interpolation 360
4.28 Divided Differences 361
4.29 Properties of Divided Differences 362
4.30 Newton’s General Interpolation Formula or Newton’s Divided
Difference Interpolation Formula 363
4.31 Relation Between Divided Differences and Ordinary
Differences 364
4.32 Merits and Demerits of Lagrange’s Formula 365
4.33 Hermite’s Interpolation Formula 381
PART 3
Chapter 5 Numerical Integration and Differentiation 393—476
5.1 Introduction 393
5.2 Numerical Differentiation 394
5.3 Formulae for Derivatives 394
5.4 Maxima and Minima of a Tabulated Function 402
5.5 Errors in Numerical Differentiation 422
5.6 Numerical Integration 423
5.7 Newton-cote’s Quadrature Formula 423
5.8 Trapezoidal Rule (n = 1) 424
5.9 Simpson’s One-third Rule (n = 2) 425
5.10 Simpson’s Three-Eighth Rule (n = 3) 426
5.11 Boole’s Rule 426
5.12 Weddle’s Rule (n = 6) 427
5.13 Algorithm of Trapezoidal Rule 429
5.14 Flow-Chart for Trapezoidal Rule 430
5.15 Program to Implement Trapezoidal Method of
Numerical Integration 431
5.16 Output 433
5.17 Algorithm of Simpson’s 3/8th Rule 433
5.18 Flow-Chart of Simpson’s 3/8th Rule 434
CONTENTS ix
5.19 Program to Implement Simpson’s 3/8th Method of
Numerical Integration 435
5.20 Output 437
5.21 Algorithm of Simpson’s 1/3rd Rule 437
5.22 Flow-Chart of Simpson’s 1/3rd Rule 438
5.23 Program to Implement Simpson’s 1/3rd Method
of Numerical Integration 439
5.24 Output 441
5.25 Euler-Maclaurin’s Formula 461
5.26 Gaussian Quadrature Formula 463
5.27 Numerical Evaluation of Singular Integrals 465
5.28 Evaluation of Principal Value Integrals 466
PART 4
Chapter 6 Numerical Solution of Ordinary Differential Equations 479—544
6.1 Introduction 479
6.2 Initial-Value and Boundary-Value Problems 480
6.3 Single Step and Multi-Step Methods 480
6.4 Comparison of Single-Step and Multi-Step Methods 480
6.5 Numerical Methods of Solution of O.D.E. 480
6.6 Picard’s Method of Successive Approximations 481
6.7 Picard’s Method for Simultaneous First Order Differential
Equations 488
6.8 Euler’s Method 492
6.9 Algorithm of Euler’s Method 493
6.10 Flow-Chart of Euler’s Method 494
6.11 Program of Euler’s Method 495
6.12 Modified Euler’s Method 496
6.13 Algorithm of Modified Euler’s Method 497
6.14 Flow-Chart of Modified Euler’s Method 498
6.15 Program of Modified Euler’s Method 499
6.16 Taylor’s Method 506
6.17 Taylor’s Method for Simultaneous I Order Differential
Equations 508
6.18 Runge-Kutta Methods 513
6.19 Fourth Order Runge-Kutta Method 515
6.20 Runge-Kutta Method for Simultaneous First Order Equations 519
x CONTENTS
6.21 Predictor-Corrector Methods 525
6.22 Milne’s Method 525
6.23 Adams-Moulton (or Adams–Bashforth) Formula 537
6.24 Stability 541
6.25 Stability in the Solution of Ordinary Differential Equations 542
6.26 Stability of I Order Linear Differential Equation of Form
dy/dx = Ay with Initial Condition y(x0) = y0 542
PART 5
Chapter 7 Statistical Computation 547—670
7.1 The Statistical Methods 547
7.2 Limitation of Statistical Methods 547
7.3 Frequency Charts 548
7.4 Graphical Representation of a Frequency Distribution 550
7.5 Types of Graphs and Diagrams 550
7.6 Histograms 551
7.7 Frequency Polygon 552
7.8 Frequency Curve 552
7.9 Cumulative Frequency Curve or the Ogive 553
7.10 Types of Frequency Curves 553
7.11 Diagrams 555
7.12 Curve Fitting 556
7.13 Principle of Least Squares 556
7.14 Fitting a Straight Line 558
7.15 Algorithm for Fitting a Straight Line of the Form y = a + bx
for a Given Set of Data Points 559
7.16 Flow-Chart for Fitting a Straight Line y = a + bx for a Given
Set of Data Points 560
7.17 Program to Implement Curve Fitting to Fit a Straight Line 561
7.18 Fitting of an Exponential Curve y = aebx 569
7.19 Fitting of the Curve y = axb 569
7.20 Fitting of the Curve y = abx 569
7.21 Fitting of the Curve pvr = k 570
7.22 Fitting of the Curve of Type xy = b + ax 570
7.23 Fitting of the Curve y = ax2 + b/x 570
7.24 Fitting of the Curve y = ax + bx2 571
7.25 Fitting of the Curve y = ax + b/x 572
CONTENTS xi
7.26 Fitting of the Curve y = a + b/x + c/x2 573
7.27 Fitting of the Curve y = c0/x + c1 x 573
7.28 Fitting of the Curve 2x = ax2 + bx + c 574
7.29 Most Plausible Solution of a System of Linear Equations 586
7.30 Curve-Fitting by Sum of Exponentials 588
7.31 Spline Interpolation 594
7.32 Spline Function 594
7.33 Cubic Spline Interpolation 594
7.34 Steps to Obtain Cubic Spline for Given Data 597
7.35 Approximations 601
7.36 Legendre and Chebyshev Polynomials 601
7.37 Legendre Polynomials 601
7.38 Chebyshev Polynomials 602
7.39 Special Values of Chebyshev Polynomials 603
7.40 Orthogonal Properties 603
7.41 Recurrence Relations 603
7.42 Aliter to Find Chebyshev Polynomials 604
7.43 Expression of Powers of x in terms of Chebyshev Polynomials 604
7.44 Properties of Chebyshev Polynomials 605
7.45 Chebyshev Polynomial Approximation 605
7.46 Lanczos Economization of Power Series for a General Function 606
7.47 Regression Analysis 614
7.48 Curve of Regression and Regression Equation 614
7.49 Linear Regression 614
7.50 Lines of Regression 614
7.51 Derivation of Lines of Regression 615
7.52 Use of Regression Analysis 618
7.53 Comparison of Correlation and Regression Analysis 618
7.54 Properties of Regression Co-efficients 619
7.55 Angle between Two Lines of Regression 620
7.56 Algorithm for Linear Regression 621
7.57 Program to Implement Least Square Fit of a Regression Line
of y on x 622
7.58 Program to Implement Least Square Fit of a Regression Line
of x on y 623
7.59 Polynomial Fit: Non-linear Regression 639
7.60 Multiple Linear Regression 652
7.61 Statistical Quality Control 654
xii CONTENTS
7.62 Advantages of Statistical Quality Control 656
7.63 Reasons for Variations in the Quality of a Product 657
7.64 Techniques of Statistical Quality Control 657
7.65 Control Chart 658
7.66 Objectives of Control Charts 658
7.67 Construction of Control Charts for Variables 659
7.68 Control Charts for Attributes 661
Chapter 8 Testing of Hypothesis 671—728
8.1 Population or Universe 671
8.2 Sampling 672
8.3 Parameters of Statistics 672
8.4 Standard Error 672
8.5 Test of Significance 673
8.6 Critical Region 674
8.7 Level of Significance 674
8.8 Errors in Sampling 674
8.9 Steps in Testing of Statistical Hypothesis 676
8.10 Test of Significance for Large Samples 676
8.11 Test of Significance of Small Samples 690
8.12 Student’s t-Distribution 691
8.13 Test I: t-test of Significance of the Mean of a Random Sample 692
8.14 Test II: t-test for Difference of Means of Two Small Samples
(From a Normal Population) 695
8.15 Snedecor’s Variance Ratio Test or F-test 703
8.16 Chi-square (χ2) Test 708
8.17 The χ2 Distribution 710
8.18 χ2 Test as a Test of Goodness of Fit 711
8.19 χ2 Test as a Test of Independence 718
PART 6 APPENDICES
Appendix A (Answers to Selected Exercises) 731
Appendix B (Sample Examination) 743
Appendix C (About the CD-ROM) 747
Index 749
P a r t 1
n Introduction
Numbers and Their Accuracy, Computer Arithmetic, Mathematical
Preliminaries.
n Errors
Errors and Their Computation, General Error Formula, Error in a
Series Approximation.
n Algebraic and Transcendental Equations
Bisection Method, Iteration Method, Method of False Position,
Newton-Raphson Method, Methods of Finding Complex Roots,
Muller’s Method, Rate of Convergence of Iterative Methods,
Polynomial Equations.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
T
he limitations of analytical methods in practical applications have led
mathematicians to evolve numerical methods.
We know that exact methods often fail in drawing plausible inferences
from a given set of tabulated data or in finding roots of transcendental equations
or in solving non-linear differential equations.
Even if analytical solutions are available, they are not amenable to direct
numerical interpretation.
The aim of numerical analysis is, therefore, to provide constructive methods
for obtaining answers to such problems in a numerical form. With the advent
of high speed computers and increasing demand for numerical solutions to
various problems, numerical techniques have become indispensible tools in
the hands of engineers and scientists.
We can solve equations x2 – 5x + 6 = 0, ax2 + bx + c = 0, y″ + 3y′ + 2y = 0 by
analytical methods, but transcendental equations such as a cos2 x + bex = 0
cannot be solved by analytical methods. Such equations are solved by numerical
analysis.
Methods of numerical analysis are used to approximate the problem
satisfactorily so that an approximate solution, amenable to precise analysis,
within a desired degree of accuracy is obtained.
To attain a desired degree of accuracy, insight into the process and resulting
error is essential.
Chapter
1 INTRODUCTION
3
4 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Consequently, numerical analysis may be regarded as a process to develop
and evaluate the methods for computing required mathematical numerical
results from the given numerical data.
Three broad steps are incorporated in the process
(i) Given data, called input information
(ii) Algorithm
(iii) The results obtained, called output information.
Input
Information
The
Algorithm
Output
Information
Computers have changed, almost revolutionized, the field of numerical
methods as a whole as well as many individual methods. That development is
continuing.
Much research is devoted to creating new methods, adapting existing
methods to new computer generations, improving existing methods, and
investigating stability and accuracy of methods. In large scale work, even small
improvements bring large savings in time and storage space.
1.1 INTRODUCTION TO COMPUTERS
The computer is an information-processing and an information-accessing tool.
It accepts information or data from the outside world and processes it to produce
new information. It also retrieves the stored information efficiency.
Hence, “The computer is an electronic device capable of accepting
information, applying prescribed processes to the information, and supplying
the results of these processes.”
A computer usually consists of input and output devices, storage, arithmetic
and logical units, and a control unit.
1.2 DEFINITIONS
Cursor
A position indicator or blinking character employed in a display on a video
terminal to indicate a character to be corrected or a position in which data is to
be entered.
INTRODUCTION 5
Algorithm
A finite, step-by-step procedure made up of mathematical and/or logical
operations designed to solve a problem is called an algorithm.
Flow-chart
A pictorial or graphical representation of a specific sequence of steps to be
used by a computer is called a flow-chart. It is, essentially, a convenient way of
planning the order of operations involved in an algorithm and helps in writing
a program.
A flow-chart contains certain symbols to represent the various operations .
These symbols are connected by arrows to indicate the flow of information. The
commonly used symbols with meanings are given below:
1. This oval shaped symbol is used to indicate
‘Start’ or ‘Stop/End’ of a program. It is also
used to mark the end of a sub-program by
writing ‘Return’.
2. This parallelogram shaped symbol is used to
indicate an input or output of data.
3. This rectangle-shaped symbol is a processing
symbol, e.g., addition, subtraction, or movement
of data to computer memory.
4. This diamond shaped symbol is a decision-
making symbol. A particular path is chosen
depending on ‘Yes’ or ‘No’ answer.
5. A small circle with any number or letter in it is
used as a connector symbol. It connects various
parts of a flow-chart which are far apart or
spread over pages.
(Subprocess symbol) (Subroutine) (Connector arrows)
G
(Terminal point)
(Input/output)
(Processing
operation box)
(Decision logic)
(Connector point)
6 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A rectangle with double vertical sides is used to denote a subprocess which
is given elsewhere as indicated by connector symbol.
When this box is encountered, the flow goes to the subroutine and it
continues till a ‘Return’ statement is encountered. Then it goes back to main
flow-chart and flow resumes onward processing.
The flow-chart can be translated into any computer language and can also
be executed on the computer.
PROGRAM. A computer does not have the capability of reading and
understanding instructions written in a natural language like English.
Thus, it is necessary to express the algorithm in a language understood
by the computer. An algorithm coded in a computer language is called
a program and the language used for coding is called a programming
language.
INSTRUCTION. A single operation to be executed by the computer is
called an instruction.
LOGIC. The science that deals with the canons and criteria of validity
in thought and demonstration, or the science of the formal principles of
reasoning is called logic.
LOOP. A series of instructions or one instruction in a program that is
repeated for a prescribed number of times, followed by a branch
instruction that exits the program from the loop.
COMPILER. A program designed to translate high level language
(source program into machine language object program) is called a
compiler.
ASSEMBLER. A machine language program that converts all
instructions into the binary format.
LOADER. A program required on practically all systems that loads
the user’s program along with required system routines into the central
processor for execution.
SYNTAX. The set of grammatical rules defining the structure of a
programming language is called syntax.
GARBAGE. An accumulation of unwanted, meaningless data after
processing of any program is called Garbage.
1.3 INTRODUCTION TO “C” LANGUAGE
In 1960, a number of computer languages had come into existence, among them
COBOL and FORTRAN. A drawback of these languages was that they were
INTRODUCTION 7
only suitable for specific purposes. There was a need for a single computer
language that could cater to the needs of different applications uniformly and
efficiently.
This led to the formation of an International Committee to develop such a
language. The result was a language called ALGOL 60. It did not become popular
as it was too abstract and too general. Successive refinements on ALGOL 60
resulted in the birth of language CPL (combined programming language), BCPL,
and ‘B’ language. These languages were again found to be either very big and
exhaustive or less powerful. Finally, in 1972, ‘Dennis Ritchie’ developed the
‘C’ language at AT and T Bell Laboratories, USA. He inherited the features of
‘B’ and BCPL languages and added some of his own in development of ‘C’
language.
Languages can be classified into two categories:
(i) High level languages (Problem Oriented Languages). e.g.,—
FORTRAN, BASIC, PASCAL, etc.
(ii) Low level languages (Machine Oriented Languages). e.g.,—Assembly
and machine language.
‘C’ language was designed to give both a relatively good programming
efficiency and a relatively good machine efficiency. Hence ‘C’ is said to be a
Middle level language as it stands between the above two categories.
1.4 ADVANTAGES/FEATURES OF ‘C’ LANGUAGE
Following are some advantages of ‘C’ language:
(i) Portability
(ii) Suitable for low level programming
(iii) Fewer Key words
(iv) ‘C’ is a structured language
(v) ‘C’ is a programmers language
1.5 ‘C’ CHARACTER SET
“Character” denotes any alphabet, digit or special symbol used to represent
information. The following table shows the valid alphabets, digits, and special
symbols allowed in ‘C’;
Alphabets: A, B, C, ......, Y, Z.
a, b, c, ......, y, z.
8 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Digits: 0, 1, 2, ......, 8, 9.
Special Symbols: ‘–’, ‘–’, + , = , /, , {}, [ ], < >,?.
The alphabets, digits, and special symbol, when properly combined, form
constants, variables, and keywords.
1.6 ‘C’ CONSTANTS
A constant is a quantity that doesn’t change. ‘C’ constants can be divided into
two major categories:
(i) Primary constants (also called primary data types).
(ii) Secondary constants (also called secondary data types).
Primary constants can be of three types:
(a) Integer constant
(b) Real constant
(c) Character constant.
Secondary data types or constants are:
(a) Array (b) Pointer (c) Structure (d) Union (e) Enum.
¾®
¾®
¾®
¾®
¾®
¾®
¾®
¾®
¾®
¾®
¾®
¾¾®
¾¾®
¾¾®
¾¾®
¾¾®
¾¾®
¾¾®
Short signed
Integer
constant Short unsigned
Long signed
Primary
constants Real
Float
or constant
Primary data
types
Double
Signed
Character
constant
Unsigned
‘C’ constants
Array
Secondary
Pointer
constants
or Structure
Secondary
data types
Union
Enum
¾®
¾®
¾®
¾®
¾®
INTRODUCTION 9
1.6.1 Primary Data Types
Data types Byte Range Format
occupied
(i) Signed character One – 128 to + 127 % C
(ii) Unsigned character One 0 to 255 % C
(iii) Short signed integer Two – 32768 to + 32767 % d
(iv) Short unsigned integer Two 0 to 65535 % u
(v) Long signed integer Four – 2147483648 to + 214748 3647 % l
(vi) Float Four ± 3.4 e – 38 to ± 3.4 e + 38 % f
(vii) Double Eight ± 1.7 e – 308 to ± 1.7 e + 308 % lf
1.7 “C” VARIABLES
Suppose we want to find the average of three numbers. The three numbers are
the input and the average is the output.
Following are the tasks to be performed by the computer.
1. Read the three numbers.
2. Calculate the average.
3. Output the average.
The computer actually works as follows:
n Reads the three numbers and stores them in three locations of memory.
n Adds the contents of the three locations and divides the result by 3. The
result is stored in a fourth location.
n The content of the fourth location is printed as output.
10 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
String variable
Integer variables
C Variables
Real variables
Floating
point
Double
Integer
Unsigned
integer
Short
integer
Long
integer Unsigned
character
Signed
character
Character
variable
When numbers are stored in various locations of memory, it becomes
necessary to name each of the memory locations. The name of the memory
location is called variable.
Memory locations may contain integer, real, or character constants.
Depending upon the data contained in the memory location, the variables are
classified as integer, real, character, and string variables.
Secondary variables can be
(a) Array variables (b) Pointer variables (c) Structure variables
(d) Union variables (e) Enum variables.
1.8 ‘C’ KEY WORDS
Key words (also called reserved words) are an integral part of a language.
Their meanings are predefined and hence these words cannot be used as variable
names. There are 32 key words in C language.
1.9 “C INSTRUCTIONS”
The constants, variables, and key words are combined to form instructions.
Basically, there are four types of instructions in ‘C’:
INTRODUCTION 11
(a) Type declaration Instruction:
e.g.: int bas_sal;
float tot_sal;
char name;
(b) Arithmetic Instruction:
e.g.: int a;
float b, C;
C = a * b;
assignment operator.
(c) Input/Output Instruction:
e.g.: printf (‘‘<format string>’’,<list of variables>);
<format string> could be
% f — for real values
% d — for integer values
% C — for character values
% S — for printing a string (sequence of character).
(d) Control Instruction:
Control Instructions specify the order in which the various instructions in
a program are to be executed by the computer. They define the flow of
control in a program.
There are four types of Control Instructions in ‘C’
(i) Sequence Control Instruction
(ii) Selection or Decision Control Instruction
(iii) Repetition or Loop Control Instruction
(iv) Case Control Instruction
1.10 HIERARCHY OF OPERATIONS
The order or priority in which the arithmetic operations are performed in an
arithmetic statement is called the hierarchy of operations. Hierarchy of
operations is given below:
Priority Operators
1. Parentheses—All parentheses are evaluated first
2. Multiplication and division
3. Addition and Subtraction.
12 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
1.11 ESCAPE SEQUENCES
In ‘C’ the backslash symbol () is called an escape character.
 t — Tab
 n — New line character takes control to the next line
 b — Backspace character moves the cursor one position to the left of its
current position.
 r — Carriage return character takes the cursor to the beginning of the line
in which it is currently placed.
 a — Alert character alerts the user by sounding the speaker inside the
computer.
1.12 BASIC STRUCTURE OF ‘‘C’’ PROGRAM
A program is defined as a valid set of instructions which perform a given task.
Each instruction in C program is written as a separate statement. However
big a problem or program is, the following rules are applicable to all ‘C’
Statements:
(a) Blank spaces may be inserted between two words to improve readability
of the statement.
(b) All statements are usually entered in small case letters.
(c) C is free from language, i.e., there is no restriction on position of
statements within the program.
(d) A ‘C’ statement always ends with a semicolon (;).
Any ‘C’ program is a combination of functions. Main( ) is one such function.
Empty parentheses after main is a must. The set of statements belonging to a
function is enclosed within a pair of braces. For example,
main( )
{
Statement 1;
Statement 2;
Statement 3;
}
Functions can be of two types:
(i) Library functions or Built-in functions or intrinsic functions
(ii) User defined functions.
Library functions are those which are available as a part of ‘C’ language (C
Compiler). These can be used by the programmers (users) directly to do a specific
task. For example, the input/output operations are performed by a group as
INTRODUCTION 13
functions which belong to a particular set. These sets are called header files in
‘C’. The header file is denoted by the file extension h.
The following table shows some popular library functions.
S. Functions Meaning Argument Value
No.
1. sqrt (x) x float float
2. log (x) loge x float float
3. abs (x) | x | integer integer
4. fabs (x) | x | float float
5. exp (x) ex float float
6. pow (x, y) xy float float
7. ceil (x) Rounding x to next float float
integer value
8. f mod (x, y) returns the remainder float float
of x/y
9. rand ( ) generates a (+) ve — integer
random integer
10. srand (v) to initialize the random Unsigned —
number generator
11. sin (x) sin x float in radian measure float
12. cos (x) cos x ’’ ’’
13. tan (x) tan x float in radian measure float
14. toascii (x) returns integer value to character integer integer
particular character
15. tolower (x) To convert character ’’ character
to lower case
16. toupper (x) To convert character character ’’
to upper case
1.12.1. Simple ‘C’ Program
#include<stdio.h>
/*program for average of three numbers*/
main( )
{
int a, b, c, d;
a = 2;
b = 3;
14 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
c = 6;
d = (a + b + c)/3;
Printf(‘‘% d’’, d);
}
In the above C-program, the first line contains a reference to a header file.
Since any standard program will have some i/o functions, the above statement
appears as the first line in every C program.
Library functions of stdio.h are scanf , printf, getchr, putchr, putc, puts.
If we want to use certain mathematical functions then the header file
math.h is included using statement
#include <math.h>
Library functions of math.h are cos, cosh, sin, sinh, tan, log, a cos, a sin,
exp.
The second line of the above program is a comment line. It can be anywhere
in the program and any number of comment lines are allowed. This comment
line improves the readability and helps the programmer to understand the
program.
The function name main( ) is written next. Function name is always followed
by a set of parentheses. Arguments, if any, are placed within the parentheses.
The opening brace and the closing brace indicate the beginning and end of the
function.
Next the variables are declared as integers. The declaration part must be
written as the first part of the function.
Next, a, b, c values are assigned and d is calculated.
In the next line, d is printed using printf function.
The basic rules for a program can be stated as follows:
1. Proper header file must be referred to.
2. There should be one and only one main function.
3. Contents of the function should be enclosed by opening and closing
braces.
4. Variables must be declared first in the function.
5. Every C statement except the comment line headlines and function
names in a function must end with a semicolon.
1.13 DECISION MAKING INSTRUCTIONS IN “C”
The ability to make decisions regarding execution of the instructions in a ‘‘C’’
program is accomplished using decision control instructions. C has three major
decision-making instructions:
INTRODUCTION 15
(i) The if statement;
(ii) The if-else statement; and
(iii) The switch statement.
(i) The if statement. The general form (syntax) of this statement is as follows:
if (this condition is true)
execute this statement;
e.g.,: if (exp > 5)
{
bonus = 3000;
printf (“% d”, bonus);
}
(ii) The if-else statement. The if statement executes a single statement or a
group of statements if the condition following if is true. The ability to execute a group
of statements if the condition is true and to execute another group of statements if the
condition is false is provided by if-else statement.
The general syntax of if-else is as follows:
if (condition)
statement 1;
else
statement 2;
or
if (condition)
{
statement 1;
statement 2;
}
else
{
statement 1;
statement 2;
}
The group of statements after the if, up to and not including the else, is
called as if block. Similarly, the statements after the else form the else block.
(iii) Decision using switch. The control structure which allows decisions to be
made from a number of choices is called as switch or switch-case-default. These 3
keywords together make up the control structure.
16 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Syntax is as follows:
Switch (integer expression)
{
case constant 1;
do this;
break;
case constant 2:
do this;
break;
default:
do this;
}
The integer expression following the keyword switch in any C expression
will yield an integer value. The keyword case is followed by an integer or a
character constant.
Each constant in each case must be different from all others. The break
statement helps in getting out of the control structure.
There is no need for a break statement after the default, since the control
automatically comes out of the control structure as it is last.
e.g.,:
main( )
{
int i = 6;
switch (i)
{
case 1:
printf (‘‘This is case 1’’);
break;
case 2:
printf (‘‘This is case 2’’);
break;
default:
printf (‘‘This is default’’);
}
}
Points to Remember. (i) The cases need not be arranged in any specific order.
(ii) It is allowed to use char values in case and switch.
(iii) There may be no statements in some of the cases in switch, but they can
still be useful.
(iv) The switch statement is very useful while writing menu-driven programs.
NOTE
INTRODUCTION 17
1.14 LOOP CONTROL STRUCTURE
The process of repeating some portion of the program either a specified number
of times or until a particular condition is satisfied is called looping.
Three methods of implementing a loop in ‘‘C’’ are:
(a) using a for statement
(b) using a while statement
(c) using a do-while statement.
(a) The for statement. It is the most popular loop control structure.
General form is as below:
for (initialize counter; test counter; increment counter).
This control structure allows us to specify 3 things about a loop in a single
line.
(i) Setting a loop counter to an initial value.
(ii) Testing the loop counter to determine whether its value has reached
the number of repetitions desired.
(iii) Increasing the value of the loop counter each time the program segment
within the loop has been executed.
e.g.,:
for (i = 1; i < = 10; i = i + 1)
| i = i + 1 may be written as i++
printf (“% d”, i);
o/p = prints values from 1 to 10.
(b) The while loop. General form is:
initialize the loop counter;
while (test of loop counter using a condition)
{
do this;
: Body of while loop
increment loop counter;
}
(i) The statement within the loop keep on getting executed as long as the
condition being tested remains true. As soon as it becomes false, the
control passes to the first statement that follows the body of the while
loop.
(ii) The condition being tested may use relational or logical operators.
O
Q
PPP
NOTE
18 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(iii) Instead of incrementing the loop counter, it can be decremented also.
e.g.: int i = 4;
while (i > = 1)
{
printf (“% d”, i);
i = i – 1;
}
(iv) The loop counter need not be of int type, it can be of float type also.
(c) The do-while loop. General form (syntax)
do
{
this;
and this;
and this;
} while (this condition is true);
The difference between while and do-while is that the do-while executes
its statements at least once even if the condition fails for the first time itself.
The while loop, however, does not execute the statements even once if the
condition is false.
The break and continue keywords are usually associated with all three
loops, i.e., for, while, and do-while. A break keyword inside the loop takes the
control out of the loop, bypassing the conditional test. A continue keyword, on
the other hand, takes the control to the conditional test.
1.15 ARRAYS AND STRING
Arrays. An array is a collection of similar elements. These elements could all
be ints, or all floats or all charcs, etc. However, there are situations in which it
is required to store more than one value at a time in a single variable.
e.g.,: if it is required to arrange the scores obtained by 100 students in a
particular subject, then the two following methods can be used.
(a) Construct 100 variables to store scores obtained by 100 students in a
particular subject.
or
(b) Construct a single variable (called as a subscripted variable) capable
of holding all 100 values of the students is a particular subject.
INTRODUCTION 19
A subscripted variable is a collective name given to a group of similar
quantities.
e.g.,: scores = {20, 50, 60, 80}
Array declaration. In order to use an array in the program, we need to
declare it in order to tell the ‘C’ Compiler what type and size of array we want.
e.g.,: int scores [100];
An array can be of more than one dimension. The two dimensional array is
also called a Matrix.
e.g.,: Scores [i] [J];
String. The character arrays are called strings. Character arrays or strings
are the data types used by programming languages to manipulate text such as
words or sentences. e.g., :
Static character name [ ] = {‘A’, ‘S’, ‘H’, ‘I’, ‘o’};
Static character name [ ] = ‘‘ASHISH’’;
(i) The length of the string entered while using scanf should not exceed the
size of the character array.
(ii) Scanf is not capable of receiving multiword strings. Hence, names such
as ‘‘Mansi Choubey’’ would be unacceptable. In order to get around this
limitation of scanf function, gets ( ) and puts ( ) functions are used.
Syntax: gets (Name);
puts (‘‘ Hello ! ”);
1.16 POINTERS
When a variable is declared in a program, the compiler does three things
(i) Reserves space in memory for this variable.
(ii) Associates the name of the variable with the memory location.
(iii) If some value is assigned to the variable, this value is stored at this
location.
It is possible to find the memory address of a variable using an “address of”
(&) operator. If the integer variable i is stored in memory as follows:
Memory Value Location name
location (address)
1000 2 i
NOTE
20 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
then its memory address can be printed using a printf statement as shown
below:
printf (‘‘Address of i = % d”, and i);
Similarly, there is another operator called ‘value at address’ (*) operator
which returns the value stored at a particular address.
printf (“value of i = % d”, * (& i));
1.17 STRUCTURE AND UNIONS
Structures. A structure is a data type which facilitates storage of similar or
dissimilar types of information about a particular entity.
all information regarding an employee.
struct employee
{
char name [10];
int code;
char address [20];
char sex;
};
The keyword struct is used to declare a structure data type.
Union. In ‘C’, a union is a memory location that is shared by two or more
different variables, generally of different types, at different times.
Defining a union is similar to defining a structure.
Its general form is;
union union_name
{
type variable_name;
type variable_name;
:
} union_variables;
Example:
union item
{
int i;
char ch;
};
INTRODUCTION 21
Unions are useful when:
(i) It is required to produce portable (machine independent) code. This is,
because the compiler keeps track of actual sizes of the variables that
make up the union, so no machine dependecies are produced.
(ii) When type conversions are needed because we can refer to the data
held in the union in different ways.
1.18 STORAGE CLASSES IN ‘C’
In order to fully define a variable, two things are required:
(i) The type of the variable
(ii) The storage class of the variable.
There are four storage classes provided in ‘C’
(a) Automatic storage classes (b) Register storage classes
(c) Static storage classes (d) Extern storage classes
EXAMPLES
Example 1. Draw a flow-chart to find real roots of the equation
ax2 + bx + c = 0
Sol. We know that the roots of quadratic equation ax2 + bx + c = 0 are given by
x1 =
− + −
b b ac
a
2
4
2
and x2 =
− − −
b b ac
a
2
4
2
or x1 =
− +
b d
a
2
,
x2 =
− −
b d
a
2
, where d = b2 – 4ac.
22 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
START
Read
a, b, c
Is
a = 0 ?
d = b – 4 ac
2
Is
d < 0 ?
No
No
x = (– b + )/2a
1 d
x = (– b – )/2a
2 d
Print
x , x
1 2
Print x1
STOP
Print roots
are complex
Is
b = 0 ?
No
x = –
1
c
b
STOP
Yes
Yes
Yes
Flow-chart
INTRODUCTION 23
Example 2. Develop a flow-chart to select the largest number of a given set of
100 numbers.
Sol.
START
Read n
Max = n
Count = 1
Is
count = 100 ?
Yes
1
Read n
No
Is
n > Max ?
No
Count = Count + 1
1
Max = n
Print
Max
STOP
Yes
Example 3. Write an algorithm to find the real roots of the equation ax2 + bx + c
= 0 ; a, b, c are real and a, b ≠ 0.
Sol. We know that the roots of the equation
ax2 + bx + c = 0
24 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
are x1 =
− +
b e
a
2
, x2 =
− −
b e
a
2
where e = b ac d
2
4
− =
Algorithm is
Step 1. Input a, b, c.
Step 2. Calculate d = b2 – 4ac.
Step 3. Check if d < 0. If yes, then print roots are complex, go to step 8.
Step 4. Calculate e = d .
Step 5. Calculate x1 =
− +
b e
a
2
.
Step 6. Calculate x2 =
− −
b e
a
2
.
Step 7. Print x1 and x2.
Step 8. Stop.
Example 4. Write an algorithm for converting a temperature from centigrade
to Fahrenheit. Also write its program in ‘C’.
Sol. For this problem, the centigrade is the input and Fahrenheit is the output.
Let c be the variable name for centigrade and f be the variable name for
Fahrenheit.
The formula for converting temperature from centigrade to Fahrenheit is
f = (9/5) * c + 32
So, the algorithm is
1. read c
2. f = (9/5) * c + 32
3. printf
4. end
In the first section, we name the header file to be included.
1. # include<stdio.h>
Then the function name is written as
main( )
In the second section, the variables c and f are declared as floating point
variables.
INTRODUCTION 25
2. float c, f;
In the third section, reading the values for c, calculating f and printing the
value of f takes place.
3. scanf (“% f ”, & c);
f = (9.0 /5.0) * c + 32.0;
printf (“Fahrenheit = % f”, f);
The complete program is given below:
# include<stdio.h>
main( )
{
float c, f;
scanf (“% f”, & c);
f = (9.0/5.0) * c + 32.0;
printf (“Fahrenheit = % f”, f);
}
The sample output is shown below:
40.0
Fahrenheit = 104.00.
Example 5. Write a C program to determine the area of a triangle using the
formula
area = s(s a) (s b) (s c)
− − − , where s =
a b c
2
+ +
.
Sol. The algorithm is
1. read a, b, c
2. s =
a b c
+ +
2
3. area = sqrt (s * (s – a) * (s – b) * (s – c))
4. print area
5. end.
The program is given below
# include<stdio.h>
# include<math.h>
main( )
26 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
{
float a, b, c, s, area;
printf (“Type the sides a, b, c”);
scanf (“%f %f %f”, & a, & b, & c );
s = (a + b + c) /2.0;
area = sqrt (s * (s – a) * (s – b) * (s – c));
printf (“Area = % f ”, area);
}
Following is a sample output
Type the sides a, b, c
2.0 3.0 4.0
Area = 2.905.
Example 6. Write a flow-chart to evaluate the sum of the series
1 + x + x2 + x3 + ..... + xn.
Sol.
START
Read x, n
Sum = 1
i < n
i = 0
i = i + 1
Sum = Sum + x
i
Print Sum
STOP
False
True
INTRODUCTION 27
Example 7. Write a C-program to print all the Fibonacci numbers less than 50.
Sol. The following are the Fibonacci numbers.
0, 1, 1, 2, 3, 5, 8, 13, .......
The first Fibonacci number is 0. The second Fibonacci number is 1.
Any kth Fibonacci number = (k – 1)th Fibonacci number + (k – 2)th Fibonacci
number
The algorithm is
1. n0 = 0
2. n1 = 1
3. print n0, n1
4. n = n0 + n1
5. if n > = 50 stop
6. print n
7. n0 = n1
8. n1 = n
9. goto step 4.
For this problem, there is no input.
The C–program is given below:
/* Program for Fibonacci Numbers */
# include<stdio.h>
main( )
{
int n, n0, n1;
n0 = 0;
n1 = 1;
printf (‘‘% d t %d”, n0, n1);
step 1: n = n1 + n0;
if (n > = 50)
goto end;
else
{ print f (“ t % d”, n);
n0 = n1;
n1 = n;
goto step 1;}
end: printf (“ ”);
}
The sample output is
0 1 1 2 3 5 8 13 21 34
28 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 8. Write a C-program to
(i) print integers from 1 to 10 (ii) print odd numbers from 1 to 10.
Sol. (i) # include<stdio.h>
main( )
{
int i;
for (i = 1; i < = 10; i + +)
printf (‘‘% dt’’ , i);
}
The output will be
1 2 3 4 5 6 7 8 9 10
(ii) # include<stdio.h>
main( )
{
int i;
for (i = 1; i < = 10; i + = 2)
printf (“%dt”, i);
}
The output will be
1 3 5 7 9
ASSIGNMENT 1.1
1. Write a C-program to find the magnitude of a vector a = a1i + a2j + a3k.
2. State whether the following statements are correct or not:
(i) scanf (‘‘Enter the value of A% d’’, a); (ii) scanf (“%d; %d, %d”, & a, & b, & c);
3. Write a C program to solve a set of linear equations with two variables
a1x + b1y = c1
a2x + b2y = c2
L
NMHint: Solution is x =
b c b c
a b a b
2 1 1 2
1 2 2 1
−
−
, y =
a c a c
a b a b
1 2 2 1
1 2 2 1
−
−
O
QP.
4. Write a C-program to read the principal, rate of interest, and the number of years and
find the simple interest using the formula
Simple interest =
PNR
100
5. Write a printf statement to print “The given value is 22.23.”
6. Give an algorithm and write a program in C to check whether a given number is prime
or not.
INTRODUCTION 29
7. What will be the value of x and the sum after the execution of the following program?
x = 1;
sum = 0;
step 1: if (x < 10)
{
sum + = 1.0/x;
x + = 1;
goto step 1
}
8. Write a program in C to determine whether a number is odd or even. Also, draw its flow-
chart.
9. Given a circle x2 + y2 = c,
Write a C-program to determine whether a point (x, y) lies inside the circle, on the circle,
or outside the circle.
10. Draw a flow-chart for adding marks of 5 subjects for a student and print the total.
11. Write a C-program to print the message CRICKET WORLD CUP-2007 six times.
12. Give any five library functions in “C”.
13. Write a program in C to print the following triangle of numbers
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
14. Write an algorithm for addition of two matrices of same order.
15. Write a C-program to find the multiplication of two square matrices each of order 2.
16. Write a C-program to find factorial of a given number.
17. Give a flow-chart for finding the determinant of a square non-singular matrix.
18. Write an algorithm for finding the inverse of a square non-singular matrix.
19. What is the maximum length allowed in defining a variable in “C”?
20. Write a C-program to find whether a year is leap year.
21. Develop a flow-chart to select the largest number of a given set of 500 numbers.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
Chapter 2 ERRORS
31
2.1 ERRORS AND THEIR ANALYSIS
2.1.1 Sources of Errors
F
ollowing are the broad sources of errors in numerical analysis:
(1) Input errors. The input information is rarely exact since it comes
from the experiments and any experiment can give results of only
limited accuracy. Moreover, the quantity used can be represented
in a computer for only a limited number of digits.
(2) Algorithmic errors. If direct algorithms based on a finite sequence
of operations are used, errors due to limited steps don’t amplify the
existing errors, but if infinite algorithms are used, exact results
are expected only after an infinite number of steps. As this cannot
be done in practice, the algorithm has to be stopped after a finite
number of steps and the results are not exact.
(3) Computational errors. Even when elementary operations such
as multiplication and division are used, the number of digits
increases greatly so that the results cannot be held fully in a register
available in a given computer. In such cases, a certain number of
digits must be discarded. Furthermore, the errors here accumulate
32 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
one after another from operation to operation, changing during the
process and producing new errors.
The following diagram gives a schematic sequence for solving a problem
using a digital computer pointing out the sources of errors.
Errors
Real
problem Model Algorithm
Program-
ming
Compu-
tation
Result
Our effort will be to minimize these errors so as to get the best possible
results.
We begin by explaining the various kinds of errors and approximations
that may occur in a problem and derive some results on error
propagation in numerical calculations.
2.2 ACCURACY OF NUMBERS
(1) Approximate numbers. There are two types of numbers: exact and
approximate. Exact numbers are 2, 4, 9,
7
2
, 6.45, ...... etc. but there are
numbers such that
4
3
(= 1.333 ......), 2 (= 1.414213 ...) and π (= 3.141592......) which cannot
be expressed by a finite number of digits. These may be approximated
by numbers 1.3333, 1.4141, and 3.1416, respectively.
Such numbers, which represent the given numbers to a certain degree
of accuracy, are called approximate numbers.
(2) Significant digits. The digits used to express a number are called
significant digits.
The digits 1, 2, 3, 4, 5, 6, 7, 8, 9 are significant digits. ‘0’ is also a
significant digit except when it is used to fix the decimal point or to fill
the places of unknown or discarded digits.
For example, each of the numbers 7845, 3.589, and 0.4758 contains 4
significant figures while the numbers 0.00386, 0.000587, 0.0000296
contain only three significant figures (since zeros only help to fix the
position of the decimal point).
ERRORS 33
Similarly, in the number 0.0003090, the first four ‘0’ s’ are not
significant digits since they serve only to fix the position of the decimal
point and indicate the place values of the other digits. The other two
‘0’ s’ are significant.
To be more clear, the number 3.0686 contains five significant digits.
A. The significant figure in a number in positional notation consists
of
(i) All non-zero digits
(ii) Zero digits which
(a) lie between significant digits;
(b) lie to the right of decimal point and at the same time to the
right of a non-zero digit;
(c) are specifically indicated to be significant.
B. The significant figure in a number written in scientific notation
(e.g., M × 10k) consists of all the digits explicitly in M.
Significant digits are counted from left to right starting with the non-
zero digit on the left.
A list is provided to help students understand how to calculate
significant digits in a given number:
Number Significant digits Number of significant digits
3969 3, 9, 6, 9 04
3060 3, 0, 6 03
3900 3, 9 02
39.69 3, 9, 6, 9 04
0.3969 3, 9, 6, 9 04
39.00 3, 9, 0, 0 04
0.00039 3, 9 02
0.00390 3, 9, 0 03
3.0069 3, 0, 0, 6, 9 05
3.9 × 106 3, 9 02
3.909 × 105 3, 9, 0, 9 04
6 × 10–2 6 01
NOTE
34 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(3) Rounding-off. There are numbers with many digits, e.g.,
22
7
=
3.142857143. In practice, it is desirable to limit such numbers to a
manageable number of digits, such as 3.14 or 3.143. This process of
dropping unwanted digits is called rounding-off.
Numbers are rounded-off according to the following rule:
To round-off a number to n significant digits, discard all digits to the
right of the nth digit and if this discarded number is
(i) less than 5 in (n + 1)th place, leave the nth digit unaltered. e.g.,
7.893 to 7.89.
(ii) greater than 5 in (n + 1)th place, increase the nth digit by unity, e.g.,
6.3456 to 6.346.
(iii) exactly 5 in (n + 1)th place, increase the nth digit by unity if it is odd,
otherwise leave it unchanged.
e.g., 12.675 ~ 12.68
12.685 ~ 12.68
The number thus rounded-off is said to be correct to n significant figures.
A list is provided for explanatory proposes:
Number Rounded-off to
Three digits Four digits Five digits
00.543241 00.543 00.5432 00.54324
39.5255 39.5 39.52 39.526
69.4155 69.4 69.42 69.416
00.667676 00.668 00.6677 00.66768
2.3 ERRORS
Machine epsilon
We know that a computer has a finite word length, so only a fixed number of
digits is stored and used during computation. Hence, even in storing an exact
decimal number in its converted form in the computer memory, an error is
introduced. This error is machine dependant and is called machine epsilon.
Error = True value – Approximate value
ERRORS 35
In any numerical computation, we come across the following types of
errors:
(1) Inherent errors. Errors which are already present in the statement
of a problem before its solution are called inherent errors. Such errors
arise either due to the fact that the given data is approximate or due to
limitations of mathematical tables, calculators, or the digital computer.
Inherent errors can be minimized by taking better data or by using high
precision* computing aids. Accuracy refers to the number of significant
digits in a value, for example, 53.965 is accurate to 5 significant digits.
Precision refers to the number of decimal positions or order of magnitude
of the last digit in the value. For example, in 53.965, precision is 10–3.
Example. Which of the following numbers has the greatest precision?
4.3201, 4.32, 4.320106.
Sol. In 4.3201, precision is 10–4
In 4.32, precision is 10–2
In 4.320106, precision is 10–6.
Hence, the number 4.320106 has the greatest precision.
(2) Rounding errors. Rounding errors arise from the process of rounding-
off numbers during the computation. They are also called procedual
errors or numerical errors. Such errors are unavoidable in most of the
calculations due to limitations of computing aids.
These errors can be reduced, however, by
(i) changing the calculation procedure so as to avoid subtraction of
nearly equal numbers or division by a small number
(ii) retaining at least one more significant digit at each step and
rounding-off at the last step. Rounding-off may be executed in two
ways:
(a) Chopping. In chopping, extra digits are dropped by truncation
of number. Suppose we are using a computer with a fixed word
length of four digits, then a number like 12.92364 will be stored
as 12.92.
We can express the number 12.92364 in the floating print form
as
True x = 12.92364
= 0.1292364 × 102 = (0.1292 + 0.0000364) × 102
= 0.1292 × 102 + 0.364 × 10–4 + 2
= fx . 10E + gx . 10E – d
= Approximate x + Error
*Concept of accuracy and precision are closely related to significant digits.
36 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ Error = gx . 10E – d, 0 ≤ gx ≤ d
Here, gx is the mantissa, d is the length of mantissa and E is
exponent
Since 0 ≤ gx < 1
∴ Absolute error ≤ 10E – d
Case I. If gx < 0.5 then approximate x = fx . 10E
Case II. If gx ≥ .5 then approximate x = fx . 10E + 10E – d
Error = True value – Approximate value
= fx . 10E + gx . 10E – d – fx .10E – 10E – d
= (gx – 1) . 10E – d
absolute error ≤ 0.5.(10)E – d.
(b) Symmetric round-off. In symmetric round-off, the last
retained significant digit is rounded up by unity if the first
discarded digit is ≥ 5, otherwise the last retained digit is
unchanged.
(3) Truncation errors
Truncation errors are caused by using approximate results or by
replacing an infinite process with a finite one.
If we are using a decimal computer having a fixed word length of 4
digits, rounding-off of 13.658 gives 13.66, whereas truncation gives
13.65.
e.g., If S = a x
i i
i =
∞
∑1
is replaced by or truncated to S = a x
i i
n
1
∑ , then the
error developed is a truncation error.
A truncation error is a type of algorithm error. Also,
if ex = 1 + x +
x x x
2 3 4
2 3 4
! ! !
+ + + ...... ∞ = X (say) is truncated to
1 + x +
x x
2 3
2 3
! !
+ = X′ (say), then truncation error = X – X′
Example. Find the truncation error for ex at x =
1
5
if
(i) The first three terms are retained in expansion.
(ii) The first four terms are retained in expansion.
Sol. (i) Error = True value – Approximate value
= 1
2 3
1
2
2 3 2
+ + + +
F
HG
I
KJ − + +
F
HG
I
KJ
x
x x
x
x
! !
......
!
= + + +
x x x
3 4 5
3 4 5
! ! !
......
ERRORS 37
NOTE
Put x =
1
5
error =
.008 .00032
6
0016
24 120
+ +
.
+ ......
= .0013333 + .0000666 + .0000026 + ... = .0014025
(ii) Similarly the error for case II may be found.
(4) Absolute error. Absolute error is the numerical difference between
the true value of a quantity and its approximate value.
Thus, if X is the true value of a quantity and X′ is its approximate
value, then | X – X′ | is called the absolute error ea.
ea = | X – X′ | = | Error |
(5) Relative error.
The relative error er is defined by
er =
|Error |
True value
X – X
X
=
′
where X is true value and X – X′ is error.
(6) Percentage error. Percentage error ep is defined as
ep = 100 er = 100
X – X
X
′
.
1. The relative and percentage errors are independent of units used
while absolute error is expressed in terms of these units.
2. If a number is correct to n decimal places, then the error
=
1
2
(10–n).
e.g., if the number 3.1416 is correct to 4 decimal places, then the
error
=
1
2
(10–4) = .00005.
3. If the first significant digit of a number is k and the number is
correct to n significant digits, then the relative error <
1
(k 10 )
n 1
× − .
38 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
EXAMPLES
Example 1. Suppose 1.414 is used as an approximation to 2 . Find the absolute
and relative errors.
Sol. True value = 2 = 1.41421356
Approximate value = 1.414
Error = True value – Approximate value
= 2 – 1.414 = 1.41421356 – 1.414
= 0.00021356
Absolute error ea = | Error |
= | 0.00021356 | = 0.21356 × 10–3
Relative error er =
ea
True value
=
0 21356 10
2
3
. × −
= 0.151 × 10–3.
Example 2. If 0.333 is the approximate value of
1
3
, find the absolute, relative,
and percentage errors.
Sol.True value (X) =
1
3
Approximate value (X′) = 0.333
∴ Absolute error ea = | X – X′ |
= − = −
1
3
0 333 0 333333 0 333
. | . . | = .000333
Relative error er =
ea
X
= =
.
.
.
000333
333333
000999
Percentage error ep = er × 100 = .000999 × 100 = .099%.
Example 3. An approximate value of π is given by 3.1428571 and its true value
is 3.1415926. Find the absolute and relative errors.
Sol. True value = 3.1415926
Approximate value = 3.1428571
Error = True value – Approximate value
= 3.1415926 – 3.1428571
= – 0.0012645
ERRORS 39
Absolute error ea = | Error | = 0.0012645
Relative error er =
ea
True value
=
0.0012645
3.1415926
= 0.000402502.
Example 4. Three approximate values of the number
1
3
are given as 0.30, 0.33,
and 0.34. Which of these three is the best approximation?
Sol. The best approximation will be the one which has the least absolute error.
True value =
1
3
= 0.33333.
Case I. Approximate value = 0.30
Absolute error = | True value – Approximate value |
= | 0.33333 – 0.30 |
= 0.03333
Case II. Approximate value = 0.33
Absolute error = | True value – Approximate value |
= | 0.33333 – 0.33 |
= 0.00333.
Case III. Approximate value = 0.34
Absolute error = | True value – Approximate value |
= | 0.33333 – 0.34 |
= | – 0.00667 | = 0.00667
Since the absolute error is least in case II, 0.33 is the best approximation.
Example 5. Find the relative error of the number 8.6 if both of its digits are
correct.
Sol. Here, ea = .05 ∵ ea = ×
F
HG I
KJ
−
1
2
10 1
∴ er =
.05
8.6
= .0058.
Example 6. Find the relative error if
2
3
is approximated to 0.667.
Sol. True value =
2
3
= 0.666666
Approximate value = 0.667
40 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Absolute error ea = | True value – approximate value |
= | .666666 – .667 | = .000334
Relative error er =
.000334
.666666
.0005
= .
Example 7. Find the percentage error if 625.483 is approximated to three
significant figures.
Sol. ea = | 625.483 – 625 | = 0.483
er =
ea
625.483 625.483
= =
.483
.000772
∴ ep = er × 100 = .077%.
Example 8. Round-off the numbers 865250 and 37.46235 to four significant
figures and compute ea, er, ep in each case.
Sol. (i) Number rounded-off to four significant digits = 865200
X = 865250
X′ = 865200
Error = X – X′ = 865250 – 865200 = 50
Absolute error ea = | error | = 50
Relative error er =
ea
X
=
50
865250
= 5.77 × 10–5
Percentage error ep = er × 100 = 5.77 × 10–3
(ii) Number rounded-off to four significant digits = 37.46
X = 37.46235
X′ = 37.46
Error = X – X′ = 0.00235
Absolute error ea = | error | = 0.00235
Relative error er =
ea
X
0.00235
=
37.46235
= 6.2729 × 10–5
Percentage error ep = er × 100 = 6.2729 × 10–3.
ERRORS 41
Example 9. Round-off the number 75462 to four significant digits and then
calculate the absolute error and percentage error.
Sol. Number rounded-off to four significant digits = 75460
Absolute error ea = | 75462 – 75460 | = 2
Relative error er =
ea
75462
2
75462
= = .0000265
Percentage error ep = er × 100 = .00265.
Example 10. Find the absolute, relative, and percentage errors if x is rounded-
off to three decimal digits. Given x = 0.005998.
Sol. Number rounded-off to three decimal digits =.006
Error = .005998 – .006 = – .000002
Absolute error ea = | error | = .000002
Relative error er =
ea
.005998
.000002
.005998
= = .0033344
Percentage error ep = er × 100 = .33344.
Example 11. Evaluate the sum S = 3 5 7
+ + to 4 significant digits and
find its absolute and relative errors.
Sol. 3 = 1.732, 5 = 2.236, 7 = 2.646
Hence, S = 6.614
and ea = .0005 + .0005 + .0005 = .0015.
The total absolute error shows that the sum is correct to 3 significant figures
only.
∴ We take, S = 6.61
then, er =
.0015
6.61
= 0.0002.
Example 12. It is necessary to obtain the roots of X2 – 2X + log10 2 = 0 to four
decimal places. To what accuracy should log10 2 be given?
Sol. Roots of X2 – 2X + log10 2 = 0 are given by
X =
2 4 4 2
2
1 1 2
10
10
± −
= ± −
log
log
∴ | ΔX | =
1
2
2
1 2
Δ(log )
log
−
< 0.5 × 10–4
or Δ(log 2) < 2 × .5 × 10–4 (1 – log 2)1/2 < .83604 × 10–4 ≈ 8.3604 × 10–5.
42 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 2.1
1. Round-off the following numbers correct to four significant digits:
3.26425, 35.46735, 4985561, 0.70035, 0.00032217, 1.6583, 30.0567, 0.859378, 3.14159.
2. The height of an observation tower was estimated to be 47 m. whereas its actual height
was 45 m. Calculate the percentage of relative error in the measurement.
3. If the number p is correct to three decimal places, what will be the error?
4. If true value =
10
3
, approximate value = 3.33, find the absolute and relative errors.
5. Round-off the following numbers to two decimal places.
48.21416, 2.3742, 52.275, 2.375, 2.385, 81.255.
6. Calculate the value of 102 101
− correct to four significant digits.
7. If X = 2.536, find the absolute error and relative error when
(i) X is rounded-off
(ii) X is truncated to two decimal digits.
8. If π =
22
7
is approximated as 3.14, find the absolute error, relative error, and percentage
of relative error.
9. Given the solution of a problem as X′ = 35.25 with the relative error in the solution
atmost 2%, find, to four decimal digits, the range of values within which the exact value
of the solution must lie.
10. Given that:
a = 10.00 ± 0.05, b = 0.0356 ± 0.0002
c = 15300 ± 100, d = 62000 ± 500
Find the maximum value of the absolute error in
(i) a + b + c + d (ii) a + 5c – d (iii) d3.
11. What do you understand by machine epsilon of a computer? Explain.
12. What do you mean by truncation error? Explain with examples.
2 . 4 A GENERAL ERROR FORMULA
Let y = f (x1, x2) be a function of two variables x1, x2.
Let δx1, δx2 be the errors in x1, x2, then the error δy in y is given by
y + δy = f(x1 + δx1, x2 + δx2)
ERRORS 43
Expanding R.H.S. by Taylor’s series, we get
y + δy = f(x1, x2) +
∂
∂
+
∂
∂
F
HG I
KJ
f
x
x
f
x
x
1
1
2
2
δ δ
+ terms involving higher powers of δx1 and δx2 (1)
If the errors δx1, δx2 are so small that their squares and higher powers can
be neglected, then (1) gives
δy =
∂
∂
+
∂
∂
f
x
x
f
x
x
1
1
2
2
δ δ approximately
Hence, δy =
∂
∂
+
∂
∂
y
x
x
y
x
x
1
1
2
2
δ δ
In general, the error δy in the function
y = f(x1, x2, ......, xn)
corresponding to the errors δxi in xi (i = 1, 2, ......, n) is given by
δy ≈
∂
∂
+
∂
∂
+ +
∂
∂
y
x
x
y
x
x
y
x
x
n
n
1
1
2
2
δ δ δ
......
and the relative error in y is
er =
δ δ δ δ
y
y
y
x
x
y
y
x
x
y
y
x
x
y
n
n
=
∂
∂
+
∂
∂
+ +
∂
∂
1
1
2
2
. ...... . .
2.5 ERRORS IN NUMERICAL COMPUTATIONS
(1) Error in addition of numbers
Let X = x1 + x2 + ...... + xn
∴ X + ΔX = (x1 + Δx1) + (x2 + Δx2) + ...... + (xn + Δxn)
The absolute error is
∴ ΔX = Δx1 + Δx2 + ...... + Δxn
⇒
Δ Δ Δ Δ
X
X X X X
= + + +
x x xn
1 2
......
which is the relative error.
The maximum relative error is
Δ Δ Δ Δ
X
X X X X
≤ + + +
x x xn
1 2
...... .
44 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
It is clear that if two numbers are added then the magnitude of absolute
error in the result is the sum of the magnitudes of the absolute errors
in the two numbers.
While adding up several numbers of different absolute accuracies, the
following procedure is adopted:
(i) Isolate the number with the greatest absolute error.
(ii) Round-off all other numbers, retaining in them one digit more than in
the isolated number.
(iii) Add up.
(iv) Round-off the sum by discarding one digit.
(2) Error in subtraction of numbers
Let X = x1 – x2
∴ X + ΔX = (x1 + Δx1) – (x2 + Δx2)
= (x1 – x2) + (Δx1 – Δx2)
∴ ΔX = Δx1 – Δx2 is the absolute error
and
Δ Δ Δ
X
X X X
= −
x x
1 2
is the relative error.
The maximum relative error =
Δ Δ Δ
X
X X X
≤ +
x x
1 2
and The maximum absolute error = | ΔX | ≤ | Δx1 | + | Δx2 | .
(3) Error in product of numbers
Let X = x1 x2 ......, xn
We know that if X is a function of x1, x2, ......, xn
then, ΔX =
∂
∂
+
∂
∂
+ +
∂
∂
X X X
x
x
x
x
x
x
n
n
1
1
2
2
Δ Δ Δ
......
Now,
Δ
Δ Δ Δ
X
X X
X
X
X
X
X
=
∂
∂
+
∂
∂
+ +
∂
∂
1 1 1
1
1
2
2
x
x
x
x
x
x
n
n
......
NOTE
ERRORS 45
Now,
1 1
1
2 3
1 2 3 1
X
X
∂
∂
= =
x
x x x
x x x x x
n
n
. ......
......
1 1
2
1 3
1 2 3 2
X
X
∂
∂
= =
x
x x x
x x x x x
n
n
......
......
 
1 1
X
X
∂
∂
=
x x
n n
∴
Δ Δ Δ Δ
X
X
= + + +
x
x
x
x
x
x
n
n
1
1
2
2
...... .
∴ The relative and absolute errors are given by,
Maximum relative error =
Δ Δ Δ Δ
X
X
≤ + + +
x
x
x
x
x
x
n
n
1
1
2
2
......
Maximum absolute error =
Δ Δ
X
X
X =
X
X
. ( ...... )
x x x xn
1 2 3
(4) Error in division of numbers
Let, X =
x
x
1
2
∴
Δ
Δ Δ
X
X X
X
X
X
=
∂
∂
+
∂
∂
1 1
1
1
2
2
x
x
x
x
. .
=
Δ Δ Δ Δ
x
x
x
x
x
x
x
x
x
x
x
x
x
1
1
2
2
2
1
2
1
2
2
1
1
2
2
1
F
HG I
KJ
+
F
HG I
KJ
−
F
HG
I
KJ = −
.
∴
Δ Δ Δ
X
X
≤ +
x
x
x
x
1
1
2
2
which is relative error.
Absolute error = | ΔX | ≤
ΔX
X
. X.
46 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(5) Error in evaluating xk
X = xk , where k is an integer or fraction
ΔX =
d
dx
X
Δx = kxk – 1 . Δx
Δ Δ
X
X
= k
x
x
.
∴
Δ Δ
X
X
≤ k
x
x
.
The relative error in evaluating xk = k .
Δx
x
.
2 . 6 INVERSE PROBLEMS
Now we have to find errors in x1, x2, ......, xn, where X = f(x1, x2, ....., xn), to have a
desired accuracy.
We have Δ Δ Δ Δ
X
X X X
=
∂
∂
+
∂
∂
+ +
∂
∂
x
x
x
x
x
x
n
n
1
1
2
2 ......
According to the principle of equal effects,
∂
∂
=
∂
∂
= =
∂
∂
X X X
x
x
x
x
x
x
n
n
1
1
2
2
Δ Δ Δ
......
∴ ΔX = n
x
x
∂
∂
X
1
1
Δ
∴ Δx1 =
ΔX
X
n
x
∂
∂
F
HG I
KJ
1
Similarly, Δx2 =
ΔX
X
n
x
∂
∂ 2
and so on.
The above article is needed when we are to find errors in both independent
variables involved and error in dependent variable is given.
NOTE
ERRORS 47
EXAMPLES
Example 1. If u =
4x y
z
2 3
4
and errors in x, y, z be 0.001, compute the relative
maximum error in u when x = y = z = 1.
Sol. δu =
∂
∂
+
∂
∂
+
∂
∂
u
x
x
u
y
y
u
z
z
δ δ δ
=
8 12 16
3
4
2 2
4
2 3
5
x y
z
x
x y
z
y
x y
z
z
δ δ δ
+ −
Since the errors δx, δy, δz may be (+) ve or (–) ve, we take the absolute
values of terms on R.H.S. giving,
(δu)max. =
8 12 16
3
4
2 2
4
2 3
5
xy
z
x
x y
z
y
x y
z
z
δ δ δ
+ +
= 8(.001) + 12(.001) + 16(.001) = 0.036
∴ Maximum relative error =
.036
4
= .009.
Example 2. Find the relative error in the function
y ax x ...... x
1
m
2
m
n
m
1 2 n
= .
Sol. We have log y = log a + m1 log x1 + m2 log x2 + ...... + mn log xn
∴
1 1
1
1
1 2
2
2
y
y
x
m
x y
y
x
m
x
∂
∂
F
HG I
KJ = =
∂
∂
= , ...... etc.
∴ er =
∂
∂
+
∂
∂
+ +
∂
∂
y
x
x
y
y
x
x
y
y
x
x
y
n
n
1
1
2
2
. . ...... .
δ δ δ
= + + +
m
x
x
m
x
x m
x
x
n
n
n
1
1
1
2
2
2
δ
δ
δ
...... .
Since errors δx1, δx2 may be (+) ve or (–) ve we take the absolute values of
terms on R.H.S.
This gives,
(er)max. ≤ m1
δ δ δ
x
x
m
x
x
m
x
x
n
n
n
1
1
2
2
2
+ + +
...... .
48 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Corollary. If y = x1 x2 ......, xn
e
x
x
x
x
x
x
r
n
n
≈ + + +
δ δ δ
1
1
2
2
......
∴ The relative error of a product of n numbers is approximately equal to
the algebraic sum of their relative errors.
Example 3. Compute the percentage error in the time period T = 2π
l
g
for
l = 1 m if the error in the measurement of l is 0.01.
Sol. T = 2π
l
g
Taking log
log T = log 2π +
1
2
1
2
log log
l g
−
⇒
1 1
2
T
T =
δ
δl
l
δ δ
T
T
0.5%
× = × =
×
× =
100
2
100
01
2 1
100
l
l
.
.
Example 4. If u = 2 V6 – 5V, find the percentage error in u at V = 1 if error in V
is .05.
Sol. u = 2V6 – 5V
δu =
∂
∂
u
V
V
δ = (12 V5 – 5) δV
δ
δ
u
u
× =
−
−
F
HG
I
KJ ×
100
12 5
2 5
V
V V
V 100
5
6
.
=
( )
( )
(. )
12 5
2 5
05 100
−
−
× × = −
7
3
× 5 = – 11.667%
The maximum percentage error = 11.667%.
Example 5. If r = 3h(h6 – 2), find the percentage error in r at h = 1, if the
percentage error in h is 5.
Sol. δr =
∂
∂
r
h
h
δ = (21h6 – 6) δh
ERRORS 49
δ
δ
r
r
h
h h
h
× =
−
−
F
HG
I
KJ ×
100
21 6
3 6
100
6
7
=
21 6
3 6
100
15
3
5%
−
−
F
HG I
KJ ×
F
HG I
KJ =
−
δh
h ( )
. = – 25%
Percentage error =
δr
r
× =
100 25%.
Example 6. The discharge Q over a notch for head H is calculated by the formula
Q = kH5/2, where k is a given constant. If the head is 75 cm and an error of 0.15
cm is possible in its measurement, estimate the percentage error in computing
the discharge.
Sol. Q = kH5/2
log Q = log k +
5
2
log H
Differentiating,
δ δ
Q
Q
H
H
=
5
2
.
δQ
Q
.15
75
× = × × = =
100
5
2
0
100
1
2
0 5
. .
Example 7. The error in the measurement of the area of a circle is not allowed
to exceed 0.1%. How accurately should the diameter be measured?
Sol. A = π
d2
4
log A = log π + 2 log d – log 4
δ
δ
A
A
× = ×
100
2
100
d
d
( )
δd
d
× = =
100
0.1
2
.05.
Example 8. (i) Prove that the absolute error in the common logarithm of a
number is less than half the relative error of the given number.
(ii) Prove that the error in the antilogarithm is many times the error in the
logarithm.
Sol. (i) N = log10 x = .43429 loge x
Hence, ΔN = 0.43429
Δ Δ
x
x
x
x

F
HG I
KJ
1
2
.
50 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(ii) From (i), Δx =
xΔN
0.43429
= 2.3026 x(ΔN).
Example 9. Find the smaller root of the equation x2 – 32x + 1 = 0 correct to four
significant figures.
Sol. The roots of the equation x2 – 32x + 1 = 0 are
32 32 4
2
2
− −
( )
and
32 32 4
2
2
+ −
( )
The smaller root is
32 1020
2
16 255
−
= −
I Algorithm. Smaller root = 16 255
− = 16 – 15.97 = 0.03
II Algorithm. Smaller root
= ( ) .
.
.
16 255
16 255
16 255
1
16 15 97
1
31.97
0 0313
−
+
+
=
+
= =
The second algorithm is evidently a better one, as gives the result correct
to 4 figures.
Example 10. If X = x + e, prove that X x
e
2 X
− ≈ .
Sol. X X X X X
X
− = − − = − −
F
HG I
KJ
x e
e
1
1/2
= X X
X
− −
F
HG I
KJ
1
2
e
= X X
X X
– + ≈
e e
2 2
.
Example 11. In a ΔABC, a = 6 cm, c = 15 cm, ∠B = 90°. Find the possible error
in the computed value of A if the errors in measurements of a and c are 1 mm
and 2 mm respectively.
Sol. Here, tan A =
a
c
∴ A = tan–1
a
c
F
HG I
KJ
δA =
∂
∂
+
∂
∂
A A
a
a
c
c
δ δ
=
c
a c
a
a
a c
c
2 2 2 2
+
−
+
δ δ
ERRORS 51
or | . .
δ δ δ
A|≤
+
+
+
c
a c
a
a
a c
c
2 2 2 2
=
15
261
. (0.1)
6
261
. (0.2)
+ = .0103 radians
∴ δA ≤ .0103 radians.
Example 12. In a ΔABC, a = 30 cm, b = 80 cm, ∠B = 90°, find the maximum
error in the computed value of A if possible errors in a and b are
1
3
% and
1
4
%,
respectively.
Sol. sin A =
a
b
⇒ A = sin–1
a
b
F
HG I
KJ
|δ δ δ
A|
A A
∂
∂
+
∂
∂
a
a
b
b (2)
Here,
δa
a
× =
100
1
3
∴ δa = 0.1
δb
b
× =
100
1
4
∴ δb = 0.2
∴
∂
∂
=
−
A
a b a
1
2 2
,
∂
∂
=
−
−
A
b
a
b b a
2 2
Substituting in (2), we get δA  .00135 + .00100  .00235.
Example 13. The approximate values of
1
7
and
1
11
correct to 4 decimal places
are 0.1429 and 0.0909, respectively. Find the possible relative error and absolute
error in the sum of .1429 and .0909.
Sol. Numbers 0.1429 and 0.0909 are correct to four places of decimal. The
maximum error in each case is
1
2
× .0001 = 0.00005.
(i) Relative error
| | | | |
|
.
.
.
.
Δ Δ Δ
X|
|X| |X| X|
1 2
 +  +
x x 0 00005
0 2338
0 00005
0 2338
(∵ X = x1 + x2)
ΔX
X
0.0001
0.2338
.00043
 = .
52 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(ii) Absolute error
ΔX = Δx1 + Δx2 = 0.00005 + 0.00005 = 0.0001.
Example 14. The approximate values of
1
7
and
1
15
, correct to four decimal
places, are 0.1429 and 0.0667 respectively. Find the relative error for the sum of
0.1429 and 0.0667.
Sol.
ΔX
X
0.0001
0.2096
0.000477
 = .
Example 15. 29 = 5.385 and 11 = 3.317 are correct to four significant figures.
Find the relative error in their sum and difference.
Sol. Numbers 5.385 and 3.317 are correct to four significant figures
∴ The maximum error in each case is
1
2
× 10–3 = 0.0005
∴ Δx1 = Δx2 = 0.0005
The relative error in their sum is
Δ Δ Δ
X
X X X
1
≤ +
x x2
| ∵ X = x1 + x2 = 8.702
≤ +  × −
0 0005
8 702
0 0005
8 702
149 10 4
.
.
.
.
1.
The relative error in their difference is
Δ Δ Δ
X
X X X
≤ +
x x
1 2
, where X = x1 – x2 = 2.068
≤ +  × −
0 0005
2 068
0 0005
2 068
4 835 10 4
.
.
.
.
. .
Example 16. Sum the following numbers: 0.1532, 15.45, 0.000354, 305.1, 8.12,
143.3, 0.0212, 0.643, and 0.1734, where digits are correct.
Sol. 305.1 and 143.3 have the greatest absolute error of .05 in each.
Rounding-off all other numbers to two decimal digits, we have 0.15, 15.45,
0.00, 8.12, 0.02, 0.64, and 0.17.
The sum S is given by
S = 305.1 + 143.3 + 0.15 + 15.45 + 0.00 + 8.12 + 0.02 + 0.64 + 0.17
= 472.59 = 472.6.
ERRORS 53
To determine the absolute error, we note that the first two numbers have
absolute errors of 0.05 and the remaining seven numbers have absolute errors
of 0.005 each.
∴ The absolute error in all 9 numbers
= 2(0.05) + 7(0.005) = 0.1 + 0.035 = 0.135 ≈ 0.14.
In addition to the above absolute error, we have to take into account the
rounding error, which is 0.01. Hence the total absolute error in
S = 0.14 + 0.01 = 0.15
Thus, S = 472.6 ± 0.15.
Example 17. 5.5 = 2.345 and 6.1 = 2.470 correct to four significant figures.
Find the relative error in taking the difference of these numbers.
Sol. The maximum error in each case =
1
2
× 0.001 = 0.0005
∴ The relative error 
Δ Δ
x x
1 2
X X
+ = =
F
HG I
KJ =
2 2
0 0005
0
0 008
1
Δx
X .125
.
. .
Example 18. 10 = 3.162 and e ~
– 2.718 correct to three decimal places. Find
the percentage error in their difference.
Sol. Relative error = 2 ×
0 0005
3 2 718
0 001
444
.
( . )
.
.
.162 −
=
∴ Percentage error = × 
0.001
100 0.23
.444
.
Example 19. Find the product of 346.1 and 865.2. State how many figures of
the result are trustworthy, given that the numbers are correct to four significant
figures.
Sol. Δx1 = 0.05, Δx2 = 0.05
X = 346.1 × 865.2 = 299446 (correct to 6 digits)
Maximum relative error (er) ≤
Δ Δ
x
x
x
x
1
1
2
2
+
=
0 05
346.1
0 05
865 2
. .
.
+
= 0.000144 + 0.000058 = 0.000202
∴ Absolute error = er . X = 0.000202 × 299446 ~
– 60
54 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ The true value of the product of the numbers given lies between
299446 – 60 = 299386 and 299446 + 60 = 299506.
The mean of these values is
299386 299506
2
+
= 299446
which is 299.4 × 103, correct to four significant digits. There is some uncertainty
about the last digit.
Example 20. Two numbers are given as 2.5 and 48.289, both of which are
correct to the significant figures given. Find their product.
Sol. 2.5 is the number with the greatest absolute error. Rounding-off the other
number to three significant digits, we get 48.3.
Their product is given by,
P = 48.3 × 2.5 = 120.75 = 1.2 × 102
where, we have retained only two significant digits.
Example 21. Find the relative error in calculation of
7.342
0.241
. Numbers are correct
to three decimal places. Determine the smallest interval in which true result
lies.
Sol. Δx1 = Δx2 = 0.0005
Relative error ≤
0 0005
7
0 0005
0
. .
.342 .241
+
≤ +
F
HG I
KJ
0 0005
1
7
1
.
.342 .241
= 0.0021
Absolute error = 0.0021 ×
x
x
1
2
0 0021
7
0 0639
= × =
. .
.342
0.241
Now,
x
x
1
2
=
7.342
0.241
= 30.4647
∴ The true value of x1/x2 lies between 30.4647 – 0.0639 = 30.4008 and
30.5286.
Example 22. Find the number of trustworthy figures in (0.491)3, assuming
that the number 0.491 is correct to the last figure.
Sol. Relative error er = k
Δ x
x
= 3 .
0.0005
0.491
= 0.003054989
ERRORS 55
Absolute error  er . X
= (0.003054989) . (0.491)3
= 0.000361621
The error affects the fourth decimal place, therefore X is correct to three
decimal places.
Example 23. If R =
1
2
r
h
h
2
+
F
HG
I
KJ and the error in R is at the most 0.4%, find the
percentage error allowable in r and h when r = 5.1 cm and h = 5.8 cm.
Sol. Percentage error in R =
ΔR
R
× 100 = 0.4
∴ ΔR =
0
100
.4
R
× =
0 4
100
1
2
5
5 8 0 0206
2
. ( )
. .
× +
L
NM O
QP=
.1
5.8
(i) Percentage error in r =
Δr
r
× 100
=
1
r
.
ΔR
r
2
R
∂
∂
F
H
GG
I
K
JJ
× 100 ∵ 2
2
∂
∂
R
r
r
h
=
=
F
HG I
KJ
=
100 50
2
r r
h
h
r
.
Δ
Δ
R
2
R
=
50 5.8
(5.1)2
×
× =
0 0206 0 22968%
. .
(ii) Percentage error in h =
Δh
h
× 100
=
100 100
2
2
1
2
2
2
h
h
h r
h
×
∂
∂
F
HG I
KJ
=
− +
L
NM O
QP
Δ Δ
R
2
R
R
.
=
100
1
100
5
0 0206
0 773186 1
2
2
h r
h
.
.
( . )
ΔR
.8
− +
F
HG
I
KJ
= ×
− +
=
2.
5.8 0.2268
1.
06
5659%
×
= .
56 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 24. Calculate the value of x – x cos θ correct to three significant figures
if x = 10.2 cm, and θ = 5°. Find permissible errors also in x and θ.
Sol. θ = 5° =
5
180
11
126
π
= radian
1 – cos θ = 1 – 1
2 4
2 4
− +
L
NM O
QP
θ θ
! !
– ......
=
θ θ
2 4 2 4
2 4
1
2
11
126
1
24
11
126
! !
...... ......
− + =
F
HG I
KJ −
F
HG I
KJ +
= 0.0038107 – 0.0000024
~
_ 0.0038083
∴ X = x(1 – cos θ)
= 10.2 (0.0038083)
= 0.0388446 ~ 0.0388
Further, Δx =
ΔX
X
2
0 0005
2 0 0038083
0 0656
∂
∂
F
HG I
KJ
=
×
x
.
.
~
– .
Δθ =
ΔX
X
2
0 0005
2
0 0005
2 10 2 0 0871907
∂
∂θ
F
HG I
KJ
= =
× ×
.
sin
.
. .
x θ
where sin θ = θ
θ
− + = −
F
HG I
KJ + =
3 3
3
11
126
1
6
11
126
0 0871907
!
...... ...... .
∴ Δθ =
0 0005
20 4 0 0871907
0 0002809 0 00028
.
. .
~
– . ~
– .
×
.
2.7. ERROR IN A SERIES APPROXIMATION
The error committed in a series approximation can be evaluated by using the
remainder after n terms.
Taylor’s series for f(x) at x = a is given by
f(x) = f(a) + (x – a) f ′(a) +
( )
!
x a
− 2
2
f ″(a) + ...... +
( )
( ) !
( ) ( )
( )
x a
n
f a x
n
n
n
−
−
+
−
−
1
1
1
R
where Rn(x) =
( )
!
( )
( )
x a
n
f
n
n
−
ξ ; a  ξ  x.
ERRORS 57
For a convergent series, Rn(x) → 0 as n → ∞. If we approximate f(x) first by
n terms of series, then by maximum error committed, we get Rn(x).
If the accuracy required is specified in advance, it would be possible to find
n, the number of terms such that the finite series yields the required accuracy.
EXAMPLES
Example 1. Find the number of terms of the exponential series such that their
sum gives the value of ex correct to six decimal places at x = 1.
Sol. ex = 1 + x +
x x x
n
x
n
n
2 3 1
2 3 1
! !
......
( ) !
( )
+ + +
−
+
−
R (3)
where Rn(x) =
x
n
n
!
eθ, 0  θ  x
Maximum absolute error (at θ = x) =
x
n
e
n
x
!
and Maximum relative error =
x
n
n
!
Hence, (er)max. at x = 1 is =
1
n !
For a six decimal accuracy at x = 1, we have
1 1
2
10 6
n !
 × −
i.e., n !  2 × 106
which gives n = 10.
Hence we need 10 terms of series (3) to ensure that its sum is correct to 6
decimal places.
Example 2. Use the series
log
1 x
1 x
2 x
x
3
x
5
......
e
3 5
+
−
F
HG I
KJ = + + +
F
HG
I
KJ
to compute the value of log (1.2) correct to seven decimal places and find the
number of terms retained.
Sol. loge
1
1
2
3 5 2 1
3 5 2 1
+ x
x
x
x x x
n
n
−
F
HG I
KJ = + + + +
−
F
HG
I
KJ
−
... + Rn(x)
58 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
If we retain n terms, then
Rn(x) =
2
2 1
1
1
2 1
x
n
n
e
+
+
+
−
F
HG I
KJ
log
ξ
ξ
; 0  ξ  x
Maximum absolute error (at ξ = x) =
2
2 1
1
1
2 1
x
n
x
x
n
e
+
+
+
−
F
HG I
KJ
log
and maximum relative error =
2
2 1
n +
x2n+1
Let
1
1
+
−
x
x
= 1.2 ⇒ x =
1
11
Hence (er)max. at x =
1
11
is
2
2 1
1
11
2 1
n
n
+
F
HG I
KJ
+
.
For seven decimal accuracy,
2
2 1
1
11
1
2
10
2 1
7
n
n
+
F
HG I
KJ  ×
+
−
.
(2n + 1) (11)2n + 1  4 × 107
which gives n ≥ 3.
Hence, retaining the first three terms of the given series, we get
loge (1.2) = 2
3 5
3 5
x
x x
+ +
F
HG
I
KJ at x =
F
HG I
KJ
1
11
= 0.1823215 .
Example 3. The function f(x) = tan–1x can be expanded as
tan–1x = x
x
3
x
5
...... ( 1) .
x
2n 1
3 5
n 1
2n 1
− + − + −
−
−
−
+ ......
Find n such that the series determines tan–1(1) correct to eight significant
digits.
Sol. If we retain n terms, then (n + 1)th term = (– 1)n .
x
n
n
2 1
2 1
+
+
For x = 1, (n + 1)th term =
( )
−
+
1
2 1
n
n
ERRORS 59
For the determination of tan–1 (1) correct up to eight significant digit
accuracy,
( )
−
+
 × −
1
2 1
1
2
10 8
n
n
⇒ 2n + 1  2 × 108
such as n = 108 + 1.
Example 4. The function f(x) = cos x can be expanded as
cos x = 1 –
x
2 !
x
4 !
x
6 !
2 4 6
+ − + ...
Compute the number of terms required to estimate cos
π
4
F
HG I
KJ so that the result
is correct to at least two significant digits.
Sol. cos x = 1 –
x x x
2 4 6
2 4 6
! ! !
+ − + ... + Rn(x)
where Rn(x) = (– 1)n x
n
n
2
2 !
cos ξ; 0  ξ  x
Maximum absolute error (at ξ = x) = ( )
( )!
cos
−1
2
2
n
n
x
n
x =
x
n
n
2
2
( )!
cos x
Maximum relative error =
x
n
n
2
2
( )!
At x =
π
4
, (er)max. =
( / )
( ) !
π 4
2
2n
n
For two significant digit accuracy,
( / )
( ) !
π 4
2
1
2
2n
n
≤ × 10–2
i.e.,
( ) !
( / )
2
4 2
n
n
π
≥ 200
n = 3 satisfies it.
60 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 2.2
1. If R = 4xy2z–3 and errors in x, y, z be 0.001, show that the maximum relative error at
x = y = z = 1 is 0.006.
2. If R = 10x3y2z2 and errors in x, y, z are 0.03, 0.01, 0.02 respectively at x = 3, y = 1, z = 2.
Calculate the absolute error and percentage relative error in evaluating R.
3. If R = 4x2y3z–4, find the maximum absolute error and maximum relative error in R when
errors in x = 1, y = 2, z = 3, respectively, are equal to 0.001, 0.002, 0.003.
4. If u =
5 2
3
xy
z
and errors in x, y, z are 0.001 at x = 1, y = 1, z = 1, calculate the maximum
relative error in evaluating u.
5. Find the number of terms of the exponential series such that their sum yields the value
of ex correct to 8 decimal places at x = 1.
6. Find the product of the numbers 56.54 and 12.4, both of which are correct to the significant
digits given.
7. Find the quotient q =
x
y
, where x = 4.536 and y = 1.32; both x and y being correct to the
digits given. Find also the relative error in the result.
8. Write a short note on error in a series approximation.
9. Explain the procedure of adding several numbers of different absolute accuracies.
10. Find the smaller root of the equation x2 – 30x + 1 = 0 correct to three decimal places.
State different algorithms. Which algorithm is better and why?
11. Write a short note on Errors in numerical computation.
2.8 MATHEMATICAL PRELIMINARIES
Following are certain mathematical results which would be useful in the sequel.
Theorem 1. If f(x) is continuous in a ≤ x ≤ b and if f(a) and f(b) are of opposite
signs then f(c) = 0 for at least one number c such that a  c  b.
Theorem 2. Rolle’s theorem.
If (i) f(x) in continuous in [a, b] (ii) f ′(x) exists in (a, b)
(iii) f(a) = f(b) = 0.
then ∃ at least one value of x, say c, such that
f ′(c) = 0, a  c  b.
ERRORS 61
Theorem 3. Mean value theorem for derivatives.
If (i) f(x) is continuous in [a, b] (ii) f ′(x) exists in (a, b)
then, ∃ at least one value of x, say c, between a and b such that
f ′(c) =
f b f a
b a
( ) ( )
−
−
, a  c  b.
Theorem 4. Taylor’s series for a function of one variable. If f(x) is
continuous and possesses continuous derivatives of order n in an interval that
includes x = a, then in that interval
f(x) = f(a) + (x – a) f ′(a) +
( )
!
x a
− 2
2
f ″(a) + ...... +
( )
( ) !
( ) ( )
( )
x a
n
f a x
n
n
n
−
−
+
−
−
1
1
1
R
where Rn(x) is remainder term, can be expressed in the form
Rn(x) =
( )
!
( )
x a
n
f c
n
n
−
, a  c  x.
Theorem 5. Maclaurin’s expansion.
f(x) = f(0) + x f ′(0) +
x
f
x
n
f
n
n
2
2
0 0
!
( ) ......
!
( ) ......
( )
″ + + +
Theorem 6. Taylor’s series for a function of two variables.
f(x1 + Δx1, x2 + Δx2) = f(x1, x2) +
∂
∂
+
∂
∂
f
x
x
f
x
x
1
1
2
2
Δ Δ
+
1
2
2
2
1
2 1
2
2
1 2
1 2
2
2
2 2
2
∂
∂
+
∂
∂ ∂
+
∂
∂
L
NMM
O
QPP
f
x
x
f
x x
x x
f
x
x
( ) . ( )
Δ Δ Δ Δ + ......
2.9 FLOATING POINT REPRESENTATION OF NUMBERS
There are two types of arithmetic operations available in a computer.
They are:
(i) Integer arithmetic (ii) Real or floating point arithmetic.
Integer arithmetic deals with integer operands and is used mainly in
counting and as subscripts. Real arithmetic uses numbers with fractional parts
as operands and is used in most computations. Computers are usually designed
such that each location, called word, in memory stores only a finite number of
digits. Consequently, all operands in arithmetic operations have only a finite
number of digits.
62 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Let us assume a hypothetical computer having memory in which each
location can store 6 digits and having provision to store one or more signs. One
method of representing real numbers in that computer would be to assume a
fixed position for the decimal point and store all numbers after appropriate
shifting if necessary with an assumed decimal point.
5 6 5 2 3 1
assumed
decimal point
position
+
One memory
location or word
sign
A memory location storing number 5652.31
In such a convention, the maximum and minimum possible numbers to be
stored are 9999.99 and 0000.01, respectively, in magnitude. This range is quite
inadequate in practice.
For this, a new convention is adopted that aims to preserve the maximum
number of significant digits in a real number and also increase the range of
values of real numbers stored. This representation is called the normalized
floating point mode of representing and storing real numbers.
In this mode, a real number is expressed as a combination of a mantissa
and an exponent. The mantissa is made less than 1 or ≥ .1 and the exponent is
the power of 10 which multiplies the mantissa.
For example, the number 43.76 × 106 is represented in this notation as
.4376 E 8, where E 8 is used to represent 108. The mantissa is .4376 and the
exponent is 8.
The number is stored in memory location as:
4 3 7 6 0 8
+ +
sign of exponent
sign of mantissa
mantissa exponent
implied
decimal point
.
Moreover, the shifting of the mantissa to the left until its most significant
digit is non-zero is called normalization.
For example, the number .006831 may be stored as .6831 E–2 because the
leading zeros serve only to locate the decimal point.
ERRORS 63
The range of numbers that may be stored is .9999 × 1099 to .1000 × 10–99 in
magnitude, which is obviously much larger than that used earlier in fixed
decimal point notation.
This increment in range has been obtained by reducing the number of
significant digits in a number by 2.
2.10 ARITHMETIC OPERATIONS WITH NORMALIZED FLOATING
POINT NUMBERS
2.10.1 Addition and Subtraction
If two numbers represented in normalized floating point notation are to be
added, the exponents of the two numbers must be made equal and the Mantissa
shifted appropriately. The operation of subtraction is nothing but the addition
of a negative number. Thus the principles are the same.
EXAMPLES
Example 1. Add the following floating point numbers:
(i) .4546 E 5 and .5433 E 5
(ii) .4546 E 5 and .5433 E 7
(iii) .4546 E 3 and .5433 E 7
(iv) .6434 E 3 and .4845 E 3
(v) .6434 E 99 and .4845 E 99.
Sol. (i) Here the exponents are equal ∴ Mantissas are added
∴ Sum = .9979 E 5
(ii) Here exponents are not equal. The operand with the larger exponent is
kept as it is
.5433 E 7
+ .0045 E 7 | .4546 E 5 = .0045 E 7
.5478 E 7
(iii) The addition will be as follows:
.5433 E 7
+ .0000 E 7 | ∵ .4546 E 3 = .0000 E 7
.5433 E 7
64 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(iv) The exponents are equal but when the mantissas are added, the sum is
1.1279 E 3. As the mantissa has 5 digits and is  1, it is shifted right one
place before it is stored.
Hence Sum = .1127 E 4
(v) Here, again the sum of the mantissas exceeds 1. The mantissa is shifted
right and the exponent increased by 1, resulting in a value of 100 for the
exponent. The exponent part cannot store more than two digits. This
condition is called an overflow condition and the arithmetic unit will
intimate an error condition.
Example 2. Subtract the following floating point numbers:
(i) .9432 E – 4 from .5452 E – 3 (ii) .5424 E 3 from .5452 E 3
(iii) .5424E – 99 from .5452 E – 99.
Sol. (i) .5452 E – 3
– .0943 E – 3
.4509 E – 3
(ii) .5452 E 3
– .5424 E 3
.0028 E 3
In a normalized floating point, the mantissa is ≥ .1
Hence, the result is .28 E 1
(iii) .5452 E – 99
– .5424 E – 99
.0028 E – 99
For normalization, the mantissa is shifted left and the exponent is reduced
by 1. The exponent would thus become – 100 with the first left shift, which can
not be accommodated in the exponent part of the number.
This condition is called an underflow condition and the arithmetic unit
will signal an error condition.
If the result of an arithmetic operation gives a number smaller than
.1000 E – 99 then it is called an underflow condition. Similarly, any result
greater than .9999 E 99 leads to an overflow condition.
NOTE
ERRORS 65
Example 3. In normalized floating point mode, carry out the following
mathematical operations:
(i) (.4546 E 3) + (.5454 E 8) (ii) (.9432 E – 4) – (.6353 E – 5).
Sol. (i) .5454 E 8
+ .0000 E 8 | ∵ .4546 E 3 = .0000 E 8
.5454 E 8
(ii) .9432 E – 4
– .0635 E – 4 | ∵ .6353 E – 5 = .0635 E – 4
.8797 E – 4
2.10.2 Multiplication
Two numbers are multiplied in the normalized floating point mode by
multiplying the mantissas and adding the exponents. After the multiplication
of the mantissas, the resulting mantissa is normalized as in an addition or
subtraction operation, and the exponent is appropriately adjusted.
EXAMPLES
Example 1. Multiply the following floating point numbers:
(i) .5543 E 12 and .4111 E – 15 (ii) .1111 E 10 and .1234 E 15
(iii) .1111 E 51 and .4444 E 50 (iv) .1234 E – 49 and .1111 E – 54.
Sol. (i) .5543 E 12 × .4111 E – 15 = .2278 E – 3
(ii) .1111 E 10 × .1234 E 15 = .1370 E 24
(iii) .1111 E 51 × .4444 E 50 = .4937 E 100
The result overflows.
(iv) .1234 E – 49 × .1111 E – 54 = .1370 E – 104
The result underflows.
Example 2. Apply the procedure for the following multiplications:
(.5334 × 109) * (.1132 × 10–25)
(.1111 × 1074) * (.2000 × 1080)
Indicate if the result is overflow or underflow.
Sol. (i) .5334 E 9 × .1132 E – 25 = .6038 E – 17
(ii) .1111 E 74 × .2000 E 80 = .2222 E 153
Hence the above result overflows.
66 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
2.10.3 Division
In division, the mantissa of the numerator is divided by that of the denominator.
The denominator exponent is subtracted from the numerator exponent. The
quotient mantissa is normalized to make the most significant digit non-zero
and the exponent is appropriately adjusted. The mantissa of the result is
chopped down to 4 digits.
EXAMPLES
Example 1. Perform the following operations:
(i) .9998 E 1 ÷ .1000 E – 99 (ii) .9998 E – 5 ÷ .1000 E 98
(iii) .1000 E 5 ÷ .9999 E 3.
Sol. (i) .9998 E 1 ÷ .1000 E – 99 = .9998 E 101
Hence the result overflows.
(ii) .9998 E – 5 ÷ .1000 E 98 = .9998 E – 104
Hence the result underflows.
(iii) .1000 E 5 ÷ .9999 E 3 = .1000 E 2.
Example 2. Evaluate, applying normalized floating point arithmetic, for the
following:
1 – cos x at x = .1396 radian
Assume cos (.1396) = .9903
Compare it when evaluated 2 sin2
x
2
Assume sin .0698 = .6974 E – 1.
Sol. 1 – cos (.1396) = .1000 E 1 – .9903 E 0
= .1000 E 1 – .0990 E 1 = .1000 E – 1
Now, sin
x
2
= sin (.0698) = .6974 E – 1
2 sin2 x
2
= (.2000 E 1) × (.6974 E – 1) × (.6974 E – 1)
= .9727 E – 2
The value obtained by the alternate formula is closer to the true value
.9728 E – 2.
ERRORS 67
Example 3. For x = .4845 and y = .4800, calculate the value of
x y
x y
2 2
−
+
using normalized floating point arithmetic. Compare with the value of (x – y).
Indicate the error in the former.
Sol. x + y = .4845 E 0 + .4800 E 0 = .9645 E 0
x2 = (.4845 E 0) × (.4845 E 0) = .2347 E 0
y2 = (.4800 E 0) × (.4800 E 0) = .2304 E 0
x2 – y2 = .2347 E 0 – .2304 E 0 = .0043 E 0
Now,
x y
x y
2 2
−
+
= .0043 E 0 ÷ .9645 E 0 = .4458 E – 2
Also, x – y = .4845 E 0 – .4800 E 0 = .0045 E 0 = .4500 E – 2
Relative error =
.4500 0.4458
.4500
.93%
−
= .
Example 4. For e = 2.7183, calculate the value of ex when x = .5250 E 1. The
expression for ex is
e 1 x
x
2 !
x
3 !
x
2 3
= + + + .
Sol. e.5250 E 1 = e5 * e.25
e5 = (.2718 E 1) × (.2718 E 1) × (.2718 E 1) × (.2718 E 1)
× (.2718 E 1)
= .1484 E 3
Also, e.25 = 1 + + +
(.25)
(.25)
2!
(.25)
3 !
2 3
= 1.25 + .03125 + .002604 = .1284 E 1
Now, e.5250 E 1 = (.1484 E 3) × (.1284 E 1) = .1905 E 3.
Example 5. Find the solution of the following equation using floating point
arithmetic with a 4 digit mantissa
x2 – 1000x + 25 = 0
Give comments or the result so obtained.
Sol. x2 – 1000 x + 25 = 0
⇒ x =
1000 10 10
2
6 2
± −
68 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now, 106 = .1000 E 7 and 102 = .1000 E 3
∴ 106 – 102 = .1000 E 7
∴ 10 10
6 2
− = .1000 E 4
∴ Roots are
.1000 E 4 + .1000 E 4
2
F
HG I
KJ and
.1000 E 4 – .1000 E 4
2
F
HG I
KJ
which are .1000 E 4 and .0000 E 4 respectively. One of the roots becomes zero
due to the limited precision allowed in calculation. Let us reformulate the
problem and remember that in a quadratic equation ax2 + bx + c = 0, the product
of roots is given by
c
a
, so the smaller root may be obtained by dividing (c/a) by
the larger root.
So, First root = .1000 E 4
and Second root =
25 2500
1
.1000 E 4
E 2
.1000 E 4
.2500 E
= = −
.
Such a situation may be recognized in an algorithm by checking to see if
b2  | 4 ac |.
Example 6. Find the smaller root of the equation x2 – 400 x + 1 = 0 using four
digit arithmetic.
Sol. Here b2   | 4ac | | See Example 5
The roots of the equation ax2 – bx + c = 0 are
b b ac
a
+ −
2
4
2
and
b b ac
a
− −
2
4
2
The product of the roots is
c
a
.
∴ The smaller root is
c a
b b ac
a
i e
c
b b ac
/
. .,
+ −
F
H
GG
I
K
JJ
+ −
2 2
4
2
2
4
Here a = 1 = .1000 E 1, b = 400 = .4000 E 3, c = 1 = .1000 E 1
b2 – 4ac = .1600 E 6 – .4000 E 1 = .1600 E 6 (to four digit accuracy)
∴ b ac
2
4
− = .4000 E 3
∴ Smaller root =
2 (.1000 E 1)
.4000 E 3 .4000 E 3
.2000 E 1
.8000 E 3
×
+
= = .25 E – 2 = .0025.
ERRORS 69
Example 7. Compute the middle value of numbers a = 4.568 and b = 6.762
using four digit arithmetic and compare the result by taking c = a +
b a
2
−
F
HG I
KJ.
Sol. a = .4568 E 1, b = .6762 E 1
Let c be the middle value of numbers, then
c
a b
=
+
= = =
2
5665
.4568 E 1+ .6762 E 1
.2000 E 1
.1133 E 2
.2000 E 1
E 1
.
However, if we use the formula
c = a +
b a
−
F
HG I
KJ
2
= .4568 E 1 +
.6762 E 1 E
E 1
−
F
HG I
KJ
.
.
4568 1
2000
= .4568 E 1 + .1097 E 1 = .5665 E 1
The results are the same.
Example 8. Obtain a second degree polynomial approximation to
f(x) = (1 + x)1/2, x ∈ [0, 0.1] using Taylor’s series expansion about x = 0. Use the
expansion to approximate f(0.05) and bound the truncation error.
Sol. f(x) = (1 + x)1/2, f(0) = 1
f ′(x) =
1
2
(1 + x)–1/2, f ′(0) =
1
2
f ″(x) = –
1
4
(1 + x)–3/2, f ″(0) = –
1
4
f ″′(x) =
3
8
(1 + x)–5/2
Taylor’s series expansion with remainder term may be written as
(1 + x)1/2 = 1 +
x x x
2 8
1
16 1
2 3
1/2 5
− +
+
[( ) ]
ξ
; 0  ξ  0.1
The truncation term is given by
T = (1 + x)1/2 – 1
2 8
1
16 1
2 3
1/2 5
+ −
F
HG
I
KJ =
+
x x x
.
[( ) ]
ξ
We have f(0.05) = 1 +
0 05
2
0 05
8
2
. ( . )
− = 0.10246875 × 101
70 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Bound of the truncation error, for x ∈ [0, 0.1] is
| T | ≤
( .1)
16 [(1+ )
.1
16
1/2
0 0
3
5
3
ξ ]
( )
≤ = 0.625 × 10–4.
Example 9. In a case of normalized floating point representation, associative
and distributive laws are not always valid. Give examples to prove this statement.
Or
If the normalization on the floating point is carried out at each stage, prove
the following:
(i) a(b – c) ≠ ab – ac
where a = .5555 E 1, b = .4545 E 1, c = .4535 E 1
(ii) (a + b) – c ≠ (a – c) + b
where a = .5665 E 1, b = .5556 E – 1, c = .5644 E 1.
Sol. This is a consequence of the normalized floating point representation that
the associative and the distributive laws of arithmetic are not always valid.
The following examples are chosen intentionally to illustrate the inaccura-
cies that may build up due to shifting and truncation of numbers in arithmetic
operations.
Non-distributivity of arithmetic
Let a = .5555 E 1
b = .4545 E 1
c = .4535 E 1
(b – c) = .0010 E 1 = .1000 E – 1
a(b – c) = (.5555 E 1) × (.1000 E – 1)
= (.0555 E 0) = .5550 E – 1
Also, ab = (.5555 E 1) × (.4545 E 1) = .2524 E 2
ac = (.5555 E 1) × (.4535 E 1) = .2519 E 2
∴ ab – ac = .0005 E 2 = .5000 E – 1
Thus, a(b – c) ≠ ab – ac
which shows the non-distributivity of arithmetic.
Non-associativity of arithmetic
Let a = .5665 E 1
b = .5556 E – 1
c = .5644 E 1
ERRORS 71
∴ (a + b) = .5665 E 1 + .5556 E – 1
= .5665 E 1 + .0055 E 1 = .5720 E 1
(a + b) – c = .5720 E 1 – .5644 E 1 = .0076 E 1 = .7600 E – 1
a – c = .5665 E 1 – .5644 E 1 = .0021 E 1 = .2100 E – 1
(a – c) + b = .2100 E – 1 + .5556 E – 1 = .7656 E – 1
Thus, (a + b) – c ≠ (a – c) + b
which proves the non-associativity of arithmetic.
2.11 MACHINE COMPUTATION
To obtain meaningful results for a given problem using computers, there are
five distinct phases:
(i) Choice of a method (ii) Designing the algorithm
(iii) Flow charting (iv) Programming
(v) Computer execution
A method is defined as a mathematical formula for finding the solution of
a given problem. There may be more than one method available to solve the
same problem. We should choose the method which suits the given problem
best. The inherent assumptions and limitations of the method must be studied
carefully.
Once the method has been decided, we must describe a complete and
unambiguous set of computational steps to be followed in a particular sequence
to obtain the solution. This description is called an algorithm. It may be
emphasized that the computer is concerned with the algorithm and not with
the method. The algorithm tells the computer where to start, what information
to use, what operations to be carried out and in which order, what information
to be printed, and when to stop.
An algorithm has five important features:
(1) finiteness: an algorithm must terminate after a finite number of steps.
(2) definiteness: each step of an algorithm must be clearly defined or the
action to be taken must be unambiguously specified.
(3) inputs: an algorithm must specify the quantities which must be read
before the algorithm can begin.
(4) outputs: an algorithm must specify the quantities which are to be
outputted and their proper place.
(5) effectiveness: an algorithm must be effective, which means that all
operations are executable.
72 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A flow-chart is a graphical representation of a specific sequence of steps
(algorithm) to be followed by the computer to produce the solution of a given
problem. It makes use of the flow chart symbols to represent the basic operations
to be carried out. The various symbols are connected by arrows to indicate the
flow of information and processing. While drawing a flow chart, any logical
error in the formulation of the problem or application of the algorithm can be
easily seen and corrected.
2.12 COMPUTER SOFTWARE
The purpose of computer software is to provide a useful computational tool for
users. The writing of computer software requires a good understanding of
numerical analysis and art of programming. Good computer software must
satisfy certain criteria of self-starting, accuracy and reliability, minimum
number of levels, good documentation, ease of use, and portability.
Computer software should be self-starting as far as possible. A numerical
method very often involves parameters whose values are determined by the
properties of the problem to be solved. For example, in finding the roots of an
equation, one or more initial approximations to the root have to be given. The
program will be more acceptable if it can be made automatic in the sense that
the program will select the initial approximations itself rather than requiring
the user to specify them.
Accuracy and reliability are measures of the performance of an algorithm
on all similar problems. Once an error criterion is fixed, it should produce
solutions of all similar problems to that accuracy. The program should be able
to prevent and handle most of the exceptional conditions like division by zero,
infinite loops, etc.
The structure of the program should avoid many levels. For example, many
programs used to find roots of an equation have three levels:
Program calls zero-finder (parameters, function)
Zero-finder calls function
Function subprogram
The more number of levels in the program, the more time is wasted in
interlinking and transfer of parameters.
Documentation that is accurate and easy to use is a very important criteria.
The program must have some comment lines or comment paragraphs at various
places giving explanation and clarification of the method used and steps
involved. Accurate documentation should clarify what kind of problems can be
solved using this software, what parameters are to be supplied, what accuracy
can be achieved, which method has been used, and other relevant details.
ERRORS 73
The criterion of portability means that the software should be made
independent of the computer being used as far as possible. Since most machines
have different hardware configuration, complete independence from the
machine may not be possible. However, the aim of writing the computer software
should be that the same program should be able to run on any machine with
minimum modifications. Machine-dependent constants, for example machine
error EPS, must be avoided or automatically generated. A standard dialect of
the programming language should be used rather than a local dialect.
Most of the numerical methods are available in the form of software, which
is a package of thoroughly tested, portable, and self documented subprograms.
The general purpose packages contain a number of subroutines for solving a
variety of mathematical problems that commonly arise in scientific and
engineering computation. The special purpose packages deal with specified
problem areas. Many computer installations require one or both types of
packages and make it available, on-line, to their users. Most of the software
packages are available for PCs also.
General Purpose Packages
IMSL: (International Mathematical and Statistical Library). The IMSL is
a general purpose library of over 900 subroutines written in ANSI Fortran
for solving a large number of mathematical and statistical problems.
NAG: (Numerical Algorithms Group). This package covers the basic areas
of mathematical and statistical computation. The package is available in
any one of the three languages ANSI Fortran, Algol 60 or Algol 68.
Special Purpose Packages
All the following packages are distributed by IMSL.
BLAS: (Basic Linear Algebra Subroutines). BLAS contains 38 ANSI Fortran
subroutines for the methods in numerical linear algebra. The objective is
fast computer execution.
B-Splines: A package of subroutines for performing calculations with piece-
wise polynomials.
DEPACK: (Differential Equations Package). DEPACK contains Fortran
subprograms for the integration of initial value problems in ordinary
differential equations. This package includes Runge-Kutta methods,
variable step, variable order Adams type methods, and backward
differentiation methods for stiff problems.
EISPACK: (Matrix Eigensystem Routines). EISPACK contains 51 Fortran
subprograms for computing the eigenvalues and/or eigenvectors of a matrix.
ELLPACK: (Elliptic Partial Differential Equations Solver). ELLPACK
contains over 30 numerical method modules for solving elliptic partial
differential equations in two dimensions with general domains and in three
dimensions with rectangular domains. The 5-point discretization is used
74 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
and the resulting system of equations is solved by Gauss elimination for
band matrices and by SOR iterations.
FISHPACK: (Routines for the Helmholtz Problems in Two or Three
Dimensions). FISHPACK contains a set of Fortran programs for solving
Helmholtz problems in two or three dimensions. There are separate
programs for rectangular, polar, spherical and cylindrical coordinates.
FUNPACK: (Special Function Subroutines). The FUNPACK package
contains Fortran and assembly language subroutines for evaluating
important special functions like exponential integral, elliptic integrals of
first and second kind, Bessel functions, Dawson integrals, etc.
ITPACK: (Iterative Methods). ITPACK contains Fortran subprograms for
iterative methods for solving linear system of equations. The package is
oriented towards the sparse matrices that arise in solving partial differential
equations and in other applications.
LINPACK: (Linear Algebra Package). LINPACK contains Fortran
subprograms for direct methods for general, symmetric, symmetric positive
definite, triangular, and tridiagonal matrices. The package also includes
programs for least-squares problems, along with the QR and singular value
decompositions of rectangular matrices.
MINPACK: MINPACK is a package of subroutines for solving systems of
nonlinear equations and nonlinear least-squares problems. The package
also includes programs for minimization and optimization problems.
QUADPACK: QUADPACK contains subroutines for evaluating a definite
integral.
Software packages for PCs are also available for most of the areas mentioned
above.
ASSIGNMENT 2.3
1. Represent 44.85 × 106 in normalized floating point mode.
2. Subtract the following two floating point numbers as
(i) .36143448 E 7 – .36132346 E 7
(ii) (.9682 E – 7) – (.3862 E – 9).
3. Explain underflow and overflow conditions of error in floating point’s addition and
subtraction.
4. Find the solution of the following equation using floating point arithmetic with 4-digit
mantissa.
x2 – 7x + 4 = 0
Give comments on the results so obtained.
ERRORS 75
5. Discuss the consequences of normalized floating point representation of numbers.
6. Calculate the value of x2 + 2x – 2 and (2x – 2) + x2
where x = .7320 E 0
using normalized floating point arithmetic and prove that they are not the same. Compare
with value of (x2 – 2) + 2x.
7. Find the value of (1 + x)2 and (x2 + 2x) + 1
when x = .5999 E – 2.
8. Find the value of
sin x ~
! !
− − +
x
x x
3 5
3 5
with an absolute error smaller than .005 for x = .2000 E 0 using normalized floating
point arithmetic with a 4 digit mantissa.
9. Write a short note on machine computation.
10. Prove the following consequence of the normalized floating point representation of
numbers by taking x = .6667
6x ≠ x + x + x + x + x + x.
11. Define normalized floating point representation of numbers and round off errors in
representation. Find the sum of 0.123 × 103 and 0.456 × 102 and write the result in three
digit mantissa form.
12. (i) Calculate the value of the polynomial
p3(x) = 2.75x3 – 2.95x2 + 3.16x – 4.67
for x = 1.07 using both chopping and rounding-off to three digits, proceeding through
the polynomial term by term from left to right.
(ii) Explain how floating point numbers are stored in computers. What factors affect
their accuracy and range?
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
C
onsider the equation of the form f(x) = 0.
If f(x) is a quadratic, cubic, or biquadratic expression, then algebraic
formulae are available for expressing the roots. But when f(x) is a
polynomial of higher degree or an expression involving transcendental
functions, for example, 1 + cos x – 5x, x tan x – cosh x, e–x – sin x, etc.,
algebraic methods are not available.
In this unit, we shall describe some numerical methods for the solution of
f(x) = 0, where f(x) is algebraic or transcendental or both.
3.1 BISECTION (OR BOLZANO) METHOD
This method is based on the repeated application of intermediate value property.
Let the function f(x) be continuous between a and b. For definiteness, let
f(a) be (–)ve and f(b) be (+)ve. Then the first approximation to the root is
x1 =
1
2
(a + b).
If f(x1) = 0, then x1 is a root of f(x) = 0, otherwise, the root lies between a and
x1 or x1 and b according to f(x1) is (+)ve or (–)ve. Then we bisect the interval as
before and continue the process until the root is found to the desired accuracy.
Chapter 3
ALGEBRAIC AND
TRANSCENDENTAL
EQUATIONS
77
78 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
In the adjoining figure, f(x1) is (+)ve so that the root lies between a and x1.
The second approximation to the root is x2 =
1
2
(a + x1). If f (x2) is (–)ve the
root lies between x1 and x2. The third approximation to the root is x3 =
1
2
(x1 +
x2), and so on.
Y
X
O
a x2
f(a) x3 x1 b
f(b)
y
=
f
(
x
)
Once the method of calculation has been decided, we must describe clearly
the computational steps to be followed in a particular sequence. These steps
constitute the algorithm of method.
3.2 ALGORITHM
Step 01. Start of the program
Step 02. Input the variables x1, x2 for the task
Step 03. Check f(x1) *f(x2)  0
Step 04. If yes, proceed
Step 05. If no exit and print error message
Step 06. Repeat 7-11 if conditions are not satisfied
Step 07. x0 = (x1 + x2)/2
Step 08. If f(x0) *f(x1)  0
Step 09. x2 = x0.
Step 10. ELSE
Step 11. x1 = x0
Step 12. Condition:
Step 13. | (x1-x2)/x1 |  maximum possible error or f(x0) = 0
Step 14. Print output
Step 15. End of program.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 79
3.3 FLOW-CHART
START
Define F(x)
Get the value of
interval (a, b),
error, iter
Initialize i = 1
Call subroutine
bisect mid
Y
is
F(mid)
 0
B = X
Yes
A = X
B
Subroutine
bisect
X = (A + B)/2
Iter + +
Print ITER, Xl
RETURN
X
Print iter, Xl
STOP
is
Abs (XI-X)
 Aerr
Yes
Yes
No
No
X
Y
i  iter
Print solution does
not converge
80 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.4 PROGRAM WRITING
Based on the flow-chart, we write the instructions in a code which the computer
can understand. A series of such instructions is called a program.
If there are any errors in the program, they will be pointed out by the
computer during compilation. After correcting compilation errors, the program
is executed with input data to check for logical errors which may be due to
misinterpretation of the algorithm. The process of finding the errors and
correcting them is called debugging.
3.5 ORDER OF CONVERGENCE OF ITERATIVE METHODS
Convergence of an iterative method is judged by the order at which the error
between successive approximations to the root decreases.
An iterative method is said to be kth order convergent if k is the largest
positive real number, such that
lim
i
i
i
k
e
e
→∞
+ 1
≤ A
where A is a non-zero finite number called asymptotic error constant and it
depends on derivative of f(x) at an approximate root x.
ei and ei+1 are the errors in successive approximations. kth order convergence
gives us the idea that in each iteration, the number of significant digits in each
approximation increases k times.
The error in any step is proportional to the kth power of the error in the
previous step.
3.6 ORDER OF CONVERGENCE OF BISECTION METHOD
In the Bisection method, the original interval is divided into half interval in
each iteration. If we take mid-points of successive intervals to be the
approximations of the root, one half of the current interval is the upper bound
to the error.
In Bisection method,
ei + 1 = 0.5 ei or
e
e
i
i
+ 1
= 0.5 (1)
where ei and ei + 1 are the errors in the ith and (i + 1)th iterations, respectively.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 81
Comparing (1) with
lim
i
i
i
k
e
e
→∞
+ 1
≤ A
we get k = 1 and A = 0.5
Thus the Bisection method is I order convergent, or linearly convergent.
3.7 CONVERGENCE OF A SEQUENCE
A sequence  xn  of successive approximations of a root x = α of the equation
f(x) = 0 is said to converge to x = α with order p ≥ 1 iff
| xn + 1 – α | ≤ c | xn – α |p, n ≥ 0
c being some constant greater than zero.
Particularly, if | xn + 1 – α | = c | xn – α |, n ≥ 0, 0  c  1 then convergence
is called geometric. Also, If p = 1 and 0  c  1, then convergence is called
linear or of first order. Constant c is called the rate of linear convergence.
Convergence is rapid or slow depending on whether c is near 0 or 1.
Using induction, the condition for linear convergence can be simplified to
the form
| xn – α | ≤ cn | x0 – α |, n ≥ 0, 0  c  1.
3.8 PROVE THAT BISECTION METHOD ALWAYS CONVERGES
Let [pn, qn] be the interval at nth step of bisection, having a root of the equation
f(x) = 0. Let xn be the nth approximation for the root. Then, initially, p1 = a and
q1 = b.
⇒ x1 = first approximation =
p q
1 1
2
+
F
HG I
KJ
⇒ p1  x1  q1
Now either the root lies in [a, x1] or in [x1, b].
∴ either [p2, q2] = [p1, x1] or [p2, q2] = [x1, q1]
⇒ either p2 = p1, q2 = x1 or p2 = x1, q2 = q1
⇒ p1 ≤ p2, q2 ≤ q1
Also, x2 =
p q
2 2
2
+
so that p2  x2  q2
82 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Continuing this way, we obtain that at nth step,
xn =
p q
n n
+
2
, pn  xn  qn
and p1 ≤ p2 ≤ ...... ≤ pn and q1 ≥ q2 ≥ ...... ≥ qn
∴  p1, p2, ......, pn, ......  is a bounded, non-decreasing sequence bounded
by b and  q1, q2, ......, qn, ......  is a bounded, non-increasing sequence of
numbers bounded by a.
Hence, both these sequences converge.
Let, lim
n → ∞
pn = p and lim
n → ∞
qn = q.
Now, since the length of the interval is decreasing at every step, we get
that
lim
n → ∞
(qn – pn) = 0 ⇒ q = p
Also, pn  xn  qn
⇒ lim pn ≤ lim xn ≤ lim qn
⇒ p ≤ lim xn ≤ q
⇒ lim xn = p = q (2)
Further, since a root lies in [pn, qn], we shall have
f(pn) . f(qn)  0
⇒ 0 ≥
→ ∞
lim
n
n n
f p f q
[ ( ) . ( )]
⇒ 0 ≥ f(p) . f(q)
⇒ 0 ≥ [f(p)]2
But, [f(p)]2 ≥ 0 being a square
∴ we get f(p) = 0
∴ p is a root of f(x) = 0 (3)
From (2) and (3), we see that xn converges necessarily to a root of equation
f(x) = 0
The method is not rapidly converging, but it is useful in the sense that it
converges surely.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 83
EXAMPLES
Example 1. Find the real root of the equation x log10 x = 1.2 by Bisection method
correct to four decimal places. Also write its program in C-language.
Sol. f(x) = x log10 x – 1.2
Since f(2.74) = – .000563 i.e., (–)ve
and f(2.75) = .0081649 i.e., (+)ve
Hence, the root lies between 2.74 and 2.75.
∴ First approximation to the root is
x1 =
2 74 2 75
2
. .
+
= 2.745
Now f(x1) = f(2.745) = .003798 i.e., (+)ve
Hence, the root lies between 2.74 and 2.745.
∴ Second approximation to the root is
x2 =
2 74 2 745
2
. .
+
= 2.7425
Now f(x2) = f(2.7425) = .001617 i.e., (+)ve
Hence, the root lies between 2.74 and 2.7425.
∴ Third approximation to the root is
x3 =
2 74 2 7425
2
. .
+
= 2.74125
Now f(x3) = f(2.74125) = .0005267 i.e., (+)ve
Hence, the root lies between 2.74 and 2.74125.
∴ Fourth approximation to the root is
x4 =
2 74 2 74125
2
. .
+
= 2.740625
Now f(x4) = f(2.740625) = – .00001839 i.e., (–)ve.
Hence, the root lies between 2.740625 and 2.74125.
∴ Fifth approximation to the root is
x5 =
2 740625 2 74125
2
. .
+
= 2.7409375
84 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now f(x5) = f(2.7409375) = .000254 i.e., (+)ve
Hence, the root lies between 2.740625 and 2.7409375.
∴ Sixth approximation to the root is
x6 =
2 740625 2 7409375
2
. .
+
= 2.74078125
Now f(x6) = f(2.74078125) = .0001178 i.e., (+)ve
Hence, the root lies between 2.740625 and 2.74078125.
∴ Seventh approximation to the root is
x7 =
2 740625 2 74078125
2
. .
+
= 2.740703125
Now f(x7) = f(2.740703125) = .00004973 i.e., (+)ve
Hence, the root lies between 2.740625 and 2.740703125
∴ Eighth approximation to the root is
x8 =
2 740625 2 740703125
2
. .
+
= 2.740664063
Now f(x8) = f(2.740664063) = .00001567 i.e., (+)ve
Hence, the root lies between 2.740625 and 2.740664063.
∴ Nineth approximation to the root is
x9 =
2 740625 2 740664063
2
. .
+
= 2.740644532
Since x8 and x9 are the same up to four decimal places, the approximate
real root is 2.7406. C-program for above problem is given below:
3.9 PROGRAM TO IMPLEMENT BISECTION METHOD
//...Included Header Files
#includestdio.h
#includemath.h
#includeconio.h
#includeprocess.h
#includestring.h
#define EPS 0.00000005
#define F(x) (x)*log10(x)–1.2
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 85
//...Function Prototype Declaration
void Bisect();
//...Global Variable Declaration field
int count=1,n;
float root=1;
//... Main Function Implementation
void main()
{
clrscr();
printf(n Solution by BISECTION method n);
printf(n Equation is );
printf(nttt x*log(x) – 1.2 = 0nn);
printf(Enter the number of iterations:);
scanf(%d,n);
Bisect();
getch();
}
//... Function Declaration
void Bisect()
{
float x0,x1,x2;
float f0,f1,f2;
int i=0;
/*Finding an Approximate ROOT of Given Equation, Having
+ve Value*/
for(x2=1;;x2++)
{
f2=F(x2);
if (f20)
{
break;
}
}
/*Finding an Approximate ROOT of Given Equation, Having
-ve Value*/
86 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
for(x1=x2-1;;x2--)
{
f1=F(x1);
if(f10)
{
break;
}
}
//...Printing Result
printf(tt-----------------------------------------);
printf(ntt ITERATIONStt ROOTSn);
printf(tt-----------------------------------------);
for(;count=n;count++)
{
x0=(x1+x2)/2.0;
f0=F(x0);
if(f0==0)
{
root=x0;
}
if(f0*f10)
{
x2=x0;
}
else
{
x1=x0;
f1=f0;
}
printf(ntt ITERATION %d, count);
printf(t :t %f,x0);
if(fabs((x1-x2)/x1)  EPS)
{
printf(ntt---------------------------------);
printf(ntt Root = %f,x0);
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 87
printf(ntt Iterations = %dn, count);
printf(tt------------------------------------);
getch();
exit(0);
}
}
printf(ntt----------------------------------------);
printf(nttt Root = %7.4f,x0);
printf(nttt Iterations = %dn, count-1);
printf(tt------------------------------------------);
getch();
}
OUTPUT
Solution by BISECTION method
Equation is
x* log(x) - 1.2=0
Enter the number of iterations: 30
-----------------------------------------
ITERATIONS ROOTS
-----------------------------------------
ITERATION 1: 2.500000
ITERATION 2: 2.750000
ITERATION 3: 2.625000
ITERATION 4: 2.687500
ITERATION 5: 2.718750
ITERATION 10: 2.741211
ITERATION 11: 2.740723
ITERATION 12: 2.740479
ITERATION 13: 2.740601
ITERATION 14: 2.740662
ITERATION 15: 2.740631
ITERATION 16: 2.740646
ITERATION 17: 2.740639
ITERATION 18: 2.740643
ITERATION 19: 2.740644
ITERATION 20: 2.740645
88 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ITERATION 21: 2.740646
ITERATION 22: 2.740646
ITERATION 23: 2.740646
ITERATION 24: 2.740646
ITERATION 25: 2.740646
ITERATION 26: 2.740646
ITERATION 27: 2.740646
ITERATION 28: 2.740646
ITERATION 29: 2.740646
ITERATION 30: 2.740646
-----------------------------------------
Root = 2.7406
Iterations = 30
-----------------------------------------
C:tcexe
Example 2. Find a root of the equation
x3 – 4x – 9 = 0
using Bisection method in four stages.
Sol. Let f(x) ≡ x3 – 4x – 9
Since f(2.706) = – .009488 i.e., (–)ve
and f(2.707) = .008487 i.e., (+)ve
Hence, the root lies between 2.706 and 2.707.
∴ First approximation to the root is
x1 =
2 706 2 707
2
. .
+
= 2.7065
Now f(x1) = – .0005025 i.e., (–)ve
Hence, the root lies between 2.7065 and 2.707.
∴ Second approximation to the root is
x2 =
2 7065 2 707
2
. .
+
= 2.70675
Now f(x2) = .003992 i.e., (+)ve
Hence, the root lies between 2.7065 and 2.70675.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 89
∴ Third approximation to the root is
x3 =
2 7065 2 70675
2
. .
+
= 2.706625
Now f(x3) = .001744 i.e., (+)ve
Hence, the root lies between 2.7065 and 2.706625.
∴ Fourth approximation to the root is
x4 =
2 7065 2 706625
2
. .
+
= 2.7065625
Hence, the root is 2.7065625, correct to three decimal places.
Example 3. Find a positive real root of x – cos x = 0 by bisection method,
correct up to 4 decimal places between 0 and 1.
Sol. Let f(x) = x – cos x
f(0.73) = (–)ve and f(0.74) = (+)ve
Hence, the root lies between 0.73 and 0.74. First approximation to the root
is
x1 =
0 73 0 74
2
. .
+
= 0.735
Now f(0.735) = (–)ve
Hence, the root lies between 0.735 and 0.74. Second approximation to the
root is
x2 =
0.73 0.74
2
+
= 0.7375
Now f(0.7375) = (–)ve
Hence, the root lies between 0.7375 and 0.74. Third approximation to the
root is
x3 =
0 7375 0 74
2
. .
+
= 0.73875
Now f(0.73875) = (–)ve
Hence, the root lies between 0.73875 and 0.74.
Fourth approximation to the root is
x4 =
1
2
(0.73875 + 0.74) = 0.739375
Now f(x4) = f(0.739375) = (+)ve
90 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence, the root lies between 0.73875 and 0.739375.
Fifth approximation to the root is
x5 =
1
2
(0.73875 + 0.739375) = 0.7390625
Now f(0.7390625) = (–)ve
Hence, the root lies between 0.7390625 and 0.739375
Sixth approximation to the root is
x6 =
1
2
(0.7390625 + 0.739375) = 0.73921875
Now f(0.73921875) = (+)ve
Hence, the root lies between 0.7390625 and 0.73921875
Seventh approximation to the root is
x7 =
1
2
(0.7390625 + 0.73921875) = 0.73914
Now f(0.73914) = (+)ve
Hence, the root lies between 0.7390625 and 0.73914
Eighth approximate to the root is
x8 =
1
2
(0.7390625 + 0.73914) = 0.73910
Hence, the approximate real root is 0.7391.
Example 4. Perform five iterations of the bisection method to obtain the smallest
positive root of equation
f(x) ≡ x3 – 5x + 1 = 0.
Sol. f(x) = x3 – 5x + 1
Since f(.2016) = .0001935 i.e., (+)ve
and f(.2017) = – .0002943 i.e., (–)ve
Hence, the root lies between .2016 and .2017.
First approximation to the root is
x1 =
. .
2016 2017
2
+
= .20165
Now f(x1) = – .00005036 i.e., (–)ve
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 91
Hence, the root lies between .2016 and .20165.
Second approximation to the root is
x2 =
. .
2016 20165
2
+
= .201625
Now f(x2) = .00007159 i.e., (+)ve
Hence, the root lies between .201625 and .20165.
Third approximation to the root is
x3 =
. .
201625 20165
2
+
= .2016375
Now f(x3) = .00001061 i.e., (+)ve
Hence, the root lies between .2016375 and .20165.
Fourth approximation to the root is
x4 =
. .
2016375 20165
2
+
= .20164375
Now f(x4) = – .00001987 i.e., (–)ve
Hence, the root lies between .2016375 and .20164375.
∴ Fifth approximation to the root is
x5 =
. .
2016375 20164375
2
+
= .201640625
Hence, after performing five iterations, the smallest positive root of the
given equation is .20164, correct to five decimal places.
Example 5. Find a real root of x3 – x = 1 between 1 and 2 by bisection method.
Compute five iterations.
Sol. Here, f(x) = x3 – x – 1
Since f(1.324) = – .00306 i.e., (–)ve
and f(1.325) = .00120 i.e., (+)ve
Hence, the root lies between 1.324 and 1.325.
∴ First approximation to the root is
x1 =
1.324 1.325
2
+
= 1.3245
Now f(x1) = – .000929 i.e., (–)ve
Hence, the root lies between 1.3245 and 1.325
∴ Second approximation to the root is
x2 =
1.3245 1.325
2
+
= 1.32475
92 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now f(x2) = .000136 i.e., (+)ve
Hence, the root lies between 1.3245 and 1.32475.
Third approximation to the root is
x3 =
1.3245 1.32475
2
+
= 1.324625
Now f(x3) = – .000396 i.e., (–)ve
Hence, the root lies between 1.324625 and 1.32475.
∴ Fourth approximation to the root is
x4 =
1.324625 1.32475
2
+
= 1.3246875
Now f(x4) = – .0001298 i.e., (–)ve
Hence, the root lies between 1.3246875 and 1.32475
∴ Fifth approximation to the root is
x5 =
1.3246875 1.32475
2
+
= 1.32471875
Hence, the real root of the given equation is 1.324 correct to three decimal
places after computing five iterations.
Example 6. Use bisection method to find out the positive square root of 30
correct to 4 decimal places.
Sol. Let f(x) = x2 – 30
Since f(5.477) = – .00247 i.e., (–)ve
and f(5.478) = .00848 i.e., (+)ve
Hence, the root lies between 5.477 and 5.478
∴ First approximation to the root is
x1 =
5 477 5 478
2
. .
+
= 5.4775
Now f(x1) = .003 i.e., (+)ve
Hence, the root lies between 5.477 and 5.4775
∴ Second approximation to the root is
x2 =
5 477 5 4775
2
. .
+
= 5.47725
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 93
Now f(x2) = .00026 i.e., (+)ve
Hence, the root lies between 5.477 and 5.47725
∴ Third approximation to the root is
x3 =
5 477 5 47725
2
. .
+
= 5.477125
Now f(x3) = – .0011 i.e., (–)ve
Hence, the root lies between 5.477125 and 5.47725
∴ Fourth approximation to the root is
x4 =
5 477125 5 47725
2
. .
+
= 5.4771875
Since x3 and x4 are the same up to four decimal places, the positive square
root of 30, correct to 4 decimal places, is 5.4771.
ASSIGNMENT 3.1
1. (i) Transcendental equation is given as
f(x) = 2x – x – 3
Calculate f(x) for x = – 4, – 3, – 2, – 1, 0, 1, 2, 3, 4 and determine, between which
integer the values roots are lying.
(ii) The equation x2 – 2x – 3cos x = 0 is given. Locate the smallest root in magnitude in
an interval of length one unit.
2. Find a real root of ex = 3x by Bisection method.
3. Find the smallest positive root of x3 – 9x + 1 = 0, using Bisection method correct to three
decimal places.
4. Find the real root lying in interval (1, 2) up to four decimal places for the equation
x6 – x4 – x3 – 1 = 0 by bisection method.
5. Find the root of tan x + x = 0 up to two decimal places which lies between 2 and 2.1 using
Bisection method.
6. Compute the root of log x = cos x correct to 2 decimal places using Bisection method.
7. Compute the root of f(x) = sin 10x + cos 3x by computer using Bisection method. The
initial approximations are 4 and 5.
8. Find the real root correct to three decimal places for the following equations:
(i) x3 – x – 4 = 0 (ii) x3 – x2 – 1 = 0
(iii) x3 + x2 – 1 = 0 (iv) x3 – 3x – 5 = 0.
9. Find a root of x3 – x – 11 = 0 using Bisection method correct to 3 decimal places which
lies between 2 and 3.
10. Find a real root of the equation x3 – 2x – 5 = 0 using Bisection method.
11. Find a positive root of the equation xex = 1 which lies between 0 and 1.
94 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
12. Apply Bisection method to find a root of the equation x4 + 2x3 – x – 1 = 0 in the interval
[0, 1].
13. Obtain a root correct to three decimal places for each of these equations using Bisection
method.
(i) x3 + x2 + x + 7 = 0 (ii) x3 – 18 = 0
(iii) x3 + x – 1 = 0 (iv) x3 – 5x + 3 = 0.
14. By displaying procedure in tabular form, use Bisection method to compute the root of
36.
15. Find a positive root of the equation x3 + 3x – 1 = 0 by bisection method.
16. Find a real root of x3 – 2x – 1 = 0 which lies between 1 and 2 by using Bisection method
correct to 2 decimal places.
17. Find the approximate value of the root of the equation 3x – 1 + sin x = 0 by Bisection
method.
18. (i) Explain the Bisection method to calculate the roots of an equation. Write an algo-
rithm and implement it in ‘C’.
(ii) Write computer program in a language of your choice which implements bisection
method to compute the real root of the equation 3x + sin x – ex = 0 in a given interval.
19. Solve x3 – 9x + 1 = 0 for the root between x = 2 and x = 4 by the method of Bisection.
20. If a root of f(x) = 0 lies in the interval (a, b), then find the minimum number of iterations
required when the permissible error is E.
21. The negative root of the smallest magnitude of the equation f(x) = 3x3 + 10x2 + 10x + 7 = 0
is to be obtained.
(i) Find an interval of unit length which contains this root.
(ii) Perform two iterations of the bisection method.
22. The smallest positive root of the equation
f(x) = x4 – 3x2 + x – 10 = 0
is to be obtained.
(i) Find an interval of unit length which contains this root.
(ii) Perform two iterations of the bisection method.
3.10 ITERATION METHOD—(Successive Approximation Method)
To find the roots of the equation f(x) = 0 by successive approximations,
we write it in the form x = φ(x)
The roots of f(x) = 0 are the same as the points of intersection of the straight
line y = x and the curve representing
y = φ(x).
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 95
Y
O X
x0 x2 x3 x1
y =
x
y = (x)
φ
(Working of Iteration method)
Let x = x0 be an initial approximation of the desired root α, then first
approximation x1 is given by
x1 = φ(x0)
Now, treating x1 as the initial value, the second approximation is
x2 = φ(x1)
Proceeding in this way, the nth approximation is given by
xn = φ(xn – 1).
3.11 SUFFICIENT CONDITION FOR CONVERGENCE OF ITERATIONS
It is not definite that the sequence of approximations x1, x2, ......, xn always
converges to the same number, which is a root of f(x) = 0.
As such, we have to choose the initial approximation x0 suitably so that the
successive approximations x1, x2, ......, xn converge to the root α. The following
theorem helps in making the right choice of x0.
3.12 THEOREM
If (i) α be a root of f(x) = 0 which is equivalent to x = φ(x)*.
(ii) I be any interval containing x = α.
(iii) | φ′(x) |  1 for all x in I, then the sequence of approximations x0, x1, x2,
......, xn will converge to the root a provided the initial approximation x0 is
chosen in I.
*x is obtained interms of φ(x) such that | φ′(x) |  1.
96 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
This method of iteration is particularly useful for finding the real roots of
an equation given in the form of an infinite series.
3.13 CONVERGENCE OF ITERATION METHOD
Since α is a root of x = φ(x), we have α = φ(α)
If xn – 1 and xn are two successive approximations to α, we have
xn = φ(xn – 1), xn – α = φ(xn – 1) – φ(α) (4)
By mean value theorem,
φ φ α
α
( ) ( )
x
x
n
n
−
−
−
−
1
1
= φ′(ξ), where xn – 1  ξ  α
Hence (4) becomes xn – α = (xn – 1 – α) φ′(ξ)
If | φ′(xi) | ≤ k  1 for all i, then,
| xn – α | ≤ k | xn – 1 – α |, k  1
Hence it is clear that the iteration method is linearly convergent.
1. The smaller the value of φ′(x), the more rapid will be the convergence.
2. For rapid convergence, f′(a) ≈ 0.
3.14 ALGORITHM FOR ITERATION METHOD
3.14.1 Algorithm 1
1. Read x0, e, n
x0 is the initial guess, e is the allowed error in root, n is total iterations to be
allowed for convergence.
2. x1 ← g(x0)
Steps 4 to 6 are repeated until the procedure converges to a root or iterations
reach n.
NOTE
NOTE
NOTE
NOTE
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 97
3. For i = 1 to n in steps of 1 do
4. x0 ← x1
5. x1 ← g(x0)
6. If
x x
x
1 0
1
−
≤ e then, GO TO 9
end for.
7. Write ‘Does not converge to a root’, x0, x1
8. Stop
9. Write ‘converges to a root’, i, x1
10. Stop.
3.14.2 Algorithm 2 (Aliter)
1. Define function f(x)
2. Define function df(x)
3. Get the value of a, max_err.
4. Initialize j
5. If df(a)  1 then b = 1, a = f(a)
6. Print root after j, iteration is f(a)
7. If fabs(b – a)  max_err then
8. j++, goto (5)
End if
Else print root doesn’t exist
9. End.
98 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.15 FLOW-CHART FOR ITERATION METHOD
START
STOP
Define F(x)
Get the value of x and max_error
0
Set n = 0.
x = f(x )
n+1 n
n = n + 1
Is
| x – x | 
max. error
n+1 n
Yes
No
Print the root is x .
n
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 99
3.16 COMPUTER PROGRAM
//Program for Solution by ITERATION method
#includestdio.h
#includemath.h
#includeconio.h
#define EPS 0.00005
#define F(x) (x*x*x + 1)/2
#define f(x) x*x*x - 2*x + 1
void ITER();
void main ()
{
clrscr();
printf(nt Solution by ITERATION method n);
printf(nt Equation is );
printf(ntttt X*X*X - 2*X + 1 = 0nn);
ITER();
getch();
}
void ITER()
{
float x1,x2,x0,f0,f1,f2,error;
int i=0,n;
for(x1=1;;x1++)
{
f1=F(x1);
if (f10)
break;
}
for(x0=x1-1;;x0--)
{
f0=f(x0);
if(f00)
break;
}
100 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
x2=(x0+x1)/2;
printf(Enter the number of iterations:);
scanf(%d,n);
printf(nntt The 1 approximation to the root is: %f,x2);
for(;in-1;i++)
{
f2=F(x2);
printf(nntt The %d approximation to the root is:
%f,i+2,f2);
x2=F(x2);
error=fabs(f2-f1);
if(errorEPS)
break;
f1=f2;
}
if(errorEPS)
printf(nnt NOTE:- The number of iterations
are not sufficient.);
printf(nnnttt------------------------------);
printf(nttt The root is %.4f,f2);
printf(nttt-----------------------------);
}
3.16.1 Output
Solution by ITERATION method
Equation is
x*x*x-2*x+1=0
Enter the number of iterations: 15
The 1 approximation to the root is: 0.000000
The 2 approximation to the root is: 0.500000
The 3 approximation to the root is: 0.562500
The 4 approximation to the root is: 0.588989
The 5 approximation to the root is: 0.602163
The 6 approximation to the root is: 0.609172
The 7 approximation to the root is: 0.613029
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 101
The 8 approximation to the root is: 0.615190
The 9 approximation to the root is: 0.616412
The 10 approximation to the root is:0.617107
The 11 approximation to the root is:0.617504
The 12 approximation to the root is:0.617730
The 13 approximation to the root is:0.617860
The 14 approximation to the root is:0.617934
The 15 approximation to the root is:0.617977
-----------------------------------------------------
The Root is 0.6179 (Correct to four decimal places)
-----------------------------------------------------
3.16.2 Insufficient Output
Solution by ITERATION method
Equation is
x*x*x-2*x+1=0
Enter the number of Iterations:5
The 1 approximation to the root is: 0.000000
The 2 approximation to the root is: 0.500000
The 3 approximation to the root is: 0.562500
The 4 approximation to the root is: 0.588989
The 5 approximation to the root is: 0.602163
The number of Iterations are not sufficient.
-----------------------------------------------------
The Root is 0.6022
EXAMPLES
Example 1. Use the method of iteration to find a positive root between 0 and 1
of the equation xex = 1.
Sol. Writing the equation in the form x = e–x
we find, φ(x) = e–x so φ′(x) = – e–x
Hence, | φ′(x) |  1 for x  1, which assures that iteration is convergent.
NOTE
102 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Starting with x0 = 1, we find that successive iterates are given by
x1 =
1
e
= 0.3678794
x = e– 0.3678794 = 0.6922006

x20 = 0.5671477.
Example 2. Find a real root of the equation cos x = 3x – 1 correct to 3 decimal
places using iteration method.
Sol. We have f(x) = cos x – 3x + 1 = 0
Now, f(0) = 2 and f(π/2) = –
3
2
π
+ 1 = (–)ve
∴ A root lies between 0 and π/2.
Rewriting the given equation as
x =
1
3
(cos x + 1) = φ(x)
We have φ′(x) = –
sin x
3
and | φ′(x) | =
1
3
| sin x |  1 in (0, π/2)
Hence the iteration method can be applied and we start with x0 = 0. Then
the successive approximations are
x1 = φ(x0) =
1
3
(cos 0 + 1) = 0.6667
x2 = φ(x1) =
1
3
[cos 0.6667 + 1] = 0.5953
x3 = φ(x2) =
1
3
[cos (0.5953) + 1] = 0.6093
x4 = φ(x3) = 0.6067
x5 = φ(x4) = 0.6072
x6 = φ(x5) = 0.6071.
Since x5 and x6 are almost the same, the root is 0.607 correct to three decimal
places.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 103
Example 3. Find a real root of 2x – log10 x = 7 correct to four decimal places
using the iteration method.
Sol. We have f(x) = 2x – log10 x – 7
f(3) = 6 – log 3 – 7 = 6 – 0.4771 – 7 = – 1.4471
f(4) = 0.398
∴ A root lies between 3 and 4.
Rewriting the given equation as
x =
1
2
(log10 x + 7) = φ(x),
we have φ′(x) =
1
2
1
10
x
e
log
F
HG I
KJ
∴ | φ′(x) |  1 when 3  x  4 (∵ log10 e = 0.4343)
Since | f(4) |  | f(3) |, the root is near 4.
Hence the iteration method can be applied.
The successive approximations of x0 = 3.6 are
x1 = φ(x0) =
1
2
(log10 3.6 + 7) = 3.77815
x2 = φ(x1) =
1
2
(log10 3.77815 + 7) = 3.78863
x3 = φ(x2) = 3.78924
x4 = φ(x3) = 3.78927
Since x3 and x4 are almost equal, the root is 3.7892, correct to four decimal
places.
Example 4. Find the smallest root of the equation
1 – x +
x
(2 !)
x
(3 !)
x
(4 !)
x
(5 !)
...... 0
2
2
3
2
4
2
5
2
− + − + = .
Sol. Writing the given equation as
x = 1 +
x x x x
x
2
2
3
2
4
2
5
2
2 3 4 5
( !) ( !) ( !) ( !)
...... ( )
− + − + = φ
and omitting x2 and higher powers of x, we get x = 1 approximately.
104 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Taking x0 = 1, we obtain,
x1 = φ(x0) = 1
1
2
1
3
1
4
1
5
2239
2 2 2 2
+ − + − + =
( !) ( !) ( !) ( !)
...... 1.
x2 = φ(x1) = 1
2239 2239 2239
4
2239
5
2 3 4
2
5
2
+ − + − +
( ) ( ) ( )
( !)
( )
( !)
......
1.
(2 !)
1.
(3!)
1. 1.
2 2
= 1.3263
Similarly, x3 = φ(x2) = 1.38
x4 = 1.409, x5 = 1.425, x6 = 1.434, x7 = 1.439, x8 = 1.442
Values of x7 and x8 indicate that the root is 1.44, correct to two decimal
places.
Example 5. If α, β are the roots of x2 + ax + b = 0, show that the iteration
xn + 1 = –
ax b
x
n
n
+
F
HG
I
KJ will converge near x = α if | α |  | β | and the iteration
xn + 1 =
−
+
b
x a
n
will converge near x = α if | α |  | β |.
Sol. Since α, β are the roots of x2 + ax + b = 0,
we have α + β = – a and αβ = b
The formula xn + 1 = –
ax b
x
n
n
+
F
HG
I
KJ, which is of the form xn + 1 = f(xn), will
converge to x = α if
d
dx
ax b
x x xn
− +
R
S
T
U
V
W 
=
( )
1 Using condition
of iteration method
⇒
b
xn
2
1

⇒ | xn
2 |  | b | or xn
2  | b |
or | α |2  | b | as xn → α
or | α |2  | α | | β | (∵ αβ = b)
or | α |  | β |
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 105
Similarly, xn + 1 =
−
+
b
x a
n
will converge to x = α if
d
dx
b
x a x xn
−
+
F
HG I
KJ
L
NM O
QP 
=
1
or
b
x a
n
( )
+

2
1
or (xn + a)2  | b | or (α + a)2  | b | as xn → α
or β2  | b | (∵ α + a = – β)
or | β |2  | α | | β |
or | β |  | α | or | α |  | β |.
Example 6. Show that the following rearrangement of equation x3 + 6x2 + 10x
– 20 = 0 does not yield a convergent sequence of successive approximations by
iteration method near x = 1,
x = (20 – 6x2 – x3)/10.
Sol. Here, x =
20 6
10
2 3
− −
x x
= f(x)
Hence, f ′(x) =
− −
12 3
10
2
x x
Clearly, f ′(x)  – 1 in neighborhood of x = 1. Hence | f ′(x) |  1, and
neither the method nor the sequence xn converge.
Example 7. Suggest a value of constant k, so that the iteration formula
x = x + k(x2 – 3) may converge at a good rate, given that x = 3 is a root.
Sol. Formula x = f(x) where f(x) = x + k(x2 – 3)
will converge if
| f ′(x) |  1 or – 1  f ′(x)  1
i.e., if – 1  1 + 2kx  1
Moreover, the convergence will be rapid if f ′(a) ~
– 0
i.e., if 1 + 2ka ~
– 0
i.e., 1 + 2k 3 ~
– 0 ⇒ k = –
1
2 3
106 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
We may take k = –
1
4
to insure a rapid convergence by this formula.
Example 8. If F(x) is sufficiently differentiable and the iteration xn + 1 = F(xn)
converges, prove that the order of convergence is a positive integer.
Sol. Let x = a be a root of the equation x = F(x) then, a = F(a)
Let, for some p(positive integer)
F′(a) = 0, F″(a) = 0, ...... , F(p – 1) (a) = 0 and F(p) (a) ≠ 0
then expanding F(xn) about a, we get
xn + 1 = F(xn) = F(a + xn – a)
= F(a) + (xn – a) F′(a) + ...... +
( )
( ) !
( )
( )
!
( )
( ) ( )
x a
p
a
x a
p
n
p
p n
p
p
−
−
+
−
−
−
1
1
1
F F ξ
where ξ is some point between x = xn and x = a.
⇒ xn + 1 = a +
( )
!
( )
( )
x a
p
n
p
p
−
F ξ
⇒ xn + 1 – a = (xn – a) p .
F( )
( )
!
p
p
ξ
∴ The order of convergence is p, a positive integer.
Example 9. The equation sin x = 5x – 2 can be written as x = sin–1 (5x – 2)
and also as x =
1
5
(sin x + 2), suggesting two iterating procedures for its solution.
Which of these, if either, would succeed, and which would fail to give a root in
the neighborhood of 0.5?
Sol. In case I, φ(x) = sin–1 (5x – 2)
∴ φ′(x) =
5
1 5 2 2
− −
( )
x
Hence, | φ′(x) |  1 for all x for which (5x – 2)2  1 or x  3/5 or x  0.6 in
neighborhood of 0.5. Thus the method would not give a convergent sequence.
In case II, φ(x) =
1
5
(sin x + 2)
∴ φ′(x) =
1
5
cos x
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 107
Hence | φ′(x) | ≤
1
5
for all x because | cos x | ≤ 1
∴ φ(x) will succeed.
Hence, taking x = φ(x) =
1
5
(sin x + 2) and the initial value x0 = 0.5, we have
the first approximation x1 given by
x1 =
1
5
(sin 0.5 + 2) = 0.4017
x2 =
1
5
[sin (0.4017) + 2] = 0.4014
x3 =
1
5
[sin (0.4014) + 2] = 0.4014
Hence, up to four decimal places, the value of the required root is 0.4014.
Example 10. Starting with x = 0.12, solve x = 0.21 sin (0.5 + x) by using the
iteration method.
Sol. Here, x = 0.21 sin (0.5 + x)
∴ First approximation of x is given by
x(1) = 0.21 sin (0.5 + 0.12) = 0.122
x(2) = 0.21 sin (0.5 + 0.122) = 0.1224
Similarly, x(3) = 0.12242, x(4) = 0.12242
Obviously, x(3) = x(4)
Hence the required root is 0.12242.
Example 11. Find a real root of the equation f(x) = x3 + x2 – 1 = 0 by using the
iteration method.
Sol. Here, f(0) = – 1 and f(1) = 1 so a root lies between 0 and 1. Now, x =
1
1 + x
so that,
φ(x) =
1
1 + x
∴ φ′(x) = –
1
2 1 3 2
( ) /
+ x
108 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
We have, | φ′(x) |  1 for x  1
Hence the iterative method can be applied.
Take x0 = 0.5, we get
x1 = φ(x0) =
1
5
1.
= 0.81649
x2 = φ(x1) =
1
81649
1.
= 0.74196

x8 = 0.75487.
Example 12. Find the reciprocal of 41 correct to 4 decimal places by iterative
formula
xi + 1 = xi(2 – 41xi).
Sol. Iterative formula is xi + 1 = xi (2 – 41 xi) (5)
Putting i = 0, x1 = x0(2 – 41 x0)
Let x0 = 0.02
x1 = (0.02) (2 – 0.82) = 0.024
Put i = 1 in (5),
x2 = (0.024) {2 – (41 × 0.024)} = 0.0244
Put i = 2, x3 = 0.02439
∴ Reciprocal of 41 is 0.0244.
Example 13. Find the square root of 20 correct to 3 decimal places by using
recursion formula
xi + 1 =
1
2
x
20
x
i
i
+
F
HG
I
KJ.
Sol. Put i = 0, x1 =
1
2
20
0
0
x
x
+
F
HG
I
KJ
Let x0 = 4.5
∴ x1 =
1
2
4 5
20
4 5
.
.
+
F
HG I
KJ = 4.47
Put i = 1, x1 = 4.47, x2 =
1
2
4 47
20
4 47
.
.
+
F
HG I
KJ = 4.472
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 109
Put i = 2, x2 = 4.472, x3 = 4.4721
∴ 20 ~
– 4.472 correct to three decimal places.
Example 14. Find the cube root of 15 correct to four significant figures by
iterative method.
Sol. Let x = (15)1/3 ∴ x3 – 15 = 0
The real root of the above equation lies in (2, 3). The equation may be
written as
x =
15 20
20
3
+ −
x x
= φ(x)
Now, φ′(x) = 1 –
3
20
2
x
∴ | φ′(x) |  1 (for x ≈ 2.5)
Iterative formula is xi + 1 =
15 20
20
3
+ −
x x
i i
(6)
Put i = 0, x0 = 2.5, we get x1 = 2.47
Put i = 1 in (6), x2 = 2.466 (where x1 = 2.47)
Similarly, x3 = 2.4661
∴ 15
3
correct to 3 decimal places is 2.466.
Example 15. The equation x4 + x = e where e is a small number has a root close
to e. Computation of this root is done by the expression α = e – e4 + 4e7.
(i) Find an iterative formula xn+1 = F(xn), x0 = 0 for the computation. Show that
we get the above expression after three iterations when neglecting terms of
higher order.
(ii) Give a good estimate (of the form Nek, where N and k are integers) of the
maximum error when the root is estimated by the above expression.
Sol. x4 + x = e may be written as
x =
e
x3
1
+
Consider the formula
xn+1 =
e
xn
3
1
+
Starting with x0 = 0, we get
x1 = e
110 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
x2 =
e
e
1 3
+
= e(1 + e3)–1
= e(1 – e3 + e6 – ...)
= e – e4 + e7 (neglecting higher powers of e)
x3 =
e
e e e
1 4 7 3
+ − +
( )
= e – e4 + 4e7 (neglecting higher powers of e)
Taking α = e – e4 + 4e7, we find that
error = α4 + α – e
= (e – e4 + 4e7)4 + (e – e4 + 4e7) – e
= 22e10 + higher powers of e.
ASSIGNMENT 3.2
1. Apply iteration method to solve e–x = 10x.
L
NM Hint: | φ′(x) | =
1
10
1
ex
 1 if x ≥ 0.
O
QP
2. Find by iterative method, the real root of the equation 3x – log10 x = 6 correct to four
significant figures.
3. Solve by iteration method:
(i) 1 + log x =
x
2
(ii) sin x =
x
x
+
−
1
1
(iii) x3 = x2 + x + 1 near 2 (use 5 iterations)
(iv) x3 + x + 1 = 0 (v) x3 – 2x2 – 5 = 0 (vi) x3 – 2x2 – 4 = 0.
4. Use the iterative method to find, correct to four significant figures, a real root of each of
the following equations:
(i) x =
1
1 2
( )
x +
(ii) x = (5 – x)1/3 (iii) sin x = 10(x – 1)
(iv) x sin x = 1 (v) ex = cot x (vi) 1 + x2 – x3 = 0
(vii) x2 – 1 = sin2 x (viii) 5x3 – 20x + 3 = 0.
5. By iteration method, find 30 .
6. The root of the equation x =
1
2
+ sin x by using the iteration method
xn+1 =
1
2
+ sin xn, x0 = 1
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 111
x = 1.497300 is correct to 6 decimal places. Determine the number of iteration steps
required to reach the root by the linear iteration.
7. The equation f(x) = 0, where
f(x) = 0.1 – x +
x x x
2
2
3
2
4
2
2 3 4
( !) ( !) ( !)
− + – ...
has one root in the interval (0, 1). Calculate this root correct to 5 decimal places.
8. Find a catenary y = c cosh
x a
c
−
F
HG I
KJ passing through the points (1, 1) and (2, 3).
[Hint: Eliminate a from c cosh
1 −
F
HG I
KJ
a
c
= 1 and c cosh
2 −
F
HG I
KJ
a
c
= 3 to get
c =
1
1
3
1
1
+
F
HG I
KJ
F
HG I
KJ
−
−
c
c
c
cosh
cosh
= φ(c)]
9. The equation x2 + ax + b = 0 has two real roots, α and β. Show that the iteration method
xn+1 = –
x b
a
n
2
+
F
HG
I
KJ
is convergent near x = α if 2 | α |  | α + β |.
10. The equation x3 – 5x2 + 4x – 3 = 0 has one root near x = 4 which is to be computed by the
iteration
xn+1 =
3 4) 5 2 3
+ − + −
(k x x x
k
n n n , k integer; x0 = 4
(i) Determine which value of k will give the fastest convergence.
(ii) Using this value of k, iterate three times and estimate the error in x3.
[Hint: Put xn = α + en, α = 4 + δ, where α is the exact root. Find the error eqn.
ken+1 = (k – 12) en + O(δen)]
3.17 THE METHOD OF ITERATION FOR SYSTEM OF NON-LINEAR
EQUATIONS
Let the equation be f(x, y) = 0, g(x, y) = 0 whose real roots are required within a
specified accuracy.
We assume, x = F(x, y) and y = G(x, y)
where functions F and G satisfy conditions
112 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∂
∂
+
∂
∂

F F
x y
1 and
∂
∂
+
∂
∂

G G
x y
1 in neighborhood of root.
Let (x0, y0) be the initial approximation to a root (α, β) of the system. We
then construct successive approximations as
x1 = F(x0, y0), y1= G(x0, y0)
x2 = F(x1, y1), y2 = G(x1, y1)
x3 = F(x2, y2), y3 = G(x2, y2)
........................................................
xn + 1 = F(xn, yn), yn + 1 = G(xn, yn)
If the iteration process converges, we get
α = F(α, β)
β = G(α, β) in the limit.
Thus α, β are the roots of the system.
Example. Find a real root of the equations by the iteration method.
x = 0.2x2 + 0.8, y = 0.3xy2 + 0.7.
Sol. We have F(x, y) = 0.2x2 + 0.8
G(x, y) = 0.3xy2 + 0.7
∂
∂
F
x
= 0.4x
∂
∂
G
x
= 0.3y2
∂
∂
F
y
= 0
∂
∂
G
y
= 0.6xy
It is easy to see that x = 1 and y = 1 are the roots of the system.
Choosing x0 =
1
2
, y0 =
1
2
, we find that
∂
∂
+
∂
∂
= 
F F
x y
x y x y
( , ) ( , )
.
0 0 0 0
0 2 1
and
∂
∂
+
∂
∂
= 
G G
x y
x y x y
( , ) ( , )
.
0 0 0 0
0 225 1
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 113
∴ Conditions are satisfied. Hence,
x1 = F(x0, y0) =
0 2
4
.
+ 0.8 = 0.85
and y1 = G(x0, y0) =
0
8
.3
+ 0.7 = 0.74*
For approximation II, we obtain
x2 = F(x1, y1) = 0.2(0.85)2 + 0.8 = 0.9445
and y2 = G(x1, y1) = 0.3(0.85) × (0.74)2 + 0.7 = 0.81
Convergence to the root (1, 1) is obvious.
3.18 METHOD OF FALSE POSITION Or REGULA-FALSI METHOD
The bisection method guarantees that the iterative process will converge. It is,
however, slow. Thus, attempts have been made to speed up** the bisection
method retaining its guaranteed convergence. A method of doing this is called
the method of false position.
It is sometimes known as the method of linear interpolation.
This is the oldest method for finding the real roots of a numerical equation
and closely resembles the bisection method.
In this method, we choose two points x0 and x1 such that f(x0) and f(x1) are
of opposite signs. Since the graph of y = f(x) crosses the X-axis between these
two points, a root must lie in between these points.
Consequently, f(x0) f(x1)  0
Y
O
X
{x , f(x )}
0 0
{x , f(x )}
1 1
P(x)
x0
x3 x2 x1
B
A
*y1 can also be obtained more accurately by assigning the value of x1 = 0.85.
**Order of convergence greater than 1.
114 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The equation of the chord joining points {x0, f(x0)} and {x1, f(x1)} is
y – f(x0) =
f x f x
x x
x x
( ) ( )
( )
1 0
1 0
0
−
−
−
The method consists in replacing the curve AB by means of the chord AB
and taking the point of intersection of the chord with the X-axis as an
approximation to the root.
So the abscissa of the point where the chord cuts y = 0 is given by
x2 = x0 –
x x
f x f x
f x
1 0
1 0
0
−
−
( ) ( )
( ) (7)
which is an approximation to the root.
If f(x0) and f(x2) are now of opposite signs, then the root lies between x0 and
x2. So replacing x1 with x2 in (7), we obtain the next approximation, x3. However,
the root could also lie between x1 and x2 and then we find x3 accordingly.
This procedure is repeated until the root is found to the desired accuracy.
The order of convergence of the Regula Falsi method is 1.618.
3.19 ALGORITHM
Step 01. Start of the program.
Step 02. Input the variables x0, x1, e, n for the task.
Step 03. f0 = f(x0)
Step 04. f1 = f(x1)
Step 05. for i = 1 and repeat if i  = n
Step 06. x2 = (x0 f1-x1 f0)/(f1-f0)
Step 07. f2 = x2
Step 08. if | f2 |  = e
Step 09. Print “convergent”, x2, f2
Step 10. If sign (f2) ! = sign (f0)
Step 11. x1 = x2  f1 = f2
Step 12. else
Step 13. x0 = x2  f0 = f2
Step 14. End loop
Step 15. Print output
Step 16. End of program.
NOTE
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 115
3.19.1 Aliter Algorithm: Method of False Position
1. Read x0, x1, e, n
x0 and x1 are two initial guesses to the root such that sign f(x0) ≠ sign f(x1).
The prescribed precision is e and n is maximum number of iterations. Steps
2 and 3 are initialization steps.
2. f0 ← f(x0)
3. f1 ← f(x1)
4. For i = 1 to n in steps of 1 do
5. x2 ← (x0 f1 – x1f0)/(f1 – f0)
6. f2 ← f(x2)
7. If | f2 | ≤ e then
8. Begin write ‘convergent solution’, x2, f2
9. Stop end
10. If sign (f2) ≠ sign (f0)
11. Then begin x1 ← x2
12. f1 ← f2 end
13. Else begin x0 ← x2
14. f0 ← f2 end
end for
15. Write ‘Does not converge in n iterations’
16. Write x2, f2
17. Stop.
NOTE
116 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.20 FLOW-CHART
START
Define function f(x)
Define function regula
Get the value of
x , x , aerr, mitr
0 1
initialize itr
Call function regula with x , x , x
f(x ), f(x ), itr
2 0 1
0 1
Call function regula with x , x , x
f(x ), f(x ), itr
3 0 1
0 1
A
B
A
x = x
1 2 x = x
0 2
Yes
Yes
Yes
No
No
No
Is
f(x )*f(x )
0
0 2
Is
fabs (x – x )
 aerr
3 2 C
x = x
2 3
Is itr
 maxitr
Print Not convergent
STOP
B
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 117
A
C
x = x – (x – x )/(f(x ) – f(x ))*f(x )
0 1 0 1 0 0
Print itr, x
Print ‘‘solution’’
Return
RETURN
EXAMPLES
Example 1. Find a real root of the equation 3x + sin x – ex = 0 by the method of
false position correct to four decimal places.
Also write its program in ‘C’ language.
Sol. Let f(x) ≡ 3x + sin x – ex = 0
f(0.3) = – 0.154 i.e., (–)ve
and f(0.4) = 0.0975 i.e., (+)ve
∴ The root lies between 0.3 and 0.4.
Using Regula Falsi method,
x2 = x0 –
x x
f x f x
f x
1 0
1 0
0
−
−
( ) ( )
( )
= −
−
− −
−
( )
( . ) ( )
( . ) ( )
( )
0
0 4 0
0 0975 0
0
.3
.3
.154
.154
| ∵ x0 = 0.3 and x1 = 0.4 (let)
= +
×
F
HG I
KJ =
( )
0
0 0
0
0
.3
.1 .154
.2515
.3612
Now f(x2) = f(0.3612) = 0.0019 = (+)ve
118 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence, the root lies between 0.3 and 0.3612.
Now again, x3 = x0 –
( )
( ) ( )
( )
x x
f x f x
f x
2 0
2 0
0
−
−
Replacing by
1 2
x x
= (0.3)
.154
.154
−
−
− −
R
S
T
U
V
W −
( . ) ( . )
( . ) ( )
( )
0 3612 0 3
0 0019 0
0
= (0.3)
.1559
.154
+
F
HG I
KJ =
0 0612
0
0 0 3604
.
( ) .
Now f(x3) = f(0.3604) = – 0.00005 = (–)ve
∴ The root lies between 0.3604 and 0.3612.
Now again, x4 = x
x x
f x f x
f x
3
2 3
2 3
3
−
−
−
R
S
T
U
V
W
( ) ( )
( ) Replacing by
0 3
x x
= −
−
− −
L
NM O
QP −
( . )
( . . )
( . ) ( . )
( . )
0 3604
0 3612 0 3604
0 0019 0 00005
0 00005
= +
F
HG I
KJ
0 3604
0 0008
0 00195
.
.
.
(0.00005) = 0.36042
Since x3 and x4 are approximately the same, the required real root is 0.3604,
correct to four decimal places.
/* ********************************************************
Program to Implement the Method of Regula Falsi (False
Position)
******************************************************** */
// ... Included Header files
#includestdio.h
#includemath.h
#includeconio.h
#includestring.h
#includeprocess.h
//...Formulae declaration
#define EPS 0.00005
#define f(x) 3*x+sin(x)-exp(x)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 119
//...Function Declaration Prototype
void FAL_POS();
//...Main Execution Thread
void main()
{
clrscr();
printf(n Solution by FALSE POSITION methodn);
printf(n Equation is );
printf(nttt 3*x + sin(x)-exp(x)=0nn);
FAL_POS();
}
//...Function Definition
void FAL_POS()
{
float f0,f1,f2;
float x0,x1,x2;
int itr;
int i;
printf(Enter the number of iteration:);
scanf(%d,itr);
for(x1=0.0;;)
{
f1=f(x1);
if(f10)
{
break;
{
else
{
x1=x1+0.1;
}
}
x0=x1-0.1;
f0=f(x0);
120 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(ntt-----------------------------------------);
printf(ntt ITERATIONt x2tt F(x)n);
printf(tt--------------------------------------------);
for(i=0;iitr;i++)
{
x2=x0-((x1-x0)/(f1-f0))*f0;
f2=f(x2);
if(f0*f20)
{
x1=x2;
f1=f2;
}
else
{
x0=x2;
f0=f2;
}
if(fabs(f(2))EPS)
{
printf(ntt%dt%ft%fn,i+1,x2,f2);
}
}
printf(tt--------------------------------------------);
printf(nttttRoot=%fn,x2);
printf(tt-------------------------------------------);
getch();
}
OUTPUT
Solution by FALSE POSITION method
Equation is
3*x+sin(x)-exp(x)=0
Enter the number of iteration: 11
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 121
----------------------------------------------------
ITERATION X2 F(x)
----------------------------------------------------
1 0.361262 0.002101
2 0.360409 -0.000031
3 0.360422 0.000000
4 0.360422 -0.000000
5 0.360422 0.000000
6 0.360422 0.000000
7 0.360422 0.000000
8 0.360422 0.000000
9 0.360422 0.000000
10 0.360422 0.000000
11 0.360422 0.000000
----------------------------------------------------
Root=0.360422
----------------------------------------------------
Example 2. Find the root of the equation xex = cos x in the interval (0, 1) using
Regula-Falsi method correct to four decimal places. Write its computer
programme in ‘C’ language.
Sol. Let f(x) = cos x – xex = 0 so that
f(0) = 1, f(1) = cos 1 – e = – 2.17798
i.e., the root lies between 0 and 1.
By Regula-Falsi method,
x2 = x0 –
( )
( ) ( )
( )
x x
f x f x
f x
1 0
1 0
0
−
−
= −
−
−
=
0
1 0
3
1 0 31467
.17798
( ) .
Now f(x2) = f(0.31467) = 0.51987
i.e., the root lies between 0.31487 and 1.
Again x3 = 0.31487 –
( )
( . )
1 0
2 0 51987
−
− −
.31487
.17798
(0.51987)
= 0.44673
122 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now f(x3) = 0.20356
∴ The root lies between 0.44673 and 1. Repeating this process,
x10 = 0.51775, corrected as 0.5177 up to 4 decimal places.
COMPUTER PROGRAMME
METHOD OF FALSE POSITION
#includestdio.h
#includeconio.h
#includemath.h
float f(float x)
{
return cos(x)-x*exp(x);
}
void regula (float *x, float x0,float x1, float fx0, float
fx1,int*itr)
{
*x=x0-((x1-x0)/(fx1-fx0))*fx0;
++(*itr);
printf(Iteration no.%3d x=%7.5fn,*itr,*x);
}
main()
{
int itr=0,maxitr;
float x0,x1,x2,x3,aerr;
printf(Enter the values for x0,x1, allowed error,
max.iterationn);
scanf(%f%f%f%d,x0,x1,aerr,maxitr);
regula(x2,x0,x1,f(x0),f(x1),itr);
do
{ if(f(x0)*f(x2)0)
x1=x2;
else
x0=x2;
regula(x3,x0,x1,f(x0),f(x1),itr);
if(fabs(x3-x2)aerr)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 123
{
printf(After %d iterations,
root=%6.4fn,itr,x3);
getch();
return (0);
}
x2=x3;
}while (itrmaxitr);
printf(Solution does not converge, iterations not
sufficientn);
getch();
return(1);
OUTPUT
Enter the values for x0,x1, allowed error, max.iteration
0
1
.00005
20
Iteration number 1 x = 0.31467
Iteration number 2 x = 0.44673
Iteration number 3 x = 0.49402
Iteration number 4 x = 0.50995
Iteration number 5 x = 0.51520
Iteration number 6 x = 0.51692
Iteration number 7 x = 0.51748
Iteration number 8 x = 0.51767
Iteration number 9 x = 0.51773
Iteration number 10 x = 0.51775
After 10 iterations, root = 0.5177
Example 3. Find a real root of the equation x3 – 2x – 5 = 0 by the method of
false position correct to three decimal places.
Sol. Let f(x) = x3 – 2x – 5 so that f(2) = – 1 and f(3) = 16
i.e., A root lies between 2 and 3. Using Regula-Falsi method,
x2 = x0 –
( )
( ) ( )
( )
x x
f x f x
f x
1 0
1 0
0
−
−
124 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 2 –
( )
( )
3 2
16 1
−
+
(– 1) = 2.0588
Now f(x2) = f(2.0588) = – 0.3908
i.e., The root lies between 2.0588 and 3.
Now again, x3 = 2.0588 –
3 0588
16 0
−
+
F
HG I
KJ
2.
.3908
(– 0.3908) = 2.0813
Repeating this process, the successive approximations are
x4 = 2.0862 ...... x8 = 2.0943 etc.
Hence, the root is 2.094, correct to three decimal places.
Example 4. Find the root of the equation tan x + tanh x = 0 which lies in the
interval (1.6, 3.0) correct to four significant digits using the method of false
position.
Sol. Let f(x) ≡ tan x + tanh x = 0
Since f(2.35) = – 0.03
and f(2.37) = 0.009
Hence, the root lies between 2.35 and 2.37.
Using Regula-Falsi method,
x2 = x
x x
f x f x
f x
0
1 0
1 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( )
= −
−
+
F
HG I
KJ −
2 35
2 37 2 35
0 009 0 03
0 03
.
. .
. .
( . )
Let
and
x
x
0
1
2 35
2 37
=
=
.
.
= +
F
HG I
KJ =
2 35
0 02
0 039
0 03 2 365
.
.
.
( . ) .
Now f(x2) = – 0.00004 (–)ve
Hence, the root lies between 2.365 and 2.37.
Using Regula-Falsi method,
x3 = x2 –
x x
f x f x
f x
1 2
1 2
2
−
−
R
S
T
U
V
W
( ) ( )
( )
Replacing
by
x x
0 2
= −
−
+
F
HG I
KJ −
2 365
2 37 2 365
0 009 0 00004
0 00004
.
. .
. .
( . )
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 125
= +
F
HG I
KJ =
2 365
0 005
0 00904
0 00004 2 365
.
.
.
( . ) .
Hence, the required root is 2.365, correct to four significant digits.
Example 5. Using the method of false position, find the root of the equation
x6 – x4 – x3 – 1 = 0 up to four decimal places.
Sol. Let f(x) = x6 – x4 – x3 – 1
f(1.4) = – 0.056
f(1.41) = 0.102
Hence, the root lies between 1.4 and 1.41.
Using the method of false position,
x2 = x0 –
x x
f x f x
f x
1 0
1 0
0
−
−
R
S
T
U
V
W
( ) ( )
( )
= −
−
+
F
HG I
KJ −
1.
1. 1.
.102
4
41 4
0 0 056
0 056
.
( . )
Let, 1.
and 1.
x
x
0
1
4
41
=
=
= +
F
HG I
KJ =
1.
.158
1.
4
0 01
0
0 056 4035
.
( . )
Now f(x2) = – 0.0016 (–)ve
Hence, the root lies between 1.4035 and 1.41.
Using the method of false position,
x3 = x
x x
f x f x
f x
2
1 2
1 2
2
−
−
−
R
S
T
U
V
W
( ) ( )
( ) Replacing by
x x
0 2
= −
−
+
F
HG I
KJ −
1.
1. 1.
4035
41 4035
0 102 0 0016
0 0016
. .
( . )
= +
F
HG I
KJ =
1.
.1036
1.
4035
0 0065
0
0 0016 4036
.
( . )
Now f(x3) = – 0.00003 (–)ve
Hence, the root lies between 1.4036 and 1.41.
Using the method of false position,
x4 = x3 –
x x
f x f x
f x
1 3
1 3
3
−
−
R
S
T
U
V
W
( ) ( )
( )
126 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= +
−
+
F
HG I
KJ
1.
1. 1.
.102
4036
41 4036
0 0 00003
0 00003
.
( . )
= +
F
HG I
KJ =
1.
.10203
1.
4036
0 0064
0
0 00003 4036
.
( . )
Since x3 and x4 are approximately the same up to four decimal places, the
required root of the given equation is 1.4036.
Example 6. Find a real root of the equation x log10 x = 1.2 by Regula-Falsi
method correct to four decimal places.
Sol. Let f(x) = x log10 x – 1.2
Since f(2.74) = – .0005634
and f(2.741) = .0003087
Hence, the root lies between 2.74 and 2.741.
Using the method of False position,
x2 = x
x x
f x f x
f x
0
1 0
1 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( )
Let
and
x
x
0
1
2 74
2 741
=
=
.
.
= 2 74
2 741 2 74
0003087 0005634
0005634
.
. .
. ( . )
( . )
−
−
− −
R
S
T
U
V
W −
= 2.74 +
.
.
(. )
001
0008721
0005634
F
HG I
KJ
= 2.740646027
Now f(x2) = – .00000006016 i.e., (–)ve
Hence, the root lies between 2.740646027 and 2.741.
Using the method of false position,
x3 = x
x x
f x f x
f x
2
1 2
1 2
2
−
−
−
R
S
T
U
V
W
( ) ( )
( ) | Replacing x0 by x2
= 2.740646027 –
2 741 2 740646027
0003087 00000006016
00000006016
. .
. .
( . )
−
+
F
HG I
KJ −
= 2.740646096
Since x2 and x3 agree up to seven decimal places, the required root, correct
to four decimal places, is 2.7406.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 127
Example 7. (i) Apply False-position method to find the smallest positive root of
the equation
x – e–x = 0
correct to three decimal places.
(ii) Find a positive root of xex = 2 by the method of false position.
Sol. (i) Let f(x) = x – e–x
Since f(.56) = – .01121
and f(.58) = .0201
Hence, the root lies between .56 and .58.
Let x0 = .56 and x1 = .58
Using the method of false position,
x2 = x
x x
f x f x
f x
0
1 0
1 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( )
= .
. .
. .
( . )
56
58 56
0201 01121
01121
−
−
+
F
HG I
KJ −
= .56716
Now f(x2) = .00002619 i.e., (+)ve
Hence, the root lies between .56 and .56716.
Using the method of false position,
x3 = x
x x
f x f x
f x
0
2 0
2 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( ) | Replacing x1 by x2
= .
. .
. .
( . )
56
56716 56
00002619 01121
01121
−
−
+
F
HG I
KJ −
= .567143
Since x2 and x3 agree up to four decimal places, the required root correct to
three decimal places is 0.567.
(ii) Let f(x) = xex – 2
Since f(.852) = – .00263
and f(.853) = .001715
The root lies between .852 and .853.
Let x0 = .852 and x1 = .853
Using the method of false position,
x2 = x
x x
f x f x
f x
0
1 0
1 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( )
128 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= .
. .
. ( . )
( . )
852
853 852
001715 00263
00263
−
−
− −
R
S
T
U
V
W −
= .852605293
Now f(x2) = – .00000090833
Hence, the root lies between .852605293 and .853
Using the method of false position,
x3 = x
x x
f x f x
f x
2
1 2
1 2
2
−
−
−
R
S
T
U
V
W
( ) ( )
( ) | Replacing x0 by x2
= (.852605293) –
.
. ( . )
( . )
853 852605293
001715 00000090833
00000090833
−
− −
R
S
T
U
V
W −
= 0.852605501
Since x2 and x3 agree up to 6 decimal places, the required root correct to 6
decimal places is 0.852605.
Example 8. (i) Solve x3 – 5x + 3 = 0 by using Regula-Falsi method.
(ii) Use the method of false position to solve x3 – x – 4 = 0.
Sol. (i) Let f(x) = x3 – 5x + 3
Since f(.65) = .024625
and f(.66) = – .012504
The root lies between .65 and .66.
Let x0 = .65 and x1 = .66
Using the method of false position,
x2 = x0 –
x x
f x f x
f x
1 0
1 0
0
−
−
R
S
T
U
V
W
( ) ( )
( )
= .65 –
. .
. .
(. )
66 65
012504 024625
024625
−
− −
F
HG I
KJ
= .656632282
Now f(x2) = – .00004392
Hence, the root lies between .65 and .656632282.
Using the method of false position,
x3 = x0 –
x x
f x f x
f x
2 0
2 0
0
−
−
R
S
T
U
V
W
( ) ( )
( )
Replacing
by
x x
1 2
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 129
= .
. .
. .
(. )
65
656632282 65
00004392 024625
024625
−
−
− −
F
HG I
KJ
= .656620474.
Since x2 and x3 agree up to 4 decimal places, the required root is .6566,
correct up to four decimal places. Similarly, the other roots of this equation are
1.8342 and – 2.4909.
(ii) Let f(x) = x3 – x – 4
Since f(1.79) = – .054661
and f(1.80) = .032
The root lies between 1.79 and 1.80
Let x0 = 1.79 and x1 = 1.80
Using the method of false position,
x2 = x
x x
f x f x
f x
0
1 0
1 0
0
−
−
−
R
S
T
U
V
W
( ) ( )
( )
= 1.79
1.80 1.79
−
−
− −
R
S
T
U
V
W −
. ( . )
( . )
032 054661
054661
= 1.796307
Now, f(x2) = – .00012936
Hence, the root lies between 1.796307 and 1.80.
Using the method of false position,
x3 = x
x x
f x f x
f x
2
1 2
1 2
2
−
−
−
R
S
T
U
V
W
( ) ( )
( )
= 1.796307 –
1.8 1.796307
.032 ( .00012936)
( .00012936)
−
− −
R
S
T
U
V
W −
= 1.796321.
Since x2 and x3 are the same up to four decimal places, the required root is
1.7963, correct up to four decimal places.
130 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.21 CONVERGENCE OF REGULA-FALSI METHOD
If  xn  is the sequence of approximations obtained from
xn + 1 = xn –
( )
( ) ( )
( )
x x
f x f x
f x
n n
n n
n
−
−
−
−
1
1
(8)
and α is the exact value of the root of the equation f(x) = 0, then
Let xn = α + en
xn + 1 = α + en + 1
where en, en + 1 are the errors involved in nth and (n + 1)th approximations,
respectively.
Clearly, f(α) = 0. Hence, (8) gives
α + en + 1 = α + en –
( )
( ) ( )
. ( )
e e
f e f e
f e
n n
n n
n
−
+ − +
−
−
1
1
α α
α +
or en + 1 =
e f e e f e
f e f e
n n n n
n n
− −
−
+ − +
+ − +
1 1
1
( ) ( )
( ) ( )
α α
α α
=
+ ′ + ″ +
L
NMM
O
QPP
− + ′ + ″ +
L
N
MM
O
Q
PP
+ ′ + ″ +
L
NMM
O
QPP
− + ′ + ″ +
L
N
MM
O
Q
PP
−
−
−
−
−
e f e f
e
f
e f e f
e
f
f e f
e
f
f e f
e
f
n n
n
n n
n
n
n
n
n
1
2
1
1
2
2
1
1
2
2
2
2
2
( ) ( )
!
( ) ......
( ) ( )
!
( ) ......
( ) ( )
!
( ) ......
( ) ( )
!
( ) ......
α α α
α α α
α α α
α α α
=
− + − ″ +
− ′ +
− +
″ +
−
−
−
−
− −
( ) ( )
!
( ) ( ) ......
( ) ( )
( ) ( )
!
( ) ......
e e f
e e
e e f
e e f
e e e e
f
n n
n n
n n
n n
n n n n
1
1
1
1
1 1
2
2
α α
α α
=
″ +
′ +
+
F
HG I
KJ ″ +
−
−
e e
f
f
e e
f
n n
n n
1
1
2
2
( ) ......
( ) ( ) ......
α
α α
| ∵ f(α) = 0
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 131
or en + 1 ≈
e e f
f
n n − ″
′
1
2 !
( )
( )
α
α
(9)
(neglecting high powers of en, en – 1)
Let en + 1 = c en
k , where c is a constant and k  0.
∴ en = c ek
n – 1
or en – 1 = c–1/k en
1/k
∴ From (9), c en
k
≈
e c
e
f
f
n
k
n
k
−
″
′
1/
1/
2 !
.
( )
( )
α
α
=
″
′
−
+
c
e
f
f
k
n
k
1/
1 1/
2 !
.
( )
( )
α
α
Comparing the two sides, we get
k = 1 +
1
k
and c =
c f
f
k
−
″
′
1/
2 !
( )
( )
α
α
Now, k = 1 +
1
k
⇒ k2 – k – 1 = 0 ⇒ k = 1.618
Also, c = c–1/k .
1
2 !
( )
( )
f
f
″
′
α
α
c c
f
f
k
1
1
1
2
+
= =
″
′
1.618 ( )
( )
α
α
or c =
f
f
″
′
L
NM O
QP
( )
( )
α
α
2
0.618
This gives the rate of convergence and k = 1.618 gives the order of
convergence.
ASSIGNMENT 3.3
1. Solve x3 – 9x + 1 = 0 for the root lying between 2 and 4 by the method of false position.
2. Find real cube root of 18 by Regula-Falsi method.
3. Find the smallest positive root correct to three decimal places of the equation cosh x cos x
= – 1.
4. Determine the real roots of f(x) = x3 – 98 using False position method within Es = 0.1%.
5. Write a short note on Regula-Falsi method.
6. Using the False-position method, find x when x2 – 9 = 0. Give computer program using ‘C’.
132 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7. Find the real root of the equations
(i) x3 – 4x + 1 = 0 (ii) x3 – x2 – 2 = 0
(iii) x3 + x – 3 = 0 (iv) x3 – 5x – 7 = 0
by using the method of false-position.
8. Find the real root of the equations
(i) x4 – x3 – 2x2 – 6x – 4 = 0 (ii) x6 – x4 – x3 – 3 = 0
(iii) xex = 3 (iv) x2 – loge x – 12 = 0
(v) x = tan x (vi) 3x = cos x + 1
by using the method of false position.
9. (i) Explain Regula-Falsi method by stating at least one advantage over the bisection
method.
(ii) Discuss the method of false position.
10. Solve the following equations by Regula-Falsi method.
(i) (5 – x) ex = 5 near x = 5 (ii) x3 + x – 1 = 0 near x = 1
(iii) 2x – log10 x = 7 lying b/w 3.5 and 4 (iv) x3 + x2 – 3x – 3 = 0 lying b/w 1 and 2
(v) x3 – 3x + 4 = 0 b/w – 2 and – 3 (vi) x4 + x3 – 7x2 – x + 5 = 0 lying b/w 2 and 3.
11. Find the rate of convergence for Regula-Falsi method.
12. Illustrate the false position method by plotting the function on a graph and discuss the
speed of convergence to the root. Develop the algorithm for computing the roots using
the false-position technique.
13. Find all the roots of cos x – x2 – x = 0 to 5 decimal places.
14. A root of the equation f(x) = x – φ(x) = 0 can often be determined by combining the
iteration method with Regula-Falsi.
(i) With a given approximate value x0, we compute
x1 = φ(x0), x2 = φ(x1)
(ii) Observing that f(x0) = x0 – x1 and f(x1) = x1 – x2, we find a better approximation x′
using Regula-Falsi on the points (x0, x0 – x1) and (x1, x1 – x2).
(iii) This last x′ is taken as a new x0 and we start from (i) all over again.
Compute the smallest root of the equation x – 5 loge x = 0 with an error less than
0.5 × 10–4 starting with x0 = 1.3.
3.22 SECANT METHOD
This method is quite similar to that of the Regula-Falsi method except for the
condition f(x1) . f(x2)  0. Here the graph of the function y = f(x) in the
neighborhood of the root is approximated by a secant line or chords. Further,
the interval at each iteration may not contain the root.
Let the limits of interval initially be x0 and x1.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 133
Then the first approximation is given by:
x2 = x1 –
x x
f x f x
1 0
1 0
−
−
L
NM O
QP
( ) ( )
f(x1)
Again, the formula for successive approximation in general form is
xn+1 = xn –
x x
f x f x
n n
n n
−
−
L
NM O
QP
−
−
1
1
( ) ( )
f(xn)
If at any stage f(xn) = f(xn–1), this method will fail.
Hence this method does not always converge while the Regula-Falsi method
will always converge. The only advantage in this method lies in the fact that if
it converges, it will converge more rapidly than the Regula-Falsi method.
x2
x1
x0 x3 X
Y
o
Secant Method
EXAMPLES
Example 1. A real root of the equation f(x) = x3 – 5x + 1 = 0 lies in the interval
(0, 1). Perform four iterations of the secant method.
Sol. We have, x0 = 0, x1 = 1, f(x0) = 1, f(x1) = – 3
By Secant Method,
The first approximation is
x2 = x1 –
x x
f x f x
1 0
1 0
−
−
L
NM O
QP
( ) ( )
f(x1) = 0.25
f(x2) = – 0.234375.
134 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The second approximation is
x3 = x2 –
x x
f x f x
2 1
2 1
−
−
L
NM O
QP
( ) ( )
f(x2) = 0.186441
f(x3) = 0.074276
The third approximation is
x4 = x3 –
x x
f x f x
3 2
3 2
−
−
L
NM O
QP
( ) ( )
f(x3) = 0.201736
f(x4) = – 0.000470
The fourth approximation is
x5 = x4 –
x x
f x f x
4 3
4 3
−
−
L
NM O
QP
( ) ( )
f(x4) = 0.201640.
Example 2. Compute the root of the equation x2e–x/2 = 1 in the interval [0, 2]
using the secant method. The root should be correct to three decimal places.
Sol. We have,
x0 = 1.42, x1 = 1.43, f(x0) = – .0086, f(x1) = .00034.
By secant method,
The first approximation is
x2 = x1 –
x x
f x f x
1 0
1 0
−
−
L
NM O
QP
( ) ( )
f(x1)
= 1.43 –
1.43 1.42
.00034 .0086
−
+
F
HG I
KJ (.00034) = 1.4296
f(x2) = – .000011
The second approximation is
x3 = x2 –
x x
f x f x
2 1
2 1
−
−
L
NM O
QP
( ) ( )
f(x2)
= 1.4296 –
1.4296 1.42
.000011 .00034
−
− −
F
HG I
KJ (– .000011) = 1.4292
Since x2 and x3 agree up to three decimal places, the required root is 1.429.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 135
ASSIGNMENT 3.4
1. Write the procedure of the secant method to find a root of a polynomial equation to
implement it in ‘C’.
2. The equation x2 – 2x – 3 cos x = 0 is given
(i) Locate the smallest root in magnitude in an interval of length one unit.
(ii) Hence, find this root correct to 3 decimal points using the secant method.
3. Use the secant method to determine the root of the equation cos x – xex = 0.
Now we proceed to discuss some methods useful for obtaining the complex
roots of polynomial equations f(x) = 0.
3.23 LIN-BAIRSTOW’S METHOD OR METHOD FOR COMPLEX
ROOT
This method is applied to obtain complex roots of an algebraic equation with
real coefficients. The complex roots of such an equation occur in pairs a ± ib.
Each such pair corresponds to a quadratic factor
{x – (a + ib)}{x – (a – ib)} = x2 – 2ax + a2 + b2 = x2 + px + q
where coefficients p and q are real.
Let f(x) = xn + a1 xn – 1 + ...... + an – 1 x + an
If we divide f(x) by x2 + px + q, we obtain a quotient
Qn – 2 = xn – 2 + b1 xn – 3 + ...... + bn – 2
and a remainder Rn = Rx + S
Thus, f(x) = (x2 + px + q) (xn – 2 + b1 xn – 3 + ...... + bn – 2) + Rx + S
(10)
If x2 + px + q divides f(x) completely, the remainder Rx + S = 0 i.e., R = 0,
S = 0. Therefore, R and S depend upon p and q.
Our problem is to find p and q such that
R(p, q) = 0, S(p, q) = 0 (11)
Let p + Δp, q + Δq be the actual values of p and q which satisfy (11), then,
R(p + Δp, q + Δq) = 0; S(p + Δp, q + Δq) = 0
To find the corrections Δp, Δq, we have the following equations:
cn – 2 Δp + cn – 3 Δq = bn – 1
(cn – 1 – bn – 1) Δp + cn – 2 Δq = bn
136 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
After finding the values of bi’ s and ci’ s by synthetic division scheme, we
obtain approximate values of Δp and Δq, say Δp0 and Δq0.
If p0, q0 are the initial approximations, then their improved values are
p1 = p0 + Δp0, q1 = q0 + Δq0.
Now, taking p1 and q1 as the initial values and repeating the process, we
can get better values of p and q.
1. Synthetic division scheme is as follows
a0 (= 1) a1 a2 a3 ...... an – 2 an – 1 an
– pb0 – pb1 – pb2 ...... – pbn – 3 – pbn – 2 – pbn – 1 – p
– qb0 – qb1 ...... – qbn – 4 – qbn – 3 – qbn – 2 – q
b0 (= 1) b1 b2 b3 ...... bn – 2 bn – 1 bn
– pc0 – pc1 – pc2 ...... – pcn – 3 – pcn – 2 – p
– qc0 – qc1 ...... – qcn – 4 – qcn – 3 – q
c0 (= 1) c1 c2 c3 ...... cn – 2 cn – 1
2. Values of p0 and q0 should be given, otherwise we pick values of p and q
which make R and S both zero.
3. Bairstow’s method works well only if the starting trial values of p and q
are close to the correct values. In this case the convergence is quite rapid.
If the starting values are arbitrarily chosen, then the method does not
converge but very often diverges.
4. Δp, Δq provide new guesses. The process is repeated until the approximate
error falls below the prespecified tolerance.
| ∈p | =
Δp
p
i
i 1
+
× 100%
and | ∈q | =
Δq
q
i
i 1
+
× 100%.
EXAMPLES
Example 1. Solve x4 – 5x3 + 20x2 – 40x + 60 = 0 given that all the roots of f(x) = 0
are complex, by using Lin-Bairstow method. Take the values as p0 = – 4, q0 = 8.
NOTE
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 137
Sol. Starting with the values p0 = – 4, q0 = 8, we have
1 – 5 20 – 40 60
– 4 – 4 32 0 4
– 8 8 – 64 – 8
1 – 1 8 0(= bn – 1) – 4(= bn)
4 12 48 4
– 8 – 24 – 8
1 3(= cn – 3) 12(= cn – 2) 24(= cn – 1)
∴ cn – 1 – bn – 1 = 24 – 0 = 24 (12)
Corrections Δp0 and Δq0 are given by
cn – 2 Δp0 + cn – 3 Δq0 = bn – 1 ⇒ 12 Δp0 + 3 Δq0 = 0 (13)
and (cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn
⇒ 24 Δp0 + 12 Δq0 = – 4 (14)
Solving (13) and (14), we get
Δp0 = 0.1667, Δq0 = – 0.6667
∴ p1 = p0 + Δp0 = – 3.8333
q1 = q0 + Δq0 = 7.3333
Also, | ∈p | =
Δp
p
0
1
× 100%
=
0.1667
3.8333
−
× 100% = 4.3487%
and | ∈q | =
Δq
q
0
1
× 100%
=
− .6667
7.3333
× 100% = 9.0914%
138 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now, repeating the same process, i.e., dividing f(x) by x2 – 3.8333x + 7.3333,
we get
1 – 5 20 – 40 60
3.8333 – 4.4723 31.4116 – 0.125 3.8333
– 7.3333 8.5558 – 60.092 – 7.3333
1 – 1.1667 8.1944 – 0.0326 – 0.217
|
|
bn −
F
HG
I
KJ
1
|
|
bn
F
HG I
KJ
3.8333 10.2219 42.4845 3.8333
– 7.3333 – 19.555 – 7.3333
1 2.6666 11.083 22.8969
(= cn – 3) (= cn – 2) (= cn – 1)
∴ cn – 1 – bn – 1 = 22.8969 – (– 0.0326) = 22.9295
Corrections Δp1 and Δq1 are given by
11.083 Δp1 + 2.6666 Δq1 = – 0.0326
22.9295 Δp1 + 11.083 Δq1 = – 0.217
Solving, we get Δp1 = 0.0033
Δq1 = – 0.0269
∴ p2 = p1 + Δp1 = – 3.83
q2 = q1 + Δq1 = 7.3064
Also, | ∈p | =
Δp
p
1
2
× 100%
=
0.0033
3.83
−
× 100% = .08616%
and | ∈q | =
Δq
q
1
2
× 100%
=
− 0.0269
7.3064
× 100% = .3682%
So, one of the quadratic factors of f(x) is
x2 – 3.83x + 7.3064 (15)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 139
If α ± iβ are its roots, then,
2α = 3.83, α2 + β2 = 7.3064
giving, α = 1.9149, β = 1.9077
Hence, the pair of roots is 1.9149 ± 1.9077i
To find the remaining two roots of f(x) = 0, we divide f(x) by (15) as follows
1 – 5 20 – 40 60
3.83 – 4.4811 31.4539 3.83
– 7.3064 8.5485 – 60.0038 – 7.3064
1 – 1.17 8.2125 0.0024 – .0038
≈ 0 ≈ 0
The other quadratic factor is x2 – 1.17x + 8.2125
If γ ± iδ are its roots, then 2δ = 1.17, γ2 + δ2 = 8.2125
giving, γ = 0.585, δ = 2.8054
Hence, the pair of roots is 0.585 ± 2.8054 i.
Example 2. Find a quadratic factor of the polynomial
x4 + 5x3 + 3x2 – 5x – 9 = 0
starting with p0 = 3, q0 = – 5 by using Bairstow’s method.
Sol. We have
1 5 3 – 5 – 9
– 3 – 6 – 6 3 – 3
5 10 10 5
1 2 2 – 1(= bn – 1) 4(= bn)
– 3 3 – 30 – 3
5 – 5 5
1 – 1 10 – 36
↓ ↓ ↓
cn – 3 cn – 2 cn – 1
∴ cn – 1 – bn – 1 = – 36 + 1 = – 35
Corrections Δp0 and Δq0 are given by
cn – 2 Δp0 + cn – 3 Δq0 = bn – 1 ⇒ 10 Δp0 – Δq0 = – 1 (16)
and (cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn ⇒ – 35 Δp0 + 10 Δq0 = 4 (17)
140 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Solving (16) and (17), we get
Δp0 = – 0.09, Δq0 = 0.08
Thus p1, q1, the first approximations of p and q are given by
p1 = p0 + Δp0 = 2.91
q1 = q0 + Δq0 = – 4.92
| ∈p | =
Δp
p
0
1
× 100%
=
− 0.09
2.91
× 100% = 3.0927%
| ∈q | =
Δq
q
0
1
× 100%
=
0.08
4.92
−
× 100% = 1.6260%.
Repeating the same process, i.e., dividing f(x) by x2 + 2.91x – 4.92, we get
1 5 3 – 5 – 9
– 2.91 – 6.08 – 5.35 0.20 – 2.91
4.92 10.28 9.05 4.92
1 2.09 1.84 – 0.07 0.25
– 2.91 2.37 – 26.57 – 2.91
4.92 – 4.03 4.92
1 – 0.82 9.13 – 30.67
At this step, the corrections Δp1 and Δq1 are given by
9.13 Δp1 – 0.82 Δq1 = – 0.07
– 30.60 Δp1 + 9.13 Δq1 = 0.25
⇒ Δp1 = – 0.00745
Δq1 = 0.00241
Hence, the second approximations of p and q are given by
p2 = p1 + Δp1 = 2.91 – 0.00745 = 2.90255
q2 = q1 + Δq1 = – 4.92 + 0.00241 = – 4.91759
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 141
| ∈p | =
Δp
p
1
2
× 100%
=
− 0.00745
2.90255
× 100% = .2566%
| ∈q | =
Δq
q
1
2
× 100%
=
0.00241
4.91759
−
× 100% = .04901%.
Thus, a quadratic factor is
x2 + 2.90255 x – 4.91759
Dividing the given equation by this factor, we can obtain the other quadratic
factor.
ASSIGNMENT 3.5
1. Find the quadratic factor of x3 – 3.7x2 + 6.25x – 4.069 after two iterations. Use p0 = – 2.5,
q0 = 0.
2. Solve the equation x4 – 8x3 + 39x2 – 62x + 50 = 0 starting with p = q = 0.
3. Find the quadratic factor of x4 – 3x3 + 20x2 + 44x + 54 = 0 close to x2 + 2x + 2.
[Hint: Take p0 = 2, q0 = 2]
3.24 MULLER’S METHOD
In this method, f(x) is approximated by a second degree curve in the vicinity of
a root. The roots of the quadratic are then assumed to be the approximations to
the roots of the equation f(x) = 0.
The method is iterative, converges almost quadratically, and can be used
to obtain complex roots.
Let xi – 2, xi – 1, xi be the three distinct approximations to a root of f(x) = 0
and let yi – 2, yi – 1, yi be the corresponding values of y = f(x).
Assuming that P(x) = A(x – xi)2 + B(x – xi) + yi is the parabola passing
through the points (xi – 2, yi – 2), (xi –1, yi – 1) and (xi, yi), we have
yi – 1 = A(xi – 1 – xi)2 + B(xi – 1 – xi) + yi (18)
and yi – 2 = A(xi – 2 – xi)2 + B(xi – 2 – xi) + yi (19)
142 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
From equations (18) and (19), we get
yi – 1 – yi = A(xi – 1 – xi)2 + B(xi – 1 – xi) (20)
and yi – 2 – yi = A(xi – 2 – xi)2 + B(xi – 2 – xi) (21)
Solution of equations (20) and (21) gives,
A =
( ) ( ) ( ) ( )
( ) ( ) ( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2 1 1 2
1 2 1 2
(22)
and B =
( ) ( ) ( ) ( )
( ) ( ) ( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2
2
1 1
2
2
2 1 1 2
(23)
with the values of A and B given in (22) and (23), the quadratic equation now
gives next approximation xi + 1.
∴ xi + 1 – xi =
− ± −
B B A
A
2
4
2
yi
(24)
A direct solution from (24) leads to inaccurate results and therefore it is
usually written in the form,
xi + 1 – xi = −
± −
2
4
y
y
i
i
B B A
2
(25)
In (25), sign in denominator should be chosen so that the denominator will
be largest in magnitude. With this choice, equation (25) gives the next
approximation to the root.
3.25 ALGORITHM OF MULLER’S METHOD
Step 01. Start of the program.
Step 02. Input the variables xi, xi1, xi2
Step 03. Input absolute error-aerr
Step 04. Repeat Steps 5-12 until |Xn-Xi|  aerr
Step 05. Yi = y(Xi)
Step 06. Yil = y(Xi1)
Step 07. Yi2 = y(Xi2)
Step 08. a = A(Xi, Xi1, Xi2, Yi, Yi1, Yi2)
Step 09. b = B(Xi, Xi1, Xi2, Yi, Yi1, Yi2);
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 143
Step 10. Xn = approx (Xi, Yi, a, b);
Step 11. Check loop condition
Step 12. if no
Step 13. exit loop
Step 14. if yes
Step 15. Xi = Xn
Step 16. increment i
Step 17. End loop
Step 18. Print output
Step 19. End of program
Step 20. Start of section A
Step 21. take Xa, Xb, Xc, Ya, Yb, Yc
Step 22. x = ((Yb-Ya)*(Xc-Xa)-(Yc-Ya)*(Xb-Xa))/((Xb-Xa)*(Xc-Xa)
*(Xb-Xc))
Step 23. Return x
Step 24. End of section A
Step 25. Start of section B
Step 26. Take Xa, Xb, Xc, Ya, Yb, Yc
Step 27. c = (((Yc-Ya)*pow((Xb-Xa),2))-((Yb-Ya)
*pow((Xc-Xa),2)))/((Xb-Xa)*(Xc-Xa)*(Xb-Xc))
Step 28. Return c
Step 29. End of section B
Step 30. Start of section approx
Step 31. Take x, y, a, b
Step 32. c = sqrt(b*b-4*a*y)
Step 33. If (b + c)  (b-c): t = x-((2*y)/(b + c))
Step 34. Else: t = (x-((2*y)/(b-c)))
Step 35. Return t
Step 36. End of section approx
144 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.26 FLOW-CHART FOR MULLER’S METHOD
Start
Define fn. y(x)
Get initial approximation in array x
Get values of aerr, maxitr
Loop for itr = 1 to maxitr
Calculate li, di, mu, s
Is mu  0
Yes
No
li = (2*y(x[0])*di)/(– mu + s)
li = (2*yx[I]*di)/(– mu + s)
x[I + 1] = x[I] + 1 * (x[I] – x[I – 1])
A
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 145
A
Print itr, x(1)
Is fabs
(x[1] – x[0])
 aerr
Yes
No
Loop for i = 0 to 2
x[i] = x[i + 1]
End loop (i)
End loop (itr)
Print 'solution does
not converge
Print ‘‘solution’’
Stop
EXAMPLE
Example. Using Muller’s method, find the root of the equation
y(x) = x3 – 2x – 5 = 0
which lies between 2 and 3. Write its program in ‘C’ language.
Sol. Let xi – 2 = 1.9, xi – 1 = 2, xi = 2.1
then yi – 2 = – 1.941, yi – 1 = – 1, yi = .061
146 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A =
( ) ( ) ( ) ( )
( ) ( ) ( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2 1 1 2
1 2 1 2
=
( .2) ( 1.061) ( .1) ( 2.002)
(.1) ( .1) ( .2)
− − − − −
− −
=
. .
.
2122 2002
002
−
= 6
B =
( ) ( ) ( ) ( )
( ) ( ) ( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2
2
1 1
2
2
2 1 1 2
=
( .2) ( 1.061) ( .1) ( 2.002)
( .1) ( .1) ( .2)
2 2
− − − − −
− − −
=
− +
−
. .
.
04244 0 02002
002
= 11.21
The next approximation to the desired root is
xi + 1 = xi –
2
4
2
y
y
i
i
B B A
± −
= 2 1
2 061
1121 1121 24 061
2
.
(. )
. ( . ) ( . )
−
± − ×
= 2.1 –
0.122
11.21 11.1445
+
| Taking (+)ve sign
= 2.094542
The procedure can now be repeated with the three approximations as 2,
2.1, and 2.094542.
Let xi–2 = 2, xi–1 = 2.1 and xi = 2.094542
then yi–2 = – 1, yi–1 = .061 and yi = – .0001058
A =
( )( ) ( )( )
( )( )( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2 1 1 2
1 2 1 2
=
( )(. ) ( )( )
( )( )( )
2 061 1
2 2
− + − − − +
− − −
2.094542 .0001058 2.1 2.094542 .0001058
2.1 2.1 2.094542 2.094542
=
( .094542)(.0611058) (.005458)( .9998942)
(.1)(.005458)( .094542)
− − −
−
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 147
=
− +
−
.005777064 .005457422
.000051601
=
−
−
.000319642
.000051601
= 6.194492
B =
( ) ( ) ( ) ( )
( )( )( )
x x y y x x y y
x x x x x x
i i i i i i i i
i i i i i i
− − − −
− − − −
− − − − −
− − −
2
2
1 1
2
2
2 1 1 2
=
( .094542) (.0611058) (.005458) ( .9998942)
( .1)(.005458)( .094542)
2 2
− − −
− −
=
(. )(. ) (. )(. )
.
008938189 0611058 000029789 9998942
000051601
+
=
.000546175 + .000029785
.000051601
= 11.161799
The next approximation to the desired root is
xi+1 = xi –
2
B B A
2
y
y
i
i
± − 4
= 2.094542 –
2( .0001058)
11.161799 (11.161799) 4(6.194492)( .0001058)
2
−
± − −
= 2.094542 +
.0002116
11.161799 11.161916
+
= 2.094551
Hence, the required root is 2.0945 correct up to 4 decimal places.
The procedure can be repeated with the three approximations as 2.1,
2.094542, and 2.094551.
/* *****************************************************
PROGRAM TO IMPLEMENT MULLER’S METHOD OF FINDING ROOTS
******************************************************** */
//...HEADER FILES DECLARATION
#include stdio.h
#include string.h
#include conio.h
148 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
#include math.h
#include process.h
#include dos.h
//... Function Prototype Declaration
float y(float);
float A(float,float,float,float,float,float);
float B(float,float,float,float,float,float);
float approx(float,float,float,float);
void main()
{
//... Variable Declaration Field
//... Floating Type
float a,b;
float Xi,Xi1,Xi2;
float Yi,Yi1, Yi2;
float Xn;
float aerr;
//... Integer Type
int i=1;
int loop=0;
//... Invoke Function Clear Screen
clrscr();
//...Input Section
printf(nn );
printf(Enter the values of X(i),X(i-1),X(i-2), absolute
errorn);
printf(nn Enter the value of X(i) - );
scanf(%f,Xi);
printf(nn Enter the value of X(i-1) - );
scanf(%f,Xi1);
printf(nn Enter the value of X(i-2) - );
scanf(%f,Xi2);
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 149
printf(nn Enter the value of Absolute Error – );
scanf(%f,aerr);
printf(nn Processing );
for(loop=0; loop10;loop++)
{
delay(200);
printf(...);
}
printf(nnn);
//...Calculation And Processing Section
while(1)
{
Yi=y(Xi);
Yi1=y(Xi1);
Yi2=y(Xi2);
a=A(Xi,Xi1,Xi2,Yi,Yi1,Yi2);
b=B(Xi,Xi1,Xi2,Yi,Yi1,Yi2);
Xn=approx(Xi,Yi,a,b);
printf(nn After Iteration %d value of x-%f,i,Xn);
if(fabs(Xn-Xi)aerr)
{
goto jmp;
}
Xi=Xn;
i++;
}
jmp:
//...Output Section
printf(nn After %d iterations root is-%6.6fn,i+1,Xn);
//...Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch();
}
//...Termination Of Main Execution Thread
150 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
//...Function y body
float y(float x)
{
float t;
t=(x*x*x)-(2*x)-5;
return(t);
}
//...Termination of Function y
//...Function A body
float A(float Xa;float Xb,float Xc,float Ya,float Yb,
float Yc)
{
float x;
x=((Yb-Ya)*(Xc-Xa)-(Yc–Ya)*(Xb-Xa))/((Xb-Xa)*(Xc-Xa)
*(Xb-Xc));
return(x);
}
//...Termination of function A
//...Function B body
float B(float Xa,float Xb,float Xc,float Ya,float Yb,
float Yc)
{
float c;
c=(((Yc-Ya)*pow((Xb-Xa),2))-((Yb-Ya)*pow((Xc-Xa),2)))
/((Xb-Xa)*(Xc-Xa)*(Xb-Xc));
return(c);
}
//...Termination of Function B
//...Function approx body
float approx(float x,float y,float a,float b)
{
int c;
float t;
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 151
c=sqrt(b*b-4*a*y);
if((b+c)(b-c))
{
t=x-((2*y)/(b+c));
}
else
{
t=(x-((2*y)/(b-c)));
}
return (t);
}
//...Termination of Function approx
OUTPUT
Enter the values of X(i),X(i-1),X(i-2), absolute error
Enter the value of X(i) - 3
Enter the value of X(i-1) - 2
Enter the value of X(i-2) - 1
Enter the value of Absolute Error - 0.000001
Processing ..................................
After Iteration 1 value of x - 2.085714
After Iteration 2 value of x - 2.094654
After Iteration 3 value of x - 2.094550
After Iteration 4 value of x - 2.094552
After Iteration 5 value of x - 2.094552
After 6 iteration root is - 2.094552
Press Enter to Exit
ASSIGNMENT 3.6
1. Use Muller’s method to find a root of the equations:
(i) x3 – x – 1 = 0 (ii) x3 – x2 – x – 1 = 0
which lie between 1 and 2.
2. Apply Muller’s method to find the root of the equation cos x = xex which lies between
0 and 1.
3. Using Muller’s method, find a root of the equations:
(i) x3 – 3x – 5 = 0 which lie between 2 and 3 (ii) log x = x – 3 taking x0 = 0.25, x1 = 0.5
and x2 = 1
152 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(iii) x3 –
1
2
= 0 take x0 = 0, x1 = 1 and x2 =
1
2
.
4. Solve by Muller’s method: x3 + 2x2 + 10x – 20 = 0 by taking x = 0, x = 1, x = 2 as initial
approximations.
3.27 THE QUOTIENT-DIFFERENCE METHOD
This is a general method to obtain the approximate roots of polynomial
equations. Let the given cubic equation be
f(x) ≡ a0x3 + a1x2 + a2x + a3 = 0 (26)
and let x1, x2, and x3 be its roots such that 0  | x1 |  | x2 |  | x3 |.
The roots can be obtained, directly by considering the transformed equation
a3x3 + a2x2 + a1x + a0 = 0 (27)
whose roots are the reciprocals of those of (26).
We then have
1
3
3
2
2
1 0 0
a x a x a x a
x
i i
i
+ + +
=
=
∞
∑ α
so that, (a3 x3 + a2 x2 + a1x + a0) (α0 + α1x + α2x2 + ......) = 1 (28)
Comparing the coefficients of like powers of x on both sides of (28), we get
α0 =
1
0
a
, α1 = −
a
a
1
0
2
, α2 =
−
+
a
a
a
a
2
0
2
1
2
0
3
Hence, q1
(1) =
α
α
1
0
1
0
= −
a
a
q1
(2) =
α
α
2
1
2 0 1
2
0 1
=
−
a a a
a a
and so, Δ1
(1) = q1
(2) – q1
(1) =
a
a
2
1
, Δ2
(0) =
a
a
3
2
In general, Δm
(m) =
a
a
m
m
+ 1
, m = 1, 2, 3, ......, (n – 1)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 153
qm
(1 – m) = 0, m = 2, 3, ......, n
(i.e., q1
(0), q2
(– 1), q3
(– 2), ......, top q’s are 0)
We also set Δ0
(k) = Δn
(k) = 0, for all k
[i.e., First and last columns of Q-d table are zero].
Following is the Quotient-difference table for a cubic equation
q1
(0) q2
(– 1) q3
(– 2)
Δ0
(1) Δ1
(0) Δ2
(– 1) Δ3
(– 2)
q1
(1) q2
(0) q3
(– 1)
Δ0
(2) Δ1
(1) Δ2
(0) Δ3
(– 1)
q1
(2) q2
(1) q3
(0)
Δ0
(3) Δ1
(2) Δ2
(1) Δ3
(0)
(i) If a Δ-element is at the top of a rhombus, then the product of one pair is
equal to that of the other pair.
For example, in rhombus
Δ1
(1)
q1
(2) q2
(1)
Δ1
(2)
we have Δ1
(1) . q2
(1) = Δ1
(2) . q1
(2)
from which Δ1
(2) can be computed, since other quantities are known.
(ii) If a q-element is at the top, then the sum of one pair is equal to that of
the other pair.
In the rhombus,
q2
(0)
Δ1
(1) Δ2
(0)
q2
(1)
we have q2
(0) + Δ2
(0) = q2
(1) + Δ1
(1)
from which q2
(1) can be computed when q2
(0), Δ1
(1), Δ2
(0) are known.
154 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
As the building up of the table proceeds, the quantities q1
(i), q2
(i), q3
(i) tend
to roots of cubic equations.
The disadvantage of this method is that additional computation is also
necessary. This method can be applied to find the complex roots and multiple
roots of polynomials and also for determining the eigen values of a matrix.
An important feature of this method is that it gives approximate values of
all the roots simultaneously, enabling one to use this method to obtain the first
approximation of all the roots and then apply a rapidly convergent method
such as the generalized Newton method.
EXAMPLE
Example. Find the real roots of the equation x3 – 6x2 + 11x – 6 = 0 using the
Quotient-difference method.
Sol. Here, a0 = 1, a1 = – 6, a2 = 11, a3 = – 6
Now, q1
(1) = –
a
a
1
0
= 6
q1
(2) =
a a a
a a
2 0 1
2
0 1
11 36
6
−
=
−
−
= 4.167
Δ1
(1) = q1
(2) – q1
(1) =
a
a
2
1
= – 1.833
Also, q2
(0) = 0, q3
(– 1) = 0
Δ2
(0) =
a
a
3
2
6
11
= − = – 0.5454.
The first two rows containing starting values of
q1
(1) q2
(0) q3
(– 1)
Δ0
(2) Δ1
(1) Δ2
(0) Δ3
(– 1)
i.e., 6 0 0
0 – 1.833 – 0.5454 0
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 155
The succeeding rows can be constructed as below:
Δ0 q1 Δ1 q2 Δ2 q3 Δ3
6 0 0
0 – 1.833 – 0.5454 0
4.167 1.288 0.5454
0 – 0.5666 – 0.2310 0
3.600 1.624 0.7764
0 – 0.2556 – 0.1105 0
3.344 1.770 0.8869
0 – 0.1353 – 0.0553 0
3.209 1.8550 0.9422
0 – 0.0782 – 0.0281 0
3.131 1.9051 0.9703
0 – .0476 – .0143 0
3.083 1.9384 0.9846
0 – .0299 – .0073 0
3.053 1.961 .9919
0 – .0192 – .0037 0
3.0338 1.976 .9956
0 – .0125 – .0019 0
3.0213 1.987 .9975
It is evident that q1, q2, q3 are gradually converging to the roots 3, 2, and 1,
respectively.
ASSIGNMENT 3.7
1. Apply the quotient-difference method to obtain the approximate roots of the equation
f(x) ≡ x3 – 7x2 + 10x – 2 = 0.
156 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3.28 HORNER’S METHOD
This is the best method of finding the real root of a numerical polynomial
equation. The method works as follows.
Let a positive root of f(x) = 0 lie in between α and α + 1, where α is an
integer. Then the value of the root is α . d1d2d3 ...... where α is the integral part
and d1, d2, d3, ...... are the digits in the decimal part.
Finding d1. First diminish the roots of f(x) = 0 by α so that the roots of the
transformed equation lie between 0 and 1. i.e., the root of the transformed
equation is 0 . d1d2d3 ......
Now multiply the roots of the transformed equation by 10 so that the root
of the new equation is d1 . d2d3 ...... . Thus the first figure after the decimal
place is d1.
Again, diminish the root by d1 and multiply the roots of the resulting
equation by 10 so that the root is d2 . d3 ...... i.e., the second figure after the
decimal place is d2.
Continue the process to obtain the root to any desired degree of accuracy
digit by digit.
EXAMPLE
Example. Using Horner’s method, find the root of x3 + 9x2 – 18 = 0, correct to
two decimal places.
Sol. Let f(x) = x3 + 9x2 – 18
Then f(1) = 1 + 9 – 18 = – ve
and f(2) = 8 + 36 – 18 = + ve
i.e., f(1) and f(2) are of opposite signs. Hence f(x) = 0 has a root between 1 and
2.
∴ The integral part of the root of f(x) = 0 is 1.
Now diminish the roots of the equation by 1.
1 1 9 0 – 18
0 1 10 10
1 1 10 10 – 8
0 1 11
1 1 11 21
0 1
1 12
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 157
∴ The transformed equation is x3 + 12x2 + 21x – 8 = 0.
This equation has a root between 0 and 1.
Multiply the roots of this equation by 10.
∴ The new equation is f1(x) = x3 + 120x2 + 2100x – 8000 = 0
We can see that f1(3)  0 and f1(4)  0
∴ The root of f1(x) = 0 lies in between 3 and 4.
Hence the first figure after the decimal place is 3.
Now, diminish the roots of f1(x) = 0 by 3.
3 1 120 2100 – 8000
0 3 369 7407
3 1 123 2469 – 593
0 3 378
3 1 126 2847
0 3
3 129
The transformed equation is 3x3 + 129x2 + 2847x – 593 = 0, whose root
lies between 0 and 1.
Multiplying the roots of this equation by 10, we get the new equation:
f2(x) = 3x3 + 1290x2 + 284700x – 593000 = 0
We can easily see that root of f2(x) lies between 2 and 3, since f2(2)  0 and
f3(3)  0.
∴ The second figure after the decimal place is 2.
Diminish the roots of f2(x) = 0 by 2
2 3 1290 284700 – 593000
0 6 2592 574584
2 3 1296 287292 – 18416
0 6 2604
2 3 1302 289896
0 6
3 1308
The transformed equation is 3x3 + 1308x2 + 289896x – 18416 = 0
whose root lies between 0 and 1.
158 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Multiplying the roots of this equation by 10, we get the new equation as
f3(x) = 3x3 + 13080x2 + 28989600x – 18416000 = 0
We can easily see that f3(0)  0 and f3(1)  0, i.e., the root of f3(x) = 0 lies
between 0 and 1.
∴ The third figure after the decimal is zero. We can stop here as the case
requires that the root be correct to 2 decimals. Hence the root is 1.32.
ASSIGNMENT 3.8
1. Find a root of the following equations correct to three decimal places using Horner’s
method.
(i) x3 + 3x2 – 12 x – 11 = 0 (ii) x4 + x3 – 4x2 – 16 = 0
(iii) x3 – 30 = 0.
2. Find the positive root of the equation x3 + x2 + x – 100 = 0, correct to four decimal places
using Horner’s method.
3.29 NEWTON-RAPHSON METHOD
This method is generally used to improve the result obtained by one of the
previous methods. Let x0 be an approximate root of f(x) = 0 and let x1 = x0 + h be
the correct root so that f(x1) = 0.
Expanding f(x0 + h) by Taylor’s series, we get
f(x0) + hf ′(x0) +
h2
2!
f″(x0) + ...... = 0
Since h is small, neglecting h2 and higher powers of h, we get
f(x0) + hf ′(x0) = 0 or h = –
f x
f x
( )
( )
0
0
′
(29)
A better approximation than x0 is therefore given by x1, where
x1 = x0 –
f x
f x
( )
( )
0
0
′
Successive approximations are given by x2, x3, ....... , xn + 1, where
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
(30) (n = 0, 1, .......)
which is the Newton-Raphson formula.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 159
1. This method is useful in cases of large values of f ′(x), i.e., when the
graph of f(x) while crossing the x-axis is nearly vertical.
2. If f ′(x) is zero or nearly 0, the method fails.
3. Newton’s formula converges provided the initial approximation x0 is
chosen sufficiently close to the root.
In the beginning, we guess two numbers b and c such that f(b) and f(c)
are of opposite signs. Then the first approximate root a lies between b
and c.
4. This method is also used to obtain complex roots.
3.30 CONVERGENCE
Comparing (30) with xn + 1 = φ (xn) of the iteration method, we get
φ(xn) = xn + 1 = xn –
f x
f x
n
n
( )
( )
′
In general, φ(x) = x –
f x
f xn
( )
( )
′
which gives φ′(x) =
f x f x
f x
( ) ( )
[ ( )]
″
′ 2
Since the iteration method converges if | φ′ (x) |  1
∴ Newton’s method converges if
| f (x) f ″ (x) |  [ f ′ (x)]2
in the interval considered.
Assuming f(x), f ′(x), and f ″(x) to be continuous, we can select a small interval
in the vicinity of the root α in which the above condition is satisfied.
The rate at which the iteration method converges if the initial approximation
to the root is sufficiently close to the desired root is called the rate of
convergence.
3.31 ORDER OF CONVERGENCE
Suppose xn differs from the root α by a small quantity en so that
xn = α + en and xn + 1 = α + en + 1
NOTE
160 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Then (30) becomes, en + 1 = en –
f e
f e
n
n
( )
( )
α
α
+
′ +
= en –
f e f
e
f
f e f
n
n
n
( ) ( )
!
( ) ......
( ) ( ) ......
α α α
α α
+ ′ + ″ +
′ + ″ +
2
2
(By Taylor’s expansion)
= en –
e f
e
f
f e f
n
n
n
′ + ″ +
′ + ″ +
( ) ( ) .......
( ) ( ) ......
α α
α α
2
2 | ∵ f(α) = 0
=
e f
f e f
n
n
2
2
″
′ + ″
( )
[ ( ) ( )]
α
α α
| Neglect high powers of en
=
en
2
2
f
f e
f
f
n
″
′ +
″
′
R
S
T
U
V
W
( )
( )
( )
( )
α
α
α
α
1
=
e f
f
e
f
f
n
n
2 1
2
1
.
( )
( )
( )
( )
″
′
+
″
′
R
S
T
U
V
W
−
α
α
α
α
=
e f
f
e
f
f
n
n
2
2
1
″
′
−
″
′
+
R
S
T
U
V
W
( )
( )
( )
( )
.......
α
α
α
α
=
e f
f
e f
f
n n
2 3 2
2 2
″
′
−
″
′
R
S
T
U
V
W
( )
( )
( )
( )
α
α
α
α
+ .......
or
e
e
n
n
+1
2 =
1
2 2
2
f
f
e f
f
n
″
′
−
″
′
R
S
T
U
V
W
( )
( )
( )
( )
α
α
α
α
+ .......
≈
f
f
″
′
( )
( )
α
α
2
(Neglecting terms containing powers of en)
Hence by definition, the order of convergence of Newton-Raphson method
is 2, i.e., Newton-Raphson method is quadratic convergent.
This also shows that subsequent error at each step is proportional to the
square of the previous error and as such the convergence is quadratic.
Hence, if at the first iteration we have an answer correct to one decimal
place, then it should be correct to two places at the second iteration, and to
four places at the third iteration.
This means that the number of correct decimal places at each iteration is
almost doubled.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 161
∴ Method converges very rapidly.
Due to its quadratic convergence, the formula (30) is also termed as a second
order formula.
3.32 GEOMETRICAL INTERPRETATION
Let x0 be a point near the root α of equation f(x) = 0, then tangent at A{x0, f(x0)}
is
y – f (x0) = f ′(x0) (x – x0)
Y
O X
x2
A
x1 x0
{x , f(x )}
0 0
A2
A1
y
=
f
(
x
)
a
It cuts the x-axis at x1 = x0 –
f x
f x
( )
( )
0
0
′
which is one approximation to root α. If A1 corresponds to x1 on the curve, then
the tangent at A1 will cut the x-axis at x2, nearer to α and is therefore another
approximation to root α.
Repeating this process, we approach the root α quite rapidly. Hence the
method consists of replacing the part of the curve between A and the x-axis by
the means of the tangent to the curve at A0.
3.33 ALGORITHM OF NEWTON-RAPHSON METHOD
Step 01. Start of the program
Step 02. Input the variables x0, n for the task
Step 03. Input Epsilon  delta
Step 04. for i = 1 and repeat if i = n
Step 05. f0 = f(x0)
162 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Step 06. df0 = df(x1)
Step 07. if |df0| = delta
a. Print Slope too small
b. Print x0, f0, df0, i
c. End of Program
Step 08. x1 = x0-(f0/df0)
Step 09. if |(x1-x0)/x1| epsilon
a. Print convergent
b. Print x1, f(x1), i
c. End of Program
Step 10. x0 = x1
Step 11. End Loop
3.34 FLOW-CHART OF NEWTON–RAPHSON METHOD
START
Define function f(x)
Define function d f(x)
Get the values of x , aerr, maxitr
0
Loop for itr = 1 to maxitr
h = f (x )/ d f(x )
x = x – h
0 0
1 0
Print itr, x1
Is fabs (h)
 aerr
No x = x
0 1
Yes
Print solution
End loop (itr)
STOP
Print ‘‘solution does
not converge”
STOP
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 163
3.35 NEWTON’S ITERATIVE FORMULAE FOR FINDING INVERSE,
SQUARE ROOT
1. Inverse. The reciprocal or inverse of a number ‘a’ can be considered as a
root of the equation
1
x
– a = 0, which can be solved by Newton’s method.
Since f(x) =
1
x
– a, f ′(x) = –
1
2
x
∴ Newton’s formula gives
xn + 1 = xn +
1
1
2
x
a
x
n
n
−
F
HG I
KJ
F
HG
I
KJ
xn + 1 = xn (2 – axn)
2. Square root. The square root of ‘a’ can be considered a root of the equation
x2 – a = 0, solvable by Newton’s method.
Since f(x) = x2 – a, f ′(x) = 2x
xn + 1 = xn –
x a
x
n
n
2
2
−
xn + 1 =
1
2
x
a
x
n
n
+
F
HG
I
KJ
3. Inverse square root. Equation is
1
2
x
– a = 0
Iterative formula is
xn + 1 =
1
2
xn (3 – a xn
2)
4. General formula for pth root. The pth root of a can be considered a
root of the equation xp – a = 0. To solve this by Newton’s method, we have
f(x) = xp – a and hence, f ′(x) = pxp – 1
164 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ The iterative formula is xn + 1 = xn –
( )
x a
px
n
p
n
p
−
− 1
xn + 1 =
( )
p x a
px
n
p
n
p
− +
−
1
1
Also, the general formula for the reciprocal of pth root of a is
x n + 1 = xn
p ax
p
n
p
+ −
F
HG
I
KJ
1
.
3.36 RATE OF CONVERGENCE OF NEWTON’S SQUARE ROOT FOR-
MULA
Let a = α so that a = α2 . If we write
xn = α
1
1
+
−
F
HG
I
KJ
e
e
n
n
then, xn + 1 = α
1
1
1
1
+
−
F
HG
I
KJ
+
+
e
e
n
n
(31)
Also, by formula, xn + 1 =
1
2
x
a
x
n
n
+
F
HG I
KJ, we get
xn + 1 =
1
2
1
1
1
1
α
α
+
−
F
HG
I
KJ +
−
+
F
HG
I
KJ
L
N
MM
O
Q
PP
e
e
a e
e
n
n
n
n
= α
1
1
2
2
+
−
F
HG
I
KJ
e
e
n
n
(32) (∵ a = α2)
Comparing (31) and (32), we get en + 1 = en
2
confirming quadratic convergence of Newton’s method.
3.37 RATE OF CONVERGENCE OF NEWTON’S INVERSE FORMULA
Let α =
1
a
i.e., a =
1
α
. If we write xn = α(1– en)
then, xn + 1 = α (1 – en + 1)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 165
By formula, xn + 1 = xn (2 – axn), we get
xn + 1 = α(1– en) [2 – aα (1– en)] = α(1– en
2) | ∵ aα = 1
Comparing, we get en+1 = en
2, hence, convergence is quadratic.
EXAMPLES
Example 1. Using Newton-Raphson method, find the real root of the
equation 3x = cos x + 1 correct to four decimal places. Give computer program
using ‘C’.
Sol. Let f(x) = 3x – cos x – 1
Since f(0) = – 2 = (–)ve;
f(1) = 1.4597 = (+)ve
∴ A root of f(x) = 0 lies between 0 and 1. It is nearer to 1. Let us take
x0 = 0.6.
Also, f ′(x) = 3 + sin x
Newton’s iteration formula gives,
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
= xn –
3 1
3
x x
x
n n
n
− −
+
cos
sin
=
x x x
x
n n n
n
sin cos
sin
+ +
+
1
3
If n = 0, the first approximation x1 is given by,
x1 =
x x x
x
0 0 0
0
1
3
sin cos
sin
+ +
+
=
0 6 6 0 6 1
3 0 6
. sin cos .
sin .
+ +
+
= .6071
If n = 1,
the second approximation is
x2 =
x x x
x
1 1 1
1
1
3
sin cos
sin
+ +
+
=
. sin (. ) cos(. )
sin (. )
6071 6071 6071 1
3 6071
+ +
+
= 0.6071
Clearly x1 = x2. Hence the desired root is 0.6071, correct to 4 decimal places.
166 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
/* ********************************************************
Program made for NEWTON RAPHSON to solve the equation
******************************************************* *
//....including source header files
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//....defining formulae
# define f(x) 3*x -cos(x)-1
# define df(x) 3+sin(x)
//...Function Declaration prototype
void NEW_RAP();
//... Main Execution Thread
void main()
{
clrscr();
printf (n Solution by NEWTON RAPHSON method n);
printf (n Equation is: );
printf (nttt 3*X - COS X - 1=0 nn );
NEW_RAP();
getch();
}
//...Function Declaration
void NEW_RAP()
{
//...Internal Declaration Field
long float x1,x0;
long float f0,f1;
long float df0;
int i=1;
int itr;
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 167
float EPS;
float error;
/*Finding an Approximate ROOT of Given Equation, Having
+ve Value*/
for(x1=0;;x1 +=0.01)
{
f1=f(x1);
if (f1  0)
{
break;
}
}
/*Finding an Approximate ROOT of Given Equation, Having
-ve value*/
x0=x1-0.01;
f0=f(x0);
printf( Enter the number of iterations: );
scanf( %d,itr);
printf( Enter the maximum possible error: );
scanf(%f,EPS);
if (fabs(f0)  f1)
{
printf(ntt The root is near to %.4fn,x1);
}
If (f1  fabs(f(x0)))
{
printf(ntt The root is near to %.4fn,x0);
}
x0=(x0+x1)/2;
for(;i=itr;i++)
{
f0=f(x0);
df0=df(x0);
x1=x0 - (f0/df0);
printf(ntt The %d approximation to the root is:
%f,i,x1);
168 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
error=fabs(x1-x0);
if(errorEPS)
{
break;
}
x0 = x1;
}
if(errorEPS)
{
prinf(nnt NOTE:- );
printf(The number of iterations are not sufficient.);
}
printf(nnnttt ------------------------------);
printf(nttt The root is %.4f ,x1);
printf(nttt ------------------------------);
}
OUTPUT
Solution by NEWTON RAPHSON method
Equation is:
3*X - cos X - 1=0
Enter the number of iterations: 10
Enter the maximum possible error: .0000001
The root is near to 0.6100
The 1 approximation to the root is:0.607102
The 2 approximation to the root is:0.607102
The 3 approximation to the root is:0.607102
--------------------------------
The root is 0.6071
--------------------------------
Example 2. Using Newton’s iterative method, find the real root of x log10 x = 1.2,
correct to five decimal places.
Sol. f(x) = x log10 x – 1.2
∵ f(1) = – 1.2 = (–)ve
f(3) = 3 log10 3 – 1.2 = (+)ve
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 169
So a root of f(x) = 0 lies between 1 and 3.
Let us take x0 = 2.
and f ′(x) = log10 x + log10 e = log10 x + 0.43429
Newton’s iteration formula gives,
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
= xn –
x x
x
n n
n
log .
log .
10
10
12
43429
−
+
=
.43429 1.
.43429
x
x
n
n
+
+
2
10
log
(33)
Given n = 0, the first approximation is
x1 =
.43429 1.
.43429
x0
10
2
2
+
+
log
= 2.81 (∵ x0 = 2)
Similarly, given n = 1, 2, 3, 4 in (33), we get
x2 = 2.741, x3 = 2.74064, x4 = 2.74065, x5 = 2.74065
Clearly, x4 = x5
Hence the required root is 2.74065, correct to five decimal places.
Example 3. Evaluate 12 to four decimal places by Newton’s iterative method.
Sol. Let x = 12 so that x2 – 12 = 0 (34)
Take f(x) = x2 – 12, Newton’s iteration formula gives,
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
= xn –
x
x
n
n
2
12
2
−
=
1
2
12
x
x
n
n
+
F
HG
I
KJ (35)
Now, since f(3) = – 3 (–)ve
f(4) = 4 (+)ve
∴ The root of (34) lies between 3 and 4.
Given x0 = 3.5, (35) gives,
x1 =
1
2
12
0
0
x
x
+
F
HG
I
KJ =
1
2
3
12
3
.5
.5
+
F
HG I
KJ = 3.4643
x2 =
1
2
12
1
1
x
x
+
F
HG I
KJ = 3.4641
x3 = 3.4641
170 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since x2 = x3 up to 4 decimal places,
we have 12 = 3.4641.
Example 4. Using Newton’s iterative method, find the real root of
x sin x + cos x = 0 which is near x = π, correct to 3 decimal places.
Sol. We have
f(x) = x sin x + cos x and f ′(x) = x cos x
The iteration formula is
xn + 1 = xn –
x x x
x x
n n n
n n
sin cos
cos
+
with x0 = π, x1 = x0 –
x x x
x x
0 0 0
0 0
sin cos
cos
+
= π –
π π π
π π
sin cos
cos
+
= 2.8233
Successive iteratives are
x2 = 2.7986, x3 = 2.7984, x4 = 2.7984
Since x3 = x4, the required root is 2.798, correct to three decimal places.
Example 5. Find a real root of the equation x = e–x using the Newton-Raphson
method.
Sol. We have f(x) = xex – 1
then, f ′(x) = (1+ x) ex
Let x0 = 1
then, x1 = 1–
e
e
−
F
HG I
KJ
1
2
=
1
2
1
1
+
F
HG I
KJ
e
= 0.6839397
Now, f(x1) = 0.3553424 and f ′(x1) = 3.337012
so that, x2 = 0.6839397 –
0 3553424
3 337012
.
.
= 0.5774545
Proceeding in this way, we obtain
x3 = 0.5672297, x4 = 0.5671433
Hence the required root is 0.5671, correct to 4 decimal places.
Example 6. Find to four decimal places, the smallest root of the equation
e–x = sin x.
Sol. The given equation is
f(x) ≡ e–x – sin x = 0
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 171
so that, xn + 1 = xn +
e x
e x
x
n
x
n
n
n
−
−
−
+
sin
cos
Take x0 = .6 then,
x1 = .58848, x2 = .588559
Hence, the desired value of the root is 0.5885.
Example 7. (i) Find a positive value of (17)1/3, correct to four decimal places,
by the Newton-Raphson method.
(ii) Find the cube root of 10.
Sol. (i) The iterative formula is
xn + 1 =
1
3
2 2
x
a
x
n
n
+
F
HG
I
KJ (36)
Here a = 17
Take x0 = 2.5 ∵ 8 2 27 3
3 3
= =
and
Putting n = 0 in (36), we get
x1 =
1
3
2
17
0
0
2
x
x
+
F
HG
I
KJ =
1
3
5
17
6 25
+
F
HG I
KJ
.
= 2.5733
Putting n = 1 in (36), we get
x2 =
1
3
2
17
1
1
2
x
x
+
F
HG
I
KJ =
1
3
5 1466
17
6 6220
.
.
+
F
HG I
KJ = 2.5713
Again putting n = 2 in (36), we get
x3 =
1
3
2
17 1
3
5 1426
17
6 61158
2
2
2
x
x
+
F
HG
I
KJ = +
F
HG I
KJ
.
.
= 2.57128
Putting n = 3 in (36), we get
x4 =
1
3
2
17 1
3
5 14256
17
6 61148
3
3
2
x
x
+
F
HG
I
KJ = +
F
HG I
KJ
.
.
= 2.57128
Since x3 and x4 agree to four decimal places, the required root is 2.5713,
correct to four decimal places.
(ii) xn + 1 =
2
3
3
2
x a
x
n
n
+
=
1
3
2 2
x
a
x
n
n
+
F
HG
I
KJ
172 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Take x0 = 2.5 (∵ 8
3
= 2 and 27
3
= 3)
∴ x1 = 2.2 (n = 0)
x2 = 2.155 (n = 1)
x3 = 2.15466 (n = 2)
∴ 10
3
≈ 2.15466.
Example 8. Show that the following two sequences both have convergence of
the second order with the same limit a.
xn + 1 =
1
2
xn
1
a
xn
2
+
F
HG
I
KJ and, xn + 1 =
1
2
xn
3
x
a
n
2
−
F
HG
I
KJ.
Sol. Since, xn + 1 =
1
2
xn
1 2
+
F
HG
I
KJ
a
xn
, we have
xn + 1 – a =
1
2
xn
1 2
+
F
HG
I
KJ
a
xn
– a =
1
2
x
a
x
a
n
n
+ −
F
HG
I
KJ
2
=
1
2
x
a
x
n
n
−
F
HG
I
KJ
2
=
1
2xn
(xn – a)2
Thus, en + 1 =
1
2xn
en
2
(37)
which shows the quadratic convergence. Similarly for the second,
xn + 1 – a =
1
2
xn 3
2
−
F
HG
I
KJ
x
a
n
– a
=
1
2
xn 1
2
−
F
HG
I
KJ
x
a
n + (xn – a)
=
x
a
n
2
(a – xn
2) + (xn – a) = (xn – a ) 1 − +
L
NM O
QP
x
a
x a
n
n
2
e j
en + 1 =
x a
a
n −
2
[2a – xn
2 – xn a]
=
x a
a
n −
2
[(a – xn
2) + (a – xn
a)]
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 173
= –
x a
a
n −
F
HG
I
KJ
2
(xn – a ) (xn + 2 a )
en + 1 = –
( )
x a
a
n − 2
2
(xn + 2 a ) = –
( )
x a
a
n + 2
2
. en
2 (38)
which shows the quadratic convergence.
Example 9. If xn is a suitably close approximation to a, show that the error
in the formula
xn + 1 =
1
2
xn
1
a
xn
2
+
F
HG
I
KJ is about
1
3
rd that in the formula,
xn + 1 =
1
2
xn
3
x
a
n
2
−
F
HG
I
KJ, and deduce that the formula
xn + 1 =
x
8
n 6
3a
x
x
a
n
2
n
2
+ −
F
HG
I
KJ gives a sequence with third order convergence.
Sol. Since xn is very close to a
en + 1 ~
− –
x x
x
n n
n
2
+
F
HG
I
KJ
2
2
en
2 | From (38)
= 3 .
1
2xn
en
2 (39)
A simple observation shows that from (37) (see Ex. 8) and (39), the error
in the first formula for en + 1 is about
1
3
rd of that in the second formula.
To find the rate of convergence of the given formula, we have
xn + 1 – a =
xn
8
6
3
2
2
+ −
F
HG
I
KJ
a
x
x
a
n
n
– a =
x x a a x
ax
n n n
n
( )
6 3
8
2 2 4
2
+ −
– a
=
6 3 8
8
2 2 4
x a a x x a a
x a
n n n
n
+ − −
=
− + −
( ) ( )
x a x a
x a
n n
n
3
8
3
∴ en + 1 = –
x a
x a
n
n
+
F
HG
I
KJ
3
8
en
3
It shows that above formula has a convergence of third order.
174 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Exmaple 10. Apply Newton’s formula to find the values of (30)1/5.
Sol. To find the pth root of a, we have
xn + 1 =
( )
p x a
p x
n
p
n
p
− +
−
1
1
Here, a = 30, p = 5, the first approximation is
x1 =
4 30
5
0
5
0
4
x
x
+
Take x0 = 1.9, we get x1 = 1.98
Again, x2 = 1.973
∴ Value = 1.973 (correct to 3 decimal places).
Example 11. Using the starting value 2(1 + i), solve x4 – 5x3 + 20x2 – 40x + 60
= 0 by Newton-Raphson method, given that all the roots of the given equation
are complex.
Sol. Let f(x) = x4 – 5x3 + 20x2 – 40x + 60
so that, f ′(x) = 4x3 – 15x2 + 40x – 40
∴ Newton-Raphson method gives,
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
= xn –
x x x x
x x x
n n n n
n n n
4 3 2
3 2
5 20 40 60
4 15 40 40
− + − +
− + −
=
3 10 20 60
4 15 40 40
4 3 2
3 2
x x x
x x x
n n n
n n n
− + −
− + −
Put n = 0, take x0 = 2(1 + i) by trial, we get
x1 = 1.92 (1 + i)
Again, x2 = 1.915 + 1.908 i
Since imaginary roots occur in conjugate pairs roots are 1.915 ± 1.908 i up
to 3 decimal places. Assuming the other pairs of roots to be α ± iβ, then
Sum =
α β α β
+ + −
+ +
+ −
F
H
GG
I
K
JJ
i i
i
i
1915 1908
1915 1908
. .
. .
= 2α + 3.83 = 5
⇒ α = 0.585
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 175
Also, the product of the roots = (α2 + β2) [(1.915)2 + (1.908)2] = 60
⇒ β = 2.805
Hence, the other two roots are 0.585 ± 2.805 i.
Example 12. Obtain Newton-Raphson’s extended formula
x1 = x0 –
f(x )
f (x )
0
0
′
–
1
2
.
{f(x )} . f (x )
{f (x )}
0
2
0
0
3
″
′
for the root of the equation f(x) = 0, also known as Chebyshev formula of third
order.
Sol. Expanding f(x) by Taylor’s series in the neighborhood of x0, we get
f(x) = 0 ⇒ f(x0) + (x – x0) f ′(x0) = 0
⇒ x = x0 –
f x
f x
( )
( )
0
0
′
This is I approximation to the root.
∴ x1 = x0 –
f x
f x
( )
( )
0
0
′
Again By Taylor’s series, we have
f(x) = f(x0) + (x – x0) f ′(x0) +
( )
x x
− 0
2
2
f ″(x0)
∴ f(x1) = f(x0) + (x1 – x0) f ′(x0) +
( )
x x
1 0
2
2
−
f ″(x0)
But f(x1) = 0 as x1 is an approximation to the root.
∴ f(x0) + (x1– x0) f ′(x0) +
1
2
(x1 – x0)2 f ″(x0) = 0
or f(x0) + (x1 – x0) f ′(x0) +
1
2
{ ( )} ( )
( )
f x f x
f x
0
2
0
0
″
′ 2
= 0
⇒ x1 = x0 –
f x
f x
( )
( )
0
0
′
–
1
2
{ ( )} ( )
{ ( )}
f x f x
f x
0
2
0
0
3
″
′
This formula can be used iteratively.
Example 13. The graph of y = 2 sin x and y = log x + c touch each other in the
neighborhood of point x = 8. Find c and the coordinates of point of contact.
Sol. The graphs will touch each other if the values of dy/dx at their point of
contact is same.
176 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
For y = 2 sin x,
dy
dx
= 2 cos x
For y = log x + c
dy
dx
=
1
x
∴ 2 cos x =
1
x
⇒ x cos x – .5 = 0
Let f(x) = x cos x – .5
∴ f ′(x) = cos x – x sin x
∴ Newton’s iterative formula is
xn + 1 = xn –
x x
x x x
n n
n n n
cos .
cos sin
−
−
0 5
For n = 0, x0 = 8, first app. x1 = 7.793
Second approximation, x2 = 7.789 ≈ 7.79
Now, y = 2 sin 7.79 = 1.9960
∴ Point of contact → (7.79, 1.996)
Now, y = log x + c
⇒ 1.996 = log 7.79 + c ⇒ c = – 0.054.
Example 14. Using the starting value x0 = i, find a zero of
x4 + x3 + 5x2 + 4x + 4 = 0.
Sol. By Newton’s method
x1 = i –
f i
f i
( )
( )
′
= i –
3
1 6
i
i
+
= .486 + .919 i
Now, x2 = .486 + .919 i –
f i
f i
(. . )
(. . )
486 919
486 919
+
′ +
= .486 + .919 i –
− +
+
F
HG I
KJ
. .
. .
292 174
178 6 005
i
i
= – .499 + 0.866i
The actual root is x =
− +
1 3
2
i
.
Example 15. Show that the square root of N = AB is given by
N ~
−
S
4
N
S
+ , where S = A + B.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 177
Sol. Let x = N
⇒ x2 – N = 0
Let f(x) = x2 – N
∴ f ′(x) = 2x
By Newton-Raphson formula,
xn + 1 = xn –
f x
f x
n
n
( )
( )
′
= x
x
x
x
x
n
n
n
n
n
−
−
= +
2
2
N
2
N
2
Let xn =
A + B
2
then, xn + 1 =
A + B
4
N
A B
+
+
~
− +
S
4
N
S
| Since S = A + B
Example 16. Determine the value of p and q so that the rate of convergence of
the iterative method
xn + 1 = pxn + q
N
xn
2
for computing N1/3 becomes as high as possible.
Sol. We have x3 = N
∴ f(x) = x3 – N
Letting α be the exact root, we have
α3 = N
Substituting xn = α + en, xn + 1 = α + en + 1, N = α3 in xn + 1 = pxn + q
N
xn
2
, we get
α + en + 1 = p(α + en) + q
α
α
3
2
( )
+ en
= p e q
e
n
n
( )
α
α
α
α
+ +
+
F
HG I
KJ
3
2
2
1
= p(α + en) + qα 1
2
+
F
HG I
KJ
−
en
α
= p e q
e e
n
n n
( ) .........
α α
α α
+ + − +
F
HG I
KJ −
R
S
|
T
|
U
V
|
W
|
1 2 3
2
178 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= p e q qe q
e
n n
n
( )
α α
α
+ + − +
2 3
2
– ........
⇒ en + 1 = (p + q – 1)α + (p – 2q)en + 0(en
2) + .......
Now for the method to become of the highest order as possible, i.e., of order
2, we must have
p + q = 1 and p – 2q = 0
so that, p =
2
3
and q =
1
3
.
Example 17. How should the constant α be chosen to ensure the fastest possible
convergence with the iteration formula?
xn+1 =
α
α
x x 1
1
n n
2
+ +
+
−
.
Sol. Since lim lim
n
n
n
n
x x
→ ∞ → ∞
+
= 1 = ξ, we have
ξ =
αξ
ξ
α
+ +
+
F
H
GG
I
K
JJ
1
1
1
2
⇒ (α + 1)ξ3 = αξ3 + ξ2 + 1
⇒ ξ3 – ξ2 – 1 = 0
ξ can be obtained by finding a root of the equation x3 – x2 – 1 = 0.
We have f(x) = x3 – x2 – 1
f ′(x) = 3x2 – 2x
Since f(1.45) = (–)ve and f(1.47) = (+)ve
∴ Root lies between 1.45 and 1.47.
Let x0 = 1.46
By Newton-Raphson method,
First approximation is
x1 = x0 –
f x
f x
( )
( )
0
0
′
= x0 –
x x
x x
0
3
0
2
0
2
0
1
3 2
− −
−
F
HG
I
KJ = 1.465601.
Second approximation is
x2 = x1 –
f x
f x
( )
( )
1
1
′
= x1 –
x x
x x
1
3
1
2
1
2
1
1
3 2
− −
−
F
HG
I
KJ = 1.46557
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 179
Hence ξ = 1.465 correct to three decimal places.
Now, we have
xn+1 =
α
α
x x
n n
+ +
+
−2
1
1
(40)
Putting xn = ξ + en and xn+1 = ξ + en+1 in (40), we get
(α + 1)(ξ + en + 1) = α(ξ + en) +
1
2
( )
ξ + en
+ 1
= α(ξ + en) +
1
1
2
2
ξ ξ
+
F
HG I
KJ
−
en
+ 1
which gives,
(1 + α)en+1 = α
ξ
−
F
HG
I
KJ
2
3 en + O(en
2)
For fastest convergence, we must have α =
2
3
ξ
∴ α =
2
(1.465)3
= 0.636.
Example 18. Newton-Raphson’s method for solving the equation f(x) = c, where
c is a real valued constant, is applied to the function
f(x) =
cos x, when|x| 1
cos x (x 1) , when|x| 1
2 2
≤
+ − ≥
R
S
T
U
V
W
For which c is xn = (– 1)n, when x0 = 1 and the calculations are carried out
with no errors? Even in high precision arithmetic, the convergence is troublesome.
Explain.
Sol. f(x) – c = 0 (41)
Applying the Newton-Raphson method to eqn. (41), we get
xn+1 = xn –
f x c
f x
n
n
( )
( )
−
′
L
NM O
QP
For n = 0, we have
x1 = x0 –
f x c
f x
( )
( )
0
0
−
′
L
NM O
QP
180 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 1 –
cos
sin
1
1
−
−
L
NM O
QP
c
| ∵ x0 = 1
– 1 = 1 +
cos
sin
1
1
−
L
NM O
QP
c
| ∵ x1 = (– 1)1 = – 1
Hence – 2 sin 1 = cos 1 – c
⇒ c = cos 1 + 2 sin 1
with this value of c, we get
x2 = 1, x3 = – 1, ..., xn = (– 1)n
Since f ′(x) = 0 between x0 and the roots and also at x = 0, the convergence
is troublesome inspite of high precision arithmetic.
ASSIGNMENT 3.9
1. By using Newton-Raphson’s method, find the root of x4 – x – 10 = 0 which is near to x = 2,
correct to three decimal places.
2. Compute one positive root of 2x – log10 x = 7 by the Newton-Raphson method correct to
four decimal places.
3. (i) Use the Newton-Raphson method to find a root of the equation x3 – 2x – 5 = 0.
(ii) Use Newton-Raphson method to find a root of the equation x3 – 3x – 5 = 0.
4. Find the real root of the equations
(i) log x = cos x (ii) x2 + 4 sin x = 0
by Newton-Raphson method, correct to three decimal places.
5. Use Newton-Raphson method to obtain a root correct to three decimal places of the
following equations:
(i) sin x = 1 – x (ii) x3 – 5x + 3 = 0 (iii) x4 + x2 – 80 = 0
(iv) x3 + 3x2 – 3 = 0 (v) 4(x – sin x) = 1 (vi) x – cos x = 0
(vii) sin x =
x
2
(viii) x + log x = 2 (ix) tan x = x.
6. Explain the method of Newton-Raphson for computing roots. Apply it for finding x from
x2 – 25 = 0. Write a program using ‘C’.
7. Write a computer program in ‘C’ for finding out a real root of eqn. f(x) = 0 by the Newton-
Raphson method.
8. Using the Newton-Raphson method, obtain the formula for N and find 20 correct to
2 decimal places.
9. Obtain the cube root of 120 using the Newton-Raphson method, starting with x0 = 4.5.
10. Develop an algorithm using the Newton-Raphson method to find the fourth root of a
positive number N, and find 32
4 .
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 181
11. Find the cube root of 3 correct to three decimal places by Newton’s iterative method.
12. Prove the recurrence formula
xi + 1 =
1
3
2 2
x
x
i
i
+
F
HG
I
KJ
N
for finding the cube root of N. Find the cube root of 63.
13. Use Newton’s formula to prove that the square root of N can be obtained by the recursion
formula,
xi + 1 = xi 1
2
−
F
HG
I
KJ
xi – N
2N
Find the square root of
(a) 26 (b) 29 (c) 35.
14. Show that the iterative formula for finding the reciprocal of n is xi + 1 = xi (2 – nxi), and
find the value of
1
31
.
15. Determine p, q, and r so that the order of the iterative method
xn + 1 = px
qa
x
ra
x
n
n n
+ +
2
2
5
for a1/3 becomes as high as possible.
[Hint: p + q + r = 1, p – 2q – 5r = 0, 3q + 15r = 0.]
16. Derive the expression for the Newton-Raphson method to find a root of an equation.
Find the order of the convergence of this method.
17. Find all positive roots of the equation
10
0
2
x
x
e dt
z −
– 1 = 0 with six correct decimals.
18. The equation
2e–x =
1
2
1
1
x x
+
+
+
has two roots greater than – 1.
Calculate these roots correct to five decimal places.
19. The equation x = 0.2 + 0.4 sin
x
b
F
HG I
KJ where b is a parameter, has one solution near x = 0.3.
The parameter is known only with some uncertainty: b = 1.2 ± 0.05.
Calculate the root with an accuracy reasonable with respect to the uncertainty of b.
20. Find the positive root of the equation
ex = 1 + x +
x x
2 3
2 6
+ e0.3x
correct to 6 decimal places.
182 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
21. Show that the equation
f(x) = cos
π( )
x +
R
S
T
U
V
W
1
8
+ 0.148x – 0.9062 = 0
has one root in the interval (– 1, 0) and one in (0, 1). Calculate the negative root
correct to 4 decimals.
3.38 DEFINITIONS
1. A number α is a solution of f(x) = 0 if f(α) = 0. Such a solution α is a root or
a zero of f(x) = 0. Geometrically, a root of the eqn. f(x) = 0 is the value of x at
which the graph of y = f(x) intersects x-axis.
2. If we can write f(x) = 0 as
f(x) = (x – α)m g(x) = 0
where g(x) is bounded and g(α) ≠ 0 then α is called a multiple root of
multiplicity m. In this case,
f(α) = f ′(α) = .......... = f(m – 1) (α) = 0, f(m) (α) ≠ 0
For m = 1, the number α is said to be a simple root.
3.39 METHODS FOR MULTIPLE ROOTS
If α is a multiple root of multiplicity m of the eqn. f(x) = 0, then we have
f(α) = f ′(α) = ........ = f(m – 1)(α) = 0 and f(m)(α) ≠ 0
It can easily be verified that all the iteration methods discussed so far have
only a linear rate of convergence when m  1.
For example, in the Newton-Raphson method, we have
f(xk) = f(α + ek) =
e
m
f
e
m
f
k
m
m k
m
m
!
( )
( ) !
( )
( ) ( )
α α
+
+
+
+
1
1
1
+
+
+
+
+
e
m
f
k
m
m
2
2
2
( ) !
( ) .......
( )
α
f ′(xk) = f e
e
m
f
e
m
f
k
k
m
m k
m
m
′ + =
−
+ +
−
+
( )
( ) !
( )
!
( ) .......
( ) ( )
α α α
1
1
1
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 183
The error equation for the Newton-Raphson method becomes,
ek + 1 = 1
1 1
1
2
1
2 3
−
F
HG I
KJ +
+
+
+
m
e
m m
f
f
e e
k
m
m k k
( )
( )
( )
( )
( )
( )
α
α
O
If m ≠ 1, we obtain,
ek + 1 = 1
1 2
−
F
HG I
KJ +
m
e e
k k
O ( ) (42)
which shows that the method has only linear rate of convergence.
However, if the multiplicity of the root is known in advance, we can modify
the methods by introducing parameters dependent on the multiplicity of the
root to increase their order of convergence.
For example, consider the Newton-Raphson method in the form
xk + 1 = x
f
f
k
k
k
−
′
β (43)
where β is an arbitrary parameter to be determined.
If α is a multiple root of multiplicity m, we obtain from (43), the error
equation
ek + 1 = 1
1
0
2
1
2 3
−
F
HG I
KJ +
+
+
+
β β α
α
m
e
m m
f
f
e e
k
m
m k k
( )
( )
( )
( )
( )
( )
If the method (43) is to have the quadratic rate of convergence, then the
coefficient of ek must vanish, which gives
1−
β
m
= 0 or β = m
Thus the method
xk + 1 = x m
f
f
k
k
k
− ′
has a quadratic rate of convergence for determining a multiple root of
multiplicity m.
If the multiplicity of the root is not known in advance, then we use the
following procedure.
It is known that if f(x) = 0 has a root α of multiplicity m, then f ′(x) = 0 has
the same root α of multiplicity m – 1.
184 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence, g(x) =
f x
f x
( )
( )
′
has a simple root α and we can now use the Newton-
Raphson method
xk + 1 = x
g x
g x
k
k
k
−
′
( )
( )
to find the approximate value of the multiple root α.
Simplifying, we have
xk + 1 = xk –
f f
f f f
k k
k k k
′
−
′ ″
2
which has a quadratic rate of convergence for multiple roots.
If initial approximation x0 is sufficiently close to the root, then the expressions
x m
f x
f x
x m
f x
f x
x m
f x
f x
0
0
0
0
0
0
0
0
0
1 2
−
′
− −
′
″
− −
″
″′
( )
( )
, ( )
( )
( )
, ( )
( )
( )
will have same value.
EXAMPLES
Example 1. Show that the modified Newton-Raphson’s method
xn + 1 = xn –
2f(x )
f (x )
n
n
′
gives a quadratic convergence when f(x) = 0 has a pair of double roots in the
neighborhood of x = xn.
Sol. en + 1 = en –
2f a e
f a e
n
n
( )
( )
+
′ +
, where a, en, and en + 1 have their usual meanings.
Expanding in powers of en and using f(a) = 0, f ′(a) = 0 since x = a is a double
root near x = xn, we get
e n + 1 = en –
2
2
2
2
2
e
f a
e f a
e
f a
n
n
n
!
( ) .......
( )
!
( ) .......
″ +
L
NMM
O
QPP
″ + ″′ +
L
NMM
O
QPP
= en –
2
1
2
1
3
2
2
e f a f a
e f a
e
f a
n
n
n
!
( )
!
( ) .......
( )
!
( ) ......
″ + ″′ +
L
NM O
QP
″ + ″′ +
L
NM O
QP
NOTE
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 185
~
− en –
2
1
2
1
3
2
e f a f a
f a
e
f a
n
n
!
( )
!
( )
( )
!
( )
″ + ″′
L
NM O
QP
″ + ″′
en + 1 ~
−
1
6
en
2.
f a
f a
e
f a
n
″ ′
″ + ″ ′
L
NM O
QP
( )
( )
!
( )
2
∴ en + 1 ≈
1
6
en
2 f a
f a
″ ′
″
( )
( )
⇒ en + 1 ∝ en
2
and hence the convergence is quadratic.
Example 2. Find the double root of the equation
x3 – x2 – x + 1 = 0.
Sol. Let f(x) = x3 – x2 – x + 1
so that f ′(x) = 3x2 – 2x – 1
f ″(x) = 6x – 2
Starting with x0 = 0.9, we have
x0 – 2
f x
f x
( )
( )
0
0
′
= .9 –
2 019
37
×
−
.
( . )
= 1.003
and x0 – (2 – 1)
f x
f x
′
″
( )
( )
0
0
= .9 –
( . )
.
− 37
3 4
= 1.009
The closeness of these values implies that there is a double root near x = 1.
Choosing x1 = 1.01 for the next approximation, we get
x1 – 2
f x
f x
( )
( )
1
1
′
= 1.01 – 2 ×
0 0002
0 0403
.
.
= 1.0001
and x1 – (2 – 1)
f x
f x
′
″
( )
( )
1
1
= 1.01 –
.
.
0403
4 06
= 1.0001
This shows that there is a double root at x = 1.0001 which is quite near the
actual root x = 1.
186 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 3. The equation
f(x) = x3 – 7x2 + 16x – 12 = 0
has a double root at x = 2. Starting with the initial approximation x0 = 1, find
the root correct to 3 decimal places using the modified Newton-Raphson method
with m = 2.
Sol. The modified Newton-Raphson method with m = 2 becomes,
xn + 1 = xn – 2
x x x
x x
n n n
n n
3 2
2
7 16 12
3 14 16
− + −
− +
L
NMM
O
QPP, n = 0, 1, .......
Starting with x0 = 1, we get
x1 = 1.8
x2 = 1.984615385
x3 = 1.999884332
x4 = 2.000000161
x5 = 2.000000161
∴ The root correct to 3 decimal places is 2.000.
Example 4. Show that the equation
f(x) = 1 – xe1 – x = 0
has a double root at x = 1. The root is obtained by using the modified Newton-
Raphson method with m = 2 starting with x0 = 0.
Sol. Since f(1) = f ′(1) = 0 and f ″(1) ≠ 0, the root x = 1 is a double root.
xn + 1 = xn – 2
1
1
1
1
−
−
L
N
MM
O
Q
PP
−
−
x e
x e
n
x
n
x
n
n
( )
; n = 0, 1, .......
Starting with x0 = 0, we get
x1 = .735758882
x2 = .978185253
x3 = .999842233
x4 = 1.000000061
x5 = 1.000000061
Hence the root correct to six decimal places is 1.000000.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 187
3.40 NEARLY EQUAL ROOTS
So far, Newton’s method is applicable when f ′(x) ≠ 0 in the neighborhood of
actual root x = a, i.e., in the interval (a – h, a + h).
If the quantity h is very very small, it will not satisfy the above restriction.
The application of Newton’s method will not be practical in that case. This
condition occurs when the roots are very close to one another.
We know that in case of the double root x = a, f(x) and f ′(x) both vanish at
x = a. Thus, while applying Newton’s method, if xi is simultaneously near
zeros of f(x) and f ′(x), i.e., f(xi) and f ′(xi) are both very small, then it is usually
practical to depart from the standard sequence and proceed to obtain two new
starting values for the two nearly equal roots.
To obtain these values, we first apply Newton’s method to the equation
f ′(x) = 0, i.e., we use the iteration formula
xi + 1 = xi –
f x
f x
i
i
′
″
( )
( )
(44)
with the last available iterate as the initial value x0 for (44).
Suppose x = c is the solution obtained by (44).
Now, by Taylor’s series, we have
f(x) = f(c) + (x – c) f ′(c) +
1
2
(x – c)2 f ″(c) + .......
But f ′(c) = 0
f(x) = f(c) +
1
2
(x – c)2 f ″(c) + R
Assuming R to be small, we conclude that the zero’s of f(x) near x = c are
approximately given by
f(c) +
1
2
(x – c)2 f ″(c) = 0
⇒ x = c ±
−
″
2f c
f c
( )
( )
(45)
Using these values as starting values, we can use the original iteration
formula to get two close roots of f(x) = 0.
188 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
EXAMPLE
Example. Use synthetic division to solve f(x) ≡ x3 – x2 – 1.0001 x + 0.9999 = 0 in
the neighborhood of x = 1.
Sol. To find f(1) and f ′(1),
1 –1 –1.0001 0.9999 1
1 0 – 1.0001
1 0 – 1.0001 – 0.0002 = f (1)
1 1
1 1 – .0001 = f ′(1)
1
1 2 =
1
2
f ″(1)
From the above synthetic division, we observe that f(1) and f ′(1) are
small. Hence there exists two nearly equal roots. Taking x0 = 1, we will use
xi + 1 = xi –
f x
f x
i
i
′
″
( )
( )
to modify the root. For this, we require f ″(1).
From the above synthetic division, we have
1
2
f ″ (1) = 2 ⇒ f ″ (1) = 4
∴ First approximation x1 = 1 –
f
f
′
″
( )
( )
1
1
= 1 –
( . )
− 0001
4
= 1.000025
Now we again calculate f(x1) and f ″(x1) by synthetic division.
1 –1 – 1.000100 0.999900 1.000025
1.000025 0.000025 – 1.000095
1 . 000025 – 1.00075 – 0.000 195 = f (x1)
1.000025 1.000075
1 1.000050 0 = f ′(x1)
1.000025
1 2.000075 =
1
2
f ″(x1)
∴ f(1.000025) = – 0.000195 and f ″(1.000025) = 4.000150
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 189
Now, For nearly equal roots,
x = c ±
−
″
2 f c
f c
( )
( )
, where c = 1.000025
= 1.000025 ±
− −
2 000195
4 000150
( . )
.
= 1.009899, 0.990151.
3.41 COMPARISON OF NEWTON’S METHOD WITH REGULA-FALSI
METHOD
Regula-Falsi is surely convergent while Newton’s method is conditionally
convergent. But once Newton’s method converges, it converges faster.
In the Falsi method, we calculate only one more value of the function at
each step i.e., f(x(n)) while in Newton’s method, we require two calculations
f(xn) and f ′(xn) at each step.
∴ Newton’s method generally requires fewer iterations but also requires
more time for computation at each iteration.
When f ′(x) is large near the root the correction to be applied is smaller in
the case of Newton’s method which is then preferred. If f ′(x) is small near the
root, the correction to be applied is large and the curve becomes parallel to the
x-axis.
In this case the Regula-Falsi method should be applied.
3.42 COMPARISON OF ITERATIVE METHODS
1. Convergence in the case of the Bisection method is slow but steady. It
is the simplest method and never fails.
2. The method of false position is slow and it is I order convergent.
Convergence is guaranteed.
3. Newton’s method has the fastest rate of convergence. This method is
quite sensitive to starting value. It may diverge if f ′(x) ≈ 0 during
iterative cycle.
4. For locating complex roots, the bisection method cannot be applied.
Newton’s and Muller’s methods are effective.
5. If all the roots of a given equation are required, Lin-Bairstow’s method
is recommended. After a quadratic factor has been found, this method
must be applied on the reduced polynomial.
190 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
If the location of some roots is known, first find these roots to a desired
accuracy and then apply this method on the reduced polynomial.
ASSIGNMENT 3.10
1. The equation f(x) = (x – 1)2 (x – 3)2 has roots at x = 1 and x = 3. Which of the following
methods can be applied to find all the roots?
(i) Bisection method
(ii) False-position method
(iii) Newton-Raphson method
Justify your answer.
2. A sphere of wood, 2 m in diameter, floating in water sinks to a depth d given by
d3 – 3d2 + 2.5 = 0
find d correct to 2 decimal places.
3. Discuss the working of modified Newton-Raphson method.
4. Find the root of the equation
f(x) ≡ sin x –
x
x
+
−
1
1
= 0 near x = – .4
5. Give a comparative study of iterative methods.
6. Under what conditions does the Newton-Raphson method become linearly convergent?
Explain.
3.43 GRAEFFE’S ROOT-SQUARING METHOD
This method has a great advantage over the other methods in that it does not
require prior information about the approximate values, etc., of the roots. It is
applicable to polynomial equations only and is capable of giving all the roots.
Here below we discuss the case of the polynomial equation having real and
distinct roots.
Consider the polynomial equation
f(x) = xn + a1xn–1 + a2xn–2 + ...... + an–1x + an = 0 (46)
Separating the even and odd powers of x and squaring, we get
(xn + a2xn–2 + a4xn–4 + ......)2 = (a1xn–1 + a3xn–3 + a5xn–5 + ......)2
Putting x2 = y and simplifying, the new equation becomes
yn + b1yn–1 + b2yn–2 + ...... + bn–1y + bn = 0 (47)
where b1 = a1
2 + 2a2; b2 = a2
2 – 2a1a3 + 2a4 ...... bn = (– 1)n an2 (48)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 191
If p1, p2, ......... , pn are the roots of (46), then the roots of (47) are
p1
2, p2
2, ......... , pn
2.
Let us suppose that after m squarings, the new transformed equation is
zn + λ1zn–1 + ...... + λn–1z + λn = 0 (49)
whose roots are q1, q2, ......., qn such that qi = pi
2m , i = 1, 2, ......, n.
Assuming the order of magnitude of the roots as
| p1 |  | p2 |  ......  | pn |, we have
| q1 |  | q2 |  ......  | qn | where  stands for ‘much greater than’.
Thus
| |
| |
, ......,
| |
| |
q
q
q
q
q
q
q
q
n
n
n
n
2
1
2
1 1 1
= =
− −
(50)
Also qi being an even power of pi, is always positive.
Now, from (49), we have
Σq1 = – λ1 ⇒ λ1 = – q1
1 2
1
3
1
+ + +
F
HG I
KJ
q
q
q
q
......
Σq1q2 = λ2 ⇒ λ2 = q1q2
1 3
1
+ +
F
HG I
KJ
q
q
......
Σq1q2q3 = – λ3 ⇒ λ3 = q1q2q3
1 4
1
+ +
F
HG I
KJ
q
q
......
............................................................................
q1q2q3 ...... qn = (– 1)n λn ⇒ λn = (– 1)n q1q2q3 ...... qn.
Hence by (50), we find q1 ≈ – λ1; q2 ≈ –
λ
λ
λ
λ
λ
λ
2
1
3
3
2 1
, , ......,
q qn
n
n
≈ − ≈ −
−
But qi = pi
2m
∴ pi = (qi)1/2m = −
F
HG
I
KJ
−
λ
λ
i
i
m
1
1/2
(51)
We can thus determine p1, p2, ......, pn the roots of the equation (46).
Case 1. Double root. If the magnitude of λi is half the square of the
magnitude of the corresponding coefficient in the previous equation after a few
squarings, then it implies that pi is a double root of (46). We determine it as
follows:
qi = –
λ
λ
i
i−1
and qi+1 = –
λ
λ
i
i
+1
192 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ qiqi+1 ≈ qi
2 ≈
λ
λ
i
i
+
−
1
1
i.e., pi
2m = qi
2 =
λ
λ
i
i
+
−
1
1
(52)
which gives the magnitude of the double root and substituting in (46), we can
find the sign.
Case 2. Complex roots. If pr and pr+1 form the complex pair Pr
i
e r
± φ
, then
the co-efficient of xn–r in successive squarings would vary both in magnitude and
sign by an amount 2Pr
m cos mφr. For sufficiently large Pr and φr can be determined
by
Pr
r
r
m
2 2 1
1
( )
≈ +
−
λ
λ
; 2 2
2
1
Pr
m
r
r
r
m
cos φ
λ
λ
= −
−
(53)
If there is only one pair of complex roots, say
Pr
i
r r
e i
r
±
= +
φ
ξ η then ξr is given by
p1 + p2 + ...... + pr–1 + 2ξr + pr+2 + ...... + pn = – a1 (54)
and ηr = Pr r
2 2
– ξ (55)
If there are two pairs of complex roots, say
Pr
i
r r
e i
r
±
= ±
φ
ξ η and Ps
i
s s
e i
s
±
= ±
φ
ξ η
where p1 + p2 + ...... + pr–1 + 2ξr + Pr+2 + ...... + ps–1 + 2ξs + ps+2 + ...... + pn = – a1
(56)
2
1 1
2 2
1
1
ξ ξ
r
r
s
s
n
n
a
n a a
P P
+
F
HG
I
KJ = − + + +
L
NM O
QP
−
...... (57)
and ηr = P P
r r s s s
2 2 2 2
− = −
ξ η ξ
; (58)
EXAMPLES
Example 1. Apply Graeffe’s root squaring method to solve the equation
x3 – 8x2 + 17x – 10 = 0.
Sol. Here f(x) = x3 – 8x2 + 17x – 10 = 0 (59)
Clearly f(x) has three changes i.e., from + to –, – to + and + to –. Hence from
Descartes rule of signs f(x) may have three positive roots.
Rewriting (59) as x(x2 + 17) = (8x2 + 10) (60)
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 193
Squaring on both sides and putting x2 = y, we get
y(y + 17)2 = (8y + 10)2
or y3 + 34y2 + 289y = 64y2 + 160y + 100
or y(y2 + 129) = (30y2 + 100) (61)
Squaring again and putting y2 = z, we get
z(z + 129)2 = (30z + 100)2
or z3 + 258z2 + 16641z = 900z2 + 6000z + 10000
or z(z2 + 10641) = (642z2 + 10000) (62)
Squaring again and putting z2 = u, we get
u(u + 10641)2 = (642u + 10000)2
or u3 + 21282u2 + 113230881u = 412164u2 + 12840000u + 108
or u3 – 390882u2 + 100390881u – 108 = 0 (63)
If the roots of (59) are p1, p2, p3 and those of (63) are q1, q2, q3, then
p1 = (q1)1/8 = ( – λ1)1/8 = (390882)1/8 = 5.000411082 ≅ 5
p2 = (q2)1/8 = (– λ2/λ1)1/8 =
100390881
378882
1/8
L
NM O
QP = 2.000811036 ≅ 2
p3 = (q3)1/8 = (– λ3/λ2)1/8 =
10
100390881
8
L
NM O
QP = 0.99951247 ≅ 1
Now f(5) = f(1) = f(2) = 0.
Hence the roots are 5, 2, and 1.
Example 2. Find all the roots of the equation x4 – 3x + 1 = 0 by Graeffe’s method.
Sol. Here f(x) = x4 – 3x + 1 = 0 (64)
Now f(x) has two changes in sign i.e., + to – and – to +. Therefore it may
have two positive real roots.
Again f(– x) = x4 + 3x + 1. Since no change in sign of f(– x) there is no
negative root. But f(x), being of degree four, will have four roots of which two
are real positive and the remaining two are complex.
Rewriting (64) as x4 + 1 = 3x.
Squaring and putting x2 = y, we have
(y2 + 1)2 = 9y
Squaring again and putting, y2 = z
(z + 1)4 = 81z
194 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
i.e., z4 + 4z3 + 6z2 – 77z + 1 = 0 (65)
or z4 + 6z2 + 1 = – z(4z2 – 77)
Squaring once again and putting z2 = u, we get
(u2 + 6u + 1)2 = u(4u – 77)2
or u4 – 4u3 + 654u2 – 5917u + 1 = 0 (66)
If p1, p2, p3, p4 are the roots of (64) and q1, q2, q3, q4 are the roots of (66),
then
p1 = (q1)1/8 = (– λ1)1/8 = (4)1/8 = 1.1892071
p2 = (q2)1/8 = −
L
NM O
QP =
L
NM O
QP
λ
λ
2
1
1/8 1/8
654
4
= 1.8909921
p3 = (q3)1/8 = −
L
NM O
QP =
L
NM O
QP
λ
λ
3
1
1/8 1/8
5917
654
= 1.3169384
p4 = (q4)1/8 = −
L
NM O
QP =
L
NM O
QP
λ
λ
4
3
1/8 1/8
1
5917
= 0.3376659
From (65) and (66), we observe that the magnitudes of the co-efficients λ1
and λ4 have become constant.
⇒ p, p4 are the real roots and p2, p3 are complex roots. Let these complex
roots be
ρ ξ η
φ
2 2 2
2
e i
i
±
= ± . From (66), its magnitude is given by
ρ
λ
λ
2
2 2 3
1
3 5917
4
( )
≈ = ∴ ρ2 = 1.5780749
also from (64) the sum of the roots = 0, i.e., p1 + 2ξ2 + p4 = 0
∴ ξ2 = –
1
2
(p1 + p4) = – 0.7634365
and η2 = ρ ξ
2
2
2
2
9074851
− = 1. = 1.3811173
Hence, the four roots are 1.1892071, 0.3376659, – 0.7634365 ± 1.3811173i.
ASSIGNMENT 3.11
1. Find all the roots of the following equations by Graeffe’s method squaring thrice:
(i) x3 – 4x2 + 5x – 2 = 0 (ii) x3 – 2x2 + 5x + 6 = 0
(iii) x3 – x – 1 = 0.
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 195
3.44 RAMANUJAN’S METHOD
S. Ramanujan (1887 – 1920) proposed an iterative method which can be used
to determine the smallest root of the equation f(x) = 0
where f(x) is of the form
f(x) = 1 – (a1x + a2x2 + a3x3 + ....)
For smaller values of x, we can write,
[1 – (a1x + a2x2 + a3x3 + ....)]–1 = b1 + b2x + b3x2 + ....
⇒ 1 + (a1x + a2x2 + a3x3 + ...) + (a1x + a2x2 + a3x3 + ....)2 + ....
= b1 + b2x + b3x2 + ....
Expanding L.H.S. by
Binomial theorem
Comparing the coefficient of like powers of x on both sides, we get
b1 = 1
b2 = a1 = a1b1
b3 = a1
2 + a2 = a1b2 + a2b1
   
bn = a1bn – 1 + a2bn – 2 + ....... + an – 1b1
n = 2, 3, .....
Ramanujan stated that the successive convergents viz.
b
b
n
n + 1
approach a
root of the equation f(x) = 0.
EXAMPLE
Example. Find the smallest root of the equation
x3 – 6x2 + 11x – 6 = 0 using Ramanujan’s method.
Sol. We have
1
11 6
6
2 3
1
−
− +
F
HG
I
KJ
L
N
MM
O
Q
PP
−
x x x
= b1 + b2x + b3x2 + .....
Here, a1 =
11
6
, a2 = – 1, a3 =
1
6
, a4 = a5 = a6 = ..... = 0
U
V
|
|
|
W
|
|
|
196 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence
b1 = 1
b2 = a1 =
11
6
∴
b
b
1
2
6
11
= = .54545
b3 = a1b2 + a2b1
=
121
36
1
85
36
− = ;
b
b
2
3
66
85
= = .7764705
b4 = a1b3 + a2b2 + a3b1
=
575
216
;
b
b
3
4
102
115
= = .8869565
b5 = a1b4 + a2b3 + a3b2 + a4b1
=
3661
1296
;
b
b
4
5
3450
3661
= = .9423654
b6 = a1b5 + a2b4 + a3b3 + a4b2 + a5b1
=
22631
7776
;
b
b
5
6
3138
3233
= = .9706155
The smallest root of the given equation is 1 and the successive convergents
approach this root.
ASSIGNMENT 3.12
1. Find a root of the equation xex = 1
using Ramanujan’s method.
2. Find a root of the equation sin x = 1 – x
using Ramanujan’s method.
3. Using Ramanujan’s method, obtain the first eight convergents of the equation x + x3 = 1.
P a r t 2
n Interpolation
Finite Differences, Difference Tables, Errors in Polynomial
Interpolation, Newton’s Forward and Backward Formula, Gauss’s
Forward and Backward Formula, Stirling’s, Bessel’s, Everett’s
Formula, Lagrange’s Interpolation, Newton’s Divided Difference
Formula, Hermite’s Interpolation.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
4.1 INTRODUCTION
A
ccording to Theile, ‘Interpolation is the art of reading between the lines
of the table’.
It also means insertion or filling up intermediate terms of the series.
Suppose we are given the following values of y = f(x) for a set of values of x:
x: x0 x1 x2 ...... xn
y: y0 y1 y2 ...... yn
Thus the process of finding the value of y corresponding to any value of
x = xi between x0 and xn is called interpolation.
Hence interpolation is the technique of estimating the value of a function
for any intermediate value of the independent variable, while the process of
computing the value of the function outside the given range is called
extrapolation.
Chapter 4 INTERPOLATION
199
200 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.2 ASSUMPTIONS FOR INTERPOLATION
1. There are no sudden jumps or falls in the values during the period under
consideration.
2. The rise and fall in the values should be uniform.
For example, if we are given data regarding deaths in various years in a
particular town and some of the observations are for the years in which
epidemic or war overtook the town, then interpolation methods are not
applicable.
3. When we apply calculus of finite differences, we assume that the given set
of observations is capable of being expressed in a polynomial form.
If the function f(x) is known explicitly, the value of y corresponding to any
value of x can be found easily.
If the function f(x) is not known, it is necessary to find a simpler function,
say φ(x), such that f(x) and φ(x) agree at the set of tabulated points. This
process is called interpolation. If φ(x) is a polynomial, then the process is
called polynomial interpolation and φ(x) is called the interpolating
polynomial.
4.3 ERRORS IN POLYNOMIAL INTERPOLATION
Let the function y(x) defined by (n + 1) points (xi, yi) i = 0, 1, 2, ......, n be
continuous and differentiable (n + 1) times and let y(x) be approximated by a
polynomial φn(x) of degree not exceeding n such that
φn(xi) = yi; i = 0, 1, 2, ....., n (1)
The problem lies in finding the accuracy of this approximation if we use
φn(x) to obtain approximate values of y(x) at some points other than those defined
above.
Since the expression y(x) – φn(x) vanishes for x = x0, x1, ......, xn, we put
y(x) – φn(x) = L Πn+1 (x) (2)
where Πn+1(x) = (x – x0) (x – x1) ...... (x – xn) (3)
and L is to be determined such that equation (2) holds for any intermediate
value of x say x′ where x0  x′  xn.
Clearly, L =
y x x
x
n
n
( ) ( )
( )
′ − ′
′
+
φ
Π 1
(4)
Construct a function, F(x) = y(x) – φn(x) – L Πn+1(x) (5)
where L is given by (4).
INTERPOLATION 201
It is clear that, F(x0) = F(x1) = ...... = F(xn) = F(x′) = 0
i.e., F(x) vanishes (n + 2) times in interval [x0, xn] consequently, by repeated
application of Rolle’s theorem, F′(x) must vanish (n + 1) times, F″(x) must
vanish n times in the interval [x0, xn]
Particularly, F(n+1) (x) must vanish once in [x0, xn].
Let this point be x = ξ; x0  ξ  xn.
Differentiating (5) (n + 1) times with respect to x and put x = ξ, we get
0 = (y)(n+1) (ξ) – L ( )!
n + 1
d
dx
x n
n
n
n
+
+
+
= +
1
1
1
1
( ) ( ) !
so that, L =
y
n
n
( )
( )
( ) !
+
+
1
1
ξ
(6)
Comparison of (4) and (6) give
y(x′) – φn(x′) =
y
n
n
( )
( )
( ) !
+
+
1
1
ξ
Πn+1(x′)
Hence, the required expression of error is
y(x) – φn(x) =
Πn x
n
+
+
1
1
( )
( ) !
yn+1(ξ), x0  ξ  xn (7)
Since y(x) is generally unknown, and we do not have any information
concerning y(n+1)(x), equation (7) is useless in practical computations.
We will use it to determine errors in Newton’s interpolating formulae.
The various methods of interpolation are as follows:
(1) The method of graph
(2) The method of curve fitting
(3) Use of calculus of finite difference formulae.
The merits of the last method over the others are
(i) It does not assume the form of function to be known.
(ii) It is less approximate than the method of graphs.
(iii) The calculations remain simple even if some additional observations
are included in the given data.
The demerit is there is no definite way to verify whether the assumptions
for the application of finite difference calculus are valid for the given set of
observations.
202 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.4 FINITE DIFFERENCES
The calculus of finite differences deals with the changes that take place in the
value of the function (dependent variable) due to finite changes in the
independent variable.
Suppose we are given a set of values (xi, yi); i = 1, 2, 3, ......, n of any function
y = f(x). A value of the independent variable x is called argument and the
corresponding value of the dependent variable y is called entry.
Suppose that the function y = f(x) is tabulated for the equally spaced
values x = x0, x0 + h, x0 + 2h, ....., x0 + nh, giving y = y0, y1, y2, ......, yn. To
determine the values of f(x) or f ′(x) for some intermediate values of x, the
following three types of differences are useful:
1. Forward differences. The differences y1 – y0, y2 – y1, y3 – y2, ......,
yn – yn–1 when denoted by Δy0, Δy1, Δy2, ......, Δyn–1 are respectively,
called the first forward differences where D is the forward difference
operator.
Thus the first forward differences are
Δyr = yr+1 – yr
Similarly, the second forward differences are defined by
Δ2yr = Δyr+1 – Δyr
Particularly, Δ2y0 = Δy1 – Δy0 = y2 – y1 – (y1 – y0) = y2 – 2y1 + y0
Similarly, Δ3y0 = y3 – 3y2 + 3y1 – y0
Δ4y0 = y4 – 4y3 + 6y2 – 4y1 + y0.
Clearly, any higher order difference can easily be expressed in terms of
ordinates since the coefficients occurring on R.H.S. are the binomial
coefficients*. In general, Δpyr = Δp–1yr+1 – Δp–1yr defines the pth forward
differences.
∗ Δn(y0) = yn – nC1 yn–1 + nC2yn–2 + ...... + (– 1)n y0
INTERPOLATION 203
The following table shows how the forward differences of all orders can
be formed.
Forward difference table
x y Δy Δ2y Δ3y Δ4y Δ5y
x0 y0
Δy0
x1 y1 Δ2y0
(= x0 + h) Δy1 Δ3y0
x2 y2 Δ2y1 Δ4y0
(= x0 + 2h) Δy2 Δ3y1 Δ5y0
x3 y3 Δ2y2 Δ4y1
= (x0 + 3h) Δy3 Δ3y2
x4 y4 Δ2y3
= (x0 + 4h) Δy4
x5 y5
= (x0 + 5h)
Here the first entry, y0, is called the leading term and Δy0, Δ2y0, ...... are
called leading differences.
Δ obeys distributive, commutative and index laws:
1. Δ [f(x) ± φ(x)] = Δf(x) ± Δφ (x)
2. Δ [c f(x)] = c Δ f(x); c is constant
3. Δm Δn f(x) = Δm+n f(x), m, n being (+)ve integers.
But, Δ[f(x) . φ(x)] ≠ f(x) . Δ φ(x).
2. Backward differences. The differences y1 – y0, y2 – y1, ......, yn – yn–1
when denoted by ∇y1, ∇y2, ......, ∇yn, respectively, are called first
backward differences where ∇ is the backward difference operator.
Similarly, we define higher order backward differences as,
∇yr = yr – yr–1
∇2yr = ∇yr – ∇yr–1
∇3yr = ∇2yr – ∇2yr–1 etc.
Particularly, ∇2y2 = ∇y2 – ∇y1
= y2 – y1 – (y1 – y0) = y2 – 2y1 + y0
∇3y3 = ∇2y3 – ∇2y2 = y3 – 3y2 + 3y1 – y0 etc.
NOTE
204 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Backward difference table
x y ∇y ∇2y ∇3y ∇4y ∇5y
x0 y0
∇y1
x1 y1 ∇2y2
(= x0 + h) ∇y2 ∇3y3
x2 y2 ∇2y3 ∇4y4
(= x0 + 2h) ∇y3 ∇3y4 ∇5y5
x3 y3 ∇2y4 ∇4y5
(= x0 + 3h) ∇y4 ∇3y5
x4 y4 ∇2y5
(= x0 + 4h) ∇y5
x5 y5
(= x0 + 5h)
3. Central differences. The central difference operator d is defined by
the relations
y1 – y0 = δy1/2, y2 – y1 = δy3/2, ......, yn – yn–1 = δy
n –
1
2
.
Similarly, high order central differences are defined as
δy3/2 – δy1/2 = δ2y1, δy5/2 – δy3/2 = δ2y2
and so on.
These differences are shown as follows:
Central difference table
x y δy δ 2y δ3y δ4y δ 5y
x0 y0
δy1/2
x1 y1 δ2y1
δy3/2 δ3y3/2
x2 y2 δ2y2 δ4y2
δy5/2 δ3y5/2 δ5y5/2
x3 y3 δ2y3 δ4y3
δy7/2 δ3y7/2
x4 y4 δ2y4
δy9/2
x5 y5
INTERPOLATION 205
1. The central differences on the same horizontal line have the same suffix.
2. It is only the notation that changes, not the differences.
e.g., y1 – y0 = Δy0 = ∇y1= δy1/2.
4.5 OTHER DIFFERENCE OPERATORS
1. Shift operator E.
Shift operator E is the operation of increasing the argument x by h so that
Ef(x) = f(x + h)
E2f(x) = f(x + 2h) and so on.
The inverse operator, E–1, is defined by
E–1f(x) = f(x – h).
Also Enyx = yx+nh.
2. Averaging operator μ.
The averaging operator is defined by
μyx =
1
2
L
NMy y
x h x h
+ −
+
1
2
1
2
O
QP
In difference calculus, E is the fundamental operator and ∇, Δ, δ, μ can be
expressed in terms of E.
4.6 RELATION BETWEEN OPERATORS
1. Δ = E – 1 or E = 1 + Δ.
Proof. We know that,
Δyx = yx+h – yx = Eyx – yx = (E – 1)yx
⇒ Δ = E – 1
or E = 1 + Δ
2. ∇ = 1 – E–1
Proof. ∇yx = yx – yx–h = yx – E–1yx
∴ ∇ = 1 – E–1
3. δ = E1/2 – E–1/2
NOTE
206 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Proof. δyx = y
x
h
+
2
– y
x
h
−
2
= E1/2 yx – E–1/2 yx
= (E1/2 – E–1/2) yx
∴ δ = E1/2 – E–1/2
4. μ =
1
2
(E1/2 + E–1/2)
Proof. μyx =
1
2
( y
x
h
+
2
+ y
x
h
−
2
) =
1
2
(E1/2 + E–1/2) yx
⇒ μ =
1
2
(E1/2 + E–1/2)
5. Δ = E∇ = ∇E = δE1/2
Proof. E(∇yx) = E(yx – yx–h) = yx+h – yx = Δyx
⇒ E∇ = Δ
∇(E yx) = ∇ yx+h = yx+h – yx = Δyx
⇒ ∇E = Δ
δE1/2 yx = δ y
x
h
+
2
= yx+h – yx = Δyx
⇒ δE1/2 = Δ
6. E = ehD
Proof. Ef(x) = f(x + h)
= f(x) + h f ′(x) +
h2
2 !
f ″(x) + ..... (By Taylor series)
= f(x) + hDf(x) +
h2
2!
D2f(x) + ......
= 1
2
2
+ + +
L
NM O
QP
h
h
D
D
( )
!
...... f(x) = ehD f(x)
∴ E = ehD or Δ = ehD – 1.
INTERPOLATION 207
4.7 DIFFERENCES OF A POLYNOMIAL
The nth differences of a polynomial of nth degree are constant and all higher
order differences are zero when the values of the independent variable are at
equal intervals.
Let f(x) = axn + bxn–1 + cxn–2 + ...... + kx + l
∴ Δf(x) = f(x + h) – f(x)
= a[(x + h)n – xn] + b [(x + h)n–1 – xn–1] + ...... + kh
= anhxn–1 + b′xn–2 + c′xn–3 + ...... + k′x + l′ (8)
where b′, c′, ...... l′ are new constant coefficients.
∴ First differences of a polynomial of nth degree is a polynomial of degree
(n – 1).
Similarly,
Δ2f(x) = Δf(x + h) – Δf(x)
= anh [(x + h)n–1 – xn–1] + b′[(x + h)n–2 – xn–2] + ...... + k′h
= an(n – 1) h2xn–2 + b″xn–3 + ...... + k″ (9)
∴ Second differences represent a polynomial of degree (n – 2).
Continuing this process, for nth differences, we get a polynomial of degree
zero, i.e.,
Δn f(x) = an(n – 1) (n – 2) ...... 1 hn = a n! hn
which is a constant. Hence the (n + 1)th and higher differences of a polynomial
of nth degree will be zero. The converse of this theorem is also true.
EXAMPLES
Example 1. Construct the forward difference table, given that
x: 5 10 15 20 25 30
y: 9962 9848 9659 9397 9063 8660
and point out the values of Δ2y10 , Δ4y5.
208 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Forward difference table is as follows:
x y Δy Δ2y Δ3y Δ4y
5 9962
– 114
10 9848 – 75
– 189 2
15 9659 – 73 – 1
– 262 1
20 9397 – 72 2
– 334 3
25 9063 – 69
– 403
30 8660
From the table, Δ2y10 = – 73 and Δ4y5 = – 1.
Example 2. If y = x3 + x2 – 2x + 1, calculate values of y for x = 0, 1, 2, 3, 4, 5 and
form the difference table. Find the value of y at x = 6 by extending the table and
verify that the same value is obtained by substitution.
Sol. For x = 0, y = 1;
x = 1, y = 1;
x = 2, y = 9;
x = 3, y = 31;
x = 4, y = 73;
x = 5, y = 141
Difference table is as follows:
x y Δy Δ2y Δ3y
0 1
0
1 1 8
8 6
2 9 14
22 6
3 31 20
42 6
4 73 26
68 6
5 141 32
100
6 241
INTERPOLATION 209
∵ Third differences are constant.
∴ Δ3y3 = 6 ⇒ Δ2y4 – Δ2y3 = 6
⇒ Δ2y4 – 26 = 6 ⇒ Δ2y4 = 32
Now, Δ2y4 = 42 ⇒ Δy5 – Δy4 = 32
⇒ Δy5 – 68 = 32 ⇒ Δy5 = 100
Further, Δy5 = 100
y6 – y5 = 100
⇒ y6 – 141 = 100
y6 = 241
Verification. y(6) = (6)3 + (6)2 – 2(6) + 1 = 241. Hence verified.
Example 3. Construct a backward difference table for y = log x given that
x: 10 20 30 40 50
y: 1 1.3010 1.4771 1.6021 1.6990
and find values of ∇3 log 40 and ∇4 log 50.
Sol. Backward difference table is:
x y ∇y ∇2y ∇3y ∇4y
10 1
0.3010
20 1.3010 – 0.1249
0.1761 0.0738
30 1.4771 – 0.0511 – 0.0508
0.1250 0.0230
40 1.6021 – 0.0281
0.0969
50 1.6990
From the table, ∇3 log 40 = 0.0738 and ∇4 log 50 = – 0.0508.
Example 4. Construct a backward difference table from the data:
sin 30° = 0.5, sin 35° = 0.5736, sin 40° = 0.6428 sin 45° = 0.7071
Assuming third differences to be constant, find the value of sin 25°.
210 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Backward difference table is:
x y ∇y ∇2y ∇3y
25 .4225
.0775
30 0.5000 – .0039
0.0736 – .0005
35 0.5736 – .0044
0.0692 – .0005
40 0.6428 – .0049
0.0643
45 0.7071
Since third differences are constant
∴ ∇3y40 = – .0005
⇒ ∇2y40 – ∇2y35 = – .0005
⇒ – .0044 – ∇2y35 = – .0005
⇒ ∇2y35 = – .0039
Again ∇y35 – ∇y30 = – .0039
⇒ .0736 – ∇y30 = – .0039
⇒ ∇y30 = .0775
Again y30 – y25 = .0775
⇒ 0.5 – y25 = .0775
⇒ y25 = 0.4225
∴ sin 25° = .4225.
Example 5. Evaluate:
(i) Δ tan–1 x (ii) Δ2 cos 2x
where h is the interval of differencing.
Sol. (i) Δ tan–1 x = tan–1 (x + h) – tan–1 x
= tan–1
x h x
x x h
+ −
+ +
R
S
T
U
V
W
1 ( )
= tan–1
h
hx x
1 2
+ +
F
HG
I
KJ
(ii) Δ2 cos 2x = Δ[cos 2(x + h) – cos 2x]
= [cos 2(x + 2h) – cos 2(x + h)] – [cos 2(x + h) – cos 2x]
INTERPOLATION 211
= – 2 sin (2x + 3h) sin h + 2 sin (2x + h) sin h
= – 2 sin h [2 cos (2x + 2h) sin h] = – 4 sin2 h cos 2(x + h).
Example 6. Evaluate:
Δ2
5x 12
x 5x 6
2
+
+ +
F
HG
I
KJ; the interval of differencing being unity.
Sol. Δ2 5 12
2 3
x
x x
+
+ +
R
S
T
U
V
W
( )( )
= Δ2
2
2
3
3
x x
+
+
+
F
HG I
KJ = Δ Δ Δ
2
2
3
3
x x
+
F
HG I
KJ +
+
F
HG I
KJ
L
NM O
QP
= Δ 2
1
3
1
2
3
1
4
1
3
x x x x
+
−
+
F
HG I
KJ +
+
−
+
F
HG I
KJ
L
NM O
QP
= – 2Δ
1
2 3
3
1
3 4
( )( ) ( )( )
x x x x
+ +
R
S
T
U
V
W
−
+ +
R
S
T
U
V
W
Δ
= – 2
1
3 4
1
2 3
( )( ) ( )( )
x x x x
+ +
−
+ +
L
NM O
QP
– 3
1
4 5
1
3 4
( )( ) ( )( )
x x x x
+ +
−
+ +
L
NM O
QP
=
4
2 3 4
6
3 4 5
( )( )( ) ( )( )( )
x x x x x x
+ + +
+
+ + +
=
2 5 16
2 3 4 5
( )
( )( )( )( )
x
x x x x
+
+ + + +
.
Example 7. If f(x) = exp(ax), evaluate Δnf(x).
Sol. Δeax = ea(x+h) – eax = (eah – 1)eax
Δ2eax = Δ(Δeax) = Δ[(eah – 1)eax]
= (eah – 1)(eah – 1)eax = (eah – 1)2 eax
Similarly Δ3 eax = (eah – 1)3 eax
  
Δn eax = (eah – 1)n eax.
212 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 8. With usual notations, prove that
Δn
1
x
F
HG I
KJ = (– 1)n .
n ! h
x (x h) ......(x nh)
n
+ +
.
Sol. Δn
1
x
F
HG I
KJ = Δn–1 Δ
1
x
F
HG I
KJ = Δn–1
1 1
x h x
+
−
L
NM O
QP
= Δn–1
−
+
R
S
T
U
V
W
h
x x h
( )
= (– h) Δn–2 Δ
1
x x h
( )
+
R
S
T
U
V
W
= (– 1) Δn–2 Δ
1 1
x x h
−
+
F
HG I
KJ
L
NM O
QP
= (– 1) Δn–2
1 1 1
2
1
x h x x h x h
+
−
F
HG I
KJ −
+
−
+
F
HG I
KJ
L
NM O
QP
= (– 1) Δn–2
2 1 1
2
x h x x h
+
− −
+
L
NM O
QP
= (– 1) Δn–2
−
+ +
L
NM O
QP
2
2
2
h
x x h x h
( )( )
= (– 1)2 Δn–2
2
2
2
!
( )( )
h
x x h x h
+ +
L
NM O
QP
= (– 1)3 Δn–3
3
2 3
3
!
( )( )( )
h
x x h x h x h
+ + +
L
NM O
QP

= (– 1)n n h
x x h x nh
n
!
( ) ...... ( )
+ +
.
Example 9. Assuming that the following values of y belong to a polynomial of
degree 4, compute the next three values:
x: 0 1 2 3 4 5 6 7
y: 1 – 1 1 – 1 1 – – –
INTERPOLATION 213
Sol. Difference table is:
x y Δy Δ2y Δ3y Δ4y
0 1
– 2
1 – 1 4
2 – 8
2 1 – 4 16
– 2 8
3 – 1 4 16
2 Δ3y2
4 1 Δ2y3 16
Δy4 Δ3y3
5 y5 Δ2y4 16
Δy5 Δ3y4
6 y6 Δ2y5
Δy6
7 y7
Since values of y belong to a polynomial of degree 4, the fourth differences
must be constant.
But Δ4y0 = 16
∴ Other fourth order differences will be 16.
Thus, Δ4y1 = 16
∴ Δ3y2 – Δ3y1 = 16
⇒ Δ3y2 = 24
∴ Δ2y3 – Δ2y2 = 24
⇒ Δ2y3 = 28
Δy4 – Δy3 = 28
⇒ Δ y4 = 30
y5 – y4 = 30
⇒ y5 = 31
Again, Δ4y2 = 16 and solving, we get y6 = 129
and Δ4y3 = 16 gives y7 = 351.
214 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 10. Prove that
Δ log f(x) = log 1
f(x)
f(x)
+
L
NM O
QP
Δ
.
Sol. L.H.S. = log f(x + h) – log f(x)
= log [f(x) + Δf(x)] – log f(x) | ∵ Δf(x) = f(x + h) – f(x)
= log
f x f x
f x
( ) ( )
( )
+
L
NM O
QP
Δ
= log 1 +
L
NM O
QP
Δf x
f x
( )
( )
= R.H.S.
Example 11. Prove that
ex =
Δ2
E
F
HG
I
KJ ex .
Ee
e
x
2 x
Δ
.
Sol.
Δ2
E
F
HG
I
KJ ex = Δ2 E–1 ex = Δ2 ex–h = e–h Δ2 ex
R.H.S. = e–h . Δ2 ex .
E e
e
x
x
Δ2
= e–h . E ex = e–h ex+h = ex.
Example 12. Prove that hD = – log (1 – ∇) = sin h–1 (μδ).
Sol. hD = log E = – log (E–1) = – log (1 – ∇) | ∵ E–1 = 1 – ∇
Also, μ =
1
2
(E1/2 + E–1/2)
δ = E1/2 – E–1/2
∴ μδ =
1
2
(E – E–1) =
1
2
(ehD – e–hD) = sin h (hD)
or hD = sin h–1 (μδ).
Example 13. Prove that
(i) (E1/2 + E–1/2) (1 + Δ)1/2 = 2 + Δ (ii) Δ =
1
2
δ2 + δ 1 /4
2
+ δ
(iii) Δ3y2 = ∇3y5.
Sol. (i) (E1/2 + E–1/2) E1/2 = E + 1 = 1 + Δ + 1 = Δ + 2
(ii)
1
2
δ2 + δ 1
4
2
+
δ
=
1
2
(E1/2 – E–1/2)2 + (E1/2 – E–1/2) 1
1
4
1/2 1/2 2
+ − −
( )
E E
=
1
2
(E + E–1 – 2) + (E1/2 – E–1/2)
E E
1/2 1/2
2
+
F
HG
I
KJ
−
=
1
2
(2E – 2) = E – 1 = Δ
INTERPOLATION 215
(iii) Δ3y2 = (E – 1)3 y2
= (E3 – 3E2 + 3E – 1) y2 = y5 – 3y4 + 3y3 – y2
∇3y5 = (1 – E–1) y5
= (1 – 3 E–1 + 3E–2 – E–3) y5 = y5 – 3y4 + 3y3 – y2.
Example 14. Prove that
(i) Δ + ∇ =
Δ
Δ
∇
−
∇
where Δ and ∇ are forward difference and backward difference operators
respectively.
(ii) Δ2
yr
r 0
n 1
=
−
∑ = Δyn – Δy0 (iii) Δryk = ∇ryk+r.
Sol. (i)
Δ
Δ
∇
−
∇
F
HG I
KJ yx =
E 1
1 E
1 E
E 1
1
1
−
−
−
−
−
F
HG
I
KJ
−
−
yx
=
E 1
E 1
E
E 1
E
E 1
−
−
F
HG I
KJ
−
−
F
HG I
KJ
−
R
S
|
|
T
|
|
U
V
|
|
W
|
|
yx = E
1
E
−
F
HG I
KJ yx = (E – E–1)yx
= {(1 + Δ) – (1 – ∇)}yx = (Δ + ∇)yx
Hence,
Δ
Δ
∇
−
∇
= Δ + ∇
(ii) Δ Δ Δ
2
1
0
1
0
1
y y y
r r r
r
n
r
n
= −
+
=
−
=
−
∑
∑ ( )
= Δy1 – Δy0 + Δy2 – Δy1 + ...... + Δyn – Δyn–1
= Δyn – Δy0.
(iii) ∇ryk+r = (1 – E–1)ryk+r =
E 1
E
−
F
HG I
KJ
r
yk+r
= (E – 1)r E–ryk+r = Δryk.
Example 15. Denoting
x
n
x x 1 x n 1
n
F
HG I
KJ =
− − +
( ) ...... ( )
!
, prove that for any polyno-
mial φ(x) of degree k
φ(x) =
i 0
k
x
i
=
∑
F
HG I
KJ Δi φ(0).
216 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. We have
En f(a) = f(a + nh) = f(a) + nC1 Δf(a) + nC2 Δ2f(a) + ...... + nCn Δn f(a)
Put a = 0, n = x, we get for h = 1
f(x) = f(0) + xC1 Δf(0) + xC2 Δ2f(0) + ...... + xCx Δx f(0)
Again, f(x) = φ(x) is the given polynomial of degree k
∴ Δk φ(x) = constant and higher order differences will be zero.
∴ φ(x) = φ(0) + xC1 Δ φ(0) + ...... + xCk Δk φ(0) =
i
k
x
i
=
∑
F
HG I
KJ
1
Δi φ(0).
Example 16. Obtain the first term of the series whose second and subsequent
terms are 8, 3, 0, – 1, 0.
Sol. f(1) = E–1 f(2) = (1 + Δ)–1 f(2)
= (1 – Δ + Δ2 – Δ3 + ......) f(2)
Since five observations are given
∴ Δ4 f(x) = constant and Δ5f(x) = 0
We construct the table as:
x f(x) Δf(x) Δ2f(x)
2 8
– 5
3 3 2
– 3
4 0 2
– 1
5 – 1 2
1
6 0
Hence, f(1) = f(2) – Δf(2) + Δ2 f(2) = 8 – (– 5) + 2 = 15.
Example 17. Given u0, u1, u2, u3, u4, and u5, and assuming the fifth order
differences to be constant, prove that
u
1
2
c
25 (c b) 3(a c)
256
2
1
2
= +
− + −
where a = u0 + u5, b = u1 + u4, c = u2 + u3.
Sol. u
2
1
2
= E5/2 u0 = (1 + Δ)5/2 u0
INTERPOLATION 217
= 1
5
2
5
2
5
2
1
2
5
2
5
2
1
5
2
2
5
2
3
5
2
4
5
2 5
+ +
−
F
HG I
KJ
+ +
−
F
HG I
KJ −
F
HG I
KJ −
F
HG I
KJ −
F
HG I
KJ
L
N
MMMM
O
Q
PPPP
Δ Δ Δ
!
......
!
u0
= u0 +
5
2
Δu0 +
15
8
Δ2u0 +
5
16
Δ3u0 –
5
128
Δ4u0 +
3
256
Δ5u0
= u0 +
5
2
(u1 – u0) +
15
8
(u2 – 2u1 + u0) +
5
16
(u3 – 3u2 + 3u1 – u0) + ......
+
3
256
(u5 – 5u4 + 10u3 – 10u2 + 5u1 – u0)
=
3
256
(u0 + u5) –
25
256
(u1 + u4) +
75
128
(u2 + u3) =
3
256
25
256
a
− b +
75
128
c
=
3
256
25
256
a b
− +
1
2
11
128
+
F
HG I
KJ c =
c a c c b
2
3 25
256
+
− + −
( ) ( )
.
Example 18. (i) Prove the relation: (1 + Δ)(1 – ∇) ≡ 1
(ii) Find the function whose first difference is ex.
(iii) If Δ3ux = 0 prove that:
u
1
2
x
1
2
+
= (ux + ux+1) –
1
16
(Δ2ux + Δ2ux+1).
Sol. (i) (1 + Δ)(1 – ∇) f(x) = (1 + Δ) [f(x) – ∇ f(x)]
= (1 + Δ) [f(x) – {f(x) – f(x – h)}] = (1 + Δ) [f (x – h)]
= E f(x – h) = 1 . f(x)
(1 + Δ) (1 – ∇) ≡ 1.
(ii) Δ ex = ex+h – ex = (eh – 1) ex
⇒ ex =
Δe
e
x
h
− 1
Hence, Δ
e
e
x
h
−
F
HG
I
KJ
1
= ex or f(x) =
e
e
x
h
− 1
.
(iii) u
x +
1
2
= E1/2 ux = (1 + Δ)1/2 ux
= 1
1
2
1
8
2
+ −
F
HG I
KJ
Δ Δ ux (10) | ∵ Δ3 ux = 0
218 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now, Δ3 ux = 0
⇒ Δ2ux+1 – Δ2 ux = 0
⇒ Δ2ux+1 = Δ2ux and Δux = ux+1 – ux
∴ From (10),
u
x +
1
2
= ux +
1
2
(ux+1 – ux) –
1
8
Δ Δ
2 2
1
2 2
u u
x x
+
F
HG
I
KJ
+
=
1
2
(ux + ux+1) –
1
16
(Δ2ux + Δ2ux+1).
Example 19. (i) Find f(6) given f(0) = – 3, f(1) = 6, f(2) = 8, f(3) = 12; third
difference being constant.
(ii) Find Δ10(1 – ax)(1 – bx2)(1 – cx3)(1 – dx4).
(iii) Evaluate Δn(axn + bxn–1).
Sol. (i) The difference table is:
x f(x) Δf(x) Δ2f(x) Δ3f(x)
0 – 3
9
1 6 – 7
2 9
2 8 2
4
3 12
f(0 + 6) = E6f(0) = (1 + Δ)6f(0) = (1 + 6Δ + 15Δ2 + 20Δ3) f(0)
= – 3 + 6 (9) + 15 (– 7) + 20 (9) = – 3 + 54 – 105 + 180 = 126.
(ii) Maximum power of x in the polynomial will be 10 and the coefficient of
x10 will be abcd.
Here k = abcd, h = 1, n = 10
∴ Expression = k hn n ! = abcd 10 !.
(iii) Δn(axn + bxn–1) = a Δn(xn) + b Δn(xn–1) = a(n) ! + b(0) = a(n) !.
Example 20. (i) Prove that if m is a (+)ve integer, then
(x 1)
m !
(m)
+
=
x
m !
(m)
+
x
(m 1) !
(m 1)
−
−
INTERPOLATION 219
(ii) Given u0 + u8 = 1.9243, u1 + u7 = 1.9590
u2 + u6 = 1.9823, u3 + u5 = 1.9956. Find u4.
Sol. (i) R.H.S. =
x x x m
m
x x x m
m
( ) ...... ( )
!
( ) ...... ( )
( ) !
− − +
+
− − +
−
1 1 1 2
1
=
x x x x m
m
( ) ( ) ...... ( )
!
− − − +
1 2 2
[(x – m + 1) + m]
=
( ) ( )( ) ...... ( )
!
( )
!
( )
x x x x x m
m
x
m
m
+ − − − +
=
+
1 1 2 2 1
= L.H.S.
(ii) Taking Δ8 u0 = 0
⇒ (E – 1)8 u0 = 0
⇒ u8 – 8c1u7 + 8c2u6 – 8c3u5 + 8c4u4 – 8c5u3 + 8c6u2 – 8c7u1 + 8c8u0 = 0
⇒ (u0 + u8) – 8(u1 + u7) + 28(u2 + u6) – 56(u3 + u5) + 70 u4 = 0
⇒ u4 = 0.99996. (After giving the values)
Example 21. Prove that
(i) δ[f(x) g(x)] = μf(x) δg(x) + μg(x) δf(x)
(ii) δ
f(x)
g(x)
g(x) f(x) f(x) g(x)
g(x ) g(x )
1
2
1
2
L
NM O
QP=
−
− +
μ δ μ δ
(iii) μ
f(x)
g(x)
f(x) g(x) f(x) g(x)
g(x ) g(x )
1
4
1
2
1
2
L
NM O
QP=
−
− +
μ μ δ δ
The interval of difference is said to be unity.
Sol. (i) R.H.S. = μf(x) δg(x) + μg(x) δf(x)
=
E E
1/2 1/2
2
+ −
f(x) . (E1/2 – E–1/2) g(x) +
E E
1/2 1/2
2
+ −
g(x) (E1/2 – E–1/2) f(x)
= 1
2 [{f(x + 1
2 ) + f(x – 1
2 )}{g(x + 1
2 ) – g(x – 1
2 )}
+ {g(x + 1
2 ) + g(x – 1
2 )} {f(x + 1
2 ) – f(x – 1
2 )}]
= 1
2 [{f(x + 1
2 )g (x + 1
2 ) – f(x + 1
2 ) g(x – 1
2 ) + f(x – 1
2 ) g(x + 1
2 )
– f(x – 1
2 ) g(x – 1
2 )} + {f(x + 1
2 ) g(x + 1
2 )
+ f(x + 1
2 ) g(x – 1
2 ) – f(x – 1
2 ) g(x + 1
2 ) – f(x – 1
2 ) g(x – 1
2 )}]
220 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 1
4
f(x + 1
2
) g(x + 1
2
) – f(x – 1
2
) g(x – 1
2
)
= E1/2 f(x) g(x) – E–1/2 f(x) g(x) = (E1/2 – E–1/2)f(x) g(x) = δf(x) g(x).
(ii) R.H.S. =
μ δ μ δ
g x f x f x g x
g x g x
( ) ( ) ( ) ( )
( ) ( )
−
− +
1
2
1
2
Numerator of R.H.S.
=
E E
1/2 1/2
2
+ −
g(x) (E1/2 – E–1/2) f(x)
–
E E
1/2 1/2
2
+ −
f(x) (E1/2 – E–1/2) g(x)
= 1
2 [{g(x + 1
2 ) + g(x – 1
2 )}{f(x + 1
2 ) – f(x – 1
2 )}
– {f(x + 1
2
) + f(x – 1
2
)}{g(x + 1
2
) – g(x – 1
2
)}]
= 1
2
[f(x + 1
2
) g(x + 1
2
) + f(x + 1
2
) g(x – 1
2
) – f(x – 1
2
) g(x + 1
2
)
– f(x – 1
2 ) g(x – 1
2 )] – 1
2 [f(x + 1
2 ) g(x + 1
2 ) – f(x + 1
2 )g(x – 1
2 )
+ f(x – 1
2
) g(x + 1
2
) – f(x – 1
2
) g(x – 1
2
)]
= f(x + 1
2
) g(x – 1
2
) – f(x – 1
2
) g(x + 1
2
)
∴ R.H.S. =
f x g x f x g x
g x g x
( ) ( ) ( ) ( )
( ) ( )
+ − − − +
− +
1
2
1
2
1
2
1
2
1
2
1
2
=
f x
g x
f x
g x
f x
g x
f x
g x
( )
( )
( )
( )
( )
( )
( )
( )
+
+
−
−
−
=
L
NM O
QP−
L
NM O
QP
1
2
1
2
1
2
1
2
1/2 1/2
E E
= (E1/2 – E–1/2)
f x
g x
f x
g x
( )
( )
( )
( )
F
HG I
KJ =
L
NM O
QP
δ .
(iii) R.H.S. =
μ μ δ δ
f x g x f x g x
g x g x
( ) ( ) ( ) ( )
( ) ( )
−
− +
1
4
1
2
1
2
Numerator of R.H.S.
= 1
2
[E1/2 + E–1/2] f(x) . 1
2
(E1/2 + E–1/2) g(x)
– 1
4
(E1/2 – E–1/2) f(x) (E1/2 – E–1/2) g(x)
= 1
4
[f(x + 1
2
) + f(x – 1
2
)][g(x + 1
2
) + g(x – 1
2
)]
– 1
4
[f(x + 1
2
) – f(x – 1
2
)][g(x + 1
2
) – g(x – 1
2
)]
INTERPOLATION 221
= 1
4
[f(x + 1
2
) g(x + 1
2
) + f(x + 1
2
) g(x – 1
2
) + f(x – 1
2
) g(x + 1
2
)
+ f(x – 1
2
) g(x – 1
2
) – 1
4
[f(x + 1
2
) g(x + 1
2
) – f(x + 1
2
) g(x – 1
2
)
– f(x – 1
2
) g(x + 1
2
) + f(x – 1
2
) g(x – 1
2
)
= 1
2
[f(x + 1
2
) g(x – 1
2
) + f(x – 1
2
) g(x + 1
2
)]
∴ R.H.S. =
1
2
1
2
1
2
1
2
1
2
1
2
1
2
[ ( ) ( ) ( ) ( )]
( ) ( )
f x g x f x g x
g x g x
+ − + − +
− +
=
1
2 2
1
2
1
2
1
2
1
2
1/2 1/2
f x
g x
f x
g x
( )
( )
( )
( )
+
+
+
−
−
L
N
MM
O
Q
PP=
+ −
E E f x
g x
f x
g x
( )
( )
( )
( )
L
NM O
QP=
L
NM O
QP
μ .
Example 22. Evaluate:
(i) Δ(eax log bx) (ii) Δ
2
(x 1) !
x
+
F
HG
I
KJ; h = 1.
Sol. (i) Let f(x) = eax, g(x) = log bx
Δ f(x) = ea(x+h) – eax = eax (eah – 1)
Also, Δg(x) = log b(x + h) – log bx = log 1 +
F
HG I
KJ
h
x
We know that,
Δ f(x) g(x) = f(x + h) Δ g(x) + g(x) Δf(x)
∴ Δ (eax log bx) = ea(x+h) log 1 +
F
HG I
KJ
h
x
+ (log bx) eax(eah – 1)
= eax e
h
x
e bx
ah ah
log ( ) log
1 1
+
F
HG I
KJ + −
L
NM O
QP.
(ii) Let f(x) = 2x, g(x) = (x + 1) !
∴ Δf(x) = 2x+1 – 2x = 2x
and Δ g(x) = (x + 1 + 1) ! – (x + 1) ! = (x + 1) (x + 1) !
We know that,
Δ
f x
g x
( )
( )
L
NM O
QP =
g x f x f x g x
g x h g x
( ) ( ) ( ) ( )
( ) ( )
Δ Δ
−
+
=
( ) !. . ( ) ( ) !
( ) ! ( )!
x x x
x x
x x
+ − + +
+ + +
1 2 2 1 1
1 1 1
(∵ h = 1)
=
2 1 1 1
2 1 2
x
x x
x x
x
x
( ) ! ( )
( ) ! ( ) ! ( ) !
+ − −
+ +
= −
+
2x.
222 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 23. Evaluate:
(i) Δn [sin (ax + b)] (ii) Δn [cos (ax + b)].
Sol. (i) Δ sin (ax + b)
= sin [a (x + h) + b] – sin (ax + b)
= 2 sin
ah
2
cos a x
h
b
+
F
HG I
KJ +
L
NM O
QP
2
= 2 sin
ah
2
sin ax b
ah
+ +
+
F
HG I
KJ
π
2
∴ Δ2 sin (ax + b)
= Δ 2
2 2
sin sin
ah
ax b
ah
+ +
+
F
HG I
KJ
L
NM O
QP
π
= 2
2
2
2 2 2
sin sin sin
ah ah
ax b
ah ah
F
HG I
KJ F
HG I
KJ + +
+
+
+
L
NM O
QP
π π
= 2
2
2
sin
ah
F
HG I
KJ sin ax b
ah
+ +
+
F
HG I
KJ
L
NM O
QP
2
2
π
Proceeding in the same manner, we get
Δ3 sin (ax + b) = 2
2
3
2
3
sin sin
( )
ah
ax b
ah
F
HG I
KJ + +
+
L
NM O
QP
π
 
Δn sin (ax + b) = 2
2 2
sin sin
( )
ah
ax b
n ah
n
F
HG I
KJ + +
+
L
NM O
QP
π
Similarly,
(ii) Δn cos (ax + b) = 2
2 2
sin cos
ah
ax b n
ah
n
F
HG I
KJ + +
+
F
HG I
KJ
L
NM O
QP
π
.
Example 24. Prove that
(i) μδ =
1
2
(Δ + ∇) (ii) 1 +
δ
δ μ
2
2 2
2
1
F
HG
I
KJ = +
(iii) ∇2 = h2D2 – h3D3 +
7
12
h4D4. ...... (iv) ∇ – Δ = – ∇Δ
Sol. (i) μδyx = μ(E1/2 – E–1/2)yx
= μ( y y
x
h
x
h
+ −
−
2 2
) = μ( ) ( )
y y
x
h
x
h
+ −
−
2 2
μ
INTERPOLATION 223
=
1
2
(E1/2 + E–1/2)( )
y
x
h
+
−
2
1
2
(E1/2 + E–1/2)( )
y
x
h
−
2
=
1
2
(yx+h + yx) –
1
2
(yx + yx–h) =
1
2
(yx+h – yx) +
1
2
(yx – yx–h)
=
1
2
(Δyx) +
1
2
(∇yx) =
1
2
(Δ + ∇)yx
Hence, μδ =
1
2
(Δ + ∇)
(ii) L.H.S. = 1
2
2
+
F
HG
I
KJ
R
S
|
T
|
U
V
|
W
|
δ
yx = 1
(E E )
2
1/2 1/2 2
+
−
R
S
T
|
U
V
W
|
−
yx
= 1
E E
2
–1
+
+ −
F
HG
I
KJ
R
S
|
T
|
U
V
|
W
|
2
yx =
1
2
(E + E–1)yx
R.H.S. = ( )
1 2 2
+ δ μ yx
= 1
1
4
1/2 1/2 2 1/2 1/2 2
1/2
+ − +
R
S
T
U
V
W
L
NM O
QP
− −
( ) . ( )
E E E E yx
= 1
1/2
+
−
F
HG
I
KJ
R
S
|
T
|
U
V
|
W
|
−
(E E )
4
1 2
yx
=
E E 2
4
2 2 1/2
+ +
F
HG
I
KJ
−
yx =
E E
2
1
+
F
HG
I
KJ
−
yx
Hence L.H.S. = R.H.S.
(iii) E = ehD and ∇ = 1 – E–1
∴ ∇2 = (1 – E–hD)2
= 1 1
2 3 4
2 3 4
2
− − + − + −
R
S
T
U
V
W
L
N
MM
O
Q
PP
h
h h h
D
D D D
( )
!
( )
!
( )
!
...
= h
h h h
D
D D D
− + − +
R
S
T
U
V
W
( )
!
( )
!
( )
!
...
2 3 4 2
2 3 4
= h2D2 1
2 6
2
− − +
R
S
T
U
V
W
L
N
MM
O
Q
PP
h h
D D)2
(
...
224 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= h2D2 1
2 6
2
2 6
2
+ − +
R
S
T
U
V
W
− − +
R
S
T
U
V
W
L
N
MM
O
Q
PP
h h h h
D D) D D)
2 2
(
...
(
...
= h2D2 1
1
4
1
3
2
− + +
F
HG I
KJ −
L
NM O
QP
h h
D D
( ) ...
= h2D2 1
7
12
2 2
− + −
F
HG I
KJ
h h
D D ... = h2D2 – h3D3 +
7
12
h4D4 – ...
(iv) ∇ – Δ = (1 – E–1) – (E – 1) =
E 1
E
−
F
HG I
KJ – (E – 1) = (E – 1)(E–1 – 1)
= – (E – 1) (1 – E–1) = – ∇Δ
ASSIGNMENT 4.1
1. Form a table of differences for the function:
f(x) = x3 + 5x – 7 for x = – 1, 0, 1, 2, 3, 4, 5
Continue the table to obtain f(6) and f(7).
2. Given the set of values
x: 10 15 20 25 30 35
y: 19.97 21.51 22.47 23.52 24.65 25.89.
Form the difference table and find the values of Δ2 y10 , Δy20 , Δ3 y15 , and Δ5y10.
3. Write the forward difference table for
x: 10 20 30 40
y: 1.1 2.0 4.4 7.9.
4. Construct the table of differences for the data below:
x: 0 1 2 3 4
f(x): 1.0 1.5 2.2 3.1 4.6
Evaluate Δ3 f(2).
5. Prove that:
(i) ∇ = ΔE–1 = E–1Δ = 1 – E–1 (ii) E1/2 = μ +
1
2
δ
(iii) δ = ΔE–1/2 = ∇E1/2 (iv) δ(E1/2 + E–1/2) = ΔE–1 + Δ
(v) Δ∇ = ∇Δ = δ2 (vi) δ = Δ(1 + Δ)–1/2 = ∇(1 – ∇)–1/2
(vii) E = (1 – Δ)–1.
INTERPOLATION 225
6. ux is a function of x for which fifth differences are constant and
u1 + u7 = –786, u2 + u6 = 686, u3 + u5 = 1088. Find u4.
7. Prove that:
(i) u4 = u3 + Δu2 + Δ2u1 + Δ3u1 (ii) u4 = u0 + 4Δu0 + 6 Δ2u–1 + 10 Δ3u–1.
8. Prove that:
Δ sin–1 x = sin–1 [(x + 1) 1 2
− x – x 1 1 2
− +
( )
x ].
9. Evaluate:
(i) (E–1 Δ) x3 (ii)
Δ2
3
E
F
HG
I
KJx ; h = 1.
10. Evaluate:
(i) Δ
e
e e
x
x x
+
F
HG
I
KJ
− (ii) Δ cos ax
the interval of difference being h.
4.8 FACTORIAL NOTATION
A product of the form x(x – 1)(x – 2) ...... (x – r + 1) is denoted by [x]r and is called
a factorial.
Particularly, [x] = x; [x]2 = x(x – 1); [x]3 = x (x – 1)(x – 2), etc.
In case the interval of difference is h, then
[x]n = x(x – h) (x – 2h) ...... (x – n − 1 h)
Factorial notation helps in finding the successive differences of a polynomial
directly by the simple rule of differentiation.
4.9 TO SHOW THAT (i) Δn[x]n = n ! (ii) Δn+1 [x]n = 0
Δ[x]n = [(x + h)]n – [x]n
= (x + h)(x + h – h) (x + h – 2h) ...... (x + h – n − 1 h)
– x(x – h) (x – 2h) ...... (x – n − 1 h)
= x(x – h) ...... (x – n − 2 h) [x + h – (x – nh + h)] = nh [x]n–1
226 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Similarly, Δ2[x]n = Δ[nh [x]n–1] = nh Δ[x]n–1 = n(n – 1) h2 [x]n–2

Δn[x]n = n(n – 1) ..... 2 . 1 . hn–1 (x + h – x) = n ! hn
Also, Δn + 1[x]n = n ! hn – n ! hn = 0
when h = 1, Δ[x]n = n[x]n–1 and Δn[x]n = n !
Hence the result of difference [x]r is analogous to that of difference xr when
h = 1.
4.10 RECIPROCAL FACTORIAL
x(–n) =
1
( )( )
x n n
+
, the interval of difference being unity.
By definition of x(n), we have
x(n) = (x – n − 1 h) x(n–1) (11)
when the interval of difference is h.
∴ When n = 0, we have x(0) = (x + h) x(– 1) (12)
Since, Δx(n) = nhx(n–1) (13)
when n = 1, Δx(1) = hx(0).
⇒ Δx = h x(0) ⇒ h = hx(0) ⇒ x(0) = 1
From (12), x(–1) =
1
( )
x h
+
(14)
when n = – 1, from (11),
x(–1) = (x + 2h) x(–2)
⇒
1
x h
+
= (x + 2h) x(–2) ⇒ x(–2) =
1
2
( )( )
x h x h
+ +
In general, x(–n) =
1
2
( )( ) ...... ( )
x h x h x nh
+ + +
(15)
x(–n) =
1
( )( )
x nh n
+
Here x(–n) is called the reciprocal factorial where n is a (+)ve integer.
Particular case. When h = 1, x(–n) =
1
( )( )
x n n
+
.
INTERPOLATION 227
4.11 MISSING TERM TECHNIQUE
Suppose n values out of (n + 1) values of y = f(x) are given, the values of x
being equidistant.
Let the unknown value be N. We construct the difference table.
Since only n values of y are known, we can assume y = f(x) to be a polynomial
of degree (n – 1) in x.
Equating to zero the nth difference, we can get the value of N.
EXAMPLES
Example 1. Express y = 2x3 – 3x2 + 3x – 10 in factorial notation and hence show
that Δ3y = 12.
Sol. Let y = A[x]3 + B[x]2 + c[x] + D
Using the method of synthetic division, we divide by x, x – 1, x – 2 etc.
successively, then
1 2 – 3 3 – 10 = D
2 – 1
2 2 – 1 2 = C
4
3 2 3 = B
2 = A
Hence, y = 2[x]3 + 3[x]2 + 2[x] – 10
∴ Δy = 6[x]2 + 6[x] + 2
Δ2y = 12[x] + 6
Δ3y = 12
which shows that the third differences of y are constant.
Example 2. Express f(x) = x4 – 12x3 + 24x2 – 30x + 9 and its successive differences
in factorial notation. Hence show that Δ5f(x) = 0.
Sol. Let
f(x) = A[x]4 + B[x]3 + C[x]2 + D[x] + E
Using the method of synthetic division, we divide by x, x – 1, x – 2, x – 3, etc.
successively, then
228 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
1 1 – 12 24 – 30 9 = E
1 – 11 13
2 1 – 11 13 – 17 = D
2 – 18
3 1 – 9 – 5 = C
3
4 1 – 6 = B
1 = A
Hence, f(x) = [x]4 – 6[x]3 – 5[x]2 – 17[x] + 9
∴ Δf(x) = 4[x]3 – 18[x]2 – 10[x] – 17
Δ2f(x) = 12[x]2 – 36[x] – 10
Δ3f(x) = 24[x] – 36
Δ4f(x) = 24
and Δ5f(x) = 0.
Example 3. Obtain the function whose first difference is 9x2 + 11x + 5.
Sol. Let f(x) be the required function so that
Δf(x) = 9x2 + 11x + 5
Let 9x2 + 11x + 5 = 9[x]2 + A[x] + B = 9x(x – 1) + Ax + B
Putting x = 0, B = 5
x = 1, A = 20
∴ Δf(x) = 9[x]2 + 20[x] + 5
Integrating, we get
f(x) = 9
[ ]
x 3
3
+ 20
[ ]
x 2
2
+ 5[x] + c
= 3x(x – 1) (x – 2) + 10x(x – 1) + 5x + c = 3x3 + x2 + x + c
where c is the constant of integration.
Example 4. Find the missing values in the table:
x: 45 50 55 60 65
y: 3 – 2 – – 2.4.
INTERPOLATION 229
Sol. The difference table is as follows:
x y Δy Δ2y Δ3y
45 3
y1 – 3
50 y1 5 – 2y1
2 – y1 3 y1 + y3 – 9
55 2 y1 + y3 – 4
y3 – 2 3.6 – y1 – 3y3
60 y3 – 0.4 – 2y3
– 2.4 – y3
65 – 2.4
As only three entries y0, y2, y4 are given, the function y can be represented
by a second degree polynomial.
∴ Δ3y0 = 0 and Δ3y1 = 0
⇒ 3y1 + y3 = 9 and y1 + 3y3 = 3.6
Solving these, we get
y1 = 2.925, y2 = 0.225.
Example 5. Express f(x) =
x 1
(x 1)(x 3)
−
+ +
in terms of negative factorial
polynomials.
Sol. f(x) =
x
x x
x x
x x x
−
+ +
=
− +
+ + +
1
1 3
1 2
1 2 3
( )( )
( )( )
( )( )( )
=
1
1
4
1 2
4
1 2 3
x x x x x x
+
−
+ +
+
+ + +
( )( ) ( )( )( )
= x(–1) – 4x(–2) + 4x(–3).
Example 6. Find the relation between α, β, and γ in order that α + βx + γx2 may
be expressible in one term in the factorial notation.
Sol. Let f(x) = α + βx + γx2 = (a + bx)(2)
where a and b are certain unknown constants.
Now, (a + bx)(2) = (a + bx) [a + b(x – 1)]
= (a + bx) (a – b + bx) = (a + bx)2 – ab – b2x
= (a2 – ab) + (2ab – b2)x + b2x2 = α + βx + γx2
230 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Comparing the coefficients of various powers of x, we get
α = a2 – ab, β = 2ab – b2, γ = b2
Eliminating a and b from the above equations,
we get γ2 + 4αγ = β2
which is the required relation.
Example 7. Given, log 100 = 2, log 101 = 2.0043, log 103 = 2.0128, log 104 =
2.0170. Find log 102.
Sol. Since four values are given, Δ4f(x) = 0.
Let the missing value be y2.
x y Δy Δ2y Δ3y Δ4y
100 2
.0043
101 2.0043 y2 – 2.0086
y2 – 2.0043 6.0257 – 3y2
102 y2 4.0171 – 2y2 6y2 – 12.0514
2.0128 – y2 3y2 – 6.0257
103 2.0128 y2 – 2.0086
.0042
104 2.0170
Since Δ4y = 0
∴ 6y2 – 12.0514 = 0 ⇒ y2 = 2.0086.
Example 8. Estimate the missing term in the following table:
x: 0 1 2 3 4
y = f(x): 1 3 9 ? 81.
Sol. We are given 4 values
∴ Δ4f(x) = 0 ∀ x ⇒ (E – 1)4 f(x) = 0 ∀ x
⇒ (E4 – 4E3 + 6E2 – 4E + 1) f(x) = 0 ∀ x
⇒ f(x + 4) – 4f(x + 3) + 6f(x + 2) – 4f(x + 1) + f(x) = 0 ∀ x
where the interval of difference is 1.
Now given x = 0, we obtain
f(4) – 4f(3) + 6f(2) – 4f(1) + f(0) = 0
INTERPOLATION 231
⇒ 81 – 4f(3) + 54 – 12 + 1 = 0 (From table)
⇒ 4f(3) = 124 ⇒ f(3) = 31.
Example 9. A second degree polynomial passes through (0, 1), (1, 3), (2, 7),
(3, 13). Find the polynomial.
Sol. Let f(x) = Ax2 + Bx + C
The difference table is:
x f(x) Δf(x) Δ2f(x)
0 1
2
1 3 2
4
2 7 2
6
3 13
Δf(x) = A Δx2 + BΔx + ΔC
= A {(x + 1)2 – x2} + B(x + 1 – x) + 0 = A(2x + 1) + B
Put x = 0,
Δf(0) = A + B ⇒ A + B = 2
Also, Δ2f(x) = 2A ⇒ Δ2f(0) = 2 = 2A ⇒ A = 1
Also, B = 1
∴ Polynomial is f(x) = x2 + x + 1.
Example 10. Estimate the production for 1964 and 1966 from the following
data:
Year: 1961 1962 1963 1964 1965 1966 1967
Production: 200 220 260 — 350 — 430
Sol. Since five figures are known, assume all the fifth order differences as
zero. Since two figures are unknown, we need two equations to determine them.
Hence Δ5y0 = 0 and Δ5y1 = 0
⇒ (E – 1)5y0 = 0 and (E – 1)5y1 = 0
⇒ y5 – 5y4 + 10y3 – 10y2 + 5y1 – y0 = 0
and y6 – 5y5 + 10y4 – 10y3 + 5y2 – y1 = 0
232 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Substituting the known values, we get
y5 – 1750 + 10y3 – 2600 + 1100 – 200 = 0
and 430 – 5y5 + 3500 – 10y3 + 1300 – 220 = 0
⇒ y5 + 10y3 = 3450 (16)
and – 5y5 – 10y3 = – 5010 (17)
Adding (16) and (17), we get
– 4y5 = – 1560
⇒ y5 = 390
From (16), 390 + 10y3 = 3450
⇒ 10y3 = 3060
⇒ y3 = 306
Hence, production for year 1964 = 306
and production for year 1966 = 390.
Example 11. Find the missing figures in the following table:
x: 2 2.1 2.2 2.3 2.4 2.5 2.6
y: 0.135 — 0.111 0.100 — 0.082 0.074.
Sol. Here five values are given.
∴ It is assumed that fifth differences are zero and hence both Δ5 y2.0 and
Δ5 y2.1 are zero.
Δ5 y2.0 = (E – 1)5 y2.0
= (E5 – 5E4 + 10E3 – 10E2 + 5E – 1)y2.0
= y2.5 – 5y2.4 + 10y2.3 – 10y2.2 + 5y2.1 – y2.0 |∵ h = 0.1
= .082 – 5y2.4 + 1 – 1.11 + 5y2.1 – .135
= – 5y2.4 + 5y2.1 – .163
Since Δ5 y2.0 = 0
∴ – 5y2.4 + 5y2.1 – .163 = 0 (18)
Further,
Δ5 y2.1 = (E – 1)5 y2.1
= (E5 – 5E4 + 10E3 – 10E2 + 5E – 1)y2.1
= y2.6 – 5y2.5 + 10y2.4 – 10y2.3 + 5y2.2. – y2.1
= .074 – (5 × .082) + 10y2.4 – 1 + .555 – y2.1
INTERPOLATION 233
= .074 – .41 + 10y2.4 – 1 + .555 – y2.1
= 10y2.4 – y2.1 – .781
Since Δ5 y2.1 = 0
∴ 10y2.4 – y2.1 – .781 = 0 (19)
Solving (18) and (19), we get
y2.1 = .123 and y2.4 = .0904.
Example 12. Find the missing value of the following data:
x: 1 2 3 4 5
f(x): 7 × 13 21 37.
Sol. Since four values are known, assume all the fourth order differences are
zero.
Since one value is unknown
we assume Δ4y1 = 0
⇒ (E – 1)4 y1 = 0
⇒ (E4 – 4E3 + 6E2 – 4E + 1)y1 = 0
⇒ y5 – 4y4 + 6y3 – 4y2 + y1 = 0 | ∵ h = 1
⇒ 37 – 4(21) + 6(13) – 4y2 + 7 = 0
⇒ 38 – 4y2 = 0
⇒ y2 = 9.5
Hence the required missing value is 9.5.
ASSIGNMENT 4.2
1. Estimate the missing term in the following:
x: 1 2 3 4 5 6 7
y: 2 4 8 — 32 64 128
Explain why the result differs from 16?
2. Estimate the production of cotton in the year 1935 from the data given below:
Year x: 1931 1932 1933 1934 1935 1936 1937
Production f(x): 17.1 13 14 9.6 — 12.4 18.2
(in millions)
234 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3. From the following data, find the value of U47:
U46 = 0.2884, U48 = 0.5356, U49 = 0.6513, U50 = 0.7620.
[Hint: Δ4 Ux = 0 ⇒ (E – 1)4 Ux = 0.]
4. Find by constructing the difference table, the tenth term of the series
3, 14, 39, 84, 155, 258, ......
[Hint: f(10) = E9 f(1) = (1 + Δ)9 f(1)]
5. Find the missing terms in the following table:
x: 1 2 3 4 5 6 7 8
f(x): 1 8 ? 64 ? 216 343 512
6. Represent the following polynomials:
(i) 11x4 + 5x3 + x – 15 (ii) 2x3 – 3x2 + 3x + 10
and its successive differences in factorial notation.
4.12 METHOD OF SEPARATION OF SYMBOLS
The relationship E = 1 + Δ can be used to prove a number of useful identities.
The method is known as separation of symbols.
4.13 DETECTION OF ERRORS BY USE OF DIFFERENCE TABLES
Difference tables can be used to check errors in tabular values. Let f(x1), f(x2),
......, f(xn) be the true values of f(x) at x = x1, x2, ......, xn. If f(x) at x = xi is
incorrect, we have to determine the error in such cases and correct the functional
value.
In particular, let the functional value at x = x5 be f(x5) + e and let other true
functional values f(x1), f(x2), ......, f(x4), f(x6) , ......, f(x9) be known.
INTERPOLATION 235
x f(x) Δf(x) Δ2f(x) Δ3f(x) Δ4f(x)
x1 f(x1)
Δf(x1)
x2 f(x2) Δ2f(x1)
Δf(x2) Δ3f(x1)
x3 f(x3) Δ2f(x2) Δ4f(x1) + e
Δf(x3) Δ3f(x2) + e
x4 f(x4) Δ2f(x3) + e Δ4f(x2) – 4e
Δ f(x4) + e Δ3 f(x3) – 3e
x5 f x
( )
5 Δ2 f(x4) – 2e Δ4f(x3) + 6e
Δ f(x5) – e Δ3 f(x4) + 3e
x6 f(x6) Δ2f(x5) + e Δ4f(x4) – 4e
Δ f(x6) Δ3f(x5) – e
x7 f(x7) Δ2f(x6) Δ4 f(x5) + e
Δ f(x7) Δ3f(x6)
x8 f(x8) Δ2f(x7)
Δ f(x8)
x9 f(x9)
From the table, we observe that,
(i) Error spreads in triangular form.
(ii) Coefficient of e’s are binomial coefficient with alternate signs + , –, .......
(iii) Algebraic sum of errors in each column is 0.
(iv) In even differences columns, the maximum error occurs in a horizontal
line in which incorrect y lies.
(v) In odd differences columns, the incorrect value of y lies between two middle
terms.
(vi) If nth differences are constant, (n + 1)th differences vanish. The sum of all
the values in (n + 1)th differences column is zero or the sum is very small as
compared to the functional values
These observations help us in finding out the error, and hence the required
correct value of y can be found.
EXAMPLES
Example 1. Find the error and correct the wrong figure in the following
functional values:
2, 5, 10, 18, 26, 37, 50.
⎯⎯⎯⎯→
R
S
|
T
|
R
S
|
|
|
T
|
|
|
R
S
|
|
|
|
T
|
|
|
|
R
S
|
|
|
|
|
|
T
|
|
|
|
|
|
⎯⎯⎯⎯→
236 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol.
x y Δy Δ2y Δ3y
1 2
3
2 5 2
5 1
3 10 3
8 – 3
4 18 ←⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 0 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
8 3
5 26 3
11 – 1
6 37 2
13
7 50
Sum of all the third differences is zero.
Adjacent values – 3, 3 are equal in magnitude. The horizontal line between
– 3 and 3 points out the incorrect functional value 18.
The coefficient of the first middle term on expansion of (1– p)3 = – 3
⇒ – 3e = – 3 ⇒ e = 1
∴ The correct functional value = 18 – 1 = 17.
Example 2. Locate the error in the following entries and correct it:
1.203, 1.424, 1.681, 1.992, 2.379, 2.848, 3.429, and 4.136.
Sol. Difference table is as follows:
103y 103Δy 103Δ2y 103Δ3y 103Δ4y
1203
221
1424 36
257 18
1681 54 4
311 22
1992 76 – 16
387 6
2379←⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 82 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 24
469 30
2848 112 – 16
581 14
3429 126
707
4136
INTERPOLATION 237
The sum of all values in the column of fourth difference is – .004,
which is very small as compared to the sum of values in other columns.
∴ Δ4y = 0
The errors in this column are e, – 4e, 6e, – 4e, and e.
The term of maximum value = 24 ⇒ 6e = 24 ⇒ e = 4
The error lies in 2379.
Hence, the required correct entry = 2379 – 4 = 2375
Hence, the correct value = 2.375.
Example 3. Using the method of separation of symbols, show that
u0 – u1 + u2 – u3 + ... =
1
2
u
1
4
u
1
8
0 0
− +
Δ Δ2u0 – ...... .
Sol. R.H.S. =
1
2
1
1
2
1
2
1
2
2 3
− +
F
HG I
KJ −
F
HG I
KJ +
L
N
MM
O
Q
PP
Δ Δ Δ ...... u0
=
1
2
1
1
1
2
1
2
1
1
2
0
1
.
+
F
HG I
KJ
= +
F
HG I
KJ
−
Δ
Δ
u u0 = (2 + Δ)–1 u0 = (1 + E)–1 u0
= (1 – E + E2 – E3 + ...) u0 = u0 – u1 + u2 – u3 + ...... = L.H.S.
Example 4. Using the method of separation of symbols, show that:
Δn ux–n = ux – nux–1 +
n(n 1)
2
−
ux–2 + ...... + (– 1)n ux–n.
Sol. R.H.S. = ux – nE–1 ux +
n n
( )
− 1
2
E–2 ux + ...... + (– 1)n E–n ux
= 1
1
2
1
1 2
− +
−
+ + −
L
NM O
QP
− − −
n
n n n n
E E E
( )
...... ( ) ux
= (1 – E–1)n ux
= 1
1
−
F
HG I
KJ
E
n
ux
=
E 1
E
−
F
HG I
KJ
n
ux =
Δn
n
E
ux
= Δn E–n ux
= Δn ux–n
= L.H.S.
238 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 5. Show that:
ex u x u
x
2 !
u .......
0 0
2
2
0
+ + +
F
HG
I
KJ
Δ Δ = u0 + u1x + u2
x
2 !
2
+ ...... .
Sol. L.H.S. = ex 1
2
2 2
+ + +
F
HG
I
KJ
x
x
Δ
Δ
!
...... u0 = ex . exΔ u0 = ex(1+Δ) u0 = exE u0
= 1
2
2 2
+ + +
F
HG
I
KJ
x
x
E
E
!
...... u0 = u xu
x
u .......
0 1
2
2
2
+ + +
F
HG
I
KJ
!
= R.H.S.
Example 6. Prove the following identity:
u1x + u2x2 + u3x3 + ...... =
x
1 x
−
u1 +
x
(1 x)
2
2
−
Δu1 + .....
Sol. L.H.S. = xu1 + x2 E u1 + x3 E2u1 + ...... = x (1 + xE + x2E2 + ......) u1
= x .
1
1
( )
− xE
u1 = x .
1
1 1
[ ( )]
− +
x Δ
u1
= x
1
1 − −
L
NM O
QP
x x Δ
u1 =
x
x
1−
1
1
1
−
−
L
N
MM
O
Q
PP
x
x
Δ
u1
=
x
x
x
x
1
1
1
1
−
−
−
L
NM O
QP
−
Δ
(u1) =
x
x
x
x
x
x
1
1
1 1
2 2
2
−
+
−
+
−
+
L
NM O
QP
Δ Δ
( )
...... u1
=
x
x
1 −
u1 +
x
x
2
2
1
( )
−
Δu1 +
x
x
3
3
1
( )
−
Δ2u1 + ...... = R.H.S.
Example 7. Prove that: ux = ux–1 + Δux–2 + Δ2ux–3 + ...... + Δn–1 ux–n + Δnux–n
Hence, or otherwise, prove that:
u3 = u2 + Δu1 + Δ2u0 + Δ3u0.
Sol. ux – Δn ux–n = (1 – Δn E–n)ux
= 1 −
F
HG I
KJ
L
N
MM
O
Q
PP
Δ
E
n
ux =
1
En (En – Δn) ux =
1
E
E
E
n
n n
−
−
F
HG
I
KJ
Δ
Δ
ux
| ∵ 1 + Δ = E
=
1
En [En–1 + ΔEn–2 + Δ2En–3 + ...... + Δn–1] ux
= (E–1 + ΔE–2 + Δ2E–3 + ...... + Δn–1 E–n) ux
INTERPOLATION 239
= ux–1 + Δux–2 + Δ2ux–3 + ...... + Δn–1 ux–n
To prove the second result, put x = 3 and n = 3.
Example 8. Prove that:
Δxn –
1
2
Δ2xn +
1.3
2.4
Δ3xn –
1 . 3 . 5
2 . 4 .6
Δ4xn + ...... n terms
= x
1
2
n
+
F
HG I
KJ – x
1
2
n
−
F
HG I
KJ
Sol. L.H.S. = Δ 1
1
2
1
2
3
2
1 2
2
− +
−
F
HG I
KJ −
F
HG I
KJ
+ ∞
L
N
MMMM
O
Q
PPPP
Δ Δ
.
. ...... xn
= Δ (1 + Δ)–1/2 xn = Δ E–1/2 xn = Δ x
n
−
F
HG I
KJ
1
2
= x
n
+ −
F
HG I
KJ
1
1
2
– x
n
−
F
HG I
KJ
1
2
= x
n
+
F
HG I
KJ
1
2
– x
n
−
F
HG I
KJ
1
2
= R.H.S.
Example 9. Prove that:
ux –
1
8
Δ2ux–1 +
1.3
8.16
Δ4ux–2 –
1 . 3 . 5
8 .16 . 24
Δ6 ux–3 + ......
= u
x
1
2
+
–
1
2
Δu
x
1
2
+
+
1
4
Δ2u
x
1
2
+
–
1
8
Δ3u
x
1
2
+
+ ....
Sol. L.H.S. = ux –
1
8
Δ2 E–1 ux +
1.3
8.16
Δ4 E–2ux –
1 3 5
8 16 24
. .
. .
Δ6 E–3 ux + ......
= ux –
1
2 4
2
Δ
E
F
HG
I
KJ ux +
−
F
HG I
KJ − −
F
HG I
KJ F
HG
I
KJ
1
2
1
2
1
1 2 4
2 2
.
Δ
E
ux
+
−
F
HG I
KJ − −
F
HG I
KJ − −
F
HG I
KJ F
HG
I
KJ
1
2
1
2
1
1
2
2
1 2 3 4
2 3
. .
Δ
E
ux + ......
= 1
1
2 4
1
2
1
2
1
2 4
2 2 2
+ −
F
HG I
KJ F
HG
I
KJ +
−
F
HG I
KJ − −
F
HG I
KJ F
HG
I
KJ +
L
N
MMMM
O
Q
PPPP
Δ Δ
E E
!
...... ux
240 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 1
4
2 1/2
+
F
HG
I
KJ
−
Δ
E
ux =
4
4
2 1/2
E
E
+
F
HG
I
KJ
−
Δ
ux
=
4 1
4
2 1/2
( )
+ +
L
NM O
QP
−
Δ Δ
E
ux =
( )
2
4
2 1/2
+
L
NM O
QP
−
Δ
E
ux
=
4
1/2
E
(2 + )2
Δ
L
NM O
QP ux = 2 E1/2
1
2 + Δ
F
HG I
KJ ux = E1/2 1
1
+
F
HG I
KJ
−
Δ
2
ux
= E1/2 1
2
2
2
− + −
F
HG
I
KJ
Δ Δ
2
...... ux
= u
x +
1
2
–
1
2
Δu
x +
1
2
+
1
4
Δ2u
x +
1
2
– ...... = R.H.S.
Example 10. Use the method of separation of symbols to prove the
following identities:
(i) ux + xC1 Δ2ux–1 + xC2Δ4ux–2 + ...... = u0 + xC1 Δu1 + xC2Δ2u2 + ......
(ii) ux+n = un + xC1 Δun–1 + x+1C2 Δ2un–2 + x+2C3 Δ3un–3 + ......
(iii) u0 + u1 + u2 + ....... + un = n+1C1 u0 + n+1C2 Δu0 + n+1C3 Δ2u0 + ...... + Δnu0.
Sol. (i) L.H.S. = (1 + xC1 Δ2E–1 + xC2 Δ4 E–2 + ......) ux
= (1 + Δ2E–1)x ux =
E
E
+
F
HG
I
KJ
Δ2 x
ux =
E E
E
2
− +
F
HG
I
KJ
1
x
ux
=
1
Ex [1 + E (E – 1)]x ux = E–x (1 + ΔE)x ux = (1 + ΔE)x u0
= (1 + xC1 ΔE + xC2 Δ2E2 + .....) u0
= u0 + xC1 Δu1 + xC2 Δ2u2 + ...... = R.H.S.
(ii) R.H.S. = un + xC1 ΔE–1 un + x+1C2 Δ2E–2 un + x+2C3 Δ3E–3un + ......
= (1 + xC1 ΔE–1 + x+1C2 Δ2E–2 + ......) un = (1 – ΔE–1)–x un
= 1 −
F
HG I
KJ
−
Δ
E
x
un =
E
E
−
F
HG I
KJ
−
Δ
x
un
=
1
E
F
HG I
KJ
−x
un = Exun = un+x = L.H.S.
INTERPOLATION 241
(iii) L.H.S. = u0 + Eu0 + E2 u0 + ..... + Enu0 = (1 + E + E2 + ....... + En) u0
=
E
E 1
n+
−
−
F
HG
I
KJ
1
1
u0 =
( )
1 1
1
+ −
L
NM O
QP
+
Δ
Δ
n
u0
=
1
Δ
[(1 + n+1C1 Δ + n+1C2 Δ2 + n+1C3 Δ3 + ...... + Δn+1) – 1] u0
= n+1C1 u0 + n+1C2 Δ u0 + n+1C3 Δ2 u0 + ...... + Δn u0 = R.H.S.
Example 11. Sum the following series
13 + 23 + 33 + ...... + n3
using the calculus of finite differences.
Sol. Let us denote 13, 23, 33, ...... by u0, u1, u2, ......, respectively, we get
S = u0 + u1 + u2 + ...... + un–1 = (1 + E + E2 + ...... + En–1) u0
=
E
E
n n
u
−
−
F
HG
I
KJ =
+ −
L
NM O
QP
1
1
1 1
0
( )
Δ
Δ
u0
=
1
1
1
2
1 2
3
1
2 3
0
Δ
Δ Δ Δ Δ
+ +
−
+
− −
+ + −
L
NM O
QP
n
n n n n n
u
n
( )
!
( )( )
!
......
= n +
n n
( )
!
− 1
2
Δ u0 +
n n n
( ) ( )
!
− −
1 2
3
Δ2 u0 + ......
Now, Δ u0 = u1 – u0 = 23 – 13 = 7
and Δ2 u0 = u2 – 2u1 + u0 = 33 – 2(2)3 + (1)3 = 12
Similarly, Δ3 u0 = u3 – 3u2 + 3u1 – u0 = (4)3 – 3(3)3 + 3(2)3 – (1)3 = 6
and Δ4u0 , Δ5u0 , ......are all zero as ur = r3 is a polynomial of the third degree.
∴ S = n +
n n
( )
!
− 1
2
(7) +
n n n
( ) ( )
− −
1 2
6
(12) +
n n n n
( ) ( ) ( )
− − −
1 2 3
24
(6)
=
n2
4
(n2 + 2n + 1) =
n n
( )
+
L
NM O
QP
1
2
2
.
Example 12. Sum to n terms, the series
1.2Δxn – 2.3Δ2xn + 3.4Δ3xn – 4.5Δ4xn + ...
Sol. Since Δn+m xn = 0 for m ≥ 1, the sum of the above series to n terms is the
same up to infinity.
Let, S = 1.2Δxn – 2.3Δ2xn + 3.4Δ3xn – ...
ΔS = 1.2Δ2xn – 2.3Δ3xn + 3.4Δ4xn – ...
242 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence, (Δ + 1)S = 1.2Δxn – 2.2Δ2xn + 2.3Δ3xn – 2.4Δ4xn + ...
= 2Δ(1 – 2Δ + 3Δ2 – ...)xn = 2Δ(1 + Δ)–2 xn
or S = 2Δ(1 + Δ)–3 xn = 2ΔE–3 xn = 2Δ(x – 3)n
= 2(E – 1)(x – 3)n = 2[E(x – 3)n – (x – 3)n]
= 2[(x – 2)n – (x – 3)n].
ASSIGNMENT 4.3
1. The values of a polynomial of degree 5 are tabulated below:
If f(3) is known to be in error, find its correct value.
x: 0 1 2 3 4 5 6
f(x): 1 2 33 254 1025 3126 7777.
2. If y = f(x) is a polynomial of degree 3 and the following table gives the values of x and y,
locate and correct the wrong values of y
x: 0 1 2 3 4 5 6
y: 4 10 30 75 160 294 490.
3. Prove the identities:
(i) ux – Δ2ux + Δ3ux – Δ5ux + Δ6ux – Δ8ux + ......
= ux – Δ2ux – 1 + Δ4 ux – 2 – Δ6 ux – 3 + Δ8 ux – 4 – ......
(ii) u u
x
x
x
x
2
0 0
2
1
2
1
4
1
2 4
=
∞
=
∞
∑ ∑
= + − + −
F
HG
I
KJ
Δ Δ
...... u0.
4. Prove that:
x2 +
1
2
(1 + x)2 +
1
22
(2 + x)2 +
1
23
(3 + x)2 + ...... = 2 (x2 + 2x + 3)
using the calculus of finite differences and taking the interval of difference unity.
[Hint: (1+ x)2 = Ex2, (2 + x)2 = E2x2 , (3 + x)2 = E3x3, ......]
5. If f(E) is a polynomial in E such that f(E) = a0En + a1 En – 1 + a2 En – 2 + ...... + an
Prove that f(E) ex = ex f(e), taking the interval of differencing unity.
We now proceed to study the use of finite difference calculus for the purpose of interpo-
lation. This we shall do in three cases as follows:
(i) The value of the argument in the given data varies by an equal interval. The tech-
nique is called an interpolation with equal intervals.
(ii) The values of argument are not at equal intervals. This is known as interpolation
with unequal intervals.
(iii) The technique of central differences.
INTERPOLATION 243
4.14 NEWTON’S FORMULAE FOR INTERPOLATION
Newton’s formula is used for constructing the interpolation polynomial. It makes
use of divided differences. This result was first discovered by the Scottish
mathematician James Gregory (1638–1675) a contemporary of Newton.
Gregory and Newton did extensive work on methods of interpolation but now
the formula is referred to as Newton’s interpolation formula. Newton has
derived general forward and backward difference interpolation formulae.
4.15 NEWTON’S GREGORY FORWARD INTERPOLATION FORMULA
Let y = f(x) be a function of x which assumes the values f(a), f(a + h), f(a + 2h),
......., f(a + nh) for (n + 1) equidistant values a, a + h, a + 2h, ......, a + nh of the
independent variable x. Let f(x) be a polynomial of nth degree.
Let f(x) = A0 + A1 (x – a) + A2 (x – a) (x – a – h)
+ A3 (x – a) (x – a – h) (x – a – 2h ) + .......
+ An (x – a) ...... (x – a – n − 1h) (20)
where A0, A1, A2 , ......., An are to be determined.
Put x = a, a + h, a + 2h, ......., a + nh in (20) successively.
For x = a, f(a) = A0 (21)
For x = a + h, f(a + h) = A0 + A1h
⇒ f(a + h) = f(a) + A1h | By (21)
⇒ A1 =
Δf a
h
( )
(22)
For x = a + 2h,
f(a + 2h) = A0 + A1 (2h) + A2 (2h) h
= f(a) + 2h
Δf a
h
( )
R
S
T
U
V
W + 2h2 A2
⇒ 2h2A2 = f(a + 2h) – 2f(a + h) + f(a) = Δ2f(a)
⇒ A2 =
Δ2
2
2
f a
h
( )
!
Similarly, A3 =
Δ3
3
3
f a
h
( )
!
and so on.
Thus, An =
Δn
n
f a
n h
( )
!
.
244 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
From (20), f(x) = f(a) + (x – a)
Δ f a
h
( )
+ (x – a) (x – a – h)
Δ2
2
2
f a
h
( )
!
+ .......
+ (x – a) ...... (x – a – n − 1 h)
Δn
n
f a
n h
( )
!
Put x = a + hu ⇒ u =
x a
h
−
, we have
f(a + hu) = f(a) + hu
Δ f a
h
( )
+
( ) ( )
!
hu hu h
h
−
2 2 Δ2 f (a) +......
+
( ) ( ) ( ) ....... ( )
!
hu hu h hu h hu n h
n hn
− − − −
2 1
Δn f(a)
⇒ f(a + hu) = f(a) + uΔ f(a) +
u u
( )
!
− 1
2
Δ2 f(a) + ...
+
u u u u n
n
( )( ) ... ( )
!
− − − +
1 2 1
Δn f(a)
which is the required formula.
This formula is particularly useful for interpolating the values of f(x) near
the beginning of the set of values given. h is called the interval of difference,
while Δ is forward difference operator.
4.15.1 Algorithm for Newton’s Forward Difference Formula
Step 01. Start of the program
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h=ax[1] – ax[0]
Step 06. for i=0; in-1; i++
Step 07. diff[i] [1]=ay[i + 1] – ay[i]
Step 08. End Loop i
Step 09. for j=2; j=4; j++
Step 10. for i = 0; i n – j; i++
Step 11. diff[i][j]=diff [i + 1] [j – 1]-diff [i][j – 1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until ax[i]x
Step 16. i=i + 1
Step 17. i=i – 1;
INTERPOLATION 245
Step 18. p=(x – ax [i])/h
Step 19. y1=p∗diff[i – 1][1]
Step 20. y2=p∗(p+1)∗diff [i – 1][2]/2
Step 21. y3=(p+1)∗p∗(p-1)∗diff[i –2 ][3]/6
Step 22. y4=(p+2)∗(p+1)∗p∗(p – 1)∗diff[i – 3][4]/24
Step 23. y=ay[i]+y1+y2+y3+y4
Step 24. Print output x, y
Step 25. End of program.
4.15.2 Flow-chart
246 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A
B
B
i = 0
i = i + 1
Is
ax[i]  x
No
Yes
i = i – 1
p = (x – ax[i])/h
y = p * diff[i – 1][1]
1
y = p * (p + 1) * diff[i – 1][2]/2
2
y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6
3
y = (p + 2) * (p + 1) * p * (p – 1) * diff[i – 3][4]/24
4
y = ay[i] + y + y + y + y
1 2 3 4
Print output x, y
STOP
ax is an array containing values of x,
ay is an array containing values of y,
Diff. is a two dimensional array containing difference table,
h is spacing between values of x
NOTE
INTERPOLATION 247
* ***********************************************************************************
4.15.3 Program to Implement Newton’s Forward Method of Interpolation
*********************************************************************************** */
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... MAIN EXECUTION THREAD
void main()
{
//... Variable declaration Field
//... Integer Type
int n; //... Number of terms
int i,j; //... Loop Variables
//...Floating Type
float ax[10]; //... array limit 9
float ay[10]; //... array limit 9
float x; //... User Querry
float y = 0; //... Initial value 0
float h; //... Calc. section
float p; //... Calc. section
float diff[20][20]; //... array limit 19,19
float y1,y2,y3,y4; //... Formulae variables
//... Invoke Function Clear Screen
clrscr();
//... Input Section
printf(n Enter the number of terms – );
scanf(%d,n);
//... Input Sequel for array X
248 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Printf (nn Enter the value in the form of x - );
//... Input Loop for X
for (i=0;in;i++)
{
printf(nn Enter the value of x%d - ,i+1);
scanf(%f,ax[i]);
}
//... Input Sequel for array Y
printf(nn Enter the value in the form of y – );
//... Input Loop for Y
for (i=0;in;i++)
{
printf (nn Enter the value of y%d – , i+1);
scanf (%f,ay [i]);
}
//... Inputting the required value quarry
printf(nEnter the value of x for);
printf(nwhich you want the value of y - );
scanf(%f,x);
//... Calculation and Processing Section
h=ax[1]-ax[0];
for(i=0;in-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
INTERPOLATION 249
i=0;
do {
i++;
}while(ax[i]x);
i--;
p=(x–ax[i])/h;
y1=p*diff[i-1][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=(p+1)*p*(p–1)*diff[i–2][3]/6;
y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;
//... Taking Sum
y=ay[i]+y1+y2+y3+y4;
//... Output Section
printf(nwhen x=%6.4f, y=%6.8f ,x,y);
//... Invoke User Watch Halt Function
Printf(nnn Press Enter to Exit);
getch();
}
//... Termination of Main Execution Thread
4.15.4 Output
Enter the number of terms – 7
Enter the value in the form of x -
Enter the value of x1 - 100
Enter the value of x2 - 150
Enter the value of x3 - 200
Enter the value of x4 - 250
Enter the value of x5 - 300
Enter the value of x6 - 350
Enter the value of x7 - 400
Enter the value in the form of y -
Enter the value of y1 - 10.63
Enter the value of y2 - 13.03
Enter the value of y3 - 15.04
250 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Enter the value of y4 - 16.81
Enter the value of y5 - 18.42
Enter the value of y6 - 19.9
Enter the value of y7 - 21.27
Enter the value of x for which you want the value of y-218
When X=218.0000, Y=15.69701481
Press Enter to Exit
EXAMPLES
Example 1. Find the value of sin 52° from the given table:
θ° 45° 50° 55° 60°
sin θ 0.7071 0.7660 0.8192 0.8660
Sol. a = 45°, h = 5, x = 52
∴ u =
x a
h
−
=
7
5
= 1.4
Difference table is:
Differences
x° 104y 104Δy 104 Δ2y 104 Δ3y
45° 7071
589
50° 7660 – 57
532 – 7
55° 8192 – 64
468
60° 8660
By forward difference formula,
f(a + hu) = f(a) + u Δ f(a) +
u u
f a
u u u
( )
!
( )
( )( )
!
−
+
− −
1
2
1 2
3
2
Δ Δ3 f(a)
⇒ 104 f(x) = 104 f(a) + 104 u Δ f(a) + 104
u u
( )
!
− 1
2
Δ2 f(a)
+ 104
u u u
( )( )
!
− −
1 2
3
Δ3 f(a)
INTERPOLATION 251
⇒ 104 f(52) = 104 f(45) + (1.4) 104 Δ f(45) +
(1.4)(1.4 1)
2!
−
104 Δ2 f(45)
+
(1.4)(1.4 1)(1.4 2)
3 !
− −
104 Δ3 f(45)
= 7071 + (1.4)(589) +
(1.4)(.4)
2
(1.4)(.4)( .6)
6
( )
− +
−
57 (– 7)
= 7880
∴ f(52) = .7880. Hence, sin 52° = 0.7880.
Example 2. The population of a town in the decimal census was as given below.
Estimate the population for the year 1895.
Year x: 1891 1901 1911 1921 1931
Population y: 46 66 81 93 101
(in thousands)
Sol. Here a = 1891, h = 10, a + hu = 1895
⇒ 1891 + 10 u = 1895 ⇒ u = 0.4
The difference table is as under:
x y Δy Δ2y Δ3y Δ4y
1891 46
20
1901 66 – 5
15 2
1911 81 – 3 – 3
12 – 1
1921 93 – 4
8
1931 101
Applying Newton’s forward difference formula,
y(1895) = y(1891) + u Δy(1891) +
u u
( )
!
− 1
2
Δ2y(1891)
+
u u u
( )( )
!
− −
1 2
3
Δ3y(1891)
+
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4y(1891)
252 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
⇒ y(1895) = 46 + (.4)(20) +
(.4)(.4 1)
2
−
(– 5)
+
(.4)(.4 1)(.4 2)
6
.4 .4 .4
− −
+
− −
( )
( )( )(. – )( )
2
1 4 2 3
24
(– 3)
⇒ y(1895) = 54.8528 thousands
Hence the population for the year 1895 is 54.8528 thousands
approximately.
Example 3. The values of f(x) for x = 0, 1, 2, ......, 6 are given by
x: 0 1 2 3 4 5 6
f(x): 2 4 10 16 20 24 38
Estimate the value of f(3.2) using only four of the given values. Choose the
four values that you think will give the best approximation.
Sol. Last four values of f(x) for x = 3, 4, 5, 6 are taken into consideration so that
3.2 occurs in the beginning of the table.
Here a = 3, h = 1, x = 3.2 ∴ a + h u = 3.2
i.e., 3 + 1 × u = 3.2 or u = 0.2
The difference table is:
x f(x) Δf(x) Δ2f(x) Δ3f(x)
3 16
4
4 20 0
4 10
5 24 10
14
6 38
Applying Newton’s forward difference formula,
f(3.2) = f(3) + u Δ f(3) +
u u
f
u u u
f
( )
!
( )
( )( )
!
( )
−
+
− −
1
2
3
1 2
3
3
2 3
Δ Δ
= 16 + (.2)(4) +
(.2)(.2 1)
2
(0)
(.2)(.2 1)(.2 2)
6
−
+
− −
(10) = 17.28.
Example 4. From the following table, find the value of e0.24
x: 0.1
0.2
0.3
INTERPOLATION 253
Sol. The difference table is:
x 105y 105Δy 105Δ2y 105 Δ3y 104Δ4y
0.1 110517
11623
0.2 122140 1223
12846 127
0.3 134986 1350 17
14196 144
0.4 149182 1494
15690
0.5 164872
Here h = 0.1. ∴ 0.24 = 0.1 + 0.1 × u or u = 1.4
Newton-Gregory forward formula is
y(.24) = y(.1) + u Δ y(.1) +
u u
y
u u u
( )
!
( )
( )( )
!
−
+
− −
1
2
1 2
3
2
Δ .1 Δ3y(.1)
+
u u u u
( )( )( )
4 !
− − −
1 2 3
Δ4 y(.1)
⇒ 105 y(.24) = 105 y(.1) + u 105 Δy(.1) +
u u
( )
2 !
− 1
105 Δ2y(.1)
+
u u u
( )( )
3 !
− −
1 2
105 Δ3y(.1) +
u u u u
( )( )( )
4 !
− − −
1 2 3
105 Δ4y(.1)
⇒ 105 y(.24) = 110517 + (1.4)(11623) +
(1.4)(1.4 1)
2
−
(1223)
+
(1.4)(1.4 1)(1.4 2)
3 !
1.4)(1.4 1.4 1.4
− −
+
− − −
( )
( )( )( )
!
127
1 2 3
4
(17)
= 127124.9088
∴ y(.24) = 1.271249088
Hence, e.24 = 1.271249088.
Example 5. From the following table of half-yearly premiums for policies
maturing at different ages, estimate the premium for policies maturing at age
of 46.
Age 45 50 55 60 65
Premium 114.84 96.16 83.32 74.48 68.48
(in dollars)
254 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. The difference table is:
Age Premium Δy Δ2y Δ3y Δ4y
(x) (in dollars)
(y)
45 114.84
– 18.68
50 96.16 5.84
– 12.84 – 1.84
55 83.32 4 .68
– 8.84 – 1.16
60 74.48 2.84
– 6
65 68.48
Here h = 5, a = 45, a + hu = 46
∴ 45 + 5u = 46 ⇒ u = .2
By Newton’s forward difference formula,
y46 = y45 + u Δy45 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
45
Δ Δ3y45
+
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4 y45
= 114.84 + (.2)(– 18.68) +
(.2)(.2 1)
2 !
−
(5.84)
+
(.2)(.2 1)(.2 2)
− −
3 !
(– 1.84) +
(.2)(.2 1)(.2 2)(.2 3)
− − −
4 !
(.68)
= 110.525632
Hence the premium for policies maturing at the age of 46 is $ 110.52.
Example 6. From the table, estimate the number of students who obtained scores
between 40 and 45.
Scores: 30—40 40—50 50—60 60—70 70—80
Number of students: 31 42 51 35 31.
INTERPOLATION 255
Sol. The difference table is:
Scores less than
(x) y Δy Δ2y Δ3y Δ4y
40 31
42
50 73 9
51 – 25
60 124 – 16 37
35 12
70 159 – 4
31
80 190
We shall find y45, number of students with scores less than 45.
a = 40, h = 10, a + hu = 45.
∴ 40 + 10u = 45 ⇒ u = .5
By Newton’s forward difference formula,
y(45) = y(40) + u Δ y(40) +
u u
( )
!
− 1
2
Δ2 y(40)
+
u u u
( )( )
!
− −
1 2
3
Δ3 y(40) +
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4 y(40)
= 31 + (.5)(42) +
(.5)(.5 1)
2
(.5)(.5 1)(.5 2)
6
−
+
− −
( )
9 (– 25)
+
(.5)(.5 1)(.5 2)(.5 3)
24
− − −
(37)
= 47.8672 ≈ 48
Hence, the number of students getting scores less than 45 = 48
By the number of students getting scores less than 40 = 31
Hence, the number of students getting scores between 40 and 45 = 48 – 31
= 17.
Example 7. Find the cubic polynomial which takes the following values:
x: 0 1 2 3
f(x): 1 2 1 10.
256 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Let us form the difference table:
x y Δy Δ2 y Δ3 y
0 1
1
1 2 – 2
– 1 12
2 1 10
9
3 10
Here, h = 1. Hence, using the formula,
x = a + hu
and choosing a = 0, we get x = u
∴ By Newton’s forward difference formula,
y = y0 + x Δy0 +
x x
y
x x x
y
( )
!
( ) ( )
!
−
+
− −
1
2
1 2
3
2
0
3
0
Δ Δ
= 1 + x(1) +
x x
( )
!
− 1
2
(– 2) +
x x x
( ) ( )
!
− −
1 2
3
(12)
= 2x3 – 7x2 + 6x + 1
Hence, the required cubic polynomial is
y = f(x) = 2x3 – 7x2 + 6x + 1.
Example 8. The following table gives the scores secured by100 students in
the Numerical Analysis subject:
Range of scores: 30—40 40—50 50—60 60—70 70—80
Number of students: 25 35 22 11 7
Use Newton’s forward difference interpolation formula to find.
(i) the number of students who got scores more than 55.
(ii) the number of students who secured scores in the range between 36 and 45.
Sol. The given table is re-arranged as follows:
Scores obtained Number of students
Less than 40 25
Less than 50 60
Less than 60 82
Less than 70 93
Less than 80 100
INTERPOLATION 257
(i) Here, a = 40, h = 10, a + hu = 55
∴ 40 + 10u = 55 ⇒ u = 1.5
First, we find the number of students who got scores less than 55.
The difference table follows:
Scores obtained Number of Δy Δ2y Δ3y Δ4y
less than students = y
40 25
35
50 60 – 13
22 2
60 82 – 11 5
11 7
70 93 – 4
7
80 100
Applying Newton’s forward difference formula,
y55 = y40 + u Δ y40 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
40
Δ Δ3 y40
+
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4 y40
= 25 + (1.5)(35) +
(1.5)(.5)
2 !
( 13)
(1.5)(.5)( .5)
3 !
− +
−
(2)
+
(1.5)(.5)( .5)( 1.5)
4 !
− −
(5)
= 71.6171875 ≈ 72
There are 72 students who got scores less than 55.
∴ Number of students who got scores more than 55 = 100 – 72 = 28
(ii) To calculate the number of students securing scores between 36 and 45,
take the difference of y45 and y36.
u =
x a
h
−
=
−
36 40
10
= – .4
Also, u =
45 40
10
−
= .5
258 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Newton’s forward difference formula:
y36 = y40 + u Δ y40 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
40
Δ Δ3 y40
+
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4 y40
= 25 + (– .4)(35) +
( )( )
!
( )
( )( )( )
!
− −
− +
− − −
.4 1.4 .4 1.4 2.4
2
13
3
(2)
+
( )( )( )( )
!
− − − −
.4 1.4 2.4 3.4
4
(5) = 7.864 ≈ 8
Also, y45 = y40 + u Δ y40 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
40
Δ Δ3 y40
+
u u u u
y
( ) ( ) ( )
!
− − −
1 2 3
4
4
40
Δ
= 25 + (.5)(35) +
(.5)( .5)
2
( 13)
(.5)( .5)( 1.5)
6
−
− +
− −
(2)
+
(.5)( .5)( 1.5)( 2.5)
24
− − −
(5)
= 44.0546 ≈ 44.
Hence, the number of students who secured scores between 36 and 45
is y45 – y36 = 44 – 8 = 36.
Example 9. The following are the numbers of deaths in four successive ten year
age groups. Find the number of deaths at 45—50 and 50—55.
Age group: 25—35 35—45 45—55 55—65
Deaths: 13229 18139 24225 31496.
Sol. Difference table of cumulative frequencies:
Age upto Number of deaths Δf(x) Δ2f(x) Δ3f(x)
x f(x)
35 13229
18139
45 31368 6086
24225 1185
55 55593 7271
31496
65 87089
INTERPOLATION 259
Here, h = 10, a = 35, a + hu = 50
∴ 35 + 10u = 50 ⇒ u = 1.5
By Newton’s forward difference formula,
y50 = y35 + u Δ y35 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
35
Δ Δ3 y35
= 13229 + (1.5)(18139) +
(1.5)(.5)
2
(1.5)(.5)(– .5)
6
( )
6086 + (1185)
= 42645.6875 ≈ 42646
∴ Deaths at ages beween 45 – 50 are 42646 – 31368 = 11278
and Deaths at ages between 50 – 55 are 55593 – 42646 = 12947.
Example 10. If p, q, r, s are the successive entries corresponding to equidistant
arguments in a table, show that when the third differences are taken into account,
the entry corresponding to the argument half way between the arguments at q
and r is A +
B
24
F
HG I
KJ, where A is the arithmetic mean of q and r and B is arithmetic
mean of 3q – 2p – s and 3r – 2s – p.
Sol. A =
q r
+
2
⇒ q + r = 2A
B =
( ) ( )
3 2 3 2
2
q p s r s p
− − + − −
=
3 3 3 3
2
q r p s
+ − −
=
3
2
3
2
( ) ( )
q r p s
+
−
+
Let the entries p, q, r, and s correspond to x = a, a + h, a + 2h, and a + 3h,
respectively. Then the value of the argument lying half way between a + h and
a + 2h will be a h
h
+ +
F
HG I
KJ
2
i.e., a
h
+
3
2
.
Hence a + mh = a h
+
3
2
⇒ m =
3
2
Let us now construct the difference table:
x f(x) Δf(x) Δ2f(x) Δ3f(x)
a p
q – p
a + h q r – 2q + p
r – q s – 3r + 3q – p
a + 2h r s – 2r + q
s – r
a + 3h s
260 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Using Newton’s Gregory Interpolation formula up to third difference
only and taking m = 3/2, we get
f a h
+
F
HG I
KJ
3
2
= f(a) +
3
2
3
2
3
2
1
2
3
2
3
2
1
3
2
2
6
2 3
Δ Δ Δ
f a f a f a
( ) ( ) ( )
+
−
F
HG I
KJ
+
−
F
HG I
KJ −
F
HG I
KJ
= p +
3
2
(q – p) +
3
8
(r – 2q + p) –
1
16
(s – 3r + 3q – p)
=
( )
16 24 24 6 12 6 3 3
16
p q p r q p s r q p
− − + − + − + − +
=
1
16
(– p + 9q + 9r – s) =
9
16
(q + r) –
p s
+
F
HG I
KJ
16
=
9
16
(2A) –
2
3
3A B
16
−
F
HG I
KJ
=
9
8
A –
1
8
A +
B
24
= A +
B
24
.
ASSIGNMENT 4.4
1. The following table gives the distance in nautical miles of the visible horizon for the
given heights in feet above the earth’s surface.
x: 100 150 200 250 300 350 400
y: 10.63 13.03 15.04 16.81 18.42 19.9 21.27
Use Newton’s forward formula to find y when x = 218 ft.
2. If lx represents the number of persons living at age x in a life table, find, as accurately as
the data will permit, lx for values of x = 35, 42 and 47. Given
l20 = 512, l30 = 390, l40 = 360, l50 = 243.
3. The values of f(x) for x = 0, 1, 2, ......, 6 are given by
x: 0 1 2 3 4 5 6
f(x): 1 3 11 31 69 131 223
Estimate the value of f(3.4), using only four of the given values.
4. Given that:
x: 1 2 3 4 5 6
y(x): 0 1 8 27 64 125
Find the value of f(2.5).
INTERPOLATION 261
5. Ordinates f(x) of a normal curve in terms of standard deviation x are given as
x: 1.00 1.02 1.04 1.06 1.08
f(x): 0.2420 0.2371 0.2323 0.2275 0.2227
Find the ordinate for standard deviation x = 1.025.
6. Using Newton’s formula for interpolation, estimate the population for the year 1905
from the table:
Year Population
1891 98,752
1901 132,285
1911 168,076
1921 195,690
1931 246,050
7. Find the number of students from the following data who secured scores not more than 45
Scores range: 30—40 40—50 50—60 60—70 70—80
Number of students: 35 48 70 40 22
8. Find the number of men getting wages between $ 10 and $ 15 from the following table:
Wages (in $): 0—10 10—20 20—30 30—40
Frequency: 9 30 35 42
9. Following are the scores obtained by 492 candidates in a certain examination
Scores Number of candidates
0—40 210
40—45 43
45—50 54
50—55 74
55—60 32
60—65 79
Find out the number of candidates
(a) who secured scores more than 48 but not more than 50;
(b) who secured scores less than 48 but not less than 45.
10. Use Newton’s forward difference formula to obtain the interpolating polynomial f(x),
satisfying the following data:
x: 1 2 3 4
f(x): 26 18 4 1
If another point x = 5, f(x) = 26 is added to the above data, will the interpolating polyno-
mial be the same as before or different. Explain why.
262 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
11. The table below gives value of tan x for .10 ≤ x ≤ .30.
x: .10 .15 .20 .25 .30
tan x: .1003 .1511 .2027 .2553 .3093
Evaluate tan 0.12 using Newton’s forward difference formula
12. (i) Estimate the value of f(22) from the following available data:
x: 20 25 30 35 40 45
f(x): 354 332 291 260 231 204
(ii) Find the cubic polynomial which takes the following values:
y(0) = 1, y(1) = 0, y(2) = 1 and y(3) = 10
Hence or otherwise obtain y(4).
(iii) Use Newton’s method to find a polynomial p(x) of lowest possible degree such that
p(n) = 2n for n = 0, 1, 2, 3, 4.
4.16 NEW TON’S GREGORY BACKWARD INTERPOLATION
FORMULA
Let y = f(x) be a function of x which assumes the values f(a), f(a + h),
f (a + 2h), ......, f(a + nh) for (n + 1) equidistant values a, a + h, a + 2h, ......, a + nh
of the independent variable x.
Let f(x) be a polynomial of the nth degree.
Let, f(x) = A0 + A1(x – a – nh) + A2 (x – a – nh) (x – a – n − 1 h) + ......
+ An (x – a – nh) (x – a – n − 1 h) ...... (x – a – h)
where A0, A1, A2, A3, ......, An are to be determined. (23)
Put x = a + nh, a + n − 1 h, ......, a in (23) respectively.
Put x = a + nh, then f (a + nh) = A0 (24)
Put x = a + (n – 1) h, then
f(a + n − 1 h) = A0 – h A1 = f(a + nh) – h A1 | By (24)
⇒ A1 =
∇ +
f a nh
h
( )
(25)
Put x = a + (n – 2)h, then
f (a + n − 2 h) = A0 – 2hA1 + (– 2h) (– h) A2
INTERPOLATION 263
⇒ 2 ! h2 A2 = f(a + n − 2 h) – f(a + nh) + 2∇f(a + nh)
= ∇2 f(a + nh)
A2 =
∇ +
2
2
2
f a nh
h
( )
!
(26)
Proceeding, we get
An =
∇ +
n
n
f a nh
n h
( )
!
(27)
Substituting the values in (24), we get
f(x) = f(a + nh) + (x – a – nh)
∇ +
f a nh
h
( )
+ ......
+ (x – a – nh) (x – a – n − 1 h)
..... (x – a – h)
∇ +
n
n
f a nh
n h
( )
!
(28)
Put x = a + nh + uh, then
x – a – nh = uh
and x – a – (n – 1)h = (u + 1)h

x – a – h = (u + n − 1) h
∴ (28) becomes,
f(x) = f(a + nh) + u ∇f(a + nh) +
u u
( )
!
+ 1
2
∇2 f(a + nh)
+ ...... + uh . (u + 1)h ..... (u + n − 1)(h)
∇ +
n
n
f a nh
n h
( )
!
or f(a + nh + uh) = f(a + nh) + u ∇f(a + nh) +
u u
( )
!
+ 1
2
∇2f(a + nh)
+ ...... +
u u u n
n
( ) ...... ( )
!
+ + −
1 1
∇n f(a + nh)
which is the required formula.
This formula is useful when the value of f(x) is required near the end of the
table.
264 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.16.1 Algorithm for Newton’s Backward Difference formula
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=0; in–1; i++
Step 07. diff[i][1]=ay[i+1]–ay[i]
Step 08. End Loop i
Step 09. for j = 2; j  = 4; j + +
Step 10. for i=0; in–j; i++
Step 11. diff[i][j]=diff[i+1][j–1]–diff [i][j–1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until (!ax[i]x)
Step 16. i=i+1
Step 17. x0=mx[i]
Step 18. sum=0
Step 19. y0=my[i]
Step 20. fun=1
Step 21. p=(x–x0)/h
Step 22. sum=y0
Step 23. for k=1; k=4; k++
Step 24. fun=(fun*(p–(k–1)))/k
Step 25. sum=sum+fun*diff[i][k]
Step 26. End loop k
Step 27. Print Output x,sum
Step 28. End of Program
INTERPOLATION 265
4.16.2 Flow-chart
START
Input number of terms n
Input array ax  ay
h = ax[1] – ax[0]
Start loop i = 0 to n – 1
Diff[i][1] = ay[i + 1] – ay[i]
End loop i
Start loop j = 2 to 4
Start loop i = 0 to n – j
Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1]
End loop i
End loop j
i = 0
i = i + 1
A
Is
! ax[i]  x
Yes
266 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A
x0 = mx[i]
Sum = 0
y0 = my[i]
Fun = 1
p = (x – x0)/n
Sum = y0
End loop k
Print Output , x, sum
‘‘ ’’
Start loop k = 1 to 4
fun = (fun * (p – (k – 1)))/k
Sum = sum + fun * diff[i][k]
STOP
* ***********************************************************************************
INTERPOLATION 267
4.16.3 Program to Implement Newton’s Backward Method of Interpolation
************************************************************************************/
//...HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... MAIN EXECUTION THREAD
void main()
{
//...Variable declaration Field
//...Integer Type
int n; //...Number of terms
int i,j,k; //...Loop Variables
//...Floating Type
float my[10]; //... array limit 9
float my[10]; //... array limit 9
float x; //... User Querry
float x0 = 0; //... Initial value 0
float y0; //... Calc. Section
float sum; //... Calc. Section
float h; //... Calc. Section
float fun; //... Calc. Section
float p; //... Calc. Section
float diff[20][20]; //... array limit 19,19
float y1, y2, y3, y4; //... Formulae variables
//...Invoke Function Clear Screen
clrscr();
//...Input Section
268 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(n Enter the number of terms - );
scanf(%d,n);
//...Input Sequel for array X
printf(nn Enter the value in the form of x - );
//...Input Loop for X
for (i=0;in;i++)
{
printf(nn Enter the value of x%d - ,i+1);
scanf (“%f”,mx[i]);
}
//...Input Sequel for array Y
printf (nn Enter the value in the form of y -);
//...Input Loop for Y
for (i=0;in;i++)
{
printf (nn Enter the value of y%d - ,i+1);
scanf (%f,my[i]);
}
//...Inputting the required value query
printf (nEnter the value of x for);
printf(nwhich you want the value of y - );
scanf(%f,x);
//...Calculation and Processing Section
h=mx[1]-mx[0];
for(i=0;in-1;i++)
{
diff[i][1]=my[i+1]-my[i];
}
for (j=2;j=4;j++)
{
for (i=0;in-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
INTERPOLATION 269
i=0;
while(!mx[i]x)
{
i++;
}
x0=mx[i];
sum=0;
y0=my[i];
fun=1;
p=(x-x0)/h;
sum=y0;
for (k=1;k=4;k++)
{
fun=(fun*(p-(k-1)))/k;
sum=sum+fun*diff[i][k];
}
//...Output Section
printf (nwhen x=%6.4f,y=%6.8f,x,sum);
//...Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch( );
}
//...Termination of Main Execution Thread
4.16.4 Output
Enter the number of terms-7
Enter the value in the form of x-
Enter the value of x1 - 100
Enter the value of x2 - 150
Enter the value of x3 - 200
Enter the value of x4 - 250
Enter the value of x5 - 300
Enter the value of x6 - 350
Enter the value of x7 - 400
270 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Enter the value in the form of y -
Enter the value of y1 - 10.63
Enter the value of y2 - 13.03
Enter the value of y3 - 15.04
Enter the value of y4 - 16.81
Enter the value of y5 - 18.42
Enter the value of y6 - 19.90
Enter the value of y7 - 21.27
Enter the value of x for which you want the value of y - 410
When x = 410.0000, y = 21.34462738
Press Enter to Exit
EXAMPLES
Example 1. The population of a town was as given. Estimate the population
for the year 1925.
Year (x): 1891 1901 1911 1921 1931
Population (y): 46 66 81 93 101
(in thousands)
Sol. Here, a + nh = 1931, h = 10, a + nh + uh = 1925
∴ u =
1925 1931
10
−
= – 0.6
The difference table is:
x y ∇y ∇2y ∇3y ∇4y
1891 46
20
1901 66 – 5
15 2
1911 81 – 3 – 3
12 – 1
1921 93 – 4
8
1931 101
INTERPOLATION 271
Applying Newton’s Backward difference formula, we get
y1925 = y1931 + u∇y1931 +
u u
( )
!
+ 1
2
∇2y1931
+
u u u
( )( )
!
+ +
1 2
3
∇3y1931 +
u u u u
( )( )( )
!
+ + +
1 2 3
4
∇4y1931
= 101 + (– .6)(8) +
( )(. )
!
( )
( )( )( )
!
−
− +
−
.6 .6 .4 1.4
4
2
4
3
(– 1)
+
( .6)(.4)(1.4)(2.4)
4 !
−
(– 3)
= 96.8368 thousands.
Hence the population for the year 1925 = 96836.8 ≈ 96837.
Example 2. The population of a town is as follows:
Year: 1921 1931 1941 1951 1961 1971
Population: 20 24 29 36 46 51
(in Lakhs)
Estimate the increase in population during the period 1955 to 1961.
Sol. Here, a + nh = 1971, h = 10, a + nh + uh = 1955
∴ 1971 + 10u = 1955 ⇒ u = – 1.6
The difference table is:
x y ∇y ∇2y ∇3y ∇4y ∇5y
1921 20
4
1931 24 1
5 1
1941 29 2 0
7 1 – 9
1951 36 3 – 9
10 – 8
1961 46 – 5
5
1971 51
272 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Applying Newton’s backward difference formula, we get
y1955 = y1971 + u∇y1971 +
u u
( )
!
+ 1
2
∇2y1971 +
u u u
( )( )
!
+ +
1 2
3
∇3y1971
+
u u u u
( )( )( )
!
+ + +
1 2 3
4
∇4 y1971 +
u u u u u
( )( )( )( )
!
+ + + +
1 2 3 4
5
∇5 y1971
= 51 + (– 1.6)(5) +
( )( . )
!
− −
1.6 0 6
2
(– 5) +
( )( . )( . )
− −
1.6 0 6 0 4
6
(– 8)
+
( )( . )(. )( )
− −
1. 1.
6 0 6 4 4
24
(– 9) +
( )( . )( . )( )( )
− −
1. 1. 2.
6 0 6 0 4 4 4
120
(– 9)
= 39.789632
∴ Increase in population during period 1955 to 1961 is
= 46 – 39.789632 = 6.210368 Lakhs
= 621036.8 Lakhs.
Example 3. In the following table, values of y are consecutive terms of a series
of which 23.6 is the 6th term. Find the first and tenth terms of the series.
x: 3 4 5 6 7 8 9
y: 4.8 8.4 14.5 23.6 36.2 52.8 73.9.
Sol. The difference table is:
x y Δy Δ2y Δ3y Δ4y
3 4.8
3.6
4 8.4 2.5
6.1 0.5
5 14.5 3 0
9.1 0.5
6 23.6 3.5 0
12.6 0.5
7 36.2 4 0
16.6 0.5
8 52.8 4.5
21.1
9 73.9
To find the first term, we use Newton’s forward interpolation formula.
INTERPOLATION 273
Here, a = 3, h = 1, x = 1 ∴ u =
x a
h
−
= – 2
We have y1 = y3 + uΔy3 +
u u
( )
!
− 1
2
Δ2y3 +
u u u
( )( )
!
− −
1 2
3
Δ3y3
= 4.8 + (– 2) × 3.6 +
( )( )
− −
2 3
2
(2.5) +
( )( )( )
− − −
2 3 4
6
(0.5)
= 3.1
To obtain the tenth term, we use Newton’s Backward interpolation
formula
a + nh = 9, h = 1, a + nh + uh = 10
∴ 10 = 9 + u ⇒ u = 1
∴ y10 = y9 + u∇y9 +
u u
( )
!
+ 1
2
∇2y9 +
u u u
( )( )
!
+ +
1 2
3
∇3y9
= 73.9 + 21.1 + 4.5 + .5 = 100.
Example 4. Given log x for x = 40, 45, 50, 55, 60 and 65 according to the
following table:
x: 40 45 50 55 60 65
log x: 1.60206 1.65321 1.69897 1.74036 1.77815 1.81291
Find the value of log 5875.
Sol. The difference table is:
x 105 log x = 105 yx 105 ∇yx 105 ∇2 yx 105 ∇3yx 105∇4 yx 105∇5yx
40 160206
5115
45 165321 – 539
4576 102
50 169897 – 437 – 25
4139 77 5
55 174036 – 360 – 20
3779 57
60 177815 – 303
3476
65 181291
274 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Newton’s Backward difference formula is
f(a + nh + uh) = f(a + nh) + u∇f(a + nh) +
u u
( )
!
+ 1
2
∇2f(a + nh)
+
u u u
( )( )
!
+ +
1 2
3
∇3f(a + nh) +
u u u u
( )( )( )
!
+ + +
1 2 3
4
∇4 f(a + nh)
+
u u u u u
( )( )( )( )
!
+ + + +
1 2 3 4
5
∇5 f(a + nh) (29)
First we shall find the value of log(58.75).
Here, a + nh = 65, h = 5, a + nh + uh = 58.75
∴ 65 + 5u = 58.75 ⇒ u = – 1.25
From (29),
105 f(58.75) = 181291 + (– 1.25)(3476) +
( )( )
!
− −
1.25 .25
2
(– 303)
+
( )( )( )
!
( )
( )( )( )( )
!
− −
+
− −
1.25 .25 .75 1.25 .25 .75 1.75
3
57
4
(– 20)
+
( )( )( )( )( )
!
− −
1.25 .25 .75 1.75 2.75
5
(5)
⇒ 105 f(58.75) = 176900.588
∴ f(58.75) = log 58.75 = 176900.588 × 10–5 = 1.76900588
Hence,
log 5875 = 3.76900588 | ∵ Mantissa remain the same
Example 5. Calculate the value of tan 48° 15′ from the following table:
x°: 45 46 47 48 49 50
tan x°: 1.00000 1.03053 1.07237 1.11061 1.15037 1.19175
Sol. Here a + nh = 50, h = 1, a + nh + uh = 48° 15′ = 48.25°
∴ 50 + u(1) = 48.25 ⇒ u = – 1.75
INTERPOLATION 275
The difference table is:
x° 105y 105∇y 105∇2y 105∇3y 105∇4y 105∇5y
45 100000
3553
46 103553 131
3648 9
47 107237 140 3
3824 12 – 5
48 111061 152 – 2
3976 10
49 115037 162
4138
50 119175
ya+nh+uh = ya+nh + u∇ya+nh +
u u
( )
+ 1
2
∇2ya+nh +
u u u
( )( )
!
+ +
1 2
3
∇3ya+nh
+
u u u u
( )( )( )
!
+ + +
1 2 3
4
∇4ya+nh +
u u u u u
( )( )( )( )
!
+ + + +
1 2 3 4
5
∇5 ya+nh
∴ 105y48.25 = 119175 + (– 1.75) × 4138 +
( ) ( . )
− × −
1.75 0 75
2
× 162
+
( 1.75)( 0.75)(0.25)
3 !
− −
× 10 +
( 1.75)( .75)(.25)(1.25)
4 !
− −
(– 2)
+
( )( )( )( )( )
!
− −
1.75 .75 .25 .25 2.25
1
5
(– 5)
⇒ 105 y48.25 = 112040.2867
∴ y48.25 = tan 48°15′ = 1.120402867.
Example 6. From the following table of half-yearly premium for policies
maturing at different ages, estimate the premium for a policy maturing at the
age of 63:
Age: 45 50 55 60 65
Premium: 114.84 96.16 83.32 74.48 68.48
(in dollars)
276 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. The difference table is:
Age Premium ∇y ∇2y ∇3y ∇4y
(x) (in dollars)
(y)
45 114.84
– 18.68
50 96.16 5.84
– 12.84 – 1.84
55 83.32 4 .68
– 8.84 – 1.16
60 74.48 2.84
– 6
65 68.48
Here a + nh = 65, h = 5, a + nh + uh = 63
∴ 65 + 5u = 63 ⇒ u = – .4
By Newton’s backward difference formula,
y(63) = y(65) + u∇y(65) +
u u
y
u u u
y
( )
!
( )
( )( )
!
( )
+
∇ +
+ +
∇
1
2
65
1 2
3
65
2 3
+
+ + +
∇
u u u u
y
( )( )( )
!
( )
1 2 3
4
65
4
= 68.48 + (– .4)(– 6)
+
( . )(. )
( . )
( . )(. )( . )
( . )
( . )(. )( . )( . )
(. )
−
+
−
− +
−
4 6
2
2 84
4 6 16
6
116
4 6 16 2 6
24
68
= 70.585152
ASSIGNMENT 4.5
1. From the following table find the value of tan 17°
θ°: 0 4 8 12 16 20 24
tan θ°: 0 0.0699 0.1405 0.2126 0.2867 0.3640 0.4402
2. Find the value of an annuity at 5
3
8
%, given the following table:
Rate: 4 4
1
2
5 5
1
2
6
Annuity value: 172.2903 162.8889 153.7245 145.3375 137.6483
INTERPOLATION 277
3. The values of annuities are given for the following ages. Find the value of annuity at the
age of 27
1
2
.
Age: 25 26 27 28 29
Annuity: 16.195 15.919 15.630 15.326 15.006
4. The table below gives the value of tan x for 0.10 ≤ x ≤ 0.30.
x: 0.10 0.15 0.20 0.25 0.30
y = tan x: 0.1003 0.1511 0.2027 0.2553 0.3093
Find: (i) tan 0.50 (ii) tan 0.26 (iii) tan 0.40.
5. Given:
x: 1 2 3 4 5 6 7 8
f(x): 1 8 27 64 125 216 343 512
Find f(7.5) using Newton’s Backward difference formula.
6. From the following table of values of x and f(x), determine
(i) f(0.23) (ii) f(0.29)
x: 0.20 0.22 0.24 0.26 0.28 0.30
f(x): 1.6596 1.6698 1.6804 1.6912 1.7024 1.7139
7. The probability integral
P =
2
0
1
2
2
π
x t
e dt
z −
has following values:
x: 1.00 1.05 1.10 1.15 1.20 1.25
P: 0.682689 0.706282 0.728668 0.749856 0.769861 0.788700
Calculate P for x = 1.235.
8. In an examination, the number of candidates who obtained scores between certain lim-
its are as follows:
Scores Number of candidates
0—19 41
20—39 62
40—59 65
60—79 50
80—99 17
Estimate the number of candidates who obtained fewer than 70 scores.
278 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
9. Estimate the value of f(42) from the following available data:
x: 20 25 30 35 40 45
f(x): 354 332 291 260 231 204
10. The area A of a circle of diameter d is given for the following values:
d: 80 85 90 95 100
A: 5026 5674 6362 7088 7854
Calculate the area of a cricle of diameter 105.
11. From the following table, find y, when x = 1.84 and 2.4 by Newton’s interpolation for-
mula:
x: 1.7 1.8 1.9 2.0 2.1 2.2 2.3
y = ex: 5.474 6.050 6.686 7.389 8.166 9.025 9.974
12. Using Newton’s backward difference formula, find the value of e–1.9 from the following
table of values of e–x:
x: 1 1.25 1.50 1.75 2.00
e–x: 0.3679 0.2865 0.2231 0.1738 0.1353
4.17 CENTRAL DIFFERENCE INTERPOLATION FORMULAE
We shall study now the central difference formulae most suited for interpolation
near the middle of a tabulated set.
4.18 GAUSS’ FORWARD DIFFERENCE FORMULA
Newton’s Gregory forward difference formula is
f(a + hu) = f(a) + uΔf(a) +
u u
f a
u u u
f a
( )
!
( )
( )( )
!
( )
−
+
− −
1
2
1 2
3
2 3
Δ Δ
+
− − −
+
u u u u
f a
( )( )( )
!
( ) ......
1 2 3
4
4
Δ (30)
Given a = 0, h = 1, we get
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( )( )
!
( )
−
+
− −
1
2
0
1 2
3
0
2 3
Δ Δ
+
− − −
+
u u u u
f
( )( )( )
!
( ) ......
1 2 3
4
0
4
Δ (31)
INTERPOLATION 279
Now, Δ3f(– 1) = Δ2f(0) – Δ2f(– 1) ⇒ Δ2f(0) = Δ3f(– 1) + Δ2f(– 1)
Also, Δ4f(– 1) = Δ3f(0) – Δ3f(– 1) ⇒ Δ3f(0) = Δ4f(– 1) + Δ3f(– 1)
and Δ5f(– 1) = Δ4f(0) – Δ4f(– 1) ⇒ Δ4f(0) = Δ5f(– 1) + Δ4f(– 1) and so on.
∴ From (31),
f(u) = f(0) + uΔf(0) +
−
− + −
u u
f f
( )
!
{ ( ) ( )}
1
2
1 1
2 3
Δ Δ
+
− −
− + −
u u u
f f
( )( )
!
{ ( ) ( )}
1 2
3
1 1
3 4
Δ Δ
+
− − −
− + − +
u u u u
f f
( )( )( )
!
{ ( ) ( )} ......
1 2 3
4
1 1
4 5
Δ Δ
= f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( )
( )
−
− +
−
+
−
R
S
T
U
V
W −
1
2
1
1
2
1
2
3
1
2 3
Δ Δ
+
− −
+
−
R
S
T
U
V
W −
u u u u
f
( )( )
( )
1 2
6
1
3
4
1
4
Δ +
− − −
− +
u u u u
f
( )( )( )
!
( ) ......
1 2 3
4
1
5
Δ
= f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
− +
− − −
− +
( ) ( )( )
!
( )
( )( )( )
!
( ) ......
u u u u
f
u u u u
f
1 1 2
4
1
1 2 3
4
1
4 5
Δ Δ
(32)
But, Δ5f(– 2) = Δ4f(– 1) – Δ4f(– 2)
∴ Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2)
then (32) becomes,
f(u) = f(0) + uΔf(0) +
−
− +
+ −
−
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
− + −
( ) ( )( )
!
{ ( ) ( )}
u u u u
f f
1 1 2
4
2 2
4 5
Δ Δ
+
− − −
− +
u u u u
f
( )( )( )
!
( ) ......
1 2 3
4
1
5
Δ
280 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
f(u) = f(0) + uΔf(0) +
−
− +
+ −
−
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
− +
( ) ( )( )
!
( ) ......
u u u u
f
1 1 2
4
2
4
Δ
This is called Gauss’ forward difference formula.
This formula is applicable when u lies between 0 and
1
2
.
4.18.1 Algorithm
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=0;in–1;i++
Step 07. diff[i][1]=ay[i+1]-ay[i]
Step 08. End Loop i
Step 09. for j=2;j=4;j++
Step 10. for i=0;in–j;i++
Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until ax[i]x
Step 16. i=i+1
Step 17. i=i–1;
Step 18. p=(x–ax[i])/h
Step 19. y1=p*diff[i][1]
Step 20. y2=p*(p–1)*diff[i–1][2]/2
Step 21. y3=(p+1)*p*(p-1)*diff[i–2][3]/6
Step 22. y4=(p+1)*p*(p–1)*(p–2)*diff[i–3][4]/24
Step 23. y=ay[i]+y1+y2+y3+y4
Step 24. Print Output x,y
Step 25. End of Program
NOTE
INTERPOLATION 281
4.18.2 Flow-chart
START
Input n, ax, ay
h = ax[i] – ax[0]
Loop i to (n – 1)
Diff[i][1] = ay[i + 1] – ay[i]
End loop i
Loop j = 2 to 4
Loop i = 0 to (n – j)
Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – i]
End loop i
End loop j
i = 0
Y
X
If
ax[i]  x
282 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
X
y
i = i + 1
i = i – 1
p = (x – ax[i])/n
y = p * diff[i][1]
y = p * (p – 1) * diff[i – 1][2]/2
y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6
1
2
3
y = ay[i] + y + y + y
1 2 3
Print Output , x, y
‘‘ ’’
STOP
/* ***********************************************************************
4.18.3 Program to Implement Gauss’s Forward Method of Interpolation
*********************************************************************** */
//...HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//...MAIN EXECUTION THREAD
void main()
{
//...Variable declaration Field
INTERPOLATION 283
//...Integer Type
int n;
int i,j;
//...Floating Type
float ax[10]; //...array limit 9
float ax[10]; //...array limit 9
float x;
float nr,dr;
float y=0; //...Initial value 0
float h;
float p;
float diff[20][20]; //...array limit 19,19
float y1,y2,y3,y4;
//...Invoke Function Clear Screen
clrscr();
//...Input Section
printf(n Enter the number of terms – );
scanf(%d,n);
//...Input Sequel for array X
printf(nn Enter the value in the form of x – );
//...Input loop for Array X
for (i=0;in;i++)
{
printf(nn Enter the value of x%d – ,i+i);
scanf(%f”,ax[i]);
}
printf(nn Enter the value in the form of y – );
//...Input Loop for Array Y
for(i=0;in;i++)
{
printf(nn Enter the value of y%d–,i+1);
scanf(%f,ay[i]);
}
284 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
//...Inputting the required value query
printf(nEnter the value of x for);
printf(nwhich you want the value of y–);
scanf (%f,x);
//... Calculation and Processing Section
h=ax[1]–ax[0];
for(i=0;in–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in–j;i++)
{
diff[i][j]=diff[i+1][j–1]–diff[i][j–1];
}
}
i=0;
do {
i++;
}while(ax[i]x);
i--;
p=(x–ax[i])/h;
y1=p*diff[i][1];
y2=p*(p–1)*diff[i-1][2]/2;
y3=(p+1)*p*(p–1)*diff[i–2][3]/6;
y4=(p+1)*p*(p–1)*(p–2)*diff[i–3][4]/24;
//...Taking Sum
y=ay[i]+y1+y2+y3+y4;
//...Output Section
printf(nwhen x=%6.4f,y=%6.8f ,x,y);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch();
}
//...Termination of Main Execution Thread
INTERPOLATION 285
4.18.4 Output
Enter the number of terms – 7
Enter the value in the form of x –
Enter the value of x1 – 1.00
Enter the value of x2 – 1.05
Enter the value of x3 – 1.10
Enter the value of x4 – 1.15
Enter the value of x5 – 1.20
Enter the value of x6 – 1.25
Enter the value of x7 – 1.30
Enter the value in the form of y –
Enter the value of y1 – 2.7183
Enter the value of y2 – 2.8577
Enter the value of y3 – 3.0042
Enter the value of y4 – 3.1582
Enter the value of y5 – 3.3201
Enter the value of y6 – 3.4903
Enter the value of y7 – 3.6693
Enter the value of x for
which you want the value of y – 1.17
When x = 1.17, y = 3.2221
Press Enter to Exit
EXAMPLES
Example 1. Apply a central difference formula to obtain f(32) given that:
f(25) = 0.2707 f(35) = 0.3386
f(30) = 0.3027 f(40) = 0.3794.
Sol. Here a + hu = 32 and h = 5
Take origin at 30 ∴ a = 30 then u = 0.4
286 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The forward difference table is:
u x f(x) Δf(x) Δ2f(x) Δ3f(x)
– 1 25 .2707
.032
0 30 .3027 .0039
.0359 .0010
1 35 .3386 .0049
.0408
2 40 .3794
Applying Gauss’ forward difference formula, we have
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
∴ f(.4) = .3027 + (.4)(.0359) +
(. )(. )
!
(. )
( . )(. )(. )
!
(. )
4 4 1
2
0039
14 4 4 1
3
0010
−
+
−
= 0.316536.
Example 2. Use Gauss’ forward formula to find a polynomial of degree four
which takes the following values of the function f(x):
x: 1 2 3 4 5
f(x): 1 – 1 1 – 1 1
Sol. Taking origin at 3 and h = 1
a + hu = x
⇒ 3 + u = x ⇒ u = x – 3
The difference table is:
u x f(x) Δf(x) Δ2f(x) Δ3f(x) Δ4f(x)
– 2 1 1
– 2
– 1 2 – 1 4
2 – 8
0 3 1 – 4 16
– 2 8
1 4 – 1 4
2
2 5 1
INTERPOLATION 287
Gauss’ forward difference formula is
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
−
( ) ( )( )
!
( )
u u u u
f
1 1 2
4
2
4
Δ
= 1 + (x – 3)(– 2) +
( )( )
( )
( )( )( )
( )
x x x x x
− −
− +
− − −
3 4
2
4
2 3 4
6
8
+
− − − −
( )( )( )( )
( )
x x x x
2 3 4 5
24
16
= 1 – 2x + 6 – 2x2 + 14x – 24 +
4
3
(x3 – 9x2 + 26x – 24)
+
2
3
(x4 – 14x3 + 71x2 – 154x + 120)
∴ F(x) =
2
3
x4 – 8x3 +
100
3
2
x – 56x + 31
Example 3. The values of e–x at x = 1.72 to x = 1.76 are given in the following
table:
x: 1.72 1.73 1.74 1.75 1.76
e–x: 0.17907 0.17728 0.17552 0.17377 0.17204
Find the value of e–1.7425 using Gauss’ forward difference formula.
Sol. Here taking the origin at 1.74 and h = 0.01.
∴ x = a + uh
⇒ u =
x a
h
−
=
−
1.7425 1.7400
0.01
= 0.25
The difference table is as follows:
u x 105f(x) 105Δf(x) 105Δ2f(x) 105Δ3f(x) 105Δ4f(x)
– 2 1.72 17907
– 179
– 1 1.73 17728 3
– 176 – 2
0 1.74 17552 1 3
– 175
1 1.75 17377 2 1
– 173
2 1.76 17204
288 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
−
( ) ( )( )
!
( )
u u u u
f
1 1 2
4
2
4
Δ
∴ 105f(.25) = 17552 + (.25)(– 175) +
(. )( . )
( )
( . )(. )( . )
( )
25 75
2
1
125 25 75
6
1
−
+
−
+
− −
( . )(. )( . )( . )
( )
125 25 75 175
24
3
= 17508.16846
∴ f(0.25) = e–1.7425 = 0.1750816846.
Example 4. Apply Gauss’s forward formula to find the value of u9, if u0 = 14,
u4 = 24, u8 = 32, u12 = 35, u16 = 40.
Sol. The difference table is (taking origin at 8):
u x f(x) Δf(x) Δ2f(x) Δ3f(u) Δ4f(x)
– 2 0 14
10
– 1 4 24 – 2
8 – 3
0 8 32 – 5 10
3 7
1 12 35 2
5
2 16 40
Here a = 8, h = 4, a + hu = 9
∴ 8 + 4u = 9 ⇒ u = .25
Gauss’ forward difference formula is
f(.25) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
−
( ) ( )( )
!
( )
u u u u
f
1 1 2
4
2
4
Δ
= 32 + (.25)(3) +
(. )( . )
( )
( . )(. )( . )
( )
25 75
2
5
125 25 75
6
7
−
− +
−
+
− −
( . )(. )( . )( . )
( )
125 25 75 175
24
10
INTERPOLATION 289
= 33.11621094
Hence u9 = 33.11621094.
ASSIGNMENT 4.6
1. Apply Gauss’s forward formula to find the value of f(x) at x = 3.75 from the table:
x: 2.5 3.0 3.5 4.0 4.5 5.0
f(x): 24.145 22.043 20.225 18.644 17.262 16.047.
2. Given that
x: 25 30 35 40 45
log x: 1.39794 1.47712 1.54407 1.60206 1.65321
Find the value of log 3.7, using Gauss’s forward formula.
3. Find the value of f(41) by applying Gauss’s forward formula from the following data:
x: 30 35 40 45 50
f(x): 3678.2 2995.1 2400.1 1876.2 1416.3
4. From the following table, find the value of e1.17 using Gauss forward formula:
x: 1 1.05 1.10 1.15 1.20 1.25 1.30
ex: 2.7183 2.8577 3.0042 3.1582 3.3201 3.4903 3.6693
5. From the following table find y when x = 1.45
x: 1.0 1.2 1.4 1.6 1.8 2.0
y: 0.0 – .112 – .016 .336 .992 2.0
4.19 GAUSS’S BACKWARD DIFFERENCE FORMULA
Newton’s Gregory forward difference formula is
f(a + hu) = f(a) + uΔf(a) +
u u
f a
u u u
f a
( )
!
( )
( )( )
!
( ) ......
−
+
− −
+
1
2
1 2
3
2 3
Δ Δ
(33)
Put a = 0, h = 1, we get
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( )( )
!
( )
−
+
− −
1
2
0
1 2
3
0
2 3
Δ Δ
+
− − −
+
u u u u
f
( )( )( )
!
( ) ......
1 2 3
4
0
4
Δ (34)
290 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now, Δf(0) = Δf(– 1) + Δ2f(– 1)
Δ2f(0) = Δ2f(– 1) + Δ3f(– 1)
Δ3f(0) = Δ3f(– 1) + Δ4f(– 1)
Δ4f(0) = Δ4f(– 1) + Δ5f(– 1) and so on.
∴ From (34),
f(u) = f(0) + u[Δf(– 1) + Δ2f(– 1)] +
u u
( )
!
− 1
2
[Δ2f(–1) + Δ3f(– 1)]
+
u u u
f f
( )( )
!
[ ( ) ( )]
− −
− + −
1 2
3
1 1
3 4
Δ Δ
+
u u u u
( )( )( )
!
− − −
1 2 3
4
[Δ4f(–1) + Δ5f(– 1)] + ...... (35)
= f(0) + uΔf(– 1) + u
u
1
1
2
+
−
F
HG I
KJ Δ2f(– 1)
+
u u u
f
( )
( )
−
+
−
F
HG I
KJ −
1
2
1
2
3
1
3
Δ
+
u u u u
f
u u u u
f
( )( )
( )
( )( )( )
!
( ) ......
− −
+
−
R
S
T
U
V
W − +
− − −
− +
1 2
6
1
3
4
1
1 2 3
4
1
4 5
Δ Δ
= f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
+
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
− +
( ) ( )( )
!
( ) ......
u u u u
f
1 1 2
4
1
4
Δ (36)
Again, Δ3f(– 1) = Δ3f(– 2) + Δ4f(– 2)
and Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2) and so on
∴ (36) gives
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
u u
f
u u u
+
− +
+ −
1
2
1
1 1
3
2
Δ {Δ3f(– 2)
+ Δ4f(– 2)}
+
( ) ( )( )
!
u u u u
+ − −
1 1 2
4
{Δ4f(– 2) + Δ5f(– 2)} + ......
INTERPOLATION 291
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
+
− +
+ −
−
1
2
1
1 1
3
2
2 3
Δ Δ
+
+ + −
− +
( ) ( ) ( )
!
( ) ......
u u u u
f
2 1 1
4
2
4
Δ
(37)
This is known as Gauss’ backward difference formula.
This formula is useful when u lies between −
1
2
and 0.
4.19.1 Algorithm of Gauss’s Backward Formula
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=0;in-l;i++
Step 07. diff[i][1]=ay[i+1]-ay[i]
Step 08. End Loop i
Step 09. for j=2;j=4;j++
Step 10. for i=0;in–j;i++
Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until ax[i]x
Step 16. i=i+1
Step 17. i=i–1;
Step 18. p=(x–ax[i])/h
Step 19. y1=p*diff[i-1][1]
Step 20. y2=p*(p+1)*diff[i–1][2]/2
Step 21. y3=(p+1)*p*(p-1)*diff[i–2][3]/6
Step 22. y4=(p+2)*(p+1)*p*(p–1)*diff[i–3][4]/24
Step 23. y=ay[i]+y1+y2+y3+y4
Step 24. Print Output x,y
Step 25. End of Program
292 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.19.2 Flow-chart
START
Input n, ax, ay
h = ax[1] – ax[0]
Loop i = 0 to n – 1
diff[i][1] = ay[i + 1] – ay[i]
End loop i
Loop for j = 2 to 4
Loop for i = 0 to (n – j)
Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – i]
End loop i
End loop j
i = 0
Y
X
No
Yes
Is
ax[i]  x
INTERPOLATION 293
X
Y
i = i + 1
i = i – 1
p = (x – ax[i])/h
y = p * diff[i – 1][1]
y = p * (p + 1) * diff[i – 1][2]/2
y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6
y = (p + 2) * (p + 1) * p * (p – 1) * diff[i – 3][4]/24
1
2
3
4
y = ay[i] + y + y + y + y
1 2 3 4
Print x, y
STOP
/* ********************************************************************
4.19.3 Program to Implement Gauss’s Backward Method of Interpolation
**********************************************************************/*
//...HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//...MAIN EXECUTION THREAD
void main()
294 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
{
//...Variable declaration Field
//...Integer Type
int n; //... No. of terms
int i,j; //... Loop Variables
//...Floating Type
float ax[10]; //... array limit 9
float ay[10]; //... array limit 9
float x; //... User Querry
float y=0; //... Initial value 0
float h; //... Calc. section
float p; //... Calc. section
float diff[20][20]; //... array limit 19, 19
float y1,y2,y3,y4; //... Formulae variables
//... Invoke Function Clear Screen
clrscr();
//... Input Section
printf(n Enter the number of terms – );
scanf(%d,n);
//... Input Sequel for array X
printf(nn Enter the value in the form of x – );
//... Input loop for X
for (i=0;in;i++)
{
printf(nn Enter the value of x%d–,i+1);
scanf(%f”,ax[i]);
}
//...Input Sequel for array Y
printf(nn Enter the value in the form of y–);
//...Input Loop for Y
for(i=0;in;i++)
{
printf(nn Enter the value of y%d–,i+1);
INTERPOLATION 295
scanf(%f,ay[i]);
}
//... Inputting the required value query
printf(nEnter the value of x for);
printf(nwhich you want the value of y – );
scanf(%f,x);
//... Calculation and Processing Section
h=ax[1]–ax[0];
for(i=0;in–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in–j;i++)
{
diff[i][j]=diff[i+1][j–1]–diff[i][j–1];
}
}
i=0;
do {
i++;
}while (ax[i]x);
i—–;
p=(x-ax[i])/h;
y1=p*diff[i–1][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=(p+1)*p*(p–1)*diff[i–2][3]/6;
y4=(p+2)*(p+1)*p*(p–1)*diff[i–3][4]/24;
//... Taking Sum
y=ay[i]+y1+y2+y3+y4;
//... Output Section
printf(nwhen x=%6.1f,y=%6.4f ,x,y);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
296 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
getch();
}
//... Termination of Main Execution Thread
4.19.4 Output
Enter the number of terms – 7
Enter the value in the form of x –
Enter the value of x1 – 1.00
Enter the value of x2 – 1.05
Enter the value of x3 – 1.10
Enter the value of x4 – 1.15
Enter the value of x5 – 1.20
Enter the value of x6 – 1.25
Enter the value of x7 – 1.30
Enter the value in the form of y –
Enter the value of y1 – 2.1783
Enter the value of y2 – 2.8577
Enter the value of y3 – 3.0042
Enter the value of y4 – 3.1582
Enter the value of y5 – 3.3201
Enter the value of y6 – 3.4903
Enter the value of y7 – 3.6693
Enter the value of x for
which you want the value of y – 1.35
When x = 1.35, y=3.8483
Press Enter to Exit
EXAMPLES
Example 1. Given that
12500 = 111.803399, 12510 = 111.848111
12520 = 111.892806, 12530 = 111.937483
Show by Gauss’s backward formula that 12516 = 111.8749301.
Sol. Taking the origin at 12520
∴ u =
x a
h
−
=
12516 12520
10
−
= –
4
10
= – 0.4
INTERPOLATION 297
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
( )
!
u u
+ 1
2
Δ2 f(– 1)
+
( ) ( )
!
u u u
+ −
1 1
3
Δ3f(– 2) + ...... (38)
The difference table is:
u x 106 f(x) 106Δ f(x) 106 Δ2 f(x) 106 Δ3 f(x)
– 2 12500 111803399
44712
– 1 12510 111848111 – 17
44695 – 1
0 12520 111892806 – 18
44677
1 12530 111937483
From (38),
106f(– .4) = 111892806 + (– .4)(44695)
+
(. )( . )
!
( )
(. )( . )( . )
!
( )
6 4
2
18
6 4 14
3
1
−
− +
− −
−
= 111874930.1
∴ f(– .4) = 111.8749301
Hence, 12516 = 111.8749301.
Example 2. Find the value of cos 51° 42′ by Gauss’s backward formula.
Given that
x: 50° 51° 52° 53° 54°
cos x: 0.6428 0.6293 0.6157 0.6018 0.5878.
Sol. Taking the origin at 52° and h = 1
∴ u = (x – a) = 51° 42′ – 52° = – 18′ = – 0.3°
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
+
− +
+ −
−
1
2
1
1 1
3
2
2 3
Δ Δ
+
+ + −
−
( )( ) ( )
!
( )
u u u u
f
2 1 1
4
2
4
Δ (39)
298 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The difference table is as below:
u x 104 f(x) 104 Δ f(x) 104 Δ2 f(x) 104 Δ3 f(x) 104 Δ4 f(x)
– 2 50° 6428
– 135
– 1 51° 6293 – 1
– 136 – 2
0 52° 6157 – 3 4
– 139 2
1 53° 6018 – 1
– 140
2 54° 5878
From (39),
104f(– .3) = 6157 + (– .3)(– 136) +
(. )( . )
!
( )
(. )( . )( . )
!
( )
7 3
2
3
7 3 13
3
2
−
− +
− −
−
+
− −
( . )(. )( . )( . )
!
( )
17 7 3 13
4
4
= 6198.10135
∴ f(– .3) = .619810135
Hence cos 51°42′ = 0.619810135.
Example 3. Using Gauss’s backward interpolation formula, find the population
for the year 1936 given that
Year: 1901 1911 1921 1931 1941 1951
Population: 12 15 20 27 39 52
(in thousands)
Sol. Taking the origin at 1941 and h = 10,
x = a + uh ∴ u =
x a
h
−
=
1936 1941
10
−
= – 0.5
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
+
− +
+ −
−
1
2
1
1 1
3
2
2 3
Δ Δ
+
+ + −
− +
+ + − −
−
( )( ) ( )
!
( )
( )( ) ( )( )
!
( )
u u u u
f
u u u u u
f
2 1 1
4
2
2 1 1 2
5
3
4 5
Δ Δ (40)
INTERPOLATION 299
The difference table is:
u f(u) Δf(u) Δ2f(u) Δ3f(u) Δ4f(u) Δ5f(u)
– 4 12
3
– 3 15 2
5 0
– 2 20 2 3
7 3 – 10
– 1 27 5 – 7
12 – 4
0 39 1
13
1 52
From (40),
f(– .5) = 39 + (– .5)(12) +
(. )( . )
( )
(. )( . )( . )
( )
5 5
2
1
5 5 15
6
4
−
+
− −
−
= 32.625 thousands
Hence, the population for the year 1936 = 32625
Example 4. f(x) is a polynomial of degree four and given that
f(4) = 270, f(5) = 648, Δf(5) = 682, Δ3 f(4) = 132.
Find the value of f(5.8) using Gauss’s backward formula.
Sol. Δf(5) = f(6) – f(5)
∴ f(6) = f(5) + Δf(5) = 648 + 682 = 1330
Δ3f(4) = (E – 1)3 f(4) = f(7) – 3 f(6) + 3 f(5) – f(4) = 132
∴ f(7) = 3f(6) – 3f(5) + f(4) + 132
= 3 × 1330 – 3 × 648 + 270 + 132 = 2448.
The difference table is (Taking origin at 6):
u x f(x) Δ f(x) Δ2 f(x) Δ3 f(x)
– 2 4 270
378
– 1 5 648 304
682 132
0 6 1330 436
1118
1 7 2448
300 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Here, a = 6, h = 1, a + hu = 5.8
∴ 6 + u = 5.8 ⇒ u = – .2
Gauss’s backward formula is
f(– .2) = f(0) + uΔf(– 1)
+
+
− +
+ −
−
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
1
2
1
1 1
3
2
2 3
Δ Δ
= 1330 + (– .2)(682)
+
(. )( . )
( )
(. )( . )( . )
( )
8 2
2
436
8 2 12
6
132
−
+
− −
= 1162.944
∴ f(5.8) = 1162.944.
ASSIGNMENT 4.7
1. The population of a town in the years 1931, ......, 1971 are as follows:
Year: 1931 1941 1951 1961 1971
Population: 15 20 27 39 52
(in thousands)
Find the population of the town in 1946 by applying Gauss’s backward formula.
2. Apply Gauss’s backward formula to find the value of (1.06)19 if (1.06)10 = 1.79085,
(1.06)15 = 2.39656, (1.06)20 = 3.20714, (1.06)25 = 4.29187 and (1.06)30 = 5.74349.
3. Given that
x: 50 51 52 53 54
tan x: 1.1918 1.2349 1.2799 1.3270 1.3764
Using Gauss’s backward formula, find the value of tan 51° 42′.
4. Interpolate by means of Gauss’s backward formula, the population of a town for the
year 1974 given that:
Year: 1939 1949 1959 1969 1979 1989
Population: 12 15 20 27 39 52
(in thousands)
5. Apply Gauss’s backward formula to find sin 45° from the following table:
θ°: 20 30 40 50 60 70 80
sin θ: 0.34202 0.502 0.64279 0.76604 0.86603 0.93969 0.98481
INTERPOLATION 301
6. Using Gauss’s backward formula, estimate the number of persons earning wages be-
tween $ 60 and $ 70 from the following data:
Wages ($): Below 40 40—60 60—80 80—100 100—120
Number of people: 250 120 100 70 50
(in thousands)
4.20 STIRLING’S FORMULA
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u u
f
u u u
f
( )
!
( )
( ) ( )
!
( )
−
− +
+ −
−
1
2
1
1 1
3
1
2 3
Δ Δ
+
+ − −
− +
( ) ( )( )
!
( ) ......
u u u u
f
1 1 2
4
2
4
Δ (41)
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
( ) ( )
!
( )
u u
f
u u u
f
+
− +
+ −
−
1
2
1
1 1
3
2
2 3
Δ Δ
+
+ + −
− +
( )( ) ( )
!
( ) ......
u u u u
f
2 1 1
4
2
4
Δ (42)
Take the mean of (41) and (42),
f(u) = f(0) +
+ −
R
S
T
U
V
W+ −
u
f f u
f
Δ Δ
Δ
( ) ( )
!
( )
0 1
2 2
1
2
2
+
+ −
( ) ( )
!
u u u
1 1
3
Δ Δ
3 3
1 2
2
f f
( ) ( )
− + −
R
S
T
U
V
W
+
u u
f
2 2
4
1
4
2
( )
!
( ) ......
−
− +
Δ (43)
This is called Stirling’s formula. It is useful when | u | 
1
2
or −  
1
2
1
2
u . It
gives the best estimate when −  
1
4
1
4
u .
302 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.20.1 Algorithm of Stirling’s Formula
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h = ax[1]-ax[0]
Step 06. for i = 1;i  n-1; i++
Step 07. diff [i][1] = ay[i + 1]-ay[i]
Step 08. End loop i
Step 09. for j = 2; j  = 4; j++
Step 10. for i = 0; i  n-j; i++
Step 11. diff[i][j] = diff[i + 1][j-1]-diff[i][j-1]
Step 12. End loop i
Step 13. End loop j
Step 14. i = 0
Step 15. Repeat step 16 until ax[i]  x
Step 16. i = i + 1
Step 17. i = i-1;
Step 18. p = (x-ax[i])/h
Step 19. y1= p*(diff[i][1] + diff[i-1][1])/2
Step 20. y2 = p*p*diff[i-1][2]/2
Step 21. y3 = p*(p*p-1)*(diff[i-1][3]+diff[i-2][3])/6
Step 22. y4 = p*p*(p*p-1)*diff[i-2][4]/24
Step 23. y = ay[i]+y1 + y2 + y3 + y4
Step 24. Print output
Step 25. End of program
INTERPOLATION 303
4.20.2 Flow-chart
START
Enter n, ax, ay
h = ax[1] – ax[0]
loop i = 1 to (n – 1)
diff[i][1] = ay[i + 1] – ay[i]
End loop i
loop j = 2 to 4
loop i = 0 to (n – j)
diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1]
End loop i
End loop j
i = 0
Y
X
No
Yes
If
ax[i]  x
304 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
X
i = i + 1
i = i – 1
p = (x – ax[i])/h
y = p * (diff[i][1] + diff[i – 1][1])/2
y = p * p * diff[i – 1][2]/2
y = p * (p * p – 1) * (diff[i – 1][3] + diff[i – 2][3])/6
y = (p * (p * (p * (p – 1))) * diff[i – 2][4]/24
1
2
3
4
y = ay[i] + y + y + y + y
1 2 3 4
Print ‘‘output’’, y
STOP
Y
*/ ********************************************************************
4.20.3 Program to Implement Stirling Method of Interpolation
******************************************************************** /*
//... HEADER FILES DECLARATION
#includestdio.h
#includeconio.h
#includemath.h
#includeprocess.h
//...MAIN EXECUTION THREAD
void main()
INTERPOLATION 305
{
//...Variable declaration Field
//...Integer Type
int n;
int i,j;
//...Floating Type
float ax[10]; //... array-limit 9
float ax[10]; //... array-limit 9
float h;
float p;
float diff[20][20]; //...array 2d-limit 19,19
float x,y;
float y1,y2,y3,y4;
clrscr(); //... Clear Screen
//... Input Section
printf(n Enter the value of terms);
scanf(%d,%n);
//... Input Section Array X
printf(”n Enter the values for x n”);
//...Input Section Loop for X
for(i=0;in;i++)
{
printf(n Enter the value for x%d-,i+1);
scanf(%f”,ax[i]);
}
//... Input Section for Y
printf(n Enter the values for y n);
//... Input Section Loop for Y
for(i=0;in;i++)
{
printf(n Enter the value for y%d-,i+1);
scanf(%f,ay[i]);
}
//... Input Section Loop for Value of X for Y
printf(n Enter the value of x for);
306 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(n which you want the value of y);
scanf(%f,x);
//...Calculation and Processing Section
h=ax[1]-ax[0];
for(i=0;in-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
i=0;
do {
i++;
}while(ax[i]x);
i--;
p=(x-ax[i])/h;
y1=p*(diff[i][1]+diff[i-1][1])/2;
y2=p*p*diff[i-1][2]/2;
y3=p*(p*p-1)*(diff[i-1][3]+diff[i-2][3])/6;
y4=p*p*(p*p-1)*diff[i-2][4]/24;
y=ay[i]+y1+y2+y3+y4;
//...Output Section
printf(nn When x=%6.2f, y=%6.8f,x,y);
//... Producing User Watch Halt Function
getch();
}
4.20.4 Output
Enter the value of terms-7
Enter the values for x
INTERPOLATION 307
Enter the value for x1 - .61
Enter the value for x2 - .62
Enter the value for x3 - .63
Enter the value for x4 - .64
Enter the value for x5 - .65
Enter the value for x6 - .66
Enter the value for x7 - .67
Enter the values for y
Enter the value for y1 - 1.840431
Enter the value for y2 - 1.858928
Enter the value for y3 - 1.877610
Enter the value for y4 - 1.896481
Enter the value for y5 - 1.915541
Enter the value for y6 - 1.934792
Enter the value for y7 - 1.954237
Enter the value of x for
which you want the value of y - 0.6440
When x=0.6440,y=1.90408230
Press Enter to Continue
EXAMPLES
Example 1. Given:
θ: 0° 5° 10° 15° 20° 25° 30°
tan θ: 0 0.0875 0.1763 0.2679 0.364 0.4663 0.5774
Find the value of tan 16° using Stirling formula.
Sol. Take origin at 15°
∴ a = 15°, h = 5
a + hu = 16
⇒ 15 + 5u = 16 ⇒ u = .2
308 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The difference table is:
u θ 104f(θ) 104Δf(θ) 104Δ2f(θ) 104Δ3f(θ) 104Δ4f(θ) 104Δ5f(θ) 104Δ6f(θ)
– 3 0 0
875
– 2 5 875 13
888 15
– 1 10 1763 28 2
916 17 – 2
0 15 2679 45 0 11
961 17 9
1 20 3640 62 9
1023 26
2 25 4663 88
1111
3 30 5774
Using Stirling’s formula,
104f(.2) = 2679 + (.2)
961 916
2
2
2
45
12 2 8
3
17 17
2
2
+
F
HG I
KJ + +
− +
F
HG I
KJ
(. )
!
( )
( . )(. )( . )
!
+
−
+
− − + −
R
S
T
U
V
W
(. ) (. )
!
( )
( . )( . )(. )( . )( . )
!
( )
2 2 1
4
0
2 2 12 2 8 18
5
9 2
2
2 2
o t
+
− −
(. ) {(. ) }{(. ) }
!
( )
2 2 1 2 4
6
11
2 2 2
= 2866.980499
∴ f(.2) = .2866980499
Hence tan 16° = 0.2866980499.
Example 2. Apply Stirling’s formula to find the value of f(1.22) from the
following table which gives the values of f(x) =
1
2
e
x
2
0
x
2
π
−
z dx, at intervals of
x = 0.5 from x = 0 to 2.
x: 0 0.5 1.0 1.5 2.0
f(x): 0 0.191 0.341 0.433 0.477.
INTERPOLATION 309
Sol. Let the origin be at 1 and h = 0.5
∴ x = a + hu, u =
x a
h
−
=
−
=
1. 1.
22 00
0 5
0 44
.
.
Applying Stirling’s formula
f(u) = f(0) + u .
1
2
0 1
2
1
2
2
Δ Δ Δ
f f
u
f
( ) ( )
!
( )
+ − + −
+
−
− + − +
−
− +
u u
f f
u u
f
( )
!
. [ ( ) ( )]
( )
!
. ( ) ......
2
3 3
2 2
4
1
3
1
2
1 2
1
4
2
Δ Δ Δ
∴ f(0.44) = f(0) + (0.44)
1
2
0 1
0 44
2
1
2
2
[ ( ) ( )]
( . )
( )
Δ Δ Δ
f f f
+ − + −
+
−
− + − +
−
−
( . )[( . ) ]
. [ ( ) ( )]
( . ) [( . ) ]
( )
0 44 0 44 1
6
1
2
1 2
0 44 0 44 1
24
2
2
3 3
2 2
4
Δ Δ Δ
f f f
~
− f(0) + (0.22)[Δf(0) + Δf(– 1)] + 0.0968 Δ2 f(– 1)
– 0.029568 [Δ3f(– 1) + Δ3f(– 2)] – 0.06505 Δ4f(– 2) + ......
The difference table is as follows:
u x 103f(x) 103 Δf(x) 103Δ2f(x) 103Δ3f(x) 103Δ4f(x)
– 2 0 0
191
– 1 .5 191 – 41
150 – 17
0 1 341 … – 58 27
1 1.5 433 92 10
44 – 48
2 2 477
f(0) and the differences are being multiplied by 103
∴ 103f(0.44) ~
− 341 + 0.22 × (150 + 92) + 0.0968 × (– 58)
– 0.029568 × [– 17 + 10] – 0.006505 × 27
~
− 341 + 0.22 × 242 – 0.0968 × 58 + 0.029568 × 7 – 0.006505 × 27
~
− 341 + 53.24 – 5.6144 + 0.206276 – 0.175635 ~
− 388.66
∴ f(0.44) = 0.389
Hence the required value of f(x) at x = 1.22 is 0.389.
310 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 3. Use Stirling’s formula to find y28, given
y20 = 49225, y25 = 48316, y30 = 47236,
y35 = 45926, y40 = 44306.
Sol. Let the origin be at 30 and h = 5
a + hu = 28
⇒ 30 + 5u = 28 ⇒ u = – .4
The difference table is as follows:
u x y Δy Δ2y Δ3y Δ4y
– 2 20 49225
– 909
– 1 25 48316 – 171
– 1080 – 59
0 30 47236 – 230 – 21
– 1310 – 80
1 35 45926 – 310
– 1620
2 40 44306
By Stirling’s formula,
f(– .4) = 47236 + (– .4)
− −
F
HG I
KJ +
−
1080 1310
2
4
2
2
( . )
!
(– 230)
+
− − − −
F
HG I
KJ +
− − −
−
(. )( . )( . )
!
( . ) {( . ) }
!
( )
6 4 14
3
59 80
2
4 4 1
4
21
2 2
= 47691.8256
Hence y28 = 47691.8256.
Example 4. Use Stirling’s formula to find y35, given y20 = 512, y30 = 439, y40 = 346
and y50 = 243.
Sol. Let the origin be at 30 and h = 10
a + hu = 35
30 + 10u = 35 ⇒ u = .5
INTERPOLATION 311
The difference table is as follows:
u x y Δy Δ2y Δ3y
– 1 20 512
– 73
0 30 439 – 20
– 93 10
1 40 346 – 10
– 103
2 50 243
By Stirling’s formula,
f(.5) = 439 + (.5)
− −
F
HG I
KJ + − +
− F
HG I
KJ
93 73
2
5
2
20
15 5 5
3
10
2
2
(. )
!
( )
( . )(. )( . )
!
= 394.6875
Hence, y35 = 394.6875.
ASSIGNMENT 4.8
1. Use Stirling’s formula to find the value of f(1.22) from the table.
x f(x)
1.0 0.84147
1.1 0.89121
1.2 0.93204
1.3 0.96356
1.4 0.98545
1.5 0.99749
1.6 0.99957
1.7 0.99385
1.8 0.97385
2. Find f(0.41) using Stirling’s formula, if
f(0.30) = 0.1179, f(0.35) = 0.1368, f(0.40) = 0.1554
f(0.45) = 0.1736, f(0.50) = 0.1915.
312 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3. Evaluate sin (0.197) from the data given below:
x: 0.15 0.17 0.19 0.21 0.23
sin x: 0.14944 0.16918 0.18886 0.20846 0.22798
4. Use Stirling’s formula to find u32 from the following table:
u20 = 14.035 u30 = 13.257
u40 = 12.089 u25 = 13.674
u35 = 12.734 u45 = 11.309.
5. Employ Stirling’s formula to evaluate y12.2 from the following table (yx = 1 + log10 sin x):
x°: 10 11 12 13 14
105 yx: 23967 28060 31788 35209 38368.
6. The following table gives the values of ex for certain equidistant values of x. Find the
value of ex when x = 0.644 using Stirling’s method.
x: 0.61 0.62 0.63 0.64 0.65 0.66 0.67
y = ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237
4.21 BESSEL’S INTERPOLATION FORMULA
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u u
f
( )
!
( )
−
−
1
2
1
2
Δ
+
+ −
−
( ) ( )
!
( )
u u u
f
1 1
3
1
3
Δ
+
( ) ( ) ( )
!
( ) .....
u u u u
f
+ − −
−
1 1 2
4
2
4
Δ (44)
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
( )
!
( )
u u
f
+
−
1
2
1
2
Δ
+
+ −
−
( ) ( )
!
( )
u u u
f
1 1
3
2
3
Δ
+
( ) ( ) ( )
!
( )
u u u u
f
+ + −
−
2 1 1
4
2
4
Δ + ..... (45)
INTERPOLATION 313
In eqn. (45), shift the origin to 1 by replacing u by u – 1 and adding 1 to
each argument 0, – 1, – 2, ....., we get
f(u) = f(1) + (u – 1) Δf(0) +
u u
f
( )
!
( )
− 1
2
0
2
Δ
+
u u u
f
( ) ( )
!
( )
− −
−
1 2
3
1
3
Δ
+
( ) ( ) ( )
!
( )
u u u u
f
+ − −
−
1 1 2
4
1
4
Δ + ..... (46)
Taking mean of (44) and (46), we get
f(u) =
f f u u
f
( ) ( ) ( )
( )
0 1
2
1
2
0
+
R
S
T
U
V
W+
+ −
R
S
T
U
V
WΔ
+
u u f f
( )
!
( ) ( )
− − +
R
S
T
U
V
W
1
2
1 0
2
2 2
Δ Δ
+
u u
u u
f
( )
!
( )
( )
−
+ + −
−
1
3
1 2
1
2
3
Δ
+
( ) ( ) ( )
!
( ) ( )
u u u u f f
+ − − − + −
R
S
T
U
V
W
1 1 2
4
2 1
2
4 4
Δ Δ
+ .....
Finally, we get
f(u) =
f f
u f
( ) ( )
( )
0 1
2
1
2
0
+
R
S
T
U
V
W+ −
F
HG I
KJ Δ
+
− − +
R
S
T
|
U
V
W
|
u u f f
( )
!
( ) ( )
1
2
1 0
2
2 2
Δ Δ
+
( )
!
( )
u u u
f
− −
F
HG I
KJ
−
1
1
2
3
1
3
Δ
+
( ) ( ) ( )
!
( ) ( )
u u u u f f
+ − − − + −
R
S
T
U
V
W
1 1 2
4
2 1
2
4 4
Δ Δ
+ ......
(47)
314 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
This is called Bessel’s formula.
It is very useful when u =
1
2
. It gives a better estimate when
1
4
u
3
4
  .
It is used mainly to compute entry against any argument between 0 and 1.
4.21.1 Algorithm of Bessel’s Formula
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=1;in-l;i++
Step 07. diff[i][1]=ay[i+1]-ay[i]
Step 08. End Loop i
Step 09. for j=2;j=4;j++
Step 10. for i=0;in–j;i++
Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until ax[i]x
Step 16. i=i+1
Step 17. i=i–1;
Step 18. p=(x–ax[i])/h
Step 19. y1=p*(diff[i][1])
Step 20. y2=p*(p-1)*(diff[i][2]+diff[i–1][2])/4
Step 21. y3=p*(p-1)*(p-0.5)*(diff[i–1][3])/6
Step 22. y4=(p+1)*p*(p–1)*(p–2)*(diff[i–2][4]+diff[i–1][4])/48
Step 23. y=ay[i]+y1+y2+y3+y4
Step 24. Print Output
Step 25. End of Program
INTERPOLATION 315
4.21.2 Flow-chart
START
Enter n, ax, ay
h = ax[i] – ax[0]
Loop i = 1 to n – 1
Diff[i][1] = ay[i + 1] – ay[i]
End loop i
Loop j = 2 to 4
Loop i = 0 to (n – j)
Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1]
End loop i
End loop j
i = 0
Y
X
No
Yes
Is
ax[i]  x
316 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
X
i = i + 1
i = i – 1
p = (x – ax[i])/h
y = p * (diff[i][1])
y = p * (p – 1) * (diff[i][2] + diff[i – 1][2])/4
y = p * (p – 1) * (p – 0.5) * (diff[i – 1][3])/6
y = (p + 1) * p*(p – 1) * (p – 2) * (diff[i – 2][4] + diff[i – 1][4])/48
1
2
3
4
y = ay[i] + y + y + y + y
1 2 3 4
Print ‘‘output’’x, y
STOP
Y
/* ***********************************************************************
4.21.3 Program to Implement Bessel’s Method of Interpolation
*********************************************************************** */
//...HEADER FILES DECLARATION
#includestdio.h
#includeconio.h
#includemath.h
#includeprocess.h
//... MAIN EXECUTION THREAD
void main()
{
//...Variable declaration Field
INTERPOLATION 317
//...Integer Type
int n;
int i,j;
//...Floating Type
float ax[10]; //...array – limit 9
float ay[10]; //...array – limit 9
float h;
float p;
float diff[20][20]; //... array 2d – limit
19, 19
float x,y;
float y1,y2,y3,y4,
//...Invoke Clear Screen Function
clrscr(); //... Clear Screen
//... Input Section
printf(n Enter the number of terms);
scanf(%d,n);
//... Input Section Array X
printf(n Enter the values for x n);
//... Input Section Loop for X
for(i=0;in;i++)
{
printf(n Enter the value for x%d–,i+1);
scanf(%f,ax[i]);
}
//... Input Section for Array Y
printf(n Enter the values for yn);
//...Input Section Loop for Y
for(i=0;in;i++)
{
printf(n Enter the value for y%d–,i+1);
scanf(%f,ay[i]);
}
//...Input Section Loop for Value Of X for Y
printf(n Enter the value of x for );
printf(n which you want the value of y );
318 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
scanf (%f,x); //...Input X
//...Calculation and Processing Section
h=ax[1]–ax[0];
for(i=0;in–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in–j;i++)
{
diff[i][j]=diff[i+1][j–1]–diff[i][j–1];
}
}
i=0;
do {
i++;
}while (ax[i]x);
i––;
//... Bessel formulae Calculation
p=(x-ax[i])/h;
y1=p*(diff[i][1]);
y2=p*(p-1)*diff[i][2]+diff[i-1][2])/4;
y3=p*(p–1)*(p–0.5)*(diff[i–1][3])/6;
y4=(p+1)*p*(p–1)*(p–2)*(diff[i–2][4]+diff[i–1][4])/48;
//...Taking Sum
y=ay[i]+y1+y2+y3+y4;
//...Output Section
printf(nwhen x=%6.2f,y=%6.8f ,x,y);
//...Invoke User Watch Halt Function
printf(nn Press Enter to Exit t);
getch();
}
*End of Main Execution Thread */
INTERPOLATION 319
4.21.4 Output
Enter the number of terms - 7
Enter the values of x
Enter the value of x1 - .61
Enter the value of x2 - .62
Enter the value of x3 - .63
Enter the value of x4 - .64
Enter the value of x5 - .65
Enter the value of x6 - .66
Enter the value of x7 - .67
Enter the values of y
Enter the value of y1 - 1.840431
Enter the value of y2 - 1.858928
Enter the value of y3 - 1.877610
Enter the value of y4 - 1.896481
Enter the value of y5 - 1.915541
Enter the value of y6 - 1.934792
Enter the value of y7 - 1.954237
Enter the value of x for
which you want the value of y - .644
When x = 0.644, y=1.90408230
Press Enter to Exit
EXAMPLES
Example 1. Given y20 = 24, y24 = 32, y28 = 35 and y32 = 40 find y25 by Bessel’s
interpolation formula.
Sol. Take origin at 24.
Here, a = 24, h = 4, a + hu = 25
∴ 24 + 4u = 25 ⇒ u = .25
320 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The difference table is:
u x y Δy Δ2y Δ3y
– 1 20 24
8
0 24 32 – 5
3 7
1 28 35 2
5
2 32 40
Using Bessel’s formula,
f(u) =
f f
u f
( ) ( )
( )
0 1
2
1
2
0
+
R
S
T
U
V
W+ −
F
HG I
KJ Δ
+
− − +
R
S
T
|
U
V
W
|
u u f f
( ) ( ) ( )
1
2
1 0
2
2 2
Δ Δ
+
( )
!
( )
u u u
f
− −
F
HG I
KJ
−
1
1
2
3
1
3
Δ
⇒ f(.25) =
32 35
2
+
F
HG I
KJ + (.25 – .5) (3) +
(. ) (. )
25 25 1
2
5 2
2
− − +
R
S
T
U
V
W
+
(. ) (. . ) (. )
!
( )
25 1 25 5 25
3
7
− −
= 32.9453125
Hence y25 = 32.9453125.
Example 2. Apply Bessel’s formula to find the value of f(27.4) from the table:
x: 25 26 27 28 29 30
f(x): 4.000 3.846 3.704 3.571 3.448 3.333.
Sol. Taking origin at 27 and h = 1
x = a + uh ⇒ 27.4 = 27 + u × 1
∴ u = 0.4
INTERPOLATION 321
The difference table is as follows:
u 103f(u) 103 Δf(u) 103 Δ2f(u) 103 Δ3f(u) 103 Δ4f(u) 103 Δ5f(u)
– 2 4000
– 154
– 1 3847 12
– 142 – 3
0 3704 9 4
– 133 1 – 7
1 3571 10 – 3
– 123 – 2
2 3448 8
– 115
3 3333
Bessel’s formula is
f(u) =
f f
u f
( ) ( )
( )
0 1
2
1
2
0
+
R
S
T
U
V
W+ −
F
HG I
KJ Δ +
u u f f
( )
!
( ) ( )
− + −
R
S
T
U
V
W
1
2
0 1
2
2 2
Δ Δ
+
( )
!
( )
u u u
f
− −
F
HG I
KJ
−
1
1
2
3
1
3
Δ
+
( ) ( ) ( )
!
( ) ( )
u u u u f f
+ − − − + −
R
S
T
U
V
W
1 1 2
4
1 2
2
4 4
Δ Δ
+
( ) ( ) ( )
!
( )
u u u u u
f
− − −
F
HG I
KJ +
−
2 1
1
2
1
5
2
5
Δ
∴ 103f(0.4) =
3704 3571
2
+
R
S
T
U
V
W + (.4 – .5) (– 133) +
(. ) (. )
!
4 4 1
2
10 9
2
− +
F
HG I
KJ
+
(. ) (. . ) (. )
!
( )
4 1 4 5 4
3
1
− −
+
(. ) (. ) (. ) (. )
!
4 1 4 4 1 4 2
4
3 4
2
+ − − − +
F
HG I
KJ
+
(. ) (. ) (. . ) (. ) (. )
!
( )
4 2 4 1 4 5 4 4 1
5
7
− − − +
−
= 3649.678336
⇒ f(.4) = 3.649678336
Hence f(27.4) = 3.649678336.
322 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 3. Probability distribution function values of a normal distribution
are given as follows:
x: 0.2 0.6 1.0 1.4 1.8
p(x): 0.39104 0.33322 0.24197 0.14973 0.07895
Find the value of p(x) for x = 1.2.
Sol. Taking the origin at 1.0 and h = 0.4
x = a + uh ⇒ 1.2 = 1.0 + u × 0.4
∴ u =
1. 1.
0.4
2 0 1
2
−
=
The difference table is:
u 105f(u) 105 Δf(u) 105 Δ2f(u) 105 Δ3f(u) 105 Δ4f(u)
– 2 39104
– 5782
– 1 33332 – 3343
– 9125 3244
0 24197 – 99 – 999
– 9224 2245
1 14973 2146
– 7078
2 7895
Bessel’s formula is
f(u) =
f f
u f
( ) ( )
( )
0 1
2
1
2
0
+
R
S
T
U
V
W+ −
F
HG I
KJ Δ
+
u u f f
( )
!
( ) ( )
− + −
R
S
T
U
V
W
1
2
0 1
2
2 2
Δ Δ
+
( ) ( )
!
( )
u u u
f
− −
F
HG I
KJ
−
1
1
2
3
1
3
Δ
105 f (.5) = 24197 14973
2
0
1
2
1
2
1
2
2146 99
2
0
+
F
HG I
KJ + +
F
HG I
KJ −
F
HG I
KJ −
F
HG I
KJ +
!
= 19457.0625
INTERPOLATION 323
∴ f(.5) = 0.194570625
Hence p(1.2) = 0.194570625.
Example 4. Given that
x: 4 6 8 10 12 14
f(x): 3.5460 5.0753 6.4632 7.7217 8.8633 9.8986
Apply Bessel’s formula to find the value of f(9).
Sol. Taking the origin at 8, h = 2,
9 = 8 + 2u or u =
1
2
The difference table is:
u 104 yu 104 Δ2yu 104 Δ2yu 104 Δ3yu 104 Δ4yu 105 Δ5yu
– 2 35460
15293
– 1 50753 – 1414
13879 120
0 64632 – 1294 5
1258 125 – 24
1 77217 – 1169 – 19
11416 106
2 88633 – 1063
10353
3 98986
Bessel’s formula is
yu =
1
2
1
2
1
2
1
2
1 0 0
2
0
2
1
( )
( )
!
( )
y y u y
u u
y y
+ + −
F
HG I
KJ +
−
+ −
Δ Δ Δ
+
u u u
y
−
F
HG I
KJ −
−
1
2
1
3
3
1
( )
!
Δ
+
( ) ( )( )
!
( )
u u u u
y y
+ − −
× +
− −
1 1 2
4
1
2
4
3
4
2
Δ Δ
+
( ) ( ) ( )
!
u u u u u
y
− − −
F
HG I
KJ +
−
2 1
1
2
1
5
5
2
Δ
324 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
104y1/2 =
1
2
77217 64632 0
1
2
1
2
2
1
2
1169 1294
( ) . ( )
+ + +
−
F
HG I
KJ
− −
+ +
−
F
HG I
KJ −
F
HG I
KJ
− +
0
3
2
1
2
1
2
3
2
24
1
2
19 5
. .
. ( ) + 0
⇒ 104y1/2 = 71078.27344
∴ y1/2 = 7.107827344
Hence, f(9) = 7.107827344.
Example 5. Given y0, y1, y2, y3, y4, y5 (fifth differences constant), prove that
y
1
2
c
25(c b) 3(a c)
256
2
1
2
= +
− + −
where a = y0 + y5, b = y1 + y4, c = y2 + y3 .
Sol. Put u =
1
2
in Bessel’s formula, we get
y1/2 =
1
2
1
16
3
256
0 1
2
0
2
1
4
1
4
2
( ) ( ) ( )
y y y y y y
+ − + + +
− − −
Δ Δ Δ Δ
Shifting the origin to 2, we have
y y y y y y y
2
1
2
2 3
2
2
2
1
4
1
4
0
1
2
1
16
3
256
= + − + + +
( ) ( ) ( )
Δ Δ Δ Δ
= −
c
2
1
16
(y3 – 2y2 + y1 + y4 – 2y3 + y2)
+
3
256
(y5 – 3y4 + 2y3 + 2y2 – 3y1 + y0)
y
c
y y y y a b c
2
1
2
4 3 2 1
2
1
16
3
256
3 2
= − − − + + − +
( ) ( )
= − − + − +
c
b c a b c
2
1
16
3
256
3 2
( ) ( )
y
c
c b a c
2
1
2
2
1
256
25 3
= + − + −
[ ( ) ( )].
INTERPOLATION 325
Example 6. If third differences are constant, prove that
y
1
2
(y y )
1
16
( y y )
x
1
2
x x 1
2
x 1
2
x
+
+ −
= + − +
Δ Δ .
Sol. Putting u =
1
2
in Bessel’s formula, we get
y y y y y
1/2 0 1
2
0
2
1
1
2
1
16
= + − + −
( ) ( )
Δ Δ
Shifting the origin to x,
y y y y y
x
x x x x
+
+ −
= + − +
1
2
1
2 2
1
1
2
1
16
( ) ( )
Δ Δ .
Example 7. Find the value of y15 ,using Bessel’s formula, if
y10 = 2854, y14 = 3162, y18 = 3544, y22 = 3992.
Sol. Taking the origin at 14, h = 4
∴ 15 = 14 + 4 . u ∴ u =
1
4
The difference table is:
u x f(x) Δ f(x) Δ2 f(x) Δ3 f(x)
– 1 10 2854
308
0 14 3162 74
382 – 8
1 18 3544 66
448
2 22 3992
Bessel’s formula is
f(u) =
f f
u f
u u f f
( ) ( )
( )
( )
!
( ) ( )
0 1
2
1
2
0
1
2
1 0
2
2 2
+
R
S
T
U
V
W+ −
F
HG I
KJ +
− − +
R
S
T
U
V
W
Δ
Δ Δ
+
( )
!
( )
u u u
f
− −
F
HG I
KJ
−
1
1
2
3
1
3
Δ
326 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ f (.25) =
3162 3544
2
+
F
HG I
KJ + (.25 – .5) (382) +
(. ) (. )
25 25 1
2
74 66
2
− +
F
HG I
KJ
+
(. ) (. . ) (. )
25 1 25 5 25
6
− −
(– 8)
= 3250.875
Hence y15 = 3250.875.
ASSIGNMENT 4.9
1. Apply Bessel’s formula to find the value of y2.73 given that
y2.5 = 0.4938, y2.6 = 0.4953, y2.7 = 0.4965
y2.8 = 0.4974, y2.9 = 0.4981, y3.0 = 0.4987.
2. Find the value of y if x = 3.75, given that
x: 2.5 3.0 3.5 4.0 4.5 5.0
y: 24.145 22.043 20.225 18.644 17.262 16.047.
Using Bessel’s formula.
3. Apply Bessel’s formula to find u62.5 from the following data:
x: 60 61 62 63 64 65
ux: 7782 7853 7924 7993 8062 8129.
4. Apply Bessel’s formula to find the value of f(12.2) from the following table:
x: 0 5 10 15 20 25 30
f(x): 0 0.19146 0.34634 0.43319 0.47725 0.49379 0.49865
5. The following table gives the values of ex for certain equidistant values of x. Find the
value of ex when x = 0.644 using Bessel’s formula:
x: .61 .62 .63 .64 .65 .66 .67
ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237
6. Find y(0.543) from the following values of x and y:
x: 0.1 0.2 0.3 0.4 0.5 0.6 0.7
y(x): 2.631 3.328 4.097 4.944 5.875 6.896 8.013
7. Apply Bessel’s formula to obtain y25 given y20 = 2854, y24 = 3162, y28 = 3544, y32 = 3992.
8. The pressure p of wind corresponding to velocity v is given by following data.
Estimate p when v = 25.
v: 10 20 30 40
p: 1.1 2 4.4 7.9
INTERPOLATION 327
4.22 LAPLACE-EVERETT’S FORMULA
Gauss’ forward formula is
f(u) = f(0) + uΔf(0) +
u u
f
( )
!
( )
−
−
1
2
1
2
Δ +
( ) ( )
!
( )
u u u
f
+ −
−
1 1
3
1
3
Δ
+
( ) ( ) ( )
!
( )
u u u u
f
+ − −
−
1 1 2
4
2
4
Δ
+
( ) ( ) ( ) ( )
!
( )
u u u u u
f
+ + − −
−
2 1 1 2
5
2
5
Δ + .... (48)
We have,
Δf(0) = f(1) – f(0)
Δ3f(– 1) = Δ2f(0) – Δ2f(– 1)
Δ5f(– 2) = Δ4f(– 1) – Δ4f(– 2)
∴ From (48),
f(u) = f(0) + u{f(1) – f(0)} +
u u
( )
!
− 1
2
Δ2f(– 1)
+
( ) ( )
!
u u u
+ −
1 1
3
{Δ2f(0) – Δ2f(– 1)}
+
( ) ( ) ( )
!
( )
u u u u
f
+ − −
−
1 1 2
4
2
4
Δ
+
( ) ( ) ( ) ( )
!
u u u u u
+ + − −
2 1 1 2
5
{Δ4f(– 1) – Δ4f(– 2)} + ......
= (1 – u) f(0) + uf(1) +
( ) ( )
!
( )
u u u
f
+ −
1 1
3
0
2
Δ
–
u u u
f
( ) ( )
!
( )
− −
−
1 2
3
1
2
Δ
+
( ) ( ) ( ) ( )
!
( )
u u u u u
f
+ + − −
−
2 1 1 2
5
1
4
Δ
–
( ) ( ) ( ) ( )
!
( )
u u u u u
f
+ − − −
−
1 1 2 3
5
2
4
Δ + .....
328 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= u f
u u u
f
( )
( ) ( )
!
( )
1
1 1
3
0
2
+
+ −
R
S
T Δ
+
+ + − −
− +
U
V
W
( ) ( ) ( ) ( )
!
( ) .....
u u u u u
f
2 1 1 2
5
1
4
Δ
+ ( ) ( )
( ) ( ) ( )
!
( )
1 0
1 1 1 1 1
3
1
2
− +
− + − − −
−
R
S
T u f
u u u
f
Δ
+
( ) ( ) ( ) ( ) ( )
!
( ) .....
1 2 1 1 1 1 1 1 2
5
2
4
− + − + − − − − −
− +
U
V
W
u u u u u
f
Δ
f(u) = uf
u u u
f
( )
( ) ( )
!
( )
1
1 1
3
0
2
+
+ −
R
S
T
Δ
+
+ + − −
− +
U
V
W
( ) ( ) ( ) ( )
!
( ) .....
u u u u u
f
2 1 1 2
5
1
4
Δ
+ wf
w w w
f
( )
( ) ( )
!
( )
0
1 1
3
1
2
+
+ −
−
R
S
T Δ
+
+ + − −
− +
U
V
W
( ) ( ) ( ) ( )
!
( ) .....
w w w w w
f
2 1 1 2
5
2
4
Δ
(49)
where w = 1 – u
This is called Laplace–Everett’s formula.
It gives the best estimate when u 
1
2
. It is used to compute any entry
against any argument between 0 and 1. It is useful when intervening values in
successive intervals are required.
4.22.1 Algorithm of Laplace’ Everett Formula
Step 01. Start of the program.
Step 02. Input number of terms n
Step 03. Input the array ax
INTERPOLATION 329
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=0; in-l; i++
Step 07. diff[i][1]=ay[i+1]-ay[i]
Step 08. End Loop i
Step 09. for j=2; j=4; j++
Step 10. for i=0; in–j; i++
Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1]
Step 12. End Loop i
Step 13. End Loop j
Step 14. i=0
Step 15. Repeat Step 16 until ax[i]x
Step 16. i=i+1
Step 17. i=i–1;
Step 18. p=(x–ax[i])/h
Step 19. q=1–p
Step 20. y1=q*(ay[i])
Step 21. y2=q*(q*q–1)*diff[i–1][2]/6
Step 22. y3=q*(q*q–1)*(q*q–4)*(diff[i–2][4])/120
Step 23. py1=p*ay[i+1]
Step 24. py2=p*(p*p–1)*diff[i][2]/6
Step 25. py3=p*(p*p–1)*(p*p–4)*(diff[i–1][4])/120
Step 26. y=y1+y2+y3+y4+py1+py2+py3
Step 27. Print Output x, y
Step 28. End of Program
330 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.22.2 Flow-chart
Input n, ax, ay
h = ax[1] – ax[0]
Start loop for i = 0 to n – 1
Diff[i][1] = ay[i + 1] – ay[i]
End loop i
For loop i = 2 to 4
For loop j = 0 to (n – j)
Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1]
End loop j
End loop i
i = 0
i = i – 1
A
Yes
No
Is
ax[i]  x i = i + 1
Start
INTERPOLATION 331
A
p = (x – ax[i])/h
q = 1 – p
y = q * (ay[i])
y = q * (q * q – 1) * diff[i – 1]
y = q * (q * q – 1) * (q * (q – 4)) * diff[i – 2][4])/120
1
2
3
py = p * ay[i + 1]
py = p * (p * p – 1) * diff[i][2]/6
py = p * (p * p – 1) * (p * p – 4) * (diff[i – 1][4])/120
1
2
3
y = y + y + y + py + py + py
1 2 3 1 2 3
Print ‘‘output’’, x, y
STOP
/* ************************************************************************
4.22.3 Program to Implement Laplace Everett’s Method of Interpolation
********************************************************************** */
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... MAIN EXECUTION THREAD
332 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
void main()
{
//... Variable declaration Field
//... Integer Type
int n;
int i,j;
//... Floating Type
float ax[10]; //... array limit 9
float ay[10]; //... array limit 9
float x;
float nr,dr;
float y=0; //... Initial value 0
float h;
float p,q;
float diff[20][20]; //... array limit 19,19
float y1,y2,y3,y4;
float py1,py2,py3,py4;
//... Invoke Function Clear Screen
clrscr();
//... Input Section
printf (n Enter the number of terms - );
scanf(%d,n);
//... Input Sequel for array X
printf(nn Enter the value in the form of x - );
//... Input Loop for Array X
for (i=0;in;i++)
{
Printf(nn Enter the value of x%d - ,i+1);
scanf(%f,ax[i]);
}
//... Input Sequel for Array X
printf (nn Enter the value in the form of y - );
INTERPOLATION 333
//... Input Loop Array Y
for (i=0;in;i++)
{
printf (nn Enter the value of y%d - ,i+1);
scanf(%f,ay[i]);
}
//... Inputting the required value query
printf(nEnter the value of x for );
printf(nwhich you want the value of y - );
scanf(%f,x);
//... Calculation and Processing Section
h=ax[1]-ax[0];
for(i=0;in-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j=4;j++)
{
for(i=0;in-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
i=0;
do {
i++;
}while(ax[i]x);
i--;
p=(x-ax[i])/h;
q=1-p;
y1=q*(ay[i]);
y2=q*(q*q-1)*diff[i-1][2]/6;
y3=q*(q*q-1)*(q*q-4)*(diff[i-2][4])/120;
py1=p*ay[i+1];
334 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
py2=p*(p*p-1)*diff[i][2]/6;
py3=p*(p*p-1)*(p*p-4)*(diff[i-1][4])/120;
//... Taking sum
y=y1+y2+y3+y4+py1+py2+py3;
//... Output Section
printf(n when x=%6.2f,y=%6.8f ,x,y);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit );
getch();
}
//... Termination of Main Execution Thread
4.22.4 Output
Enter the number of terms - 7
Enter the value in the form of x -
Enter the value of x1 - 1.72
Enter the value of x2 - 1.73
Enter the value of x3 - 1.74
Enter the value of x4 - 1.75
Enter the value of x5 - 1.76
Enter the value of x6 - 1.77
Enter the value of x7 - 1.78
Enter the value in the form of y -
Enter the value of y1 - .1790661479
Enter the value of y2 - .1772844100
Enter the value of y3 - .1755204006
Enter the value of y4 - .1737739435
Enter the value of y5 - .1720448638
Enter the value of y6 - .1703329888
Enter the value of y7 - .1686381473
Enter the value of x for
which you want the value of y - 1.7475
When x = 1.7475, y = 0.17420892
Press Enter to Exit
INTERPOLATION 335
EXAMPLES
Example 1. Using Everett’s formula, evaluate f(30) if
f(20) = 2854, f(28) = 3162
f(36) = 7088, f(44) = 7984.
Sol. Take origin at 28.
∴ a = 28, h = 8
a + hu = 30
⇒ 28 + 8u = 30 ⇒ u = .25
Also, w = 1 – u = 1 – .25 = .75
The difference table is:
u f(u) Δf(u) Δ2f(u) Δ3f(u)
– 1 2854
308
0 3162 3618
3926 – 6648
1 7088 – 3030
896
2 7984
By Everett’s formula,
∴ f(.25) = (. ) ( )
( . ) (. ) ( . )
!
( ) .....
25 7088
125 25 75
3
3030
+
−
− +
R
S
T
U
V
W
+ (. ) ( )
( . ) (. ) ( . )
!
( ) .....
75 3162
175 75 25
3
3618
+
−
+
R
S
T
U
V
W
= 4064
Hence f(30) = 4064.
Example 2. Find the value of f(27.4) from the following table:
x: 25 26 27 28 29 30
f(x): 4.000 3.846 3.704 3.571 3.448 3.333.
Sol. Here u =
27 4 27 0
1
. .
−
= 0.4 ∵ origin is at 27.0, h = 1
Also, w = 1 – u = 0.6
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→
336 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The difference table is:
u 103 f(u) 103 Δf(u) 103Δ2f(u) 103Δ3f(u) 103Δ4f(u)
– 2 4000
– 154
– 1 3846 12
– 142 – 3
0 3704 9 4
– 133 1
1 3571 10 – 3
– 123 – 2
2 3448 8
– 115
3 3333
By Laplace Everett’s formula,
f(.4) = (. )( )
( . ) (. ) ( . )
!
( )
4 3571
14 4 6
3
10
+
−
R
S
T
+
− −
− +
U
V
W
( . ) ( . ) (. ) ( . ) ( . )
!
( ) .....
2 4 14 4 6 16
5
3
+ (. ) ( )
( . ) (. ) ( . )
!
( )
6 3704
16 6 4
3
9
+
−
R
S
T
+
− − U
V
W
( . ) ( . ) (. ) ( . ) ( . )
!
( )
2 6 16 6 4 14
5
4
= 3649.678336.
Hence f(27.4) = 3649.678336.
ASSIGNMENT 4.10
1. Given the table
x: 21 22 23 24 25 26
log x: 1.3222 1.3424 1.3617 1.3802 1.3979 1.4150
Apply Laplace-Everett’s formula to find the value of log 2375.
⎯⎯⎯⎯⎯⎯⎯⎯⎯→
⎯⎯⎯⎯⎯⎯⎯⎯⎯→
⎯⎯⎯⎯⎯⎯⎯⎯⎯→
⎯⎯⎯⎯⎯⎯⎯⎯⎯→
INTERPOLATION 337
2. From the following present value annuity an table:
x: 20 25 30 35 40
an: 11.4699 12.7834 13.7648 14.4982 15.0463
find the present value of the annuity a31, a32, a33, a34.
3. Find the value of f(31), f(32), f(33), f(34). Given that
f(20) = 3010, f(25) = 3979, f(30) = 4771
f(35) = 5441, f(40) = 6021 and f(45) = 6532.
4. Find y12 if y0 = 0, y10 = 43214, y20 = 86002 and y30 = 128372.
5. Obtain the values of y25, given that
y20 = 2854, y24 = 3162
y28 = 3544 and y32 = 3992
6. Find the value of e–x when x = 1.748 from the following:
x: 1.72 1.73 1.74 1.75 1.76 1.77
e–x: 0.1790 0.1773 0.1755 0.1738 0.1720 0.1703
7. Use Everett’s formula to find the present value of the annuity for n = 36 from the table:
x: 25 30 35 40 45 50
ax: 12.7834 13.7648 14.4982 15.0463 15.4558 15.7619.
8. Apply Everett’s formula to find the value of f(26) and f(27) from the table:
x: 15 20 25 30 35 40
f(x): 12.849 16.351 19.524 22.396 24.999 27.356.
9. Find the compound interest on the sum of Rs. 10,000 at 7% for the period 16 and 17
years if:
x: 5 10 15 20 25 30
(1.07)n: 1.40255 1.96715 2.75903 3.86968 5.42743 7.61236.
10. Apply Everett’s formula to find the values of e–x for x = 3.2, 3.4, 3.6, 3.8, if
x: 1 2 3 4 5 6
e–x: 0.36788 0.13534 0.04979 0.01832 0.00674 0.00248.
11. Given that
x: 40 45 50 55 60 65
x1/3: 3.4200 3.3569 3.6840 3.8030 3.9149 4.0207
Find the values of x1/3 when x = 51 to 54.
338 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
12. Prove that if third differences are assumed to be constant,
yx = xy1 +
x x
( )
!
2
1
3
−
Δ2y0 + uy0 +
u u
( )
!
2
1
3
−
Δ2y–1
where u = 1 – x.
Apply this formula to find the value of y11 and y16, given that
y0 = 3010, y5 = 2710, y10 = 2285, y15 = 1860, y20 = 1560, y25 = 1510, y30 = 1835.
13. The following table gives the values of ex for certain equidistant values of x.
Find the value of ex when x = 0.644 using Everett’s formula
x: 0.61 0.62 0.63 0.64 0.65 0.66 0.67
y = ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237.
14. The values of the elliptic integral,
k(m) = ( sin )
/
1 2
1
2
0
2
−
−
z m d
θ θ
π
for certain equidistant values of m are given below. Use Everett’s or Bessel’s formula to
determine k(0.25).
m: 0.20 0.22 0.24 0.26 0.28 0.30
k(m): 1.659624 1.669850 1.680373 1.691208 1.702374 1.713889.
15. From the following table of values of x and y = ex, interpolate the value of y when x = 1.91
x: 1.7 1.8 1.9 2.0 2.1 2.2
y = ex: 5.4739 6.0496 6.6859 7.3891 8.1662 9.0250.
16. Given the table:
x: 310 320 330 340 350 360
log x: 2.49136 2.50515 2.51851 2.53148 2.54407 2.55630.
Find the value of log 337.5 by Laplace Everett’s formula.
4.23 INTERPOLATION BY UNEVENLY SPACED POINTS
The interpolation formulae derived sofar possess the disadvantage of being
applicable only to equally spaced values of the argument. It is then desirable to
develop interpolation formulae for unequally spaced values of x. We shall study
two such formulae:
(1) Lagrange’s interpolation formula
(2) Newton’s general interpolation formula with divided differences.
INTERPOLATION 339
4.24 LAGRANGE’S INTERPOLATION FORMULA
Let f(x0), f(x1) ,......, f(xn) be (n + 1) entries of a function y = f(x), where f(x) is
assumed to be a polynomial corresponding to the arguments x0, x1, x2, ......, xn.
The polynomial f(x) may be written as
f(x) = A0 (x – x1) (x – x2) ...... (x – x n)
+ A1(x – x0)(x – x2) ...... (x – xn)
+ ...... + An (x – x0) (x – x1) ...... (x – xn –1) (50)
where A0, A1, ......, An are constants to be determined.
Putting x = x0, x1, ......, xn in (50), we get
f(x0) = A0 (x0 – x1) (x0 – x2) ....... (x0 – xn)
∴ A0 =
f x
x x x x x xn
( )
( ) ( ) ...... ( )
0
0 1 0 2 0
− − −
(51)
f(x1) = A1 (x1 – x0) (x1 – x2) ...... (x1 – xn)
∴ A1 =
f x
x x x x x xn
( )
( ) ( ) ...... ( )
1
1 0 1 2 1
− − −
(52)
  
Similarly, An =
f x
x x x x x x
n
n n n n
( )
( ) ( ) ...... ( )
− − − −
0 1 1
(53)
Substituting the values of A0, A1, ......, An in equation (50), we get
f(x) =
( ) ( ) ...... ( )
( ) ( ) ...... ( )
x x x x x x
x x x x x x
n
n
− − −
− − −
1 2
0 1 0 2 0
f(x0)
+
( ) ( ) ...... ( )
( ) ( ) ...... ( )
x x x x x x
x x x x x x
n
n
− − −
− − −
0 2
1 0 1 2 1
f(x1)
+ ...... +
( ) ( ) ...... ( )
( ) ( ) ...... ( )
x x x x x x
x x x x x x
n
n n n n
− − −
− − −
−
−
0 1 1
0 1 1
f(xn) (54)
This is called Lagrange’s Interpolation Formula. In eqn. (54), dividing
both sides by (x – x0) (x – x1) ..... (x – xn), Lagrange’s formula may also be written
as
340 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
f x
x x x x x xn
( )
( ) ( ) ...... ( )
− − −
0 1
=
f x
x x x x x x x x
n
( )
( ) ( ) ...... ( )
.
( )
0
0 1 0 2 0 0
1
− − − −
+
f x
x x x x x x x x
n
( )
( ) ( ) ...... ( )
.
( )
1
1 0 1 2 1 1
1
− − − −
+ ......
+
f x
x x x x x x x x
n
n n n n n
( )
( ) ( ) ...... ( )
.
( )
− − − −
−
0 1 1
1
. (55)
4.24.1 Another form of Lagrange’s Formula
§ Prove that the Lagrange’s formula can be put in the form
Pn(x) =
φ
φ
( ) ( )
( ) ( )
x f x
x x x
r
r r
r
n
− ′
=
∑0
where φ(x) = ( )
x xr
r
n
−
=
∏
0
and φ′(xr) =
d
dx
x
x xr
{ ( )}
φ
L
NM O
QP =
We have the Lagrange’s formula,
Pn(x) =
( ) ( ) ... ( ) ( ) ... ( )
( ) ( ) ... ( ) ( ) ... ( )
( )
x x x x x x x x x x
x x x x x x x x x x
f x
r r n
r r r r r r r n
r
r
n
− − − − −
− − − − −
− +
− +
=
∑ 0 1 1 1
0 1 1 1
0
=
φ ( ) ( )
( ) ( ) ... ( ) ( ) ... ( )
x
x x
f x
x x x x x x x x x x
r
r
r r r r r r r n
r
n
−
R
S
T
U
V
W − − − − −
R
S
|
T
|
U
V
|
W
|
− +
=
∑ 0 1 1 1
0
(56)
Now,
φ(x) = ( )
x xr
r
n
−
=
∏
0
= (x – x0)(x – x1) ..... (x – xr – 1) (x – xr) (x – xr + 1) ..... (x – xn)
∴ φ′(x) = (x – x1) (x – x2) ..... (x – xr) ..... (x – xn)
+ (x – x0) (x – x2) ..... (x – xr) ..... (x – xn) + .....
+ (x – x0) (x – x1) ..... (x – xr – 1) (x – xr + 1) ..... (x – xn) + .....
+ (x – x0) (x – x1) ..... (x – xr) ..... (x – xn – 1)
INTERPOLATION 341
⇒ φ′(xr) = [ ( )]
φ′ =
x x xr
= (xr – x0) (xr – x1) ..... (xr – xr – 1) (xr – xr + 1) ..... (xr – xn) (57)
Hence from (56),
Pn(x) =
φ
φ
( ) ( )
( ) ( )
x f x
x x x
r
r r
r
n
− ′
=
∑0
|using (57)
4.24.2 Algorithm
Step 01. Start of the program
Step 02. Input number of terms n
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. for i=0; in; i++
Step 06. nr=1
Step 07. dr=1
Step 08. for j=0; jn; j++
Step 09. if j !=i
a. nr=nr∗(x-ax[j])
b.dr∗(ax[i]-ax[j])
Step 10. End Loop j
Step 11. y+=(nr/dr)∗ay[i]
Step 12. End Loop i
Step 13. Print Output x, y
Step 14. End of Program
342 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4.24.3 Flow-chart
START
STOP
Get the value of n
Get the values of ax, ay
Get the values of x
y = 0
Loop for i = 0 to n
nr = dr = 1
Loop for j = 0 to n
nr = x – ax[j]
∗
dr = ax[i] – ax[j]
∗
End loop[j]
Print x, y as solution
B
B
No
Yes
Is
J ! = i
INTERPOLATION 343
/* ********************************************************************
4.24.4 Program to Implement Lagrange’s Method of Interpolation
********************************************************************** */
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... MAIN EXECUTION THREAD
void main()
{
//... Variable declaration Field
//... Integer Type
int n; //... Number of terms
int i,j; //... Loop Variables
//... Floating Type
float ax[100]; //... array limit 99
float ay[100]; //... array limit 99
float x=0; //... User Querry
float y=0; //... Initial value 0
float nr; //... Calc. section
float dr; //... Calc. section
//... Invoke Function Clear Screen
clrscr();
//... Input Section
printf(n Enter the number of terms - );
scanf(%d,n);
//... Input Sequel for array X
344 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(nn Enter the value in the form of x - );
//... Input Loop for X
for (i=0;in;i++)
{
printf (nn Enter the value of x%d - , i+1);
scanf(%f,ax[i]);
}
//... Input Sequel for array Y
printf(nn Enter the value in the form of y - );
//... Input Loop for Y
for (i=0;in;i++)
{
printf(nn Enter the value of y%d - , i+1);
scanf (%f,ay[i]);
}
//... Inputting the required value query
printf(n Enter the value of x for );
printf(n which you want the value of y - );
scanf(%f,x);
//... Calculation  Processing Section
for(i=0;in;i++)
{
nr=1;
dr=1;
for(j=0;jn;j++)
{
if(j!=i)
{
nr=nr*(x-ax[j]);
dr=dr*(ax[i]–ax[j]);
}
y+=(nr/dr)*ay[i];
}
}
INTERPOLATION 345
//... Output Section
printf(nn When x=%5.2f,y=%5.2f ,x,y);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch();
}
//... Termination of Main Execution Thread
4.24.5 Output
Enter the number of terms - 5
Enter the value in the form of x -
Enter the value of x1- 5
Enter the value of x2 - 7
Enter the value of x3 - 11
Enter the value of x4 - 13
Enter the value of x5 - 17
Enter the value in the form of y -
Enter the value of y1 - 150
Enter the value of y2 - 392
Enter the value of y3 - 1452
Enter the value of y4 - 2366
Enter the value of y5 - 5202
Enter the value of x for
Which you want the value of y - 9.0
When x = 9.00, y = 810.00
Press Enter to Exit
EXAMPLES
Example 1. Using Lagrange’s interpolation formula, find y(10) from the
following table:
x 5 6 9 11
y 12 13 14 16
Sol. Here x0 = 5, x1 = 6, x2 = 9, x3 = 11
f(x0) = 12, f(x1) = 13, f(x2) = 14, f(x3) = 16
346 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Lagrange’s formula is
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
1 2 3
0 1 0 2 0 3
0
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 3
2 0 2 1 2 3
2
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 1 2
3 0 3 1 3 2
3
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
6 9 11
5 6 5 9 5 11
12
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
5 9 11
6 5 6 9 6 11
13
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
5 6 11
9 5 9 6 9 11
14
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
5 6 9
11 5 11 6 11 9
16
= –
1
2
6 9 11
13
15
5 9 11
( ) ( ) ( ) ( ) ( ) ( )
x x x x x x
− − − + − − −
–
7
12
5 6 11
( ) ( ) ( )
x x x
− − −
+
4
15
5 6 9
( ) ( ) ( )
x x x
− − −
Putting x = 10, we get
f(10) = –
1
2
10 6 10 9 10 11
13
15
10 5 10 9 10 11
( ) ( ) ( ) ( ) ( ) ( )
− − − + − − −
–
7
12
10 5 10 6 10 11
4
15
10 5 10 6 10 9
( ) ( ) ( ) ( ) ( ) ( )
− − − + − − −
= 14.66666667
Hence,
y(10) = 14.66666667.
INTERPOLATION 347
Example 2. Compute the value of f(x) for x = 2.5 from the following table:
x: 1 2 3 4
f(x): 1 8 27 64
using Lagrange’s interpolation method.
Sol. Here x0 = 1, x1 = 2, x2 = 3, x3 = 4
f(x0) = 1, f(x1) = 8, f(x2) = 27, f(x3) = 64
Lagrange’s formula is
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
1 2 3
0 1 0 2 0 3
0
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 3
2 0 2 1 2 3
2
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 1 2
3 0 3 1 3 2
3
=
( ) ( ) ( )
( ) ( ) ( )
( )
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
− − −
− − −
+
− − −
− − −
2 3 4
1 2 1 3 1 4
1
1 3 4
2 1 2 3 2 4
8
+
( ) ( ) ( )
( ) ( ) ( )
x x x
− − −
− − −
1 2 4
3 1 3 2 3 4
(27)
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
1 2 3
4 1 4 2 4 3
64
= − − − − + − − −
1
6
2 3 4 4 1 3 4
( ) ( ) ( ) ( ) ( ) ( )
x x x x x x
–
27
2
1 2 4
( ) ( ) ( )
x x x
− − −
+
32
3
1 2 3
( ) ( ) ( )
x x x
− − −
Given x = 2.5, we get
f(2.5) = −
1
6
(2.5 – 2) (2.5 – 3) (2.5 – 4)
+ 4(2.5 – 1) (2.5 – 3) (2.5 – 4)
348 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
–
27
2
(2.5 – 1) (2.5 – 2) (2.5 – 4)
+
32
3
(2.5 – 1) (2.5 – 2) (2.5 – 3)
= 15.625
Hence, f(2.5) = 15.625.
Example 3. Find the cubic Lagrange’s interpolating polynomial from the
following data:
x: 0 1 2 5
f(x): 2 3 12 147.
Sol. Here x0 = 0, x1 = 1, x2 = 2, x3 = 5
f(x0) = 2, f(x1) = 3, f(x2) = 12, f(x3) = 147
Lagrange’s formula is
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
1 2 3
0 1 0 2 0 3
0
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 3
2 0 2 1 2 3
2
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 1 2
3 0 3 1 3 2
3
=
( ) ( ) ( )
( ) ( ) ( )
( )
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
− − −
− − −
+
− − −
− − −
1 2 5
0 1 0 2 0 5
2
0 2 5
1 0 1 2 1 5
3
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
0 1 5
2 0 2 1 2 5
12
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
0 1 2
5 0 5 1 5 2
147
= − − − + − −
1
5
1 2
3
4
2 5
( ) ( ) ( ) ( )
x x x x x – 2x(x – 1) (x – 5)
+
49
20
1 2
x x x
( ) ( )
− −
INTERPOLATION 349
= − − + − + − +
1
5
8 17 10
3
4
7 10
3 2 3 2
( ) ( )
x x x x x x – 2(x3 – 6x2 + 5x)
+
49
20
(x3 – 3x2 + 2x)
⇒ f(x) = x3 + x2 – x + 2
which is the required Lagrange’s interpolating polynomial.
Example 4. Find the unique polynomial P(x) of degree 2 such that:
P(1) = 1, P(3) = 27, P(4) = 64
Use the Lagrange method of interpolation.
Sol. Here, x0 = 1, x1 = 3, x2 = 4
f(x0) = 1, f(x1) = 27, f(x2) = 64
Lagrange’s interpolation formula is
P(x) =
( ) ( )
( ) ( )
( )
x x x x
x x x x
f x
− −
− −
1 2
0 1 0 2
0
+
− −
− −
( ) ( )
( ) ( )
( )
x x x x
x x x x
f x
0 2
1 0 1 2
1
+
− −
− −
( ) ( )
( ) ( )
( )
x x x x
x x x x
f x
0 1
2 0 2 1
2
=
( ) ( )
( ) ( )
( )
( ) ( )
( ) ( )
( )
x x x x
− −
− −
+
− −
− −
3 4
1 3 1 4
1
1 4
3 1 3 4
27 +
− −
− −
( ) ( )
( ) ( )
( )
x x
1 3
4 1 4 3
64
=
1
6
7 12
27
2
5 4
64
3
4 3
2 2 2
( ) ( ) ( )
x x x x x x
− + − − + + − +
= 8x2 – 19x + 12
Hence the required unique polynomial is
P(x) = 8x2 – 19x + 12.
Example 5. The function y = f(x) is given at the points (7, 3), (8, 1), (9, 1) and
(10, 9). Find the value of y for x = 9.5 using Lagrange’s interpolation formula.
Sol. We are given
x: 7 8 9 10
f(x): 3 1 1 9
Here, x0 = 7, x1 = 8, x2 = 9, x3 = 10
f(x0) = 3, f(x1) = 1, f(x2) = 1, f(x3) = 9
350 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Lagrange’s interpolation formula is
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
1 2 3
0 1 0 2 0 3
0
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 3
2 0 2 1 2 3
2
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 2
3 0 3 1 3 2
3
=
( ) ( ) ( )
( ) ( ) ( )
( )
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
− − −
− − −
+
− − −
− − −
8 9 10
7 8 7 9 7 10
3
7 9 10
8 7 8 9 8 10
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
7 8 10
9 7 9 8 9 10
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
− − −
− − −
7 8 9
10 7 10 8 10 9
9
= − − − − + − − −
1
2
8 9 10
1
2
7 9 10
( ) ( ) ( ) ( ) ( ) ( )
x x x x x x
–
1
2
7 8 10
( ) ( ) ( )
x x x
− − −
+
3
2
7 8 9
( ) ( ) ( )
x x x
− − − (58)
Given x = 9.5 in eqn. (58), we get
f(9.5) = − − − − + − − −
1
2
9 5 8 9 5 9 9 5 10
1
2
9 5 7 9 5 9 9 5 10
( . ) ( . ) ( . ) ( . ) ( . ) ( . )
–
1
2
9 5 7 9 5 8 9 5 10
3
2
9 5 7 9 5 8 9 5 9
( . ) ( . ) ( . ) ( . ) ( . ) ( . )
− − − + − − −
= 3.625.
Example 6. Use Lagrange’s interpolation formula to fit a polynomial to the
data:
x: – 1 0 2 3
ux: – 8 3 1 12
Hence or otherwise find the value of u1.
INTERPOLATION 351
Sol. Here,
x0 = – 1, x1 = 0, x2 = 2, x3 = 3
f(x0) = – 8, f(x1) = 3, f(x2) = 1, f(x3) = 12
Lagrange’s interpolation formula is
f(x) =
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
1 2 3
0 1 0 2 0 3
0
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
− − −
− − −
0 1 3
2 0 2 1 2 3
2
+
− − −
− − −
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
x x x x x x
f x
0 1 2
3 0 3 1 3 2
3
=
( ) ( ) ( )
( ) ( ) ( )
( )
( ) ( ) ( )
( ) ( ) ( )
( )
x x x x x x
− − −
− − − − − −
− +
+ − −
+ − −
0 2 3
1 0 1 2 1 3
8
1 2 3
0 1 0 2 0 3
3
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
+ − −
+ − −
1 0 3
2 1 2 0 2 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( )
x x x
+ − −
+ − −
1 0 2
3 1 3 0 3 2
12
=
2
3
2 3
1
2
1 2 3
x x x x x x
( ) ( ) ( ) ( ) ( )
− − + + − −
–
1
6
1 3 1 2
( ) ( ) ( ) ( )
x x x x x x
+ − + + −
=
2
3
5 6
1
2
4 6
3 2 3 2
( ) ( )
x x x x x x
− + + − + +
–
1
6
2 3 2
3 2 3 2
( ) ( )
x x x x x x
− − + − −
⇒ f(x) = 2x3 – 6x2 + 3x + 3
Hence, ux = 2x3 – 6x2 + 3x + 3 (59)
Given x = 1 in (59), we get
u1 = 2(1)3 – 6(1)2 + 3(1) + 3 = 2.
352 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 7. By means of Lagrange’s formula, prove that
(i) y0 =
1
2
(y y )
1
8
1
2
(y y )
1
2
(y y )
1 1 3 1 1 3
+ − − − −
L
NM O
QP
− − −
(ii) y 0.05 (y y ) 0.3 (y y ) 0.75 (y y )
3 0 6 1 5 2 4
= + − + + +
(iii) y1 = y3 – 0.3 (y5 – y– 3 ) + 0.2 (y–3 – y– 5 ).
Sol. (i) For the arguments – 3, – 1, 1, 3, the Lagrange’s formula is
yx =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x
y
x x x
y
+ − −
− + − − − −
+
+ − −
− + − − − −
− −
1 1 3
3 1 3 1 3 3
3 1 3
1 3 1 1 1 3
3 1
+
( ) ( ) ( )
( ) ( ) ( )
x x x
+ + −
+ + −
3 1 3
1 3 1 1 1 3
y1
+
( ) ( ) ( )
( ) ( ) ( )
x x x
y
+ + −
+ + −
3 1 1
3 3 3 1 3 1
3
=
( ) ( ) ( )
( )
( ) ( ) ( )
x x x
y
x x x
y
+ − −
−
+
+ − −
− −
1 1 3
48
3 1 3
16
3 1
+
( ) ( ) ( )
( )
x x x
y
+ + −
−
3 1 3
16
1
+
( ) ( ) ( )
x x x
y
+ + −
3 1 1
48
3 (60)
Given x = 0 in (60), we get
y0 = − + + −
− −
1
16
9
16
9
16
1
16
3 1 1 3
y y y y
=
1
2
1
8
1
2
1
2
1 1 3 1 1 3
( ) ( ) ( )
y y y y y y
+ − − − −
L
NM O
QP
− − −
(ii) For the arguments 0, 1, 2, 4, 5, 6, the Lagrange’s formula is
yx =
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
− − − − −
− − − − −
1 2 4 5 6
0 1 0 2 0 4 0 5 0 6
0
+
− − − − −
− − − − −
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
0 2 4 5 6
1 0 1 2 1 4 1 5 1 6
1
+
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
− − − − −
− − − − −
0 1 4 5 6
2 0 2 1 2 4 2 5 2 6
2
INTERPOLATION 353
+
− − − − −
− − − − −
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
0 1 2 5 6
4 0 4 1 4 2 4 5 4 6
4
+
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
− − − − −
− − − − −
0 1 2 4 6
5 0 5 1 5 2 5 4 5 6
5
+
− − − − −
− − − − −
( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )
x x x x x
y
0 1 2 4 5
6 0 6 1 6 2 6 4 6 5
6 (61)
Given x = 3 in (61), we get
y3 = 0.05 y0 – 0.3 y1 + 0.75 y2 + 0.75 y4 – 0.3 y5 + 0.05 y6
= 0.05 (y0 + y6) – 0.3(y1 + y5) + 0.75 (y2 + y4).
(iii) For the arguments – 5, – 3, 3, 5, the Lagrange’s formula is
yx =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
x x x
y
x x x
y
+ − −
− + − − − −
+
+ − −
− + − − − −
− −
3 3 5
5 3 5 3 5 5
5 3 5
3 5 3 3 3 5
5 3
+
( ) ( ) ( )
( ) ( ) ( )
x x x
y
+ + −
+ + −
5 3 5
3 5 3 3 3 5
3 +
( ) ( ) ( )
( ) ( ) ( )
x x x
y
+ + −
+ + −
5 3 3
5 5 5 3 5 3
5 (62)
Given x = 1 in eqn. (62), we get
y1 = – 0.2 y– 5 + 0.5y–3 + y3 – 0.3 y5
= y3 – 0.3 (y5 – y–3) + 0.2 (y–3 – y–5).
Example 8. If four equidistant values u–1, u0, u1, and u2 are given, a value is
interpolated by Lagrange’s formula, show that it may be written in the form
ux = yu0 + xu1 +
y(y 1)
3 !
2
−
Δ2u–1 +
x(x 1)
3 !
2
−
Δ2u0 where x + y = 1.
Sol. Δ2u1 = (E – 1)2u–1 = (E2 – 2E + 1) u–1 = u1 – 2u0 + u–1
Δ2u0 = (E2 – 2E + 1) u0 = u2 – 2u1 + u0
R.H.S. = (1 – x) u0 + xu1 +
( ) {( ) }
!
1 1 1
3
2
− − −
x x
(u1 – 2u0 + u–1)
+
x x
u u u
( )
!
( )
2
2 1 0
1
3
2
−
− + |where y = 1 – x
= −
− −
+
− − +
−
+ −
−
x x x
u
x x x
u
x x x
u
( ) ( ) ( ) ( ) ( ) ( ) ( )
1 2
6
2 1 1
2
1 2
2
1 0 1
+
( ) ( )
x x x
u
+ −
1 1
6
2 (63)
354 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Applying Lagrange’s formula for the arguments – 1, 0 , 1 and 2.
ux =
x x x
u
x x x
u
( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
− −
− − −
+
+ − −
− −
−
1 2
1 2 3
1 1 2
1 1 2
1 0
+
( ) ( )
( ) ( ) ( )
x x x
u
+ −
−
1 2
2 1 1
1 +
( ) ( )
( ) ( ) ( )
x x x
u
+ −
1 1
3 2 1
2
= −
− −
+
− − +
−
+ −
−
x x x
u
x x x
u
x x x
u
( ) ( ) ( ) ( ) ( ) ( ) ( )
1 2
6
2 1 1
2
1 2
2
1 0 1
+
( ) ( )
x x x
u
+ −
1 1
6
2 (64)
From (63) and (64), we observe that
R.H.S. = L.H.S.
Hence the result.
Example 9. Prove that Lagrange’s formula can be expressed in the form
P (x) 1 x x ... ... x
f(x ) 1 x x ... ... x
f(x ) 1 x x ... ... x
... ... ... ... ... ... ...
f(x ) 1 x x ... ... x
n
2 n
0 0 0
2
0
n
1 1 1
2
1
n
n n n
2
n
n
= 0 where Pn(x) = f(x).
Sol. Let Pn(x) = a0 + a1x + a2x2 + ... + anxn
Given x = x0, x1, ..., xn, and Pn(xi) = f(xi), i = 0, 1, 2, ..., n
f(x0) = a0 + a1x0 + a2x0
2 + ... + anx0
n
f(x1) = a0 + a1x1 + a2x1
2 + ... + anx1
n
... ... ... ... ... ...
f(xn) = a0 + a1xn + a2xn
2 + ... + anxn
n ... (n + 2)
Eliminating a0, a1, a2, ......, an from these equations, we get
−
−
−
−
P x x x x
f x x x x
f x x x x
f x x x x
n
n
n
n
n n n n
n
( ) ... ...
( ) ... ...
( ) 1 ... ...
... ... ... ... ... ... ...
( ) ... ...
1
1
1
2
0 0 0
2
0
1 1 1
2
1
2
= 0
INTERPOLATION 355
or
P x x x x
f x x x x
f x x x x
f x x x x
n
n
n
n
n n n n
n
( ) ... ...
( ) ... ...
( ) 1 ... ...
... ... ... ... ... ... ...
( ) ... ...
1
1
1
2
0 0 0
2
0
1 1 1
2
1
2
= 0
ASSIGNMENT 4.11
1. Apply Lagrange’s formula to find f(5) and f(6) given that
f(2) = 4, f(1) = 2, f(3) = 8, f(7) = 128
Explain why the result differs from those obtained by completing the series of powers
of 2?
2. Values of f(x) for values of x are given as
f(1) = 4, f(2) = 5, f(7) = 5, f(8) = 4
Find f(6) and also the value of x for which f(x) is maximum or minimum.
3. Find by Lagrange’s formula, the value of
(i) u5 if u0 = 1, u3 = 19, u4 = 49, u6 = 181
(ii) u4 if u3 = 16, u5 = 36, u7 = 64, u8 = 81 and u9 = 100.
4. Using Lagrange’s formula, find the values of
(i) y5 if y1 = 4, y3 = 120, y4 = 340, y5 = 2544
(ii) y0 if y–30 = 30, y–12 = 34, y3 = 38, y18 = 42.
5. Find the value of tan 33° by Lagrange’s formula if
tan 30° = 0.5774, tan 32° = 0.6249,
tan 35° = 0.7002, tan 38° = 0.7813.
6. Use Lagrange’s formula to find f(6) from the following table:
x: 2 5 7 10 12
f(x): 18 180 448 1210 2028.
7. Apply Lagrange’s formula to find f(15), if
x: 10 12 14 16 18 20
f(x): 2420 1942 1497 1109 790 540.
8. If y0, y1, ..., y9 are consecutive terms of a series, prove that
y5 =
1
70
[56(y4 + y6) – 28(y3 + y7) + 8(y2 + y8) – (y1 + y9)]
356 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
9. Using the following table, find f(x) as a polynomial in x:
x: – 1 0 3 6 7
f(x): 3 – 6 39 822 1611.
10. If y(1) = – 3, y(3) = 9, y(4) = 30, and y(6) = 132, find the four-point
Lagrange interpolation polynomial that takes the same values as the function y at the
given points.
11. Given the table of values
x: 150 152 154 156
y = x : 12.247 12.329 12.410 12.490
Evaluate 155 using Lagrange’s interpolation formula.
12. Applying Lagrange’s formula, find a cubic polynomial which approximates the follow-
ing data:
x: – 2 – 1 2 3
y(x): – 12 – 8 3 5.
13. Given the table of values
x: 50 52 54 56
x
3 : 3.684 3.732 3.779 3.825
Use Lagrange’s formula to find x when x
3
= 3.756.
14. Find the equation of the cubic curve that passes through the points (4, – 43), (7, 83),
(9, 327) and (12, 1053).
15. Values of f(x) are given at a, b, and c. Show that the maximum is obtained by
x =
f a b c f b c a f c a b
f a b c f b c a f c a b
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
2 2 2 2 2 2
− + − + −
− + − + −
.
16. The following table gives the viscosity of an oil as a function of temperature. Use
Lagrange’s formula to find the viscosity of oil at a temperature of 140°.
Temp° : 110 130 160 190
Viscosity: 10.8 8.1 5.5 4.8
17. Certain corresponding values of x and log10x are given below:
x: 300 304 305 307
log10 x: 2.4771 2.4829 2.4843 2.4871
Find log10 310 by Lagrange’s formula.
18. The following table gives the normal weights of babies during the first 12 months of life:
Age in months: 0 2 5 8 10 12
Weight in lbs: 7.5 10.25 15 16 18 21
INTERPOLATION 357
19. Given f(0) = – 18, f(1) = 0, f(3) = 0, f(5) = – 248, f(6) = 0, f(9) = 13104; find f(x).
20. (i) Determine by Lagrange’s formula, the percentage number of criminals under 35 years:
Age % number of criminals
under 25 years 52
under 30 years 67.3
under 40 years 84.1
under 50 years 94.4
(ii) Find a Lagrange’s interpolating polynomial for the data given below:
x0 = 1, x1 = 2.5, x2 = 4 and x3 = 5.5
f(x0) = 4, f(x1) = 7.5, f(x2) = 13 and f(x3) = 17.5
Also, find the value of f(5).
4.25 ERROR IN LAGRANGE’S INTERPOLATION FORMULA
Remainder,
y(x) – Ln(x) = Rn(x) =
Πn x
n
+
+
1
1
( )
( ) !
y(n+1) (ξ) , a  ξ  b
where Lagrange’s formula is for the class of functions having continuous
derivatives of order upto (n + 1) on [a, b].
Quantity EL = max.
[ , ]
a b
| Rn(x) | may be taken as an estimate of error.
Let us assume
| y(n+1) (ξ) | ≤ Mn+1, a ≤ ξ ≤ b
then, EL ≤
Mn
n
+
+
1
1
( ) !
max.
[ , ]
a b
| Πn+1(x) |.
EXAMPLES
Example 1. Show that the truncation error of quadratic interpolation in an
equidistant table is bounded by
h
9 3
3
max | f ″′(ξ) | where h is the step size and
f is the tabulated function.
358 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Let xi–1, xi, xi+1 denote three consecutive equispaced points with step size h.
The truncation error of the quadratic Lagrange interpolation is bounded
by
| E2(f; x) | ≤
M3
6
max | (x – xi–1)(x – xi)(x – xi+1) |
where xi–1 ≤ x ≤ xi+1 and M3 = max
a x b
≤ ≤
| f ″′(x) |
Substitute t =
x x
h
i
−
then,
x – xi–1 = x – (xi – h) = x – xi + h = th + h = (t + 1)h
x – xi+1 = x – (xi + h) = x – xi – h = th – h = (t – 1)h
and (x – xi–1)(x – xi)(x – xi+1) = (t + 1) t(t – 1)h3 = t(t2 – 1)h3 = g(t)
Setting g ′(t) = 0, we get
3t2 – 1 = 0 ⇒ t = ±
1
3
.
For both these values of t, we obtain
max | (x – xi–1)(x – xi)(x – xi+1) | = h3
max
− ≤ ≤
1 1
t
| t(t2 – 1) | =
2
3 3
3
h
Hence, the truncation error of the quadratic interpolation is bounded by
| E2(f; x) | ≤
h3
3
9 3
M
or, | E2(f; x) | ≤
h3
9 3
max | f ″′(ξ) |.
Example 2. Determine the step size that can be used in the tabulation of
f(x) = sin x in the interval 0,
4
π
L
NM O
QP at equally spaced nodal points so that the
truncation error of the quadratic interpolation is less than 5 × 10–8.
Sol. From Example 1, we have
| E2(f; x) | ≤
h3
9 3
M3
For f(x) = sin x, we get f ″′(x) = – cos x
and M3 = max |cos |
/
0 4
≤ ≤
x
x
π
= 1
INTERPOLATION 359
Hence the step size h is given by
h3
9 3
≤ 5 × 10–8 or h ≈ 0.009
Example 3. Using Lagrange’s interpolation formula, find the value of sin
π
6
F
HG I
KJ
from the following data:
x: 0 π/4 π/2
y = sin x: 0 0.70711 1.0
Also estimate the error in the solution.
Sol. sin
π
6
F
HG I
KJ =
π π π
π π π
6
0
6 2
4
0
4 2
−
F
HG I
KJ −
F
HG I
KJ
−
F
HG I
KJ −
F
HG I
KJ
(0.70711) +
π π π
π π π
6
0
6 4
2
0
2 4
−
F
HG I
KJ −
F
HG I
KJ
−
F
HG I
KJ −
F
HG I
KJ
(1)
=
8
9
(0.70711) –
1
9
=
4 65688
9
.
= 0.51743
Now, y(x) = sin x, y′(x) = cos x, y″(x) = – sin x, y′″(x) = – cos x
Hence, | y′″ (ξ) |  1
when x = π/6.
| Rn(x) | ≤
π π π π π
6
0
6 4 6 2
3
−
F
HG I
KJ −
F
HG I
KJ −
F
HG I
KJ
!
= 0.02392
which agrees with the actual error in problem.
4.26 EXPRESSION OF RATIONAL FUNCTION AS A SUM OF PARTIAL
FRACTIONS
Let f(x) =
3 1
1 2 3
2
x x
x x x
+ +
− − −
( )( )( )
Consider φ(x) = 3x2 + x + 1 and tabulate its values for x = 1, 2, 3, we get
x: 1 2 3
3x2 + x + 1: 5 15 31
360 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Using Lagrange’s interpolation formula, we get
f(x) =
( )( )
( )( )
x x
− −
− −
2 3
1 2 1 3
(5) +
( )( )
x x
− −
−
1 3
1
(15) +
( )( )
x x
− −
1 2
2
(31)
=
5
2
(x – 2)(x – 3) – 15 (x – 1)(x – 3) +
31
2
(x – 1)(x – 2)
=
5
2 1
( )
x −
–
15
2
x −
+
31
2 3
( )
x −
.
4.27 INVERSE INTERPOLATION
The process of estimating the value of x for the value of y not in the table is
called inverse interpolation.
When values of x are unevenly spaced, Lagrange’s method is used by
interchanging x and y.
EXAMPLES
Example 1. Values of elliptic integral F(θ) = 2
0
θ
z d
1 cos2
θ
θ
+
are given below:
θ: 21° 23° 25°
F(θ): 0.3706 0.4068 0.4433
Find θ for which F(θ) = 0.3887.
Sol. By inverse interpolation formula
θ =
(F F )(F F )
(F F )(F F )
1 2
0 1 0 2
− −
− −
θ0 +
(F F )(F F )
(F F )(F F )
0 2
1 0 1 2
− −
− −
θ1 +
(F F )(F F )
(F F )(F F )
0 1
2 0 2 1
− −
− −
θ2
=
( . ) ( . )
( . )( . )
0 0 4068 0 0 4433
0 0 4068 0 0 4433
.3887 .3887
.3706 .3706
− −
− −
(.3706) + ... + ...
= 7.884 + 17.20 – 3.087 = 22°.
Example 2. From the given table:
x: 20 25 30 35
y(x): 0.342 0.423 0.5 0.65
Find the value of x for y(x) = 0.390.
INTERPOLATION 361
Sol. By inverse interpolation formula,
x =
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
y y y y y y
y y y y y y
x
y y y y y y
y y y y y y
x
− − −
− − −
+
− − −
− − −
1 2 3
0 1 0 2 0 3
0
0 2 3
1 0 1 2 1 3
1
+
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
y y y y y y
y y y y y y
x
y y y y y y
y y y y y y
x
− − −
− − −
+
− − −
− − −
0 1 3
2 0 2 1 2 3
2
0 1 2
3 0 3 1 3 2
3
=
(. . ) (. . ) (. . )
(. . ) (. . ) (. . )
( )
39 423 39 5 39 65
342 423 342 5 342 65
20
− − −
− − −
+
(. . ) (. . ) (. . )
(. . ) )(. . ) (. . )
( )
39 342 39 5 39 65
423 342 423 5 423 65
25
− − −
− − −
+
(. . ) (. . ) (. . )
(. . ) (. . ) (. . )
( )
39 342 39 423 39 65
5 342 5 423 5 65
30
− − −
− − −
+
(. . ) (. . ) (. . )
(. . ) (. . ) (. . )
( )
39 342 39 423 39 5
65 342 65 423 65 5
35
− − −
− − −
= 22.84057797.
4.28 DIVIDED DIFFERENCES
Lagrange’s interpolation formula has the disadvantage that if another
interpolation point were added, the interpolation coefficient will have to be
recomputed.
We therefore seek an interpolation polynomial which has the property that
a polynomial of higher degree may be derived from it by simply adding new
terms.
Newton’s general interpolation formula is one such formula and it employs
divided differences.
If (x0, y0), (x1, y1), (x2, y2) ...... be given points then the first divided difference
for the arguments x0, x1 is defined by
Δ
|
x1
y0 = [x0, x1] =
y y
x x
1 0
1 0
−
−
Similarly, [x1, x2] =
y y
x x
2 1
2 1
−
−
and so on.
The second divided difference for x0, x1, x2 is defined as
Δ
|
,
2
1 2
x x
y0 = [x0, x1, x2] =
[ , ] [ , ]
x x x x
x x
1 2 0 1
2 0
−
−
362 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Third divided difference for x0, x1, x2, x3 is defined as
[x0, x1, x2, x3] =
[ , , ] [ , , ]
x x x x x x
x x
1 2 3 0 1 2
3 0
−
−
and so on.
4.29 PROPERTIES OF DIVIDED DIFFERENCES
1. The divided differences are symmetrical in their arguments, i.e.,
independent of the order of arguments.
[x0, x1] =
y
x x
1
1 0
−
+
y
x x
0
0 1
−
= [x1, x0]
Also, [x0, x1, x2] =
y
x x x x
0
0 1 0 2
( )( )
− −
+
y
x x x x
1
1 0 1 2
( )( )
− −
+
y
x x x x
2
2 0 2 1
( )( )
− −
= [x2, x0, x1] or [x1, x2, x0]
2. The nth divided differences of a polynomial of nth degree are
constant.
Let the arguments be equally spaced so that
x1 – x0 = x2 – x1 = ..... = xn – xn–1 = h
then, [x0, x1] =
y y
x x
1 0
1 0
−
−
=
Δy
h
0
[x0, x1, x2] =
[ , ] [ , ]
( )
x x x x
x x
1 2 0 1
2 0
−
−
=
1
2h
Δ Δ
y
h
y
h
1 0
−
F
HG I
KJ =
1
2
1
2
!
.
h
(Δ2 y0)
In general,
[x0, x1, x2, ......, xn] =
1
n !
.
1
hn
Δny0
If tabulated function is a nth degree polynomial. ∴ Δny0 = constant
∴ nth divided differences will also be constant.
INTERPOLATION 363
4.30 NEWTON’S GENERAL INTERPOLATION FORMULA
O R
NEWTON’S DIVIDED DIFFERENCE INTERPOLATION FORMULA
Let y0, y1, ......, yn be the values of y = f(x) corresponding to the arguments x0, x1,
......, xn then from the definition of divided differences, we have
[x, x0] =
y y
x x
−
−
0
0
so that, y = y0 + (x – x0) [x, x0] (65)
Again, [x, x0, x1] =
[ , ] [ , ]
x x x x
x x
0 0 1
1
−
−
which gives, [x, x0] = [x0, x1] + (x – x1) [x, x0, x1] (66)
From (65) and (66),
y = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x, x0, x1] (67)
Also [x, x0, x1, x2] =
[ , , ] [ , , ]
x x x x x x
x x
0 1 0 1 2
2
−
−
which gives [x, x0, x1] = [x0, x1, x2] + (x – x2) [x, x0, x1, x2] (68)
From (67) and (68),
y = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x0, x1, x2]
+ (x – x0) (x – x1) (x – x2) [x, x0, x1, x2]
Proceeding in this manner, we get
y = f(x) = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x0, x1, x2]
+ (x – x0) (x – x1) (x – x2) [x0, x1, x2, x3]
+ ..... + (x – x0) (x – x1) (x – x2)
..... (x – xn–1) [x0, x1, x2, x3, ......, xn]
+ (x – x0) (x – x1) (x – x2)
..... (x – xn) [x, x0, x1, x2, ......, xn]
which is called Newton’s general interpolation formula with divided differences,
the last term being the remainder term after (n + 1) terms.
364 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Newton’s divided difference formula can also be written as
y = y0 + (x – x0) Δ
| y0 + (x – x0) (x – x1) Δ
|
2y0
+ (x – x0) (x – x1) (x – x2) Δ
|
3y0
+ (x – x0) (x – x1) (x – x2) (x – x3) Δ
|
4y0
+ ..... + (x – x0) (x – x1) ..... (x – xn–1) Δ
|
ny0
4.31 RELATION BETWEEN DIVIDED DIFFERENCES AND ORDINARY
DIFFERENCES
Let the arguments x0, x1, x2, ....., xn be equally spaced such that
x1 – x0 = x2 – x1 = ... = xn – xn–1 = h
∴ x1 = x0 + h
x2 = x0 + 2h
.........
xn = x0 + nh
Now Δ
|
x1
f(x0) =
f x f x
x x
( ) ( )
1 0
1 0
−
−
=
f x h f x
h
( ) ( )
0 0
+ −
=
Δ f x
h
( )
0
(69)
|
Δ2
1 2
x x
f(x0) =
1
2 0
x x
−
[f(x1, x2) – f(x0, x1)]
=
1
2 0
x x
−
f x f x
x x
f x f x
x x
( ) ( ) ( ) ( )
2 1
2 1
1 0
1 0
−
−
−
−
−
L
NM O
QP
=
1
2
2
0 0 0 0
h
f x h f x h
h
f x h f x
h
( ) ( ) ( ) ( )
+ − +
−
+ −
L
NM O
QP
=
1
2
2 2
2 0 0 0
h
f x h f x h f x
[ ( ) ( ) ( )]
+ − + +
=
Δ2
0
2
2
f x
h
( )
! .
(70)
INTERPOLATION 365
|
, ,
Δ3
1 2 3
x x x
f(x0) =
1
2 0
x x
−
[f(x1, x2, x3) – f(x0, x1, x2)]
=
1
3h
Δ Δ
2
1
2
2
0
2
2 2
f x
h
f x
h
( ) ( )
−
L
NMM
O
QPP =
Δ Δ
2
1
2
0
3
6
f x f x
h
( ) ( )
−
[From (69)]
=
Δ3
0
3
3
f x
h
( )
!
... ... ...
Δ
|
,.....,
n
x xn
1
f(x0) =
Δn
n
f x
n h
( )
!
0
.
4.32 MERITS AND DEMERITS OF LAGRANGE’S FORMULA
1. The formula is simple and easy to remember.
2. There is no need to construct the divided difference table and we can directly
interpolate the unknown value with the help of given observations.
3. The calculations in the formula are more complicated than in the divided
difference formula.
4. The application of the formula is not speedy
5. There is always a chance of commiting some error due to a number of (+)ve
and (–)ve sign in the denominator and numerator of each term.
6. The calculations provide no check whether the functional values used are
taken correctly or not, whereas the differences used in a difference formula
provide a check on the functional values.
EXAMPLES
Example 1. Construct a divided difference table for the following:
x: 1 2 4 7 12
f(x): 22 30 82 106 216.
366 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol.
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x) Δ
| 4f(x)
1 22
30 22
2 1
−
−
= 8
2 30
26 8
4 1
−
−
= 6
82 30
4 2
−
−
= 26
− −
−
3 6 6
7 1
.
= – 1.6
4 82
8 26
7 2
−
−
= – 3.6
0 6
12 1
.535 1.
+
−
= 0.194
106 82
7 4
−
−
= 8
175 3 6
12 2
. .
+
−
= 0.535
7 106
22 8
12 4
−
−
= 1.75
216 106
5
−
= 22
12 216
Example 2. (i) Find the third divided difference with arguments 2, 4, 9, 10 of
the function f(x) = x3 – 2x.
(ii) If f(x) =
1
x2 , find the first divided differences f(a, b), f(a, b, c), f(a, b, c, d).
(iii) If f(x) = g(x) h(x), prove that
f(x1, x2) = g(x1) h(x1, x2) + g(x1, x2) h (x2).
Sol. (i)
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x)
2 4
56 4
4 2
26
−
−
=
4 56
131 26
9 2
15
−
−
=
711 56
9 4
131
−
−
=
23 15
10 2
1
−
−
=
9 711
269 131
10 4
23
−
−
=
980 711
10 9
269
−
−
=
10 980
Hence, the third divided difference is 1.
INTERPOLATION 367
(ii)
x f(x) =
1
x2
Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x)
a
1
2
a
1 1
2 2
b a
b a
−
F
HG I
KJ
−
= –
a b
a b
+
F
HG I
KJ
2 2
b
1
2
b
ab bc ca
a b c
+ +
2 2 2
−
+
F
HG I
KJ
b c
b c
2 2 –
abc acd abd bcd
a b c d
+ + +
F
HG I
KJ
2 2 2 2
c
1
2
c
bc cd db
b c d
+ +
2 2 2
−
+
F
HG I
KJ
c d
c d
2 2
d
1
2
d
From the above divided difference table, we observe that the first divided
differences,
f(a, b) = –
a b
a b
+
F
HG I
KJ
2 2
f(a, b, c) =
ab bc ca
a b c
+ +
2 2 2
and f(a, b, c, d) = –
abc acd abd bcd
a b c d
+ + +
F
HG I
KJ
2 2 2 2
(iii) R.H.S. = g(x1)
h x h x
x x
g x g x
x x
h x
( ) ( ) ( ) ( )
( )
2 1
2 1
2 1
2 1
2
−
−
+
−
−
=
1
2 1
x x
−
[{g(x1) h(x2) – g(x1)h(x1)}
+ {g(x2) h(x2) – g(x1) h(x2)}]
=
g x h x g x h x
x x
( ) ( ) ( ) ( )
2 2 1 1
2 1
−
−
= Δ
|
x2
g(x1) h(x1) = Δ
|
x2
f(x1) = f(x1, x2) = L.H.S.
Hence the result.
368 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 3. (i) Prove that
Δ
|
bcd
3 1
a
1
abcd
F
HG I
KJ = −
(ii) Show that the nth divided differences
[x0, x1, ....., xn] for ux =
1
x
is
( 1)
x x ..... x
n
0 1 n
−
L
NM O
QP.
Sol. (i)
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x)
a
1
a
1 1
b a
b a
−
−
= –
1
ba
b
1
b
(– 1)2
1
abc
1 1
c b
c b
−
−
= –
1
bc
(– 1)3
1
abcd
c
1
c
(– 1)2
1
bdc
1 1
d c
d c
−
−
= –
1
dc
d
1
d
From the table, we observe that
Δ
| 3
bcd
1
a
F
HG I
KJ = –
1
abcd
. (71)
(ii) From (71), we see that
Δ
| 3
bcd
1
a
F
HG I
KJ = –
1
abcd
= (– 1)3 f(a, b, c, d)
∴ In general,
Δ
|
, , .....,
n
x x xn
x
0 1
1
0
F
HG
I
KJ = (– 1)n f (x0, x1, x2, ....., xn) =
( )
.....
−
L
NM O
QP
1
0 1 2
n
n
x x x x
.
INTERPOLATION 369
Example 4. Using Newton’s divided difference formula, find a polynomial
function satisfying the following data:
x: – 4 – 1 0 2 5
f(x): 1245 33 5 9 1335
Hence find f(1).
Sol. The divided difference table is:
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x) Δ
| 4f(x)
– 4 1245
– 404
– 1 33 94
– 28 – 14
0 5 10 3
2 13
2 9 88
442
5 1335
Applying Newton’s divided difference formula
f(x) = 1245 + (x + 4) (– 404) + (x + 4) (x + 1) 94
+ (x + 4) (x + 1) (x – 0) (– 14) + (x + 4)(x + 1)x(x – 2)(3)
= 3x4 – 5x3 + 6x2 – 14x + 5
Hence, f(1) = 3 – 5 + 6 – 14 + 5 = – 5.
Example 5. By means of Newton’s divided difference formula, find the values
of f(8) and f(15) from the following table:
x: 4 5 7 10 11 13
f(x): 48 100 294 900 1210 2028.
Sol. Newton’s divided difference formula, using the arguments 4, 5, 7, 10, 11,
and 13 is
f(x) = f(4) + (x – 4) Δ
|
5
f(4) + (x – 4)(x – 5) Δ
|
,
5 7
f(4)
+ (x – 4)(x – 5)(x – 7) Δ
|
,
3
5 7, 10
f(4)
+ (x – 4)(x – 5)(x – 7)(x – 10) Δ
|
, ,
4
5 7, 10 11
f(4)
+ (x – 4)(x – 5)(x – 7) (x – 10)(x – 11) Δ
|
, , ,
4
5 7, 10 11 13
f(4) (72)
370 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The divided difference table is as follows:
x f(x) Δ
| f(x) Δ
| 2 f(x) Δ
| 3f(x) Δ
| 4f(x)
4 48
100 48
5 4
−
−
= 52
5 100
97 52
7 4
−
−
= 15
294 100
7 5
97
−
−
=
21 15
10 4
−
−
= 1
7 294
202 97
10 5
21
−
−
= 0
900 294
10 7
202
−
−
=
27 21
11 5
1
−
−
=
10 900
310 202
11 7
27
−
−
= 0
1210 900
11 10
310
−
−
=
33 27
13 7
−
−
= 1
11 1210
409 310
13 10
−
−
= 33
2028 1210
13 11
409
−
−
=
13 2028
Substituting the values of the divided differences in (72),
f(x) = 48 + (x – 4) × 52 + (x – 4)(x – 5) × 15 + (x – 5)(x – 4)(x – 7) × 1
= 48 + 52(x – 4) + 15(x – 4)(x – 5) + (x – 4)(x – 5)(x – 7)
Putting x = 8 and 15
f(8) = 48 + 52 × 4 + 15 × 4 × 3 + 4 × 3 × 1
= 48 + 208 + 180 + 12 = 448
f(15) = 48 + 52 × 11 + 15 × 11 × 10 + 11 × 10 × 8
= 48 + 572 + 1650 + 880 = 3150.
Example 6. Given the following table, find f(x) as a polynomial in powers of
(x – 5)
x: 0 2 3 4 7 9
f(x): 4 26 58 112 466 922.
INTERPOLATION 371
Sol. The divided difference table is:
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x)
0 4
11
2 26 7
32 1
3 58 11
54 1
4 112 16
118 1
7 466 22
228
9 922
By Newton’s divided difference formula, we get
f(x) = 4 + (x – 0)(11) + (x – 0)(x – 2)7 + (x – 0)(x – 2)(x – 3) 1
= x3 + 2x2 + 3x + 4
In order to express it in power of (x – 5), we use synthetic division, as
5 1 2 3 4
5 35 190
5 1 7 38 194
5 60
5 1 12 98
5
1 17
∴ 2x2 + x3 + 3x + 4 = (x – 5)3 + 17(x – 5)2 + 98 (x – 5) + 194.
Example 7. Given
log10 654 = 2.8156, log10 658 = 2.8182, log10 659 = 2.8189 and
log10 661 = 2.8202, find by the divided difference formula the value of log10 656.
Sol. For the arguments 654, 658, 659, and 661, the divided difference formula
is
f(x) = f(654) + (x – 654) Δ
|
658
f(654)
+ (x – 655) (x – 658) Δ
|
,
658 659
2
f(654)
+ (x – 654) (x – 658) (x – 659) Δ
|
, ,
658 659 661
3 f(654) (73)
372 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The divided difference table is as follows:
x 105 f(x) 105
Δ
| f(x) 105
Δ
| 2f(x) 105 Δ
| 3 f(x)
654 281560
260
4
= 65
658 281820
70 65
5
−
= 1
70
1
= 70
− −
166 1
7
.
= – 0.38
659 281890
65 70
3
−
= – 1.66
130
2
= 65
661 282020
From (73),
105f(x) = 281560 + (x – 654) (65) + (x – 654) (x – 658) (1)
+ (x – 654) (x – 658) (x – 659) (0.38)
Putting x = 656, we get
105 f(656) = 281560 + (2) (65) + (2) (– 2) (1)
+ (2) (– 2) (– 3) (.38)
= 281690.56
∴ f(656) = 2.8169056
Hence, log10 656 = 2.8169056.
Example 8. Find f ′(10) from the following data:
x: 3 5 11 27 34
f(x): – 13 23 899 17315 35606.
INTERPOLATION 373
Sol. The divided difference table is:
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x) Δ
| 4f(x)
3 – 13
18
5 23 16
146 1
11 899 40 0
1026 1
27 17315 69
2613
34 35606
By Newton’s divided difference formula,
f(x) = – 13 + (x – 3) 18 + (x – 3)(x – 5)16 + (x – 3)(x – 5)(x – 11)1
∴ f ′(x) = 3x2 – 6x – 7
Put x = 10, f ′(10) = 3(10)2 – 6(10) – 7 = 233.
Example 9. Given that
log10 2 = 0.3010, log10 3 = 0.4771, log10 7 = 0.8451,
find the value of log10 33.
Sol. log 30 = 1.4771,
log 32 = 5 log 2 = 5 × 0.3010 = 1.5050
log 36 = 2 (log 2 + log 3) = 2 × (0.3010 + 0.4771) = 1.5562
log 35 = log
70
2
= log 70 – log 2 = 1.8451 – 0.3010 = 1.5441.
The divided difference table is as follows:
x 104 log10 x 104 Δ
| log10 x 104 Δ
| 2 log10 x 104Δ
| 3log10 x
30 14771
279
2
139 5
= .
32 15050 –
9 2
5
184
.
.
= −
391
3
130 3
= . –
0 48
6
0 08
.
.
= −
35 15441 –
9 3
7
2 32
.
.
= −
121
1
= 121
36 15562
374 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Applying Newton’s divided difference formula, we get
104 log10 x = 14771 + (x – 30) (139.5) + (x – 30)(x – 32) (– 1.84)
+ (x – 30)(x – 32)(x – 35)(– 0.08)
Putting x = 33
104 log10 33 = 14771 + 3 × 139.5 + 3 × 1 × (– 1.84) + 3 × 1 × (– 2)(– 0.08)
= 14771 + 418.5 – 5.52 + 0.48 = 15184.46
∴ log10 33 = 1.5184.
Example 10. Find approximately the real root of the equation x3 – 2x – 5 = 0.
Sol. Let f(x) = x3 – 2x – 5.
The real root of f(x) = 0 lies between 2 and 2.1.
∴ Values of f(x) at x = 1.9, 2, 2.1, 2.2 are – 1.941, – 1.000, 0.061, 1.248,
respectively.
Let
x: – 1.941 – 1.000 0.061 1.248
ux: 1.9 2.0 2.1 2.2
We have to find ux at u = 0.
The divided difference table is:
x ux Δ
| ux Δ
| 2 ux Δ
| 3 ux
– 1.941 1.9
0.1062699
– 1.000 2.0 – 0.0060035
0.0942507 0.0004869
0.061 2.1 – 0.0044505
0.0842459
1.248 2.2
Applying the Newton-divided difference formula,
ux = 1.9 + (x + 1.941) × 0.1062699 + (x + 1.941)(x + 1)(– 0.0060035)
+ (x + 1.941)(x + 1)(x – 0.061) × 0.0004869.
Given x = 0
u0 = 1.9 + 0.2062698 – 0.0116527 – 0.0000576 = 2.0945595
∴ The required root is 2.0945595.
INTERPOLATION 375
Example 11. The mode of a certain frequency curve y = f(x) is very near to x = 9
and the values of frequency density f(x) for x = 8.9, 9.0 and 9.3 are respectively
equal to 0.30, 0.35, and 0.25. Calculate the approximate value of mode.
Sol. The divided difference table is as follows:
x 100 f(x) 100Δ
| f(x) 100 Δ
| 2f(x)
8.9 30
5
0 9
50
9
.
=
9.0 35 –
350
9 0 4
3500
36
×
= −
.
–
10
0 3
100
3
.
= −
9.3 25
Applying Newton’s divided difference formula
100 f(x) = 30 + (x – 8.9) ×
50
9
+ (x – 8.9)(x – 9) −
F
HG I
KJ
3500
36
= – 97.222 x2 + 1745.833x – 1759.7217.
∴ f(x) = – .9722x2 + 17.45833x – 17.597217
f ′(x) = – 1.9444 x + 17.45833
Given f ′(x) = 0, we get
x =
17 45833
19444
.
.
= 8.9788
Also,
f ″(x) = – 1.9444 i.e., (–)ve
∴ f(x) is maximum at x = 8.9788
Hence, the mode is 8.9788.
Example 12. The following are the mean temperatures (°F) on three days, 30
days apart during summer and winter. Estimate the approximate dates and
values of maximum and minimum temperature.
376 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Summer Winter
Day Date Temp. Date Temp.
0 15 June 58.8 16 Dec. 40.7
30 15 July 63.4 15 Jan. 38.1
60 14 August 62.5 14 Feb. 39.3
Sol. The divided difference table for summer is:
x f(x) Δ
| f(x) Δ
| 2f(x)
0 58.8
4.6
1 63.4 – 2.75
– 0.9
2 62.5
∴ f(x) = 58.8 + (x – 0)(4.6) + (x – 0)(x – 1)(– 2.75)
= – 2.75 x2 + 7.35 x + 58.8
For maximum and minimum of f(x), we have
f ′ (x) = 0
⇒ – 5.5 x + 7.35 = 0 ⇒ x = 1.342
Again, f ″ (x) = – 5.5  0
∴ f(x) is maximum at x = 1.342
Since unit 1 ≡ 30 days
∴ 1.342 ≡ 30 × 1.342 = 40.26 days
∴ The maximum temperature was on 15 June + 40 days, i.e., on 25 July,
and the value of the maximum temperature is
[f(x)]max. = [f(x)]1.342 = 63.711°F. approximately.
The divided difference table for winter is as follows:
x f(x) Δ
| f(x) Δ
| 2f(x)
0 40.7
– 2.6
1 38.1 1.9
1.2
2 39.3
INTERPOLATION 377
∴ f(x) = 40.7 + (x – 0) (– 2.6) + x(x – 1)(1.9)
= 1.9x2 – 4.5x + 40.7
For f(x) to be maximum or minimum, we have f ′(x) = 0
3.8x – 4.5 = 0 ⇒ x = 1.184
Again, f ″ (x) = 3.8  0
∴ f(x) is minimum at x = 1.184
Again, unit 1 ≡ 30 days
∴ 1.184 ≡ 30 × 1.184 = 35.52 days
∴ The minimum temperature was on 16 Dec. + 35.5 days, i.e., at mid-
night on the 20th of January and its value can be obtained similarly.
[f(x)]min. = [f(x)]1.184 = 63.647°F approximately.
Example 13. Using Newton’s divided difference formula, calculate the value
of f(6) from the following data:
x: 1 2 7 8
f(x): 1 5 5 4.
Sol. The divided difference table is:
x f(x) Δ
| f(x) Δ
| 2f(x) Δ
| 3f(x)
1 1
4
2 5 −
2
3
0
1
14
7 5 −
1
6
– 1
8 4
Applying Newton’s divided difference formula,
f(x) = 1 + (x – 1) (4) + (x – 1) (x – 2) −
F
HG I
KJ
2
3
+ (x – 1) (x – 2) (x – 7)
1
14
F
HG I
KJ
378 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ f(6) = 1 + 20 + (5) (4) −
F
HG I
KJ
2
3
+ (5) (4) (– 1)
1
14
F
HG I
KJ
= 6.2381.
Example 14. Referring to the following table, find the value of f(x) at point
x = 4:
x: 1.5 3 6
f(x): – 0.25 2 20.
Sol. The divided difference table is:
x f(x) Δ
| f(x) Δ
| 2f(x)
1.5 – 0.25
1.5
3 2 1
6
6 20
Applying Newton’s divided difference formula,
f(x) = – 0.25 + (x – 1.5) (1.5) + (x – 1.5) (x – 3) (1)
Putting x = 4, we get
f(4) = 6.
Example 15. Using Newton’s divided difference formula, prove that
f(x) = f(0) + xΔf(– 1) +
(x 1)x
2 !
+
Δ2 f(– 1)
+
(x 1)x(x 1)
3 !
+ −
Δ3f(– 2) + ......
Sol. Taking the arguments, 0, – 1, 1, – 2, ...... the divided Newton’s difference
formula is
f(x) = f(0) + x Δ
|
− 1
f(0) + x(x + 1) Δ
|
,
− 1 1
2
f(0)
+ x(x + 1)(x – 1) Δ
|
, ,
3
1 1 2
− −
f(0) + ... (74)
= f(0) + x Δ
|
0
f(– 1) + x(x + 1) Δ
|
,
2
0 1
f(– 1)
+ (x + 1)x(x – 1) Δ
|
, ,
3
1 0 1
−
f(– 2) + ....
INTERPOLATION 379
Now Δ
|
0
f(– 1) =
f f
( ) ( )
( )
0 1
0 1
− −
− −
= Δ f(– 1)
Δ
|
,
2
0 1
f(– 1) =
1
1 1
− −
( )
[Δ
|
1
f(0) – Δ
|
0
f(– 1)]
= 1
2
[Δ f(0) – Δ f(– 1)] = 1
2
Δ2 f(– 1)
Δ
|
, ,
3
1 0 1
−
f(– 2) =
1
1 2
− −
( )
[Δ
|
,
2
0 1
f(– 1) – Δ
|
,
2
1 0
−
f(– 2)]
=
1
3
Δ Δ
2 2
1
2
2
2
f f
( ) ( )
−
−
−
L
NM O
QP
=
Δ Δ
3 3
2
3 2
2
3
f f
( )
.
( )
!
−
=
−
and so on.
Substituting these values in (74)
f(x) = f(0) + xΔ f(– 1) +
( )
!
x x
+ 1
2
Δ2 f(– 1)
+
( ) ( )
!
x x x
+ −
1 1
3
Δ3 f(– 2) + ......
ASSIGNMENT 4.12
1. Given the values:
x: 5 7 11 13 17
f(x): 150 392 1452 2366 5202
Evaluate f(9) using Newton’s divided difference formula.
2. The observed values of a function are, respectively, 168, 120, 72, and 63 at the four
positions 3, 7, 9, and 20 of the independent variable. What is the best estimate you can
give for value of the function at the position 6 of the independent variable?
3. Apply Newton’s divided difference formula to find the value of f(8) if
f(1) = 3, f(3) = 31, f(6) = 223, f(10) = 1011, f(11) = 1343.
4. Given that
x: 1 3 4 6 7
yx: 1 27 81 729 2187
Find y5. Why does it differ from 35?
5. Use Newton’s divided difference formula to find f(7) if f(3) = 24, f(5) = 120, f(8) = 504,
f(9) = 720, and f(12) = 1716.
380 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6. The following table is given:
x: 0 1 2 5
f(x): 2 3 12 147
What is the form of the function?
7. Find the function ux in powers of x – 1, given that u0 = 8, u1 = 11, u4 = 68, u5 = 123.
8. Find ux in powers of x – 4 where u0 = 8, u1 = 11, u4 = 68, u5 = 125.
9. Using Lagrange’s interpolation formula express the function
x x
x x x
2
3 2
3
2 2
+ −
− − +
as sums of portial fractions
10. Express the function
x x
x x x
2
2
6 1
1 4)( 6
+ −
− − −
( )( )
as a sum of partial fractions.
11. Certain corresponding values of x and log10 x are given below:
x: 300 304 305 307
log10 x: 2.4771 2.4829 2.4843 2.4871
Find log10 310 by Newton’s divided difference formula.
12. (i) The following table gives the values of x and y:
x: 1.2 2.1 2.8 4.1 4.9 6.2
y: 4.2 6.8 9.8 13.4 15.5 19.6
Find the value of x corresponding to y = 12 using Lagrange’s technique of inverse inter-
polation.
(ii) Obtain the value of t when A = 85 from the following table using Lagrange’s method
t: 2 5 8 14
A: 94.8 87.9 81.3 68.7
13. Using Newton’s divided difference method, compute f(3) from the following table
x: 0 1 2 4 5 6
f(x): 1 14 15 5 6 19
14. Find the Newton’s divided difference interpolation polynomial for:
x: 0.5 1.5 3.0 5.0 6.5 8.0
f(x): 1.625 5.875 31.0 131.0 282.125 521.0
INTERPOLATION 381
15. If f(x) = U(x)V(x), find the divided difference f(x0, x1) in terms of U(x0), V(x1) and the
divided differences U(x0, x1), V(x0, x1). Write a code in C to implement.
16. Write an algorithm to compute the value of a function using Lagrange’s interpolation.
4.33 HERMITE’S INTERPOLATION FORMULA
So far we have considered the interpolation formulae which make use only of a
certain number of function values. We now derive an interpolation formula in
which both the function and its first derivative are to be assigned at each point
of interpolation. This is called Hermite’s interpolation formula or
osculating interpolation formula.
Let the set of data points (xi, yi, yi′), 0 ≤ i ≤ n be given. A polynomial of the
least degree say H(x) is to be determined such that
H(xi) = yi and H′(xi) = yi′; i = 0, 1, 2, ... n (75)
H(x) is called Hermite’s interpolating polynomial.
Since there are 2n + 2 conditions to be satisfied, H(x) must be a polynomial
of degree ≤ 2n + 1.
The required polynomial may be written as
H(x) = u x y v x y
i i i i
i
n
i
n
( ) ( )
+ ′
=
=
∑
∑ 0
0
(76)
where ui(x) and vi(x) are polynomials in x of degree ≤ (2n + 1) and satisfy
(i) ui(xj) =
0
1
,
,
i j
i j
≠
=
R
S
T
U
V
W (77 (i))
(ii) vi(xj) = 0 ∀ i, j (77 (ii))
(iii) ui′(xj) = 0 ∀ i, j (77 (iii))
(iv) vi′(xj) =
0
1
,
,
i j
i j
≠
=
R
S
T
U
V
W (77 (iv))
Using the Lagrange fundamental polynomials Li(x), we choose
ui(x) = Ai(x) [Li(x)]2
and vi(x) = Bi(x) [Li(x)]2 (78)
where Li(x) is defined as
Li(x) =
( )( ) ... ( )( ) ... ( )
( )( ) ... ( )( ) ... ( )
x x x x x x x x x x
x x x x x x x x x x
i i n
i i i i i i i n
− − − − −
− − − − −
− +
− +
0 1 1 1
0 1 1 1
U
V
W
382 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since Li
2(x) is a polynomial of degree 2n, Ai(x) and Bi(x) must be linear
polynomials.
Let Ai(x) = aix + bi
and Bi(x) = cix + di so that from (78),
ui(x) = (aix + bi) [Li(x)]2
vi(x) = (cix + di) [Li(x)]2 (79)
using conditions (77(i)) and (77(ii)) in (79), we get
aix + bi = 1 (80 (i))
and cix + di = 0 (80 (ii)) | since [Li(xi)]2 = 1
Again, using conditions (77(iii)) and (77(iv)) in (79), we get
ai + 2Li′(xi) = 0 (80 (iii))
and ci = 1 (80 (iv))
From equations (80(i)), (80(ii)), (80(iii)) and (80(iv)), we deduce
ai = – 2Li′(xi)
bi = 1 + 2xiLi′(xi)
(81)
ci = 1
and di = – xi
Hence, from (79),
ui(x) = [– 2x Li′(xi) + 1 + 2xiLi′(xi)] [Li(x)]2
= [1 – 2(x – xi) Li′(xi)] [Li(x)]2
and vi(x) = (x – xi) [Li(x)]2
Therefore from (76),
H(x) =
i
n
=
∑
0
[1 – 2(x – xi) Li′(xi)] [Li(x)]2 yi + ( ) [ ( )]
x x x y
i i i
i
n
− ′
=
∑ L 2
0
which is the required Hermite’s interpolation formula.
EXAMPLES
Example 1. Apply Hermite’s interpolation formula to find a cubic polynomial
which meets the following specifications.
U
V
W
U
V
|
|
W
|
|
INTERPOLATION 383
xi yi yi′
0 0 0
1 1 1
Sol. Hermite interpolation formula is
H(x) = [ ( ) ( )][ ( )]
1 2 2
0
1
− − ′
=
∑ x x x x y
i i i i i
i
L L +
i
i i i
x x x y
=
∑ − ′
0
1
2
( ) [ ( )]
L
= [1 – 2 (x – x0) L0′(x0)] [L0(x)]2 y0
+ [1 – 2(x – x1) L1′(x1)] [L1(x)]2 y1
+ (x – x0) [L0(x)]2 y0′ + (x – x1) [L1 (x)]2 y1′ (82)
Now, L0(x) =
x x
x x
x
−
−
=
−
−
1
0 1
1
0 1
= 1 – x
L1 (x) =
x x
x x
x
−
−
=
−
−
0
1 0
0
1 0
= x
∴ L0′(x) = – 1
and L1′(x) = 1
Hence, L0′(x0) = – 1 and L1′(x1) = 1
∴ From (82),
H(x) = [1 – 2 (x – 0) (– 1) [ (1 – x)2 (0)
+ [1 – 2 (x – 1) (1) ] x2 (1)
+ (x – 0) (1 – x)2 (0) + (x – 1) x2 (1)
= x2 – 2x2(x – 1) + x2 (x – 1)
= x2 – x2 (x – 1) = x2(2 – x)
= 2x2 – x3.
Example 2. Apply Hermite’s formula to find a polynomial which meets these
specifications
xk yk yk′
0 0 0
1 1 0
2 0 0
384 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Hermite’s interpolation formula is
H(x) =
i
i i i i i
i
i i i
x x x x y x x x y
= =
∑ ∑
− − ′ + − ′
0
2
2
0
2
2
1 2
[ ( ) ( )][ ( )] ( )[ ( )]
L L L
= [1 – 2(x – x0) L0′(x0)] [L0 (x)]2 y0 + [1 – 2(x – x1) L1′(x1)] [L1(x)]2 y1
+ [1 – 2 (x – x2) L2′(x2)] [L2(x)]2 y2 + (x – x0) [L0(x)]2 y0′
+ (x – x1) [L1(x)]2 y1′ + (x – x2) [L2(x)]2 y2′ (83)
Now, L0(x) =
( ) ( )
( ) ( )
( ) ( )
( ) ( )
x x x x
x x x x
x x
− −
− −
=
− −
− −
=
1 2
0 1 0 2
1 2
0 1 0 2
1
2
(x2 – 3x + 2)
L1 (x) =
( ) ( )
( ) ( )
( ) ( )
( ) ( )
x x x x
x x x x
x x
− −
− −
=
− −
− −
0 2
1 0 1 2
0 2
1 0 1 2
= 2x – x2
L2(x) =
( ) ( )
( ) ( )
( ) ( )
( ) ( )
x x x x
x x x x
x x
− −
− −
=
− −
− −
=
0 1
2 0 2 1
0 1
2 0 2 1
1
2
(x2 – x)
∴ L0′(x) =
2 3
2
x −
, L1′(x) = 2 – 2x, L2′(x) =
2 1
2
x −
Hence, L0′(x0) = –
3
2
, L1′(x1) = 0, L2′(x2) =
3
2
∴ From (83),
H(x) = 1 2 0
3
2
1
4
− − −
F
HG I
KJ
L
NM O
QP
( )
x (x2 – 3x + 2)2 (0)
+ [1 – 2(x – 1) (0)] (2x – x2)2 (1)
+ 1 2 2
3
2
1
4
− −
F
HG I
KJ
L
NM O
QP
( )
x (x2 – x)2 (0)
+ (x – 0)
1
4
(x2 – 3x + 2)2 (0)
+ (x – 1) (2x – x2)2 (0) + (x – 2)
1
4
(x2 – x)2 (0)
= (2x – x2)2 = x4 – 4x3 + 4x2.
Example 3. A switching path between parallel railroad tracks is to be a cubic
polynomial joining positions (0, 0) and (4, 2) and tangent to the lines y = 0 and
y = 2 as shown in the figure. Apply Hermite’s interpolation formula to obtain
this polynomial.
INTERPOLATION 385
(0, 0)
(4, 2)
X
Y
Sol. Since tangents are parallel to X-axis,
y′ = 0 in both the cases.
∴ We have the table of values,
x y y′
0 0 0
4 2 0
The hermite interpolation formula is
H(x) = [ ( ) ( )][ ( )] ( )[ ( )]
1 2 2
0
1
0
1
2
− − ′ + − ′
= =
∑ ∑
x x x x y x x x y
i i i i i
i i
i i i
L L L (84)
Now, L0(x) =
x x
x x
x x
−
−
=
−
−
= −
1
0 1
4
0 4
1
4
L1(x) =
x x
x x
x x
−
−
=
−
−
=
0
1 0
0
4 0 4
∴ L0′( x) = –
1
4
and L1′(x) =
1
4
Hence, L0′(x0) = –
1
4
and L1′(x1) =
1
4
∴ From (84), H(x) = 1 2 0
1
4
1
4
2
− − −
F
HG I
KJ
L
NM O
QP −
F
HG I
KJ
( )
x
x
(0)
+ 1 2 4
1
4 4
2
− −
F
HG I
KJ
L
NM O
QPF
HG I
KJ
( )
x
x
(2)
+ (x – 0) 1
4
2
−
F
HG I
KJ
x
(0) + (x – 4) x
4
2
F
HG I
KJ (0)
= 1
4
2 8
2
−
−
F
HG I
KJ
L
NM O
QP
x x
=
( )
6
16
1
16
2
−
=
x x
(6x2 – x3).
386 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 4.13
1. Apply Hermite’s interpolation formula to find f(x) at x = 0.5 which meets the following
requirement:
xi f(xi) f ′(xi)
– 1 1 – 5
0 1 1
1 3 7
Also find f(– 0.5).
2. Apply Hermite’s interpolating formula to obtain a polynomial of degree 4 for the follow-
ing data:
xi yi yi′
0 1 0
1 0 0
2 9 24
3. Apply Hermite’s formula to find a polynomial which meets the following specifications:
xi yi yi′
– 1 – 1 0
0 0 0
1 1 0
4. Apply osculating interpolation formula to find a polynomial which meets the following
requirements:
xi yi yi′
0 1 0
1 0 0
2 9 0
INTERPOLATION 387
5. Apply Hermite’s formula to interpolate for sin 1.05 from the following data:
x sin x cos x
1.00 0.84147 0.54030
1.10 0.89121 0.45360
6. Find y = f(x) by Hermite’s interpolation from the table:
xi yi yi′
– 1 1 – 5
0 1 1
1 3 7
Compute y2 and y2′.
7. Compute e by Hermite’s formula for the function f(x) = ex at the points 0 and 1. Com-
pare the value with the value obtained by using Lagrange’s interpolation.
8. Show that
f
a b f a f b b a f a f b
+
F
HG I
KJ =
+
+
− ′ − ′
2 2 8
( ) ( ) ( ) [ ( ) ( )]
by Hermite’s interpolation.
9. Apply Hermite’s interpolation to find f(1.05) given:
x f f ′
1 1.0 0.5
1.1 1.04881 0.47673
10. Apply Hermite’s interpolation to find log 2.05 given that
x log x 1
x
2.0 0.69315 0.5
2.1 0.74194 0.47619
388 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
11. Determine the Hermite polynomial of degree 5 which fits the following data and hence
find an approximate value of loge 2.7.
x y = logex y′ =
1
x
2.0 0.69315 0.5
2.5 0.91629 0.4
3.0 1.09861 0.33333
12. Using Hermite’s interpolation formula, estimate the value of ln (3.2) from the following
table:
x 3 3.5 4.0
y = ln (x) 1.09861 1.25276 1.38629
y′ =
1
x
0.33333 0.28571 0.25000
13. (i) Construct the Hermite interpolation polynomial that fits the data:
x f(x) f ′(x)
1 7.389 14.778
2 54.598 109.196
Estimate the value of f(1.5).
(ii) Consider the cubic polynomial
P(x) = c0 + c1x + c2 x2 + c3 x3.
Fit the data in problem 13(i) and find P(x). Are these polynomials different? Comment.
14. (i) Construct the Hermite interpolation polynomial that fits the data:
x f(x) f ′(x)
2 29 50
3 105 105
Interpolate f(x) at x = 2.5.
(ii) Fit the cubic polynomial P(x) = c0 + c1x + c2x2 + c3x3 to the data given in problem
14(i). Are these polynomials same?
INTERPOLATION 389
15. (i) Construct the Hermite interpolation polynomial that fits the data:
x f(x) f ′(x)
0 0 1
0.5 0.4794 0.8776
1.0 0.8415 0.5403
Estimate the value of f(0.75).
(ii) Construct the Hermite interpolation polynomial that fits the data:
x y(x) y′(x)
0 4 – 5
1 – 6 – 14
2 – 22 – 17
Interpolate y(x) at x = 0. 5 and 1.5.
16. Obtain the unique polynomial p(x) of degree 3 or less corresponding to a function f(x)
where f(0) = 1, f ′(0) = 2, f(1) = 5, f ′(1) = 4.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
P a r t 3
n Numerical Integration and Differentiation
Introduction, Numerical Differentiation,
Numerical Integration,
Trapezoidal Rule, Simpson’s
1
3
rd
F
HG I
KJ and
3
8
th
F
HG I
KJ Rule, Boole’s Rule,
Weddle’s Rule.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
5.1 INTRODUCTION
C
onsider a function of a single variable y = f(x). If f(x) is defined as an
expression, its derivative or integral may often be determined using the
techniques of calculus.
However, when f(x) is a complicated function or when it is given in a tabular
form, numerical methods are used.
This section discusses numerical methods for approximating the
derivative(s) f(r)(x), r ≥ 1 of a given function f(x) and for the evaluation of the
integral
a
b
f x dx
z ( ) where a, b may be finite or infinite.
The accuracy attainable by these methods would depend on the given
function and the order of the polynomial used. If the polynomial fitted is exact
then the error would be, theoretically, zero. In practice, however, rounding
errors will introduce errors in the calculated values.
The error introduced in obtaining derivatives is, in general, much worse
than that introduced in determining integrals.
It may be observed that any errors in approximating a function are amplified
while taking the derivative whereas they are smoothed out in integration.
Thus numerical differentiations should be avoided if an alternative exists.
Chapter 5 NUMERICAL INTEGRATION
AND DIFFERENTIATION
393
394 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
5.2 NUMERICAL DIFFERENTIATION
In the case of numerical data, the functional form of f(x) is not known in general.
First we have to find an appropriate form of f(x) and then obtain its derivatives.
So “Numerical Differentiation” is concerned with the method of finding the
successive derivatives of a function at a given argument, using the given table
of entries corresponding to a set of arguments, equally or unequally spaced.
Using the theory of interpolation, a suitable interpolating polynomial can be
chosen to represent the function to a good degree of approximation in the given
interval of the argument.
For the proper choice of interpolation formula, the criterion is the same as
in the case of interpolation problems. In the case of equidistant values of x, if
the derivative is to be found at a point near the beginning or the end of the
given set of values, Newton’s forward or backward difference formula should
be used accordingly. Also if the derivative is to be found at a point near the
middle of the given set of values, then any one of the central difference formulae
should be used. However, if the values of the function are not known at
equidistant values of x, Newton’s divided difference or Lagrange’s formula
should be used.
5.3 FORMULAE FOR DERIVATIVES
(1) Newton’s forward difference interpolation formula is
y = y0 + u Δy0 +
u u
y
u u u
y
( )
!
( )( )
!
....
−
+
− −
+
1
2
1 2
3
2
0
3
0
Δ Δ (1)
where u =
x a
h
−
(2)
Differentiating eqn. (1) with respect to u, we get
dy
du
y
u
y
u u
= +
−
+
− +
Δ Δ
0
2
0
2
2 1
2
3 6 2
6
Δ3y0 + ... (3)
Differentiating eqn. (2) with respect to x, we get
du
dx h
=
1
(4)
We know that
dy
dx
dy
du
du
dx h
y
u
y
u u
y
= = +
−
F
HG I
KJ +
− +
F
HG
I
KJ +
L
N
MM
O
Q
PP
. ...
1 2 1
2
3 6 2
6
0
2
0
2
3
0
Δ Δ Δ (5)
NUMERICAL INTEGRATION AND DIFFERENTIATION 395
Expression (5) provides the value of
dy
dx
at any x which is not tabulated.
Formula (5) becomes simple for tabulated values of x, in particular when
x = a and u = 0
Putting u = 0 in (5), we get
dy
dx h
y y y y y
x a
F
HG I
KJ = − + − + −
L
NM O
QP
=
1 1
2
1
3
1
4
1
5
0
2
0
3
0
4
0
5
0
Δ Δ Δ Δ Δ ... (6)
Differentiating eqn. (5) with respect to x, we get
d y
dx
d
dx
dy
dx
2
2
=
F
HG I
KJ =
d
du
dy
dx
du
dx
F
HG I
KJ
=
1
1
6 18 11
12
1
2
0
3
0
2
4
0
h
y u y
u u
y
h
Δ Δ Δ
+ − +
− +
F
HG
I
KJ +
L
N
MM
O
Q
PP
( ) ...
=
1
1
6 18 11
12
2
2
0
3
0
2
4
0
h
y u y
u u
y
Δ Δ Δ
+ − +
− +
F
HG
I
KJ +
L
N
MM
O
Q
PP
( ) ... (7)
Putting u = 0 in (7), we get
d y
dx h
y y y
x a
2
2 2
2
0
3
0
4
0
1 11
12
F
HG
I
KJ = − + +
F
HG I
KJ
=
Δ Δ Δ ... (8)
Similarly, we get
d y
dx h
y y
x a
3
3 3
3
0
4
0
1 3
2
F
HG
I
KJ = − +
F
HG I
KJ
=
Δ Δ ... (9)
and so on.
Formulae for computing higher derivatives may be obtained by
successive differentiation.
Aliter: We know that
E = ehD ⇒ 1 + Δ = ehD
∴ hD = log (1 + Δ) = Δ
Δ Δ Δ
− + − +
2 3 4
2 3 4
...
396 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
⇒ D =
1 1
2
1
3
1
4
2 3 4
h
Δ Δ Δ Δ
− + − +
L
NM O
QP
...
Similarly,
D2 =
1 1
2
1
3
1
4
1 11
12
5
6
2
2 3 4
2
2
2 3 4 5
h h
Δ Δ Δ Δ Δ Δ Δ Δ
− + − +
F
HG I
KJ = − + − +
F
HG I
KJ
... ...
and D3 =
1 3
2
3
3 4
h
Δ Δ
− +
F
HG I
KJ
...
(2) Newton’s backward difference interpolation formula is
y = yn + u ∇yn +
u u
y
u u u
n
( )
!
( )( )
!
+
∇ +
+ +
1
2
1 2
3
2
∇3yn + ... (10)
where u =
x x
h
n
−
(11)
Differentiating (10) with respect to, u, we get
dy
du
y
u
y
u u
n n
= ∇ +
+
F
HG I
KJ ∇ +
+ +
F
HG
I
KJ
2 1
2
3 6 2
6
2
2
∇3yn + ... (12)
Differentiating (11) with respect to x, we get
du
dx h
=
1
(13)
Now,
dy
dx
dy
du
du
dx
= .
=
1 2 1
2
3 6 2
6
2
2
3
h
y
u
y
u u
y
n n n
∇ +
+
F
HG I
KJ ∇ +
+ +
F
HG
I
KJ ∇ +
L
N
MM
O
Q
PP
... (14)
Expression (14) provides us the value of
dy
dx
at any x which is not tabulated.
At x = xn, we have u = 0
∴ Putting u = 0 in (14), we get
dy
dx h
y y y y
x x
n n n n
n
F
HG I
KJ = ∇ + ∇ + ∇ + ∇ +
F
HG I
KJ
=
1 1
2
1
3
1
4
2 3 4
... (15)
NUMERICAL INTEGRATION AND DIFFERENTIATION 397
Differentiating (14) with respect to x, we get
d y
dx
d
du
dy
dx
du
dx
2
2
=
F
HG I
KJ
=
1
1
6 18 11
12
2
2 3
2
4
h
y u y
u u
y
n n n
∇ + + ∇ +
+ +
F
HG
I
KJ ∇ +
L
N
MM
O
Q
PP
( ) ... (16)
Putting u = 0 in (16), we get
d y
dx h
y y y
x x
n n n
n
2
2 2
2 3 4
1 11
12
F
HG
I
KJ = ∇ + ∇ + ∇ +
F
HG I
KJ
=
... (17)
Similarly, we get
d y
dx h
y y
x x
n n
n
3
3 3
3 4
1 3
2
F
HG
I
KJ = ∇ + ∇ +
F
HG I
KJ
=
... (18)
and so on.
Formulae for computing higher derivatives may be obtained by
successive differentiation.
Aliter: We know that
E–1 = 1 – ∇
e–hD = 1 – ∇
∴ – hD = log (1 – ∇) = – ∇ + ∇ + ∇ + ∇ +
F
HG I
KJ
1
2
1
3
1
4
2 3 4
...
⇒ D =
1 1
2
1
3
1
4
2 3 4
h
∇ + ∇ + ∇ + ∇ +
F
HG I
KJ
...
Also, D2 =
1 1
2
1
3
2
2 3
2
h
∇ + ∇ + ∇ +
F
HG I
KJ
...
= ∇ + ∇ + ∇ +
F
HG I
KJ
1 11
12
2
2 3 4
h
...
Similarly, D3 =
1 3
2
3
3
h
∇ + ∇ +
F
HG I
KJ
4
... and so on.
398 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(3) Stirling’s central difference interpolation formula is
y = y0 +
u y y u
y
u u y y
1 2 2
1
3 2
0 1
2
2
1
2 2 3
1
3
2
! !
( )
!
Δ Δ
Δ
Δ Δ
+
F
HG I
KJ + +
− +
F
HG
I
KJ
−
−
− −
+
u u
y
u u u y y
2 2 2
4
2
2 2 2 2 5
2
5
3
1
4
1 2
5 2
( )
!
( )( )
!
−
+
− − +
F
HG
I
KJ
−
− −
Δ
Δ Δ
+ ...
(19)
where u =
x a
h
−
(20)
Differentiating eqn. (19) with respect to u, we get
dy
du
y y
u y
u y y
=
+
+ +
−
F
HG
I
KJ +
F
HG
I
KJ
−
−
− −
Δ Δ
Δ
Δ Δ
0 1 2
1
2 3
1
3
2
2
3 1
6 2
+
4 2
4
5 15 4
5 2
3
4
2
4 2 5
2
5
3
u u
y
u u y y
−
F
HG
I
KJ +
− +
F
HG
I
KJ +
F
HG
I
KJ
−
− −
! !
Δ
Δ Δ
+ ... (21)
Differentiating (20) with respect to x, we get
du
dx h
=
1
(22)
Now,
dy
dx
dy
du
du
dx
= .
=
1
2
3 1
6 2
0 1 2
1
2 3
1
3
2
h
y y
u y
u y y
Δ Δ
Δ
Δ Δ
+
+ +
−
F
HG
I
KJ +
F
HG
I
KJ
L
N
MM
−
−
− −
+
4 2
4
5 15 4
5 2
3
4
2
4 2 5
2
5
3
u u
y
u u y y
−
F
HG
I
KJ +
− +
F
HG
I
KJ +
F
HG
I
KJ +
O
Q
PP
−
− −
! !
...
Δ
Δ Δ
(23)
Expression (23) provides the value of
dy
dx
at any x which is not tabulated.
Given x = a, we have u = 0
NUMERICAL INTEGRATION AND DIFFERENTIATION 399
∴ Given u = 0 in (23), we get
dy
dx h
y y y y
x a
F
HG I
KJ =
+
F
HG I
KJ −
+
F
HG
I
KJ
L
N
MM
=
− − −
1
2
1
6 2
0 1
3
1
3
2
Δ Δ Δ Δ
+
1
30 2
5
2
5
3
Δ Δ
y y
− −
+
F
HG
I
KJ −
O
Q
PP
...
(24)
Differentiating (23) with respect to x, we get
d y
dx
d
du
dy
dx
du
dx
2
2
=
F
HG I
KJ
=
1
2
6 1
12
2
2
1
3
1
3
2
2
h
y u
y y u
Δ
Δ Δ
−
− −
+
+
F
HG
I
KJ +
−
F
HG
I
KJ
L
N
MM Δ4y–2
+
2 3
12 2
3 5
2
5
3
u u y y
−
F
HG
I
KJ +
F
HG
I
KJ +
O
Q
PP
− −
Δ Δ
... (25)
Given u = 0 in (25), we get
d y
dx h
y y y
x a
2
2 2
2
1
4
2
6
3
1 1
12
1
90
F
HG
I
KJ = − + −
F
HG I
KJ
=
− − −
Δ Δ Δ ... (26)
and so on.
Formulae for computing higher derivatives may be obtained by
successive differentiation.
(4) Bessel’s central difference interpolation formula is
y =
y y
u y
u u y y
0 1
0
2
1
2
0
2
1
2
1
2 2
+
F
HG I
KJ + −
F
HG I
KJ +
− +
F
HG
I
KJ
−
Δ
Δ Δ
( )
!
+
u u u
y
( )
!
− −
F
HG I
KJ
−
1
1
2
3
3
1
Δ +
+ − − +
F
HG
I
KJ
− −
( ) ( )( )
!
u u u u y y
1 1 2
4 2
4
2
4
1
Δ Δ
+
( ) ( )( )
!
u u u u u
y
+ − − −
F
HG I
KJ
−
1 1 2
1
2
5
5
2
Δ
+
( )( ) ( )( )( )
!
u u u u u u y y
+ + − − − +
F
HG
I
KJ
− −
2 1 1 2 3
6 2
6
3
6
2
Δ Δ
+ ... (27)
where u =
x a
h
−
(28)
400 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Differentiating eqn. (27) with respect to u, we get
dy
du
y
u y y
= +
−
F
HG I
KJ +
F
HG
I
KJ
−
Δ
Δ Δ
0
2
1
2
0
2 1
2 2
!
+
3 3
1
2
3
2
u u
− +
F
H
GG
I
K
JJ
!
Δ3y–1
+
4 6 2 2
4 2
5 10 5 1
5
3 2 4
2
4
1
4 3
u u u y y u u u
− − +
F
HG
I
KJ +
F
HG
I
KJ +
− + −
F
HG
I
KJ
− −
! !
Δ Δ
Δ5y–2
+
6 15 20 45 8 12
6 2
5 4 3 2 6
3
6
2
u u u u u y y
− − + + −
F
HG
I
KJ +
F
HG
I
KJ
− −
!
Δ Δ
+ ... (29)
Differentiating (28) with respect to x, we get
du
dx h
=
1
Now,
dy
dx
dy
du
du
dx
= .
=
1 2 1
2 2
3 3
1
2
3
0
2
1
2
0
2
h
y
u y y u u
Δ
Δ Δ
+
−
F
HG I
KJ +
F
HG
I
KJ +
− +
F
H
GG
I
K
JJ
L
N
MMMM
−
! ! Δ3y–1
+
4 6 2 2
4 2
5 10 5 1
5
3 2 4
2
4
1
4 3
u u u y y u u u
− − +
F
HG
I
KJ +
F
HG
I
KJ +
− + −
F
HG
I
KJ
− −
! !
Δ Δ
Δ5y–2
+ 6 15 20 45 8 12
6 2
5 4 3 2 6
3
6
2
u u u u u y y
− − + + −
F
HG
I
KJ +
F
HG
I
KJ +
O
Q
PP
− −
!
...
Δ Δ
(30)
Expression (30) provides us the value of
dy
dx
at any x which is not tabu-
lated.
Given x = a, we have u = 0
∴ Given u = 0 in (30), we get
dy
dx h
y
y y
y
y y
x a
F
HG I
KJ = −
+
F
HG
I
KJ + +
+
F
HG
I
KJ
L
N
MM
=
−
−
− −
1 1
2 2
1
12
1
12 2
0
2
1
2
0 3
1
4
2
4
1
Δ
Δ Δ
Δ
Δ Δ
–
1
120 60 2
5
2
6
3
6
2
Δ
Δ Δ
y
y y
−
− −
−
1 +
F
HG
I
KJ +
O
Q
PP
... (31)
NUMERICAL INTEGRATION AND DIFFERENTIATION 401
Differentiating (30) with respect to x, we get
d y
dx
d
dx
dy
dx
2
2
=
F
HG I
KJ =
d
du
dy
dx
du
dx
F
HG I
KJ
=
1
2
2 1
2
6 6 1
12
2
2
1
2
0 3
1
2
h
y y u
y
u u
Δ Δ
Δ
−
−
+
F
HG
I
KJ +
−
F
HG I
KJ +
− −
F
HG
I
KJ
L
N
MM
Δ Δ
4 4
1
2
y y
–2 +
F
HG
I
KJ
−
+
4 6 1
24
3 2
u u
− +
F
HG
I
KJ Δ5y–2
+
15 30 30 45 4
360 2
4 3 2 6
3
6
2
u u u u y y
− − + +
F
HG
I
KJ +
F
HG
I
KJ +
O
Q
PP
− −
Δ Δ
... (32)
Given u = 0 in (32), we get
d y
dx h
y y
y
y y
x a
2
2 2
2
1
2
0 3
1
4
2
4
1
1
2 2
1
12 2
F
HG
I
KJ =
+
F
HG
I
KJ −
1
−
+
F
HG
I
KJ
L
N
MM
=
−
−
− −
Δ Δ
Δ
Δ Δ
+
1
24
1
90 2
5
2
6
3
6
2
Δ
Δ Δ
y
y y
−
− −
+
+
F
HG
I
KJ +
O
Q
PP
... (33)
and so on.
(5) For unequally spaced values of the argument
(i) Newton’s divided difference formula is
f(x) = f(x0) + (x – x0) f(x0) + (x – x0)(x – x1) 2f(x0) + (x – x0)(x – x1)
(x – x2) 3f(x0) + (x – x0)(x – x1) (x – x2)(x – x3) 4f(x0) + ... (34)
f ′(x) is given by
f ′(x) = f(x0) + {2x – (x0 + x1)} 2f(x0) + {3x2 – 2x(x0 + x1 + x2)
+ (x0x1 + x1x2 + x2x0)} 3f(x0) + ... (35)
(ii) Lagrange’s interpolation formula is
f(x) =
( )( ) ... ( )
( )( ) ... ( )
x x x x x x
x x x x x x
n
n
− − −
− − −
1 2
0 1 0 2 0
f(x0)
+
( )( ) ... ( )
( )( ) ... ( )
x x x x x x
x x x x x x
n
n
− − −
− − −
0 2
1 0 1 2 1
f(x1) + ... (36)
f ′(x) can be obtained by differentiating f(x) in eqn. (36).
402 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
1. Formula (8) can be extended as
d y
dx
1
h
11
12
5
6
137
180
7
10
363
560
...
2
2
x a
2
2 3 4 5
6 7 8
F
HG
I
KJ =
− + −
+ − + +
F
H
GGG
I
K
JJJ
=
Δ Δ Δ Δ
Δ Δ Δ
y0
2. Formula (17) can be extended as
d y
dx
1
h
11
12
5
6
137
180
7
10
363
560
...
2
2
x x
2
2 3 4 5 6
7 8
n
F
HG
I
KJ =
∇ + ∇ + ∇ + ∇ + ∇
+ ∇ + ∇ +
F
H
GGG
I
K
JJJ
=
yn.
5.4 MAXIMA AND MINIMA OF A TABULATED FUNCTION
Since maxima and minima of y = f(x) can be found by equating
dy
dx
to zero and
solving the equation for the argument x, the same method can be used to
determine maxima and minima of tabulated function by differentiating the
interpolating polynomial.
For example, if Newton’s forward difference formula is used, we have
y = y0 + u Δy0 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
0
Δ Δ3y0 + ... (37)
Differentiating (37) with respect to u, we get
dy
du
y
u
y
u u
= +
−
+
− +
Δ Δ
0
2
0
2
2 1
2
3 6 2
3
! !
Δ3y0 + ...
For maxima or minima,
dy
du
= 0
⇒ Δy0 +
2 1
2
3 6 2
3
2
0
2
u
y
u u
−
+
− +
! !
Δ Δ3y0 + ... = 0 (38)
If we terminate L.H.S. series after third differences for convenience, eqn.
(38) being a quadratic in u gives two values of u.
Corresponding to these values, x = a + uh will give the corresponding x at
which function may be maximum or minimum.
NOTE
NUMERICAL INTEGRATION AND DIFFERENTIATION 403
For maximum,
d y
du
2
2
= (–)ve
For minimum,
d y
du
2
2
= (+)ve.
EXAMPLES
Example 1. Find
dy
dx
at x = 0.1 from the following table:
x: 0.1 0.2 0.3 0.4
y: 0.9975 0.9900 0.9776 0.9604.
Sol. Take a = 0.1. The difference table is:
x y Δy Δ2y Δ3y
0.1 0.9975
– 0.0075
0.2 0.9900 – 0.0049
– 0.0124 0.0001
0.3 0.9776 – 0.0048
– 0.0172
0.4 0.9604
Here h = 0.1 and y0 = 0.9975
dy
dx h
y y y
x
L
NM O
QP = − +
L
NM O
QP
= 0.1
0
2
0
3
0
1 1
2
1
3
Δ Δ Δ
=
1
0
0 0075
1
2
0 0049
1
3
0 0001
.1
− − − +
L
NM O
QP
. ( . ) ( . )
= – 0.050167.
Example 2. The table given below reveals the velocity ‘v’ of a body during the
time ‘t’ specified. Find its acceleration at t = 1.1.
t: 1.0 1.1 1.2 1.3 1.4
v: 43.1 47.7 52.1 56.4 60.8.
404 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. The difference table is:
t v Δv Δ2v Δ3v Δ4v
1.0 43.1
4.6
1.1 47.7 – 0.2
4.4 0.1
1.2 52.1 – 0.1 0.1
4.3 0.2
1.3 56.4 0.1
4.4
1.4 60.8
Let a = 1.1,
∴ v0 = 47.7 and h = 0.1
Acceleration at t = 1.1 is given by
dv
dt h
v v v
t
L
NM O
QP = − +
L
NM O
QP= − − +
L
NM O
QP
= 1.1
1
0.1
4.4
1
2
( 0.1)
1
3
(0.2)
1 1
2
1
3
0
2
0
3
0
Δ Δ Δ
= 45.1667
Hence the required acceleration is 45.1667.
Example 3. Find f ′(1.1) and f ″(1.1) from the following table:
x: 1.0 1.2 1.4 1.6 1.8 2.0
f(x): 0.0 0.1280 0.5540 1.2960 2.4320 4.000.
Sol. Since we are to find f ′(x) and f ″(x) for non-tabular value of x, we proceed
as follows:
Newton’s forward difference formula is
y = y0 + u Δy0 +
u u
y
u u u
( )
!
( )( )
!
−
+
− −
1
2
1 2
3
2
0
Δ Δ3y0
+
u u u u
( )( )( )
!
− − −
1 2 3
4
Δ4y0 + ... (39)
where u =
x a
h
−
(40)
NUMERICAL INTEGRATION AND DIFFERENTIATION 405
Differentiating eqn. (39) with respect to u, we get
dy
du
y
u
y
u u
= +
−
F
HG I
KJ +
− +
F
HG
I
KJ
Δ Δ
0
2
0
2
2 1
2
3 6 2
6
Δ3y0
+
2 9 11 3
12
3 2
u u u
− + −
F
HG
I
KJ Δ4y0 + ... (41)
Differentiating eqn. (40) with respect to x
du
dx h
=
1
(42)
∴
dy
dx
dy
du
du
dx
= .
=
1 2 1
2
3 6 2
6
0
2
0
2
h
y
u
y
u u
Δ Δ
+
−
F
HG I
KJ +
− +
F
HG
I
KJ
L
N
MM Δ3
0
y
+
− + −
F
HG
I
KJ +
O
Q
PP
2 9 11 3
12
3 2
4
0
u u u
y
Δ ... (43)
Also, at x = 1.1, u =
1.1 1.0
0.2
−
=
1
2
Here 1.0
and 0.2
a
h
=
=
The forward difference table is as follows:
x f(x) = y Δy Δ2y Δ3y Δ4y Δ5y
1.0 0.0
0.1280
1.2 0.1280 0.298
0.4260 0.018
1.4 0.5540 0.316 0.06
0.7420 0.078 – 0.1
1.6 1.2960 0.394 – 0.04
1.1360 0.038
1.8 2.4320 0.432
1.5680
2.0 4.000
406 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
From eqn. (43),
dy
dx h
y
u
y
u u
y
= +
−
F
HG I
KJ +
− +
F
HG
I
KJ
L
N
MM
1 2 1
2
3 6 2
6
0
2
0
2
3
0
Δ Δ Δ
+
− + −
F
HG
I
KJ
2 9 11 3
12
3 2
u u u
Δ4y0
+
5 40 105 100 24
120
4 3 2
5
0
u u u u
y
− + − +
F
HG
I
KJ +
O
Q
PP
Δ ... (44)
At x = 1.1, we get
f ′(1.1) =
dy
dx x
F
HG I
KJ =1.1
=
1
0.2
L
N
MMM0.1280 +
2
1
2
1
2
F
HG I
KJ −
R
S
|
T
|
U
V
|
W
| (0.298)
+
3
1
2
6
1
2
2
6
2
F
HG I
KJ −
F
HG I
KJ +
R
S
|
T
|
U
V
|
W
| (0.018) +
2
1
2
9
1
2
11
1
2
3
12
3 2
F
HG I
KJ −
F
HG I
KJ +
F
HG I
KJ −
R
S
|
T
|
U
V
|
W
| (.06)
+
5
1
2
40
1
2
105
1
2
100
1
2
24
120
4 3 2
F
HG I
KJ −
F
HG I
KJ +
F
HG I
KJ −
F
HG I
KJ +
R
S
|
T
|
U
V
|
W
|(– 0.1)
O
Q
PPP
= 0.66724.
Differentiating eqn. (44), with respect to x, we get
d y
dx
d
du
dy
du
du
dx
2
2
=
F
HG I
KJ =
1
1
6 18 11
12
2
2
0
3
0
2
4
0
h
y u y
u u
y
Δ Δ Δ
+ − +
− +
F
HG
I
KJ
L
N
MM
( )
+
2 12 21 10
12
3 2
5
0
u u u
y
− + −
F
HG
I
KJ +
O
Q
PP
Δ ...
NUMERICAL INTEGRATION AND DIFFERENTIATION 407
At x = 1.1, we get
f ″(1.1) =
d y
dx x
2
2
F
HG
I
KJ =1.1
=
1
2
( )
0.2
L
N
MMM0.298 +
1
2
1
−
F
HG I
KJ (0.018) +
6
1
2
18
1
2
11
12
2
F
HG I
KJ −
F
HG I
KJ +
R
S
|
T
|
U
V
|
W
| (0.06)
+
2
1
2
12
1
2
21
1
2
10
12
3 2
F
HG I
KJ −
F
HG I
KJ +
F
HG I
KJ −
R
S
|
T
|
U
V
|
W
|(– 0.1)
O
Q
PPP
= 8.13125.
Example 4. The distance covered by an athlete for the 50 meter race is given in
the following table:
Time (sec): 0 1 2 3 4 5 6
Distance (meter): 0 2.5 8.5 15.5 24.5 36.5 50
Determine the speed of the athlete at t = 5 sec., correct to two decimals.
Sol. Here we are to find derivative at t = 5 which is near the end of the table,
hence we shall use the formula obtained from Newton’s backward difference
formula. The backward difference table is as follows:
t s ∇s ∇2s ∇3s ∇4s ∇5s ∇6s
0 0
2.5
1 2.5 3.5
6 – 2.5
2 8.5 1 3.5
7 1 – 3.5
3 15.5 2 0 1
9 1 – 2.5
4 24.5 3 – 2.5
12 – 1.5
5 36.5 1.5
13.5
6 50
408 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The speed of the athlete at t = 5 sec is given by
ds
dt h
s s s s s
t
F
HG I
KJ = ∇ + ∇ + ∇ + ∇ + ∇
L
NM O
QP
=5
5
2
5
3
5
4
5
5
5
1 1
2
1
3
1
4
1
5
=
1
1
12
1
2
3
1
3
1
1
4
0
1
5
+ + + + −
L
NM O
QP
( ) ( ) ( ) ( )
3.5
= 13.1333 ≈ 13.13 metre/sec.
Example 5. Find
dy
dx
and
d y
dx
2
2
at x = 6, given that
x: 4.5 5.0 5.5 6.0 6.5 7.0 7.5
y: 9.69 12.90 16.71 21.18 26.37 32.34 39.15.
Sol. Here a = 6.0 ∴ y0 = 21.18 and h = 0.5
The forward difference table is:
x y Δy Δ2y Δ3y Δ4y
4.5 9.69
3.21
5.0 12.9 0.60
3.81 0.06
5.5 16.71 0.66 0
4.47 0.06
6.0 21.18 0.72 0
5.19 0.06
6.5 26.37 0.78 0
5.97 0.06
7.0 32.34 0.84
6.81
7.5 39.15
We know that
dy
dx h
y y y
x
L
NM O
QP = − +
F
HG I
KJ
= 6
0
2
0
3
0
1 1
2
1
3
Δ Δ Δ
=
1
0.5
5.19
1
2
(0.78)
1
3
(0.06)
− +
L
NM O
QP = 9.64
NUMERICAL INTEGRATION AND DIFFERENTIATION 409
and
d y
dx h
y y y
x
2
2
6
2
2
0
3
0
4
0
1 11
12
L
NM O
QP = − +
L
NM O
QP
=
Δ Δ Δ
=
1
0.25
[0.78 – 0.06] = 4(0.72) = 2.88.
Example 6. From the following table of values of x and y, obtain
dy
dx
and
d y
dx
2
2
for x = 1.2, 2.2 and 1.6
x: 1.0 1.2 1.4 1.6 1.8 2.0 2.2
y: 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250.
Sol. The forward difference table is:
x y Δy Δ2y Δ3y Δ4y Δ5y Δ6y
1.0 2.7183
0.6018
1.2 3.3201 0.1333
0.7351 0.0294
1.4 4.0552 0.1627 0.0067
0.8978 0.0361 0.0013
1.6 4.9530 0.1988 0.0080 0.0001
1.0966 0.0441 0.0014
1.8 6.0496 0.2429 0.0094
1.3395 0.0535
2.0 7.3891 0.2964
1.6359
2.2 9.0250
(i) Here a = 1.2
∴ y0 = 3.3201; h = 0.2
dy
dx x
L
NM O
QP = − + − +
L
NM O
QP
= 1.2
1
0.2
0.7351
1
2
(0.1627)
1
3
(0.0361)
1
4
(0.008)
1
5
(0.0014)
= 3.3205
d y
dx x
2
2
1
2
1
0
L
NM O
QP = − + −
L
NM O
QP
= .2
( )
.2
0.1627 0.0361
11
12
(0.0080)
5
6
(0.0014)
= 3.318
410 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(ii) Here a = 2.2,
∴ yn = 9.02 and h = 0.2
dy
dx x
L
NM O
QP = + +
L
NM
= 2 2
.
1
0.2
1.6359
1
2
(0.2964)
1
3
(0.0535) + +
O
QP
1
4
(0.0094)
1
5
(0.0014)
= 9.0228
d y
dx x
2
2
1
L
NM O
QP = + + +
L
NM O
QP
= 2.2
0.04
0.2964 0.0535
11
12
(0.0094)
5
6
(0.0014)
= 8.992.
(iii) Here a = 1.6
∴ y0 = 4.9530, y–1 = 4.0552
y–2 = 3.3201, y–3 = 2.7183 and h = 0.2
By using Stirling’s formula for derivatives, we get
dy
dx x
L
NM O
QP =
+
F
HG I
KJ −
+
F
HG I
KJ
L
NM
= 1.6
1
0.2
1.0966 0.8978
2
1
6
0.0441 0.0361
2
+
+
F
HG I
KJO
QP
1
30
0.0014 0.0013
2
= 4.9530
and
d y
dx x
2
2
L
NM O
QP = − +
L
NM O
QP
= 1.6
1
0.04
0.1988
1
12
(.0080)
1
90
(.0001)
= 4.9525.
Example 7. Using Bessel’s formula, find f ′(7.5) from the following table:
x: 7.47 7.48 7.49 7.5 7.51 7.52 7.53
f(x): 0.193 0.195 0.198 0.201 0.203 0.206 0.208.
NUMERICAL INTEGRATION AND DIFFERENTIATION 411
Sol. The difference table is:
x y Δy Δ2y Δ3y Δ4y Δ5y Δ6y
7.47 0.193
0.002
7.48 0.195 0.001
0.003 – 0.001
7.49 0.198 0.000 0.000
0.003 – 0.001 0.003
7.50 0.201 – 0.001 0.003 – 0.01
0.002 0.002 – 0.007
7.51 0.203 0.001 – 0.004
0.003 – 0.002
7.52 0.206 – 0.001
0.002
7.53 0.208
Let a = 7.5, h = 0.01
f ′(7.5) =
dy
dx
y
y y
y
x
F
HG I
KJ = −
+
F
HG
I
KJ +
L
N
MM
=
−
−
7.5 0.01
1 1
2 2
1
12
0
2
1
2
0 3
1
Δ
Δ Δ
Δ
+
1
12 2
1
120
1
60 2
4
2
4
1 5
2
6
3
6
2
Δ Δ
Δ
Δ Δ
y y
y
y y
− −
−
− −
+
F
HG
I
KJ − −
+
F
HG
I
KJ +
O
Q
PP
...
=
1 1
2 2
1
12
1
12
0.01
.002
.001 .001
0.002
( ) ( )
−
− +
R
S
T
U
V
W+ +
L
NM
.003 .004
0.007
.01
2
+ −
R
S
T
U
V
W− − −
−
F
HG I
KJO
QP
( )
( )
2
1
120
1
60
= 0.226667.
Example 8. A rod is rotating in a plane. The following table gives the angle θ
(in radians) through which the rod has turned for various values of time t (in
seconds)
t: 0 0.2 0.4 0.6 0.8 1.0 1.2
θ: 0 0.12 0.49 1.12 2.02 3.20 4.67.
Calculate the angular velocity and angular acceleration of the rod at
t = 0.6 sec.
412 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. The forward difference table is:
t θ Δθ Δ2θ Δ3θ Δ4θ
0 0
0.12
0.2 0.12 0.25
0.37 0.01
0.4 0.49 0.26 0
0.63 0.01
0.6 1.12 0.27 0
0.9 0.01
0.8 2.02 0.28 0
1.18 0.01
1.0 3.20 0.29
1.47
1.2 4.67
Here a = 0.6
∴ θ0 = 1.12 and h = 0.2
Since the goal is to find derivatives at t = 0.6 sec, which is in the middle of
the table, use the formula obtained from Stirling’s or Bessel’s central difference
formula.
Choose the formula obtained from Bessel’s central difference formula.
Angular velocity at t = 0.6 sec is given by
d
dt h
t
θ θ θ
θ
F
HG I
KJ = −
+
F
HG
I
KJ +
L
N
MM
O
Q
PP
=
−
−
0.6
1 1
2 2
1
12
0
2
1
2
0 3
1
Δθ
Δ Δ
Δ
=
1 1
2 2
1
12
0.2
0.9
0.27 0.28
0.01
−
+
F
HG I
KJ +
L
NM O
QP
( )
= 3.81667 rad./sec.
Angular acceleration at t = 0.6 sec is given by
d
dt h
t
2
2 2
2
1
2
0 3
1
1
2
1
2
θ θ θ
θ
F
HG
I
KJ =
+
F
HG
I
KJ −
L
N
MM
O
Q
PP
=
−
−
0.6
Δ Δ
Δ
=
1
2
1
2
2
( )
( )
0.2
0.27 0.28
0.01
+
F
HG I
KJ −
L
NM O
QP
= 6.75 rad./sec2.
NUMERICAL INTEGRATION AND DIFFERENTIATION 413
In case we choose the formula obtained from Stirling’s formula,
at t = 0.6 sec.,
angular velocity
d
dt
1
h 2
1
6 2
0 1
3
1
3
2
θ θ θ
F
HG I
KJ =
+
F
HG I
KJ −
+
F
HG
I
KJ
L
N
MM
O
Q
PP
− − −
Δθ Δθ Δ Δ
=
1
0.2
.9 + .63
2
1
6
.01 .01
2
F
HG I
KJ −
+
F
HG I
KJ
L
NM O
QP
= 3.81667 rad./sec.
and angular acceleration
d
dt
1
h
1
(0.2)
2
2 2
2
1 2
θ
θ
F
HG
I
KJ = =
−
( )
Δ (0.27)
= 6.75 rad./sec2.
Example 9. The table below gives the result of an observation. θ is the observed
temperature in degrees centigrade of a vessel of cooling water, t is the time in
minutes from the beginning of observations:
t: 1 3 5 7 9
θ: 85.3 74.5 67.0 60.5 54.3
Find the approximate rate of cooling at t = 3 and 3.5.
Sol. The forward difference table is:
t θ Δθ Δ2θ Δ3θ Δ4θ
1 85.3
– 10.8
3 74.5 3.3
– 7.5 – 2.3
5 67.0 1.0 1.6
– 6.5 – 0.7
7 60.5 0.3
– 6.2
9 54.3
(i) When t = 3, θ0 = 74.5
Here h = 2
Rate of cooling =
d
dt
θ
NOTE
414 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴
d
dt h
t
θ
θ θ θ
F
HG I
KJ = − + −
L
NM O
QP
=3
0
2
0
3
0
4
0
1 1
2
1
3
1
4
Δθ Δ Δ Δ
=
1
2
1
1
3
− − + −
L
NM O
QP
7.5
1
2
0.7
( ) ( )
= – 4.11667°C/min.
(ii) t = 3.5 is the non-tabular value of t so, we have from Newton’s forward
difference formula,
dy
dx h
y
u
y
u u
y
= +
−
F
HG I
KJ +
− +
F
HG
I
KJ
L
N
MM
1 2 1
2
3 6 2
6
0
2
0
2
3
0
Δ Δ Δ
+
2 9 11 3
12
3 2
4
0
u u u
y
− + −
F
HG
I
KJ +
O
Q
PP
Δ ...
Here,
d
dt h
u u u
θ
θ θ
= +
−
F
HG I
KJ +
− +
F
HG
I
KJ
L
N
MM
1 2 1
2
3 6 2
6
0
2
0
2
3
0
Δθ Δ Δ
+
2 9 11 3
12
3 2
4
0
u u u
− + −
F
HG
I
KJ +
O
Q
PP
Δ θ ... (45)
At t = 3.5, u =
3.5 3.0 0.5
−
=
2 2
= 0.25 | Here a = 3.0 and h = 2
From (45),
d
dt t
θ
F
HG I
KJ = − +
−
R
S
T
U
V
W +
− +
R
S
T
U
V
W
−
L
N
MM
O
Q
PP
=3.5
.25 .25 .25
.7
1
2
7 5
2 1
2
1
3 6 2
6
2
.
( )
( )
( ) ( )
( )
= – 3.9151°C/min.
Example 10. Find x for which y is maximum and find this value of y
x: 1.2 1.3 1.4 1.5 1.6
y: 0.9320 0.9636 0.9855 0.9975 0.9996.
NUMERICAL INTEGRATION AND DIFFERENTIATION 415
Sol. The difference table is as follows:
x y Δ Δ2 Δ3 Δ4
1.2 0.9320
0.0316
1.3 0.9636 – 0.0097
0.0219 – 0.0002
1.4 0.9855 – 0.0099 0.0002
0.0120 0
1.5 0.9975 – 0.0099
0.0021
1.6 0.9996
Let y0 = 0.9320 and a = 1.2
By Newton’s forward difference formula,
y = y0 + u Δy0 +
u u
y
( )
...
−
+
1
2
2
0
Δ
= 0.9320 + 0.0316 u +
u u
( )
(– )
− 1
2
0.0097 | Neglecting higher
differences
dy
du
u
= +
−
F
HG I
KJ −
0.0316 0.0097
2 1
2
( )
At a maximum,
dy
du
= 0
⇒ 0.0316 = u −
F
HG I
KJ
1
2
(0.0097) ⇒ u = 3.76
∴ x = a + hu = 1.2 + (0.1) (3.76) = 1.576
To find ymax., we use the backward difference formula,
x = xn + hu
⇒ 1.576 = 1.6 + (0.1)u ⇒ u = – 0.24
y(1.576) = yn + u ∇yn +
u u
y
u u u
y
n n
( )
!
( )( )
!
+
∇ +
+ +
∇
1
2
1 2
3
2 3
416 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 0.9996 – (0.24 × 0.0021) +
( 0.24)(1 0.24)
2
− −
(– 0.0099)
= 0.9999988 = 0.9999 nearly
∴ Maximum y = 0.9999 approximately.
Example 11. Assuming Bessel’s interpolation formula, prove that
d
dx
(y ) y
1
24
y
x x 1/2
3
x 3/2
= −
− −
Δ Δ + ...
Sol. Bessel’s formula is
yx =
y y
x y
x x y y
0 1
0
2
1
2
0
2
1
2
1
2 2
+
F
HG I
KJ + −
F
HG I
KJ +
− +
F
HG
I
KJ
−
Δ
Δ Δ
( )
!
+
x x x
( )
!
− −
F
HG I
KJ
1
1
2
3
Δ3y–1 + ... (46)
Replacing x by x +
1
2
, we get
yx+1/2 =
y y
x y
x x
0 1
0
2
1
2
1
2
2
+
F
HG I
KJ + +
+
F
HG I
KJ −
F
HG I
KJ
Δ
!
Δ Δ
2
1
2
0
2
y y
− +
F
HG
I
KJ
+
+
F
HG I
KJ −
F
HG I
KJ
−
x x x
y
1
2
1
2
3
3
1
!
Δ + ... (47)
Differentiating (47) with respect to x, we get
d
dx
y y
x y y
x
( )
!
+
−
= +
+
F
HG
I
KJ
1/2 0
2
1
2
0
2
2 2
Δ
Δ Δ
+
3
1
4
3
2
x −
F
H
GG
I
K
JJ
!
Δ3y–1 + ...
Given x = 0, we get
d
dx
y y
x
( )
+ = −
1/2 0
1
24
Δ Δ3y–1 + ...
Shifting the origin from x = 0 to x –
1
2
, we get
d
dx
y y y
x x x
( ) /
= −
− −
Δ Δ
1/2
3
3 2
1
24
+ ...
NUMERICAL INTEGRATION AND DIFFERENTIATION 417
Example 12. Find f ″′(5) from the data given below:
x: 2 4 9 13 16 21 29
f(x): 57 1345 66340 402052 1118209 4287844 21242820
Sol. In this case, the values of argument x are not equally spaced and therefore
we shall apply Newton’s divided difference formula.
f(x) = f(x0) + (x – x0) f(x0) + (x – x0)(x – x1) 2f(x0)
+ (x – x0)(x – x1)(x – x2) 3f(x0)
+ (x – x0) (x – x1)(x – x2)(x – x3) 4f(x0) + ... (48)
Newton’s divided difference table is as follows:
x f(x) f(x) 2 f(x) 3 f(x) 4 f(x) 5 f(x) 6 f(x)
2 57
644
4 1345 1765
12999 556
9 66340 7881 45
83928 1186 1
13 402052 22113 64 0
238719 2274 1
16 1118209 49401 89
633927 4054
21 4287844 114265
2119372
29 21242820
Substituting values in eqn. (48), we get
f(x) = 57 + (x – 2)(644) + (x – 2)(x – 4)(1765)
+ (x – 2)(x – 4)(x – 9)(556)
+ (x – 2)(x – 4)(x – 9)(x – 13)(45)
+ (x – 2)(x – 4)(x – 9)(x – 13)(x – 16)(1)
= 57 + 644(x – 2) + 1765(x2 – 6x + 8)
+ 556(x3 – 15x2 + 62x – 72)
+ 45(x4 – 28x3 + 257x2 – 878x + 936)
+ x5 – 44x4 + 705x3 – 4990x2 + 14984x – 14976
418 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
f ′(x) = 644 + 1765(2x – 6) + 556(3x2 – 30x + 62)
+ 45(4x3 – 84x2 + 514x – 878)
+ 5x4 – 176x3 + 2115x2 – 9980x + 14984
f ″(x) = 3530 + 556(6x – 30) + 45(12x2 – 168x + 514)
+ 20x3 – 528x2 + 4230x – 9980
f ″′(x) = 3336 + 45(24x – 168) + 60x2 – 1056x + 4230
= 60x2 + 24x + 6
where x = 5,
f ″′ (5) = 60(5)2 + 24(5) + 6 = 1626
Example 13. Find f ′(4) from the following data:
x: 0 2 5 1
f(x): 0 8 125 1.
Sol. Though this problem can be solved by Newton’s divided difference formula,
we are giving here, as an alternative, Lagrange’s method. Lagrange’s
polynomial, in this case, is given by
f(x) =
( )( )( )
( )( )( )
( )
( )( )( )
( )( )( )
x x x x x x
− − −
− − −
+
− − −
− − −
2 5 1
0 2 0 5 0 1
0
0 5 1
2 0 2 5 2 1
(8)
+
( )( )( )
( )( )( )
( )
( )( )( )
( )( )( )
x x x x x x
− − −
− − −
+
− − −
− − −
0 2 1
5 0 5 2 5 1
125
0 2 5
1 0 1 2 1 5
(1)
= –
4
3
(x3 – 6x2 + 5x) +
25
12
(x3 – 3x2 + 2x) +
1
4
(x3 – 7x2 + 10x)
= x3
∴ f ′(x) = 3x2
when x = 4, f ′(4) = 3(4)2 = 48
Example 14. State the three different finite difference approximations to the
first derivative f ′(x0) together with the order of their truncation errors.
Derive the forward difference approximation and its leading error term.
Sol. (i) Newton’s forward difference approximation is given by
f(x) = f0 + u Δf0 +
u u
( )
− 1
2
Δ2f0
where u =
x x
h
− 0
and E =
1
6
u(u – 1) (u – 2) h3 f ′″(ξ)
NUMERICAL INTEGRATION AND DIFFERENTIATION 419
We have, f ′(x) =
df
du
du
dx
.
=
1
h
Δ Δ
f u f
0
2
0
1
2
2 1
+ −
L
NM O
QP
( )
and | E′(x0) | = | E′(u = 0) | ≤
h2
3
M3
where M3 = max| ( )|
′′′
≤ ≤
f x
x x x
0 2
(ii) Newton’s backward difference approximation is given by
f(x) = f2 + u ∇f2 +
1
2
u(u + 1) ∇2 f2
where u =
x x
h
− 2
and E =
1
6
u (u + 1) (u + 2) h3 f ′″(ξ)
We have, f ′(x) =
1 1
2
2 1
2
2
2
h
f u f
∇ + + ∇
L
NM O
QP
( )
and | E′(x2) | = | E′ (u = 0) | ≤
h2
3
M3
(iii) Central difference approximation is given by
f(x) = f0 +
u
2
(δf1/2 + δf–1/2)
where u =
x x
h
− 0
.
We have f ′(x) =
1
2h
(δf1/2 + δf–1/2)
=
1
2h
[(f1 – f0) + (f0 – f–1)]
=
1
2h
(f1 – f–1)
and | E′(x) | ≤
h2
6
M3.
420 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 5.1
1. Given that
x: 1.0 1.1 1.2 1.3 1.4 1.5 1.6
y: 7.989 8.403 8.781 9.129 9.451 9.750 10.031
Find
dy
dx
and
d y
dx
2
2
at
(i) x = 1.1 (ii) x = 1.6.
2. Find first and second derivatives of the function tabulated below at x = 0.6
x: 0.4 0.5 0.6 0.7 0.8
y: 1.5836 1.7974 2.0442 2.3275 2.6511.
3. Find y′(0) and y″(0) from the given table:
x: 0 1 2 3 4 5
y: 4 8 15 7 6 2
4. Find y′(1.5) and y″(1.5) from the following table:
x: 1.5 2.0 2.5 3 3.5 4
f(x): 3.375 7 13.625 24 38.875 59.
5. Given the following table of values of x and y:
x: 1 1.05 1.1 1.15 1.2 1.25 1.30
y: 1 1.0247 1.0488 1.0723 1.0954 1.1180 1.1401
Find
dy
dx
and
d y
dx
2
2
at
(i) x = 1 (ii) x = 1.25 (iii) x = 1.15.
6. Find y′(4) from the given table:
x: 1 2 4 8 10
y: 0 1 5 21 27.
7. Find the numerical value of y′(10°) for y = sin x given that:
sin 0° = 0.000, sin 10° = 0.1736,
sin 20° = 0.3420, sin 30° = 0.5000, sin 40° = 0.6428.
8. Find
d
dx
( )
J0 at x = 0.1 from the following table:
x: 0.0 0.1 0.2 0.3 0.4
J0(x): 1 0.9975 0.99 0.9776 0.9604.
9. Find the first and second derivatives for the function tabulated below at the point
x = 3.0:
x: 3 3.2 3.4 3.6 3.8 4.0
y: – 14 – 10.032 – 5.296 0.256 6.672 14.
10. (i) A slider in a machine moves along a fixed straight rod. Its distance x cm along the rod
is given below for various values of the time t seconds. Find the velocity of the slider
and its acceleration when t = 0.3 second.
NUMERICAL INTEGRATION AND DIFFERENTIATION 421
t: 0 0.1 0.2 0.3 0.4 0.5 0.6
x: 30.13 31.62 32.87 33.64 33.95 33.81 33.24.
(ii) A slider in a machine moves along a fixed straight rod. Its distance x(in cm) along
the rod is given at various times t (in secs).
t: 0 0.1 0.2 0.3 0.4 0.5 0.6
x: 30.28 31.43 32.98 33.54 33.97 33.48 32.13
Evaluate
dx
dt
at t = .1 and at t = .5.
11. Using Newton’s divided difference formula, find f ′(10) from the following data:
x: 3 5 11 27 34
f(x): – 13 23 899 17315 35606
12. From the table below, for what value of x, y is minimum? Also find this value of y
x: 3 4 5 6 7 8
y: 0.205 0.240 0.259 0.262 0.250 0.224.
13. Given the following table of values, find f ′(8):
x: 6 7 9 12
f(x): 1.556 1.690 1.908 2.158.
14. Find the minimum value of y from the following table:
x: 0.2 0.3 0.4 0.5 0.6 0.7
y: 0.9182 0.8975 0.8873 0.8862 0.8935 0.9086
15. Prove that
d
dx
y
h
x
( ) =
1
(yx+h – yx–h) –
1
2h
(yx+2h – yx–2h) +
1
3h
(yx+3h – yx–3h) – ...
Hint: R.H.S. =
1 E
1 E
E D
1
1 1
h
y
h
y y
x x x
log log ( )
+
+
F
HG
I
KJ =
F
HG I
KJ =
L
N
MM
O
Q
PP
−
16. Find f ′(6) from the following table:
x: 0 1 3 4 5 7 9
f(x): 150 108 0 – 54 – 100 – 144 – 84
17. Take 10 figure logarithm to base 10 from x = 300 to x = 310 by unit increments. Calculate
the first derivative of log10 x when x = 310.
18. Given the following table:
x: 1 1.05 1.1 1.15 1.2 1.25 1.3
f(x) = x : 1 1.0247 1.04881 1.07238 1.09544 1.11803 1.14014
Apply the above results to find f ′(1), f ″(1) and f ″′(1).
19. The following table gives values of pressure P and specific volume V of saturated steam:
P: 105 42.7 25.3 16.7 13
V: 2 4 6 8 10
422 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Find
(a) the rate of change of pressure with respect to volume at V = 2
(b) the rate of change of volume with respect to pressure at P = 105.
20. y is a function of x satisfying the equation xy″ + ay′ + (x – b) y = 0, where a and b are
integers. Find the values of constants a and b if y is given by the following table:
x: 0.8 1 1.2 1.4 1.6 1.8 2 2.2
y: 1.73036 1.95532 2.19756 2.45693 2.73309 3.02549 2.3333 3.65563.
5.5 ERRORS IN NUMERICAL DIFFERENTIATION
In numerical differentiation, the error in the higher order derivatives occurs
due to the fact that, although the tabulated function and its approximating
polynomial would agree at the set of data points, their slopes at these points
may vary considerably. Numerical differentiation is, therefore, an unsatisfactory
process and should be used only in rare cases.
The numerical computation of derivatives involves two types of errors:
truncation errors and rounding errors.
The truncation error is caused by replacing the tabulated function by means
of an interpolating polynomial.
The truncation error in the first derivative =
1
6 2
3
2
3
1
h
y y
Δ Δ
− −
+
.
The truncation error in the second derivative =
1
12 2
4
2
h
y
| |
Δ − .
The rounding error is proportional to
1
h
in the case of the first derivatives,
while it is proportional to
1
2
h
in the case of the second derivatives, and so on.
The maximum rounding error in the first derivative =
3
2
ε
h
The maximum rounding error in the second derivative =
4
2
ε
h
where ε is the maximum error in the value of yi.
Example. Assuming that the table of values given in Example 6 and the function
values are correct to the accuracy given, estimate the errors in
dy
dx
at x = 1.6.
NUMERICAL INTEGRATION AND DIFFERENTIATION 423
Sol. Since the values are correct to four decimals, it follows that
ε = 0.5 × 10–4
Truncation error =
1
6 2
1
2
3
1
3
0
h
y y
Δ Δ
− +
=
+
F
HG I
KJ
1.2
0.0361 0.0441
| See difference table in Example 6
= 0.03342
Rounding error =
3
2
ε
h
=
× ×
×
−
3 0.5 10
2 0.2
4
= 0.00038.
5.6 NUMERICAL INTEGRATION
Given a set of tabulated values of the integrand f(x), determining the value of
x
xn
f x dx
0
z ( ) is called numerical integration. The given interval of integration is
subdivided into a large number of subintervals of equal width h and the function
tabulated at the points of subdivision is replaced by any one of the interpolating
polynomials like Newton-Gregory’s, Stirling’s, Bessel’s over each of the
subintervals and the integral is evaluated. There are several formulae for
numerical integration which we shall derive in the sequel.
Y
O x0
y0 y1 y2 yn
x + h
0 x + 2h
0 x + nh
0
X
y = f(x)
5.7 NEWTON-COTE’S QUADRATURE FORMULA
Let I = y dx
a
b
z , where y takes the values y0, y1, y2, ......., yn for x = x0, x1, x2, ......, xn.
424 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Let the interval of integration (a, b) be divided into n equal sub-intervals,
each of width h =
b a
n
−
so that
x0 = a, x1 = x0 + h, x2 = x0 + 2h, ......., xn = x0 + nh = b.
∴ I = f x dx
x
x nh
( )
0
0 +
z
Since any x is given by x = x0 + rh and dx = hdr
∴ I = h f x rh dr
n
( )
0
0
+
z
= h y r y
r r
y
r r r
y dr
n
0 0
2
0
3
0
0
1
2
1 2
3
+ +
−
+
− −
+
L
NM O
QP
z Δ Δ Δ
( )
!
( )( )
!
.......
[by Newton’s forward interpolation formula]
= h ry
r
y
r r
y
0
2
0
3 2
2
0
2
1
2 3 2
+ + −
F
HG
I
KJ
L
N
MM Δ Δ
+ − +
F
HG
I
KJ +
O
Q
PP
1
6 4
4
3 2 3
0
0
r
r r y
n
Δ .......
= nh y
n
y
n n
y
n n
y
0 0
2
0
2
3
0
2
2 3
12
2
24
+ +
−
+
−
+
L
NM O
QP
Δ Δ Δ
( ) ( )
........ (49)
This is a general quadrature formula and is known as Newton-Cote’s
quadrature formula. A number of important deductions viz. Trapezoidal rule,
Simpson’s one-third and three-eighth rules, Weddle’s rule can be immediately
deduced by putting n = 1, 2, 3, and 6, respectively, in formula (49).
5.8 TRAPEZOIDAL RULE (n = 1)
Putting n = 1 in formula (49) and taking the curve through (x0, y0) and (x1, y1)
as a polynomial of degree one so that differences of an order higher than one
vanish, we get
f x dx h y y
h
y y y
h
y y
x
x h
( ) [ ( )] ( )
= +
F
HG I
KJ = + − = +
+
z 0 0 0 1 0 0 1
1
2 2
2
2
0
0
Δ
NUMERICAL INTEGRATION AND DIFFERENTIATION 425
Similarly, for the next sub-interval (x0 + h, x0 + 2h), we get
f x dx
h
y y
x h
x h
( ) ( ) , ......,
= +
+
+
z 2
1 2
2
0
0
f x dx
h
y y
n n
x n h
x nh
( ) ( )
( )
= +
−
+ −
+
z 2
1
1
0
0
Adding the above integrals, we get
f x dx
h
y y y y y
n n
x
x nh
( ) [( ) ( ...... )]
= + + + + + −
+
z 2
2
0 1 2 1
0
0
which is known as Trapezoidal rule. By increasing the number of subintervals,
thereby making h very small, we can improve the accuracy of the value of the
given integral.
5.9 SIMPSON’S ONE-THIRD RULE (n = 2)
Putting n = 2 in formula (49) and taking the curve through (x0, y0), (x1, y1) and
(x2, y2) as a polynomial of degree two so that differences of order higher than
two vanish, we get
f x dx h y y y
x
x h
( ) = + +
L
NM O
QP
+
z 2
1
6
0 0
2
0
2
0
0
Δ Δ
=
2
6
6 2
0 1 0 2 1 0
h
y y y y y y
[6 ( ) ( )]
+ − + − +
=
h
y y y
3
4
0 1 2
( )
+ +
Similarly,
f x dx
h
x h
x h
( ) =
+
+
z 3
0
0
2
4
(y2 + 4y3 + y4), ...... ,
f x dx
h
y y y
n n n
x n h
x nh
( ) ( )
( )
= + +
− −
+ −
+
z 3
4
2 1
2
0
0
Adding the above integrals, we get
f x dx
h
x
x nh
( ) =
+
z 3
0
0
[(y0 + yn) + 4(y1 + y3 + ... + yn–1)
+ 2(y2 + y4 + ... + yn–2)]
which is known as Simpson’s one-third rule.
426 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
While using this formula, the given interval of integration must be
divided into an even number of sub-intervals, since we find the area over
two sub-intervals at a time.
5.10 SIMPSON’S THREE-EIGHTH RULE (n = 3)
Putting n = 3 in formula (49) and taking the curve through (x0, y0), (x1, y1),
(x2, y2), and (x3, y3) as a polynomial of degree three so that differences of order
higher than three vanish, we get
f x dx h y y y y
x
x h
( ) = + + +
F
HG I
KJ
+
z 3
3
2
3
4
1
8
0 0
2
0
3
0
3
0
0
Δ Δ Δ
=
3
8
h
[8y0 + 12(y1 – y0) + 6(y2 – 2y1 + y0) + (y3 – 3y2 + 3y1 – y0)]
=
3
8
h
[y0 + 3y1 + 3y2 + y3]
Similarly, f x dx
h
x h
x h
( ) =
+
+
z 3
8
0
0
3
6
[y3 + 3y4 + 3y5 + y6], ...
f x dx
h
x n h
x h
( )
(
=
+ −
+
z 3
8
0
0
3)
6
[yn–3 + 3yn–2 + 3yn–1 + yn]
Adding the above integrals, we get
f x dx
h
x
x nh
( ) =
+
z 3
8
0
0
[(y0 + yn) + 3(y1 + y2 + y4 + y5
+ ..... + yn–2 + yn–1) + 2(y3 + y6 + ...... + yn–3)]
which is known as Simpson’s three-eighth rule.
While using this formula, the given interval of integration must be
divided into sub-intervals whose number n is a multiple of 3.
5.11 BOOLE’S RULE
Putting n = 4 in formula (49) and neglecting all differences of order higher
than four, we get
NUMERICAL INTEGRATION AND DIFFERENTIATION 427
x
x h
f x dx
0
0 4
+
z ( ) = h y r y
r r
y
r r r
y
0 0
2
0
3
0
0
4 1
2
1 2
3
+ +
−
+
− −
L
NM
z Δ Δ Δ
( )
!
( )( )
!
+
− − − O
QP
r r r r
y dr
( )( )( )
!
1 2 3
4
4
0
Δ
| By Newton’s forward interpolation formula
= 4h y
n
y
n n
y
n n
y
0 0
2
0
2
3
0
2
2 3
12
2
24
+ +
−
+
−
L
N
MM Δ Δ Δ
( ) ( )
+ − + −
F
HG
I
KJ
O
Q
PP
n n n
n
y
4 3 2 4
0
0
4
5
3
2
11
3
3
4
Δ
!
= 4 2
5
3
3
2
7
90
0 0
2
0
3
0
4
0
h y y y y y
+ + + +
L
NM O
QP
Δ Δ Δ Δ
=
2
45
h
(7y0 + 32y1 + 12y2 + 32y3 + 7y4)
Similarly, f x dx
h
x h
x h
( )
0
0
4
8 2
45
+
+
z = (7y4 + 32y5 + 12y6 + 32y7 + 7y8) and so on.
Adding all these integrals from x0 to x0 + nh, where n is a multiple of 4, we
get
f x dx
h
x
x nh
( ) =
+
z 2
45
0
0
[7y0 + 32y1 + 12y2 + 32y3 + 14y4 + 32 y5
+ 12y6 + 32y7 + 14y8 + ......]
This is known as Boole’s rule.
While applying Boole’s rule, the number of sub-intervals should be
taken as a multiple of 4.
5.12 WEDDLE’S RULE (n = 6)
Putting n = 6 in formula (49) and neglecting all differences of order higher than
six, we get
428 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
x
x h
f x dx h y r y
r r
y
r r r
y
0
0 6
0 0
2
0
3
0
0
6 1
2
1 2
3
+
z z
= + +
−
+
− −
L
NM
( )
( )
!
( )( )
!
Δ Δ Δ
+
− − −
+
− − − −
r r r r
y
r r r r r
y
( )( )( )
!
( )( )( )( )
!
1 2 3
4
1 2 3 4
5
4
0
5
0
Δ Δ
+
− − − − − O
QP
r r r r r r
y dr
( )( )( )( )( )
!
1 2 3 4 5
6
6
0
Δ
= h ry
r
y
r r
y
r
r r y
0
2
0
3 2
2
0
4
3 2 3
0
2
1
2 3 2
1
6 4
+ + −
F
HG
I
KJ + − +
F
HG
I
KJ
L
N
MM
Δ Δ Δ
+ − + −
F
HG
I
KJ
1
24 5
3
2
11
3
3
5 4 3
2 4
0
r r r
r y
Δ
+ − + − +
F
HG
I
KJ
1
120 6
2
35
4
50
3
12
6
5
4 3
2 5
0
r
r
r r
r y
Δ
+ − + − + −
F
HG
I
KJ
O
Q
PP
1
720 7
5
2
17
225
4
274
3
60
7 6
5
4 3
2 6
0
0
6
r r
r
r r
r y
Δ
= 6h y y y y y
0 0
2
0
3
0
4
0
3
9
2
4
41
20
+ + + +
L
NM Δ Δ Δ Δ
+ +
O
QP
11
20
41
840
5
0
6
0
Δ Δ
y y
=
6
20
20 60 90 80 41
0 0
2
0
3
0
4
0
h
y y y y y
+ + + +
L
N
MM Δ Δ Δ Δ
+ +
O
QP
11
41
42
5
0
6
0
Δ Δ
y y
=
3
10
h
[20y0 + 60(y1 – y0) + 90(y2 – 2y1 + y0)
+ 80(y3 – 3y2 + 3y1 – y0)
+ 41(y4 – 4y3 + 6y2 – 4y1 + y0)
+ 11 (y5 –5y4 + 10y3 – 10y2 + 5y1 – y0)
+ (y6 – 6y5 + 15y4 – 20y3
+ 15y2 – 6y1 + y0)] ∵
41
42
1
~
−
L
NM O
QP
NUMERICAL INTEGRATION AND DIFFERENTIATION 429
=
3
10
h
[y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6]
Similarly,
f x dx
h
x h
x h
( ) =
+
+
z 3
10
0
0
6
12
[y6 + 5y7 + y8 + 6y9 + y10 + 5y11 + y12]
...................................................................................................
...................................................................................................
f x dx
h
x n h
x nh
( )
( )
=
+ −
+
z 3
10
0
0
6
[yn–6 + 5yn–5 + yn–4 + 6yn–3 + yn–2 + 5yn–1 + yn]
Adding the above integrals, we get
f x dx
h
x
x nh
( ) =
+
z 3
10
0
0
[y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + 2y6
+ 5y7 + y8 + 6y9 + y10 + 5y11 + 2y12 + ......]
which is known as Weddle’s rule. Here n must be a multiple of 6.
5.13 ALGORITHM OF TRAPEZOIDAL RULE
Step 01. Start of the program.
Step 02. Input Lower limit a
Step 03. Input Upper Limit b
Step 04. Input number of sub intervals n
Step 05. h=(b-a)/n
Step 06. sum=0
Step 07. sum=fun(a)+fun(b)
Step 08. for i=1; in; i++
Step 09. sum +=2*fun(a+i)
Step 10. End Loop i
Step 11. result =sum*h/2;
Step 12. Print Output result
Step 13. End of Program
Step 14. Start of Section fun
Step 15. temp = 1/(1+(x*x))
Step 16. Return temp
Step 17. End of Section fun.
430 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
5.14 FLOW-CHART FOR TRAPEZOIDAL RULE
START
STOP
Define function y(x)
Get values x , x , n
0 n
h = (x – x )/n
n 0
s = y(x ) + y(xn)
0
Loop for i = 1 to n – 1
s + = 2 * y * (x + i * h)
0
End loop(i)
t = (h/2) * s
Print ‘‘soln.’’, t
NUMERICAL INTEGRATION AND DIFFERENTIATION 431
/* ***********************************************************
5.15 PROGRAM TO IMPLEMENT TRAPEZOIDAL METHOD OF
NUMERICAL INTEGRATION
*********************************************************** */
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... Function Prototype Declaration
float fun(float);
//... Main Execution Thread
void main()
{
//... Variable Declaration Field
//... Floating Type
float result=1;
float a,b;
float h,sum;
//... Integer Type
int i,j;
int n;
//... Invoke Clear Screen Function
clrscr();
//... Input Section
//... Input Range
printf(“nn Enter the range - ”);
printf(“nn Lower Limit a - ”);
scanf(“%f” ,a);
432 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(“nn Upper Limit b - );
scanf(“%f” ,b);
//... Input Number of subintervals
printf(“nn Enter number of subintervals - ”);
scanf(“%d” ,n);
//... Calculation and Processing Section
h=(b-a)/n;
sum=0;
sum=fun(a)+fun(b);
for(i=1;in;i++)
{
sum+=2*fun(a+i);
}
result=sum*h/2;
//... Output Section
printf(“nnnn Value of the integral is %6.4ft”,result);
//...Invoke User Watch Halt Function
printf(“nnn Press Enter to Exit”);
getch();
}
//... Termination of Main Execution Thread
//... Function Body
float fun(float x)
{
float temp;
temp = 1/(1+(x*x));
return temp;
}
//... Termination of Function Body
NUMERICAL INTEGRATION AND DIFFERENTIATION 433
5.16 OUTPUT
Enter the range -
Lower Limit a - 0
Upper Limit b - 6
Enter number of subintervals - 6
Value of the integral is 1.4108
Press Enter to Exit
5.17 ALGORITHM OF SIMPSON’S 3/8th RULE
Step 01. Start of the program.
Step 02. Input Lower limit a
Step 03. Input Upper limit b
Step 04. Input number of sub itervals n
Step 05. h = (b – a)/n
Step 06. sum = 0
Step 07. sum = fun(a) + fun (b)
Step 08. for i = 1; i  n; i++
Step 09. if i%3=0:
Step 10. sum + = 2*fun(a + i*h)
Step 11. else:
Step 12. sum + = 3*fun(a+(i)*h)
Step 13. End of loop i
Step 14. result = sum*3*h/8
Step 15. Print Output result
Step 16. End of Program
Step 17. Start of Section fun
Step 18. temp = 1/(1+(x*x))
Step 19. Return temp
Step 20. End of section fun
434 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
5.18 FLOW-CHART OF SIMPSON’S 3/8th RULE
START
STOP
Define fn. f(x)
Get values x , x , n
0 n
h = (x – x )/n
n 0
Sum = 0
Sum = f(a) + f(b)
Loop for i = 1 to n
Sum + = 2 * f(a + i * h)
Sum + = 3 * f(a + i * h)
End loop i
Print sum
Yes
No
Is
i% 3 = 0
NUMERICAL INTEGRATION AND DIFFERENTIATION 435
/*************************************************************
5.19 PROGRAM TO IMPLEMENT SIMPSON’S 3/8th METHOD OF
NUMERICAL INTEGRATION
***************************************************************/
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... Function Prototype Declaration
float fun(float);
//... Main Execution Thread
void main()
{
//... Variable Declaration Field
//... Floating Type
float result=1;
float a,b;
float h,sum;
//...Integer Type
int i,j;
int n;
//...Invoke Clear Screen Function
clrscr();
//...Input Section
//...Input Range
printf(nn Enter the range - );
printf(nn Lower Limit a - );
scanf(%f ,a);
436 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(nn Upper Limit b - );
scanf(%f ,b);
//...Input Number of Subintervals
printf(nn Enter number of subintervals - );
scanf(%d ,n);
//...Calculation and Processing Section
h=(b-a)/n;
sum=0;
sum=fun(a)+fun(b);
for(i=1;in;i++)
{
if(i%3==0)
{
sum+=2*fun(a+i*h)
}
else
{
sum+=3*fun(a+(i)*h);
}
}
result=sum*3*h/8;
//... Output Section
printf(nnnn Value of the integral is %6.4ft,result);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch();
}
//... Termination of Main Execution Thread
//... Function Body
NUMERICAL INTEGRATION AND DIFFERENTIATION 437
float fun(float x)
{
float temp;
temp=1/(1+(x*x));
return temp;
}
//... Termination of Function Body
5.20 OUTPUT
Enter the range -
Lower Limit a - 0
Upper Limit b - 6
Enter number of subintervals - 6
Value of the integral is 1.3571
Press Enter to Exit
5.21 ALGORITHM OF SIMPSON’S 1/3rd RULE
Step 01. Start of the program.
Step 02. Input Lower limit a
Step 03. Input Upper limit b
Step 04. Input number of subintervals n
Step 05. h=(b–a)/n
Step 06. sum=0
Step 07. sum=fun(a)+4*fun(a+h)+fun(b)
Step 08. for i=3; in; i + = 2
Step 09. sum + = 2*fun(a+(i – 1)*h) + 4*fun(a+i*h)
Step 10. End of loop i
Step 11. result=sum*h/3
Step 12. Print Output result
Step 13. End of Program
Step 14. Start of Section fun
Step 15. temp = 1/(1+(x*x))
438 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Step 16. Return temp
Step 17. End of Section fun
5.22 FLOW-CHART OF SIMPSON’S 1/3rd RULE
START
STOP
Define fn y(x)
Get values of x , x , n
0 n
h = (x – x )/n
n 0
s = y + y + 4y
0 n 1
Loop for i = 3 to n – 1 step 2
s + = 4 * y + 2 * y
i i + 1
End loop (i)
P = s * (h/3)
Print ''solution'', P
NUMERICAL INTEGRATION AND DIFFERENTIATION 439
/* ***********************************************************
5.23 PROGRAM TO IMPLEMENT SIMPSON’S 1/3rd METHOD OF
NUMERICAL INTEGRATION
*********************************************************** */
//... HEADER FILES DECLARATION
# include stdio.h
# include conio.h
# include math.h
# include process.h
# include string.h
//... Function Prototype Declaration
float fun(float);
//... Main Execution Thread
void main()
{
//...Variable Declaration Field
//... Floating Type
float result=1;
float a,b;
float h,sum;
//... Integer Type
int i,j;
int n;
//... Invoke Clear Screen Function
clrscr();
//... Input Section
//...Input Range
printf(nn Enter the range - );
440 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
printf(nn Lower Limit a - );
scanf(%f ,a);
printf(nn Upper Limit b - );
scanf(%f ,b);
//... Input Number of Subintervals
printf(nn Enter number of subintervals - );
scanf(%d,n);
//... Calculation and Processing Section
h=(b-a)/n;
sum=0;
sum=fun(a)+4*fun(a+h)fun(b);
for(i=3;in;i+=2)
{
sum+=2*fun(a+(i-1)*h)+4*fun(a+i*h);
}
result=sum*h/3;
//... Output Section
printf(nnnn Value of the integral is %6.4ft,result);
//... Invoke User Watch Halt Function
printf(nnn Press Enter to Exit);
getch();
}
//... Termination of Main Execution Thread
//... Function Body
float fun(float x)
{
float temp;
temp=1/(1+(x*x));
return temp;
}
//... Termination of Function Body
NUMERICAL INTEGRATION AND DIFFERENTIATION 441
5.24 OUTPUT
Enter the range -
Lower Limit a - 0
Upper Limit b - 6
Enter number of subintervals - 6
Value of the integral is 1.3662
Press Enter to Exit
EXAMPLES
Example 1. Use Trapezoidal rule to evaluate x dx
3
0
1
z considering five sub-
intervals.
Sol. Dividing the interval (0, 1) into 5 equal parts, each of width h =
1 0
5
−
= 0.2, the values of f(x) = x3 are given below:
x: 0 0.2 0.4 0.6 0.8 1.0
f(x): 0 0.008 0.064 0.216 0.512 1.000
y0 y1 y2 y3 y4 y5
By Trapezoidal rule, we have
x dx
h
3
0
1
2
=
z [(y0 + y5) + 2(y1 + y2 + y3 + y4)]
=
0.2
2
[(0 + 1) + 2(0.008 + 0.064 + 0.216 + 0.512)]
= 0.1 × 2.6 = 0.26.
Example 2. Evaluate
dx
1 x2
0
1
+
z using
(i) Simpson’s
1
3
rule taking h =
1
4
(ii) Simpson’s
3
8
rule taking h =
1
6
(iii) Weddle’s rule taking h =
1
6
Hence compute an approximate value of π in each case.
442 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. (i) The values of f(x) =
1
1 2
+ x
at x = 0,
1
4
2
4
3
4
1
, , , are given below:
x: 0
1
4
1
2
3
4
1
f(x): 1
16
17
0.8 0.64 0.5
y0 y1 y2 y3 y4
By Simpson’s
1
3
rule,
dx
x
h
1 3
2
0
1
+
=
z [(y0 + y4) + 4(y1 + y3) + 2y2]
=
1
12
1 4
16
17
2
( ) ( )
+ + +
R
S
T
U
V
W+
L
NM O
QP
0.5 .64 0.8 = 0.785392156
Also
dx
x
x
1
1
4
2
0
1
0
1
+
=
L
N
MM
O
Q
PP
= =
z tan tan
–1 –1 π
∴
π
4
~
– 0.785392156 ⇒ π ~
– 3.1415686
(ii) The values of f(x) =
1
1 2
+ x
at x = 0,
1
6
2
6
3
6
4
6
5
6
1
, , , , , are given below:
x: 0
1
6
2
6
3
6
4
6
5
6
1
f(x): 1
36
37
9
10
4
5
9
13
36
61
1
2
y0 y1 y2 y3 y4 y5 y6
By Simpson’s
3
8
rule,
0
1
2
1
3
8
z +
=
dx
x
h
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
NUMERICAL INTEGRATION AND DIFFERENTIATION 443
=
3
1
6
8
1
1
2
3
36
37
9
10
9
13
36
61
2
4
5
F
HG I
KJ
+
F
HG I
KJ + + + +
R
S
T
U
V
W+
F
HG I
KJ
L
NM O
QP
= 0.785395862
Also,
0
1
2
1 4
z +
=
dx
x
π
∴
π
4
= 0.785395862
⇒ π = 3.141583
(iii) By Weddle’s rule, using the values as in (ii),
0
1
2
1
3
10
z +
=
dx
x
h
(y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6)
=
3
1
6
10
1 5
36
37
9
10
6
4
5
9
13
5
36
61
1
2
F
HG I
KJ
+
F
HG I
KJ + +
F
HG I
KJ + +
F
HG I
KJ +
R
S
T
U
V
W
= 0.785399611
Since
0
1
2
1 4
z +
=
dx
x
π
∴
π
4
= 0.785399611
⇒ π = 3.141598.
Example 3. Evaluate
0
6
2
dx
1 x
z +
by using
(i) Simpson’s one-third rule
(ii) Simpson’s three-eighth rule
(iii) Trapezoidal rule
(iv) Weddle’s rule.
444 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Divide the interval (0, 6) into six parts each of width h = 1.
The values of f(x) =
1
1 2
+ x
are given below:
x: 0 1 2 3 4 5 6
f(x): 1 0.5 0.2 0.1
1
17
1
26
1
37
y0 y1 y2 y3 y4 y5 y6
(i) By Simpson’s one-third rule,
0
6
2
1 3
z +
=
dx
x
h
[(y0 + y6) + 4(y1 + y3 + y5) + 2(y2 + y4)]
=
1
3
1
1
37
4 2
1
17
+
F
HG I
KJ + + +
F
HG I
KJ + +
F
HG I
KJ
L
NM O
QP
0.5 0.1
1
26
0.2
= 1.366173413.
(ii) By Simpson’s three-eighth rule,
0
6
2
1
3
8
z +
=
dx
x
h
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
=
3
8
1
1
37
3
1
17
1
26
2
+
F
HG I
KJ + + + +
F
HG I
KJ +
L
NM O
QP
.5 .2 .1
( )
= 1.357080836.
(iii) By Trapezoidal rule,
0
6
2
1 2
z +
=
dx
x
h
[(y0 + y6) + 2(y1 + y2 + y3 + y4 + y5)]
=
1
2
1
1
37
2
1
17
1
26
+
F
HG I
KJ + + + + +
F
HG I
KJ
L
NM O
QP
.5 .2 .1
= 1.410798581.
(iv) By Weddle’s rule,
0
6
2
1
3
10
z +
=
dx
x
h
[y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6]
NUMERICAL INTEGRATION AND DIFFERENTIATION 445
=
3
10
1 5 5
1
26
1
37
+ + +
F
HG I
KJ +
L
NM O
QP
( )
.5 .2 + 6(.1) +
1
17
= 1.373447475.
Example 4. The speed, v meters per second, of a car, t seconds after it starts, is
shown in the following table:
t 0 12 24 36 48 60 72 84 96 108 120
v 0 3.60 10.08 18.90 21.60 18.54 10.26 5.40 4.50 5.40 9.00
Using Simpson’s rule, find the distance travelled by the car in 2 minutes.
Sol. If s meters is the distance covered in t seconds, then
ds
dt
= v
∴ s v dt
t
t
L
NM O
QP =
=
=
z
0 0
120
120
since the number of sub-intervals is 10 (even). Hence, by using Simpson’s
1
3
rd
rule,
0
120
3
z =
v dt
h
[(v0 + v10) + 4(v1 + v3 + v5 + v7 + v9) + 2(v2 + v4 + v6 + v8)]
=
12
3
[(0 + 9) + 4(3.6 + 18.9 + 18.54 + 5.4 + 5.4)
+ 2(10.08 + 21.6 + 10.26 + 4.5)]
= 1236.96 meters.
Hence, the distance travelled by car in 2 minutes is 1236.96 meters.
Example 5. Evaluate
0.6
2
y dx
z , where y is given by the following table:
x: 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
y: 1.23 1.58 2.03 4.32 6.25 8.36 10.23 12.45.
Sol. Here the number of subintervals is 7, which is neither even nor a multiple
of 3. Also, this number is neither a multiple of 4 nor a multiple of 6, hence
using Trapezoidal rule, we get
446 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
0.6
2
2
z =
y dx
h
[(y0 + y7) + 2(y1 + y2 + y3 + y4 + y5 + y6)]
=
0.2
2
[(1.23 + 12.45) + 2(1.58 + 2.03 + 4.32 + 6.25 + 8.36 + 10.23)]
| Here h = 0.2
= 7.922.
Example 6. Find
1
11
f(x) dx
z , where f(x) is given by the following table, using a
suitable integration formula.
x: 1 2 3 4 5 6 7 8 9 10 11
f(x): 543 512 501 489 453 400 352 310 250 172 95
Sol. Since the number of subintervals is 10 (even) hence we shall use Simpson’s
1
3
rd rule.
f x dx
h
( )
1
11
3
z = [(y0 + y10) + 4(y1 + y3 + y5 + y7 + y9) + 2(y2 + y4 + y6 + y8)]
=
1
3
[(543 + 95) + 4(512 + 489 + 400 + 310 + 172)
+ 2(501 + 453 + 352 + 250)]
=
1
3
[638 + 7532 + 3112] = 3760.67.
Example 7. Evaluate
dx
1 x
0
1
+
z by dividing the interval of integration into 8 equal
parts. Hence find loge 2 approximately.
Sol. Since the interval of integration is divided into an even number of
subintervals, we shall use Simpson’s one-third rule.
Here, y =
1
1 + x
= f(x)
y0 = f(0) =
1
1 0
+
= 1, y1 = f
1
8
1
1
1
8
8
9
F
HG I
KJ =
+
= , y2 = f
2
8
4
5
F
HG I
KJ =
y3 = f
3
8
8
11
F
HG I
KJ = , y4 = f
4
8
2
3
F
HG I
KJ = , y5 = f
5
8
8
13
F
HG I
KJ =
NUMERICAL INTEGRATION AND DIFFERENTIATION 447
y6 = f
6
8
4
7
F
HG I
KJ = , y7 = f
7
8
8
15
F
HG I
KJ = and y8 = f(1) =
1
2
Hence the table of values is
x: 0
1
8
2
8
3
8
4
8
5
8
6
8
7
8
1
y: 1
8
9
4
5
8
11
2
3
8
13
4
7
8
15
1
2
y0 y1 y2 y3 y4 y5 y6 y7 y8
By Simpson’s
1
3
rd rule,
0
1
1 3
z +
=
dx
x
h
[(y0 + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)]
=
1
24
1
1
2
4
8
9
8
11
8
13
8
15
2
4
5
2
3
4
7
+
F
HG I
KJ + + + +
F
HG I
KJ + + +
F
HG I
KJ
L
NM O
QP
| Here h = 1/8
= 0.69315453
Since,
0
1
0
1
1
1
z +
= +
L
NMM
O
QPP
dx
x
x
e
log ( ) = loge 2
∴ loge 2 = 0.69315453.
Example 8. Find, from the following table, the area bounded by the curve and
the x-axis from x = 7.47 to x = 7.52.
x: 7.47 7.48 7.49 7.50 7.51 7.52
f(x): 1.93 1.95 1.98 2.01 2.03 2.06.
Sol. We know that
Area =
7.47
7.52
z f x dx
( )
with h = 0.01, the trapezoidal rule gives,
Area =
.01
2
[(1.93 + 2.06) + 2(1.95 + 1.98 + 2.01 + 2.03)]
= 0.09965.
448 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 9. Use Simpson’s rule for evaluating
−
z0.6
0.3
f(x) dx
from the table given below:
x: – 0.6 – 0.5 – 0.4 – 0.3 – 0.2 – 0.1 0 .1 .2 .3
f(x): 4 2 5 3 – 2 1 6 4 2 8
Sol. Since the number of subintervals is 9(a multiple of 3), we will use Simpson’s
3/8th rule here.
∴
−
z =
0.6
0.3 .1
f x dx
( )
( )
3
8
[(4 + 8) + 3{2 + 5 + (– 2) + 1 + 4 + 2} + 2(3 + 6)]
= 2.475.
Example 10. Evaluate
1
2
1
2
x
e dx
z −
using four intervals.
Sol. The table of values is:
x: 1 1.25 1.5 1.75 2
y = e–x/2: .60653 .53526 .47237 .41686 .36788
y0 y1 y2 y3 y4
Since we have four (even) subintervals here, we will use Simpson’s
1
3
rd
rule.
∴
1
2
1
2
3
z −
=
e dx
h
x
[(y0 + y4) + 4(y1 + y3) + 2y2]
=
.25
3
[(.60653 + .36788) + 4(.53526) + .41686) + 2(.47237)]
= 0.4773025.
Example 11. Find
e
1 x
dx
x
0
6
+
z approximately using Simpson’s
3
8
th rule
on integration.
Sol. Divide the given integral of integration into 6 equal subintervals, the
arguments are 0, 1, 2, 3, 4, 5, 6; h = 1.
f(x) =
e
x
x
1+
; y0 = f(0) = 1
NUMERICAL INTEGRATION AND DIFFERENTIATION 449
y1 = f(1) =
e
2
, y2 = f(2) =
e2
3
, y3 = f(3) =
e3
4
,
y4 = f(4) =
e4
5
, y5 = f(5) =
e5
6
, y6 = f(6) =
e6
7
The table is as below:
x: 0 1 2 3 4 5 6
y: 1
e
2
e2
3
e3
4
e4
5
e5
6
e6
7
y0 y1 y2 y3 y4 y5 y6
Applying Simpson’s three-eighth rule, we have
0
6
1
3
8
z +
=
e
x
dx
h
x
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
=
3
8
1
7
3
2 3 5 6
2
4
6 2 4 5 3
+
F
HG
I
KJ + + + +
F
HG
I
KJ +
L
N
MM
O
Q
PP
e e e e e e
=
3
8
[(1 + 57.6327) + 3(1.3591 + 2.463 + 10.9196
+ 24.7355 + 2(5.0214)]
= 70.1652.
It is not possible to evaluate
0
6 x
e
1 x
dx
z +
by using usual calculus method.
Numerical integration comes to our rescue in such situations.
Example 12. A train is moving at the speed of 30 m/sec. Suddenly brakes are
applied. The speed of the train per second after t seconds is given by
Time (t): 0 5 10 15 20 25 30 35 40 45
Speed (v): 30 24 19 16 13 11 10 8 7 5
Apply Simpson’s three-eighth rule to determine the distance moved by the
train in 45 seconds.
Sol. If s meters is the distance covered in t seconds, then
ds
dt
v
= ⇒ s v dt
t
t
L
NM O
QP =
=
=
z
0 0
45
45
NOTE
450 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since the number of subintervals is 9 (a multiple of 3) hence by using
Simpson’s
3
8
F
HG I
KJ
th
rule,
0
45 3
8
z =
v dt
h
[(v0 + v9) + 3(v1 + v2 + v4 + v5 + v7 + v8) + 2(v3 + v6)]
=
15
8
[(30 + 5) + 3(24 + 19 + 13 + 11 + 8 + 7) + 2(16 + 10)]
= 624.375 meters.
Hence the distance moved by the train in 45 seconds is 624.375 meters.
Example 13. Evaluate
0
4
2
dx
1 x
z +
using Boole’s rule taking
(i) h = 1 (ii) h = 0.5
Compare the results with the actual value and indicate the error in both.
Sol. (i) Dividing the given interval into 4 equal subintervals (i.e., h = 1), the
table is as follows:
x: 0 1 2 3 4
y: 1
1
2
1
5
1
10
1
17
y0 y1 y2 y3 y4
using Boole’s rule,
0
4 2
45
z =
y dx
h
[7y0 + 32y1 + 12y2 + 32y3 + 7y4]
=
2 1
45
7 1 32
1
2
12
1
5
32
1
10
7
1
17
( )
( ) +
F
HG I
KJ +
F
HG I
KJ +
F
HG I
KJ +
F
HG I
KJ
L
NM O
QP
= 1.289412 (approx.)
∴
0
4
2
1
z +
dx
x
= 1.289412.
NUMERICAL INTEGRATION AND DIFFERENTIATION 451
(ii) Dividing the given interval into 8 equal subintervals (i.e., h = 0.5), the
table is as follows:
x: 0 .5 1 1.5 2 2.5 3 3.5 4
y: 1 0.8 0.5
4
13
.2
4
29
.1
4
53
1
17
y0 y1 y2 y3 y4 y5 y6 y7 y8
using Boole’s rule,
0
4
z ydx =
2
45
7 32 12 32 7
0 1 2 3 4
h
y y y y y
[ ( ) ( ) ( ) ( ) ( )
+ + + +
+ 7 32 12 32 7
4 5 6 7 8
( ) ( ) ( ) ( ) ( )]
y y y y y
+ + + +
=
1
45
7 1 32 8 12 5 32
4
13
7 2 7 2
( ) (. ) (. ) (. ) (. )
+ + +
F
HG I
KJ + +
L
NM
+
F
HG I
KJ +
32
4
29
12 1
(. ) +
F
HG I
KJ +
F
HG I
KJO
QP
32
4
53
7
1
17
= 1.326373
∴
0
4
2
1
z +
dx
x
= 1.326373
But the actual value is
0
4
2
1
z +
dx
x
= tan−
F
HG
I
KJ
1
0
4
x = tan–1 (4) = 1.325818
Error in result I =
1325818 1289412
1325818
100
. .
.
−
F
HG I
KJ × = 2.746%
Error in result II =
1325818 1326373
1325818
100
. .
.
−
F
HG I
KJ × = – 0.0419%.
Example 14. A river is 80 m wide. The depth ‘y’ of the river at a distance ‘x’
from one bank is given by the following table:
x: 0 10 20 30 40 50 60 70 80
y: 0 4 7 9 12 15 14 8 3
452 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Find the approximate area of cross-section of the river using
(i) Boole’s rule.
(ii) Simpson’s
1
3
rd rule.
Sol. The required area of the cross-section of the river
=
0
80
z y dx
Here the number of sub intervals is 8.
(i) By Boole’s rule,
0
80 2
45
z =
y dx
h
[7y0 + 32y1 + 12y2 + 32y3 + 7y4 + 7y4
+ 32y5 + 12y6 + 32y7 + 7y8]
=
2 10
45
( )
[7(0) + 32(4) + 12(7) + 32(9) + 7(12) + 7(12) + 32(15)
+ 12(14) + 32(8) + 7(3)]
= 708
Hence the required area of the cross-section of the river = 708 sq. m.
(ii) By Simpson’s
1
3
rd rule
0
80
3
z =
y dx
h
[(y0 + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)]
=
10
3
[(0 + 3) + 4(4 + 9 + 15 + 8) + 2(7 + 12 + 14)]
= 710
Hence the required area of the cross-section of the river = 710 sq. m.
Example 15. Evaluate
0.2
1.4
z (sin x – loge x + ex) dx approximately using Weddle’s
rule correct to 4 decimals.
Sol. Let f(x) = sin x – log x + ex. Divide the given interval of integration into 12
equal parts so that the arguments are: 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
1.1, 1.2, 1.3, 1.4.
NUMERICAL INTEGRATION AND DIFFERENTIATION 453
The corresponding entries are
y0 = f(0.2) = 3.0295, y1 = f(0.3) = 2.8494, y2 = f(0.4) = 2.7975,
y3 = f(0.5) = 2.8213, y4 = f(0.6) = 2.8976, y5 = f(0.7) = 3.0147
y6 = f(0.8) = 3.1661, y7 = f(0.9) = 3.3483, y8 = f(1) = 3.5598,
y9 = f(1.1) = 3.8001, y10 = f(1.2) = 4.0698, y11 = f(1.3) = 4.3705
y12 = f(1.4) = 4.7042
Now, by Weddle’s rule,
0.2
1.4
z =
f x dx
h
( )
3
10
[y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6 + y6
+ 5y7 + y8 + 6y9 + y10 + 5y11 + y12]
=
3
10
(0.1)[3.0295 + 14.2470 + 2.7975 + 16.9278 + 2.8976
+ 15.0735 + 3.1661 + 3.1661 + 16.7415 + 3.5598
+ 22.8006 + 4.0698 + 21.8525 + 4.7042]
= (0.03)[135.0335] = 4.051.
Example 16. A solid of revolution is formed by rotating about x-axis, the lines
x = 0 and x = 1 and a curve through the points with the following coordinates.
x: 0 0.25 0.5 0.75 1
y: 1 0.9896 0.9589 0.9089 0.8415
Estimate the volume of the solid formed using Simpson’s rule.
Sol. If V is the volume of the solid formed then we know that
V = π y dx
2
0
1
z
Hence we need the values of y2 and these are tabulated below correct to
four decimal places
x 0 .25 .5 .75 1
y2 1 .9793 .9195 .8261 .7081
with h = 0.25, Simpson’s rule gives
V = π
( . )
0 25
3
[(1 + .7081) + 4(.9793 + .8261) + 2(.9195)]
= 2.8192.
454 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 17. A tank is discharging water through an orifice at a depth of x
meter below the surface of the water whose area is A m2. Following are the
values of x for the corresponding values of A.
A: 1.257 1.39 1.52 1.65 1.809 1.962 2.123 2.295 2.462 2.650 2.827
x: 1.5 1.65 1.8 1.95 2.1 2.25 2.4 2.55 2.7 2.85 3
Using the formula (0.018) T =
1.5
3.0 A
x
dx
z , calculate T, the time (in seconds)
for the level of the water to drop from 3.0 m to 1.5 m above the orifice.
Sol. Here h = 0.15
The table of values of x and the corresponding values of
A
x
is
x 1.5 1.65 1.8 1.95 2.1 2.25 2.4 2.55 2.7 2.85 3
y =
A
x
1.025 1.081 1.132 1.182 1.249 1.308 1.375 1.438 1.498 1.571 1.632
Using Simpson’s
1
3
rd rule, we get
1 5
3 15
3
.
.
z =
A
x
dx [(1.025+1.632) + 4(1.081 + 1.182 + 1.308 + 1.438
+ 1.571) + 2(1.132 + 1.249 + 1.375 + 1.498)]
= 1.9743
Using the formula
(0.018)T =
1 5
3
.
z A
x
dx
We get 0.018T = 1.9743 ⇒ T = 110 sec. (approximately).
Example 18. Using the following table of values, approximate by Simpson’s
rule, the arc length of the graph y =
1
x
between the points (1, 1) and 5,
1
5
F
HG I
KJ
x: 1 2 3 4 5
1 x
x
4
4
+
: 1.414 1.031 1.007 1.002 1.001.
NUMERICAL INTEGRATION AND DIFFERENTIATION 455
Sol. The given curve is
y =
1
x
∴
dy
dx x
= −
1
2
∴
ds
dx
dy
dx x
x
x
= +
F
HG I
KJ = + =
+
1 1
1 1
2
4
4
4
∴ The arc length of the curve between the points (1, 1) and 5
1
5
,
F
HG I
KJ
=
1
5 4
4
1
z + x
x
dx
=
h
3
[(1.414 + 1.001) + 4(1.031 + 1.002) + 2(1.007)]
=
1
3
(2.415 + 8.132 + 2.014) = 4.187
Example 19. From the following values of y = f(x) in the given range of values
of x, find the position of the centroid of the area under the curve and the x-axis
x: 0
1
4
1
2
3
4
1
y: 1 4 8 4 1
Also find
(i) the volume of solid obtained by revolving the above area about x-axis.
(ii) the moment of inertia of the area about x-axis.
Sol. Centroid of the plane area under the curve y = f(x) is given by ( , )
x y where
and
x
xy dx
y dx
y
y
y dx
y dx
y
dx
y dx
=
= =
O
Q
PPPPPPPPP
z
z
z
z
z
z
0
1
0
1
0
1
0
1
0
1 2
0
1
2 2
.
(50)
456 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
From the given data, we obtain
x: 0
1
4
1
2
3
4
1
y: 1 4 8 4 1
xy: 0 1 4 3 1
y2
2
:
1
2
8 32 8
1
2
∴ By Simpson’s rule,
0
1 1 4
3
z =
xy dx
( / )
[(0 + 1) + 4(1 + 3) + 2(4)] =
25
12
0
1 2
2
1
12
1
2
1
2
4 8 8 2 32
z = +
F
HG I
KJ + + +
L
NM O
QP
y
dx ( ) ( ) =
129
12
0
1 1
12
z =
y dx [(1 + 1) + 4(4 + 4) + 2(8)] =
50
12
From (50), x = =
25 12
50 12
1
2
/
/
= 0.5
y = =
129 12
50 12
129
50
/
/
= 2.58
∴ Centroid is the point (0.5, 2.58).
(i) We know that
V = Volume = π
0
1
2
z y dx
∴ Required volume = π.2
2
0
1 2
z y
dx = 2
129
12
π × = 67.5442
(ii) We know that moment of inertia of the area about the x-axis is given by
M.I. =
1
3
3
ρ
a
b
y dx
z
where ρ is the mass per unit area.
NUMERICAL INTEGRATION AND DIFFERENTIATION 457
Table for y3 is
x: 0
1
4
1
2
3
4
1
y: 1 4 8 4 1
y3: 1 64 512 64 1
0
1
3 1
12
z =
y dx [(1 + 1) + 4(64 + 64) + 2(512)] =
769
6
∴ Reqd. M.I. =
1
3
769
6
ρ
F
HG I
KJ =
769
18
ρ = 42.7222 ρ.
Example 20. A reservoir discharging water through sluices at a depth h below
the water surface, has a surface area A for various values of h as given below:
h (in meters): 10 11 12 13 14
A (in sq. meters): 950 1070 1200 1350 1530
If t denotes time in minutes, the rate of fall of the surface is given by
dh
dt
48
A
h
= −
Estimate the time taken for the water level to fall from 14 to 10 m above the
sluices.
Sol. From
dh
dt
h
= −
48
A
, we have
dt = −
A
48
dh
h
Integration yields,
t = − =
z z
1
48
1
48
14
10
10
14
A A
h
dh
h
dh
Here, y =
A
h
. The table of values is as follows:
h: 10 11 12 13 14
A: 950 1070 1200 1350 1530
A
h
: 300.4164 322.6171 346.4102 374.4226 408.9097
458 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Applying Simpson’s
1
3
rd rule, we have
time t =
1
48
1
3
. [(300.4164 + 408.9097)
+ 4(322.6171 + 374.4226) + 2(346.4102)]
= 29.0993 minutes.
ASSIGNMENT 5.2
1. Evaluate
1
2 1
z x
dx by Simpson’s
1
3
rd rule with four strips and determine the error by
direct integration.
2. Evaluate the integral
0
2
π
θ θ
/
cos
z d by dividing the interval into 6 parts.
3. Evaluate log
.
e x dx
4
5 2
z by Simpson’s
3
8
th rule. Also write its programme in ‘C’ language.
4. Evaluate
30
90
10
°
°
z log sin x dx by Simpson’s
1
3
rd rule by dividing the interval into 6 parts.
5. Evaluate
4
5 2
.
log
z e x dx using
(i) Trapezoidal rule (ii) Weddle’s rule.
6. Evaluate using Trapezoidal rule
(i) t t dt
sin
0
π
z (ii)
t dt
t
5 2
2
2
+
−
z
7. Evaluate
3
7
z x2 log x dx taking 4 strips.
8. The velocities of a car running on a straight road at intervals of 2 minutes are given
below:
Time (in minutes): 0 2 4 6 8 10 12
Velocity (in km/hr): 0 22 30 27 18 7 0
Apply Simpson’s rule to find the distance covered by the car.
9. Evaluate
0
1
z cos x dx using h = 0.2.
NUMERICAL INTEGRATION AND DIFFERENTIATION 459
10. Evaluate
0
4
z ex dx by Simpson’s rule, given that e = 2.72, e2 = 7.39, e3 = 20.09, e4 = 54.6
and compare it with the actual value.
11. Find an approximate value of loge 5 by calculating to 4 decimal places, by Simpson’s
1
3
rd rule,
0
5
4 5
z +
dx
x
dividing the range into 10 equal parts.
12. Use Simpson’s rule, taking five ordinates, to find an approximate value of
1
2 1
z −
x
x
dx
to 2 decimal places.
13. Evaluate
0
2
π/
sin
z x dx given that
x: 0 π/12 π/6 π/4 π/3 5π/12 π/2
sin x : 0 0.5087 0.7071 0.8409 0.9306 0.9878 1
14. The velocity of a train which starts from rest is given by the following table, time being
reckoned in minutes from the start and speed in kilometers per hour:
Minutes: 0 2 4 6 8 10 12 14 16 18 20
Speed (km/hr): 0 10 18 25 29 32 20 11 5 2 0
Estimate the total distance in 20 minutes. Hint: Here step-size h =
L
NM O
QP
2
60
15. A rocket is launched from the ground. Its acceleration is registered during the first 80
seconds and is given in the following table. Using Simpson’s
1
3
rd rule, find the
velocity of the rocket at t = 80 seconds.
t(sec): 0 10 20 30 40 50 60 70 80
f(cm/sec2): 30 31.63 33.34 35.47 37.75 40.33 43.25 46.69 50.67.
16. A curve is drawn to pass through the points given by the following table:
x: 1 1.5 2 2.5 3 3.5 4
y: 2 2.4 2.7 2.8 3 2.6 2.1
Find
(i) Center of gravity of the area.
(ii) Volume of the solid of revolution.
(iii) The area bounded by the curve, the x-axis and lines x = 1, x = 4.
17. In an experiment, a quantity G was measured as follows:
G(20) = 95.9, G(21) = 96.85, G(22) = 97.77
G(23) = 98.68, G(24) = 99.56, G(25) = 100.41, G(26) = 101.24.
Compute
20
26
z G(x dx
) by Simpson’s and Weddle’s rule, respectively.
460 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
18. Using the data of the following table, compute the integral
0 5
1 1
.
.
z xy dx by Simpson’s
rule:
x: 0.5 0.6 0.7 0.8 0.9 1.0 1.1
y: 0.4804 0.5669 0.6490 0.7262 0.7985 0.8658 0.9281
19. Find the value of loge 2 from
0
1 2
3
1
.
z +
x
x
dx using Simpson’s
1
3
rd rule by dividing the
range of integration into four equal parts. Also find the error.
20. Use Simpson’s rule dividing the range into ten equal parts to show that
0
1 2
2
1
1
z +
+
log ( )
x
x
dx = 0.173
21. Find by Weddle’s rule the value of the integral
I =
0 4
1 6
.
.
sinh
z x
x
dx
by taking 12 sub-intervals.
22. Evaluate
0 5
0 7
1/2
.
.
z −
x e dx
x
approximately by using a suitable formula.
23. (i) Compute the integral
I = 2
0
1
2)
2
π z −
e dx
x
( /
Using Simpson’s
1
3
rd rule, taking h = 0.125.
(ii) Compute the value of I given by
I =
0 2
15 2
.
.
z −
e dx
x
Using Simpson’s
1
3
F
HG I
KJ rule with four subdivisions.
24. Using Simpson’s
1
3
rd rule, Evaluate the integrals:
(i)
10
1 8
2
.
.
z + −
e e
dx
x x
(taking h = 0.2)
(ii)
0
2
2 2
1
4
π/
sin cos
z +
dx
x x
NUMERICAL INTEGRATION AND DIFFERENTIATION 461
25. Evaluate
0
1
z +
sin cos
x x dx correct to two decimal places using seven ordinates.
26. Use Simpson’s three-eighths rule to obtain an approximate value of
0
0 3
3 1/2
1 8
.
( )
z − x dx
27. Evaluate
0
1/2
2
1
z −
dx
x
using Weddle’s rule.
28. Evaluate
0
1 2
2
2
1
z +
+
x
x
dx using Weddle’s rule correct to four places of decimals.
29. Using
3
8
th Simpson’s rule,
Evaluate:
0
6
4
1
z +
dx
x
.
30. Apply Simpson’s
1
3
rd rule to evaluate the integral
I =
0
1
z e dx
x
by choosing step size h = 0.1
Show that this step size is sufficient to obtain the result correct to five decimal places.
31. (i) Obtain the global truncation error term of trapezoidal method of integration.
(ii) Compute the approximate value of the integral
l = ( )
1 2
+ +
z x x dx
Using Simpson’s rule by taking interval size h as 1. Write a C program to imple-
ment.
32. The function f(x) is known at one point x* in the interval [a, b]. Using this value, f(x) can
be expressed as
f(x) = p0(x) + f ′{ξ(x)} (x – x*) for x ∈ (a, b)
where p0(x) is the zeroth-order interpolating polynomial p0(x) = f(x*) and ξ (x) ∈ (a, b).
Integrate this expression from a to b to derive a quadrature rule with error term. Sim-
plify the error term for the case when x* = a.
5.25 EULER-MACLAURIN’S FORMULA
This formula is based on the expansion of operators. Suppose ΔF(x) = f(x), then
an operator Δ–1, called inverse operator, is defined as
F(x) = Δ–1 f(x) (51)
462 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Also, ΔF(x) = f(x) gives
F(x1) – F(x0) = f(x0)
Similarly, F( F(
F( F(
x x f x
x x f x
n n n
2 1 1
1 1
) ) ( )
) ) ( )
− =
− =
− −
  
On adding, F(xn) – F(x0) =
i
n
i
f x
=
−
∑
0
1
( ) (52)
where x0, x1, ......, xn are the (n + 1) equidistant values of x with difference h.
From (51), F(x) = (E – 1)–1 f(x)
= (ehD – 1)–1 f(x)
= 1
2 3
1
1
+ + +
F
HG
I
KJ −
L
N
MM
O
Q
PP
−
h
h h
f x
D +
D D
2 2 3 3
! !
...... ( )
= h
h h
f x
D +
D D
2 2 3 3
2 3
1
! !
...... ( )
+ +
L
N
MM
O
Q
PP
−
= + + +
F
HG
I
KJ
L
N
MM
O
Q
PP
−
−
(
! !
...... ( )
h
h h
f x
D)
D D
1
2 2
1
2 3
1
=
1
1
2 3
h
h h
D
D D
1
2 2
−
− + +
F
HG
I
KJ
L
N
MM ! !
......
+
− −
+ +
F
HG
I
KJ +
O
Q
PP
( ) ( )
! ! !
...... ...... ( )
1 2
2 2 3
2
h h
f x
D D
2 2
=
1
1
2 12 720
1
4
h
h h h
f x
D
D D D
2 2 4
−
− + − +
L
NM O
QP
...... ( )
F(x) =
1 1
2 12 720
3
h
f x dx f x
h
f x
h
f x
( ) ( ) ( ) ( ) ......
− + ′ − ′ ″ +
z (53)
NUMERICAL INTEGRATION AND DIFFERENTIATION 463
Putting x = xn and x = x0 in (53) and then subtracting, we get
F(xn) – F(x0) =
1 1
2
0
h
f x dx
x
xn
z −
( ) [f(xn) – f(x0)] +
h
12
[f ′(xn) – f′(x0)]
−
h3
720
[f′″(xn) – f′″(x0)] + ......
⇒ f x
h
f x dx f x f x
h
f x f x
i
i
n
x
x
n n
n
( ) ( ) [ ( ) ( )] [ ( ) ( )]
=
−
∑ z
= − − + ′ − ′
0
1
0 0
1 1
2 12
0
− ′″ − ′″ +
h
f x f x
n
3
0
720
[ ( ) ( )] ...... | using (52)
⇒
1 1
2 12
0
0
1
0 0
h
f x dx f x f x f x
h
f x f x
x
x
i
n
i n n
n
z ∑
= + − − ′ − ′
=
−
( ) ( ) [ ( ) ( )] [ ( ) ( )]
+ ′″ − ′″ −
h
f x f x
n
3
0
720
[ ( ) ( )] ...... (54)
or
x
x
n
n
y dx
h
y y y y
0 2
2 2
0 1 2
z = + + + +
[ ...... ]
− ′ − ′ + ′ ″ − ′ ″ −
h
y y
h
y y
n n
2
0
4
0
12 720
( ) ( ) ......
=
h
y y y y y
n n
2
2
0 1 2 1
[( ) ( ...... )]
+ + + + + −
− ′ − ′ + ′ ″ − ′ ″
h
y y
h
y y
n n
2
0
4
0
12 720
( ) ( ) – ...... (55)
which is called Euler-Maclaurin’s formula. The first term on the R.H.S. of
(55) represents the approximate value of the integral obtained from trapezoidal
rule and the other terms denote the successive corrections to this value.
This formula is often used to find the sum of a series of the form
y(x0) + y(x0 + h) + y(x0 + 2h) + ...... + y(x0 + nh).
5.26 GAUSSIAN QUADRATURE FORMULA
Consider the numerical evaluation of the integral
a
b
f x dx
z ( ) (56)
464 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
So far, we studied some integration formulae which require values of the
function at equally spaced points of the interval. Gauss derived a formula which
uses the same number of function values but with different spacing and gives
better accuracy.
Gauss’s formula is expressed in the form
F( )
u du
−
z1
1
= W1 F(u1) + W2 F(u2) + ...... + Wn F(un)
= W F
i i
i
n
u
( )
=
∑1
(57)
where Wi and ui are called the weights and abscissae respectively. The formula
has an advantage that the abscissae and weights are symmetrical with respect
to the middle point of the interval.
In equation (57), there are altogether 2n arbitrary parameters and therefore
the weights and abscissae can be determined so that the formula is exact
when F(u) is a polynomial of degree not exceeding 2n – 1. Hence, we start with
F(u) = C0 + C1 u + C2 u2 + C3 u3 + ...... + C2n – 1 u2n – 1 (58)
Then from (57),
F( )
u du
−
z1
1
= ( ...... )
C C C C C
0 1 2
2
3
3
2 1
2 1
1
1
+ + + + + −
−
−
z u u u u du
n
n
= 2 C0 +
2
3
2
5
2 4
C C
+ + ....... (59)
Set u = ui in (58), we get
F(ui) = C0 + C1 ui + C2 ui
2 + C3 ui
3 + ...... + C2n – 1 ui
2n – 1
From (57),
F( )
u du
−
z1
1
= W1 (C0 + C1 u1 + C2 u1
2 + ........ + C2n – 1 u1
2n – 1)
+ W2 (C0 + C1 u2 + C2 u2
2 + ...... + C2n – 1 u2
2n – 1)
+ W3 (C0 + C1 u3 + C2 u3
2 + ...... + C2n – 1 u3
2n – 1) + ......
+ Wn (C0 + C1 un + C2 un
2 + ...... + C2n – 1 un
2n – 1)
which can be written as
F( )
u du
−
z1
1
= C0 (W1 + W2 + ....... + Wn) + C1(W1 u1 + W2 u2
+ W3 u3 + ...... + Wn un) + C2(W1 u1
2 + W2 u2
2
+ W3 u3
2 + ...... + Wn un
2) + ......
+ C2n – 1(W1 u1
2n – 1 + W2 u2
2n – 1
+ W3 u3
2n – 1 + ...... + Wn un
2n – 1) (60)
NUMERICAL INTEGRATION AND DIFFERENTIATION 465
Now equations (59) and (60) are identical for all values of Ci and hence
comparing the coefficients of Ci, we obtain 2n equations
W1 + W2 + W3 + ....... + Wn = 2
W1 u1 + W2 u2 + W3 u3 + ....... + Wn un = 0
W1 u1
2 + W2 u2
2 + W3 u3
2 + ........ + Wn un
2 =
2
3
(61)
  
W1 u1
2n – 1 + W2 u2
2n – 1 + W3 u3
2n – 1 + ........ + Wn un
2n – 1 = 0
in 2n unknowns Wi and ui (i = 1, 2, ......, n).
The abscissae ui and the weights Wi are extensively tabulated for different
values of n.
The table up to n = 5 is given below:
n ± ui Wi
2 0.57735, 02692 1.0
0.0 0.88888 88889
3 0.77459 66692 0.55555 55556
4 0.33998 10436 0.65214 51549
0.86113 63116 0.34785 48451
0.0 0.56888 88889
5 0.53846 93101 0.47862 86705
0.90617 98459 0.23692 68851
In general case, the limits of integral in (56) have to be changed to those in
(57) by transformation
x =
1
2
u (b – a) +
1
2
(a + b).
5.27 NUMERICAL EVALUATION OF SINGULAR INTEGRALS
The various numerical integration formulae we have discussed so far are valid
if integrand f(x) can be expanded by a polynomial or, alternatively can be
expanded in a Taylor’s series in the interval [a, b]. In a case where function has
a singularity, the preceding formulae cannot be applied and special methods
will have to be adopted.
U
V
|
|
|
|
W
|
|
|
|
466 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
5.28 EVALUATION OF PRINCIPAL VALUE INTEGRALS
Consider, I(f) =
f x
x t
dx
a
b ( )
−
z (62)
which is singular at t = x.
Its Principal value,
P(I) = lim
( ) ( )
ε
ε
ε
→
−
+
−
+
−
L
NM O
QP
z z
0
f x
x t
dx
f x
x t
dx
a
t
t
b
; a  t  b (63)
= I(f) (for t  a or t  b)
Set x = a + uh and t = a + kh in (1), we get
P(I) = P
f a hu
u k
du
p ( )
+
−
z0
(64)
Replacing f(a + hu) by Newton’s forward difference formula at x = a and
simplifying, we get
I(f) =
Δj
j
j
f a
j
( )
!
=
∞
∑0
C (65)
where the constants Cj are given by
Cj = P
( )
u
u k
du
j
p
−
z0
(66)
In (66), (u)0 = 1, (u)1 = u, (u)2 = u (u – 1) etc.
Various approximate formulae can be obtained by truncating the series on
R.H.S. of (65).
Eqn. (65) may be written as
In(f) =
Δj
j
n
j
f a
j
( )
!
=
∑0
C (67)
We obtain rules of orders 1, 2, 3, ...... etc. by setting n = 1, 2, 3, ......
respectively.
(i) Two point rule (n = 1): I1(f) =
Δj
j
f a
j
( )
!
=
∑0
1
Cj
= C0 f(a) + C1 Δ f(a)
= (C0 – C1) f(a) + C1 f (a + h) (68)
NUMERICAL INTEGRATION AND DIFFERENTIATION 467
(ii) Three-point rule (n = 2):
I2 (f) =
Δj
j
f a
j
( )
!
=
∑0
2
Cj = C0 f(a) + C1 Δ f(a) + C2 Δ2 f(a)
= C C C
0 1 2
1
2
− +
F
HG I
KJ f(a) + (C1 – C2) f (a + h)
+
1
2
C2 f (a + 2h) (69)
In above relations (68) and (69), values of Cj are given by,
C0 = log e
p k
k
−
C1 = p + C0 k
C2 =
1
2
p2 + p (k – 1) + C0 k (k – 1) .
EXAMPLES
Example 1. Apply Euler-Maclaurin formula to evaluate
1
51
1
53
1
55
.......
1
99
2 2 2 2
+ + + + .
Sol. Take y =
1
2
x
, x0 = 51, h = 2, n = 24, we have
y′ = −
2
3
x
, y′″ = −
24
5
x
Then from Euler-Maclaurin’s formula,
dx
x2
51
99
z =
2
2
1
51
2
53
2
55
2
97
1
99
2 2 2 2 2
+ + + + +
L
NM O
QP
......
–
( ) ( )
( )
( )
( )
2
12
2
99
2
51
2
3 3
−
−
−
L
NM O
QP +
( ) ( )
( )
( )
( )
2
720
24
99
24
51
4
5 5
−
−
−
L
NM O
QP
∴
1
51
2
53
2
55
2
97
1
99
2 2 2 2 2
+ + + + +
......
=
dx
x2
51
99
z +
2
3
1
51
1
99
3 3
( ) ( )
−
L
NM O
QP –
8
15
1
51
1
99
5 5
( ) ( )
−
L
NM O
QP +......
468 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
⇒ 2
1
51
1
53
1
55
1
99
2 2 2 2
+ + + +
L
NM O
QP
......
=
dx
x2 2 2
51
99 1
51
1
99
+ +
F
HG I
KJ
z +
2
3
1
51
1
99
3 3
( ) ( )
−
L
NM O
QP
–
8
15
1
51
1
99
5 5
( ) ( )
−
L
NM O
QP + ......
⇒
1
51
1
53
1
55
1
99
2 2 2 2
( ) ( ) ( )
......
( )
+ + + +
=
1
2 2
51
99 dx
x
z +
1
2
1
51
1
99
2 2
( ) ( )
+
L
NM O
QP +
1
3
1
51
1
99
3 3
( ) ( )
−
L
NM O
QP
–
4
15
1
51
1
99
5 5
( ) ( )
−
L
NM O
QP + ......
=
1
2
−
F
HG I
KJ
1
51
99
x
+
1
2
1
51
1
99
2 2
( ) ( )
+
L
NM O
QP +
1
3
1
51
1
99
3 3
( ) ( )
−
L
NM O
QP
–
4
15
1
51
1
99
5 5
( ) ( )
−
L
NM O
QP + .......
= 0.00475 + 0.000243 + 0.0000022 + ......
= 0.00499 approximately.
Example 2. Using Euler-Maclaurin’s formula, find the value of loge 2 from
dx
1 x
0
1
+
z .
Sol. Take y =
1
1+ x
, x0 = 0, n = 10, h = 0.1,
we have y′ = −
+
1
1 2
( )
x
and y′″ =
−
+
6
1 4
( )
x
NUMERICAL INTEGRATION AND DIFFERENTIATION 469
Then from Euler-Maclaurin’s formula, we have
dx
x
1
0
1
+
z =
0
2
.1 1
1 0
2
1 01
2
1 0 2
2
1 03
2
1 0 4
+
+
+
+
+
+
+
+
+
L
NM . . . .
+
+
+
+
+
+
+
+
+
+
+
+
O
QP
2
1 05
2
1 0 6
2
1 07
2
1 0 8
2
1 0 9
1
1 1
. . . . .
–
( . ) ( )
( )
( )
( )
0 1
12
1
1 1
1
1 0
2
2 2
−
+
−
−
+
L
NM O
QP +
( . ) ( )
( )
( )
( )
0 1
720
6
1 1
6
1 0
4
4 4
−
+
−
−
+
L
NM O
QP
= 0.693773 – 0.000625 + 0.000001 = 0.693149
Also,
dx
x
1
0
1
+
z = log ( )
1
0
1
+ x = log 2
Hence loge 2 = 0.693149.
Example 3. Evaluate sin x dx
0
/2
π
z using the Euler-Maclaurin formula.
Sol. sin
0
/2
x dx
π
z =
h
2
[y0 + 2y1 + 2y2 + ....... + 2yn – 1 + yn]
+
h h h
2 4 6
12 720 30240
+ + + ......
To evaluate the integral, let us take h =
π
4
.
Then we obtain,
sin
0
/2
x dx
π
z =
π
8
(0 + 2 + 0) +
π2
192
+
π4
184320
+ ......
=
π π π
4 192 184320
2 4
+ + (approximately)
= 0.785398 + 0.051404 + 0.000528 = 0.837330
If we take h =
π
8
, we get
sin
0
/2
x dx
π
z =
π
16
[0 + 2(0.382683 + 0.707117 + 0.923879) + 1]
= 0.987119 + 0.012851 + 0.000033 = 1.000003.
470 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 4. Use Euler-Maclaurin’s formula to prove that
x2
1
n
∑ =
n (n 1) (2n 1)
6
+ +
.
Sol. By Euler–Maclaurin’s formula,
y dx
x
xn
0
z =
h
2
[y0 + 2y1 + 2y2+ ......... + 2yn – 1 + yn] –
h2
12
(yn′ – y0′)
+
h4
720
(yn′″ – y0′″) –
h6
30240
(yn
(v) – y0
(v)) + .....
⇒
1
2
y0 + y1 + y2 + ...... + yn – 1 +
1
2
yn
=
1
h
y dx
x
xn
0
z +
h
12
(yn′ – y0′) –
h3
720
(yn′″ – y0′″)
+
h5
30240
(yn
(v) – y0
(v)) – ....... (70)
Here y(x) = x2, y′(x) = 2x and h = 1
∴ From (70),
Sum = x dx
n
2
1
z +
1
2
(n2 + 1) +
1
12
(2n – 2)
∵
1
2
y0 =
1
2
,
1
2
yn =
n2
2
=
1
3
(n3 – 1) +
1
2
(n2 + 1) +
1
6
(n – 1) =
n n n
( ) ( )
+ +
1 2 1
6
.
Example 5. Find x dx
0
1
z by Gaussian formula.
Sol. Let us change the limits as
x =
1
2
u(1– 0) +
1
2
(1 + 0) =
1
2
(u + 1)
This gives,
I =
1
4
( )
u du
+
−
z 1
1
1
=
1
4
W F
i i
i
n
u
( )
=
∑1
where F(ui) = ui + 1
NUMERICAL INTEGRATION AND DIFFERENTIATION 471
For simplicity, let n = 4 and using the abscissae and weights corresponding
to n = 4 in the table, we get
I =
1
4
[(– 0.86114 + 1) (0.34785 ) + (– 0.33998 + 1) (0.65214)
+ (0.33998 + 1) (0.65214) + (0.86114 + 1) (0.34785)]
= 0.49999 .....
where the abscissae and weights have been rounded to 5 decimal places.
Example 6. Show that the integration formula f(x) dx
0
h
z = hf
h
2
F
HG I
KJ is exact for
all polynomials of degree less than or equal to 1. Obtain an estimate for the
truncation error.
If |f ″(x)|  1 for all x, then find the step size h so that the truncation error is
less than 10–3.
Sol. If f(x) = k (a constant or zero degree polynomial) then the result is obvious
since
f x dx
h
( )
0
z = kh (71)
and hf
h
2
F
HG I
KJ = hk (72)
∴ From (71) and (72),
f x dx
h
( )
0
z = hf
h
2
F
HG I
KJ
If f(x) is a polynomial of degree one then
f(x) = ax + b
f x dx
h
( )
0
z = ( )
ax b dx
h
+
z0
=
ah
bh
2
2
+ (73)
hf
h
2
F
HG I
KJ = h
ah
b
2
+
F
HG I
KJ =
ah
bh
2
2
+ (74)
From (73) and (74), we have the result.
Now, y dx
h
0
z = y x x y
x x
y dx
h
0 0 0
0
2
0
0 2
+ − ′ +
−
″ +
L
NMM
O
QPP
z ( )
( )
.....
472 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= hy0 +
h
y
h
y
2
0
3
0
2 3
! !
.....
′ + ″ + (75)
(where x – x0 = h)
Also, hf
h
2
F
HG I
KJ = h y
h
y
h
y
0 0
2
0
2
2
2
+ ′ +
F
HG I
KJ
″ +
L
N
MMMMM
O
Q
PPPPP
!
..... (76)
(75) – (76) gives the truncation error
= h3
1
6
1
8
−
F
HG I
KJ y0″ (nearly)
Now,
h
y
3
0
24
″ 
1
24
h3
⇒
1
24
h3  10–3 or | h3 |  24 × 10– 3 = 0.024
⇒ – 0 024
3
.  h  0 024
3
. .
Example 7. Find λ such that the quadrature formula
f(x)
x
dx
0
1
z ≈ Af(0) + Bf(λ)
+ Cf(1) may be exact for polynomials of degree 3.
Sol.
f x
x
dx
( )
0
1
z = Af(0) + Bf(λ) + Cf(1)
Set f(x) = 1, x, x2 and x3 in turn,
2 = A + B + C (77)
2
3
= Bλ + C (78)
2
5
= Bλ2 + C (79)
2
7
= Bλ3 + C (80)
Subtracting (78) from (79), we get
Bλ (λ – 1) = −
4
15
NUMERICAL INTEGRATION AND DIFFERENTIATION 473
Subtracting (79) from (80), we get
Bλ2(λ – 1) = –
4
35
∴ λ =
3
7
.
Example 8. Determine W0, W1 and W2 as functions of α such that the error R
in
f(x) dx
–1
1
z = W0 f(– α) + W1 f(0) + W2 f(α) + R, α ≠ 0
Vanishes when f(x) is an arbitrary polynomial of degree at most 3. Show
that the precision is five when α =
3
5
and three otherwise.
Compute the error R when α =
3
5
.
Sol. f x dx
( )
–1
1
z = W0 f(– α) + W1 f(0) + W2 f(α) is exact for f(x) = 1, x, x2, x3.
f(x) = 1 ⇒ W0 + W1 + W2 = 2
f(x) = x ⇒ W0 = W2
f(x) = x2 ⇒ 2W0α2 =
2
3
f(x) = x3 ⇒ W0 = W2
Solving, we find
W0 = W2 =
1
3 2
α
, W1 = 2 1
1
3 2
−
F
HG I
KJ
α
Choosing f(x) = x4, we get
2
5
= 2W0α4 =
2
3
α2
⇒ α =
3
5
With this value, f(x) = x5 gives exact value.
∴ The precision is 5.
474 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
If α ≠
3
5
the precision is 3.
With α =
3
5
, we have
f x dx
( )
–1
1
z =
5
9
f f
−
F
HG
I
KJ +
F
HG
I
KJ
L
N
MM
O
Q
PP
3
5
3
5
+
8
9
f(0) + R
Hence the error term R is given by
R =
2
7!
f (vi) (0) + terms involving higher order derivatives
=
f vi
( )
( )
0
2520
.
Example 9. Determine a, b and c such that the formula
f(x) dx
0
h
z = h af(0) bf
h
3
cf (h)
+
F
HG I
KJ +
R
S
T
U
V
W
is exact for polynomials of as high order as possible and determine the order of
truncation error.
Sol. Making the method exact for polynomials of degree up to 2, we get
For f(x) = 1: h = h (a + b + c) ⇒ a + b + c = 1
For f(x) = x:
h2
2
= h
bh
ch
3
+
F
HG I
KJ ⇒
b
3
+ c =
1
2
For f(x) = x2:
h3
3
= h
bh
ch
2
2
9
+
F
HG
I
KJ ⇒
b
9
+ c =
1
3
Solving above eqns., we get
a = 0, b =
3
4
, c =
1
4
Truncation error of the formula =
c
3!
f ′″(ξ); 0  ξ  h
and c = x dx
h
3
0
z – h
bh
ch
3
3
27
+
F
HG
I
KJ = –
h4
36
NUMERICAL INTEGRATION AND DIFFERENTIATION 475
Hence, we have
Truncation error = −
h4
216
f ′″ (ξ) = 0 (h4).
ASSIGNMENT 5.3
1. Using Euler-Maclaurin’s formula, evaluate
(i)
1
400
+
1
402
+
1
404
+ ....... +
1
500
(ii)
1
201 2
( )
+
1
203 2
( )
+
1
205 2
( )
+ ...... +
1
299 2
( )
.
2. Prove that x
n
3
1
∑ =
n n
( )
+
R
S
T
U
V
W
1
2
2
applying Euler-Maclaurin’s formula.
3. Use Euler-Maclaurin’s formula to find the value of π from the formula
π
4
=
dx
x
1 2
0
1
+
z .
4. Find the sum of the fourth powers of first n natural numbers by means of Euler-
Maclaurin’s formula.
OR
Prove that, i
n
4
0
∑ =
n n n n
5 4 3
5 2 3 30
+ + + .
5. Sum the series
1
100
1
101
1
102
1
103
1
104
+ + + + .
6. Determine α, β, γ and δ such that the relation
y′
a b
+
F
HG I
KJ
2
= αy (a) + βy (b) + γ y″ (a) + δ y″ (b)
is exact for polynomials of as high degree as possible.
7. Find the values of α0 , α1, α2 so that the given rule of differentiation
f ′(x0) = α0 f0 + α1f1 + α2f2 (xk = x0 + kh)
is exact for f ∈ P2.
8. Find the values a, b, c such that the truncation error in the formula
f x dx
h
h
( )
−
z = h [af(– h) + bf (0) + af(h) + h2 c {f ′ (– h) – f ′ (h)}]
is minimized.
9. Show that i i
i
n
i
n
7
1
5
1
+
= =
∑ ∑ = 2 i
i
n
3
1
2
=
∑
F
H
GG
I
K
JJ .
10. Evaluate:
1
10 2
0
( )
+
=
∞
∑ m
m
by applying Euler-Maclaurin’s formula.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
P a r t 4
n Numerical Solution of Ordinary Differential Equations
Picard’s Method, Euler’s Method, Taylor’s Method, Runge-Kutta
Methods, Predictor-Corrector Methods, Milne’s Method, Adams-
Moulton Formula, Stability in the Solution of Ordinary Differential
Equations.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
Chapter 6
NUMERICAL SOLUTION
OF ORDINARY
DIFFERENTIAL EQUATIONS
479
6.1 INTRODUCTION
A
physical situation concerned with the rate of change of one quantity
with respect to another gives rise to a differential equation.
Consider the first order ordinary differential equation
dy
dx
= f (x, y) (1)
with the initial condition
y(x0) = y0 (2)
Many analytical techniques exist for solving such equations, but these
methods can be applied to solve only a selected class of differential equations.
However, a majority of differential equations appearing in physical problems
cannot be solved analytically. Thus it becomes imperative to discuss their
solution by numerical methods.
In numerical methods, we do not proceed in the hope of finding a
relation between variables but we find the numerical values of the dependent
variable for certain values of independent variable.
It must be noted that even the differential equations which are solvable by
analytical methods can be solved numerically as well.
480 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.2 INITIAL-VALUE AND BOUNDARY-VALUE PROBLEMS
Problems in which all the conditions are specified at the initial point only are
called initial-value problems. For example, the problem given by eqns. (1)
and (2) is an initial value problem.
Problems involving second and higher order differential equations, in which
the conditions at two or more points are specified, are called boundary-value
problems.
To obtain a unique solution of nth order ordinary differential equation, it is
necessary to specify n values of the dependent variable and/or its derivative at
specific values of independent variable.
6.3 SINGLE STEP AND MULTI-STEP METHODS
The numerical solutions are obtained step-by-step through a series of equal
intervals in the independent variable so that as soon as the solution y has been
obtained at x = xi , the next step consists of evaluating yi+1 at x = xi+1. The
methods which require only the numerical value yi in order to compute the
next value yi+1 for solving eqn. (1) given above are termed as single step
methods.
The methods which require not only the numerical value yi but also at
least one of the past values yi–1, yi–2, ...... are termed as multi-step methods.
6.4 COMPARISON OF SINGLE-STEP AND MULTI-STEP METHODS
The single step method has obvious advantages over the multi-step methods
that use several past values (yn, yn–1, ......, yn–p) and that require initial values
(y1, y2, ......, yn) that have to be calculated by another method.
The major disadvantage of single-step methods is that they use many more
evaluations of the derivative to attain the same degree of accuracy compared
with the multi-step methods.
6.5 NUMERICAL METHODS OF SOLUTION OF O.D.E.
In this chapter we will discuss various numerical methods of solving ordinary
differential equations.
We know that these methods will yield the solution in one of the two forms:
(a) A series for y in terms of powers of x from which the value of y can be
obtained by direct substitution.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 481
(b) A set of tabulated values of x and y.
Picard’s method and Taylor’s method belong to class (a) while those of
Euler’s, Runge-Kutta, Adams-Bashforth, Milne’s, etc. belong to class (b).
Methods which belong to class (b) are called step-by-step methods or
marching methods because the values of y are computed by short steps ahead
for equal intervals of the independent variable.
In Euler’s and Runge-Kutta methods, the interval range h should be kept
small, hence they can be applied for tabulating y only over a limited range.
To get functional values over a wider range, the Adams-Bashforth, Milne,
Adams-Moulton, etc. methods may be used since they use finite differences
and require starting values, usually obtained by Taylor’s series or Runge-Kutta
methods.
6.6 PICARD’S METHOD OF SUCCESSIVE APPROXIMATIONS
Picard was a distinguished Professor of Mathematics at the university of Paris,
France. He was famous for his research on the Theory of Functions.
Consider the differential equation
dy
dx
= f (x, y); y(x0) = y0 (3)
Integrating eqn. (3) between the limits x0 and x and the corresponding
limits y0 and y, we get
y
y
x
x
dy f x y dx
0 0
z z
= ( , )
⇒ y – y0 =
x
x
f x y dx
0
z ( , )
or, y = y0 +
x
x
f x y dx
0
z ( , ) (4)
In equation (4), the unknown function y appears under the integral sign.
This type of equation is called integral equation.
This equation can be solved by the method of successive approximations or
iterations.
To obtain the first approximation, we replace y by y0 in the R.H.S. of eqn. (4).
Now, the first approximation is
y(1) = y0 +
x
x
f x y dx
0
0
z ( , )
The integrand is a function of x alone and can be integrated.
482 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
For a second approximation, replace y0 by y(1) in f (x, y0) which gives
y(2) = y0 +
x
x
f x y dx
0
z { , }
(1)
Proceeding in this way, we obtain y(3), y(4), ......., y(n–1) and y(n) where
y(n) = y0 +
x
x
n
f x y dx
0
1
z −
{ , }
( )
with y(x0) = y0
As a matter of fact, the process is stopped when the two values of y viz.
y(n–1) and y(n) are the same to the desired degree of accuracy.
Picard’s method is of considerable theoretical value. Practically, it is
unsatisfactory because of the difficulties which arise in performing the necessary
integrations. However, each step gives a better approximation of the required
solution than the preceding one.
EXAMPLES
Example 1. Given the differential eqn.
dy
dx
x
y 1
2
2
=
+
with the initial condition y = 0 when x = 0. Use Picard’s method to obtain y for
x = 0.25, 0.5 and 1.0 correct to three decimal places.
Sol. (a) The given initial value problem is
dy
dx
= f(x, y) =
x
y
2
2
1
+
where y = y0 = 0 at x = x0 = 0
We have first approximation,
y(1) = y0 +
x
x
f x y dx
0
0
z ( , )
= 0 +
0
2
0 1
x x
z +
dx =
1
3
x3 (5)
Second approximation,
y(2) = y0 +
x
x
f x y dx
0
1
z { , }
( )
= 0 +
0
2
3 2
3
1
x x
x
dx
z F
HG
I
KJ +
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 483
= tan−
L
NM O
QP
1
3
0
3
x
x
= tan–1 x3
3
=
1
3
x3 –
1
3
1
3
3
3
x
F
HG I
KJ + ......
=
1
3
x3 –
1
81
x9 + ..... (6)
From (5) and (6), we see that y(1) and y(2) agree to the first term
x3
3
. To find
the range of values of x so that the series with the term 1
3
x3 alone will give the
result correct to three decimal places, we put
1
81
x9 ≤ .0005
which gives, x9 ≤ .0405 or x ≤ 0.7
Hence, y(.25) =
1
3
(.25)3 = .005
and y(0.5) =
1
3
(0.5)3 = .042
To find y(1.0), we make use of eqn. (6) which gives,
y(1.0) =
1
3
–
1
81
= 0.321.
Example 2. Use Picard’s method to obtain y for x = 0.2. Given:
dy
dx
= x – y with initial condition y = 1 when x = 0.
Sol. Here f(x, y) = x – y, x0 = 0, y0 = 1
We have first approximation,
y(1) = y0 + f x y dx
x
( , )
0
0
z = 1 + ( )
x dx
x
−
z 1
0
= 1 – x +
x2
2
Second approximation,
y(2) = y0 +
0
1
x
f x y dx
z { , }
( )
= 1 +
0
x
x y dx
z −
{ }
(1)
= 1 +
0
2
1
2
x
x x
x
dx
z − + −
F
HG
I
KJ = 1 – x + x2 –
x3
6
484 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Third approximation,
y(3) = y0 +
0
2
x
f x y dx
z { , }
( )
= 1 +
0
2
x
x y dx
z −
{ }
( )
= 1 +
0
2
3
1
6
x
x x x
x
dx
z − + − +
F
HG
I
KJ
= 1 – x + x2 –
x x
3 4
3 24
+
Fourth approximation,
y(4) = y0 +
0
3)
x
f x y dx
z { , }
(
= 1 +
0
3)
x
x y dx
z −
{ }
(
= 1 +
0
2
3 4
1
3 24
x
x x x
x x
dx
z − + − + −
F
HG
I
KJ
= 1 – x + x2 –
x x x
3 4 5
3 12 120
+ −
Fifth approximation,
y(5) = y0 +
0
4
x
f x y dx
z { , }
( )
= 1 +
0
4
x
x y dx
z −
{ }
( )
= 1 +
0
2
3 4 5
1
3 12 120
x
x x x
x x x
dx
z − + − + − +
F
HG
I
KJ
= 1 – x + x2 –
x x x x
3 4 5 6
3 12 60 720
+ − +
When x = 0.2, we get
y(1) = .82, y(2) = .83867, y(3) = .83740
y(4) = .83746, y(5) = .83746
Thus, y = .837 when x = .2.
Example 3. Use Picard’s method to obtain y for x = 0.1. Given that:
dy
dx
= 3x + y2; y = 1 at x = 0.
Sol.Here f(x, y) = 3x + y2, x0 = 0, y0 = 1
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 485
First approximation, y(1) = y0 + f x y dx
x
( , )
0
0
z
= 1 + ( )
3 1
0
x dx
x
+
z
= 1 + x +
3
2
x2
Second approximation, y(2) = 1 + x +
5
2
x2 +
4
3
x3 +
3
4
x4 +
9
20
x5
Third approximation, y(3) = 1 + x +
5
2
x2 + 2x3 +
23
12
x4 +
25
12
x5
+
68
45
x6 +
1157
1260
x7 +
17
32
x8 +
47
240
x9
+
27
400
x10 +
81
4400
x11
when x = 0.1, we have
y(1) = 1.115, y(2) = 1.1264, y(3) = 1.12721
Thus, y = 1.127 when x = 0.1.
Example 4. If
dy
dx
y x
y x
=
−
+
, find the value of y at x = 0.1 using Picard’s method.
Given that y(0) = 1.
Sol. First approximation,
y(1) = y0 +
y x
y x
dx
x
0
0
0
−
+
z = 1 +
0
1
1
x x
x
dx
z −
+
F
HG I
KJ
= 1 +
0
2
1
1
x
x
dx
z +
−
F
HG I
KJ
= 1 – x + 2 log (1 + x)
Second approximation,
y(2) = 1 + x – 2
0 1 2 1
x x dx
x
z + +
log ( )
which is difficult to integrate.
Thus, when, x = 0.1, y(1) = 1 – 0.1 + 2 log (1.1) = 0.9828
Here in this example, only I approximation can be obtained and so it gives
the approximate value of y for x = 0.1.
486 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 5. Solve
dy
dx
= 1 + xy with x0 = 2, y0 = 0 using Picard’s method of
successive approximations.
Sol. Here, y(1) = y0 +
2
0
x
f x y dx
z ( , ) = 0 +
2
1 0
x
x dx
z +
[ ( )] = x – 2
y(2) = 0 +
2
1 2
x
x x dx
z + −
{ ( )}
= x x
x
x
− +
F
HG
I
KJ
2
3
2
3
= –
2
3
+ x – x2 +
x3
3
And third approximation,
y(3) = 0 +
2
2
1
x
x y dx
z +
{ }
( )
= –
22
15
+ x –
1
3 3 4 15
2
3 4 5
x
x x x
+ − +
which is the required solution.
Example 6. Obtain y when x = 0.1, x = 0.2, given that
dy
dx
= x + y; y(0) = 1. Check
the result with exact value.
Sol. We have
dy
dx
= f(x, y) = x + y, x0 = 0, y0 = 1
Now first approximation,
y(1) = 1 + ( )
1
0
+
z x dx
x
= 1 + x +
x2
2
Second approximation,
y(2) = 1 + x x
x
dx
x
+ + +
F
HG
I
KJ
z 1
2
2
0
= 1 + x + x2 +
x3
6
Third approximation,
y(3) = 1 + x + x2 +
x x
3 4
3 24
+
When x = .1, y(1) = 1.105
y(2) = 1.11016
y(3) = 1.11033 (closer appr.)
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 487
When x = .2,
y(3) = 1.2427
We can continue further to get the better approximations. Now we shall
obtain exact value.
dy
dx
– y = x is the given differential equation. General sol. is
ye–x = – e–x (1 + x) + c | I.F. = e–x
Putting y = 1, x = 0 we obtain, c = 2
∴ y = – x – 1 + 2ex
When x = 0.1, y = 1.11034
and x = 0.2, y = 1.24281
These results reveal that the approximations obtained for x = 0.1 is correct
to four decimal places while that for x = 0.2 is correct to 3 decimal places.
Example 7. Find the solution of
dy
dx
= 1 + xy, y(0) = 1 which passes through
(0, 1) in the interval (0, 0.5) such that the value of y is correct to three decimal
places (use the whole interval as one interval only). Take h = 0.1.
Sol. The given initial value problem is
dy
dx
= f(x, y) = 1 + xy; y(0) = 1
i.e., y = y0 = 1 at x = x0 = 0
Here, y(1) = 1 + x +
x2
2
y(2) = 1 + x +
x x x
2 3 4
2 3 8
+ +
y(3) = 1 + x +
x x x x x
2 3 4 5 6
2 3 8 15 48
+ + + +
y(4) = y(3) +
x x
7 8
105 384
+
when x = 0, y = 1.000
x = 0.1, y(1) = 1.105, y(2) = 1.1053 ....
∴ y = 1.105 (correct up to 3 decimals)
x = 0.2, y(1) = 1.220, y(2) = 1.223 = y(3)
488 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ y = 1.223 (correct up to 3 decimals)
x = 0.3, y = 1.355 as y(2) = 1.355 = y(3)
x = 0.4, y = 1.505 (similarly)
x = 0.5, y = 1.677 as y(4) = y(3) = 1.677
Thus,
x 0 0.1 0.2 0.3 0.4 0.5
y 1.000 1.105 1.223 1.355 1.505 1.677
We have numerically solved the given differential eqn. for x = 0, .1, .2, .3,
.4, and .5.
6.7 PICARD’S METHOD FOR SIMULTANEOUS FIRST ORDER DIF-
FERENTIAL EQUATIONS
Let
dy
dx
= φ(x, y, z) and
dz
dx
= f(x, y, z)
be the simultaneous differential eqns. with initial conditions y(x0) = y0; z(x0) = z0.
Picard’s method gives
y(1) = y0 +
x
x
x y z dx
0
0 0
z φ( , , ) ; z(1) = z0 +
x
x
f x y z dx
0
0 0
z ( , , )
y(2) = y0 +
x
x
x y z dx
0
1 1
z φ{ , , }
( ) ( )
; z(2) = z0 +
x
x
f x y z dx
0
1 1
z { , , }
( ) ( )
and so on as successive approximations.
EXAMPLES
Example 1. Approximate y and z by using Picard’s method for the particular
solution of
dy
dx
= x + z,
dz
dx
= x – y2 given that y = 2, z = 1 when x = 0.
Sol. Let φ(x, y, z) = x + z, f(x, y, z) = x – y2
Here, x0 = 0, y0 = 2, z0 = 1
We have,
dy
dx
= φ(x, y, z) ⇒ y = y0 +
x
x
x y z dx
0
z φ( , , )
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 489
Also,
dz
dx
= f(x, y, z) ⇒ z = z0 +
x
x
f x y z dx
0
z ( , , )
First approximation,
y(1) = y0 +
x
x
x y z dx
0
0 0
z φ( , , ) = 2 +
0
0
x
x z dx
z +
( )
= 2 +
0
1
x
x dx
z +
( ) = 2 + x +
x2
2
and z(1) = z0 +
x
x
f x y z dx
0
0 0
z ( , , ) = 1 +
0
0
2
x
x y dx
z −
( )
= 1 +
0
4
x
x dx
z −
( ) = 1 – 4x +
x2
2
Second approximation,
y(2) = y0 +
x
x
x y z dx
0
1 1
z φ{ , , }
( ) ( )
= 2 +
0
1
x
x z dx
z +
{ }
( )
= 2 +
0
2
1 4
2
x
x x
x
dx
z + − +
F
HG
I
KJ
= 2 + x –
3
2
x2 +
x3
6
z(2) = z0 +
x
x
f x y z dx
0
z { , , }
(1) (1)
= 1 +
0
2
2
2
2
x
x x
x
dx
z − + +
F
HG
I
KJ
L
N
MM
O
Q
PP
= 1 – 4x –
3
2
x2 – x3 –
x4
4
–
x5
20
.
Example 2. Solve by Picard’s method, the differential equations
dy
dx
= z,
dz
dx
= x3 (y + z)
where y = 1, z =
1
2
at x = 0. Obtain the values of y and z from III
approximation when x = 0.2 and x = 0.5.
490 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Let φ(x, y, z) = z, f(x, y, z) = x3(y + z)
Here x0 = 0, y0 = 1, z0 =
1
2
First approximation,
y(1) = y0 +
0
0 0
x
x y z dx
z φ( , , ) = 1 +
0
0
x
z dx
z
= 1 +
1
2
x
z(1) = z0 +
0
0 0
0
3
0 0
1
2
x x
f x y z dx x y z dx
z z
= + +
( , , ) ( )
=
1
2
3
2 4
4
+
x
.
Second approximation,
y(2) = 1 +
0
1
x
z dx
z ( )
= 1 +
0
4
1
2
3
8
x
x dx
z +
F
HG I
KJ
= 1 +
x
2
3
40
+ x5
z(2) =
1
2 0
3 1 1
+ +
zx
x y z dx
{ }
( ) ( )
=
1
2
3
2 2
3
8
0
3 4
+ + +
F
HG I
KJ
zx
x
x
x dx
=
1
2
3
8 10
3
64
4
5
8
+ + +
x
x
x
Third approximation,
y(3) = 1 + z dx
x
( )
2
0
z = 1 +
0
4 5 8
1
2
3
8 10
3
64
x x x x
dx
z + + +
F
HG
I
KJ
= 1 +
x
x
x x
2
3
40 60
3
576
5
6 9
+ + +
z(3) =
1
2
3 2 2
0
+ +
z x y z dx
x
{ }
( ) ( )
=
1
2
3
2 2
3
8
7
40
3
64
0
3 4 5 8
+ + + + +
R
S
T
U
V
W
zx
x
x
x x x dx
=
1
2
3
2 4
1
2 5
3
8 8
7
40 9
3
64 12
4 5 8 9 12
+ + + + +
. . . . .
x x x x x
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 491
=
1
2
3
8
+ x4 +
x5
10
3
64
+ x8 +
7
360
x9 +
3
768
x12
when x = 0.2
y(3) = 1 + 0.1 +
3
40
(0.2)5 +
( . )
0 2
60
3
576
6
+ (0.2)9
= 1.100024 (leaving higher terms)
z(3) =
1
2
3
8
+ (.2)4 +
(. )
2
10
3
64
5
+ (.2)8 +
7
360
(.2)9 +
3
768
(.2)12
= .500632 (leaving higher terms)
when x = 0.5
y(3) = 1 +
.5
2
3
40
+ (.5)5 +
(. )
5
60
3
576
6
+ (.5)9
= 1.25234375
z(3) =
1
2
3
8
+ (.5)4 +
(. )
5
10
3
64
5
+ (.5)8 +
7
360
(.5)9 +
3
768
(.5)12
= .5234375.
ASSIGNMENT 6.1
1. For the differential equation
dy
dx
= x – y2, y(0) = 0
Calculate y(0.2) by Picard’s method to third approximations and round-off the value at
the 4th place of decimals.
2. Find y(0.2) if
dy
dx
= log (x + y); y(0) = 1. Use Picard’s method.
3. Employ Picard’s method to obtain the solution of
dy
dx
= x2 + y2 for x = 0.1 correct to four
decimal places, given that y = 0 when x = 0.
4. Find an approximate value of y when x = 0.1 if
dy
dx
= x – y2 and y = 1 at x = 0 using
Picard’s method.
5. Solve numerically
dy
dx
= 2x – y, y(0) = 0.9 at x = 0.4 by Picard’s method with three
iterations and compare the result with the exact value.
6. Employ Picard’s method to find y (0.2) and y (0.4) given that
dy
dx
= 1 + y2 and y (0) = 0.
7. Explain Picard’s method of successive approximation for numerical solution of ordinary
differential equations.
492 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
8. Approximate y and z by using Picard’s method for the solution of simultaneous differential
equations
dy
dx
= 2x + z,
dz
dx
= 3xy + x2z
with y = 2, z = 0 at x = 0 up to third approximation.
9. Using Picard’s method, obtain the solution of
dy
dx
= x(1 + x3y), y (0) = 3
Tabulate the values of y(0.1), y(0.2).
6.8 EULER’S METHOD
Euler’s method is the simplest one-step method and has a limited application
because of its low accuracy. This method yields solution of an ordinary
differential equation in the form of a set of tabulated values.
In this method, we determine the change Δy is y corresponding to small
increase in the argument x. Consider the differential equation
dy
dx
f x y
= ( , ) , y(x0) = y0 (7)
Let y = g(x) be the solution of (7). Let x0, x1, x2, ...... be equidistant values
of x.
In this method, we use the property that in a small interval, a curve is
nearly a straight line. Thus at the point (x0, y0), we approximate the curve by
the tangent at the point (x0, y0).
Y
O
X
Q1
Q2
P0
x0 x1 x2
y0
y1
y2
slope f(x , y )
0
0
slope
f(x
, y
)
1
1
y
=
g
(
x
)
The eqn. of the tangent at P0(x0, y0) is
y – y0 =
dy
dx
x x
F
HG I
KJP0
0
( – ) = f(x0, y0) (x – x0)
⇒ y = y0 + (x – x0) f(x0, y0) (8)
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 493
This gives the y-coordinate of any point on the tangent. Since the curve is
approximated by the tangent in the interval (x0, x1), the value of y on the curve
corresponding to x = x1 is given by the above value of y in eqn. (8) approximately.
Putting x = x1(= x0 + h) in eqn. (8), we get
y1 = y0 + hf(x0, y0)
Thus Q1 is (x1, y1)
Similarly, approximating the curve in the next interval (x1, x2) by a line
through Q1(x1, y1) with slope f(x1, y1), we get
y2 = y1 + hf(x1, y1)
In general, it can be shown that,
yn+1 = yn + hf(xn, yn)
This is called Euler’s Formula.
A great disadvantage of this method lies in the fact that if
dy
dx
changes
rapidly over an interval, its value at the beginning of the interval may give a
poor approximation as compared to its average value over the interval and
thus the value of y calculated from Euler’s method may be in much error from
its true value. These errors accumulate in the succeeding intervals and the
value of y becomes erroneous.
In Euler’s method, the curve of the actual solution y = g(x) is approximated
by a sequence of short lines. The process is very slow. If h is not properly
chosen, the curve P0Q1Q2 ...... of short lines representing numerical solution
deviates significantly from the curve of actual solution.
To avoid this error, Euler’s modified method is preferred because in
this, we consider the curvature of the actual curve inplace of approximating
the curve by sequence of short lines.
6.9 ALGORITHM OF EULER’S METHOD
1. Function F(x,y)=(x–y)/(x+y)
2. Input x0,y0,h,xn
3. n=((xn–x0)/h)+1
4. For i=1,n
5. y=y0+h*F(x0,y0)
6. x=x+h
NOTE
494 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7. Print x0,y0
8. If xxn then
x0=x
y0=y
ELSE
9. Next i
10. Stop
6.10 FLOW-CHART OF EULER’S METHOD
For i = 1, n
START
F(x, y) = (x – y)/(x + y)
Input x0, y0, h, xn
n = (xn – x0)/h + 1
y = y0 + h*F(x0, y0)
x = x + h
Print x0, y0
If
x  xn
x0 = x
y0 = y
STOP
No
Yes
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 495
6.11 PROGRAM OF EULER’S METHOD
#includestdio.h
#define F(x,y) (x–y)/(x+y)
main ( )
{
int i,n;
float x0,y0,h,xn,x,y;
printf(n Enter the values: x0,y0,h,xn: n);
scanf (%f%f%f%f,x0,y0,h,xn);
n=(xn–x0)/h+1;
for (i=1;i=n;i++)
{
y=y0+h*F(x0,y0);
x=x0+h;
printf(n X=%f Y=%f,x0,y0);
if(xxn)
{
x0=x;
y0=y;
}
}
return;
}
6.11.1 Output
Enter the values: x0,y0,h,xn:
0 1 0.02 0.1
X=0.000000 Y=1.000000
X=0.020000 Y=0.980000
X=0.040000 Y=0.960800
X=0.060000 Y=0.942399
X=0.080000 Y=0.924793
X=0.100000 Y=0.907978
496 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.11.2 Notations used in the Program
(i) x0 is the initial value of x.
(ii) y0 is the initial value of y.
(iii) h is the spacing value of x.
(iv) xn is the last value of x at which value of y is required.
6.12 MODIFIED EULER’S METHOD
The modified Euler’s method gives greater improvement in accuracy over the
original Euler’s method. Here the core idea is that we use a line through (x0, y0)
whose slope is the average of the slopes at (x0, y0)and (x1, y1
(1)) where y1
(1) = y0 +
hf(x0, y0). This line approximates the curve in the interval (x0, x1).
Geometrically, if L1 is the tangent at (x0, y0), L2 is a line through (x1, y1
(1)) of
slope f(x1, y1
(1)) and L is the line through (x1, y1
(1)) but with a slope equal to the
average of f(x0, y0) and f(x1, y1
(1)) then the line L through (x0, y0) and
parallel to L is used to approximate the curve in the interval (x0, x1). Thus the
ordinate of the point B will give the value of y1. Now, the eqn. of the line AL is
given by
Y
O
X
x0 x1
A
L1
L2
L
L
B
(x , y )
1 1
(x , y )
1 1
(1)
(x , y )
0 0
y1 = y0 + (x1 – x0)
f x y f x y
( , ) ( , )
(1)
0 0 1 1
2
+
L
N
MM
O
Q
PP
= y0 + h
f x y f x y
( , ) ( , )
( )
0 0 1 1
1
2
+
L
NMM
O
QPP
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 497
A generalised form of Euler’s modified formula is
y1
(n+1) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(n)}] ; n = 0, 1, 2, ......
where y1
(n) is the nth approximation to y1.
The above iteration formula can be started by choosing y1
(1) from Euler’s
formula
y1
(1) = y0 + hf(x0, y0)
Since this formula attempts to correct the values of yn+1 using the predicted
value of yn+1 (by Euler’s method), it is classified as a one-step predictor-corrector
method.
6.13 ALGORITHM OF MODIFIED EULER’S METHOD
1. Function F(x)=(x–y)/(x+y)
2. Input x(1),y(1),h,xn
3. yp=y(1)+h*F(x(1),y(1))
4. itr=(xn–x(1))/h
5. Print x(1),y(1)
6. For i=1,itr
7. x(i+1)=x(i)+h
8. For n=1,50
9. yc(n+1)=y(i)+(h/2*(F(x(i),y(i))+F(x(i+1),yp))
10. Print n,yc(n+1)
11. p=yc (n+1)-yp
12. If abs(p).0001 then
goto Step 14
ELSE
yp=yc(n+1)
13. Next n
14. y(i+1)=yc(n+1)
15. print x(i+1),yp
16. Next i
17. Stop
498 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.14 FLOW-CHART OF MODIFIED EULER’S METHOD
START
F(x) = (x – y)/(x + y)
Input x(1), y(1), h, xn
itr = (xn – x(1))/h
Print x(1), y(1)
yp = y(1) + h*F(x(1), y(1))
For i = 1, itr
x(i + 1) = x(i) + h
Print n, yc(n + 1)
If
abs(p)  0.0001
yp = yc(n + 1)
STOP
No
Yes
For n = 1, 50
yc(n + 1) = y(i) + (h/2*(F(x(i), y(i)) +
F(x(i + 1), yp))
p = yc(n + 1) – yp
y(i + 1) = yc(n + 1)
Print x(i + 1), yp
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 499
6.15 PROGRAM OF MODIFIED EULER’S METHOD
#includestdio.h
#includemath.h
#define F(x,y) (x-y)/(x+y)
main ()
{
int i,n,itr ;
float x[5],y[50],yc[50],h,yp,p,xn;
printf(n Enter the values: x[1],y[1],h,xn:n);
scanf(%f%f%f%f,x[1],y[1],h,xn);
yp=y[1]+h*F(x[1],y[1]);
itr=(xn-x[1])/h;
printf(nn X=%f Y=%fn,x[1],y[1];
for (i=1;i=itr;i++)
{
x[i+1]=x[i]+h;
for (n=1;n=50;n++)
{
yc[n+1]=y[i]+(h/2.0)*(F(x[i],y[i])+F(x[i+1],yp));
printf(nN=%d Y=%f,n,yc[n+1]);
p=yc[n+1]-yp;
if(fabs (p)0.0001)
goto next;
else
yp=yc[n+1];
}
next:
y[i+1]=yc[n+1];
printf(nn X=%f Y=%fn,x[i+1], yp);
}
return;
}
500 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.15.1 Output
Enter the values: x[1],y[1],h,xn:
0 1 0.02 0.06
X=0.000000 Y=1.000000
N=1 Y=0.980400
N=2 Y=0.980400
X=0.020000 Y=0.980400
N=1 Y=0.961584
N=2 Y=0.961598
X=0.040000 Y=0.961584
N=1 Y=0.943572
N=2 Y=0.943593
X=0.060000 Y=0.943572
6.15.2 Notations used in the Program
(i) x(1) is an array of the initial value of x.
(ii) y(1) is an array of the initial value of y.
(iii) h is the spacing value of x.
(iv) xn is the last value of x at which value of y is required.
EXAMPLES
Example 1. Given
dy
dx
y – x
y x
=
+
with y = 1 for x = 0. Find y approximately for
x = 0.1 by Euler’s method.
Sol. We have
dy
dx
= f(x, y) =
y x
y x
–
+
; x0 = 0, y0 = 1, h = 0.1
Hence the approximate value of y at x = 0.1 is given by
y1 = y0 + hf(x0, y0) | using yn+1 = yn + hf(xn, yn)
= 1 + (.1) +
1 0
1 0
–
+
F
HG I
KJ = 1.1
Much better accuracy is obtained by breaking up the interval 0 to 0.1 into
five steps. The approximate value of y at xA = .02 is given by,
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 501
y1 = y0 + hf(x0, y0)
= 1 + (.02)
1 0
1 0
–
+
F
HG I
KJ = 1.02
At xB = 0.04, y2 = y1 + hf(x1, y1)
= 1.02 + (.02)
102 02
102 02
. – .
. .
+
F
HG I
KJ = 1.0392
At xC = .06, y3 = 1.0392 + (.02)
1.0392 – .04
1.0392 .04
+
F
HG I
KJ = 1.0577
At xD = .08, y4 = 1.0577 + (.02)
1.0577 – .06
1.0577 .06
+
F
HG I
KJ = 1.0756
At xE = .1, y5 = 1.0756 + (.02)
1.0756 – .08
1.0756 .08
+
F
HG I
KJ = 1.0928
Hence y = 1.0928 when x = 0.1
Y
O
X
A¢
A
B
C
D
E
B¢ C¢ D¢ E¢
Example 2. Solve the equation
dy
dx
1 – y
= with the initial condition x = 0, y = 0
using Euler’s algorithm and tabulate the solutions at x = 0.1, 0.2, 0.3.
Sol. Here, f(x, y) = 1 – y
Taking h = 0.1, x0 = 0, y0 = 0, we obtain
y1 = y0 + hf(x0, y0)
= 0 + (.1) (1 – 0) = .1
∴ y(0.1) = 0.1
502 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Again, y2 = y1 + hf(x1, y1)
= 0.1 + (0.1) (1 – .1)
= 0.1 + .09 = .19
∴ y(0.2) = 0.19
Again, y3 = y2 + hf(x2, y2)
= .19 + (.1) (1 – .19)
= .19 + (.1) (.81) = .271
∴ y(0.3) = .271
Tabulated values are
x y(x)
0 0
0.1 0.1
0.2 0.19
0.3 0.271
Example 3. Using Euler’s modified method, obtain a solution of the equation
dy
dx
x | y| f(x, y)
= + =
with initial condition y = 1 at x = 0 for the range 0 ≤ x ≤ 0.6 in steps of 0.2.
Sol. Here f(x, y) = x +| |
y ; x0 = 0, y0 = 1, h = .2
∴ f(x0, y0) = x0 +| |
y 0
= 0 + 1 = 1
We have y1
(1) = y0 + hf(x0, y0)
= 1 + (.2) . 1 = 1.2
∴ f(x1, y1
(1)) = x1 + | |
( )
y 1
1
= 0.2 +| . |
12 = 1.2954
The second approximation to y1 is
y1
(2) = y0 + h
f x y f x y
( , ) { , }
( )
0 0 1 1
1
2
+
L
NMM
O
QPP
= 1 + (0.2)
1 12954
2
+
F
HG I
KJ
.
= 1.2295
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 503
Again, f{x1, y1
(2)} = x1 +| |
( )
y1
2
= 0.2 + 12295
. = 1.3088
So, y1
(3) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(2)}]
= 1 +
0 2
2
.
[1 + 1.3088] = 1.2309
We have f{x1, y1
(3)} = 0.2 + 12309
. = 1.309
Then y1
(4) = 1 +
.2
2
[1 + 1.309] = 1.2309
Since, y1
(4) = y1
(3) hence y1 = 1.2309
Now, y2
(1) = y1 + hf(x1, y1)
= 1.2309 + (0.2) [0.2 + 12309
. ]
= 1.4927 |∵ x1 = 0.2
f{x2, y2
(1)} = x2 + y2
1
( ) = 0.4 + 14927
.
= 1.622 |∵ x2 = 0.4
Then, y2
(2) = y1 +
h
2
[f(x1, y1) + f{x2, y2
(1)}]
= 1.2309 +
0 2
2
2 12309 1622
.
[(. . ) . ]
+ + = 1.524
Now, y2
(3) = y1 +
h
f x y f x y
2
1 1 2 2
2
[ ( , ) { , }]
( )
+
= 1.2309 +
0 2
2
2 12309 4 1524
.
[(. . ) (. . )]
+ + +
= 1.5253
y2
(4) = 1.2309 +
0.2
2
[(. . ) (. . )]
2 12309 4 15253
+ + +
Since, y2
(4) = y2
(3) hence y2 = 1.5253
Now, y3
(1) = y2 + hf(x2, y2)
= 1.5253 + (0.2) [.4 + 15253
. ] = 1.8523
y3
(2) = y2 +
h
2
[f(x2, y2) + f{x3, y3
(1)}]
= 1.5253 +
0 2
2
4 15253 6 18523
.
[(. . ) (. . )]
+ + +
= 1.8849
504 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Similarly, y3
(3) = 1.8861 = y3
(4)
Since, y3
(3) = y3
(4)
Hence, we take y3 = 1.8861.
Example 4. Given that
dy
dx
log (x y)
10
= + with the initial condition that y = 1
when x = 0. Find y for x = 0.2 and x = 0.5 using Euler’s modified formula.
Sol. Let x = 0, x1 = 0.2, x2 = .5 then y0 = 1
y1 and y2 are yet to be computed.
Here, f(x, y) = log (x + y)
∴ f(x0, y0) = log 1 = 0
∴ y1
(1) = y0 + hf(x0, y0) = 1
f{x1, y1
(1)} = log {x1 + y1
(1)} = log (.2 + 1) = log (1.2)
∴ y1
(2) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(1)}]
= 1 +
.2
2
[0 + log (1.2)] = 1.0079
Also, y1
(3) = 1 +
.2
2
[0 + log (.2 + 1.0079)] = 1.0082
y1
(4) = 1 +
.2
2
[0 + log (.2 + 1.0082)] = 1.0082
Since, y1
(4) = y1
(3) hence y1 = 1.0082
To obtain y2, the value of y at x = 0.5, we take,
y2
(1) = y1 + hf(x1, y1)
= 1.0082 + 0.3 log (.2 + 1.0082)
= 1.0328 (∵ h = .5 – .2 = .3 here)
Now, y2
(2) = y1 +
h
2
[f(x1, y1) + f{x2, y2
(1)}]
= 1.0082 +
.3
2
[log (.2 + 1.0082) + log (.5 + 1.0328)]
= 1.0082 + 0.0401 = 1.0483
Also, y2
(3) = 1.0082 +
.3
2
[log (.2 + 1.0082) + log (.5 + 1.0483)]
= 1.0082 + .0408 = 1.0490
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 505
Similarly, y2
(4) = 1.0490
Since, y2
(3) = y2
(4) hence, y2 = 1.0490.
Example 5. Given :
dy
dx
= x – y2 ; y(.2) = 0.2, find y(.4) by modified Euler’s
method correct to 3 decimal places, taking h = 0.2.
Sol. Here, f(x, y) = x – y2 ; x0 = 0.2, y0 = .02 and h = 0.2
Let x1 = 0.4 then we are to find y1 = y(0.4)
We have f(x0, y0) = x0 – y0
2 = 0.2 – (.02)2 = 0.2 – .0004 = 0.1996
∴ y1
(1) = y0 + hf(x0, y0) = .02 + (.2) (.1996) = .060
f{x1, y1
(1)} = x1 – {y1
(1)}2 = .4 – (.06)2 = .3964
∴ y1
(2) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(1)}]
= .02 +
.2
2
[.1996 + .3964] = .0796 ~
− .080
Now, f{x1, y1
(2)} = x1 – [y1
(2)]2 = .4 – (.08)2 = .3936
∴ y1
(3) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(2)}]
= .02 +
.2
2
[.1996 + .3936] = .07932 ~
− .079
f{x1, y1
(3)} = x1 – [y1
(3)]2 = .4 – (.079)2 = .3938
∴ y1
(4) = y0 +
h
2
[f(x0, y0) + f{x1, y1
(3)}]
= .02 +
.2
2
[.1996 + .3938] = .0793 ~
− .079
Since y1
(3) = y1
(4) hence y1 = .079.
ASSIGNMENT 6.2
1. Find y for x = 0.2 and x = 0.5 using modified Euler’s method, given that
dy
dx
x y
e
= +
log ( ); y(0) = 1
2. Taking h = .05, determine the value of y at x = 0.1 by Euler’s modified method, given
that,
dy
dx
= x2 + y; y(0) = 1
506 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3. Given
dy
dx
x y
= +
2
, y(0) = 1, find y(.02), y(.04) and y(.06) using Euler’s modified method.
4. Apply Euler’s method to the initial value problem
dy
dx
= x + y, y(0) = 0 at x = 0 to x = 1.0
taking h = 0.2.
5. Use Euler’s method with h = 0.1 to solve the differential equation
dy
dx
= x2 + y2, y(0) = 1
in the range x = 0 to x = 0.3.
6. Solve for y at x = 1.05 by Euler’s method, the differential equation
dy
dx
y
x
=
F
HG I
KJ
2 – where
y = 2 when x = 1. (Take h = 0.05).
7. Use Euler’s modified method to compute y for x = .05 and .10. Given that
dy
dx
x y
= +
with the initial condition x0 = 0, y0 = 1. Give the correct result up to 4 decimal places.
8. Using Euler’s method, compute y(0.04) for the differential eqn.
dy
dx
y
= – ; y(0) = 1. Take
h = 0.01.
9. Compute y(0.5) for the differential eqn.
dy
dx
= y2 – x2 with y(0) = 1 using Euler’s method.
10. Find y(2.2) using modified Euler’s method for
dy
dx
= – xy2; y(2) = 1. Take h = .1.
11. Given
dy
dx
x y y
= + =
3
0 1
, ( ) . Compute y (0.02) by Euler’s method taking h = 0.01.
12. Find y(1) by Euler’s method from the differential equation
dy
dx
y
x
=
+
–
1
when y(0.3) = 2.
Convert up to four decimal places taking step length h = 0.1.
6.16 TAYLOR’S METHOD
Consider the differential equation
dy
dx
= f(x, y) U
V
W
(9)
with the initial condition y(x0) = y0.
If y(x) is the exact solution of (9) then y(x) can be expanded into a Taylor’s
series about the point x = x0 as
y(x) = y0 + (x – x0) y0′ +
( )
!
x x
− 0
2
2
y0″ +
( )
!
x x
− 0
3
3
y0′″ + ...... (10)
where dashes denote differentiation with respect to x.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 507
Differentiating (9) successively with respect to x, we get
y″ =
∂
∂
∂
∂
∂
∂
∂
∂
∂
∂
∂
∂
f
x
f
y
dy
dx
f
x
f
f
y x
f
y
+ = + = +
F
HG I
KJf (11)
∴ y″′ =
d
dx
(y″) =
∂
∂
∂
∂
∂
∂
∂
∂
x
f
y
f
x
f
f
y
+
F
HG I
KJ +
F
HG I
KJ
=
∂
∂
∂
∂
∂
∂
∂
∂ ∂
∂
∂ ∂
∂
∂
∂
∂
2
2
2 2 2
2
2
2
f
x
f
x
f
y
f
f
x y
f
f
y x
f
f
y
f
f
y
+ + + +
F
HG I
KJ + (12)
and so on.
Putting x = x0 and y = y0 in the expressions for y′, y″, y″′, ....... and
substituting them in eqn. (10), we get a power series for y(x) in powers of x – x0.
i.e., y(x) = y0 + (x – x0)y0′ +
( )
!
x x
− 0
2
2
y0″
+
( )
!
x x
− 0
3
3
y0″′ + ....... (13)
Putting x = x1 (= x0 + h) in (13), we get
y1 = y(x1) = y0 + hy0′ +
h2
2 !
y0″ +
h3
3 !
y0″′ + ....... (14)
Here y0′, y0″, y0″′, ...... can be found by using (9) and its successive
differentiations (11) and (12) at x = x0 . The series (14) can be truncated at any
stage if h is small.
After obtaining y1, we can calculate y1′, y1″, y1″′, ...... from (9) at x1 = x0 + h.
Now, expanding y(x) by Taylor’s series about x = x1, we get
y2 = y1 + hy′1 +
h2
2 !
y1″ +
h3
3 !
y1″′ + .......
Proceeding, we get
yn = yn –1 + hyn–1′ +
h2
2 !
yn–1″ +
h3
3 !
yn–1″′ + ........
Practically, this method is not of much importance because of its need of
partial derivatives.
Moreover if we are interested in a better approximation with a small
truncation error, the evaluation of higher order derivatives is needed which
are complicated in evaluation. Besides its impracticability, it is useful in judging
the degree of accuracy of the approximations given by other methods.
508 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
We can determine the extent to which any other formula agrees with the
Taylor’s series expansion. Taylor’s method is one of those methods which yield
the solution of a differential equation in the form of a power series. This method
suffers from a serious disadvantage that h should be small enough so that
successive terms in the series diminish quite rapidly.
6.17 TAYLOR’S METHOD FOR SIMULTANEOUS I ORDER
DIFFERENTIAL EQUATIONS
Simultaneous differential equations of the type
dy
dx
= f(x, y, z) (15)
and
dz
dx
= φ(x, y, z) (16)
with initial conditions y(x0) = y0 and z(x0) = z0
can be solved by Taylor’s method.
If h is the step-size then
y1 = y(x0 + h) and z1 = z(x0 + h)
Taylor’s algorithm for (15) and (16) gives
y1 = y0 + hy0′ +
h2
2!
y0″ +
h3
3 !
y0″′ + ...... (17)
and z1 = z0 + hz0′ +
h2
2!
z0″ +
h3
3 !
z0″′ + ...... (18)
Differentiating (15) and (16) successively, we get y″, y″′, ......., z″, z″′, ......
etc. So the values y0″, y0″′, ...... and z0″, z0″′, ...... can be obtained.
Substituting them in (17) and (18), we get y1, z1 for the next step.
y2 = y1 + hy1′ +
h2
2 !
y1″ +
h3
3 !
y1′″ + ......
and z2 = z1 + hz1′ +
h2
2 !
z1″ +
h
z
3
1
3!
″ ′ + .......
Since y1 and z1 are known, y1′, y1″, y1″′......., z1′, z1″, z1″′, ....... can be calculated.
Hence y2 and z2 can be obtained. Proceeding in this manner, we get other values
of y, step-by-step.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 509
EXAMPLES
Example 1. Use Taylor’s series method to solve
dy
dx
= x + y; y(1) = 0
numerically up to x = 1.2 with h = 0.1. Compare the final result with the value
of explicit solution.
Sol. Here, x0 = 1, y0 = 0
y′ = x + y i.e., y0′ = x0 + y0 = 1
⇒ y″ = 1 + y′ i.e., y0″ = 1 + y0′ = 2
⇒ y″′ = y″ i.e., y0″′ = y0″ = 2
⇒ y(iv) = y″′ i.e., y0
(iv) = 2
⇒ y(v) = y(iv) i.e., y0
(v) = 2
By Taylor’s series, we have
y1 = y0 + hy0′ +
h2
2!
y0″ +
h3
3 !
y0″′ +
h4
4 !
y0
(iv) + ......
y(1 + h) = 0 + (0.1) 1 +
(0.1)
2 !
2
2 +
(0.1)
3 !
3
2 +
(0.1)
4 !
4
2 + ......
⇒ y(1.1) = 0.1103081 = 0.110 (app.)
Also, x1 = x0 + h = 1.1
Again, y1′ = x1 + y1 = 1.1 + 0.11 = 1.21
y1″ = 1 + y1′ = 1 + 1.21 = 2.21
y1″′ = y1″ = 2.21
y1
(iv) = 2.21
y1
(v) = 2.21
Now, y(1.1 + h) = y1 + hy1′ +
h2
2 !
y1″ +
h3
3 !
y1″′ + ......
= 0 . 11 + (0.1) (1.21) +
( . )
0 1
2
2
(2.21) + ......
⇒ y(1.2) = 0.232 (app.)
510 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The analytical solution of the given differential equation is
y = – x – 1 + 2ex –1
when x = 1.2, we get
y = – 1.2 – 1 + 2e0.2 = 0.242.
Example 2. For the differential eqn.,
dy
dx
= – xy2, y (0) = 2. Calculate y(0. 2) by
Taylor’s series method retaining four non-zero terms only.
Sol. Here x0 = 0, y0 = 2 Also y′ = – xy2
Taylor’s series for y(x) is given by
y(x) = y0 + xy0′ +
x2
2
y0″ +
x3
6
y0″′ +
x4
24
y0
(iv)
+
x5
120
y0
(v) + ....... (19)
The values of the derivatives y0′, y0″, ......., etc. are obtained as follows:
y′ = – xy2 y0′ = – x0y0
2 = 0
y″ = – y2 – 2xyy′ y 0″ = – 22 – 0 = – 4
y′″ = – 4yy′ – 2xy′2 – 2xyy″ y0′″ = 0
y(iv) = – 6y′2 – 6y′y″ – 6xy′y″ – 2xyy′″ y0
(iv) = 48
y(v) = – 24y′y″ – 8yy′″ – 6xy″2 y0
(v) = 0
– 8xy′y″′ – 2xyy(iv)
y(vi) = – 40y′y′″ – 30y″2 – 10 yy(iv) – 20xy″y″′ y0
(vi) = – 1440
– 10xy′ y(iv) – 2xyy(v).
We stop here as we shall get four non-zero terms in the Taylor’s series (19).
∴ y(x) = 2 +
x2
2
(– 4) +
x4
24
(48) +
x6
720
(– 1440) + ......
= 2 – 2x2 + 2x4 – 2x6 + .......
∴ y(0.2) = 2 – 2(0.2)2 + 2(0.2)4 – 2 (0.2)6 + ......
= 2 – 0.08 + 0.0032 – 0.000128 = 1.923072
~
− 1.9231 correct up to four decimal places.
Example 3. From the Taylor’s series, for y(x), find y(0.1) correct to four decimal
places if y(x) satisfies
dy
dx
= x – y2 and y(0) = 1. Also find y(0.2).
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 511
Sol. Here x0 = 0, y0 = 1
y′ = x – y2 y0′ = 0 – 1 = – 1
y″ = 1 – 2yy′ y0″ = 3
y″′ = – 2yy″ – 2y′2 y0′″ = – 8
y(iv) = – 2yy′″ – 6y′y″ y0
(iv) = 34
y(v) = – 2yy(iv) – 8y′y′″ – 6y″2 y0
(v) = – 186
y(vi) = – 2yy(v) – 10y′y(iv) – 20 y″y′″ y0
(vi) = 1192 U
V
W
y(vii) = – 2yy(vi) – 12y′y(v) – 50 y″y(iv) y0
(vii) = – 10996 only for y(0.2)
– 20 y′″2
Using these values, Taylor’s series becomes
y(x) = 1 – x +
3
2
x2 –
4
3
x3 +
17
12
x4 –
31
20
x5 + ...... (20)
Put x = 0.1 in (20), we get
y(0.1) = 0.91379 ~
− 0.9138 (upto four decimal places)
To determine y(0.2), we have
y(x) = 1 – x +
3
2
x2 –
4
3
x3 +
17
12
x4 –
31
20
x5 +
1192
720
x6 –
10996
5040
x7 + ........
= 0.8512 (correct to four decimal places).
Example 4. Using Taylor’s series, find the solution of the differential equation
xy′ = x – y, y(2) = 2 at x = 2.1 correct to five decimal places.
Sol. Here x0 = 2, y0 = 2
Also, y′ = 1 –
y
x
y0′ = 0
y″ = –
′
+
y
x
y
x2 y0″ = – 0 +
2
4
1
2
=
y″′ = −
′′
+
′
−
y
x
y
x
y
x
2 2
2 3 y0″′ =
− 3
4
y(iv) = –
′′′
+
′′
−
′
+
y
x
y
x
y
x
y
x
3 6 6
2 3 4 y0
(iv) =
3
2
and so on.
Putting these values in Taylor’s series, we get
y(2 + h) = 2 +
h h h
2 3 4
4 8 16
− + + .......
512 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Put h = 0.1, we get
y (2.1) = 2.00238 (correct to 5 decimal places).
Example 5. Find y(1) for
dy
dx
= 2y + 3ex , y(0) = 0. Also check the value.
Sol. Here x0 = 0, y0 = 0
y′(x) = 2y + 3ex y0′ = 3, y0″ = 9,
y″(x) = 2y′ + 3ex y0″′ = 21, y0
(iv) = 45
: :
: : y0
(v) = 93, y0
(vi) = 189
y(viii) (x) = 2y(vii) + 3ex y0
(vii) = 381, y0
(viii) = 765
Now, y(h) = 3h +
9
2
h2 +
7
2
h3 +
15
8
h4 +
31
40
h5 +
21
80
h6 +
127
1680
h7
+
17
896
h8 + .......
Put h = 1, y(1) = 14.01
Exact solution.
dy
dx
– 2y = 3ex
Solution is ye–2x = – 3e–x + c
x = 0, y = 0 ∴ c = 3
∴ ye–2x = – 3e–x + 3
⇒ y = 3(e2x – ex)
when x = 1,
y = 3(e2 – e) = 14.01 correct to two decimal places.
Example 6. Solve the simultaneous equations
y′ = 1 + xyz, y (0) = 0
z′ = x + y + z, z(0) = 1.
Sol. Differentiating the given equations
y″ = yz + xy′z + xyz′, y″′ = 2y′z + 2yz′ + 2xy′z′ + xy″z + xyz″
z″ = 1 + y′ + z′, z″′ = y″ + z″
with x = 0, y = 0, z = 1; we get y′ = 1, y″ = 0, y″′ = 2
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 513
Also z′ = 1, z″ = 3, z″′ = 3
Hence, y(x) = x +
x3
3
and z(x) = 1 + x +
3
2
x2 +
1
2
x3.
ASSIGNMENT 6.3
1. Compute y for x = 0.1 and 0.2 correct to four decimal places given: y′ = y – x, y (0) = 2.
2. Solve by Taylor’s method, y′ = x2 + y2, y(0) = 1 compute y(0.1).
3. Solve by Taylor’s method: y′ = y –
2x
y
; y(0) = 1. Also compute y(0.1).
4. Using Taylor series method, solve
dy
dx
= x2 – y, y(0) = 1 at x = 0.1, 0.2, 0.3 and 0.4.
Compare the values with exact solution.
5. Solve
dy
dx
= x + z,
dz
dx
= x – y2 with y(0) = 2, z(0) = 1 to get y(0. 1), y(0. 2), z(0. 1) and
z(0. 2) approximately by Taylor’s algorithm.
6. Given the differential equation dy
dx x y
=
+
1
2
with y(4) = 4
Obtain y (4.1) and y(4.2) by Taylor’s series method.
6.18 RUNGE-KUTTA METHODS
More efficient methods in terms of accuracy were developed by two German
Mathematicians Carl Runge (1856-1927) and Wilhelm Kutta (1867-1944).
These methods are well-known as Runge-Kutta methods. They are
distinguished by their orders in the sense that they agree with Taylor’s series
solution up to terms of hr where r is the order of the method.
These methods do not demand prior computation of higher derivatives of
y(x) as in Taylor’s method. In place of these derivatives, extra values of the
given function f(x, y) are used.
The fourth order Runge-Kutta method is used widely for finding the
numerical solutions of linear or non-linear ordinary differential equations.
Runge-Kutta methods are referred to as single step methods. The major
disadvantage of Runge-Kutta methods is that they use many more evaluations
of the derivative f(x, y) to obtain the same accuracy compared with multi-step
methods. A class of methods known as Runge-Kutta methods combines the
advantage of high order accuracy with the property of being one step.
514 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.18.1 First Order Runge-Kutta Method
Consider the differential equation
dy
dx
= f(x, y); y (x0) = y0 (21)
Euler’s method gives
y1 = y0 + hf(x0, y0) = y0 + hy0′ (22)
Expanding by Taylor’s series, we get
y1 = y(x0 + h) = y0 + hy0′ +
h2
2 !
y0″ + ....... (23)
Comparing (22) and (23), it follows that Euler’s method agrees with Taylor’s
series solution up to the term in h. Hence Euler’s method is the first order
Runge-Kutta method.
6.18.2 Second Order Runge-Kutta Method
Consider the differential equation
y′ = f(x, y) with the initial condition y(x0) = y0
Let h be the interval between equidistant values of x then in II order Runge-
Kutta method, the first increment in y is computed from the formulae
k1 = hf (x0, y0)
k2 = hf(x0 + h, y0 + k1)
Δy = 1
2
(k1 + k2)
taken in the given order.
Then, x1 = x0 + h
y1 = y0 + Δy = y0 + 1
2
(k1 + k2)
In a similar manner, the increment in y for the second interval is computed
by means of the formulae,
k1 = hf (x1, y1)
k2 = hf (x1 + h, y1 + k1)
Δy = 1
2
(k1 + k2)
and similarly for the next intervals.
The inherent error in the second order Runge-Kutta method is of order h3.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 515
6.18.3 Third Order Runge-Kutta Method
This method gives the approximate solution of the initial value problem
dy
dx
= f (x, y); y(x0) = y0 as
y1 = y0 + δy
U
V
W (24)
where δy =
h
6
(k1 + 4k2 + k3)
Here, k1 = f (x0, y0)
k2 = f x
h
y
k
0 0
1
2 2
+ +
R
S
T
U
V
W
,
k3 = f (x0 + h, y0 + k′); k′ = hf (x0 + h, y0 + k1)
Formula (24) can be generalized for successive approximations. Expression
in (24) agrees with Taylor’s series expansion for y1 up to and including terms in
h3. This method is also known as Runge’s method.
6.19 FOURTH ORDER RUNGE-KUTTA METHOD
The fourth order Runge-Kutta Method is one of the most widely used methods
and is particularly suitable in cases when the computation of higher derivatives
is complicated.
Consider the differential equation y′ = f(x, y) with the initial condition
y(x0) = y0. Let h be the interval between equidistant values of x, then the first
increment in y is computed from the formulae
k1 = hf (x0, y0)
k2 = hf x
h
y
k
0 0
1
2 2
+ +
F
HG I
KJ
,
k3 = hf x
h
y
k
0 0
2
2 2
+ +
F
HG I
KJ
,
U
V
|
|
|
|
|
W
|
|
|
|
|
(25)
k4 = hf (x0 + h, y0 + k3)
Δy =
1
6
(k1 + 2k2 + 2k3 + k4)
taken in the given order.
Then, x1 = x0 + h and y1 = y0 + Δy
516 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
In a similar manner, the increment in y for the II interval is computed by
means of the formulae
k1 = hf (x1, y1)
k2 = hf x
h
y
k
1 1
1
2 2
+ +
F
HG I
KJ
,
k3 = hf x
h
y
k
1 1
2
2 2
+ +
F
HG I
KJ
,
k4 = hf (x1 + h, y1 + k3)
Δy =
1
6
(k1 + 2k2 + 2k3 + k4)
and similarly for the next intervals.
This method is also simply termed as Runge-Kutta’s method.
It is to be noted that the calculations for the first increment are exactly the
same as for any other increment. The change in the formula for the different
intervals is only in the values of x and y to be substituted. Hence, to obtain Δy
for the nth interval, we substitute xn–1, yn–1, in the expressions for k1, k2, etc.
The inherent error in the fourth order Runge-Kutta method is of the order
h5.
6.19.1 Algorithm of Runge-Kutta Method
1. Function F(x)=(x-y)/(x+y)
2. Input x0,y0,h,xn
3. n=(xn-x0)/h
4. x=x0
5. y=y0
6. For i=0, n
7. k1=h*F(x,y)
8. k2=h*F(x+h/2,y+k1/2)
9. k3=h*F(x+h/2,y+k2/2)
10. k4=h*F(x+h,y+k3)
11. k=(k1+(k2+k3)2+k4)/6
12. Print x,y
13. x=x+h
14. y=y+k
15. Next i
16. Stop
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 517
6.19.2 Flow-Chart of Runge-Kutta Method
For i = 0, n
START
F(x) = (x – y)/(x + y)
Input x0, y0, h, xn
n = (xn – x0)/h
x = x0
y = y0
k1 = h*F(x, y)
k2 = h*F(x + h/2, y + k1/2)
k3 = h*F(x + h/2, y + k2/2)
k4 = h*F(x + h, y + k3)
k = (k1 + 2(k2 + k3) + k4)/6
Print x, y
x = x + h
y = y + k
STOP
6.19.3 Program of Runge-Kutta Method
#includestdio.h
#define F(x,y) (x-y)/(x+y)
main()
{
int i,n;
float x0,y0,h,xn,k1,k2,k3,k4,x,y,k;
printf(n Enter the values: x0,y0,h,xn:n);
518 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
scanf(%f%f%f%f, x0,y0,h,xn);
n=(xn-x0)/h;
x=x0;
y=y0;
for(i=0;i=n;i++)
{
k1=h*F(x,y);
k2=h*F(x+h/2.0,y+k1/2.0);
k3=h*F(x+h/2.0,y+k2/2.0);
k4=h*F(x+h,y+k3);
k=(k1+(k2+k3)*2.0+k4)/6.0;
printf(n X=%f Y=%f, x, y);
x=x+h;
y=y+k;
}
return;
}
6.19.4 Output
Enter the values: x0,y0,h,xn:
0 1 0.02 0.1
X=0.000000 Y=1.000000
X=0.020000 Y=0.980000
X=0.040000 Y=0.960816
X=0.060000 Y=0.942446
X=0.080000 Y=0.924885
X=0.100000 Y=0.908128
Notations used in the Program
(i) x0 is the initial value of x.
(ii) y0 is the initial value of y.
(iii) h is the spacing value of x.
(iv) xn is the last value of x at which value of y is required.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 519
6.20 RUNGE-KUTTA METHOD FOR SIMULTANEOUS FIRST ORDER
EQUATIONS
Consider the simultaneous equations
dy
dx
= f1(x, y, z)
dz
dx
= f2 (x, y, z)
With the initial condition y(x0) = y0 and z(x0) = z0. Now, starting from
(x0, y0, z0), the increments k and l in y and z are given by the following formulae:
k1 = hf1(x0, y0, z0);
l1 = hf2(x0, y0, z0)
k2 = hf1 x
h
y
k
z
l
0 0
1
0
1
2 2 2
+ + +
F
HG I
KJ
, , ;
l2 = hf2 x
h
y
k
z
l
0 0
1
0
1
2 2 2
+ + +
F
HG I
KJ
, ,
k3 = hf1 x
h
y
k
z
l
0 0
2
0
2
2 2 2
+ + +
F
HG I
KJ
, , ;
l3 = hf2 x
h
y
k
z
l
0 0
2
0
2
2 2 2
+ + +
F
HG I
KJ
, ,
k4 = hf1(x0 + h, y0 + k3 , z0 + l3);
l4 = hf2(x0 + h, y0 + k3 , z0 + l3)
k =
1
6
(k1 + 2k2 + 2k3 + k4);
l =
1
6
(l1 + 2l2 + 2l3 + l4)
Hence y1 = y0 + k, z1 = z0 + l
To compute y2, z2, we simply replace x0, y0, z0 by x1, y1, z1 in the above
formulae.
520 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
EXAMPLES
Example 1. Solve the equation
dy
dx
= x + y with initial condition y(0) = 1 by
Runge-Kutta rule, from x= 0 to x = 0.4 with h = 0.1.
Sol. Here f(x, y) = x + y, h = 0.1, x0 = 0, y0 = 1
We have,
k1 = hf (x0, y0) = 0.1 (0 + 1) = 0.1
k2 = hf x
h
y
k
0 0
1
2 2
+ +
F
HG I
KJ
, = 0.1 (0.05 + 1.05) = 0.11
k3 = hf x
h
y
k
0 0
2
2 2
+ +
F
HG I
KJ
, = 0.1105
k4 = hf (x0 + h, y0 + k3) = 0.12105
∴ Δy =
1
6
(k1 + 2k2 + 2k3 + k4) = 0.11034
Thus, x1 = x0 + h = 0.1 and y1 = y0 + Δy = 1.11034
Now for the second interval, we have
k1 = hf (x1, y1) = 0.1 (0.1 + 1.11034) = 0.121034
k2 = hf x
h
y
k
1 1
1
2 2
+ +
F
HG I
KJ
, = 0.13208
k3 = hf x
h
y
k
1 1
2
2 2
+ +
F
HG I
KJ
, = 0.13263
k4 = hf (x1 + h, y1 + k3) = 0.14429
∴ Δy =
1
6
(k1 + 2k2 + 2k3 + k4) = 0.132460
Hence x2 = 0.2 and y2 = y1 + Δy = 1.11034 + 0.13246 = 1.24280
Similarly, for finding y3, we have
k1 = hf (x2, y2) = 0.14428
k2 = 0.15649
k3 = 0.15710 Repeating the above
process
k4 = 0.16999
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 521
∴ y3 = 0.13997
and for y4 = y(0.4), we calculate
k1 = 0.16997
k2 = 0.18347
k3 = 0.18414
k4 = 0.19838
∴ y4 = 1.5836
Example 2. Given
dy
dx
= y – x, y(0) = 2. Find y(0.1) and y(0.2) correct to four
decimal places (use both II and IV order methods).
Sol. By II order Method
To find y(0.1)
Here y′ = f (x, y) = y – x, x0 = 0, y0 = 2 and h = 0.1
Now, k1 = hf (x0, y0) = 0.1(2 – 0) = 0.2
k2 = hf (x0 + h, y0 + k1) = 0.21
∴ Δy =
1
2
(k1 + k2) = 0.205
Thus, x1 = x0 + h = 0.1 and y1 = y0 + Δy = 2.205
To find y(0.2) we note that,
x1 = 0.1, y1 = 2.205, h = 0.1
For interval II, we have
k1 = hf (x1, y1) = 0.2105
k2 = hf (x1 + h, y1 + k1) = 0.22155
∴ Δy =
1
2
(k1 + k2) = 0.216025
Thus, x2 = x1 + h = 0.2 and y2 = y1 + Δy = 2.4210
Hence y(0.1) = 2.205, y(0.2) = 2.421.
By IV order method- As before
k1 = 0.2, k2 = 0.205,
k3 = hf (x0 + h/2, y0 + k2/2) = 0.20525
and k4 = hf (x0 + h, y0 + k3) = 0.210525
522 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ Δy =
1
6
(k1 + 2k2 + 2k3 + k4) = 0.2052
Thus, x1 = x0 + h = 0 + 0.1 = 0.1
y1 = y0 + Δy = 2 + 0.2052 = 2.2052
Now to determine y2 = y(0.2), we note that
x1 = x0 + h = 0.1, y1 = 2.2052, h = 0.1
For interval II, k1 = hf (x1, y1) = 0.21052
k2 = hf x
h
y
k
1 1
1
2 2
+ +
F
HG I
KJ
, = 0.21605
k3 = hf x h y
k
1 1
2
2
2
+ +
F
HG I
KJ
/ , = 0.216323
and k4 = hf (x1 + h, y1 + k3) = 0.221523
∴ Δy =
1
6
(k1 + 2k2 + 2k3 + k4) = 0.21613
Thus, x2 = x1 + h = 0.1 + 0.1 = 0.2
and y2 = y1 + Δy = 2.2052 + 0.21613 = 2.4213
Hence y(0.1) = 2.2052, y(0.2) = 2.4213.
Example 3. Solve
dy
dx
= yz + x,
dz
dx
= xz + y;
given that y(0) = 1, z(0) = – 1 for y(0.1), z(0.1).
Sol. Here, f1(x, y, z) = yz + x
f2 (x, y, z) = xz + y
h = 0.1, x0 = 0, y0 = 1, z0 = – 1
k1 = hf1 (x0, y0, z0) = h (y0 z0 + x0) = – 0.1
l1 = hf2(x0, y0, z0) = h(x0 z0 + y0) = 0.1
k2 = hf1 x
h
y
k
z
l
0 0
1
0
1
2 2 2
+ + +
F
HG I
KJ
, ,
= hf1(0.05, 0.95, – 0.95) = – 0.08525
l2 = hf2 x
h
y
k
z
l
0 0
1
0
1
2 2 2
+ + +
F
HG I
KJ
, ,
= hf2 (0.05, 0.95, – 0.95) = 0.09025
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 523
k3 = hf1 x
h
y
k
z
l
0 0
2
0
2
2 2 2
+ + +
F
HG I
KJ
, ,
= hf1(0.05, 0.957375, – 0.954875) = – 0.0864173
l3 = hf2
x
h
y
k
z
l
0 0
2
0
2
2 2 2
+ + +
F
HG I
KJ
, ,
= hf2 (0.05, 0.957375, – 0.954875) = – 0.0864173
k4 = hf1 x h y k z l
0 0 3 0 3
+ + +
, ,
b g = – 0.073048.
l4 = hf2(x0 + h, y0 + k3, z0 + l3) = 0.0822679
k =
1
6
(k1 + 2k2 + 2k3 + k4) = – 0.0860637
l =
1
6
(l1 + 2l2 + 2l3 + l4) = 0.0907823
∴ y1 = y(0.1) = y0 + k = 1 – 0.0860637 = 0.9139363
z1 = z(0.1) = z0 + k = – 1 + 0.0907823 = – 0.9092176
ASSIGNMENT 6.4
1. Use the Runge-Kutta Method to approximate y when x = 0.1 given that x = 0 when
y = 1 and
dy
dx
= x + y.
2. Apply the Runge-Kutta Fourth Order Method to solve 10
dy
dx
= x2 + y2; y (0) = 1 for
0  x ≤ 0. 4 and h = 0.1.
3. Use Runge-Kutta Fourth Order Formula to find y(1.4) if y (1) = 2 and
dy
dx
= xy. Take
h = 0.2.
4. Prove that the solution of y′ = y, y(0) = 1 by Second Order Runge-Kutta Method yields
ym = 1
2
2
+ +
F
HG
I
KJ
h
h
m
.
5. Solve y′ =
1
x y
+
, y(0) = 1 for x = 0.5 to x = 1 by Runge-Kutta Method (h = 0.5).
6. Solve y′ = – xy2 and By Runge-Kutta Fourth Order Method, find y(0.6) given that
y = 1.7231 at x = 0.4. Take h = 0.2.
524 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7. Use Runge-Kutta Method to find y when x = 1.2 in steps of 0.1 given that
dy
dx
= x2 + y2 and y(1) = 1.5
8. Given y′ = x2 – y, y (0) = 1 find y(0.1), y(0.2) using Runge-Kutta Methods of (i) Second
Order (ii) Fourth Order.
9. Using Runge-Kutta Method of Fourth Order, solve for y(0.1), y(0.2) and y(0.3),
given that y′ = xy + y2, y(0) = 1.
10. Using Runge-Kutta Method, find y(0.2) for the equation
dy
dx
y x
y x
=
−
+
, y (0) = 1. Take h = 0.2
11. (i) Using Runge-Kutta Method, find y(0.2) given that
dy
dx
= 3x +
1
2
y, y(0) = 1 taking h = 0.1.
(ii) Use the classical Runge-Kutta Formula of Fourth Order to find the numerical
solution at x = 0.8 for the differential equation
y′ = x y
+ , y (0.4) = 0.41
Assume the step length h = 0.2.
12. Solve
dy
dx
= x + z
dz
dx
= x – y2
for y(0.1), z(0.1) given that y(0) = 2, z(0) = 1 by Runge-Kutta Method.
13. Use classical Runge-Kutta Method of Fourth Order to find the numerical solution at
x = 1.4 for
dy
dx
= y2 + x2, y(1) = 0. Assume step size h = 0.2.
14. Explain Runge-Kutta Method with a suitable example. Write a program in C to
implement.
15. Write the main steps to be followed in using the Runge-Kutta Method of Fourth Order
to solve an ordinary differential equation of the First Order. Hence solve
dy
dx
= x3 + y3,
y(0) = 1 and step length h = 0.1 upto three iterations.
16. Given
dy
dx
= xy with y(1) = 5. Using the Fourth Order Runge-Kutta Method, find the
solution in the interval (1, 1.5) using step size h = 0.1.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 525
17. Using the Runge-Kutta Method of Fourth Order, solve the following differential equation:
dy
dx
y x
y x
=
−
+
2 2
2 2 with y (0) = 1 at x = 0.2, 0.4.
Also write computer program in ‘C’
18. Discuss the Fourth Order Runge-Kutta Method for solving differential equations.
Give program for the solution of differential equation using Fourth Order Runge-
Kutta Method. Use ‘C’ language.
6.21 PREDICTOR-CORRECTOR METHODS
In Runge-Kutta Methods, we need only the information at (xi, yi) to calculate
the value of yi + 1 and no attention is paid to the nature of the solution at the
earlier points.
To overcome this defect, Predictor-Corrector Methods are useful. The
technique of refining an initially crude predicted estimate of yi by means of a
more accurate corrector formula is called, Predictor-Corrector Method.
The modified Euler’s Method of solving the initial value problem,
y′ = f(x, y), y(x0) = y0 (26)
can be stated as
y1
p = y0 + hf(x0, y0) (27)
y1
c = y0 +
h
2
[f(x0, y0) + f(x1, y1
p)] (28)
Here we predict the value of y1 by Euler’s Method and use it in (28) to get a
corrected or improved value. This is a typical case of Predictor-Corrector Method.
In this section, we will obtain two important Predictor-Corrector Methods,
namely, Milne’s Simpson Method and Adams-Moulton (or Adams-Bash Fourth)
Method. Both of these methods are of IV order and the error is of order h5.
These methods make use of four starting values of y, namely, y0, y1, y2, and y3.
Hence, these methods are also called as Multi-Step Methods.
6.22 MILNE’S METHOD
Milne’s Method is a simple and reasonably accurate method of solving
differential equations numerically. To solve the differential equation y′ = f(x, y)
by this method, first we get the approximate value of yn + 1 by predictor formula
and then improve this value using a corrector formula. These formula are
derived from Newton’s Formula.
526 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Newton’s Forward Interpolation Formula in terms of y′ and u is
y′ = y0′ + uΔy0′ +
u u
( )
− 1
2
Δ2 y0′ +
u u u
( ) ( )
− −
1 2
6
Δ3 y0′
+
u u u u
( ) ( ) ( )
− − −
1 2 3
24
Δ4 y0′ + ....... (29)
where u =
x x
h
− 0
or x = x0 + uh
Now integrating (29) over the interval x0 to x0 + 4h (or u = 0 to 4), we get
′ = ′
+
z z
y dx h y du
x
x h
0
0 4
0
4
| ∵ dx = h du
or y4 – y0 = h
0
4
0 0
2
0
3
0
1
2
1 2
6
z ′ + ′ +
−
′ +
− −
′
L
NMy u y
u u
y
u u u
y
Δ Δ Δ
( ) ( ) ( )
+
u u u u
y du
( ) ( ) ( )
......
− − −
′ +
O
QP
1 2 3
24
4
0
Δ
= h 4 8
20
3
8
3
28
90
0 0
2
0
3
0
4
0
′ + ′ + ′ + ′ + ′
F
HG I
KJ
y y y y y
Δ Δ Δ Δ
| keeping up to IV differences
Here, y0 and y4 stand for values of y at x = x0 and x = x0 + 4h respectively.
Substituting the values of I, II and III differences, we get
y4 – y0 = h 4 8 1
20
3
1
8
3
1
28
90
0 0
2
0
3
0
4
0
′ + − ′ + − ′ + − ′ + ′
F
HG I
KJ
y y y y y
( ) ( ) ( )
E E E Δ (30)
=
4
3
h
(2y1′ – y2′ + 2y3′) +
28
90
hΔ4y0′
or y4 = y0 +
4
3
h
(2y1′ – y2′ + 2y3′) +
28
90
hΔ4 y0′ (31)
This is Milne’s Predictor (Extrapolation) formula.
It is used to predict the value of y4 when the value of y0, y1, y2, and y3 are
known.
To obtain the corrector formula, we integrate (29) over the interval x0 to
x0 + 2h (or u = 0 to 2) and consequently.
y2 – y0 = h 2 2
1
3
1
90
0 0
2
0
4
0
′ + ′ + ′ − ′
F
HG I
KJ
y y y y
Δ Δ Δ
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 527
Expressing the I, II and III differences in terms of the function value by
using D ≡ E – 1,
we obtain,
y2 – y0 =
h
3
(y0′ + 4y1′ + y2′) –
h
90
Δ4y0′
⇒ y2 = y0 +
h
3
(y0′ + 4y1′ + y2′) –
h
90
Δ4 y0′ (32)
This is Milne’s Corrector Formula.
The value of y4 obtained from (31) and (32) can be put as
yn + 1 = yn–3 +
4
3
h
(2y′n–2 – y′n–1 + 2yn′) (33)
y′n + 1 = yn–1 +
h
3
(y′n–1 + 4yn′ + y′n + 1) (34)
It is to be noted that we have considered the differences up to the third
order because we fit up a polynomial of degree four.
The terms containing Δ4y0′ are not used explicitly in the formula, but they
give the principal parts of the errors in the two values of yn + 1 as computed
from (33) and (34).
We notice that this error in (34) is of opposite sign to that in (33) but it is
very small in magnitude.
So we may take, (yn + 1)exact = yn + 1 +
28
90
hΔ4y′
and (yn + 1)exact = y(1)
n + 1 –
h
90
Δ4y′
where yn + 1 and y(1)
n + 1 denote the predicted and first corrected value of y
at x = xn + 1.
Equating these two values, we get
yn + 1 – y(1)
n +1 = –
29
90
hΔ4y′ = 29 δ
where δ = –
h
90
Δ4y′ denotes the principal part of the error in (34). Thus it gives
δ =
1
29
[yn + 1 – y(1)
n + 1 ]
Thus we observe that the error in (34) is
1
29
th of the difference between the
predicted and corrected values.
528 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.22.1 Algorithm of Milne’s Predictor-Corrector Method
1. Function F(x,y)=x+y
2. Input xn
3. For i=0,3
4. Input x(i),y(i)
5. Next i
6. h=x(1)-x(0)
7. n=(xn-x(0))/h
8. For i=3,n
9. x(i+1)=x(i)+h
10. f=F(x(i),y(i))
11. f1=F(x(i-1),y(i-1))
12. f2=F(x(i-2),y(i-2))
13. yp=y(i-3)+4h/3(2f2-f1+2f)
14. yc=y(i-1)+h/3(f1+4f+F(x(i+1),yp))
15. If abs (yp-yc)0.0005 then
y(i+1)=yc
print x(i+1), y(i+1)
ELSE
yp=yc
16. Next i
17. Stop
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 529
6.22.2 Flow-Chart of Milne’s Predictor Corrector Method
For i = 0, 3
START
F(x, y) = x + y
Input xn
Input x(i), y(i)
h = x(1) – x(0)
n = (xn – x(0)/h
STOP
For i = 3, n
x(i + 1) = x(i) + h
f = F(x(i), y(i))
f1 = F(x(i – 1), y(i – 1))
f2 = F(x(i – 2), y(i – 2))
yp = y(i – 3) + 4h/3 (2f2 – f1 + 2f)
yc = y(i – 1) + h/3 (f1 + 4f + F(x(i + 1), yp))
If
abs (yp – yc)  0.0005
Yes
y(i + 1) = yc
Print x(i + 1), y(i + 1)
No
yp = yc
530 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.22.3 Program of Milne’s Method
#includestdio.h
#includemath.h
#define F(x,y) x+y
main()
{
int i,n;
float x[20],y[20],h,f,f1,f2,yp,yc,xn;
printf(n Enter the value: xn: };
scanf{%f,xn);
printf(n Enter the value: x{i], y[i]:n};
for(i=0;i=3;i++)
scanf(%f%f,x[i],y[i]);
h=x[1]-x[0];
n=(xn-x[0]/h;
for(i=3;i=n;i++)
{
x[i+1]=x[i]+h;
f=F[x[i],y[i]);
f1=F(x[i-1],y[i-1]);
f2=F(x[i-2],y[i-2]);
yp=y[i-3]+4.0*h/3.0*(2.0*f2-f1+2.0*f);
yc=y[i-1]+h/3.0*(f1+4.0*f+F(x[i+1],yp));
printf(nnPredicated Y=%f Correctd Y=%f, yp,yc);
If(fabs (yp-yc)0.00005)
goto next;
yp=yc;
next;
y[i+1]=yc;
printf(nn X=%f Y=%f, x[i+1], y[i+1]);
}
return;
}
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 531
6.22.4 Output
Enter the value: xn: 1
Enter the value: x[i], y[i]:
0.0 0.0
0.2 0.02
0.4 0.0906
0.6 0.2214
Predicted Y=0.423147 Corrected Y=0.429650
X=0.800000 Y=0.429650
Predicted Y=0.721307 Corrected Y=0.718820
X=1.000000 Y=0.718820
Notations used in the Program
(i) xn is the last value of x at which value of y is required.
(ii) x(i) is an array for prior values of x.
(iii) y(i) is an array for prior values of y.
(iv) yp is the predicted value of y.
(v) yc is the corrected value of y.
EXAMPLES
Example 1. Tabulate by Milne’s Method the numerical solution of
dy
dx
= x + y
with initial conditions x0 = 0, y0 = 1 from x = 0.20 to x = 0.30.
Sol. To obtain the solution, we find three consecutive values of y and y′
corresponding to x = 0.05, 0.10 and 0.15, i.e., taking h = 0.05
x y y′ = dy/dx
0.00 1 1
0.05 1.0525 1.1025
0.10 1.1103 1.2103
0.15 1.1736 1.3236
(using y = 2ex – x – 1 (35) as explicit solution of given equations)
In general form, Milne’s Predictor and Corrector Formulae are
yn + 1 = yn – 3 +
4
3
h
(2y′n – 2 – y′n – 1 + 2yn′) (36)
532 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
and yn + 1
(1) = yn – 1 +
h
3
(y′n – 1 + 4yn′ + y′n + 1) (37)
Put n = 3, h = 0.05 in (36), we get
y4 = y0 +
4
3
h
(2y1′ – y2′ + 2y3′)
= 1 +
4 0 05
3
( . )
[2.205 – 1.2103 + 2.6472]
= 1.2428 (predicted value)
It is corrected by
y4
(1) = y2 +
h
3
(y2′ + 4y3′ + y4′)
= 1.1103 +
0 05
3
.
[1.2103 + 5.2944 + 1.4428] = 1.2428
which is the same as predicted value.
Put x = 0.20 and y = 1.2428 in
dy
dx
= x + y,
we get y4′ = 1.4428
Hence, y = 1.2428 when x = 0.20 and y′ = 1.4428
Now, put n = 4, h = 0.05 in (36), we get
y5 = y1 +
4
3
h
(2y2′ – y3′ + 2y4′)
= 1.0525 +
4 0 05
3
( . )
[2.4206 – 1.3236 + 2.8856]
= 1.3180
which is corrected by
y5
(1) = y3 +
h
3
(y3′ + 4y4′ + y5′)
= 1.1736 +
005
3
.
(1.3236 + 5.7712 + 1.568) = 1.3180
which is same as predicted value.
Thus, y5 = y0.25 = 1.3180 and y5′ = 1.5680
Again putting n = 5, h = 0.05, we get
y6 = 1.3997 which is corrected by
y6
(1) = 1.3997 = y0.30
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 533
The same as the predicted value.
y6 = 1.3997, y′6 = 1.6997 (y′ = x + y)
Collecting the results in Tabular form, we get
x y y′ = dy/dx
x4 = 0.20 y4 = 1.2428 y4′ = 1.4428
x5 = 0.25 y5 = 1.3180 y5′ = 1.5680
x6 = 0.30 y6 = 1.3997 y6′ = 1.6997
Example 2. Find y(2) if y(x) is the solution of
dy
dx
=
1
2
(x + y) where y(0) = 2,
y(0.5) = 2.636, y(1) = 3.595, y(1.5) = 4.968
Sol. Let x0 = 0, x1 = 0.5, x2 = 1, x3 = 1.5 then we are given y0, y1, y2, y3 and we
require y4 corresponding to x4 = 2.
By Predictor Formula, we get
y4 = y0 +
4
3
h
(2y1′ – y2′ + 2y3′) (38)
we have, y′ =
1
2
(x + y)
∴ y1′ =
1
2
(x1 + y1) = 1.568
Similarly y2′ = 2.2975, y3′ = 3.234
∴ from (38), y4 = 2 +
4 0 5
3
( . )
[3.136 – 2.2975 + 6.468] = 6.871
⇒ y4′ =
1
2
(x4 + y4) = 4.4355
This is corrected by
y4
(1) = y2 +
h
3
(y2′ + 4y3′ + y4′)
= 3.595 +
0 5
3
.
[2.2975 + 12.936 + 4.4355] = 6.87317
Now, (y4
(1))′ =
1
2
[x4 + y4
(1)] =
1
2
(2 + 6.87317) = 4.43659
534 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Again by the Corrector Formula, we get the second corrected value i.e.,
y2.00.
y4
(2) = y2 +
h
3
[y2′ + 4y3′ + (y4
(1))′]
= 3.595 +
0 5
3
.
[2.2975 + 12.936 + 4.43659] = 6.87335
Example 3. Using Milne’s Method, solve y′ = 1 + y2 with y(0) = 0, y(0.2) =
0.2027, y(0.4) = 0.4228, y(0.6) = 0.6841, obtain y(0.8) and y(1)
Sol. Let x0 = 0, x1 = 0.2, x2 = 0.4, x3 = 0.6. We are given y0, y1, y2, y3, and we
require y4 = y(0.8) and y5 = y(1.0). Here h = 0.2
We have, y′ = 1 + y2
∴ y1′ = 1 + y1
2 = 1 + (0.2027)2 = 1.0411
y2′ = 1 + y2
2 = 1 + (0.4228)2 = 1.1788
y3′ = 1 + y3
2 = 1 + (0.6841)2 = 1.4680
By Predictor Formula, we get
y4 = y0 +
4
3
h
(2y1′ – y2′ + 2y3′)
= 0 +
0 8
3
.
[2.0822 – 1.1788 + 2.936] = 1.0238
y4′ = 1 + y4
2 = 1 + (1.0238)2 = 2.0482
This is corrected by
y4
(1) = y2 +
h
3
(y2′ + 4y3′ + y4′)
= 0.4228 +
0 2
3
.
[1.1788 + 5.872 + 2.0482] = 1.0294
Now, [y4
(1)]′ = 1 + [y4
(1)]2 = 1 + (1.0294)2 = 2.0597
The second corrected value is,
y4
(2) = y2 +
h
3
[y2′ + 4y3′ + y4
(1) ′]
= 0.4228 +
0 2
3
.
[1.1788 + 5.872 + 2.0597] = 1.0302
Again, [y4
(2)]′ = 1 + [y4
(2)]2 = 1 + (1.0302)2 = 2.0613
Again, y4
(3) = 1.0303 = y4
(4)
hence, y4 = y(0.8) = 1.0303
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 535
Now, by Predictor Formula, also
y5 = y1 +
4
3
h
(2y2′ – y3′ + 2y4′)
= 0.2027 +
0.8
3
[2.3576 – 1.468 + 4.123] | y4′ = 1 + (1.0303)2
= 1.5394
y5′ = 1 + y5
2 = 3.3698
This is corrected by
y5′ = y3 +
h
3
( y3′ + 4y4′ + y5′)
= 0.6841 +
0 2
3
.
(1.468 + 8.246 + 3.3698) = 1.5564
Now, [y5
(1)]′ = 1 + (1.5564)2 = 3.4224
The second corrected value is
y5
(2) = 1.55999
Now, [y5
(2)]′ = 3.4333
Also, y5
(3) = 1.5606
Similarly y5
(4) = 1.5607 = y5
(5)
Hence, y5 = y(1.0) = 1.5607.
ASSIGNMENT 6.5
1. Apply Milne’s Method to solve the differential equation
dy
dx
= – xy2 at x = 0.8, given that
y(0) = 2, y(0.2) = 1.923, y(0.4) = 1.724, y(0.6) = 1.471
2. Solve 10
dy
dx
= x2 + y2, y(0) = 1 and compute y(0.4) and y(0.5) by Milne’s Method given
x: 0.1 0.2 0.3
y: 1.0101 1.0206 1.0317
3. Part of a numerical solution of the differential equation
dy
dx
= 0.2x + 0.1y
536 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
is shown in the following table:
x: 0 0.05 0.10 0.15
y: 2 2.0103 2.0212 2.0323
Use Milne’s Method to find the next entry in the table.
4. Given
dy
dx
=
1
2
(1 + x2) y2 and y(0) = 1, y(0.1) = 1.06, y(0.2) = 1.12, y(0.3) = 1.21, evaluate
y(0.4) by Milne’s Predictor-Corrector Method.
5. The differential equation
dy
dx
+
1
10
y2 = x satisfies the following pairs of values of x
and y:
x: – 0.2 – 0.1 0.0 0.1 0.2
y: 1.04068 1.01513 1 0.99507 1.00013
Compute the values of y when x = 0.3 by Milne’s Method.
6. Solve the differential equation
dy
dx
= y – x2
by Milne’s Method and compute y at x = 0.80 when:
x: 0 0.2 0.4 0.6
y: 1 1.12186 1.46820 1.73790
7. Solve y′ = – y with y(0) = 1 by the using Milne’s Method from x = 0.5 to x = 0.8 with
h = 0.1. Given:
x: 0.1 0.2 0.3 0.4
y: 0.9048 0.8188 0.7408 0.6705
8. Given:
dy
dx
= 2 – xy2 and y(0) = 1. Show that by Milne’s Method, y(1) = 1.6505 taking
h = 0.2. You may use Picard’s Method to obtain the values of y(0.2), y(0.4), y(0.6).
9. Solve the initial value problem
dy
dx
= 1 + xy2, y(0) = 1 for x = 0.4, 0.5 by using Milne’s
Method. It is given that,
x: 0.1 0.2 0.3
y: 1.105 1.223 1.355
10. Derive Milne’s Predictor Formula and find the solution of the equation.
dy
dx
= x – y2 for y(0.8) and y(1), given the starting values.
x: 0 0.2 0.4 0.6
y: 0 0.02 0.0795 0.1762
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 537
11. Given: y(0) = 2, y(0.2) = 2.0933, y(0.4) = 2.1755, y(0.6) = 2.2493, find y(0.8) and y(1.0) by
solving
dy
dx
=
1
x y
+
by Milne’s Method.
12. Solve numerically
dy
dx
= 2ex – y at x = 0.4 and 0.5 by Milne’s Method given:
x: 0 0.1 0.2 0.3
y: 2 2.010 2.040 2.090
13. Given
dy
dx
= – xy with y(0) = 1. Solve the equation in the interval (0, 1) using step size = 0.5
using Predictor-Corrector Method. Give algorithm of Predictor-Corrector Method.
14. Apply Predictor-Corrector Method on a differential equation
dx
dt
= f (t, x).
Let x = x(t)
The method is of order IV with step-size h is x(t + h) = x(t) +
1
6
(k1 + 2k2 + 2k3 + k4)
where, k1 = h f (t, x)
k2 = h f t
h
x
k
+ +
F
HG I
KJ
2 2
1
,
k3 = h f t
h
x
k
+ +
F
HG I
KJ
2 2
2
,
k4 = h f (t + h, x + k3)
Use this method with h = 0.1 to find x(0.1) and x(0.2) where
dx
dt
= t – x and x(0) = 0.
15. Discuss Predictor-Corrector Method for solving differential equation. Illustrate method
using figure. Give program of Predictor-Corrector Method in ‘C’ language.
6.23 ADAMS–MOULTON (OR ADAMS–BASHFORTH) FORMULA
Consider the initial value problem
dy
dx
= f (x, y) with y(x0) = y0 (39)
We compute y–1 = y(x0 – h), y–2 = y (x0 – 2h), y– 3 = y(x0 – 3h),......
538 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now integrating (39) on both sides with respect to x in [x0, x0 + h], we get
y1 = y0 +
x
x h
f x y dx
0
0 +
z ( , ) (40)
Replacing f (x, y) by Newton’s Backward Interpolation Formula, we get
y1 = y0 + h
0
1
0 0
2
0
3
0
1
2
1 2
6
z + ∇ +
+
∇ +
+ +
∇ +
R
S
T
U
V
W
f u f
u u
f
u u u
f
( ) ( ) ( )
... du
∵ x x hu
dx h du
u
= +
∴ =
0
0 1
Limits of are from to
= y0 + h f f f f
0 0
2
0
3
0
1
2
5
12
3
8
+ ∇ + ∇ + ∇ +
F
HG I
KJ
... (41)
Neglecting the fourth order and higher order differences and using
∇ f0 = f0 – f–1
∇2 f0 = f0 – 2f–1 + f–2
∇3 f0 = f0 – 3f–1 + 3f–2 – f–3 in (41), we get after simplification,
y1 = y0 +
h
24
(55f0 – 59f –1 + 37f–2 – 9f–3)
which is known as Adams–Bashforth or Adams–Moulton–Predictor
Formula and is denoted generally as
yp
n + 1 = yn +
h
24
(55fn – 59fn –1 + 37fn –2 – 9fn –3)
or yp
n + 1 = y0 +
h
24
(55yn′ – 59y′n –1 + 37y′n –2 – 9y′n –3)
Having found y1, we find f1 = f (x0 + h, y1)
To find a better value of y1, we derive a corrector formula by substituting
Newton’s Backward Interpolation Formula at f1 in place of f (x, y) in (40) i.e.,
y1 = y0 +
x
x h
f u f
u u
f
u u u
f
0
0
1 1
2
1
3
1
1
2
1 2
6
+
z + ∇ +
+
∇ +
+ +
∇ +
L
NM O
QP
( ) ( ) ( )
... dx
= y0 + h
−
z + ∇ +
+
∇ +
+ +
F
HG
I
KJ ∇ +
L
N
MM
O
Q
PP
1
0
1 1
2
2
1
3 2
3
1
2
3 2
6
f u f
u u
f
u u u
f
( )
... du
∵x x hu
dx h du
= +
∴ =
1
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 539
= y0 + h f f f f
1 1
2
1
3
1
1
2
1
12
1
24
− ∇ − ∇ − ∇ −
F
HG I
KJ
... (42)
Neglecting the fourth order and higher order differences and using
∇ f1 = f1 – f0, ∇2f1 = f1 – 2f0 + f–1,∇3f1 = f1 – 3f0 + 3f–1 – f–2 in (42), we get
y1 = y0 +
h
24
(9f1 + 19f0 – 5f–1 + f–2)
which is known as Adams–Bashforth or Adams–Moulton Corrector
Formula and is denoted generally as
yc
n + 1 = yn +
h
24
(9fn + 1 – 19fn – 5fn –1 + fn –2)
or yc
n + 1 = yn +
h
24
(9y′n + 1 – 19yn′ – 5y′n –1 + y′n –2)
EXAMPLES
Example 1. Using Adam’s–Moulton–Bashforth Method to find y (1.4) given:
dy
dx
= x2 (1 + y), y(1) = 1, y(1.1) = 1.233, y(1.2) = 1.548 and y(1.3) = 1.979.
Sol. Here, y′ = x2 (1 + y), h = 0.1
x0 = 1, x1 = 1.1, x2 = 1.2, x3 = 1.3
y0 = 1, y1 = 1.233, y2 = 1.548, y3 = 1.979
Now, Adams–Bashforth Predictor Formula is
y4
p = y3 +
h
24
(55y3′ – 59y2′ + 37y1′ – 9y0′) (43)
y1′ = x1
2 (1 + y1) = 2.70193
y2′ = x2
2 (1 + y2) = 3.66912
y3′ = x3
2 (1 + y3) = 5.03451
∴ from (43),
y4
p = 1.979 +
01
24
.
F
HG I
KJ [55(5.03451) – 59(3.66912)
+ 37(2.70193) – 9(2)]
= 2.5722974
Now, (y4′)p = x4
2 (1 + y4
p) = (1.4)2 (1 + 2.5722974)
= 7.0017029
540 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Now, the Corrector Formula is
y4
c = y3 +
h
24
(9y4′p + 19y3′ – 5y2′ + y1′)
= 1.979 +
0 1
24
.
F
HG I
KJ [9(7.0017029) + 19(5.03451)
– 5(3.66912) + 2.70193]
= 2.5749473
∴ y(0.4) = 2.5749
Example 2. Find y(0.1), y(0.2), y(0.3) from
dy
dx
= x2 – y; y(0) = 1
by using Taylor’s Series Method and hence obtain y(0.4) using Adams–Bashforth
Method.
Sol. We have, y′ = x2 – y, y(0) = 1
By Taylor’s Series Method, we have
y(0.1) = 0.905125
y(0.2) = 0.8212352
y(0.3) = 0.7491509
Hence, x0 = 0, x1 = 0.1, x2 = 0.2, x3 = 0.3
y0 = 1, y1 = 0.905125, y2 = 0.8212352, y3 = 0.7491509
Also, y0′ = – 1, y1′ = – 0.895125, y2′ = – 0.7812352
and y3′ = – 0.6591509
Now, Adams–Bashforth Predictor Formula is
y4
p = y3 +
h
24
(55y3′ – 59y2′ + 37y1′ – 9y0′)
= 0.7491509 +
01
24
.
F
HG I
KJ [55(– 0.6591509) – 59(– 0.7812352)
+ 37(– 0.895125) – 9(– 1)]
= 0.6896507
Now, y4′p = x4
2 – y4
p = (0.4)2 – 0.6896507 = – 0.5296507
The Corrector Formula is
y4
c = y3 +
h
24
(9y4′p + 19y3′ – 5y2′ + y1′)
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 541
= 0.7491509 +
01
24
.
F
HG I
KJ [9(– 0.5296507)
+ 19(– 0.6591509) – 5(– 0.7812352) + (– 0.895125)]
= 0.6896522
∴ y(0.4) = 0.6896522
ASSIGNMENT 6.6
1. Using Adams–Bashforth Formula, find y(0.4) and y(0.5) if y satisfies the differential
equation
dy
dx
= 3ex + 2y with y(0) = 0.
Compute y at x = 0.1, 0.2, 0.3 by means of Runge-Kutta Method.
2. Determine y(0.4) given the equation
dy
dx
=
1
2
xy using Adams–Moulton Method, given
that
y(0) = 1, y(0.1) = 1.0025, y(0.2) = 1.0101, y(0.3) = 1.0228.
3. Using Adams–Bashforth Predictor–Corrector Method, find y(1.4) given that
x2y′ + xy = 1; y(1) = 1, y(1.1) = 0.996, y(1.2) = 0.986, y(1.3) = 0.972
4. Compute y(1) by Adam’s Method given
y′ = x2 – y3 , y(0) = 1, y(0.25) = 0.821028, y(0.5)
= 0.741168, y(0.75) = 0.741043.
5. Given y′ = 2y – 1, y(0) = 1. Compute y for x = 0.1, 0.2, 0.3 by the IV order Runge-Kutta
Method and y(0.4) by Adam’s Method.
6.24 STABILITY
A numerical method for solving a mathematical problem is considered stable if
the sensitivity of the numerical answer to the data is no greater than in the
original mathematical problem. Stable problems are also called well-posed
problems.
If a problem is not stable, it is called unstable or ill-posed.
A problem f(x, y) = 0 is said to be stable if the solution y depends in a
continuous way on the variable x.
542 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
6.25 STABILITY IN THE SOLUTION OF ORDINARY DIFFERENTIAL
EQUATIONS
The idea of stability may be defined as
(i) A computation is stable if it does not blow up.
(ii) Stability is a boundedness of the relative error.
Two types of stability considerations enter in the solution of ordinary
differential equations.
(a) Inherent stability
(b) Numerical stability
Inherent stability is determined by the mathematical formulations of the
problem and is dependent on the Eigen values of Jacobean Matrix of the
differential equation.
Numerical stability is a function of the error propagation in the numerical
method. Three types of errors occur in the application of numerical integration
methods:
(a) Truncation error (b) Round-off error (c) Propagation error.
6.26 STABILITY OF I ORDER LINEAR DIFFERENTIAL EQUATION OF
FORM
dy
dx
= Ay WITH INITIAL CONDITION y(x0) = y0
The solution of this equation is
y(x) = y(x0) e A(x– x0)
Let, yn = y(xn) + εn at xn = x0 + nh
εn being the total truncation error.
Let E(Ah) be the polynomial approximation to e–Ah (for small Ah). Then the
computed result of one step length is
yn + 1 = E(Ah) yn
while the correct solution is
y(xn + 1) = eAh y(xn)
Thus, yn + 1 – y(xn + 1) = E(Ah) yn – eAh y(xn)
= E(Ah) [y(xn) + En] – eAh y(xn)
= [E(Ah) – eAh] y(xn) + E(Ah) εn
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 543
Clearly, the error εn will be amplified if E(Ah)  1 which is possible
for sufficiently large Ah at xn + k = x0 + (n + k) h. It will have grown by
factor Ek(Ah). Thus meaningful results can be obtained only for E(Ah)  1. If
| E(Ah) |  eAh then we say that the method is relatively stable for that value
of Ah.
EXAMPLES
Example 1. How many terms are to be retained if we want to have an accuracy
of 10–10 in solving y′ = x + y, y(0) = 1, x∈(0, 1) by Taylor’s series method?
Sol. y′ = x + y
⇒ y′′ = 1 + y′, y′′′ = y′′, ..., and so on
⇒ y(p + 1) = y(p), p = 2, 3...
∴ y′(0) = 1, y′′(0) = 2,..., y(p)(0) = 2
Hence, y(x) = 1 + x + x2 + ... +
2
p!
xp + ...
In order to obtain results, which will be accurate up to 10–10 for x ≤ 1,
we have
1
1
( )!
p +
 5 × 10–10
⇒ p ≈ 15
Hence about 15 terms are required to obtain the accuracy of 10–10 for solving
dy
dx
= x + y by Taylor’s Series Method when x ≤ 1.
Example 2. Discuss the stability of Euler’s Method for solving the differential
equation.
dy
dx
= λy
Sol.
dy
dx
= λy = f (x, y)
True solution is y(x) = ceλx so that
y(xn + 1) = y(xn)eλh, h = xn + 1 – xn
Approximate solution using Euler’s Method is
yn + 1 = yn + h f(xn, yn) = yn + h λ yn
= (1 + hλ) yn
544 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Let yn = y(xn) + εn
where εn is the total solution error.
⇒ yn + 1 = y(xn + 1) + εn + 1 = (1 + hλ) yn
= (1 + hλ) [y(xn) + εn]
Therefore,
yn + 1 – y(xn + 1) = (1 + λh) y(xn) + (1 + λh) εn – y(xn) eλh
⇒ εn + 1 = (1 + λh – eλh) y(xn) + (1 + λh) εn
The first term on R.H.S. is the total truncation error while the second term
is the contribution to the error from the previous step (inherited error).
Hence, we have E(λh) = 1 + λh
where E(λh) is a polynomial approximation to eλh for small λh.
Obviously, Euler’s Method is absolutely stable if | 1 + λh |  1 or – 2
 λh  0; relatively stable if λh is greater than the solution of λh = – 1 – e–λh.
P a r t 5
n Statistical Computation
Frequency Charts, Curve Fitting, Principle of Least Squares, Fitting
a Straight Line, Exponential Curves etc., Data Fitting with Cubic
Splines, Regression Analysis, Linear Regression, Polynomial Fit:
Non-linear Regression, Multiple Linear Regression, Statistical Quality
Control.
n Testing of Hypothesis
Population or Universe, Sampling, Parameters of Statistics, Test of
Significance, t-Test, F-Test, Chi-square (χ2) Test.
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
7.1 THE STATISTICAL METHODS
S
tatistical methods are devices by which complex and numerical data are
so systematically treated as to present a comprehensible and intelligible
view of them. In other words, the statistical method is a technique used
to obtain, analyze and present numerical data.
7.2 LIMITATION OF STATISTICAL METHODS
There are certain limitations to the Statistics and Statistical Methods.
1. Statistical laws are not exact laws like mathematical or chemical laws.
They are derived by taking a majority of cases and are not true for
every individual. Thus, the statistical inferences are uncertain.
2. Statistical technique applies only to data reducible to quantitative forms.
3. Statistical technique is the same for the social as for physical sciences.
4. Statistical results might lead to fallacious conclusions if they are quoted
short of their context.
Chapter 7 STATISTICAL COMPUTATION
547
548 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.3 FREQUENCY CHARTS
7.3.1 Variable
A quantity which can vary from one individual to another is called a variable.
It is also called a variate. Wages, barometer readings, rainfall records, heights,
and weights are the common examples of variables.
Quantities which can take any numerical value within a certain range are
called continuous variables. For example, the height of a child at various
ages is a continuous variable since, as the child grows from 120 cm to 150 cm,
his height assumes all possible values within the limit.
Quantities which are incapable of taking all possible values are called
discontinuous or discrete variables. For example, the number of rooms in
a house can take only the integral values such as 2, 3, 4, etc.
7.3.2 Frequency Distributions
The scores of 50 students in mathematics are arranged below according to
their roll numbers, the maximum scores being 100.
19, 70, 75, 15, 0, 23, 59, 56, 27, 89, 91, 22, 21, 22, 50, 89, 56, 73, 56, 89, 75,
65, 85, 22, 3, 12, 41, 87, 82, 72, 50, 22, 87, 50, 89, 28, 89, 50, 40, 36, 40, 30,
28, 87, 81, 90, 22, 15, 30, 35.
The data given in the crude form (or raw form) is called ungrouped data.
If the data is arranged in ascending or descending order of magnitude, it is
said to be arranged in an array. Let us now arrange it in the intervals 0–10,
10–20, 20–30, 30–40, 40–50, 50–60, 60–70, 70–80, 80–90, 90–100. This is
arranged by a method called the tally method.
In this we consider every observation and put it in the suitable class by
drawing a vertical line. After every 4 vertical lines, we cross it for the 5th entry
and then a little space is left and the next vertical line is drawn.
STATISTICAL COMPUTATION 549
Scores Number of Students Frequency Cumulative
(Class-interval) (f ) Frequencies
0—10 | | 2 2
10—20 | | | | 4 6
20—30 | | | | | | | | 10 16
30—40 | | | | 4 20
40—50 | | | 3 23
50—60 | | | | | | | 8 31
60—70 | 1 32
70—80 | | | | 5 37
80—90 | | | | | | | | | 11 48
90—100 | | 2 50
Total Σf = 50
This type of representation is called a grouped frequency distribution
or simply a frequency distribution. The groups are called the classes and
the boundary ends 0, 10, 20, ...... etc. are called class limits. In the class limits
10—20, 10 is the lower limit and 20 is the upper limit. The difference between
the upper and lower limits of a class is called its magnitude or class-interval.
The number of observations falling within a particular class is called its
frequency or class frequency. The frequency of the class 80—90 is 11. The
variate value which lies mid-way between the upper and lower limits is called
mid-value or mid-point of that class. The mid-points of these are respectively
5, 15, 25, 35, ...... The cumulative frequency corresponding to a class is the
total of all the frequencies up to and including that class. Thus the cumulative
frequency of the class 10—20 is 2 + 4, i.e., 6 the cumulative frequency of the
class 20—50 is 6 + 10, i.e., 16, and so on.
While preparing the frequency distribution the following points must be
remembered:
1. The class-intervals should be of equal width as far as possible A
comparison of different distributions is facilitated if the class interval
is used for all. The class-interval should be an integer as far as possible.
2. The number of classes should never be fewer than 6 and not more than
30. With a smaller number of classes, the accuracy may be lost, and
with a larger number of classes, the computations become tedious.
3. The observation corresponding to the common point of two classes
should always be put in the higher class. For example, a number
corresponding to the value 30 is to be put up in the class 30—40 and
not in 20—30.
550 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The following forms of the above table may also be used:
Cumulative Frequency
Scores Number of Students Scores Number of Students
Under 10 2 above 90 2
Under 20 6 above 80 13
Under 30 16 above 70 18
Under 40 20 above 60 19
Under 50 23 above 50 27
Under 60 31 above 40 30
Under 70 32 above 30 34
Under 80 37 above 20 44
Under 90 48 above 10 48
Under 100 50 above 0 50
7.4 GRAPHICAL REPRESENTATION OF A FREQUENCY DISTRIBU-
TION
Representation of frequency distribution by means of a diagram makes the
unwieldy data intelligible and conveys to the eye the general run of the
observations. The graphs and diagrams have a more lasting effect on the brain.
It is always easier to compare data through graphs and diagrams. Forecasting
also becomes easier with the help of graphs. Graphs help us in interpolation of
values of the variables.
However there are certain disadvantages as well. Graphs do not give
measurements of the variables as accurate as those given by tables. The
numerical value can be obtained to any number of decimal places in a table,
but from graphs it can not be found to 2nd or 3rd places of decimals. Another
disadvantage is that it is very difficult to have a proper selection of scale. The
facts may be misrepresented by differences in scale.
7.5 TYPES OF GRAPHS AND DIAGRAMS
Generally the following types of graphs are used in representing frequency
distributions:
(1) Histograms, (2) Frequency Polygon, (3) Frequency Curve, (4) Cumulative
Frequency Curve or the Ogive, (5) Historigrams, (6) Bar Diagrams, (7) Area
STATISTICAL COMPUTATION 551
Diagrams, (8) Circles or Pie Diagrams, (9) Prisms, (10) Cartograms and Map
Diagrams, (11) Pictograms.
7.6 HISTOGRAMS
To draw the histograms of a given grouped frequency distribution, mark off
along a horizontal base line all the class-intervals on a suitable scale. With the
class-intervals as bases, draw rectangles with the areas proportional to the
frequencies of the respective class-intervals. For equal class-intervals, the
heights of the rectangles will be proportional to the frequencies. If the class-
intervals are not equal, the heights of the rectangles will be proportional to the
ratios of the frequencies to the width of the corresponding classes. A diagram
with all these rectangles is a Histogram.
1
2
3
4
5
6
7
8
9
10
11
0 10 20 30 40 50 60 70 80 90 100 X
Y
Scores
Frequencies
(Histogram for the previous table)
Histograms are also useful when the class-intervals are not of the same
width. They are appropriate to cases in which the frequency changes rapidly.
552 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.7 FREQUENCY POLYGON
If the various points are obtained by plotting the central values of the class
intervals as x co-ordinates and the respective frequencies as the y co-ordinates,
and these points are joined by straight lines taken in order, they form a polygon
called Frequency Polygon.
1
2
3
4
5
6
7
8
9
10
11
0 10 20 30 40 50 60 70 80 90 100 X
Y
Scores
Frequencies
(Frequency Polygon)
In a frequency polygon the variables or individuals of each class are assumed
to be concentrated at the mid-point of the class-interval.
Here in this diagram dotted is the Histogram and a polygon with lines as
sides is the Frequency Polygon.
7.8 FREQUENCY CURVE
If through the vertices of a frequency polygon a smooth freehand curve is drawn,
we get the Frequency Curve. This is done usually when the class-intervals
are of small widths.
STATISTICAL COMPUTATION 553
7.9 CUMULATIVE FREQUENCY CURVE OR THE OGIVE
If from a cumulative frequency table, the upper limits of the class taken as x
co-ordinates and the cumulative frequencies as the y co-ordinates and the points
are plotted, then these points when joined by a freehand smooth curve give the
Cumulative Frequency Curve or the Ogive.
10 20 30 40 50 60 70 80 90 100
0
10
20
30
40
50
Scores
Cumulative
frequencies
X
Y
Ogive
7.10 TYPES OF FREQUENCY CURVES
Following are some important types of frequency curves, generally obtained in
the graphical representations of frequency distributions:
1. Symmetrical curve or bell shaped curve.
2. Moderately asymmetrical or skewed curve.
3. Extremely asymmetrical or J-shaped curve or reverse J-shaped.
4. U-shaped curve.
5. A bimodal frequency curve.
6. A multimodal frequency curve.
1. Symmetrical curve or Bell shaped curve. If a curve can be folded
symmetrically along a vertical line, it is called a symmetrical curve. In
this type the class frequencies decrease to zero symmetrically on either
side of a central maximum, i.e., the observations equidistant from the
central maximum have the same frequency.
554 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(Bell shaped curve) (Skewed curve)
2. Moderately asymmetrical or skewed curve. If there is no symmetry
in the curve, it is called a Skew Curve. In this case the class frequencies
decrease with greater rapidity on one side of the maximum than on the
other. In this curve one tail is always longer than the other. If the long
tail is to the to be a positive side, it is said to be a positive skew curve,
if long tail is to the negative side, it is said to be a negative skew curve.
3. Extremely asymmetrical or J-shaped curve. When the class
frequencies run up to a maximum at one end of the range, they form a
J-shaped curve.
J-shaped curve Reversed J-shaped curve U-shaped curve
4. U-shaped curve. In this curve, the maximum frequency is at the ends
of the range and a maximum towards the center.
5. A Bimodal curve has two maxima.
Bimodal curve Multimodal curve
6. A multimodal curve has more than two maxima.
STATISTICAL COMPUTATION 555
7.11 DIAGRAMS
1. Bar diagrams. Bar diagrams are used to compare the simple
magnitude of different items. In bar diagrams, equal bases on a
horizontal or vertical line are selected and rectangles are constructed
with the length proportional to the given data. The width of bars is an
arbitrary factor. The distance between two bars should be taken at
about one-half of the width of a bar.
2. Area diagrams. When the difference between two quantities to be
compared is large, bars do not show the comparison so clearly. In such
cases, squares or circle are used.
3. Circle or Pie-diagrams. When circles are drawn to represent an area
equivalent to the figures, they are said to form pie-diagrams or circles-
diagrams. In case of circles, the square roots of magnitudes are
proportional to the radii.
4. Subdivided Pie-diagram. Subdivided Pie-diagrams are used when
comparison of the component parts is done with another and the total.
The total value is equated to 360° and then the angles corresponding to
the component parts are calculated.
5. Prisms and Cubes. When the ratio between the two quantities to be
compared is very great so that even area diagrams are not suitable, the
data can be represented by spheres, prisms, or cubes. Cubes are in
common use. Cubes are constructed on sides which are taken in the
ratio of cube roots of the given quantities.
6. Cartograms or map diagrams. Cartograms or map diagrams are
most suitable for geographical data. Rainfalls and temperature in
different parts of the country are shown with dots or shades in a
particular map.
7. Pictograms. When numerical data are represented by pictures,
they give a more attractive representation. Such pictures are called
pictograms.
556 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.12 CURVE FITTING
Let there be two variables x and y which give us a set of n pairs of numerical
values (x1, y1), (x2, y2).......(xn, yn). In order to have an approximate idea about
the relationship of these two variables, we plot these n paired points on a graph,
thus we get a diagram showing the simultaneous variation in values of both
the variables called scatter or dot diagram. From scatter diagram, we get only
an approximate non-mathematical relation between two variables. Curve fitting
means an exact relationship between two variables by algebraic equations.
In fact, this relationship is the equation of the curve. Therefore, curve fitting
means to form an equation of the curve from the given data. Curve fitting is
considered of immense importance both from the point of view of theoretical
and practical statistics.
Theoretically, curve fitting is useful in the study of correlation and
regression. Practically, it enables us to represent the relationship between two
variables by simple algebraic expressions, for example, polynomials,
exponential, or logarithmic functions.
Curve fitting is also used to estimate the values of one variable
corresponding to the specified values of the other variable.
The constants occurring in the equation of an approximate curve can be
found by the following methods:
(i) Graphical method
(ii) Method of group averages
(iii) Principle of least squares
(iv) Method of moments.
Out of the above four methods, we will only discuss and study here the
principle of least squares.
7.13 PRINCIPLE OF LEAST SQUARES
Principle of least squares provides a unique set of values to the constants and
hence suggests a curve of best fit to the given data.
Suppose we have m-paired observations (x1, y1), (x2, y2), ......, (xm, ym) of two
variables x and y. It is required to fit a polynomial of degree n of the type
y = a + bx + cx2 + ...... + kxn (1)
of these values. We have to determine the constants a, b, c, ..., k such that they
represent the curve of best fit of that degree.
In case m = n, we get in general a unique set of values satisfying the given
system of equations.
STATISTICAL COMPUTATION 557
But if m  n, then we get m equations by putting different values of x and
y in equation (1) and we want to find only the values of n constants. Thus there
may be no such solution to satisfy all m equations.
Therefore we try to find out those values of a, b, c, ......, k which satisfy all
the equations as nearly as possible. We apply the principle of least squares in
such cases.
Putting x1, x2, ..., xm for x in (1), we get
y1′ = a + bx1 + cx1
2 + ...... + kx1
n
y2′ = a + bx2 + cx2
2 + ...... + kx2
n
 
ym′ = a + bxm + cxm
2 + ...... + kxm
n
where y1′, y2′, ......, ym′ are the expected values of y for x= x1, x2, ......., xm respectively.
The values y1, y2, ......, ym are called observed values of y corresponding to
x = x1, x2, ......, xm respectively.
The expected values are different from the observed values, the difference
yr – yr′ for different values of r are called residuals.
Introduce a new quantity U such that
U = Σ(yr – yr′)2 = Σ(yr – a – bxr – cxr
2 – ..... – kxr
n)2
The constants a, b, c, ......, k are choosen in such a way that the sum of the
squares of the residuals is minimum.
Now the condition for U to be maximum or minimum is
∂
∂
U
a
= 0 =
∂
∂
∂
∂
U U
b c
=
= ...... =
∂
∂
U
k
. On simplifying these relations, we get
Σy = ma + bΣx + ..... + kΣxn
Σxy = aΣx + bΣx2 + ....... + k Σxn+1
Σx2y = aΣx2 + bΣx3 + ....... + k Σxn+2
 
Σxny = aΣxn + bΣxn+1 + ....... + k Σx2n
These are known as Normal equations and can be solved as simultaneous
equations to give the values of the constants a, b, c, ......., k. These equations
are (n + 1) in number.
If we calculate the second order partial derivatives and these values are
given, they give a positive value of the function, so U is minimum.
558 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
This method does not help us to choose the degree of the curve to be fitted
but helps us is finding the values of the constants when the form of the curve
has already been chosen.
7.14 FITTING A STRAIGHT LINE
Let (xi, yi), i = 1, 2, ......, n be n sets of observations of related data and
y = a + bx (2)
be the straight line to be fitted. The residual at x = xi is
Ei = yi – f(xi) = yi – a – bxi
Introduce a new quantity U such that
U =
i
n
i
i
n
i i
y a bx
= =
∑ ∑
= − −
1
2
1
2
E ( )
By the principle of Least squares, U is minimum
∴
∂
∂
U
a
= 0 and
∂
∂
U
b
= 0
∴ 2 1 0
1
i
n
i i
y a bx
=
∑ − − − =
( )( ) or Σy = na + bΣx (3)
and 2 0
1
i
n
i i i
y a bx x
=
∑ − − − =
( )( ) or Σxy = aΣx + bΣx2 (4)
Since xi, yi are known, equations (3) and (4) result in a and b. Solving these,
the best values for a and b can be known, and hence equation (2).
In case of change of origin,
if n is odd then, u =
x (middle term)
interval (h)
−
but if n is even then u =
x (mean of two middle terms)
1
2
(interval)
−
.
NOTE
STATISTICAL COMPUTATION 559
7.15 ALGORITHM FOR FITTING A STRAIGHT LINE OF THE FORM
y = a + bx FOR A GIVEN SET OF DATA POINTS
Step 01. Start of the program.
Step 02. Input no. of terms observ
Step 03. Input the array ax
Step 04. Input the array ay
Step 05. for i=0 to observ
Step 06. sum1+=x[i]
Step 07. sum2+=y[i]
Step 08. xy[i]=x[i]*y[i];
Step 09. sum3+=xy[i]
Step 10. End Loop i
Step 11. for i = 0 to observ
Step 12. x2[i]=x[i]*x[i]
Step 13. sum4+=x2[i]
Step 14. End of Loop i
Step 15. temp1=(sum2*sum4)-(sum3*sum1)
Step 16. a=temp1/((observ *sum4)-(sum1*sum1))
Step 17. b=(sum2-observ*a)/sum1
Step 18. Print output a,b
Step 19. Print “line is: y = a+bx”
Step 20. End of Program
560 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.16 FLOW-CHART FOR FITTING A STRAIGHT LINE y = a + bx FOR A
GIVEN SET OF DATA POINTS
START
Input number of observations
Input array ax and ay
Loop for i = 0 to observ
Sum 1 + = x[i]
Sum 2 + = y[i]
xy[i] = x[i]*y[i]
Sum 3 + = xy[i]
End loop i
Loop for i = 0 to observ
x2[i] = x[i]*x[i]
Sum 4 + = x2[i]
End loop i
STOP
Print ‘‘output’’
a = ((Sum 2* Sum4) – (Sum 3* Sum1))/
((observ* sum4) – (sum 1* sum1))
b = ((sum 2 – observ* a)/sum1)
STATISTICAL COMPUTATION 561
/* **********************************************************
7.17 PROGRAM TO IMPLEMENT CURVE FITTING TO FIT A
STRAIGHT LINE
********************************************************** */
//... HEADER FILE DECLARATION
# include stdio.h
# include conio.h
# include math.h
//... Main Execution Thread
void main()
{
//... Variable Declaration Field
//... Integer Type
int i=0;
int observ;
//... Floating Type
float x[10];
float y[10];
float xy[10];
float x2[10];
float sum1=0.0;
float sum2=0.0;
float sum3=0.0;
float sum4=0.0;
//... Double Type
double a;
double b;
//... Invoke Function Clear Screen
clrscr ();
//... Input Section
//... Input Number of Observations
printf(“nn Enter the number of observations - ”);
scanf(“%d” ,observ);
562 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
//... Input Sequel For Array X
printf(“nnn Enter the values of x – n);
for (;iobserv;i++)
{
printf(nn Enter the Value of x%d: ,i+1);
scanf(“%f” ,x[i]);
sum1 +=x[i];
}
//... Input Sequel For Array Y
printf(“nn Enter the values of y - n”);
for(i=0;iobserv;i++)
{
printf(nn Enter the value of y%d:,i+1);
scanf(%f,y[i]);
sum2+=y[i];
}
//... Processing and Calculation Section
for(i=0;iobserv;i++)
{
xy[i]=x[i]*y[i];
sum3 +=xy[i];
}
for(i=0;iobserv; i++)
{
x2[i]=x[i]*x[i];
sum4+ =x2[i];
}
a=(sum2*sum4–sum3*sum1)/(observ*sum4–sum1*sum1);
b=(sum2–observ*a)/sum1;
//... Output Section
printf(“nnnn Equation of the STRAIGHT LINE);
printf(of the form y = a + b*x is:);
printf(“nnn ttt Y = %.2f + (%.2f) X, a,b);
//... Invoke User Watch Halt Function
STATISTICAL COMPUTATION 563
printf(nnn Press Enter to Exit);
getch();
}
//... Termination of Main Execution Thread
EXAMPLES
Example 1. By the method of least squares, find the straight line that best fits
the following data:
x: 1 2 3 4 5
y: 14 27 40 55 68.
Sol. Let the straight line of best fit be
y = a + bx (5)
Normal equations are Σy = ma + bΣx (6)
and Σxy = aΣx + bΣx2 (7)
Here m = 5
The table is as below:
x y xy x2
1 14 14 1
2 27 54 4
3 40 120 9
4 55 220 16
5 68 340 25
Σx = 15 Σy = 204 Σxy = 748 Σx2 = 55
Substituting in (6) and (7), we get
204 = 5a + 15b
748 = 15a + 55b
Solving, we get a = 0, b = 13.6
Hence required straight line is y = 13.6x
Example 2. Fit a straight line to the following data:
x: 0 1 2 3 4
y: 1 1.8 3.3 4.5 6.3.
564 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Let the straight line obtained from the given data be y = a + bx then the
normal equations are
Σy = ma + b Σx (8)
Σxy = aΣx + bΣx2 (9)
Here m = 5
x y xy x2
0 1 0 0
1 1.8 1.8 1
2 3.3 6.6 4
3 4.5 13.5 9
4 6.3 25.2 16
Σx = 10 Σy = 16.9 Σxy = 47.1 Σx2 = 30
From (8) and (9), 16.9 = 5a + 10b
and 47.1 = 10a + 30b
Solving, we get a = 0.72, b = 1.33
∴ Required line is y = 0.72 + 1.33 x.
Example 3. Fit a straight line to the following data regarding x as the indepen-
dent variable:
x: 1 2 3 4 5 6
y: 1200 900 600 200 110 50.
Sol. Let the equation of the straight line to be fitted be y = a + bx
Here m = 6
x y x2 xy
1 1200 1 1200
2 900 4 1800
3 600 9 1800
4 200 16 800
5 110 25 550
6 50 36 300
Σx = 21 Σy = 3060 Σx2 = 91 Σxy = 6450
STATISTICAL COMPUTATION 565
From normal equations, we get
3060 = 6a + 21b, 6450 = 21a + 91b
Solving, we get a = 1361.97, b = – 243.42
∴ Required line is
y = 1361.97 – 243.42 x.
Example 4. Show that the line of fit to the following data is given by
y = 0.7x + 11.285:
x: 0 5 10 15 20 25
y: 12 15 17 22 24 30.
Sol. Since m is even,
Let x0 = 12.5 h = 5 y0 = 20 (say)
Then let, u =
x − 12.5
2.5
and v = y – 20
x y u v uv u2
0 12 – 5 – 8 40 25
5 15 – 3 – 5 15 9
10 17 – 1 – 3 3 1
15 22 1 2 2 1
20 24 3 4 12 9
25 30 5 10 50 25
Total Σu = 0 Σv = 0 Σuv = 122 Σu2 = 70
Normal equations are 0 = 6a and 122 = 70b
⇒ a = 0, b = 1.743
Line of fit is v = 1.743u
Put u =
x − 12.5
2.5
and v = y – 20, we get
y = 0.7x + 11.285.
Example 5. Fit a straight line to the following data:
x: 71 68 73 69 67 65 66 67
y: 69 72 70 70 68 67 68 64.
566 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Let the equation of the straight line to be fitted be
y = a + bx (10)
Normal equations are
Σy = ma + bΣx (11)
and Σxy = aΣx + bΣx2 (12)
Here m = 8. Table is as below:
x y xy x2
71 69 4899 5041
68 72 4896 4624
73 70 5110 5329
69 70 4830 4761
67 68 4556 4489
65 67 4355 4225
66 68 4488 4356
67 64 4288 4489
Σx = 546 Σy = 548 Σxy = 37422 Σx2 = 37314
Substituting these values in equations (11) and (12), we get
548 = 8a + 546b
37422 = 546a + 37314b
Solving, we get
a = 39.5454, b = 0.4242
Hence the required line of best fit is
y = 39.5454 + 0.4242 x.
Example 6. Show that the best fitting linear function for the points (x1, y1),
(x2, y2), ....., (xn, yn) may be expressed in the form
x y 1
x y n
x x y x
i i
i
2
i i i
Σ Σ
Σ Σ Σ
= 0 (i = 1, 2, ......, n)
Show that the line passes through the mean point ( , )
x y .
Sol. Let the best fitting linear function be y = a + bx (13)
Then the normal equations are
Σyi = na + bΣxi (14)
and Σxiyi = aΣxi + bΣxi
2 (15)
STATISTICAL COMPUTATION 567
Equations (13), (14), (15) may be rewritten as
bx – y + a = 0
bΣxi – Σyi + na = 0
and bΣxi
2 – Σxiyi + aΣxi = 0
Eliminating a and b between these equations
x y
x y n
x x y x
i i
i i i i
1
2
Σ Σ
Σ Σ Σ
= 0 (16)
which is the required best fitting linear function for the mean point ( , )
x y ,
x =
1
n
Σxi
y =
1
n
Σyi .
Clearly, the line (16) passes through point ( , )
x y as two rows of determinants
being equal make it zero.
ASSIGNMENT 7.1
1. Fit a straight line to the given data regarding x as the independent variable:
x 1 2 3 4 6 8
y 2.4 3.1 3.5 4.2 5.0 6.0
2. Find the best values of a and b so that y = a + bx fits the given data:
x 0 1 2 3 4
y 1.0 2.9 4.8 6.7 8.6
3. Fit a straight line approximate to the data:
x 1 2 3 4
y 3 7 13 21
4. A simply supported beam carries a concentrated load P(lb) at its mid-point. Corresponding
to various values of P, the maximum deflection Y (in) is measured. The data are given
below. Find a law of the type Y = a + bP
568 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
P 100 120 140 160 180 200
Y 0.45 0.55 0.60 0.70 0.80 0.85
5. In the following table y in the weight of potassium bromide which will dissolve in 100
grams of water at temperature x0. Find a linear law between x and y
x0(c) 0 10 20 30 40 50 60 70
y gm 53.5 59.5 65.2 70.6 75.5 80.2 85.5 90
6. The weight of a calf taken at weekly intervals is given below. Fit a straight line using
the method of least squares and calculate the average rate of growth per week.
Age 1 2 3 4 5 6 7 8 9 10
Weight 52.5 58.7 65 70.2 75.4 81.1 87.2 95.5 102.2 108.4
7. Find the least square line for the data points
(– 1, 10), (0, 9), (1, 7), (2, 5), (3, 4), (4, 3), (5, 0) and (6, – 1).
8. Find the least square line y = a + bx for the data:
xi – 2 – 1 0 1 2
yi 1 2 3 3 4
9. If P is the pull required to lift a load W by means of a pulley block, find a linear law of
the form P = mW + c connecting P and W, using the data:
P 12 15 21 25
W 50 70 100 120
where P and W are taken in kg-wt.
10. Using the method of least squares, fit a straight line to the following data:
x 1 2 3 4 5
y 2 4 6 8 10
11. Differentiate between interpolating polynomial and least squares polynomial obtained
for a set of data.
STATISTICAL COMPUTATION 569
7.18 FITTING OF AN EXPONENTIAL CURVE y = aebx
Taking logarithms on both sides, we get
log10 y = log10 a + bx log10 e
i.e., Y = A + Bx (17)
where Y = log10 y, A = log10 a and B = b log10 e
The normal equations for (17) are ΣY = nA + BΣx and ΣxY = AΣx + BΣx2
Solving these, we get A and B.
Then a = antilog A and b =
B
log10 e
.
7.19 FITTING OF THE CURVE y = axb
Taking the logarithm on both sides, we get
log10 y = log10 a + b log10 x
i.e., Y = A + bX (18)
where Y = log10 y, A = log10 a and X = log10 x.
The normal equations to (18) are ΣY = nA + bΣX
and ΣXY = AΣX + bΣX2
which results A and b on solving and a = antilog A.
7.20 FITTING OF THE CURVE y = abx
Take the logarithm on both sides,
log y = log a + x log b
⇒ Y = A + Bx
where Y = log y, A = log a, B = log b.
This is a linear equation in Y and x.
570 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
For estimating A and B, normal equations are
ΣY = nA + B Σx
and ΣxY = A Σx + B Σx2
where n is the number of pairs of values of x and y.
Ultimately, a = antilog (A) and b = antilog (B).
7.21 FITTING OF THE CURVE pvr = k
pvr = k ⇒ v = k1/r p–1/r
Taking logarithm on both sides,
log v =
1 1
r
k
r
log − log p
⇒ Y = A + BX
where Y = log v, A =
1
r
log k, B = –
1
r
and X = log p
r and k are determined by the above equations. Normal equations are obtained
as per that of the straight line.
7.22 FITTING OF THE CURVE OF TYPE xy = b + ax
xy = b + ax ⇒ y =
b
x
+ a
⇒ Y = bX + a, where X =
1
x
.
Normal equations are ΣY = na + bΣX
ΣXY = aΣX + bΣX2.
7.23 FITTING OF THE CURVE y = ax2 +
b
x
Let the n points be (x1, y1), (x2, y2), ..... , (xn, yn)
Error of estimate for ith point (xi, yi) is
Ei = y ax
b
x
i i
i
− −
F
HG
I
KJ
2
STATISTICAL COMPUTATION 571
By principle of Least squares, the values of a and b are such that
U =
i
n
i
=
∑1
2
E =
i
n
i i
i
y ax
b
x
=
∑ − −
F
HG
I
KJ
1
2
2
is minimum.
Normal equations are given by
∂
∂
U
a
= 0
⇒
i
n
i i
i
n
i
i
n
i
x y a x b x
= = =
∑ ∑ ∑
= +
1
2
1
4
1
and
∂
∂
U
b
= 0
⇒
i
n
i
i i
n
i
i
n
i
y
x
a x b
x
= = =
∑ ∑ ∑
= +
1 1 1
2
1
or Dropping the suffix i, normal equations are
Σx2y = a Σx4 + bΣx
and ∑
y
x
= a Σx + b ∑
1
2
x
.
7.24 FITTING OF THE CURVE y = ax + bx2
Error of estimate for ith point (xi, yi) is Ei = (yi – axi– bxi
2)
By the principle of Least Squares, the values of a and b are such that
U =
i
n
i
i
n
i i i
y ax bx
= =
∑ ∑
= − −
1
2
1
2 2
E ( ) is minimum.
Normal equations are given by
∂
∂
U
a
= 0
⇒
i
n
i i
i
n
i
i
n
i
x y a x b x
= = =
∑ ∑ ∑
= +
1 1
2
1
3
and
∂
∂
U
b
= 0
572 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
⇒
i
n
i i
i
n
i
i
n
i
x y a x b x
= = =
∑ ∑ ∑
= +
1
2
1
3
1
4
or Dropping the suffix i, normal equations are
Σxy = a Σx2 + bΣx3
Σx2y = a Σx3 + bΣx4.
7.25 FITTING OF THE CURVE y = ax +
b
x
Error of estimate for ith point (xi, yi) is
Ei = yi – axi –
b
xi
By the principle of Least Squares the values of a and b are such that
U =
i
n
i
i
n
i i
i
y ax
b
x
= =
∑ ∑
= − −
F
HG
I
KJ
1
2
1
2
E is minimum.
Normal equations are given by
∂
∂
U
a
= 0
⇒ 2 0
1
i
n
i i
i
i
y ax
b
x
x
=
∑ − −
F
HG
I
KJ − =
( )
⇒
i
n
i i
i
n
i
x y a x nb
= =
∑ ∑
= +
1 1
2
and
∂
∂
U
b
= 0
⇒ 2
1
0
1
i
n
i i
i i
y ax
b
x x
=
∑ − −
F
HG
I
KJ −
F
HG
I
KJ =
⇒
i
n
i
i i
n
i
y
x
na b
x
= =
∑ ∑
= +
1 1
2
1
STATISTICAL COMPUTATION 573
Dropping the suffix i, normal equations are
Σxy = aΣx2 + nb
and ∑ ∑
= +
y
x
na b
x
1
2
where n is the number of pairs of values of x and y.
7.26 FITTING OF THE CURVE y = a +
b
x
+
c
x2
Normal equations are
Σy = ma + b ∑ ∑
+
1 1
2
x
c
x
∑ ∑ ∑ ∑
= + +
y
x
a
x
b
x
c
x
1 1 1
2 3
∑ ∑ ∑ ∑
= + +
y
x
a
x
b
x
c
x
2 2 3 4
1 1 1
where m is the number of pairs of values of x and y.
7.27 FITTING OF THE CURVE y =
c
x
0
+ c x
1
Error of estimate for ith point (xi, yi) is
Ei = yi –
c
x
c x
i
i
0
1
−
By the principle of Least Squares, the values of a and b are such that
U =
i
n
i
i
n
i
i
i i
y
c
x
c x
= =
∑ ∑
= − −
1
2
1
0 2
E ( ) is minimum.
Normal equations are given by
∂
∂
U
c0
0
= and
∂
∂
U
c1
= 0
Now,
∂
∂
U
c0
0
=
574 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
⇒ 2
1
0
1
0
1
i
n
i
i
i
i
y
c
x
c x
x
=
∑ − −
F
HG
I
KJ −
F
HG
I
KJ =
⇒
i
n
i
i i
n
i i
n
i
y
x
c
x
c
x
= = =
∑ ∑ ∑
= +
1
0
1
2 1
1
1 1
(19)
Also,
∂
∂
U
c1
0
=
⇒ 2 0
1
0
1
i
n
i
i
i i
y
c
x
c x x
=
∑ − −
F
HG
I
KJ − =
( )
⇒
i
n
i i
i
n
i i
n
i
y x c
x
c x
= = =
∑ ∑ ∑
= +
1
0
1
1
1
1
(20)
Dropping the suffix i, normal equations (19) and (20) become
∑ ∑ ∑
= +
y
x
c
x
c
x
0 2 1
1 1
and ∑ ∑
=
y x c
x
0
1
+ c1 Σx.
7.28 FITTING OF THE CURVE 2x = ax2 + bx + c
Normal equations are
Σ 2xx2 = aΣx4+ bΣx3 + cΣx2
Σ 2x . x = aΣx3 + bΣx2 + cΣx
and Σ 2x = aΣx2 + bΣx + mc
where m is number of points (xi, yi)
EXAMPLES
Example 1. Find the curve of best fit of the type y = aebx to the following data by
the method of Least Squares:
x: 1 5 7 9 12
y: 10 15 12 15 21.
STATISTICAL COMPUTATION 575
Sol. The curve to be fitted is y = aebx
or Y = A + Bx,
where Y = log10 y, A = log10 a, and B = b log10 e
∴ The normal equations are ΣY = 5A + BΣx
and ΣxY = AΣx + BΣx2
x y Y = log10 y x2 xY
1 10 1.0000 1 1
5 15 1.1761 25 5.8805
7 12 1.0792 49 7.5544
9 15 1.1761 81 10.5849
12 21 1.3222 144 15.8664
Σx = 34 ΣY = 5.7536 Σx2 = 300 ΣxY = 40.8862
Substituting the values of Σx, etc. calculated by means of above table in the
normal equations.
We get 5.7536 = 5A + 34B
and 40.8862 = 34A + 300B
On solving A = 0.9766; B = 0.02561
∴ a = antilog10 A = 9.4754; b =
B
log10 e
= 0.059
Hence the required curve is y = 9.4754e0.059x.
Example 2. For the data given below, find the equation to the best fitting
exponential curve of the form y = aebx
x: 1 2 3 4 5 6
y: 1.6 4.5 13.8 40.2 125 300.
Sol. y = aebx
Take log, log y = log a + bx log e
which is of the form Y = A + Bx
where Y = log y, A = log a, B = b log e
576 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
x y Y = log y x2 xY
1 1.6 .2041 1 .2041
2 4.5 .6532 4 1.3064
3 13.8 1.1399 9 3.4197
4 40.2 1.6042 16 6.4168
5 125 2.0969 25 10.4845
6 300 2.4771 36 14.8626
Σx = 21 ΣY = 8.1754 Σx2 = 91 ΣxY = 36.6941
Normal equations are
and
Σ Σ
Σ Σ Σ
Y A B
Y A B
= +
= +
U
V
W
m x
x x x2 (21)
Here m = 6
∴ From (21), 8.1754 = 6A + 21B, 36.6941 = 21A + 91B
⇒ A = – 0.2534, B = 0.4617
∴ a = antilog A = antilog (– .2534)
= antilog ( . )
17466 = 0.5580
and b =
B .4617
.4343
log e
= = 1.0631
Hence required equation is
y = 0.5580 e1.0631 x.
Example 3. Determine the constants a and b by the Method of Least Squares
such that y = aebx fits the following data:
x 2 4 6 8 10
y 4.077 11.084 30.128 81.897 222.62
Sol. y = aebx
Taking log on both sides
log y = log a + bx log e
or Y = A + BX,
where Y = log y
A = log a
STATISTICAL COMPUTATION 577
B = b log10 e
X = x.
Normal equations are
ΣY = mA + BΣX (22)
and ΣXY = AΣX + BΣX2. (23)
Here m = 5.
Table is as follows:
x y X Y XY X2
2 4.077 2 .61034 1.22068 4
4 11.084 4 1.04469 4.17876 16
6 30.128 6 1.47897 8.87382 36
8 81.897 8 1.91326 15.30608 64
10 222.62 10 2.347564 23.47564 100
ΣX = 30 ΣY = 7.394824 ΣXY = 53.05498 ΣX2 = 220
Substituting these values in equations (22) and (23), we get
7.394824 = 5A + 30B
and 53.05498 = 30A + 220B.
Solving, we get A = 0.1760594
and B = 0.2171509
∴ a = antilog (A)
= antilog (0.1760594) = 1.49989
and b =
B
log10 e
=
0 2171509
4342945
.
.
= 0.50001
Hence the required equation is
y = 1.49989 e0.50001x.
Example 4. Obtain a relation of the form y = abx for the following data by the
Method of Least Squares:
x 2 3 4 5 6
y 8.3 15.4 33.1 65.2 126.4
578 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. The curve to be fitted is y = abx
or Y = A + Bx,
where A = log10 a, B = log10 b and Y = log10 y.
∴ The normal equations are ΣY = 5A + BΣx
and ΣXY = AΣx + BΣx2.
x y Y = log10 y x2 xY
2 8.3 0.9191 4 1.8382
3 15.4 1.1872 9 3.5616
4 33.1 1.5198 16 6.0792
5 65.2 1.8142 25 9.0710
6 127.4 2.1052 36 12.6312
Σx = 20 ΣY = 7.5455 Σx2 = 90 ΣxY = 33.1812
Substituting the values of Σx, etc. from the above table in normal equations,
we get
7.5455 = 5A + 20B and 33.1812 = 20A + 90B.
On solving A = 0.31 and B = 0.3
∴ a = antilog A = 2.04
and b = antilog B = 1.995.
Hence the required curve is
y = 2.04(1.995)x.
Example 5. By the method of least squares, find the curve y = ax + bx2 that best
fits the following data:
x 1 2 3 4 5
y 1.8 5.1 8.9 14.1 19.8
Sol. Error of estimate for ith point (xi, yi) is Ei = (yi – axi – bxi
2)
By the principle of least squares, the values of a and b are such that
U =
i
i
i
i i i
y ax bx
= =
∑ ∑
= − −
1
5
2
1
5
2 2
E ( ) is minimum.
STATISTICAL COMPUTATION 579
Normal equations are given by
∂
∂
U
a
= 0
⇒
i
i i
i
i
i
i
x y a x b x
= = =
∑ ∑ ∑
= +
1
5
1
5
2
1
5
3
and
∂
∂
U
b
= 0
⇒
i
i i
i
i
i
i
x y a x b x
= = =
∑ ∑ ∑
= +
1
5
2
1
5
3
1
5
4
Dropping the suffix i, Normal equations are
Σxy = aΣx2 + bΣx3 (24)
and Σx2y = aΣx3 + bΣx4 (25)
Let us form a table as below:
x y x2 x3 x4 xy x2y
1 1.8 1 1 1 1.8 1.8
2 5.1 4 8 16 10.2 20.4
3 8.9 9 27 81 26.7 80.1
4 14.1 16 64 256 56.4 225.6
5 19.8 25 125 625 99 495
Total Σx2 = 55 Σx3 = 225 Σx4 = 979 Σxy = 194.1 Σx2y = 822.9
Substituting these values in equations (24) and (25), we get
194.1 = 55 a + 225 b
and 822.9 = 225 a + 979 b
⇒ a =
83 85
55
.
~ 1.52
and b =
317.4
664
~ .49
Hence the required parabolic curve is y = 1.52 x + 0.49 x2.
580 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 6. Fit the curve pvγ = k to the following data:
p (kg/cm2) 0.5 1 1.5 2 2.5 3
v (liters) 1620 1000 750 620 520 460
Sol. pvγ = k
v =
k
p
F
HG I
KJ
1/γ
= k1/γ p–1/γ
Taking log, log v =
1 1
γ γ
log k − log p
which is of the form Y = A + BX
where Y = log v, X = log p, A =
1
γ
log k and B = –
1
γ
p v X Y XY X2
.5 1620 – .30103 3.20952 – .96616 0.09062
1 1000 0 3 0 0
1.5 750 .17609 2.87506 .50627 .03101
2 620 .30103 2.79239 .84059 .09062
2.5 520 .39794 2.716 1.08080 .15836
3 460 .47712 2.66276 1.27046 .22764
Total ΣX = 1.05115 ΣY = 17.25573 ΣXY = 2.73196 ΣX2 = .59825
Here m = 6
Normal equations are
17.25573 = 6A + 1.05115 B
and 2.73196 = 1.05115 A + 0.59825 B
Solving these, we get
A = 2.99911 and B = – 0.70298
∴ γ = –
1
B
1
.70298
= = 1.42252
Again, log k = γA = 4.26629
∴ k = antilog (4.26629) = 18462.48
STATISTICAL COMPUTATION 581
Hence the required curve is
pv1.42252 = 18462.48.
Example 7. Given the following experimental values:
x: 0 1 2 3
y: 2 4 10 15
Fit by the method of least squares a parabola of the type y = a + bx2.
Sol. Error of estimate for ith point (xi, yi) is Ei = (yi – a – bxi
2)
By the principle of Least Squares, the values of a, b are such that
U =
i
i
i
i i
y a bx
= =
∑ ∑
= − −
1
4
2
1
4
2 2
E ( ) is minimum.
Normal equations are given by
∂
∂
U
a
= 0 ⇒ Σy = ma + bΣx2 (26)
and
∂
∂
U
b
= 0 Σx2y = aΣx2 + bΣx4 (27)
x y x2 x2y x4
0 2 0 0 0
1 4 1 4 1
2 10 4 40 16
3 15 9 135 81
Total Σy = 31 Σx2 = 14 Σx2y = 179 Σx4 = 98
Here m = 4
From (26) and (27), 31 = 4a + 14b and 179 = 14a + 98b
Solving for a and b, we get a = 2.71, b = 1.44
Hence the required curve is y = 2.71 + 1.44 x2.
Example 8. The pressure of the gas corresponding to various volumes V is
measured, given by the following data:
V (cm3): 50 60 70 90 100
P (kg cm–2): 64.7 51.3 40.5 25.9 78
Fit the data to the equation PVγ = C.
582 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. PVγ = C
⇒ P = CV–γ
Take log on both sides,
log P = log C – γ log V
⇒ Y = A + BX
where Y = log P, A = log C, B = – γ, X = log V
Normal equations are
ΣY = mA + BΣX
and ΣXY = AΣX + BΣX2
Here m = 5
Table is as below:
V P X = log V Y = log P XY X2
50 64.7 1.69897 1.81090 3.07666 2.88650
60 51.3 1.77815 1.71012 3.04085 3.16182
70 40.5 1.84510 1.60746 2.96592 3.40439
90 25.9 1.95424 1.41330 2.76193 3.81905
100 78 2 1.89209 3.78418 4
ΣX = 9.27646 ΣY = 8.43387 ΣXY = 15.62954 ΣX2 = 17.27176
From Normal equations, we have
8.43387 = 5A + 9.27646 B
and 15.62954 = 9.27646 A + 17.27176 B
Solving these, we get
A = 2.22476, B = – 0.28997
∴ γ = – B = 0.28997
C = antilog (A) = antilog (2.22476) = 167.78765
Hence the required equation of curve is
PV0.28997 = 167.78765.
STATISTICAL COMPUTATION 583
Example 9. Use the Method of Least Squares to fit the curve: y =
c
x
c x
0
1
+ to
the following table of values:
x: 0.1 0.2 0.4 0.5 1 2
y: 21 11 7 6 5 6.
Sol. As derived in article 5.16, normal equations to the curve
y =
c
x
c x
0
1
+ are
∑ ∑ ∑
= +
y
x
c
x
c
x
0 2 1
1 1
(28)
and ∑ ∑ ∑
= +
y x c
x
c x
0 1
1
(29)
The table is as below:
x y y/x y x
1
x
1
x2
0.1 21 210 6.64078 3.16228 100
0.2 11 55 4.91935 2.23607 25
0.4 7 17.5 4.42719 1.58114 6.25
0.5 6 12 4.24264 1.41421 4
1 5 5 5 1 1
2 6 3 8.48528 .70711 0.25
Σx = 4.2 Σ(y/x) = 302.5 Σy x = 33.71524
1
x
∑ = 10.10081
1
2
x
∑ = 136.5
From equations (28) and (29), we have
302.5 = 136.5 c0 + 10.10081 c1
and 33.71524 = 10.10081 c0 + 4.2 c1
Solving these, we get
c0 = 1.97327 and c1 = 3.28182
Hence the required equation of curve is
y =
197327
3 28182
.
.
x
x
+ .
584 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 7.2
1. Fit an equation of the form y = aebx to the following data by the method of least squares:
x 1 2 3 4
y 1.65 2.7 4.5 7.35
2. The voltage V across a capacitor at time t seconds is given by the following table. Use
the principle of least squares to fit a curve of the form V = aekt to the data:
t 0 2 4 6 8
V 150 63 28 12 5.6
3. Using the method of least squares, fit the non-linear curve of the form y = aebx to the
following data:
x 0 2 4
y 5.012 10 31.62
4. Fit a curve of the form y = axb to the data given below:
x 1 2 3 4 5
y 7.1 27.8 62.1 110 161
5. Fit a curve of the form y = abx in least square sense to the data given below:
x 2 3 4 5 6
y 144 172.8 207.4 248.8 298.5
6. Fit an exponential curve of the form y = abx to the following data:
x 1 2 3 4 5 6 7 8
y 1 1.2 1.8 2.5 3.6 4.7 6.6 9.1
7. Fit a curve y = axb to the following data:
x 1 2 3 4 5 6
y 2.98 4.26 5.21 6.1 6.8 7.5
STATISTICAL COMPUTATION 585
8. Fit a least square geometric curve y = axb to the following data:
x 1 2 3 4 5
y 0.5 2 4.5 8 12.5
9. Derive the least square equations for fitting a curve of the type y = ax2 +
b
x
to a set of n
points.
Hence fit a curve of this type to the data:
x 1 2 3 4
y – 1.51 0.99 3.88 7.66
10. Derive the least squares approximations of the type ax2 + bx + c to the function 2x at the
points xi = 0, 1, 2, 3, 4.
11. A person runs the same race track for 5 consecutive days and is timed as follows:
Day (x) 1 2 3 4 5
Time (y) 15.3 15.1 15 14.5 14
Make a least square fit to the above data using a function a +
b
x
c
x
+ 2
.
12. It is known that the variables x and y hold the relation of the form y = ax +
b
x
.
Fit the curve to the given data:
x 1 2 3 4 5 6 7 8
y 5.43 6.28 8.23 10.32 12.63 14.86 17.27 19.51
13. Fit a curve of the type xy = ax + b to the following data:
x 1 3 5 7 9 10
y 36 29 28 26 24 15
14. Determine the constants of the curve y = ax + bx2 for the following data:
x 0 1 2 3 4
y 2.1 2.4 2.6 2.7 3.4
586 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
15. The presssure and volume of a gas are related by the equation pva = b where a and b are
constants. Fit this equation to the following set of data:
p (kg/cm3) 0.5 1 1.5 2 2.5 3
v (liters) 1.62 1 0.75 0.62 0.52 0.46
7.29 MOST PLAUSIBLE SOLUTION OF A SYSTEM OF LINEAR
EQUATIONS
Consider a set of m equations in n variables x, y, z,......, t;
a1x + b1y + c1z + ...... + k1t = l1
a2x + b2y + c2z + ...... + k2t = l2
U
V
|
|
W
|
|
(30)
     
amx + bmy + cmz + ...... + kmt = lm
where ai, bi, ci, ....., ki, li; i = 1, 2, ......, m are constants.
In case m = n, the system of equation (30) can be solved uniquely by using
algebra.
In case m  n, we find the values of x, y, z, ......, t which will satisfy the
system (30) as nearly as possible using normal equations.
On solving normal equations simultaneously, they give the values of x, y, z,
......, t; known as the best or most plausible values.
On calculating the second order partial derivatives and substituting values
of x, y, z,......, t so obtained, we will observe that the expression will be positive.
EXAMPLES
Example 1. Find the most plausible values of x and y from the following
equations:
3x + y = 4.95, x + y = 3.00, 2x – y = 0.5, x + 3y = 7.25.
Sol. Let S = (3x + y – 4.95)2 + (x + y – 3)2 + (2x – y – 0.5)2 + (x + 3y – 7.25)2
(31)
Differentiating S partially with respect to x and y separately and equating
to zero, we have
∂
∂
S
x
= 0 = 2(3x + y – 4.95) (3) + 2(x + y – 3)
+ 2(2x – y – 0.5) (2) + 2(x + 3y – 7.25)
STATISTICAL COMPUTATION 587
⇒ 30x + 10y = 52.2
or 3x + y = 5.22 (32)
and
∂
∂
S
y
= 0 = 2(3x + y – 4.95) + 2(x + y – 3)
+ 2(2x – y – 0.5) (– 1) + 2(x + 3y – 7.25) (3)
⇒ 10x + 24y = 58.4
or x + 2.4y = 5.84 (33)
Solving equations (32) and (33), we get
x = 1.07871 and y = 1.98387.
Example 2. Three independent measurements on each of the angles A, B, and
C of a triangle are as follows:
A B C
39.5° 60.3° 80.1°
39.3° 63.2° 80.3°
39.6° 69.1° 80.4°
Obtain the best estimate of the three angles when the sum of the angles is
taken to be 180°.
Sol. Let the three measurements of angles A, B, C be x1, x2, x3; y1, y2, y3 and z1,
z2, z3 respectively. Further suppose the best estimates of the angle A, B, and C
to be α, β, γ respectively where γ = 180° – (α + β)
According to Least squares method,
S =
i
i
i
i
i
i
x y z
= = =
∑ ∑ ∑
− + − + − + +
1
3
2
1
3
2
1
3
2
180
( ) ( ) ( )
α β α β
(34)
and
∂
∂α
α α β
S
= = − − + − + +
= =
∑ ∑
0 2 2 180
1
3
1
3
i
i
i
i
x z
( ) ( )
∂
∂β
β α β
S
= = − − + − + +
= =
∑ ∑
0 2 2 180
1
3
1
3
i
i
i
i
y z
( ) ( )
or
− + + − + + =
+ + − + + =
R
S
T
Σ Σ
Σ Σ
x z
y z
3 540 3 3 0
3 540 3 3 0
α α β
β α β
–
or R
S
T
6α + 3β = 540 + Σx – Σz = 417.6 (35)
3α + 6β = 540 + Σy – Σz = 481.8 (36)
588 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Solving equations (35) and (36), we get
α = 39.2667, β = 60.6667, γ = 80.0666
ASSIGNMENT 7.3
1. Find the most plausible values of x and y from the following equations:
x + y = 3, x – y = 2, x + 2y = 4, x – 2y = 1
2. Find the most plausible values of x and y from the equations:
x + y = 3.31, 2x – y = .03, x + 3y = 7.73, 3x + y = 5.47
3. Find the most plausible values of x, y, and z from the follwoing equations:
x – y + 2z = 3, 3x + 2y – 5z = 5,
4x + y + 4z = 21, – x + 3y + 3z = 14
4. Find the most plausible values of x, y, and z from the following equations:
(i) x + y = 3.01, 2x – y = 0.03, x + 3y = 7.02 and 3x + y = 4.97
(ii) x + 2y = 4, x = y + 2, x + y – 3 = 0, x – 2y = 1
(iii) x + 2.5y = 21, 4x + 1.2y = 42.04, 3.2x – y = 28 and 1.5x + 6.3y = 40
(iv) x – 5y + 4 = 0, 2x – 3y + 5 = 0
x + 2y – 3 = 0, 4x + 3y + 1 = 0
5. Find the most plausible values of x, y, and z from the following equations:
(i) 3x + 2y – 5z = 13 (ii) x + 2y + z = 1
x – y + 2z = – 2 2x + y + z = 4
4x + y + 4z = 3 – x + y + 2z = 3
– x + 3y + 3z = 0 4x + 2y – 5z = – 7
(iii) x – y + 2z = 3, 3x + 2y – 5z = 5
4x + y + 4z = 21, – x + 3y + 3z = 14.
7.30 CURVE-FITTING BY SUM OF EXPONENTIALS
We are to fit a sum of exponentials of the form
y = f(x) = A A A
1 2
1 2
e e e
x x
n
x
n
λ λ λ
+ + +
...... (37)
to a set of data points say (x1, y1), (x2, y2), ......, (xn, yn)
In equation (37), we assume that n is known and A1, A2, ......, An, λ1, λ2, ......,
λn are to be determined.
Since equation (37) involves n arbitrary constants,
STATISTICAL COMPUTATION 589
It can be seen that f(x) satisfies a differential equation of the type
d y
dx
a
d y
dx
a
d y
dx
n
n
n
n
n
n
+ +
−
−
−
−
1
1
1 2
2
2
+ ...... + any = 0 (38)
where coefficients a1, a2, ......, an are unknown.
According to the Froberg Method, we numerically evaluate the derivatives
at the n data points and substitute them in (38) thus obtaining a system of n
linear equations for n unknowns a1, ......., an which can be solved thereafter.
Again, since λ1, λ2, ......, λn are the roots of algebraic equation
λn + a1λn–1 + a2λn–2 + ...... + an = 0 (39)
which, when solved, enables us to compute A1, A2, ....., An from equation (37) by
the method of least squares.
An obvious disadvantage of the method is the numerical evaluation of the
derivatives whose accuracy deteriorates with their increasing order, leading to
unreliable results.
In 1974, Moore described a computational technique which leads to more
reliable results.
We demonstrate the method for the case n = 2.
Let the function to be fitted to a given data be of the form
y = A A
1 2
1 2
e e
x x
λ λ
+ (40)
which satisfies a differential equation of the form
d y
dx
a
dy
dx
2
2 1
= + a2y (41)
where the constants a1 and a2 have to be determined.
Assuming that a is the initial value of x, we obtain by integrating (41) from
a to x, the following equation
y′(x) – y′(a) = a1y(x) – a1y(a) + a2
a
x
y x dx
z ( ) (42)
where y′(x) denotes
dy
dx
.
Integrating (42) again from a to x, we get
y(x) – y(a) – y′(a) (x – a) = a1
a
x
y x dx
z ( ) – a1(x – a) y(a)
+ a2
a
x
a
x
y x dx
z z ( ) dx (43)
590 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
using the formula,
a
x
a
x
a
x
n
f x dx dx
n
x t f t dt
z z z
=
−
− −
...... ( ) ......
( ) !
( ) ( )
1
1
1
(44)
equation (43) simplifies to,
y(x) – y(a) – (x – a) y′(a) = a1
a
x
y x dx
z ( ) – a1(x – a) y(a) + a2
a
x
x t y t dt
z −
( ) ( )
(45)
In order to use equation (45) to set up a linear system for a1 and a2, y′(a)
should be eliminated.
To do this, we choose two data points x1 and x2 such that
a – x1 = x2 – a
then from (45),
y(x1) – y(a) – (x1– a) y′(a)
= a1
a
x
a
x
y x dx a x a y a a x t y t dt
1 1
1 1 2 1
z z
− − + −
( ) ( ) ( ) ( ) ( )
y(x2) – y(a) – (x2 – a) y′(a)
= a1
a
x
a
x
y x dx a x a y a a x t y t dt
2 2
1 2 2 2
z z
− − + −
( ) ( ) ( ) ( ) ( )
Adding the above equations and simplifying, we get
y(x1) + y(x2) – 2y(a) = a1
a
x
a
x
y x dx y x dx
1 2
z z
+
L
NM O
QP
( ) ( )
+ − + −
L
NM O
QP
z z
a x t y t dt x t y t dt
a
x
a
x
2 1 2
1 2
( ) ( ) ( ) ( ) (46)
we find integrals using Simpson’s rule and equation (46) can be used to set up
a linear system of equations for a1 and a2, then we obtain λ1 and λ2 from the
characteristic equation
λ2 = a1λ + a2 (47)
Finally, A1 and A2 can be obtained by the Method of Least Squares.
Example. Fit a function of the form
y = A e A e
1
x
2
x
1 2
λ λ
+
to the data given by
x: 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8
y: 1.54 1.67 1.81 1.97 2.15 2.35 2.58 2.83 3.11.
STATISTICAL COMPUTATION 591
Sol. Choose x1 = 1, x2 = 1.4, a = 1.2
so that, a – x1 = x2 – a then,
y(x1) + y(x2) – 2y(a) = a1
a
x
a
x
y x dx y x dx
1 2
z z
+
L
NM O
QP
( ) ( )
+ − + −
L
NM O
QP
z z
a x t y t dt x t y t dt
a
x
a
x
2 1 2
1 2
( ) ( ) ( ) ( )
⇒ 1.54 + 2.15 – 3.62 = a1 − +
L
NM O
QP
z z
1
1 2
1 2
1 4
.
.
.
( ) ( )
y x dx y x dx
+ − − + −
L
NM O
QP
z z
a t y t dt t y t dt
2
1
1 2
1 2
1 4
1 14
.
.
.
( ) ( ) ( . ) ( ) (48)
Evaluation of
1
1.2
y(x) dx
z
The table of values is
x: 1 1.1 1.2
y(x): 1.54 1.67 1.81
By Simpson’s
1
3
rd rule,
1
1.2
(1.54 1.81) 4(1.67
z = + +
y x dx
( )
.
[ )]
0 1
3
= 0.33433
Evaluation of
1.2
1.4
y(x) dx
z
The table of values is
x: 1.2 1.3 1.4
y(x): 1.81 1.97 2.15
By Simpson’s
1
3
rd rule,
1
1 4 0 1
3
.2
.
( )
.
z =
y x dx [(1.81 + 2.15) + 4(1.97)] = 0.39466
592 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Evaluation of
1
1.2
(1 t) y(t) dt
z −
The table of values is
t: 1 1.1 1.2
y(t): 1.54 1.67 1.81
(1 – t) y(t): 0 – 0.167 – 0.362
By Simpson’s
1
3
rd rule,
1
1.2
z − =
( ) ( )
.
1
0 1
3
t y t dt [0 – .362 + 4 (– .167)] = – .03433
Evaluation of
1.2
1.4
(1.4 t) y(t) dt
z −
The table of values is
t: 1.2 1.3 1.4
(1.4 – t): .2 .1 0
y(t): 1.81 1.97 2.15
(1.4 – t) y(t): .362 .197 0
By Simpson’s
1
3
rd rule,
1.2
1.4
z − =
( . ) ( )
.
14
0 1
3
t y t dt [(0.362 + 0) + 4(.197)] = 0.03833
Substituting values of above obtained integrals in equation (48), we get
0.07 = a1[– 0.33433 + 0.39466] + a2[0.03433 + 0.03833]
0.07 = 0.06033 a1 + 0.07266 a2
⇒ 1.8099 a1 + 2.1798 a2 = 2.10
or 1.81 a1 + 2.18 a2 = 2.10 (49)
Again, letting x1 = 1.4, a = 1.6 and x2 = 1.8
so that a – x1 = x2 – a then,
y(x1) + y(x2) – 2y(a) = a y x dx y x dx
a
x
a
x
1
1 2
z z
+
L
NM O
QP
( ) ( )
+ a x t y t dt x t y t dt
a
x
a
x
2 1 2
1 2
z z
− + −
L
NM O
QP
( ) ( ) ( ) ( )
STATISTICAL COMPUTATION 593
⇒ 2.15 + 3.11 – 5.16 = a y x dx y x dx
1
1 4
1 6
1 6
1 8
− +
L
NM O
QP
z z
.
.
.
.
( ) ( )
+ a t y t dt t y t dt
2
1 4
1 6
1 6
1 8
14 18
− − + −
L
NM O
QP
z z
.
.
.
.
( . ) ( ) ( . ) ( )
Evaluating all of the above integrals by Simpson’s
1
3
rd rule and substituting,
we obtain
2.88 a1 + 3.104 a2 = 3.00 (50)
Solving (49) and (50), we get
a1 = 0.03204, a2 = 0.9364
Characteristic equation is
λ2 = a1λ + a2
⇒ λ2 – 0.03204λ – 0.9364 = 0
⇒ λ1 = 0.988 ≈ 0.99
and λ2 = – 0.96
Now the curve to be fitted is
y = A1e0.99x + A2e–0.96x (51)
Residual Ei = yi – A1e e
x x
i i
0.99
2
0.96
− −
A
Consider U =
i
n
i
i
n
i
x x
y e e
i i
= =
−
∑ ∑
= − −
1
2
1
1
0.99
2
0.96 2
E A A
( )
By the Method of Least Squares, values of A1 and A2 are chosen such that
U is the minimum.
For U to be minimum,
∂
∂
U
A1
0
= and
∂
∂
U
A2
0
=
Now,
∂
∂
U
A1
0
= ⇒ 2 0
1
99
2
96 99
∑ − − − =
−
( ) ( )
. . .
y e e e
x x x
A A
⇒ ∑ ∑
= +
ye e e
x x x
. . .
99
1
1 98
2
03
A A (52)
594 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
and
∂
∂
U
A2
0
= ⇒ 2 0
1
99
2
96 96
∑ − − − =
− −
( ) ( )
. . .
y e e e
x x x
A A
⇒ ∑ ∑ ∑
− −
= +
ye e e
x x x
. . .
96
1
03
2
1 92
A A (53)
Solving normal equations (52) and (53) using values of x and y given in the
table, we get
A1 = 0.499 and A2 = 0.491
Hence the required function is
y = 0.499 e0.99x + 0.491 e–0.96x.
7.31 SPLINE INTERPOLATION
When computers were not available, the draftsman used a device to draw a
smooth curve through a given set of points such that the slope and curvature
were also continuous along the curve, i.e., f(x), f ′(x), and f ″(x) were continuous
on the curve. Such a device was called a spline and plotting of the curve was
called spline fitting.
The given interval [a, b] is subdivided into n subintervals [x0, x1], [x1, x2],......,
[xn–1 , xn] where a = x0  x1  x2  .....  xn = b. The nodes (knots) x1, x2,....., xn–1
are called internal nodes.
7.32 SPLINE FUNCTION
A spline function of degree n with knots (nodes) xi, i = 0, 1,......, n is a function
F(x) satisfying the properties
(i) F(xi) = f(xi); i = 0, 1,......, n.
(ii) on each subinterval [xi–1, xi], 1 ≤ i ≤ n, F(x) is a polynomial in x of degree
at most n.
(iii) F(x) and its first (n – 1) derivatives are continuous on [a, b]
(iv) F(x) is a polynomial of degree one for x  a and x  b.
7.33 CUBIC SPLINE INTERPOLATION
A cubic spline satisfies the following properties:
(i) F(xi) = fi, i = 0, 1,......, n
STATISTICAL COMPUTATION 595
(ii) On each subinterval [xi–1, xi], 1 ≤ i ≤ n, F(x) is a third degree polynomial.
(iii) F(x), F′(x) and F″(x) are continuous on [a, b].
Since F(x) is piecewise cubic, polynomial F″(x) is a linear function of x in
the interval xi–1 ≤ x ≤ xi and hence can be written as
F″(x) =
x x
x x
i
i i
−
− −1
F″(xi–1) +
x x
x x
i
i i
−
−
−
−
1
1
F″(xi) (54)
For equally spaced intervals,
xi – xi–1 = h; 1 ≤ i ≤ n
From (54), F″(x) =
1
h
[(xi – x) F″(xi–1) + (x – xi–1) F″(xi)] (55)
Integrating equation (55) twice, we get
F(x) =
1
6 6
3
1
1
3
h
x x
x
x x
x
i
i
i
i
( )
( )
( )
( )
−
″ +
−
″
L
NMM
O
QPP
−
−
F F
+ c1(xi – x) + c2(x – xi–1) (56)
where c1 and c2 are arbitrary constants which are to be determined by conditions
F(xi) = fi; i = 0, 1, 2,......, n
Then, fi =
1
6
3
2
h
h
x c h
i
F″
L
NM O
QP+
( )
⇒ c2 =
f
h
h
x
i
i
− ″
6
F ( ) (57)
and fi–1 =
1
6
3
1 1
h
h
x c h
i
F″
L
NM O
QP+
−
( )
⇒ c1 =
f
h
h
x
i
i
−
−
− ″
1
1
6
F ( ) (58)
Putting the values of c1 and c2 in equation (56), we get
F(x) =
1
6 6
3
1
1
3
h
x x
x
x x
x
i
i
i
i
( )
( )
( )
( )
−
″ +
−
″
L
NMM −
−
F F
+ (xi – x) f
h
x
i i
− −
− ″
R
S
T
U
V
W
1
2
1
6
F ( )
+ (x – xi–1) f
h
x
i i
− ″
R
S
T
U
V
W
O
Q
PP
2
6
F ( ) (59)
596 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Denoting F″(xi) = Mi, we have
F(x) =
1
6
3
1 1
3
h
x x x x
i i i i
[( ) ( )
− + −
− −
M M
+ (xi – x) {6fi–1 – h2 Mi–1} + (x – xi–1) {6fi – h2 Mi}] (60)
Now, F′(x) =
1
6h
[– 3(xi – x)2 Mi–1 + 3(x – xi–1)2 Mi
+ 6(fi – fi–1) + h2Mi–1 – h2Mi] (61)
Now, we require that the derivative F′(x) be continuous at x = xi ± ε as ε → 0
Therefore,
(i) F′(xi–1 + 0) =
1
6h
[– 3h2Mi–1 + h2Mi–1 – h2Mi + 6(fi – fi–1)]
=
1
6h
[– h2Mi – 2h2Mi–1 + 6(fi – fi–1)] (62)
Again in the interval [xi–2, xi–1],
F′(x) =
1
6h
[– 3(xi–1 – x)2 Mi–2 + 3(x – xi–2)2 Mi–1 + 6(fi–1 – fi–2)
+ h2Mi–2 – h2Mi–1] (63)
(ii) From (63),
F′(xi–1 – 0) =
1
6h
[3h2Mi–1 + 6fi–1 – 6fi–2 + h2Mi–2 – h2Mi–1]
=
1
6h
[2h2Mi–1 + h2Mi–2 + 6fi–1 – 6fi–2] (64)
As F′(x) is continuous at xi–1,
∴ F′(xi–1 – 0) = F′(xi–1 + 0)
∴ 2h2Mi–1 + h2Mi–2 + 6fi–1 – 6fi–2 = – h2Mi – 2h2Mi–1 + 6fi – 6fi–1
or h2 (Mi + 4Mi–1 + Mi–2) = 6(fi – 2fi–1 + fi–2)
For the interval [xi–1, xi],
we have h2 [Mi+1 + 4Mi + Mi–1] = 6(fi+1 – 2fi + fi–1) (65)
where i = 1, 2,......, n
STATISTICAL COMPUTATION 597
This gives a system of (n – 1) linear equations with (n + 1) unknowns
M0, M1,......, Mn.
Two additional conditions may be taken in one of the following forms:
(i) M0 = Mn = 0 (Natural spline)
(ii) M0 = Mn, M1 = Mn+1, f0 = fn, f1 = fn+1, h1 = hn+1
A spline satisfying the above conditions is called a periodic spline.
(iii) For a non-periodic spline, we use the conditions
F′(a) = f ′(a) = f0′ and F′(b) = f ′(b) = fn′
Splines usually provide a better approximation of the behavior of functions
that have abrupt local changes. Further, splines perform better than higher
order polynomial approximations.
7.34 STEPS TO OBTAIN CUBIC SPLINE FOR GIVEN DATA
Step 1. For interval (xi–1, xi), write cubic spline as
F(x) =
1
6h
[(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
+ (x – xi–1){6fi – h2Mi}]
Step 2. If not given, choose M0 = 0 = M3 (for the interval 0 ≤ x ≤ 3)
Step 3. For i = 1, 2,......, n, choose values of M1 and M2 such that
h2[Mi+1 + 4Mi + Mi–1] = 6[fi+1 – 2fi + fi–1]
exists for two sub intervals 0 ≤ x ≤ 1 and 1 ≤ x ≤ 2 respectively,
where h is the interval of differencing.
Step 4. Find F(x) for different sub-intervals and tabulate at last.
EXAMPLES
Example 1. Obtain the cubic spline for the following data:
x: 0 1 2 3
y: 2 – 6 – 8 2.
Sol. For the interval (xi–1, xi), the cubic spline is
F(x) =
1
6h
[(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
+ (x – xi–1) {6fi – h2Mi}]
598 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
With M0 = M3 = 0 and for i = 1, 2,......, n; we also have
h2[Mi–1 + 4 Mi + Mi+1] = 6 [fi+1 – 2fi + fi–1]
Here h = 1
∴ M0 + 4M1 + M2 = 6(f2 – 2f1 + f0) | For 0 ≤ x ≤ 1
and M1 + 4M2 + M3 = 6(f3 – 2f2 + f1) | For 1 ≤ x ≤ 2
Here, M2 + 4M1 + M0 = 6[– 8 – 2(– 6) + 2] = 36
and M3 + 4M2 + M1 = 6 [2 – 2 (– 8) + (– 6) = 72
Putting M0 = M3 = 0, we get
M2 + 4M1 = 36
4M2 + M1 = 72
Solving, we get M1 = 4.8, M2 = 16.8
Hence for 0 ≤ x ≤ 1,
F(x) =
1
6
[(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) (6f0 – M0)
+ (x – 0) (6f1 – M1)]
=
1
6
[x3(4.8) + (1 – x) (12) + x (– 36 – 4.8)]
= 0.8x3 – 8.8x + 2
For 1 ≤ x ≤ 2,
F(x) =
1
6
[(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1}
+ (x – 1) {6f2 – M2}]
=
1
6
[(2 – x)3 (4.8) + (x – 1)3 (16.8) + (2 – x) {– 36 – 4.8}
+ (x – 1) {– 48 – 16.8}]
= 2x3 – 3.6x2 – 5.2x + 0.8
For 2 ≤ x ≤ 3,
F(x) =
1
6
[(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) {6f2 – h2M2}
+ (x – 2) {6f3 – h2M3}]
=
1
6
[(3 – x)3 (16.8) + (3 – x) {– 48 – 16.8} + (x – 2) (12)]
| using M3 = 0
STATISTICAL COMPUTATION 599
⇒ F(x) =
1
6
[(27 – x3 – 27x + 9x2) (16.8) – 64.8 (3 – x) + 12x – 24]
=
1
6
[– 16.8x3 + 151.2x2 – 376.8x + 235.2]
= – 2.8x3 + 25.2x2 – 62.8x + 39.2
Therefore, cubic splines in different intervals are tabulated as below:
Interval Cubic spline
[0, 1] 0.8x3 – 8.8x + 2
[1, 2] 2x3 – 3.6x2 – 5.2x + 0.8
[2, 3] – 2.8x3 + 25.2x2 – 62.8x + 39.2.
Example 2. Obtain the cubic spline for every subinterval from the given data:
x: 0 1 2 3
f(x): 1 2 33 244
with the end conditions M0 = M3 = 0. Hence find an estimate of f(2.5).
Sol. For the interval (xi–1, xi), the cubic spline is
F(x) =
1
6h
[(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
+ (x – xi–1) {6fi – h2Mi}] (66)
For i = 1, 2,......., n, we have
h2 [Mi–1 + 4Mi + Mi+1] = 6[fi+1 – 2fi + fi–1] (67)
and M0 = M3 = 0 (68)
Here h = 1
∴ From (67), For 0 ≤ x ≤ 1,
M0 + 4M1 + M2 = 6(f2 – 2f1 + f0) (69)
and for 1 ≤ x ≤ 2,
M1 + 4M2 + M3 = 6(f3 – 2f2 + f1) (70)
From (69), we get
M0 + 4M1 + M2 = 6[33 – 4 + 1] = 180 (71)
and M1 + 4M2 + M3 = 6[244 – 66 + 2] = 1080 (72)
Using (68), equations (71) and (72) reduce to
4M1 + M2 = 180
and M1 + 4M2 = 1080
600 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Solving, we get
M1 = – 24 and M2 = 276 (73)
Hence for 0 ≤
≤
≤
≤
≤ x ≤
≤
≤
≤
≤ 1,
F(x) =
1
6
[(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) {6f0 – M0}
+ (x – 0) {6f1 – M1}] | ∵ h = 1
=
1
6
[x3 (– 24) + (1 – x) {6} + x(12 + 24)]
=
1
6
[– 24x3 + 6 – 6x + 36x] = – 4x3 + 5x + 1
For 1 ≤ x ≤ 2,
F(x) =
1
6
[(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1}
+ (x – 1) {6f2 – M2}]
=
1
6
[(2 – x)3 (– 24) + (x – 1)3 (276) + (2 – x) (12 + 24)
+ (x – 1) {198 – 276}]
=
1
6
[(2 – x)3 (– 24) + 276 (x – 1)3 + 36(2 – x) – 78(x – 1)]
= 50x3 – 162 x2 + 167 x – 53
For 2 ≤ x ≤ 3,
F(x) =
1
6
[(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) (6f2 – M2)
+ (x – 2) (6f3 – M3)]
=
1
6
[(3 – x)3 (276) + (x – 2)3 (0) + (3 – x) (198 – 276)
+ (x – 2) {(6 × 244) – 0}]
=
1
6
[(27 – x3 – 27x + 9x2) (276) + (3 – x) (– 78) + 1464 (x – 2)]
= – 46x3 + 414x2 – 985x + 715
Therefore, the cubic splines in different intervals are tabulated as below:
Interval Cubic Spline
[0, 1] – 4x3 + 5x + 1
[1, 2] 50x3 – 162x2 + 167x – 53
[2, 3] – 46x3 + 414x2 – 985x + 715
STATISTICAL COMPUTATION 601
An estimate at x = 2.5 is
f(2.5) = – 46 (2.5)3 + 414(2.5)2 – 985 (2.5) + 715 = 121.25.
7.35 APPROXIMATIONS
The problem of approximating a function is an important problem in numerical
analysis due to its wide application in the development of software for digital
computers. The functions commonly used for approximating given functions
are polynomials, trigonometric functions, exponential functions, and rational
functions. However, from an application point of view, the polynomial functions
are mostly used.
7.36 LEGENDRE AND CHEBYSHEV POLYNOMIALS
In the theory of approximation of functions, we often use the well known
orthogonal polynomials, Legendre and Chebyshev polynomials, as the
coordinate functions while applying the method of least squares.
Chebyshev polynomials are also used in the economization of power series.
7.37 LEGENDRE POLYNOMIALS
Pn(x) is a Legendre polynomial in x of degree n and satisfies the Legendre
differential equation
(1 – x2)
d y
dx
x
dy
dx
n n y
2
2
2 1 0
− + + =
( )
we have Pn(– x) = (– 1)n Pn(x).
From this, we conclude that Pn(x) is an even function of x if n is even and an
odd function of x if n is odd.
Legendre polynomials satisfy the recurrence relation
(n + 1) Pn+1 (x) = (2n + 1) xPn(x) – nPn–1(x)
P0(x) = 1, P1(x) = x
we have
Pn(x) =
13 5 2 1 1
2 2 1
1 2 3
2 4 2 1 2 3
2 4
. . ...... ( )
!
( )
( )
( )( )( )
. .( ) ( )
......
n
n
x
n n
n
x
n n n n
n n
x
n n n
−
−
−
−
+
− − −
− −
−
L
NM O
QP
− −
602 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
In particular,
P2(x) =
3 1
2
2
x −
, P3(x) =
5 3
2
3
x x
−
P4(x) =
35 30 3
8
4 2
x x
− +
, P5(x) =
63 70 15
8
5 3
x x x
− +
Legendre polynomials Pn(x) are orthogonal on the interval [– 1, 1] with
respect to the weight function W(x) = 1
We have
–1
( ) ( )
1
z P P
m n
x x dx =
0
2
2 1
,
,
if
if
m n
n
m n
≠
+
≠
R
S
|
T
|
U
V
|
W
|
7.38 CHEBYSHEV POLYNOMIALS
The Chebyshev polynomial of first kind of degree n over the interval [– 1, 1] is
denoted by Tn(x) and is defined by the relation
Tn(x) = cos (n cos–1 x) = cos nθ
where θ = cos–1 x or x = cos θ
we have, T0(x) = 1 and T1(x) = x
The Chebyshev polynomial of second kind of degree n over the interval
[– 1, 1] is denoted by Un(x) and is defined by the relation
Un(x) = sin (n cos–1 x) = sin nθ
where θ = cos–1 x or x = cos θ
1. Chebyshev’s polynomials are also known as Tchebichef or Tchebicheff
or Tchebysheff.
2. Sometimes the Chebyshev polynomial of the second kind is defined by
Un(x) =
sin {(n 1) cos x}
1 x
U (x)
1 x
1
2
n 1
2
+
−
=
−
−
+
.
NOTE
STATISTICAL COMPUTATION 603
7.39 SPECIAL VALUES OF CHEBYSHEV POLYNOMIALS
T0 (x) = cos 0 = 1
T1 (x) = cos (cos–1 x) = x
T2 (x) = cos (2 cos–1 x) = 2 cos2 (cos–1 x) – 1 = 2x2 – 1
T3 (x) = cos (3 cos–1 x) = 4 cos3 (cos–1 x) – 3 cos (cos–1 x) = 4x3 – 3x
T4 (x) = cos (4 cos–1 x) = 2 cos2 (2 cos–1 x) – 1
= 2 (2x2 – 1)2 – 1 = 8x4 – 8x2 + 1
T5(x) = cos (5 cos–1 x) = cos (3 cos–1 x) cos (2 cos–1 x)
– sin (3 cos–1 x) sin (2 cos–1 x)
= 16x5 – 20x3 + 5x
Similarly, T6 (x) = 32x6 – 48x4 + 18x2 – 1 and so on.
7.40 ORTHOGONAL PROPERTIES
To prove:
(1)
−
z −
=
≠
= ≠
= =
R
S
|
T
|
U
V
|
W
|
1
1
2
1
0
2 0
0
T T
if
/ if
if
n m
x x
x
dx
m n
m n
m n
( ) ( )
;
;
;
π
π
(2)
−
z −
=
≠
= ≠
= =
R
S
|
T
|
U
V
|
W
|
1
1
2
1
0
2 0
0 0
U U
if
/ if
if
n m
x x
x
dx
m n
m n
m n
( ) ( )
;
;
;
π .
7.41 RECURRENCE RELATIONS
1. Tn+1 (x) – 2x Tn(x) + Tn–1(x) = 0.
2. (1 – x2) Tn′(x) = – nxTn(x) + n Tn–1(x).
3. Un+1(x) – 2x Un(x) + Un–1(x) = 0.
4. (1 – x2) Un′(x) = – nx Un(x) + nUn–1(x).
604 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.42 ALITER TO FIND CHEBYSHEV POLYNOMIALS
The recurrence relation
Tn + 1(x) = 2x Tn (x) – Tn–1(x) (74)
Can also be used to compute all Tn(x) successively since we know T0(x) and
T1(x).
T0(x) = 1, T1(x) = x
Given n = 1 in (74), we have
T2(x) = 2xT1(x) – T0(x) = 2x2 – 1
Given n = 2 in (74), we get
T3 (x) = 2x T2(x) – T1(x) = 2x (2x2– 1) – x = 4x3 – 3x
Given n = 3 in (74), we get
T4 (x) = 2x T3(x) – T2(x) = 2x (4x3 – 3x) – (2x2 – 1)
= 8x4 – 6x2 – 2x2 + 1 = 8x4 – 8x2 + 1
Given n = 4 in (74), we get
T5 (x) = 2x T4(x) – T3(x) = 2x (8x4 – 8x2 + 1) – (4x3 – 3x)
= 16x5 – 20x3 + 5x
Similarly, T6 (x) = 2x T5(x) – T4(x)
= 2x (16x5 – 20x3 + 5x) – (8x4 – 8x2 + 1)
= 32x6 – 48x4 + 18x2 – 1.
7.43 EXPRESSION OF POWERS OF X INTERMS OF CHEBYSHEV
POLYNOMIALS
1 = T0(x)
x = T1(x)
x2 =
1
2
[T0(x) + T2(x)]
x3 =
1
4
[3 T1(x) + T3(x)]
x4 =
1
8
[3 T0(x) + 4T2(x) + T4(x)]
STATISTICAL COMPUTATION 605
x5 =
1
16
[10 T1(x) + 5T3(x) + T5(x)]
x6 =
1
32
[10 T0(x) + 15T2(x) + 6T4(x) + T6(x)]
and so on.
The above expressions will be useful in the economization of power series.
7.44 PROPERTIES OF CHEBYSHEV POLYNOMIALS
(i) Tn(x) is a polynomial of degree n. We have Tn(– x) = (– 1)n Tn(x) so that
Tn(x) is an even function of x if n is even and it is an odd function of x if
n is odd.
(ii) Tn(x) has n simple zeros.
xk = cos
2 1
2
k
n
−
F
HG I
KJ
π , k = 1, 2, ......, n on the interval [– 1, 1]
(iii) Tn(x) assumes extreme values at (n + 1) points xk = cos
k
n
π
, k = 0, 1, 2,
......, n and the extreme value at xk is (– 1)k.
(iv) | Tn(x) | ≤ 1, x ∈ [– 1, 1]
(v) Tn(x) are orthogonal on the interval [– 1, 1] with respect to the weight
function
W(x) =
1
1 2
− x
(vi) If pn(x) is any monic polynomial of degree n and
~
( )
( )
T
T
n
n
n
x
x
= −
2 1 is the
monic Chebyshev polynomial, then
max |
~
( )| max | ( )|
− ≤ ≤ − ≤ ≤
≤
1 1 1 1
x
n
x
n
x p x
T .
7.45 CHEBYSHEV POLYNOMIAL APPROXIMATION
Let f(x) be a continuous function defined on the interval [– 1, 1] and let c0 + c1x
+ c2x2 + ...... + cnxn be the required minimax (or uniform) polynomial
approximation for f(x).
606 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Suppose f(x) =
a
a x
i
i i
0
1
2
+
=
∞
∑ T ( ) is the Chebyshev series expansion for f(x).
Then the truncated series or the partial sum
Pn(x) =
a
a x
i
n
i i
0
1
2
+
=
∑ T ( ) (75)
is very nearly the solution to the problem
max ( ) min ( )
− ≤ ≤
=
− ≤ ≤
=
− = −
∑ ∑
1 1
0
1 1
0
x
i
n
i
i
x
i
n
i
i
f x c x f x c x
i.e., the partial sum (75) is nearly the best uniform approximation to f(x).
Reason. Suppose we write
f(x) =
a0
2
+ a1T1(x) + a2T2(x) + ...... + anTn(x) + an + 1Tn + 1(x) + remainder
(76)
Neglecting the remainder, we obtain from (76),
f(x) –
a
a x
i
n
i i
0
1
2
+
L
N
MM
O
Q
PP
=
∑ T ( ) = an+1Tn+1(x) (77)
Since Tn + 1 (x) has n + 2 equal maxima and minima which alternate in sign,
therefore by Chebyshev equioscillation theorem, the polynomial (75) of degree
n is the best uniform approximation to f(x).
7.46 LANCZOS ECONOMIZATION OF POWER SERIES FOR A
GENERAL FUNCTION
First we express the given function f(x) as a power series in x in the form
f(x) =
i
i
i
a x
=
∞
∑
0
, – 1 ≤ x ≤ 1 (78)
Then we change each power of x in (78) in terms of Chebyshev polynomials
and we obtain
f(x) =
i
i i
c x
=
∞
∑
0
T ( ) (79)
STATISTICAL COMPUTATION 607
as the Chebyshev series expansion for f(x) on [– 1, 1]. It has been found that for
a large number of functions f(x), the series (79) converges more rapidly than
the power series given by eqn. (78). If we truncate series (79) at Tn(x), then the
partial sum
Pn(x) =
i
n
i i
c x
=
∑
0
T ( ) (80)
is a good uniform approximation to f(x) in the sense
max
− ≤ ≤
1 1
x
| f(x) – Pn(x) | ≤ | cn + 1 | + | cn + 2 | + ...... ≤ ε (say)
For a given ε, it is possible to find the number of terms that should be
retained in eqn. (80). This process is known as Lanczos Economization.
Replacing each Ti(x) in eqn. (80) by its polynomial form and rearranging the
terms, we get the required economized polynomial approximation for f(x).
EXAMPLES
Example 1. Prove that
1 x2
− Tn(x) = Un + 1 (x) – x Un(x).
Sol. If x = cos θ, we get
Tn (cos θ) = cos nθ
and Un (cos θ) = sin nθ
Then we are to prove,
sin θ cos nθ = sin (n + 1)θ – cos θ sin nθ
Now, R.H.S. = sin nθ cos θ + cos nθ sin θ – cos θ sin nθ
= sin θ cos nθ = L.H.S.
Example 2. Find the best lower order approximation to the cubic 2x3 + 3x2.
Sol. We know that
x3 =
1
4
[3T1(x) + T3(x)]
2x3 + 3x2 = 2
1
4
{3 ( ) ( )}
T T
1 3
x x
+
L
NM O
QP + 3x2
=
3
2
1
2
3 2
T T
1 3
( ) ( )
x x x
+ + = 3x2 +
3
2
1
2
x x
+ T3 ( )
[∵ T1(x) = x]
608 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since | T3(x) | ≤ 1, – 1 ≤ x ≤ 1 therefore, the polynomial 3x2 +
3
2
x is the
required lower order approximation to the given cubic with a max. error ±
1
2
in
range [– 1, 1].
Example 3. Express 2 T0 (x) –
1
4
T2 (x) +
1
8
T4 (x) as polynomials in x.
Sol. 2T0 (x) –
1
4
T2 (x) +
1
8
T4 (x)
= 2 (1)
1
4
− − + − +
( ) ( )
2 1
1
8
8 8 1
2 4 2
x x x
= − + + − +
2
1
2
1
4
1
8
2 4 2
x x x
= x x
4 2
3
4
19
8
− + .
Example 4. Express 1 – x2 + 2x4 as sum of Chebyshev polynomials.
Sol. 1 – x2 + 2x4 = 1 – x2 + 2
1
8
4
{3 ( ) ( ) ( )}
T T T
0 2 4
x x x
+ +
L
NM O
QP
= 1 – x2 +
3
4
1
4
T T T
0 2 4
( ) ( ) ( )
x x x
+ +
= 1
1
2
3
4
1
4
− + + + +
[ ( ) ( )] ( ) ( ) ( )
T T T T T
0 2 0 2 4
x x x x x
= T T T T T T
0 0 2 0 2 4
( ) ( ) ( ) ( ) ( ) ( )
x x x x x x
− − + + +
1
2
1
2
3
4
1
4
=
5
4
T T T
0 2 4
( ) ( ) ( )
x x x
+ +
1
2
1
4
.
Example 5. Economize the power series: sin x ≈ x
x
6
x
120
x
5040
3 5 7
− + − + ...... to
three significant digit accuracy.
Sol. The truncated series is
sin x ≈ x
x x
− +
3 5
6 120
(81)
STATISTICAL COMPUTATION 609
which is obtained by truncating the last term since
1
5040
= 0.000198 will produce
a change in the fourth decimal place only.
Converting the powers of x in (81) into Chebyshev polynomials, we get
sin x ≈ T
1
6
T T T T T
1 1 3 1 3 5
( ) {3 ( ) ( )} { ( ) ( ) ( )}
x x x x x x
− +
L
NM O
QP+ + +
L
NM O
QP
1
4
1
120
1
16
10 5
≈ T
1
24
T T T T T
1 1 3 1 3 5
( ) [3 ( ) ( )] [ ( ) ( ) ( )]
x x x x x x
− + +
×
+ +
1
120 16
10 5
≈
169
192
5
128
1
1920
T T T
1 3 5
( ) ( ) ( )
x x x
− +
Truncated series is
sin x ≈
169
192
5
128
T T
1 3
( ) ( )
x x
−
which is obtained by truncating the last term since
1
1920
= 0.00052 will pro-
duce a change in the fourth decimal place only.
Economized series is
sin x ≈
169
192
5
128
x − (4x3 – 3x)
=
383
384
5
32
3
x x
− = 0.9974x – 0.1526x3
which gives sin x to three significant digit accuracy.
Example 6. Using the Chebyshev polynomials, obtain the least squares
approximation of second degree for f(x) = x4 on [– 1, 1].
Sol. Let f(x) ≈ P(x) = C0T0(x) + C1T1(x) + C2T2(x)
We have
U(C0, C1, C2) =
−
z −
1
1
2
1
1 x
(x4 – C0T0 – C1T1 – C2T2)2 dx
which is to be minimum.
Normal equations are given by
∂
∂
U
C0
= 0 ⇒
−
z − − −
−
1
1
4
2
1
( )
x
x
dx
C T C T C T
T
0 0 1 1 2 2
0
= 0
610 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∂
∂
U
C1
= 0 ⇒
−
z − − −
−
1
1
4
2
1
( )
x
x
dx
C T C T C T
T
0 0 1 1 2 2
1
= 0
and
∂
∂
U
C2
= 0 ⇒
−
z − − −
−
1
1
4
2
1
( )
x
x
dx
C T C T C T
T
0 0 1 1 2 2
2
= 0
We find that
C0 =
1
1
3
8
1
1
2
π −
z −
=
x
x
dx
4
0
T
C1 =
2
1
0
1
1
2
π −
z −
=
x
x
dx
4
1
T
C2 =
2
1
1
2
1
1
2
π −
z −
=
x
x
dx
4
2
T
Hence the required approximation is f(x) =
3
8
1
2
T T
0 2
+ .
Example 7. Find a uniform polynomial approximation of degree four or less
to ex on [– 1, 1] using Lanczos economization with a tolerance of ε = 0.02.
Sol. We have
f(x) = ex = 1 + x +
x x x x
2 3 4 5
2 6 24 120
+ + + + ......
Since
1
120
0 008
= . ......, therefore
ex = 1 + x +
x x x
2 3 4
2 6 24
+ + (82)
with a tolerance of ε = 0.02.
Changing each power of x in (82) in terms of Chebyshev polynomials, we
get
ex = T0 + T1 +
1
4
(T0 + T2) +
1
24
(3T1 + T3) +
1
192
(3T0 + 4T2 + T4)
=
81
64
9
8
13
48
1
24
1
192
T T T T T
0 1 2 3 4
+ + + + (83)
STATISTICAL COMPUTATION 611
We have
1
192
= 0.005 ......
∴ The magnitude of last term on R.H.S. of (83) is less than 0.02.
Hence the required economized polynomial approximation for ex is given
by
ex =
81
64
9
8
13
48
1
24
T T T T
0 1 2 3
+ + +
or ex =
x
x x
3
2
6
13
24
191
192
+ + + .
Example 8. The function f is defined by
f(x) =
1
x
1 e
t
dt
0
x t
2
2
z − −
Approximate f by a polynomial P(x) = a + bx + cx2 such that
max.
x 1
| | ≤
| f(x) – P(x) | ≤ 5 × 10–3.
Sol. The given function
f(x) =
1
1
2 6 24 120 720
0
2 4 6 8 10
x
t t t t t
dt
x
z − + − + − +
F
HG
I
KJ
......
= 1
6 30 168 1080 7920
2 4 6 8 10
− + − + − +
x x x x x
...... (84)
The tolerable error is 5 × 10–3 ≈ 0.005.
Truncating the series (84) at x8, we get
P(x) = 1
6 30 168 1080
2 4 6 8
− + − +
x x x x
= T0 –
1
12
(T2 + T0) +
1
240
(T4 + 4T2 + 3T0)
–
1
5376
(T6 + 6T4 + 15T2 + 10T0)
+
1
138240
(T8 + 8T6 + 28T4 + 56T2 + 35T0)
612 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
= 0.92755973 T0 – 0.06905175 T2 + 0.003253 T4
– 0.000128 T6 + 0.000007 T8 (85)
Truncating R.H.S. of (85) at T2, we obtain the required polynomial
P(x) = 0.92755973 T0 – 0.06905175 T2
= 0.99661148 – 0.13810350x2
= 0.9966 – 0.1381x2
The maximum absolute error in the neglected terms is obviously less than
the tolerable error.
ASSIGNMENT 7.4
1. Express 1 + x – x2 + x3 as sum of Chebyshev polynomials.
2. Prove that x2 =
1
2
[T0(x) + T2(x)]
3. Express T0(x) + 2T1(x) + T2(x) as polynomials in x.
4. Obtain the best lower degree approximation to the cubic x3 + 2x2.
5. Explain how to fit a function of the form
y = A A
1 2
e e
x x
λ λ
1 2
+
to the given data.
6. Obtain y(1.5) from the following data using cubic spline.
x: 1 2 3
y: – 8 – 1 18
7. Economize the series
f(x) = 1
2 8 16
2 3
− − −
x x x
8. Economize the series sinh x = x
x x x
+ + +
3 5 7
6 120 5040
on the interval [– 1, 1] allowing for a
tolerance of 0.0005.
9. Economize the series cos x = 1
2 24 720
2 4 6
− + −
x x x
.
10. Obtain the cubic spline approximation valid in [3, 4], for the function given in the tabu-
lar form
x: 1 2 3 4
f(x): 3 10 29 65
under the natural spline conditions:
M(1) = 0 = M(4)
STATISTICAL COMPUTATION 613
11. Obtain the cubic spline fit for the data
x: 0 1 2 3
f(x): 1 4 10 8
under the end conditions f″(0) = 0 = f ″(3) and valid in the interval [1, 2].
Hence obtain the estimate of f(1.5).
12. Fit the following four points by the cubic splines:
x: 1 2 3 4
y: 1 5 11 8
Use the end conditions y″(1) = 0 = y″(4). Hence compute y(1.5).
13. Find the natural cubic spline that fits the data
x: 1 2 3 4
f(x): 0 1 0 0
14. Find whether the following functions are splines or not?
(i) f(x) =
− − − ≤ ≤
− + ≤ ≤
U
V
|
W
|
x x x
x x x
2 3
2 3
2 1 0
2 0 1
,
,
(ii) f(x) =
− − − ≤ ≤
+ ≤ ≤
U
V
|
W
|
x x x
x x x
2 3
2 3
2 1 0
2 0 1
,
,
[Hint: Check the continuity of f(x), f ′(x) and f″(x) at x = 0]
15. Find the values of α and β such that the function
f(x) =
x x x
x x
2
1 1 2
3 2 3
− + ≤ ≤
− ≤ ≤
R
S
T
U
V
W
α
β
,
,
is a quadratic spline. [Hint: For f(x) to be continuous at x = 2, 5 – 2α = 6 – β
and For f′(x) to be continuous at x = 2, 4 – α = 3]
16. We are given the following values of a function of the variable t:
t: 0.1 0.2 0.3 0.4
f: 0.76 0.58 0.44 0.35
Obtain a least squares fit of the form
f = ae–3t + be–2t.
17. Evaluate
I =
1
1
0
1
+
z x
dx using the cubic spline method.
18. Explain approximation of function by Taylor series by taking suitable example.
614 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.47 REGRESSION ANALYSIS
The term ‘regression’ was first used by Sir Francis Galton (1822–1911), a British
biometrician in connection with the height of parents and their offspring. He
found that the offspring of tall or short parents tend to regress to the average
height. In other words, though tall fathers do tend to have tall sons, the average
height of tall fathers is more than the average height of their sons and the
average height of short fathers is less than the average height of their sons.
The term ‘regression’ stands for some sort of functional relationship between
two or more related variables. The only fundamental difference, if any, between
problems of curve-fitting and regression is that in regression, any of the variables
may be considered as independent or dependent while in curve-fitting, one
variable cannot be dependent.
Regression measures the nature and extent of correlation. Regression is
the estimation or prediction of unknown values of one variable from known
values of another variable.
7.48 CURVE OF REGRESSION AND REGRESSION EQUATION
If two variates x and y are correlated, i.e., there exists an association or
relationship between them, then the scatter diagram will be more or less
concentrated round a curve. This curve is called the curve of regression and the
relationship is said to be expressed by means of curvilinear regression.
The mathematical equation of the regression curve is called regression
equation.
7.49 LINEAR REGRESSION
When the points of the scatter diagram concentrate round a straight line, the
regression is called linear and this straight line is known as the line of regression.
The regression will be called non-linear if there exists a relationship other
than a straight line between the variables under consideration.
7.50 LINES OF REGRESSION
A line of regression is the straight line which gives the best fit in the least
square sense to the given frequency.
In case of n pairs (xi, yi); i = 1, 2, ..., n from a bivariate data, we have no
reason or justification to assume y as a dependent variable and x as an
STATISTICAL COMPUTATION 615
independent variable. Either of the two may be estimated for the given values
of the other. Thus, if we wish to estimate y for given values of x, we shall have
the regression equation of the form y = a + bx, called the regression line of y on
x. If we wish to estimate x for given values of y, we shall have the regression
line of the form x = A + By, called the regression line of x on y.
Thus it implies, in general, we always have two lines of regression.
If the line of regression is so chosen that the sum of the squares of deviation
parallel to the axis of y is minimized [See Figure (a)], it is called the line of
regression of y on x and it gives the best estimate of y for any given value of x.
If the line of regression is so chosen that the sum of the squares of deviations
parallel to the axis of x is minimized [See Figure (b)], it is called the line of
regression of x on y and it gives the best estimate of x for any given value of y.
A
B
Y
O X
H(x , y )
i i
P (x , y )
i i i
A
B
Y
O X
H(x , y )
i i
P (x , y )
i i i
FIGURE (a) FIGURE (b)
The independent variable is called the predictor or Regresser or Explanator
and the dependent variable is called the predictant or Regressed or Explained
variable.
7.51 DERIVATION OF LINES OF REGRESSION
7.51.1 Line of Regression of y on x
To obtain the line of regression of y on x, we shall assume y as dependent
variable and x as independent variable.
Let y = a + bx be the equation of regression line of y on x.
The residual for ith point is Ei = yi – a – bxi.
Introduce a new quantity U such that
U = Ei
i
n
2
1
=
∑ = ( )
y a bx
i i
i
n
− −
=
∑ 2
1
(86)
616 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
According to the principle of Least squares, the constants a and b are chosen
in such a way that the sum of the squares of residuals is minimum.
Now, the condition for U to be maximum or minimum is
∂
∂
U
a
= 0 and
∂
∂
U
b
= 0
From (86),
∂
∂
U
a i
n
=
=
∑
2
1
(yi – a – bxi)(– 1)
∂
∂
U
a
= 0 gives 2
i
n
=
∑
1
(yi – a – bxi)(– 1) = 0
⇒ Σy = na + b Σx (87)
Also,
∂
∂
U
b
y a bx x
i
n
i i i
= − − −
=
∑
2
1
( )( )
∂
∂
U
b
= 0 gives 2
i
n
=
∑
1
(yi – a – bxi)(– xi) = 0
⇒ Σxy = a Σx + b Σx2 (88)
Equations (87) and (88) are called normal equations.
Solving (87) and (88) for ‘a’ and ‘b’, we get
b =
Σ Σ Σ
Σ Σ
Σ Σ Σ
Σ Σ
xy
n
x y
x
n
x
n xy x y
n x x
−
−
=
−
−
1
1
2 2
2 2
( ) ( )
(89)
and a =
Σ Σ
y
n
b
x
n
y bx
− = − (90)
Eqn. (90) gives y a bx
= +
Hence y = a + bx line passes through point ( , )
x y .
Putting a = y bx
− in equation of line y = a + bx, we get
y – y b x x
= −
( ) (91)
Equation (91) is called regression line of y on x. ‘b’ is called the regression
coefficient of y on x and is usually denoted by byx.
STATISTICAL COMPUTATION 617
Hence eqn. (91) can be rewritten as
y – y b x x
yx
= −
( )
where x y
and are mean values while
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
In equation (88), shifting the origin to ( , )
x y , we get
Σ(x – x )(y – y) = a Σ(x – x ) + b(x – x )2
⇒ nr σxσy = a(0) + bnσx
2
∵ Σ
Σ
Σ
( )
( )
( )( )
x x
n
x x
x x y y
n
r
x
x y
− =
− =
− −
=
0
1 2 2
σ
σ σ
and
⇒ b = r
σ
σ
y
x
Hence regression coefficient byx can also be defined as
byx = r
σ
σ
y
x
where r is the coefficient of correlation, σx and σy are the standard deviations
of x and y series respectively.
7.51.2 Line of Regression of x on y
Proceeding in the same way as 7.16.1, we can derive the regression line of x on
y as
x – x = bxy(y – y)
where bxy is the regression coefficient of x on y and is given by
bxy =
n xy x y
n y y
Σ Σ Σ
Σ Σ
−
−
2 2
( )
or bxy = r
σ
σ
x
y
where the terms have their usual meanings.
618 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
If r = 0, the two lines of regression become y = y and x = x which are two
straight lines parallel to x and y axes respectively and passing through
their means y and x . They are mutually perpendicular. If r = ± 1, the two
lines of regression will coincide.
7.52 USE OF REGRESSION ANALYSIS
(i) In the field of Business, this tool of statistical analysis is widely used.
Businessmen are interested in predicting future production, consumption,
investment, prices, profits and sales etc.
(ii) In the field of economic planning and sociological studies, projections of
population, birth rates, death rates and other similar variables are of great
use.
7.53 COMPARISON OF CORRELATION AND REGRESSION ANALYSIS
Both the correlation and regression analysis helps us in studying the relation-
ship between two variables yet they differ in their approach and objectives.
(i) Correlation studies are meant for studying the covariation of the two
variables. They tell us whether the variables under study move in the same
direction or in reverse directions. The degree of their covariation is also
reflected in the correlation co-efficient but the correlation study does not
provide the nature of relationship. It does not tell us about the relative
movement in the variables and we cannot predict the value of one variable
corresponding to the value of other variable. This is possible through
regression analysis.
(ii) Regression presumes one variable as a cause and the other as its effect.
The independent variable is supposed to be affecting the dependent variable
and as such we can estimate the values of the dependent variable by
projecting the relationship between them. However, correlation between
two series is not necessarily a cause-effect relationship.
(iii) Coefficient of correlation cannot exceed unity but one of the regression
coefficients can have a value higher than unity but the product of two
regression coefficients can never exceed unity.
NOTE
STATISTICAL COMPUTATION 619
7.54 PROPERTIES OF REGRESSION CO-EFFICIENTS
Property I. Correlation co-efficient is the geometric mean between the
regression co-efficients.
Proof. The co-efficients of regression are
r r
y
x
x
y
σ
σ
σ
σ
and .
Geometric mean between them =
r r
r
y
x
x
y
σ
σ
σ
σ
× = 2
= r = co-efficient of
correlation.
Property II. If one of the regression co-efficients is greater than unity,
the other must be less than unity.
Proof. The two regression co-efficients are byx =
r
b
r
y
x
xy
x
y
σ
σ
σ
σ
and = .
Let byx  1, then
1
1
byx
 (92)
Since byx. bxy = r2 ≤ 1 (∵ – 1 ≤ r ≤ 1)
∴ bxy ≤
1
1
byx
 . | using (92)
Similarly, if bxy  1, then byx  1.
Property III. Arithmetic mean of regression co-efficients is greater
than the correlation co-efficient.
Proof. We have to prove that
b b
yx xy
+
2
 r
or r r
y
x
x
y
σ
σ
σ
σ
+  2r
or σx
2 + σy
2  2σxσy
or (σx – σy)2  0 which is true.
Property IV. Regression co-efficients are independent of the origin
but not of scale.
Proof. Let u =
x a
h
v
y b
k
–
, =
−
, where a, b, h and k are constants
byx =
r
r
k
h
k
h
r k
h
b
y
x
v
u
v
u
vu
σ
σ
σ
σ
σ
σ
= =
F
HG
I
KJ =
.
620 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Similarly, bxy =
h
k
buv.
Thus, byx and bxy are both independent of a and b but not of h and k.
Property V. The correlation co-efficient and the two regression co-
efficients have same sign.
Proof. Regression co-efficient of y on x = byx = r
σ
σ
y
x
Regression co-efficient of x on y = bxy = r
σ
σ
x
y
Since σx and σy are both positive; byx, bxy and r have same sign.
7.55 ANGLE BETWEEN TWO LINES OF REGRESSION
If θ is the acute angle between the two regression lines in the case of two variables
x and y, show that
tan θ =
1 r
r
2
x y
x
2
y
2
−
+
.
σ σ
σ σ
, where r, σx, σy have their usual meanings.
Explain the significance of the formula when r = 0 and r = ± 1.
Proof. Equations to the lines of regression of y on x and x on y are
y y
r
x x
y
x
− = −
σ
σ
( ) and x x
r
y y
x
y
− = −
σ
σ
( )
Their slopes are m1 =
r y
x
σ
σ
and m2 =
σ
σ
y
x
r
.
∴ tan θ = ±
m m
m m
r
r
y
x
y
x
y
x
2 1
2 1
2
2
1
1
−
+
= ±
−
+
σ
σ
σ
σ
σ
σ
= ±
1 1
2 2
2 2
2
2 2
−
+
= ±
−
+
r
r
r
r
y
x
x
x y
x y
x y
. . .
σ
σ
σ
σ σ
σ σ
σ σ
Since r2 ≤ 1 and σx, σy are positive.
∴ +ve sign gives the acute angle between the lines.
STATISTICAL COMPUTATION 621
Hence tan θ =
1 2
2 2
−
+
r
r
x y
x y
.
σ σ
σ σ
when r = 0, θ =
π
2
∴ The two lines of regression are perpendicular to each
other.
Hence the estimated value of y is the same for all values of x and vice-
versa.
When r = ± 1, tan θ = 0 so that θ = 0 or π
Hence the lines of regression coincide and there is perfect correlation
between the two variates x and y.
7.56 ALGORITHM FOR LINEAR REGRESSION
1. Read n
2. sum x ← 0
3. sum xsq ← 0
4. sum y ← 0
5. sum xy ← 0
6. for i = 1 to n do
7. Read x,y
8. sum x ← sum x + x
9. sum xsq ← sum xsq + x2
10. sum y ← sum y + y
11. sum xy ← sum xy + x × y
end for
12. denom ← n × sum x sq - sum x × sum x
13. a ← (sum y × sum x sq - sum x × sum xy)/denom
14. b ← (n × sum xy - sum x × sum y)/denom
15. Write b,a
16. Stop
622 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.57 PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A
REGRESSION LINE OF Y ON X
#includestdio.h
#includeconio.h
#includemath.h
void main()
{
int data,i;
float x[10],y[10],xy[10],x2[10],z;
float sum1=0.0,sum2=0.0,sum3=0.0,sum4=0.0;
clrscr();
printf(Enter the number of data points:);
scanf(%d,data);
printf(Enter the value of x: n);
for(i=0;idata;i++)
{
printf(Value of x%d:,i+1);
scanf(%f,x[i]);
}
printf{nEnter the value of f(x):n};
for(i=0;idata;i++)
{
printf(Value of f(x%d):,i+1);
scanf(%f,y[i]);
}
for(i=0;idata;i++)
}
xy[i]=x[i]*y[i];
x2[i]=x[i]*x[i];
sum1 +=xy[i];
sum2 +=x2[i];
sum3 +=x[i];
sum4 +=y[i];
}
STATISTICAL COMPUTATION 623
sum3 =sum3/2;
sum4 =sum4/2;
//printf(%.2f %.2f %.2f, %.2f sum1,sum2,sum3,sum4);
sum1=(sum1/sum2);
z=(sum1*sum3)-sum4;
printf(nnThe REGRESSION LINE OF Y on X is:n);
printf(ttt y=%.2f *x - (%.2f),sum1,z);
getch(1);
}
7.58 PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A
REGRESSION LINE OF X ON Y
#includestdio.h
#includeconio.h
#includemath.h
void main()
{
int data,i;
float x[10],y[10],xy[10],y2[10],z;
float sumx=0.0,sumy=0.0,sumxy=0.0,sumy2=0.0;
clrscr();
printf(Enter the number of data points: );
scanf(%d,data);
printf(Enter the value of x: n);
for(i=0;idata;i++)
{
printf(Value of x%d: ,i+1);
scanf(%f,x[i]);
}
printf(nEnter the value of f(x): n);
for(i=0;idata; i++)
{
printf(Value of f(x%d):, i+1);
scanf(%f,y[i]);
}
624 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
for(i=0;idata;i++)
{
xy[i]=x[i]*y[i];
y2[i]=y[i]*y[i];
sumxy +=xy[i];
sumy2 +=y2[i];
sumx +=x[i];
sumy +=y[i];
}
sumx =sumx/2;
sumy =sumy/2;
sumxy=(sumxy/sumy2);
z=(sumxy*sumy)-sumx;
printf(nnThe REGRESSION LINE OF X on Y is:n);
printf(ttt x = %.2f *y - (%.2f),sumxy, z);
getch();
}
EXAMPLES
Example 1. If the regression coefficients are 0.8 and 0.2, what would be the
value of coefficient of correlation?
Sol. We know that,
r2 = byx . bxy = 0.8 × 0.2 = 0.16
Since r has the same sign as both the regression coefficients byx and bxy
Hence r = 0.16 = 0.4.
Example 2. Calculate linear regression coefficients from the following:
x → 1 2 3 4 5 6 7 8
y → 3 7 10 12 14 17 20 24
Sol. Linear regression coefficients are given by
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
and bxy =
n xy x y
n y y
Σ Σ Σ
Σ Σ
−
−
2 2
( )
STATISTICAL COMPUTATION 625
Let us prepare the following table:
x y x2 y2 xy
1 3 1 9 3
2 7 4 49 14
3 10 9 100 30
4 12 16 144 48
5 14 25 196 70
6 17 36 289 102
7 20 49 400 140
8 24 64 576 192
Σx = 36 Σy = 107 Σx2 = 204 Σy2 = 1763 Σxy = 599
Here n = 8
∴ byx =
( ) ( )
( ) ( )
8 599 36 107
8 204 36 2
× − ×
× −
=
4792 3852
1632 1296
940
336
−
−
= = 2.7976
and bxy =
( ) ( )
( ) ( )
8 599 36 107
8 1763 107
940
2655
2
× − ×
× −
= = 0.3540
Example 3. The following table gives age (x) in years of cars and annual
maintenance cost (y) in hundred rupees:
x: 1 3 5 7 9
y: 15 18 21 23 22
Estimate the maintenance cost for a 4 year old car after finding the regression
equation.
Sol.
x y xy x2
1 15 15 1
3 18 54 9
5 21 105 25
7 23 161 49
9 22 198 81
Σx = 25 Σy = 99 Σxy = 533 Σx2 = 165
626 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Here, n = 5
x
x
n
= =
Σ 25
5
= 5
y
y
n
= =
Σ 99
5
= 19.8
∴ byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
=
× − ×
× −
2 2 2
5 533 25 99
5 165 25
( )
( ) ( )
( ) ( )
= 0.95
Regression line of y on x is given by
y y b x x
yx
− = −
( )
⇒ y – 19.8 = 0.95 (x – 5)
⇒ y = 0.95x + 15.05
When x = 4 years, y = (0.95 × 4) + 15.05
= 18.85 hundred rupees = Rs. 1885.
Example 4. In a partially destroyed laboratory record of an analysis of a
correlation data, the following results only are eligible:
Variance of x = 9
Regression equations: 8x – 10y + 66 = 0, 40x – 18y = 214.
What were (a) the mean values of x and y (b) the standard deviation of y
and the co-efficient of correlation between x and y.
Sol. (a) Since both lines of regression pass through the point ( , )
x y
therefore, we have
8 10 66 0
x y
− + = (93)
40 18 214 0
x y
− − = (94)
Multiplying (93) by 5, 40 50 330 0
x y
− + = (95)
Subtracting (95) from (94), 32 544 0
y − =
∴ y = 17
∴ From (93), 8x – 170 + 66 = 0
or 8x = 104 ∴ x = 13
Hence x = 13, y = 17
(b) Variance of x = σx
2 = 9 (given)
∴ σx = 3
STATISTICAL COMPUTATION 627
The equations of lines of regression can be written as
y = .8x + 6.6 and x = .45y + 5.35
∴ The regression co-efficient of y on x is
r y
x
σ
σ
= .8 (96)
The regression co-efficient of x on y is
r x
y
σ
σ
= .45 (97)
Multiplying (96) and (97), r2 = .8 × .45 = .36 ∴ r = 0.6
(+ve sign with square root is taken because regression co-efficients are
+ve).
From (96), σy =
.8 .8 3
0.6
σx
r
=
×
= 4.
Example 5. The regression lines of y on x and x on y are respectively y = ax + b,
x = cy + d. Show that
σ
σ
y
x
a
c
= , x
bc d
1 ac
and y
ad b
1 ac
=
+
−
=
+
−
.
Sol. The regression line of y on x is
y = ax + b (98)
∴ byx = a
The regression line of x on y is
x = cy + d (99)
∴ bxy = c
We know that, byx = r
σ
σ
y
x
(100)
and bxy = r
σ
σ
x
y
(101)
Dividing eqn. (100) by (101), we get
b
b
yx
xy
y
x
=
σ
σ
2
2
⇒
a
c
a
c
y
x
y
x
= ⇒ =
σ
σ
σ
σ
2
2
Since both the regression lines pass through the point ( , )
x y therefore,
y ax b
= + and x cy d
= +
⇒ ax y b
− = − (102)
x cy d
− = (103)
628 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Multiplying equation (103) by a and then subtracting from (102), we get
(ac – 1) y ad b
= − − ⇒ y
ad b
ac
=
+
−
1
Similarly, we get x
bc d
ac
=
+
−
1
.
Example 6. For two random variables, x and y with the same mean, the two
regression equations are
y = ax + b and x = αy + β
Show that
b 1 a
1
β α
=
−
−
.
Find also the common mean.
Sol. Here, byx = a, bxy = α
Let the common mean be m, then regression lines are
y – m = a (x – m)
⇒ y = ax + m (1 – a) (104)
and x – m = α(y – m)
⇒ x = αy + m (1 – α) (105)
Comparing (104) and (105) with the given equations.
b = m (1 – a), β = m (1 – α)
∴
b a
β α
=
−
−
1
1
Again m =
b
a
1 1
−
=
−
β
α
Since regression lines pass through ( , )
x y
∴ x y
= +
α β
and y ax b
= + will hold.
⇒ m = am + b
m = αm + β
⇒ am + b = αm + β
⇒ m =
β
α
−
−
b
a
.
STATISTICAL COMPUTATION 629
Example 7. Obtain the line of regression of y on x for the data given below:
x: 1.53 1.78 2.60 2.95 3.42
y: 33.50 36.30 40.00 45.80 53.50.
Sol. The line of regression of y on x is given by
y – y b x x
yx
= −
( ) (106)
where byx is the coefficient of regression given by
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
Now we form the table as,
x y x2 xy
1.53 33.50 2.3409 51.255
1.78 36.30 2.1684 64.614
2.60 40.00 6.76 104
2.95 45.80 8.7025 135.11
3.42 53.50 11.6964 182.97
Σx = 12.28 Σy = 209.1 Σx2 = 32.6682 Σxy = 537.949
Here, n = 5
byx =
( ) ( )
( ) ( )
5 537.949 12.28 209.1
5 32.6682 12.28
121.997
12.543
2
× − ×
× −
= = 9.726
Also, mean x
x
n
= =
Σ 12.28
5
= 2.456
and y
y
n
= =
Σ 2091
.
5
= 41.82
∴ From (106), we get
y – 41.82 = 9.726(x – 2.456) = 9.726x – 23.887
y = 17.932 + 9.726x
which is the required line of regression of y on x.
Example 8. For 10 observations on price (x) and supply (y), the following data
were obtained (in appropriate units):
Σx = 130, Σy = 220, Σx2 = 2288, Σy2 = 5506 and Σxy = 3467
Obtain the two lines of regression and estimate the supply when the price is
16 units.
630 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. Here, n = 10, x
x
n
=
Σ
= 13 and y
y
n
=
Σ
= 22
Regression coefficient of y on x is
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
=
( ) ( )
( ) ( )
10 3467 130 220
10 2288 130 2
× − ×
× −
=
34670 28600
22880 16900
6070
5980
−
−
= = 1.015
∴ Regression line of y on x is
y – y b x x
yx
= −
( )
y – 22 = 1.015(x – 13)
⇒ y = 1.015x + 8.805
Regression coefficient of x on y is
bxy =
n xy x y
n y y
Σ Σ Σ
Σ Σ
−
−
2 2
( )
=
( ) ( )
( ) ( )
10 3467 130 220
10 5506 220
6070
6660
2
× − ×
× −
= = 0.9114
Regression line of x on y is
x – x b y y
xy
= −
( )
x – 13 = 0.9114(y – 22)
x = 0.9114y – 7.0508
Since we are to estimate supply (y) when price (x) is given therefore we are
to use regression line of y on x here.
When x = 16 units,
y = 1.015(16) + 8.805 = 25.045 units.
Example 9. The following results were obtained from records of age (x) and
systolic blood pressure (y) of a group of 10 men:
x y
Mean 53 142
Variance 130 165
and Σ(x – x )(y – y) = 1220
Find the approximate regression equation and use it to estimate the blood
pressure of a man whose age is 45.
STATISTICAL COMPUTATION 631
Sol. Given:
Mean x = 53
Mean y = 142
Variance σx
2 = 130
Variance σy
2 = 165
Number of men, n = 10
Σ(x – x )(y – y) = 1220
∴ Coefficient of correlation,
r =
Σ( )( )
x x y y
n x y
− −
σ σ
=
1220
10 130 165
×
=
122
146 458
.
= 0.83.
Since we are to estimate blood pressure (y) of a 45 years old man, we will
find regression line of y on x.
Regression coefficient byx = r
σ
σ
y
x
= ×
0 83
165
130
. = 0.935.
Regression line of y on x is given by
y – y b x x
yx
= −
( )
⇒ y – 142 = 0.935(x – 53) = 0.935x – 49.555
⇒ y = 0.935x + 92.445
when x = 45,
y = (0.935 × 45) + 92.445 = 134.52.
Hence the required blood pressure = 134.52.
Example 10. The following results were obtained from scores in Applied
Mechanics and Engineering Mathematics in an examination:
Applied Mechanics (x) Engineering Mathematics (y)
Mean 47.5 39.5
Standard Deviation 16.8 10.8
r = 0.95.
Find both the regression equations. Also estimate the value of y for x = 30.
Sol. x = 47.5, y = 39.5
σx = 16.8, σy = 10.8 and r = 0.95.
632 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Regression coefficients are
byx = r
σ
σ
y
x
= ×
0 95
10 8
16 8
.
.
.
= 0.6107
and bxy = r
σ
σ
x
y
= ×
0 95
16 8
10 8
.
.
.
= 1.477.
Regression line of y on x is
y – y b x x
yx
= −
( )
⇒ y – 39.5 = 0.6107 (x – 47.5) = 0.6107x – 29.008
y = 0.6107x + 10.49 (107)
Regression line of x on y is
x – x b y y
xy
= −
( )
⇒ x – 47.5 = 1.477 (y – 39.5)
⇒ x – 47.5 = 1.477y – 58.3415
x = 1.477y – 10.8415
Putting x = 30 in equation (107), we get
y = (0.6107)(30) + 10.49 = 18.321 + 10.49 = 28.81.
Example 11. From the following data. Find the most likely value of y when
x = 24:
y x
Mean 985.8 18.1
S.D. 36.4 2.0
r = 0.58.
Sol. Given: y = 985.8, x = 18.1, σy = 36.4, σx = 2, r = 0.58
Regression coefficient,
byx = r
σ
σ
y
x
= (0.58)
36 4
2
.
= 10.556.
Regression line of y on x is
y – y = byx(x – x )
⇒ y – 985.8 = 10.556(x – 18.1)
y – 985.8 = 10.556x – 191.06
STATISTICAL COMPUTATION 633
⇒ y = 10.556x + 794.73
when x = 24,
y = (10.556 × 24) + 794.73
y = 1048 (approximately).
Example 12. The equations of two regression lines, obtained in a correlation
analysis of 60 observations are:
5x = 6y + 24 and 1000y = 768x – 3608.
What is the correlation coefficient? Show that the ratio of coefficient of
variability of x to that of y is
5
24
. What is the ratio of variances of x and y?
Sol. Regression line of x on y is
5x = 6y + 24
x =
6
5
24
5
y +
∴ bxy =
6
5
(108)
Regression line of y on x is
1000y = 768x – 3608
y = 0.768x – 3.608
∴ byx = 0.768 (109)
From (108), r
σ
σ
x
y
=
6
5
(110)
From (109), r
σ
σ
y
x
= 0.768 (111)
Multiplying equations (110) and (111), we get
r2 = 0.9216 ⇒ r = 0.96 (112)
Dividing (111) by (110), we get
σ
σ
x
y
2
2
6
5 0 768
=
× .
= 1.5625.
Taking the square root, we get
σ
σ
x
y
= =
125
5
4
. (113)
634 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since the regression lines pass through the point (x y
, ), we have
5 6
x y
= + 24
1000 y x
= 768 – 3608.
Solving the above equations for x and y, we get
x = 6, y = 1.
Coefficient of variability of x =
σx
x
,
Coefficient of variability of y =
σy
y
.
∴ Required ratio =
σ
σ
x
y
x
y
× =
y
x
x
y
σ
σ
F
HG
I
KJ =
1
6
5
4
× =
5
24
. | using (113)
Example 13. The following data regarding the heights (y) and weights (x) of
100 college students are given:
Σx = 15000, Σx2 = 2272500, Σy = 6800, Σy2 = 463025 and Σxy = 1022250.
Find the equation of the regression line of height on weight.
Sol. x
x
n
= =
Σ 15000
100
= 150
y
y
n
= =
Σ 6800
100
= 68
Regression coefficient of y on x,
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
=
( ) ( )
( ) ( )
100 1022250 15000 6800
100 2272500 15000 2
× − ×
× −
=
102225000 102000000
227250000 225000000
−
−
=
225000
2250000
= 0.1
Regression line of height (y) on weight (x) is given by
y – y b x x
yx
= −
( )
⇒ y – 68 = 0.1(x – 150)
⇒ y = 0.1x – 15 + 68
⇒ y = 0.1x + 53.
STATISTICAL COMPUTATION 635
Example 14. Find the coefficient of correlation when the two regression
equations are
X = – 0.2Y + 4.2
Y = – 0.8X + 8.4.
Sol. We have the regression lines
X = – 0.2Y + 4.2 (114)
Y = – 0.8X + 8.4. (115)
Let us assume that eqn. (114) is the regression line of X on Y and eqn. (115)
is the regression line of Y on X then,
Regression coefficient of X on Y is
bXY = – 0.2
Regression coefficient of Y on X is
bYX = – 0.8
Since bXY and bYX are of the same sign and bXYbYX = 0.16 ( 1) hence our
assumption is correct.
We know that
bXY bYX = r2 | where r is the correlation coefficient
⇒ (– 0.2)(– 0.8) = r2
⇒ r2 = 0.16
⇒ r = – 0.4. | Since r, σx and σy have the same sign
Example 15. A panel of two judges, A and B, graded seven TV serial
performances by awarding scores independently as shown in the following table:
Performance 1 2 3 4 5 6 7
Scores by A 46 42 44 40 43 41 45
Scores by B 40 38 36 35 39 37 41
The eighth TV performance, which judge B could not attend, was awarded
37 scores by judge A. If judge B had also been present, how many scores would
be expected to have been awarded by him to the eighth TV performance?
Use regression analysis to answer this question.
Sol. Let the scores awarded by judge A be denoted by x and the scores awarded
by judge B be denoted by y.
636 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Here, n = 7; x
x
n
= =
+ + + + + +
Σ 46 42 44 40 43 41 45
7
= 43
y
y
n
= =
+ + + + + +
Σ 40 38 36 35 39 37 41
7
= 38
Let us form the table as
x y xy x2
46 40 1840 2116
42 38 1596 1764
44 36 1584 1936
40 35 1400 1600
43 39 1677 1849
41 37 1517 1681
45 41 1845 2025
Σx = 301 Σy = 266 Σxy = 11459 Σx2 = 12971
Regression coefficient,
byx =
n xy x y
n x x
Σ Σ Σ
Σ Σ
−
−
2 2
( )
=
( ) ( )
( ) ( )
7 11459 301 266
7 12971 301 2
× − ×
× −
=
80213 80066
90797 90601
147
196
−
−
= = 0.75
Regression line of y on x is given by
y – y b x x
yx
= −
( )
y – 38 = 0.75(x – 43)
⇒ y = 0.75x + 5.75
when x = 37,
y = 0.75(37) + 5.75 = 33.5 marks
Hence, if judge B had also been present, 33.5 scores would be expected to
have been awarded to the eighth T.V. performance.
ASSIGNMENT 7.5
1. Find the regression line of y on x from the following data:
x: 1 2 3 4 5
y: 2 5 3 8 7
STATISTICAL COMPUTATION 637
2. In a study between the amount of rainfall and the quantity of air pollution removed the
following data were collected:
Daily rainfall: 4.3 4.5 5.9 5.6 6.1 5.2 3.8 2.1
(in .01 cm)
Pollution removed: 12.6 12.1 11.6 11.8 11.4 11.8 13.2 14.1
(mg/m3)
Find the regression line of y on x.
3. If F is the pull required to lift a load W by means of a pulley block, fit a linear law of
the form F = mW + c connecting F and W, using the data
W: 50 70 100 120
F: 12 15 21 25
where F and W are in kg wt. Compute F when W = 150 kg wt.
4. The two regression equations of the variables x and y are x = 19.13 – 0.87 y and
y = 11.64 – 0.50 x. Find (i) mean of x’s (ii) mean of y’s and (iii) correlation coefficient
between x and y.
5. Two random variables have the regression lines with equations 3x + 2y = 26 and 6x +
y = 31. Find the mean values and the correlation coefficient between x and y.
6. In a partially destroyed laboratory data, only the equations giving the two lines of re-
gression of y on x and x on y are available and are respectively
7x – 16y + 9 = 0
5y – 4x – 3 = 0
Calculate the coefficient of correlation, x and y .
7. A simply supported beam carries a concentrated load P (kg) at its mid-point. The follow-
ing table gives maximum deflection y (cm) corresponding to various values of P:
P: 100 120 140 160 180 200
y: 0.45 0.55 0.60 0.70 0.80 0.85
Find a law of the form y = a + bP.
Also find the value of maximum deflection when P = 150 kg.
8. If a1x + b1y + c1 = 0 and a2x + b2y + c2 = 0 are the equations of the regression lines of y on
x and x on y respectively, prove that
a1b2 ≤ a2b1
given that the constants a1, a2, b1, b2 are either all positive or all negative.
9. The regression equations calculated from a given set of observations for two random
variables are
x = – 0.4y + 6.4 and y = – 0.6x + 4.6
Calculate (i) x (ii) y (iii) r.
638 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
10. The following regression equations were obtained from a correlation table:
y = 0.516x + 33.73
x = 0.512y + 32.52
Find the value of (i) r (ii) x (iii) y .
11. Find the regression line of y on x for the following data:
x: 1 3 4 6 8 9 11 14
y: 1 2 4 4 5 7 8 9.
12. Given N = 50, Mean of y = 44
Variance of x is
9
16
of the variance of y.
Regression equation of x on y is 3y – 5x = – 180
Find (i) Mean of x (ii) Coefficient of correlation between x and y.
13. For an army personnel of strength 25, the regression of weight of kidneys (y) on weight
of heart (x), both measured in ounces is
y – 0.399x – 6.934 = 0
and the regression of weight of heart on weight of kidney is x – 1.212y + 2.461 = 0.
Find the correlation coefficient between x and y and their mean values. Can you find out
the standard deviation of x and y as well?
14. A panel of judges A and B graded 7 debators and independently awarded the following
scores:
Debator: 1 2 3 4 5 6 7
Scores by A: 40 34 28 30 44 38 31
Scores by B: 32 39 26 30 38 34 28
An eighth debator was awarded 36 scores by judge A while judge B was not present. If
judge B were also present, how many scores would you expect him to award to the
eighth debator assuming that the same degree of relationship exists in their judgement.
15. The following results were obtained in the analysis of data on yield of dry bark in ounces
(y) and age in years (x) of 200 cinchona plants:
x y
Average: 9.2 16.5
Standard deviation: 2.1 4.2
Correlation coefficient = 0.84
Construct the two lines of regression and estimate the yield of dry bark of a plant of age
8 years.
16. Given that x = 4y + 5 and y = kx + 4 are the lines of regression of x on y and y on x
respectively. Show that 0 ≤ 4k ≤ 1.
If k =
1
16
, find x , y and coefficient of correlation between x and y.
STATISTICAL COMPUTATION 639
17. The means of a bivariate frequency distribution are at (3, 4) and r = 0.4. The line of
regression of y on x is parallel to the line y = x. Find the two lines of regression and
estimate value of x when y = 1.
18. Assuming that we conduct an experiment with 8 fields planted with corn, four fields
having no nitrogen fertilizer and four fields having 80 kgs of nitrogen fertilizer. The
resulting corn yields are shown in table in bushels per acre:
Field: 1 2 3 4 5 6 7 8
Nitrogen (kgs) x: 0 0 0 0 80 80 80 80
Corn yield y: 120 360 60 180 1280 1120 1120 760
(acre)
(a) Compute a linear regression equation of y on x.
(b) Predict corn yield for a field treated with 60 kgs of fertilizer.
19. Find both the lines of regression of following data:
x: 5.60 5.65 5.70 5.81 5.85
y: 5.80 5.70 5.80 5.79 6.01
20. Obtain regression line of x on y for the given data:
x: 1 2 3 4 5 6
y: 5.0 8.1 10.6 13.1 16.2 20.0
7.59 POLYNOMIAL FIT: NON-LINEAR REGRESSION
Let y = a + bx + cx2
be a second degree parabolic curve of regression of y on x to be fitted for
the data (xi, yi), i = 1, 2, ......, n.
Residual at x = xi is
Ei = yi – f(xi) = yi – a – bxi – cxi
2
Now, let U =
i
n
i
i
n
= =
∑ ∑
=
1
2
1
E (yi – a – bxi – cxi
2)2
By principle of Least squares, U should be minimum for the best values of
a, b and c.
For this,
∂
∂
U
a
= 0,
∂
∂
U
b
= 0 and
∂
∂
U
c
= 0
∂
∂
U
a
= 0 ⇒ 2
1
i
n
=
∑ (yi – a – bxi – cxi
2) (– 1) = 0
⇒ Σy = na + bΣx + cΣx2 (116)
640 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∂
∂
U
b
= 0 ⇒ 2
1
i
n
=
∑ (yi – a – bxi – cxi
2) (– xi) = 0
⇒ Σxy = aΣx + bΣx2 + cΣx3 (117)
∂
∂
U
c
= 0 ⇒ 2
1
i
n
=
∑ (yi – a – bxi – cxi
2) (– xi
2) = 0
⇒ Σx2y = aΣx2 + bΣx3 + cΣx4 (118)
Equations (116), (117) and (118) are the normal equations for fitting a second
degree parabolic curve of regression of y on x. Here n is the number of pairs of
values of x and y.
EXAMPLES
Example 1. (a) Fit a second degree parabola to the following data:
x: 0.0 1.0 2.0
y: 1.0 6.0 17.0
(b) Fit a second degree curve of regression of y on x to the following data:
x: 1.0 2.0 3.0 4.0
y: 6.0 11.0 18.0 27
(c) Fit a second degree parabola in the following data:
x: 0.0 1.0 2.0 3.0 4.0
y: 1.0 4.0 10.0 17.0 30.0
Sol. The equation of second degree parabola is given by
y = a + bx + cx2 (119)
Normal equations are
Σy = ma + bΣx + cΣx2 (120)
Σxy = aΣx + bΣx2 + cΣx3 (121)
and Σx2y = aΣx2 + bΣx3 + cΣx4 (122)
STATISTICAL COMPUTATION 641
(a) Here m = 3
The table is as follows:
x y x2 x3 x4 xy x2y
0 1 0 0 0 0 0
1 6 1 1 1 6 6
2 17 4 8 16 34 68
Total 24 5 9 17 40 74
Substituting in eqns. (120), (121) and (122), we get
24 = 3a + 3b + 5c (123)
40 = 3a + 5b + 9c (124)
74 = 5a + 9b + 17c (125)
Solving eqns. (123), (124) and (125), we get
a = 1, b = 2, c = 3
Hence the required second degree parabola is
y = 1 + 2x + 3x2
(b) Here m = 4
The table is as follows:
x y x2 x3 x4 xy x2y
1 6 1 1 1 6 6
2 11 4 8 16 22 44
3 18 9 27 81 54 162
4 27 16 64 256 108 432
Σx = 10 Σy = 62 Σx2 = 30 Σx3 = 100 Σx4 = 354 Σxy = 190 Σx2y = 644
Substituting values in eqns. (120), (121) and (122), we get
62 = 4a + 10b + 30c (126)
190 = 10a + 30b + 100c (127)
644 = 30a + 100b + 354c (128)
Solving equations (126), (127) and (128), we get
a = 3, b = 2, c = 1
642 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Hence the required second degree parabola is
y = 3 + 2x + x2
(c) Here m = 5
The table is as follows:
x y x2 x3 x4 xy x2y
0.0 1.0 0 0 0 0 0
1.0 4.0 1 1 1 4 4
2.0 10.0 4 8 16 20 40
3.0 17.0 9 27 81 51 153
4.0 30.0 16 64 256 120 480
Σx = 10 Σy = 62 Σx2 = 30 Σx3 = 100 Σx4 = 354 Σxy = 195 Σx2y = 677
Substituting values in eqns. (120), (121) and (122), we get
62 = 5a + 10b + 30c (129)
195 = 10a + 30b + 100c (130)
677 = 30a + 100b + 354c (131)
Solving eqns. (129), (130) and (131), we get
a = 1.2, b = 1.1 and c = 1.5
Hence the required second degree parabola is
y = 1.2 + 1.1x + 1.5x2
Example 2. Fit a parabola y = ax2 + bx + c in least square sense to the data
x: 10 12 15 23 20
y: 14 17 23 25 21.
Sol. The normal equations to the curve are
and
Σ Σ Σ
Σ Σ Σ Σ
Σ Σ Σ Σ
y a x b x c
xy a x b x c x
x y a x b x c x
= + +
= + +
= + +
U
V
|
W
|
2
3 2
2 4 3 2
5
(132)
STATISTICAL COMPUTATION 643
The values of Σx, Σx2,...... etc., are calculated by means of the following
table:
x y x2 x3 x4 xy x2y
10 14 100 1000 10000 140 1400
12 17 144 1728 20736 204 2448
15 23 225 3375 50625 345 5175
23 25 529 12167 279841 575 13225
20 21 400 8000 160000 420 8400
Σx = 80 Σy = 100 Σx2 = 1398 Σx3 = 26270 Σx4 = 521202 Σxy = 1684 Σx2y = 30648
Substituting the obtained values from the table in normal equation (132),
we have
100 = 1398a + 80b + 5c
1684 = 26270a + 1398b + 80c
30648 = 521202a + 26270b + 1398c
On solving, a = – 0.07, b = 3.03, c = – 8.89
∴ The required equation is
y = – 0.07x2 + 3.03x – 8.89.
Example 3. Fit a parabolic curve of regression of y on x to the following data:
x: 1.0 1.5 2.0 2.5 3.0 3.5 4.0
y: 1.1 1.3 1.6 2.0 2.7 3.4 4.1
Sol. Here m = 7 (odd)
Let u =
x − 2.5
0.5
= 2x – 5 and v = y
The results in tabular form are:
x y u v u2 uv u2v u3 u4
1.0 1.1 – 3 1.1 9 – 3.3 9.9 – 27 81
1.5 1.3 – 2 1.3 4 – 2.6 5.2 – 8 16
2.0 1.6 – 1 1.6 1 – 1.6 1.6 – 1 1
2.5 2.0 0 2.0 0 0 0 0 0
3.0 2.7 1 2.7 1 2.7 2.7 1 1
3.5 3.4 2 3.4 4 6.8 13.6 8 16
4.0 4.1 3 4.1 9 12.3 36.9 27 81
Total 0 16.2 28 14.3 69.9 0 196
644 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Let the curve to be fitted be v = a + bu + cu2 so that the normal equations
are
Σv = 7a + bΣu + cΣu2
Σuv = aΣu + bΣu2 + cΣu3
and Σu2v = aΣu2 + bΣu3 + cΣu4
⇒ 16.2 = 7a + 28c, 14.3 = 28b, 69.9 = 28a + 196c
Solving, we get a = 2.07, b = 0.511, c = 0.061
Hence the curve of fit is
v = 2.07 + 0.511u + 0.061u2
⇒ y = 2.07 + 0.511 (2x – 5) + 0.061 (2x – 5)2
= 1.04 – 0.193x + 0.243x2.
Example 4. Fit a second degree parabola to the following data by the Least
Squares Method:
x: 1929 1930 1931 1932 1933 1934 1935 1936 1937
y: 352 356 357 358 360 361 361 360 359.
Sol. Here m = g (odd)
∴ Let x0 = 1933, h = 1, y0 = 357
then u =
x − 1933
1
= x – 1933
v = y – 357
and the equation y = a + bx + cx2 is transformed to
v = a′ + b′u + c′u2
x u y v uv u2 u2v u3 u4
1929 – 4 352 – 5 20 16 – 80 – 64 256
1930 – 3 356 – 1 3 9 – 9 – 27 81
1931 – 2 357 0 0 4 0 – 8 16
1932 – 1 358 1 – 1 1 1 – 1 1
1933 0 360 3 0 0 0 0 0
1934 1 361 4 4 1 4 1 1
1935 2 361 4 8 4 16 8 16
1936 3 360 3 9 9 27 27 81
1937 4 359 2 8 16 32 64 256
Total Σu = 0 Σv = 11 Σuv = 51 Σu2 = 60 Σu2v = – 9 Σu3 = 0 Σu4 = 708
STATISTICAL COMPUTATION 645
Putting the above values in normal equations, we get
11 = 9a′ + 60c′, 51 = 60b′, – 9 = 60a′ + 708c′
⇒ a′ = 3, b′ = 0.85, c′ = – 0.27.
Fitted parabola in u and v is given by
v = 3 + 0.85 u – 0.27 u2
Putting u = x – 1933 and v = y – 357
y – 357 = 3 + 0.85 (x – 1933) – .27 (x – 1933)2
⇒ y = – 0.27x2 + 1044.67x – 1010135.08
which is the required equation.
Example 5. Fit a second degree parabola to the following data by Least Squares
Method:
x: 1 2 3 4 5
y: 1090 1220 1390 1625 1915
Sol. Here m = 5 (odd)
Let u = x – 3, v = y – 1220
x y u v u2 u2v uv u3 u4
1 1090 – 2 – 130 4 – 520 260 – 8 16
2 1220 – 1 0 1 0 0 – 1 1
3 1390 0 170 0 0 0 0 0
4 1625 1 405 1 405 405 1 1
5 1915 2 695 4 2780 1390 8 16
Total Σu = 0 Σv = 1140 Σu2 = 10 Σu2v = 2665 Σuv = 2055 Σu3 = 0 Σu4 = 34
Putting these values in normal equations, we get
1140 = 5a′ + 10c′, 2055 = 10b′, 2655 = 10a′ + 34c′
⇒ a′ = 173, b′ = 205.5, c′ = 27.5
∴ v = 173 + 205.5u + 27.5u2 (133)
Put u = x – 3 and v = y – 1220
From (133), y – 1220 = 173 + 205.5 (x – 3) + 27.5 (x – 3)2
⇒ y = 27.5x2 + 40.5x + 1024.
646 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Example 6. Fit a second degree parabola to the following data taking y as
dependent variable:
x 1 2 3 4 5 6 7 8 9
y 2 6 7 8 10 11 11 10 9
Sol. Normal equations to fit a second degree parabola of the form
y = a + bx + cx2 are
and
Σ Σ Σ
Σ Σ Σ Σ
Σ Σ Σ Σ
y ma b x c x
xy a x b x c x
x y a x b x c x
= + +
= + +
= + +
U
V
|
W
|
2
2 3
2 2 3 4
(134)
Here, m = 9
x y x2 x3 x4 xy x2y
1 2 1 1 1 2 2
2 6 4 8 16 12 24
3 7 9 27 81 21 63
4 8 16 64 256 32 128
5 10 25 125 625 50 250
6 11 36 216 1296 66 396
7 11 49 343 2401 77 539
8 10 64 512 4096 80 640
9 9 81 729 6561 81 729
Σx = 45 Σy = 74 Σx2 = 285 Σx3 = 2025 Σx4 = 15333 Σxy = 421 Σx2y = 2771
Putting in (134), we get
74 = 9a + 45b + 285c
421 = 45a + 285b + 2025c
2771 = 285a + 2025b + 15333c
Solving the above equations, we get
a = – 1, b = 3.55, c = – 0.27
Hence the required equation of second degree parabola is
y = – 1 + 3.55x – 0.27x2.
Example 7. Employ the method of least squares to fit a parabola y = a + bx + cx2
in the following data:
(x, y): (– 1, 2), (0, 0), (0, 1), (1, 2)
STATISTICAL COMPUTATION 647
Sol. Normal equations to the parabola y = a + bx + cx2 are
Σy = ma + bΣx + cΣx2 (135)
Σxy = aΣx + bΣx2 + cΣx3 (136)
and Σx2y = aΣx2 + bΣx3 + cΣx4 (137)
Here m = 4
The table is as follows:
x y x2 x3 x4 xy x2y
– 1 2 1 – 1 1 – 2 2
0 0 0 0 0 0 0
0 1 0 0 0 0 0
1 2 1 1 1 2 2
Σx = 0 Σy = 5 Σx2 = 2 Σx3 = 0 Σx4 = 2 Σxy = 0 Σx2y = 4
Substituting these values in equations (135), (136) and (137); we get
5 = 4a + 2c (138)
0 = 2b (139)
and 4 = 2a + 2c (140)
Solving (138), (139) and (140), we get
a = 0.5, b = 0 and c = 1.5
Hence the required second degree parabola is
y = 0.5 + 1.5x2
7.59.1 Algorithm of Second Degree Parabolic Curve Fitting
1. Input n
2. For i=0,3
3. For j=0,4
4. u(i,j)=0
5. Next j
6. Next i
7. u(0,0)=n
8. For i=0,n
9. Input x,y
648 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
10. x2=x*x
11. u(0,1)+=x
12. u(0,2)+=x2
13. u(1,2)+=x*x2
14. u(2,2)+=x2*x2
15. u(0,3)+=y
16. u(1,3)+=x*y
17. u(2,3)+=x2*y
18. Next i
19. u(1,1)=u(0,2)
20. u(2,1)=u(1,2)
21. u(1,0)=u(0,1)
22. u(2,0)=u(1,1)
23. For j=0,3
24. For i=0,3
25. If i!=j then
goto step 26
ELSE
goto step 24
26. y=u(i,j)/u(j,j)
27. For k=0,4
28. u(i,k)-=u(j,k)*p
29. Next k
30. Next i
31. Next j
32. a=u(0,3)/u(0,0)
33. b=u(1,3)/u(1,1)
34. c=u(2,3)/u(2,2)
35. Print a,b,c
36. Stop
STATISTICAL COMPUTATION 649
7.59.2 Flow-Chart of Second Degree Parabolic Curve Fitting
START
Input n
For i = 0, 3
For j = 0, 4
u(i, j) = 0
u(0, 0) = n
For i = 0, n
Input x, y
x2 = x*x
u(0, 1) + = x
u(0, 2) + = x2
u(1, 2) + = x*x2
u(2, 2) + = x2*x2
u(0, 3) + = y
u(1, 3) + = x*y
u(2, 3) + = x2*y
u(1, 1) = u(0, 2)
u(2, 1) = u(1, 2)
u(1, 0) = u(0, 1)
u(2, 0) = u(1, 1)
A
650 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A
For j = 0, 3
For i = 0, 3
For k = 0, 4
u(i, k) – = u(j, k)*p
a = u(0, 3)/u(0, 0)
b = u(1, 3)/u(1, 1)
c = u(2, 3)/u(2, 2)
STOP
If
i ! = j
y = u(i, j)/u(j, j)
Print a, b, c
Yes
No
7.59.3 Program in ‘C’ for Second Degree Parabolic Curve Fitting
Notations used in the Program
(i) n is the number of data points.
(ii) x is the data point value of x.
(iii) y is the data point of y.
(iv) u is the two dimensional array of augmented matrix.
#includestdio.h
main()
{
int i,j,k,n;
STATISTICAL COMPUTATION 651
float u[3][4], x,y,x2,p,a,b,c;
printf(nEnter the value of data set n:);
scanf(%d,n);
for(i=0; i3; i++)
for(j=0; j4; j++)
u[i][j]=0;
u[0][0]=n;
printf(nEnter the value of x  y:n);
for(i=0; in; i++)
{
scanf(%f%f, x, y);
x2=x*x;
u[0][1]+=x;
u[0][2]+=x2;
u[1][2]+=x*x2;
u[2][2]+=x2*x2;
u[0][3]+=y;
u[1][3]+=x*y;
u[2][3]+=x2*y;
}
u[1][1]=u[0][2];
u[2][1]=u[1][2];
u[1][0]=u[0][1];
u[2][0]=u[1][1];
/* Finding the value of a,b,c */
for (j=0;j3;j++)
for (i=0;i3;i++)
if(i!=j)
{
p=u[i][j]/u[j][j];
for(k=0;k;k++)
u[i][k]-=u[j][k]*p;
}
a=u[0][3]/u[0][0];
b=u[1][3]/u[1][1];
652 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
c=u[2][3]/u[2][2];
printf(na=%f b=%f c=%f , a,b,c);
printf(nnEquation of parabola is: y=a+bx+cx^2 n);
printf(ny=%f+(%f)x+(%f)x^2,a,b,c);
return;
}
7.59.4 Output
Enter the value of data set n: 5
Enter the value of x  y:
1 10.9
2 12.2
3 13.9
4 16.3
5 19.2
a=10.239998 b=0.398574 c=0.278571
Equation of parabola is: y = a+bx+cx^2
y=10.239998+(0.398574)x+(0.278571)x^2
7.60 MULTIPLE LINEAR REGRESSION
Now we proceed to discuss the case where the dependent variable is a function
of two or more linear or non-linear independent variables. Consider such a
linear function as
y = a + bx + cz
The sum of the squares of residual is
U = ( )
y a bx cz
i i i
i
n
− − −
=
∑ 2
1
Differentiating U partially with respect to a, b, c; we get
∂
∂
U
a
= 0 ⇒ 2
1
( )
y a bx cz
i i i
i
n
− − −
=
∑ (– 1) = 0
∂
∂
U
b
= 0 ⇒ 2
1
( )
y a bx cz
i i i
i
n
− − −
=
∑ (– xi) = 0
STATISTICAL COMPUTATION 653
and
∂
∂
U
c
= 0 ⇒ 2
1
( )
y a bx cz
i i i
i
n
− − −
=
∑ (– zi) = 0
which on simplification and omitting the suffix i, yields.
∑y = ma + b∑x + c∑z
∑xy = a∑x + b∑x2 + c∑xz
∑yz = a∑z + b∑xz + c∑z2
Solving the above three equations, we get values of a, b and c. Consequently,
we get the linear function y = a + bx + cz called regression plane.
Example. Obtain a regression plane by using multiple linear regression to fit
the data given below:
x: 1 2 3 4
z: 0 1 2 3
y: 12 18 24 30
Sol. Let y = a + bx + cz be the required regression plane where a, b, c are the
constants to be determined by following equations:
Σy = ma + bΣx + cΣz
Σyx = aΣx + bΣx2 + cΣzx
and Σyz = aΣz + bΣzx + cΣz2
Here m = 4
x z y x2 z2 yx zx yz
1 0 12 1 0 12 0 0
2 1 18 4 1 36 2 18
3 2 24 9 4 72 6 48
4 3 30 16 9 120 12 90
Σx = 10 Σz = 6 Σy = 84 Σx2 = 30 Σz2 = 14 Σyx = 240 Σzx = 20 Σyz = 156
Substitution yields, 84 = 4a + 10b + 6c
240 = 10a + 30b + 20c
and 156 = 6a + 20b + 14c
Solving, we get a = 10, b = 2, c = 4
Hence the required regression plane is
y = 10 + 2x + 4z.
654 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 7.6
1. Fit a second degree parabola to the following data taking x as the independent variable:
x: 0 1 2 3 4
y: 1 5 10 22 38
2. Fit a second degree parabola to the following data by Least Squares Method:
x: 0 1 2 3 4
y: 1 1.8 1.3 2.5 6.3
3. The profit of a certain company in Xth year of its life are given by:
x: 1 2 3 4 5
y: 1250 1400 1650 1950 2300
Taking u = x – 3 and v =
y − 1650
50
, show that the parabola of second degree of v on u is
v + 0.086 = 5.3 u + 0.643u2 and deduce that the parabola of second degree of y on x is
y = 1144 + 72x + 32.15x2.
4. The following table gives the results of the measurements of train resistances, V is the
velocity in miles per hour, R is the resistance in pounds per ton:
V: 20 40 60 80 100 120
R: 5.5 9.1 14.9 22.8 33.3 46
If R is related to V by the relation R = a + bV + cV2; find a, b and c by using the Method
of Least Squares.
5. Determine the constants a, b, and c by the Method of Least Squares such that
y = ax2 + bx + c fits the following data:
x: 2 4 6 8 10
y: 4.01 11.08 30.12 81.89 222.62
7.61 STATISTICAL QUALITY CONTROL
A quality control system performs inspection, testing and analysis to ensure
that the quality of the products produced is as per the laid down quality
standards. It is called “Statistical Quality Control” when statistical
techniques are employed to control, improve and maintain quality or to solve
quality problems. Building an information system to satisfy the concept of
prevention and control and improving upon product quality requires statistical
thinking.
STATISTICAL COMPUTATION 655
Statistical quality control (S.Q.C.) is systematic as compared to guess-work
of haphazard process inspection and the mathematical statistical approach
neutralizes personal bias and uncovers poor judgement. S.Q.C. consists of three
general activities:
(1) Systematic collection and graphic recording of accurate data
(2) Analyzing the data
(3) Practical engineering or management action if the information obtained
indicates significant deviations from the specified limits.
Modern techniques of statistical quality control and acceptance sampling
have an important part to play in the improvement of quality, enhancement of
productivity, creation of consumer confidence, and development of industrial
economy of the country.
The following statistical tools are generally used for the above purposes:
(i) Frequency distribution. Frequency distribution is a tabulation of
the number of times a given quality characteristic occurs within the
samples. Graphic representation of frequency distribution will show:
(a) Average quality
(b) Spread of quality
(c) Comparison with specific requirements
(d) Process capability.
(ii) Control chart. Control chart is a graphical representation of quality
characteristics, which indicates whether the process is under control
or not.
(iii) Acceptance sampling. Acceptance sampling is the process of
evaluating a portion of the product/material in a lot for the purpose of
accepting or rejecting the lot on the basis of conforming to a quality
specification.
It reduces the time and cost of inspection and exerts more effective
pressure on quality improvement than it is possible by 100% inspection.
It is used when assurance is desired for the quality of materials/products
either produced or received.
(iv) Analysis of data. Analysis of data includes analysis of tolerances,
correlation, analysis of variance, analysis for engineering design,
problem solving technique to eliminate cause to troubles. Statistical
methods can be used in arriving at proper specification limits of product,
in designing the product, in purchase of raw-material, semi-finished
and finished products, manufacturing processes, inspection, packaging,
sales, and also after sales service.
656 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
7.62 ADVANTAGES OF STATISTICAL QUALITY CONTROL
1. Efficiency. The use of statistical quality control ensures rapid and efficient
inspection at a minimum cost. It eliminates the need of 100% inspection of
finished products because the acceptance sampling in statistial quality
control exerts more effective pressure for quality improvement.
2. Reduction of scrap. Statistial quality control uncovers the cause of
excessive variability in manufactured products forecasting trouble before
rejections occur and reducing the amount of spoiled work.
3. Easy detection of faults. In statistical quality control, after plotting the
control charts (X, R, P, C, U) etc., when the points fall above the upper
control limits or below the lower control limit, an indication of deterioration
in quality is given. Necessary corrective action may then be taken
immediately.
4. Adherence to specifications. So long as a statistical quality control
continues, specifications can be accurately predicted for the future by which
it is possible to assess whether the production processes are capable of
producing the products with the given set of specifications.
5. Increases output and reduces wasted machine and man hours.
6. Efficient utilization of personnel, machines and materials results
in higher productivity.
7. Creates quality awareness in employees. However, it should be noted
that statistical quality control is not a panacea for assuring product quality.
8. Provides a common language that may be used by designers, production
personnel, and inspectors in arriving at a rational solution of mutual
problems.
9. Points out when and where 100% inspection, sorting or screening
is required.
10. Eliminates bottlenecks in the process of manufacturing.
It simply furnishes ‘perspective facts’ upon which intelligent management
and engineering action can be based. Without such action, the method is
ineffective.
Even the application of standard procedures is very dangerous without
adequate study of the process.
STATISTICAL COMPUTATION 657
7.63 REASONS FOR VARIATIONS IN THE QUALITY OF A PRODUCT
Two extremely similar things are rarely obtained in nature. This fact holds
good for production processes as well. No production process is good enough to
produce all items or products exactly alike. The variations are due to two main
reasons:
(i) Chance or random causes. Variations due to chance causes are inevitable
in any process or product. They are difficult to trace and to control even
under the best conditions of production.
These variations may be due to some inherent characteristic of the process
or machine which functions at random.
If the variations are due to chance factors alone, the observations will follow
a “normal curve.” The knowledge of the behaviour of chance variation is
the foundation on which control chart analysis rests. The conditions which
produce these variations are accordingly said to be “under control.” On
the other hand, if the variations in the data do not conform to a pattern
that might reasonably be produced by chance causes, then in this case,
conditions producing the variations are said to be “out of control” as it
may be concluded that one or more assignable causes are at work.
(ii) Assignable causes. The variations due to assignable causes possess greater
magnitude as compared to those due to chance causes and can be easily
traced or detected. The power of the shewhart control chart lies in its ability
to separate out these assignable causes of quality variations, for example,
in length thickness, weight, or diameter of a component.
The variations due to assignable causes may be because of following factors:
(i) Differences among machines
(ii) Differences among workers
(iii) Differences among materials
(iv) Differences in each of these factors over time
(v) Differences in their relationship to one another.
These variations may also be caused due to change in working conditions,
mistake on the part of the operator, etc.
7.64 TECHNIQUES OF STATISTICAL QUALITY CONTROL
To control the quality characteristics of the product, there are two main
techniques:
1. Process Control. Process control is a process of monitoring and measuring
variability in the performance of a process or a machine through the
658 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
interpretation of statistical techniques and it is employed to manage in-
process quality. This technique ensures the production of requisite standard
product and makes use of control charts.
2. Product control. This technique is concerned with the inspection of already
produced goods to ascertain whether they are fit to be dispatched or not.
To achieve the objectives, product control makes use of sampling inspection
plans.
7.65 CONTROL CHART
A control chart is a graphical representation of the collected information. It
detects the variation in processing and warns if there is any departure from
the specified tolerance limits. In other words, control charts is a device which
specifies the state of statistical control or is a device for attaining quality control
or is a device to judge whether the statistical control has been attained.
The control limits on the chart are so placed as to disclose the presence or
absence of the assignable causes of quality variation which makes the diagnosis
possible and brings substantial improvements in product quality and reduction
of spoilage and rework.
Moreover, by identifying chance variations, the control chart tells when to
leave the process alone and thus prevents unnecessarily frequent adjustments
that tend to increase the variability of the process rather than to decrease it.
There are many types of control charts designed for different control
situations. Most commonly used control charts are:
(i) Control charts for variables. These are useful to measure quality
characteristics and to control fully automatic process. It includes X
and R-charts and charts for X and σ.
(ii) Control charts for attributes. These include P-chart for fraction
defective. A fraction defective control chart discloses erratic fluctuations
in the quality of inspection which may result in improvement in
inspection practice and inspection standards.
It also includes C-chart for number of defects per unit.
7.66 OBJECTIVES OF CONTROL CHARTS
Control charts are based on statistical techniques.
1. X and R or X and σ charts are used in combination for control process.
X -chart shows the variation in the averages of samples. It is the most
STATISTICAL COMPUTATION 659
commonly used variables chart. R-chart shows the uniformity or consistency
of the process, i.e., it shows the variations in the ranges of samples. It is a
chart for measure of spread. σ-chart shows the variation of process.
2. To determine whether a given process can meet the existing specifications
without a fundamental change in the production line or to tell whether the
process is in control and if so, at what dispersion.
3. To secure information to be used in establishing or changing production
procedures.
4. To secure information when it is necessary to widen the tolerances.
5. To provide a basis for current decisions or acceptance or rejection of
manufactured or purchased product.
6. To secure information to be used in establishing or changing inspection
procedure or acceptance procedure or both.
7.67 CONSTRUCTION OF CONTROL CHARTS FOR VARIABLES
First of all, a random sample of size n is taken during a manufacturing process
over a period of time and quality measurements x1, x2, ......, xn are noted
Sample mean x =
x x x
n n
x
n
i
i
n
1 2
1
1
+ + +
=
=
∑
......
Sample range R = xmax. – xmin.
If the process is found stable, k consecutive samples are selected and for
each sample, x and R are calculated. Then we find x and R as
x
x x x
k k
x
k
i
i
k
=
+ + +
=
=
∑
1 2
1
1
......
and R =
R R R
R
1 2
1
1
+ + +
=
=
∑
...... k
i
i
k
k k
For X -chart
Central line =
x , when tolerance limits are not given
, when tolerance limits are given
μ
U
V
W
where μ =
1
2
[LCL + UCL]
LCL is lower control limit and UCL is upper control limit
Now, LCL (for X -chart) = x − A R
2 and UCL (for X -chart) = x + A R
2
are set.
660 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
A2 depends on sample size n and can be found from the following table:
Sample 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
size (n)
A2 1.88 1.02 0.73 0.58 0.48 0.42 0.37 0.34 0.31 0.29 0.27 0.25 0.24 0.22 0.21 0.20 0.19 0.19 0.18
For R-chart Central line (CL) = R
Now, LCL (for R-chart) = D3R UCL (for R-chart) = D4R are set.
where D3 and D4 depend on sample size and are found from the following table:
Sample size (n) D3 D4 d2
2 0 3.27 1.13
3 0 2.57 1.69
4 0 2.28 2.06
5 0 2.11 2.33
6 0 2.00 2.53
7 0.08 1.92 2.70
8 0.14 1.86 2.85
9 0.18 1.82 2.97
10 0.22 1.78 3.08
11 0.26 1.74 3.17
12 0.28 1.72 3.26
13 0.31 1.69 3.34
14 0.33 1.67 3.41
15 0.35 1.65 3.47
16 0.36 1.64 3.53
17 0.38 1.62 3.59
18 0.39 1.61 3.64
19 0.40 1.60 3.69
20 0.41 1.59 3.74
To compute upper and lower process tolerance limits for the values of x, we
have
LTL = x
d
−
3
2
R
UTL = x
d
+
3
2
R
where d2 is found from the above table.
Moreover, The process capability is given by 6σ = 6
2
R
d
where σ is standard
deviation.
STATISTICAL COMPUTATION 661
While plotting the X -chart the central line on the X chart should be drawn
as a solid horizontal line at X . The upper and lower control limits for X chart
should be drawn as dotted horizontal lines at the computed values.
Similarly, for R-chart, the central line should be drawn as a solid horizontal
line at R . The upper control limit should be drawn as dotted horizontal line at
the computed value of UCLR. If the subgroup size is 7 or more, the lower control
limit should be drawn as dotted horizontal line at LCLR. However, if the
subgroup size is ≤ 6, the lower control limit for R is zero.
Plot the averages of subgroups in X -chart, in the order collected and ranges
in R-chart which should be below the X -chart so that the subgroups correspond
to one-another in both the charts. Points outside the control limits are indicated
with cross (×) on X -chart and the points outside the limits on R chart by a
circle ( • ).
7.68 CONTROL CHARTS FOR ATTRIBUTES
The following control charts will be discussed here
(i) P chart (ii) np chart
(iii) C chart (iv) u chart.
As an alternative to X and R chart and as a substitute when characteristic
is measured only by attribute, a control chart based on fraction defective p is
used, called P-chart.
p =
Number of defective articles found in any inspection
Total number of articles actually inspected
.
(i) Control limits (3σ limits) on P-chart. We know that for binomial
distribution, the mean value of total number of defectives in a sample n is
np and standard deviation is npq or np p
( )
1 − .
∴ Mean value of fraction defective is p and standard deviation
σp =
1
1
1
n
np p
p p
n
( )
( )
− =
−
∴ CL = p
The upper and lower limits for P-chart are,
UCLP = p + 3σp = p + 3
p p
n
( )
1 −
662 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
and LCLP = p – 3σp = p – 3
p p
n
( )
1 −
.
Due to the lower inspection and maintenance costs of P-charts, they usually
have a greater area of economical applications.
(ii) Control limits for np chart. Whenever subgroup size is variable, P-chart
is used but if it is constant, the chart for actual number of defectives called
np chart is used.
CL = n p where p =
∑
∑
np
n
UCLnp = n p + 3σnp = n p + 3 np p
( )
1 − (where σnp = nσp)
and LCLnp = n p – 3 np p
( )
1 − .
In case of X and R chart, it may not be necessary to draw lines connecting
the points which represent the successive subgroups. But incase of P-chart,
a line connecting the points is usually helpful in interpretation of the chart.
Such a line assists in the interpretation of trends.
(iii) Control limits for C chart
(a) Difference between a defect and defective
An item is called defective if it fails to conform to the specifications
in any of the characteristics. Each characteristic that does not meet
the specifications is a defect. An item is defective if it contains atleast
one defect. The np chart applies to the number of defectives in
subgroups of constant size while C chart applies to the number of
defects in a subgroup of constant size.
(b) Basis for control limits on C chart
Control limits on C chart are based on Poisson distribution.
Hence two conditions must be satisfied. The first condition specifies
that the area of opportunity for occurrence of defects should be
fairly constant from period to period. Second condition specifies
that opportunities for defects are large while the chances of a defect
occurring in any one spot are small.
(c) Calculation of control limits on C chart
Standard deviation
σc = C
Thus 3σ limits on a C chart are
UCLc = C + 3 C and LCLc = C 3 C
−
NOTE
STATISTICAL COMPUTATION 663
and central line CL = C
where C =
Number of defects in all samples
Total number of samples
.
(iv) u chart. When the subgroup size varies from sample to sample, it is
necessary to use u charts. The control limits on u chart will however vary.
If c is total number of defects found in any sample and n is number of
inspection units in a sample,
u
n
= =
C Number of defects in a sample
Number of units in a sample
The larger the number of units in a sample, the narrower the limits.
Formulae for control limits on u chart are:
UCLu = u
u
n
+ 3 ; LCLu = u
u
n
− 3 and central line CL = u .
EXAMPLES
Example 1. The following are the mean lengths and ranges of lengths of a
finished product from 10 samples each of size 5. The specification limits for
length are 200 ± 5 cm. Construct X and R-chart and examine whether the
process is under control and state your recommendations.
Sample
number 1 2 3 4 5 6 7 8 9 10
Mean (X ) 201 198 202 200 203 204 199 196 199 201
Range (R) 5 0 7 3 3 7 2 8 5 6
Assume for n = 5, A2 = 0.58, D4 = 2.11 and D3 = 0.
Sol. (i) Control limits for X chart:
Central limit CL = 200
∵ Tolerance / specification limits are given
= 200
∴ μ
UCL A R = + A R
2 2
x x
= + μ
LCL A R = A R
2 2
x x
= − −
μ
where R
R R R
1 2 10
=
+ + +
=
......
10
46
10
= 4.6
Then, UCLX = 200 + (0.58 × 4.6) = 202.668
664 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
LCLX
= 200 – (0.58 × 4.6) = 197.332.
(ii) Control limits for R chart.
Central limit CL = R = 4.6
UCLR = D4R = 2.11 × 4.6 = 9.706
LCLR = D3 R = 0 × 4.6 = 0
The X and R-charts are drawn below:
×
×
×
1 2 3 4 5 6 7 8 9 10
190
195
200
205
LCL = 197.332
UCL = 202.668
CL = 200
Sample number
Sample
mean
X
–
X-Chart
1 2 3 4 5 6 7 8 9 10
0
4
8
12
UCL = 9.706
CL = 4.6
LCL = 0
Sample number
Sample
Range
(R)
R-Chart
STATISTICAL COMPUTATION 665
It is noted that all points lie within the control limits on the R chart. Hence
the process variability is under control. But in X-chart, points corresponding to
sample number 5, 6, and 8 lie outside the control limits. Therefore the process
is not in statistical control. The process should be halted and it is
recommended to check for any assignable causes. Fluctuation will remain until
these causes, if found, are removed.
Example 2. A drilling machine bores holes with a mean diameter of 0.5230 cm
and a standard deviation of 0.0032 cm. Calculate the 2-sigma and 3-sigma
upper and lower control limits for means of sample of 4.
Sol. Mean diameter x = 0.5230 cm
S.D. σ = 0.0032 cm
n = 4
(i) 2-sigma limits are as follows:
CL = x = 0.5230 cm
UCL = x
n
+ = + ×
2 0 5230 2
0 0032
4
σ
.
.
= 0.5262 cm
LCL = x
n
− = − ×
2 0 5230 2
0 0032
4
σ
.
.
= 0.5198 cm.
(ii) 3-sigma limits are as follows:
CL = x = 0.5230 cm
UCL = x
n
+ = + ×
3 0 5230 3
0 0032
4
σ
.
.
= 0.5278 cm
LCL = x
n
− = − ×
3 0 5230 3
0 0032
4
σ
.
.
= 0.5182 cm.
Example 3. In a blade manufacturing factory, 1000 blades are examined daily.
Draw the np chart for the following table and examine whether the process is
under control?
Date: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Number of
defective blades: 9 10 12 8 7 15 10 12 10 8 7 13 14 15 16
Sol. Here, n = 1000
∑np = total number of defectives = 166
∑n = total number inspected = 1000 × 15
∴ p
np
n
=
∑
∑
=
×
166
1000 15
= 0.011
666 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ n p = 1000 × 0.011 = 11
Control limits are CL = n p = 11
UCLnp = np np p
+ −
3 1
( ) = 11 + 3 11 1 0 011
( . )
− = 20.894
LCLnp = np np p
− − = − −
3 1 11 3 11 1 0 011
( ) ( . ) = 1.106
The np chart is drawn in the figure. Since all the points lie within the
control limits, the process is under control.
1 3 5 7 9 11 13 15
0
5
10
15
20
25
UCL = 20.894
LCL = 1.106
Sample number
( -chart)
np
Number
of
defective
blades
Example 4. In a manufacturing process, the number of defectives found in the
inspection of 20 lots of 100 samples is given below:
Lot number Number of defectives Lot number Number of defectives
1 5 11 7
2 4 12 6
3 3 13 3
4 5 14 5
5 4 15 4
6 6 16 2
7 9 17 8
8 15 18 7
9 11 19 6
10 6 20 4
STATISTICAL COMPUTATION 667
(i) Determine the control limits of p-chart and state whether the process is
in control.
(ii) Determine the new value of mean fraction defective if some points are
out of control. Compute the corresponding control limits and state
whether the process is still in control or not.
(iii) Determine the sample size when a quality limit not worse than 9% is
desirable and a 10% bad product will not be permitted more than three
times in thousand.
Sol. (i) p = =
×
Total number of defectives
Total number of items inspected
120
20 100
= 0.06
UCLP = p
p p
n
+
−
= +
−
3
1
0 06 3
0 06 1 0 06
100
( )
.
. ( . )
= 0.13095
LCLP = p
p p
n
−
−
= −
−
3
1
0 06 3
0 06 1 0 06
100
( )
.
. ( . )
= – 0.01095
Since the fraction defective cannot be (–) ve
∴ LCLP = 0
After observing the values of defectives in the given example, it is clear
that only 8th lot having fraction defective
15
100
= 0.15 will go above UCLP.
(ii) After eliminating the 8th lot,
Revised value of p =
−
×
120 15
100 19
= 0.056
Revised control limits will be
UCLP = 0.056 + 3
0 056 1 0 056
100
. ( . )
−
= 0.125
LCLP = 0.056 – 3
0 056 1 0 056
100
. ( . )
−
= – 0.013 i.e., zero.
It is clear that all the points are within control limits.
∴ Revised quality level p = 0.056
(iii) Since a probability that a defective more than a 9% defective quality
will not be permitted, is more than 3 times in a thousand (0.3%) in corresponding
3σ limits:
∴ p + 3p = 0.09
668 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
0.056 + 3
0 056 1 0 056
. ( . )
−
n
= 0.09 ⇒
0 056 0 034
3
. .
×
=
0.944
n
Squaring,
0 056 0 034
3
2
. .
×
=
F
HG I
KJ
0.944
n
= (0.01133)2
n =
0 056 0 944
0 01133 0 01133
. .
. .
×
×
= 333.
Example 5. A control chart for defects per unit u uses probability limits
corresponding to probabilities of 0.975 and 0.025. The central line on the control
chart is at u = 2.0. The limits vary with the value of n. Determine the correct
position of these upper and lower control limits when n = 5. (Assume σ = 1.96)
Sol. UCLu = u
u
n
+ = +
σ 2
2
5
1.96 = 3.239
LCLu = 2 – 1.96
2
5
= 0.761.
Example 6. Determine the control limits for X and R charts if ∑ X = 357.50,
∑R = 9.90, number of subgroups = 20. It is given that A2 = 0.18, D3 = 0.41, D4 =
1.59 and d2 = 3.736. Also find the process capability.
Sol. X =
X
N
∑
=
357 50
20
.
= 17.875
R =
R
N
∑
=
9 90
20
.
= 0.495
UCL X A R
X 2
= + = 17.875 + (0.18 × 0.495) = 17.9641
LCL X A R
X 2
= − = 17.875 – (0.18 × 0.495) = 17.7859
UCLR = D4R = 1.59 × 0.495 = 0.78705
LCLR = D3 R = 0.41 × 0.495 = 0.20295
σ =
R
d2
0 495
3 735
=
.
.
= 0.13253
∴ Process capability = 6σ = 6 × 0.13253 = 0.79518.
Example 7. If the average fraction defective of a large sample of a product is
0.1537, Calculate the control limits given that sub-group size is 2000.
Sol. Average fraction defective
p = 0.1537
STATISTICAL COMPUTATION 669
Sub-group size is 2000
∴ n = 2000
Central line CL = n p = 2000 × 0.1537 = 307.4
UCLnp = n p + 3σnp = np np p
+ −
3 1
( )
= 307.4 + 3 307 4 1 0 1537
. ( . )
− = 307.4 + 48.38774204
= 355.787742
and LCLnp = np np p
− −
3 1
( ) = 307.4 – 48.38774204
= 259.012258
ASSIGNMENT 7.7
1. A company manufactures screws to a nominal diameter 0.500 ± 0.030 cm. Five samples
were taken randomly from the manufactured lots and 3 measurements were taken on
each sample at different lengths. Following are the readings:
Sample number Measurement per sample x(in cm)
1 2 3
1 0.488 0.489 0.505
2 0.494 0.495 0.499
3 0.498 0.515 0.487
4 0.492 0.509 0.514
5 0.490 0.508 0.499
Calculate the control limits of X and R charts. Draw X and R charts and examine
whether the process is in statistical control?
[Take A2 = 1.02, D4 = 2.57, D3 = 0 for n = 3]
2. The average percentage of defectives in 27 samples of size 1500 each was found to be
13.7%. Construct P-chart for this situation. Explain how the control chart can be used to
control quality.
[Hint: p = 0.137]
3. The number of customer complaints received daily by an organization is given below:
Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Complaints: 2 3 0 1 9 2 0 0 4 2 0 7 0 2 4
Does it mean that the number of complaints is under statistical control? Establish a
control scheme for the future.
670 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
4. It was found that when a manufacturing process is under control, the average number
of defectives per sample batch of 10 is 1.2. What limits would you set in a quality control
chart based on the examination of defectives in sample batches of 10?
[Hint: p = 0.12, n p = 1.2]
5. The following data shows the value of sample mean X and range R for 10 samples of
size 5 each. Calculate the values for central line and control limits for X -chart and R
chart and determine whether the process is under control.
Sample number:1 2 3 4 5 6 7 8 9 10
Mean X : 11.2 11.8 10.8 11.6 11 9.6 10.4 9.6 10.6 10
Range R: 7 4 8 5 7 4 8 4 7 9
Assume for n = 5, A2 = 0.577, D3 = 0 and D4 = 2.115.
6. What are statistical quality control techniques? Discuss the objectives and advantages
of statistical quality control.
7. The following table shows the number of missing rivets observed at the time of inspection
of 12 aircrafts. Find the control limits for the number of defects chart and comment on
the state of control.
Air craft number: 1 2 3 4 5 6 7 8 9 10 11 12
Number of
missing rivets: 7 15 13 18 10 14 13 10 20 11 22 15
Chapter 8 TESTING OF HYPOTHESIS
671
8.1 POPULATION OR UNIVERSE
A
n aggregate of objects (animate or inanimate) under study is called
population or universe. It is thus a collection of individuals or of
their attributes (qualities) or of results of operations which can be
numerically specified.
A universe containing a finite number of individuals or members is called
a finite inverse. For example, the universe of the weights of students in a
particular class.
A universe with infinite number of members is known as an infinite
universe. For example, the universe of pressures at various points in the
atmosphere.
In some cases, we may be even ignorant whether or not a particular universe
is infinite, for example, the universe of stars.
The universe of concrete objects is an existent universe. The collection of
all possible ways in which a specified event can happen is called a hypothetical
universe. The universe of heads and tails obtained by tossing a coin an infinite
number of times (provided that it does not wear out) is a hypothetical one.
672 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
8.2 SAMPLING
The statistician is often confronted with the problem of discussing a universe
of which he cannot examine every member, i.e., of which complete enumeration
is impracticable. For example, if we want to have an idea of the average per
capita income of the people of a country, enumeration of every earning individual
in the country is a very difficult task. Naturally, the question arises: What can
be said about a universe of which we can examine only a limited number of
members? This question is the origin of the Theory of Sampling.
A finite subset of a universe is called a sample. A sample is thus a small
portion of the universe. The number of individuals in a sample is called the
sample size. The process of selecting a sample from a universe is called
sampling.
The theory of sampling is a study of relationship existing between a
population and samples drawn from the population. The fundamental object of
sampling is to get as much information as possible of the whole universe by
examining only a part of it. An attempt is thus made through sampling to give
the maximum information about the parent universe with the minimum effort.
Sampling is quite often used in our day-to-day practical life. For example,
in a shop we assess the quality of sugar, rice, or any other commodity by taking
only a handful of it from the bag and then decide whether to purchase it or not.
A housewife normally tests the cooked products to find if they are properly
cooked and contain the proper quantity of salt or sugar, by taking a spoonful of
it.
8.3 PARAMETERS OF STATISTICS
The statistical constants of the population such as mean, the variance, etc. are
known as the parameters. The statistical concepts of the sample from the
members of the sample to estimate the parameters of the population from which
the sample has been drawn is known as statistic.
Population mean and variance are denoted by μ and σ2, while those of the
samples are given by x , s2.
8.4 STANDARD ERROR
The standard deviation of the sampling distribution of a statistic is known as
the standard error (S.E.). It plays an important role in the theory of large
samples and it forms a basis of the testing of hypothesis. If t is any statistic, for
large sample.
TESTING OF HYPOTHESIS 673
z =
t t
t
− E
S E
( )
. ( )
is normally distributed with mean 0 and variance unity.
For large sample, the standard errors of some of the well known statistic
are listed below:
n—sample size; σ2—population variance; s2—sample variance; p—population
proportion ; Q = 1 – p; n1, n2—are sizes of two independent random samples.
Number Statistic Standard error
1. x σ/ n
2. s σ2
2
/ n
3. Difference of two sample means x x
1 2
−
σ σ
1
2
1
2
2
2
n n
+
4. Difference of two sample standard deviation s1 – s2
σ σ
1
2
1
2
2
2
2 2
n n
+
5. Difference of two sample proportions p1 – p2
P Q P Q
1 1
1
2 2
2
n n
+
6. Observed sample proportion p PQ/n
8.5 TEST OF SIGNIFICANCE
An important aspect of the sampling theory is to study the test of significance
which will enable us to decide, on the basis of the results of the sample, whether
(i) the deviation between the observed sample statistic and the hypothetical
parameter value or
(ii) the deviation between two sample statistics is significant or might be
attributed due to chance or the fluctuations of the sampling.
For applying the tests of significance, we first set up a hypothesis which is
a definite statement about the population parameter called Null hypothesis
denoted by H0.
Any hypothesis which is complementary to the null hypothesis (H0) is called
an Alternative hypothesis denoted by H1.
674 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
For example, if we want to test the null hypothesis that the population has
a specified mean μ0, then we have
H0: μ = μ0
Alternative hypothesis will be
(i) H1: μ ≠ μ0 (μ  μ0 or μ  μ0) (two tailed alternative hypothesis).
(ii) H1: μ  μ0 (right tailed alternative hypothesis (or) single tailed).
(iii) H1: μ  μ0 (left tailed alternative hypothesis (or) single tailed).
Hence alternative hypothesis helps to know whether the test is two tailed
test or one tailed test.
8.6 CRITICAL REGION
A region corresponding to a statistic t, in the sample space S which amounts to
rejection of the null hypothesis H0 is called as critical region or region of
rejection. The region of the sample space S which amounts to the acceptance
of H0 is called acceptance region.
8.7 LEVEL OF SIGNIFICANCE
The probability of the value of the variate falling in the critical region is known
as level of significance. The probability α that a random value of the statistic t
belongs to the critical region is known as the level of significance.
P(t ∈ ω| H0) = α
i.e., the level of significance is the size of the type I error or the maximum
producer’s risk.
8.8 ERRORS IN SAMPLING
The main aim of the sampling theory is to draw a valid conclusion about the
population parameters on the basis of the sample results. In doing this we may
commit the following two types of errors:
Type I Error. When H0 is true, we may reject it.
P(Reject H0 when it is true) = P(Reject H0/H0) = α
α is called the size of the type I error also referred to as producer’s risk.
TESTING OF HYPOTHESIS 675
Type II Error. When H0 is wrong we may accept it P(Accept H0 when it is
wrong) = P(Accept H0/H1) = β . β is called the size of the type II error, also
referred to as consumer’s risk.
The values of the test statistic which separates the critical region and
acceptance region are called the critical values or significant values.
This value is dependent on (i) the level of significance used and (ii) the
alternative hypothesis, whether it is one-tailed or two-tailed.
For larger samples corresponding to the statistic t, the variable z =
t t
t
− E
S.E
( )
( )
is normally distributed with mean 0 and variance 1. The value of z given above
under the null hypothesis is known as test statistic.
The critical value of zα of the test statistic at level of significance α for a
two-tailed test is given by
p(| z |  zα) = α (1)
i.e., zα is the value of z so that the total area of the critical region on both tails
is α. Since the normal curve is symmetrical, from equation (1), we get
p(z  zα) + p(z  – zα) = α; i.e., 2p(z  zα) = α; p(z  zα) = α/2
i.e., the area of each tail is α/2.
Lower critical
value
z = – za
Level of significance (Two tailed test)
a
Rejection
region ( /2)
a
Upper critical
value
Rejection
region ( /2)
a
z = 0 z = za
z = 0
Right tailed test
Acceptance
region Rejection
region
( )
a
z = za
Left tailed test
Acceptance
region
z = – za z = 0
Rejection
region
( )
a
The critical value zα is that value such that the area to the right of zα is
α/2 and the area to the left of – zα is α/2.
In the case of the one-tailed test,
p(z  zα) = α if it is right-tailed; p(z  – zα) = α if it is left-tailed.
NOTE
676 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
The critical value of z for a single-tailed test (right or left) at level of
significance α is same as the critical value of z for two-tailed test at level of
significance 2α.
Using the equation, also using the normal tables, the critical value of z at
different levels of significance (α) for both single tailed and two tailed test are
calculated and listed below. The equations are
p(| z |  zα) = α; p(z  zα) = α; p(z  – zα) = α
Level of significance
1% (0.01) 5% (0.05) 10% (0.1)
Two tailed test | zα | = 2.58 | z | = 1.966 | z | = 0.645
Right tailed zα = 2.33 zα = 1.645 zα = 1.28
Left tailed zα = – 2.33 zα = – 1.645 zα = – 1.28
8.9 STEPS IN TESTING OF STATISTICAL HYPOTHESIS
Step 1. Null hypothesis. Set up H0 in clear terms.
Step 2. Alternative hypothesis. Set up H1, so that we could decide whether
we should use one tailed test or two tailed test.
Step 3. Level of significance. Select the appropriate level of significance
in advance depending on the reliability of the estimates.
Step 4. Test statistic. Compute the test statistic z =
t t
t
− E
S.E
( )
( )
under the null
hypothesis.
Step 5. Conclusion. Compare the computed value of z with the critical value
zα at level of significance (α).
If | z |  zα, we reject H0 and conclude that there is significant
difference. If | z |  zα, we accept H0 and conclude that there is no
significant difference.
8.10 TEST OF SIGNIFICANCE FOR LARGE SAMPLES
If the sample size n  30, the sample is taken as large sample. For such sample
we apply normal test, as Binomial, Poisson, chi square, etc. are closely
approximated by normal distributions assuming the population as normal.
Under large sample test, the following are the important tests to test the
significance:
1. Testing of significance for single proportion.
2. Testing of significance for difference of proportions.
TESTING OF HYPOTHESIS 677
3. Testing of significance for single mean.
4. Testing of significance for difference of means.
5. Testing of significance for difference of standard deviations.
8.10.1 Testing of Significance for Single Proportion
This test is used to find the significant difference between proportion of the
sample and the population. Let X be the number of successes in n independent
trials with constant probability P of success for each trial.
E(X) = nP; V(X) = nPQ; Q = 1 – P = Probability of failure.
Let p = X/n called the observed proportion of success.
E(p) = E(X/n) =
1
n
x
E( ) =
np
n
= p; E(p) = p
V(p) = V(X/n) =
1
2
n
V(X) =
1( )
PQ
n
= PQ/n
S.E.(p) =
PQ
n
; z =
p p
p
p p
n
−
=
−
E
S.E. PQ
( )
( ) /
~ N(0, 1)
This z is called test statistic which is used to test the significant difference
of sample and population proportion.
1. The probable limit for the observed proportion of successes are p±
zα PQ/n , where zα is the significant value at level of significance α..
2. If p is not known, the limits for the proportion in the population are
p± zα pq n
/ , q = 1 – p.
3. If α is not given, we can take safely 3σ limits.
Hence, the confidence limits for observed proportion p are p ± 3
PQ
n
.
The confidence limits for the population proportion p are p ±
pq
n
.
EXAMPLES
Example 1. A coin was tossed 400 times and the head turned up 216 times.
Test the hypothesis that the coin is unbiased.
Sol.H0: The coin is unbiased i.e., P = 0.5.
H1: The coin is not unbiased (biased); P ≠ 0.5
NOTE
678 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Here n = 400; X = Number of success = 216
p = proportion of success in the sample
X
n
=
216
400
= 0.54.
Population proportion = 0.5 = P; Q = 1 – P = 1 – 0.5 = 0.5.
Under H0, test statistic z =
p
n
− P
PQ/
| z | =
0 54 0 5
0 5 0 5
400
. .
. .
−
×
= 1.6
we use a two-tailed test.
Conclusion. Since | z | = 1.6  1.96
i.e., | z |  zα, zα is the significant value of z at 5% level of significance.
i.e., the coin is unbiased is P = 0.5.
Example 2. A manufacturer claims that only 4% of his products supplied by
him are defective. A random sample of 600 products contained 36 defectives.
Test the claim of the manufacturer.
Sol. (i) P = observed proportion of success.
i.e., P = proportion of defective in the sample =
36
600
= 0.06
p = proportion of defectives in the population = 0.04
H0: p = 0.04 is true.
i.e., the claim of the manufacturer is accepted.
H1: (i) P ≠ 0.04 (two tailed test)
(ii) If we want to reject, only if p  0.04 then (right tailed).
Under H0, z =
p
n
−
=
−
×
P
PQ/
0 06 0 04
0 04 0 96
600
. .
. .
= 2.5.
Conclusion. Since | z | = 2.5  1.96, we reject the hypothesis H0 at 5%
level of significance two tailed.
If H1 is taken as p  0.04 we apply right tailed test.
| z | = 2.5  1.645 (zα) we reject the null hypothesis here also.
In both cases, manufacturer’s claim is not acceptable.
TESTING OF HYPOTHESIS 679
Example 3. A machine is producing bolts a certain fraction of which are
defective. A random sample of 400 is taken from a large batch and is found to
contain 30 defective bolts. Does this indicate that the proportion of defectives is
larger than that claimed by the manufacturer if the manufacturer claims that
only 5% of his product are defective? Find 95% confidence limits of the proportion
of defective bolts in batch.
Sol. Null hypothesis H0: The manufacturer claim is accepted i.e.,
P =
5
100
= 0.05
Q = 1 – P = 1 – 0.05 = 0.95
Alternative hypothesis. p  0.05 (Right tailed test).
p = observed proportion of sample =
30
400
= 0.075
Under H0, the test statistic
z =
p
n
− P
PQ/
∴ z =
0 075 0 05
0 05 0 95
400
. .
. .
−
×
= 2.2941.
Conclusion. The tabulated value of z at 5% level of significance for the
right-tailed test is
zα = 1.645. Since | z | = 2.2941  1.645,
H0 is rejected at 5% level of significance. i.e., the proportion of defective is
larger than the manufacturer claim.
To find 95% confidence limits of the proportion.
It is given by p ± zα PQ/n
0.05 ± 1.96
0 05 0 95
400
. .
×
= 0.05 ± 0.02135 = 0.07136, 0.02865
Hence 95% confidence limits for the proportion of defective bolts are
(0.07136, 0.02865).
Example 4. A bag contains defective articles, the exact number of which is not
known. A sample of 100 from the bag gives 10 defective articles. Find the limits
for the proportion of defective articles in the bag.
Sol. Here p = proportion of defective articles =
10
100
= 0.1;
q = 1 – p = 1 – 0.1 = 0.9
Since the confidence limit is not given, we assume it is 95%. ∴ level of
significance is 5% zα = 1.96.
680 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Also the proportion of population P is not given. To get the confidence limit,
we use P and it is given by
P ± zα pq n
/ = 0.1 ± 1.96
0 1 0 9
100
. .
×
= 0.1 ± 0.0588 = 0.1588, 0.0412.
Hence 95% confidence limits for defective articles in the bag are (0.1588,
0.0412).
ASSIGNMENT 8.1
1. A sample of 600 persons selected at random from a large city shows that the percentage
of males in the sample is 53. It is believed that the ratio of males to the total population
in the city is 0.5. Test whether the belief is confirmed by the observation.
2. In a city a sample of 1000 people was taken and 540 of them are vegetarian and the rest
are non-vegetarian. Can we say that both habits of eating (vegetarian or non-vegetarian)
are equally popular in the city at (i) 1% level of significance (ii) 5% level of significance?
3. 325 men out of 600 men chosen from a big city were found to be smokers. Does this
information support the conclusion that the majority of men in the city are smokers?
4. A random sample of 500 bolts was taken from a large consignment and 65 were found to
be defective. Find the percentage of defective bolts in the consignment.
5. In a hospital 475 female and 525 male babies were born in a week. Do these figures
confirm the hypothesis that males and females are born in equal number?
6. 400 apples are taken at random from a large basket and 40 are found to be bad. Estimate
the proportion of bad apples in the basket and assign limits within which the percentage
most probably lies.
8.10.2 Testing of Significance for Difference of Proportions
Consider two samples X1 and X2 of sizes n1 and n2, respectively, taken from
two different populations. Test the significance of the difference between the
sample proportion p1 and p2. The test statistic under the null hypothesis H0,
that there is no significant difference between the two sample proportion, we
have
z =
p p
n n
1 2
1 2
1 1
−
+
F
HG I
KJ
PQ
, where P =
n p n p
n n
1 1 2 2
1 2
+
+
and Q = 1 – P.
TESTING OF HYPOTHESIS 681
EXAMPLES
Example 1. Before an increase in excise duty on tea, 800 people out of a sample
of 1000 persons were found to be tea drinkers. After an increase in the duty, 800
persons were known to be tea drinkers in a sample of 1200 people. Do you think
that there has been a significant decrease in the consumption of tea after the
increase in the excise duty?
Sol. Here n1 = 800, n2 = 1200
p1 =
X1
1
800
1000
4
5
n
= = ; p2 =
X2
2
800
1200
2
3
n
= =
P =
p n p n
n n
1 1 2 2
1 2
+
+
=
X X
1 2
1 2
+
+
n n
=
800 800
1000 1200
8
11
+
+
= ; Q =
3
11
Null hypothesis H0: p1 = p2, i.e., there is no significant difference in the
consumption of tea before and after increase of excise duty.
H1: p1  p2 (right-tailed test)
The test statistic
z =
p p
n n
1 2
1 2
1 1
−
+
F
HG I
KJ
PQ
=
0 8 0 6666
8
11
3
11
1
1000
1
1200
. .
−
× +
F
HG I
KJ
= 6.842.
Conclusion. Since the calculated value of | z |  1.645 also | z |  2.33,
both the significant values of z at 5% and 1% level of significance. Hence H0 is
rejected, i.e., there is a significant decrease in the consumption of tea due to
increase in excise duty.
Example 2. A machine produced 16 defective articles in a batch of 500. After
overhauling it produced 3 defectives in a batch of 100. Has the machine
improved?
Sol. p1 =
16
500
= 0.032; n1 = 500 p2 =
3
100
= 0.03; n2 = 100
Null hypothesis H0: The machine has not improved due to overhauling,
p1 = p2.
H1: p1  p2 (right-tailed)
∴ P =
p n p n
n n
1 1 2 2
1 2
19
600
+
+
= ~
= 0.032
682 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Under H0, the test statistic
z =
p p
n n
1 2
1 2
1 1
0 032 0 03
0 032 0 968
1
500
1
100
−
+
F
HG I
KJ
=
−
+
F
HG I
KJ
PQ
. .
( . )( . )
= 0.104.
Conclusion. The calculated value of | z |  1.645, the significant value of
z at 5% level of significance, H0 is accepted, i.e., the machine has not improved
due to overhauling.
Example 3. In two large populations, there are 30% and 25%, respectively, of
fair haired people. Is this difference likely to be hidden in samples of 1200 and
900, respectively, from the two populations.
Sol. p1 = proportion of fair haired people in the first population = 30% = 0.3;
p2 = 25% = 0.25; Q1 = 0.7; Q2 = 0.75.
H0: Sample proportions are equal, i.e., the difference in population
proportions is likely to be hidden in sampling.
H1: p1 ≠ p2
z =
P P
P Q P Q
2 2
1 2
1 1
1 2
03 0 25
03 07
1200
0 25 075
900
−
+
=
−
×
+
×
n n
. .
. . . .
= 2.5376.
Conclusion. Since | z |  1.96, the significant value of z at 5% level of
significance, H0 is rejected. However | z |  2.58, the significant value of z at
1% level of significance, H0 is accepted. At 5% level, these samples will reveal
the difference in the population proportions.
Example 4. 500 articles from a factory are examined and found to be 2%
defective. 800 similar articles from a second factory are found to have only 1.5%
defective. Can it reasonably be concluded that the product of the first factory
are inferior to those of second?
Sol.n1 = 500, n2 = 800
p1 = proportion of defective from first factory = 2% = 0.02
p2 = proportion of defective from second factory = 1.5% = 0.015
H0: There is no significant difference between the two products, i.e., the
products do not differ in quality.
H1: p1  p2 (one tailed test)
Under H0, z =
p p
n n
1 2
2
1
−
+
F
HG I
KJ
PQ
1
1
TESTING OF HYPOTHESIS 683
P =
n p n p
n n
1 1 2 2
1 2
0 02 500 0 015 800
500 800
+
+
=
+
+
. ( ) ( . )( )
= 0.01692;
Q = 1 – P = 0.9830
z =
0 02 0 015
0 01692 0 983
1
500
1
800
. .
. .
−
× +
F
HG I
KJ
= 0.68
Conclusion. As | z |  1.645, the significant value of z at 5% level of
significance, H0 is accepted i.e., the products do not differ in quality.
ASSIGNMENT 8.2
1. A random sample of 400 men and 600 women were asked whether they would like to
have a school near their residence. 200 men and 325 women were in favor of the proposal.
Test the hypothesis that the proportion of men and women in favor of the proposal are
the same at 5% level of significance.
2. In a town A, there were 956 births, of which 52.5% were males while in towns A and B
combined, this proportion in total of 1406 births was 0.496. Is there any significant
difference in the proportion of male births in the two towns?
3. In a referendum submitted to the student body at a university, 850 men and 560 women
voted. 500 men and 320 women voted yes. Does this indicate a significant difference of
opinion between men and women on this matter at 1% level?
4. A manufacturing firm claims that its brand A product outsells its brand B product by
8%. If it is found that 42 out of a sample of 200 persons prefer brand A and 18 out of
another sample of 100 persons prefer brand B. Test whether the 8% difference is a valid
claim.
8.10.3 Testing of Significance for Single Mean
To test whether the difference between sample mean and population mean is
significant or not.
Let X1, X2, ......, Xn be a random sample of size n from a large population X1,
X2, ......, XN of size N with mean μ and variance σ2. ∴ the standard error of
mean of a random sample of size n from a population with variance σ2 is σ/ n .
To test whether the given sample of size n has been drawn from a population
with mean μ, i.e. to test whether the difference between the sample mean and
the population mean is significant. Under the null hypothesis, there is no
difference between the sample mean and population mean.
The test statistic is z =
x
n
− μ
σ/
, where σ is the standard deviation of the
population.
684 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
If σ is not known, we use the test statistic z =
X − μ
s n
/
, where s is the standard
deviation of the sample.
If the level of significance is a and zα is the critical value
– zα  | z | =
x
n
− μ
σ/
 zα.
The limits of the population mean μ are given by
x z
n
x z
n
−   +
α α
σ
μ
σ .
At 5% level of significance, 95% confidence limits are
x 1.96
n
x 1.96
n
−   +
σ
μ
σ
At 1% level of significance, 99% confidence limits are
x
n
x
n
−   +
2 58 2 58
. .
σ
μ
σ
.
These limits are called confidence limits or fiducial limits.
EXAMPLES
Example 1. A normal population has a mean of 6.8 and standard deviation of
1.5. A sample of 400 members gave a mean of 6.75. Is the difference significant?
Sol.H0: There is no significant difference between x and μ.
H1: There is significant difference between x and μ.
Given μ = 6.8, σ = 1.5, x = 6.75 and n = 400
| z | =
x
n
−
=
−
μ
σ/
. .
/
6 75 6 8
900
1.5
= | – 0.67 | = 0.67
Conclusion. As the calculated value of | z |  zα = 1.96 at 5% level of
significance, H0 is accepted, i.e., there is no significant difference between x
and μ.
Example 2. A random sample of 900 members has a mean 3.4 cms. Can it be
reasonably regarded as a sample from a large population of mean 3.2 cms and
standard deviation 2.3 cms?
Sol. Here n = 900, x = 3.4, μ = 3.2, σ = 2.3
NOTE
TESTING OF HYPOTHESIS 685
H0: Assume that the sample is drawn from a large population with mean 3.2
and standard deviation = 2.3
H1: μ ≠ 3.25 (Apply two-tailed test)
Under H0; z =
x
n
−
=
−
μ
σ/
. .
. /
3 4 3 2
2 3 900
= 0.261.
Conclusion. As the calculated value of | z | = 0.261  1.96, the significant
value of z at 5% level of significance, H0 is accepted, i.e., the sample is drawn
from the population with mean 3.2 and standard deviation = 2.3.
Example 3. The mean weight obtained from a random sample of size 100 is 64
gms. The standard deviation of the weight distribution of the population is 3
gms. Test the statement that the mean weight of the population is 67 gms at 5%
level of significance. Also set up 99% confidence limits of the mean weight of the
population.
Sol. Here n = 100, μ = 67, x = 64, σ = 3
H0: There is no significant difference between sample and population mean.
i.e., μ = 67, the sample is drawn from the population with μ = 67.
H1: μ ≠ 67 (Two-tailed test).
Under H0, z =
x
n
−
=
−
μ
σ/ /
64 67
3 100
= – 10 ∴ | z | = 10.
Conclusion. Since the calculated value of | z |  1.96, the significant
value of z at 5% level of significance, H0 is rejected, i.e., the sample is not
drawn from the population with mean 67.
To find 99% confidence limits, given by
x ± 2.58 σ/ n = 64 ± 2.58(3/ 100 ) = 64.774, 63.226.
Example 4. The average score in mathematics of a sample of 100 students was
51 with a standard deviation of 6 points. Could this have been a random sample
from a population with average scores 50?
Sol. Here n = 100, x = 51, s = 6, μ = 50; σ is unknown.
H0: The sample is drawn from a population with mean 50, μ = 50
H1: μ ≠ 50
Under H0, z =
x
s n
−
=
−
=
μ
/ /
51 50
6 100
10
6
= 1.6666.
Conclusion. Since | z | = 1.666  1.96, zα the significant value of z at 5%
level of significance, H0 is accepted, i.e., the sample is drawn from the population
with mean 50.
686 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 8.3
1. A sample of 1000 students from a university was taken and their average weight was
found to be 112 pounds with a standard deviation of 20 pounds. Could the mean weight
of students in the population be 120 pounds?
2. A sample of 400 male students is found to have a mean height of 160 cms. Can it be
reasonably regarded as a sample from a large population with mean height 162.5 cms
and standard deviation 4.5 cms?
3. A random sample of 200 measurements from a large population gave a mean value of 50
and a standard deviation of 9. Determine 95% confidence interval for the mean of popu-
lation.
4. The guaranteed average life of certain type of bulbs is 1000 hours with a standard de-
viation of 125 hours. It is decided to sample the output so as to ensure that 90% of the
bulbs do not fall short of the guaranteed average by more than 2.5%. What must be the
minimum size of the sample?
5. The heights of college students in a city are normally distributed with standard devia-
tion 6 cms. A sample of 1000 students has mean height 158 cms. Test the hypothesis
that the mean height of college students in the city is 160 cms.
8.10.4 Test of Significance for Difference of Means of Two Large Samples
Let x1 be the mean of a sample of size n1 from a population with mean μ1, and
variance σ1
2. Let x2 be the mean of an independent sample of size n2 from
another population with mean μ2 and variance σ2
2. The test statistic is given
by z =
x x
n n
1 2
1
2
1
2
2
2
−
+
σ σ
.
Under the null hypothesis that the samples are drawn from the same
population where σ1 = σ2 = σ, i.e., μ1 = μ2 the test statistic is given by
z =
x x
n n
1 2
1 2
1 1
−
+
σ
.
1. If σ1, σ2 are not known and σ1 ≠ σ2 the test statistic in this case is
z =
x x
s s
n n
1 2
1
2
2
2
1 2
−
+
+
.
NOTE
TESTING OF HYPOTHESIS 687
2. If σ is not known and σ1 = σ2. We use σ2 =
n s n s
n n
1 1
2
2 2
2
1 2
+
+
to calculate σ;
z =
x x
n s n s
n n
1
n
1
n
1 2
1 1
2
2 2
2
1 2 1 2
−
+
+
+
F
HG I
KJ
.
EXAMPLES
Example 1. The average income of persons was 210 with a standard deviation
of 10 in a sample of 100 people. For another sample of 150 people, the average
income was 220 with a standard deviation of 12. The standard deviation of
incomes of the people of the city was 11. Test whether there is any significant
difference between the average incomes of the localities.
Sol. Here n1 = 100, n2 = 150, x1 = 210, x2 = 220, s1 = 10, s2 = 12.
Null hypothesis. The difference is not significant, i.e., there is no difference
between the incomes of the localities.
H0: x x
1 2
= , H1: x1 ≠ x2
Under H0, z =
x x
s
n
s
n
1 2
1
2
1
2
2
2
2 2
210 220
10
100
12
150
−
+
=
−
+
= – 7.1428 ∴ | z | = 7.1428.
Conclusion. As the calculated value of | z |  1.96, the significant value
of z at 5% level of significance, H0 is rejected i.e., there is significant difference
between the average incomes of the localities.
Example 2. Intelligence tests were given to two groups of boys and girls.
Mean Standard deviation Size
Girls 75 8 60
Boys 73 10 100
Examine if the difference between mean scores is significant.
Sol. Null hypothesis H0: There is no significant difference between mean
scores, i.e., x1 = x2.
H1: x1 ≠ x2
Under the null hypothesis z =
x x
s
n
s
n
1 2
1
2
1
2
2
2
2 2
75 73
8
60
10
100
−
+
=
−
+
= 1.3912.
688 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Conclusion. As the calculated value of | z |  1.96, the significant value
of z at 5% level of significance, H0 is accepted i.e., there is no significant difference
between mean scores.
ASSIGNMENT 8.4
1. Intelligence tests on two groups of boys and girls gave the following results. Examine if
the difference is significant.
Mean Standard Deviation Size
Girls 70 10 70
Boys 75 11 100
2. Two random samples of 1000 and 2000 farms gave an average yield of 2000 kg and 2050
kg, respectively. The variance of wheat farms in the country may be taken as 100 kg.
Examine whether the two samples differ significantly in yield.
3. A sample of heights of 6400 soldiers has a mean of 67.85 inches and a standard devia-
tion of 2.56 inches. While another sample of heights of 1600 sailors has a mean of 68.55
inches with standard deviation of 2.52 inches. Do the data indicate that sailors are, on
the average, taller than soldiers?
4. In a survey of buying habits, 400 women shoppers are chosen at random in supermarket
A. Their average weekly food expenditure is 250 with a standard deviation of 40. For
500 women shoppers chosen at supermarket B, the average weekly food expenditure is
220 with a standard deviation of 45. Test at 1% level of significance whether the aver-
age food expenditures of the two groups are equal.
5. A random sample of 200 measurements from a large population gave a mean value of 50
and standard deviation of 9. Determine the 95% confidence interval for the mean of the
population.
6. The means of two large samples of 1000 and 2000 members are 168.75 cms and 170 cms,
respectively. Can the samples be regarded as drawn from the same population of stand-
ard deviation 6.25 cms?
8.10.5 Test of Significance for the Difference of Standard Deviations
If s1 and s2 are the standard deviations of two independent samples, then under
the null hypothesis H0: σ1 = σ2, i.e., the sample standard deviations don’t differ
significantly, the statistic
TESTING OF HYPOTHESIS 689
z =
s s
n n
1 2
1
2
1
2
2
2
2 2
−
+
σ σ
, where σ1 and σ2 are population standard deviations.
When population standard deviations are not known, then z =
s s
s
n
s
n
1 2
1
2
1
2
2
2
2 2
−
+
.
EXAMPLE
Example. Random samples drawn from two countries gave the following data
relating to the heights of adult males:
Country A Country B
Mean height (in inches) 67.42 67.25
Standard deviation 2.58 2.50
Number in samples 1000 1200
(i) Is the difference between the means significant?
(ii) Is the difference between the standard deviations significant?
Sol. Given: n1 = 1000, n2 = 1200, x1 = 67.42; x2 = 67.25, s1 = 2.58, s2 = 2.50
Since the samples size are large we can take σ1 = s1 = 2.58; σ2 = s2 = 2.50.
(i) Null hypothesis: H0 = μ1 = μ2 i.e., sample means do not differ
significantly.
Alternative hypothesis: H1: μ1 ≠ μ2 (two tailed test)
z =
x x
s
n
s
n
1 2
1
2
1
2
2
2
2 2
67 42 67 25
2 58
1000
2 50
1200
−
+
=
−
+
. .
( . ) ( . )
= 1.56.
Since | z |  1.96 we accept the null hypothesis at 5% level of significance.
(ii) We set up the null hypothesis.
H0: σ1 = σ2 i.e., the sample standard deviations do not differ significantly.
Alternative hypothesis: H1 = σ1 ≠ σ2 (two tailed)
690 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
∴ The test statistic is given by
z =
s s
n n
s s
s
n
s
n
1 2
1
2
1
2
2
2
1 2
1
2
1
2
2
2
2 2 2 2
−
+
=
−
+
σ σ
(∵ σ1 = s1, σ2 = s2 for large samples)
=
2 58 2 50
2 58
2 1000
2 50
2 1200
0 08
6 6564
2000
6 25
2400
2 2
. .
( . ) ( . )
.
. .
−
×
×
×
=
+
= 1.0387.
Since | z |  1.96 we accept the null hypothesis at 5% level of significance.
ASSIGNMENT 8.5
1. The mean yield of two sets of plots and their variability are as given. Examine
(i) whether the difference in the mean yield of the two sets of plots is significant.
(ii) whether the difference in the variability in yields is significant.
Set of 40 plots Set of 60 plots
Mean yield per plot 1258 lb 1243 lb
Standard deviation per plot 34 28
2. The yield of wheat in a random sample of 1000 farms in a certain area has a standard
deviation of 192 kg. Another random sample of 1000 farms gives a standard deviation of
224 kg. Are the standard deviation significantly different ?
8.11 TEST OF SIGNIFICANCE OF SMALL SAMPLES
When the size of the sample is less than 30, then the sample is called small
sample. For such sample it will not be possible for us to assume that the random
sampling distribution of a statistic is approximately normal and the values
given by the sample data are sufficiently close to the population values and
can be used in their place for the calculation of the standard error of the estimate.
TESTING OF HYPOTHESIS 691
t-TEST
8.12 STUDENT’S t-DISTRIBUTION
This t-distribution is used when sample size is ≤ 30 and the population standard
deviation is unknown.
t-statistic is defined as t =
x
s n
− μ
/
~ t(n – 1 d. f) d.f–degrees of freedom
where s =
Σ( )
X X
−
−
2
1
n
.
8.12.1 The t-Table
The t-table given at the end is the probability integral of t-distribution. The
t-distribution has different values for each degrees of freedom and when the
degrees of freedom are infinitely large, the t-distribution is equivalent to normal
distribution and the probabilities shown in the normal distribution tables are
applicable.
8.12.2 Applications of t-Distribution
Some of the applications of t-distribution are given below:
1. To test if the sample mean ( )
X differs significantly from the hypothetical
value μ of the population mean.
2. To test the significance between two sample means.
3. To test the significance of observed partial and multiple correlation coeffi-
cients.
8.12.3 Critical Value of t
The critical value or significant value of t at level of significance α degrees of
freedom γ for two tailed test is given by
P[| t |  tγ (α)] = α
P[| t | ≤ tγ (α)] = 1 – α
The significant value of t at level of significance α for a single tailed test can
be determined from those of two-tailed test by referring to the values at 2α.
692 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
8.13 TEST I: t-TEST OF SIGNIFICANCE OF THE MEAN OF A RANDOM
SAMPLE
To test whether the mean of a sample drawn from a normal population deviates
significantly from a stated value when variance of the population is unknown.
H0: There is no significant difference between the sample mean x and the
population mean μ, i.e., we use the statistic
t =
X − μ
s n
/
where X is mean of the sample.
s2 =
1
1 1
2
n i
n
i
−
−
=
∑ ( )
X X with degrees of freedom (n – 1).
At a given level of significance α1 and degrees of freedom (n – 1). We refer
to t-table tα (two-tailed or one-tailed). If calculated t value is such that | t |  tα
the null hypothesis is accepted. | t |  tα, H0 is rejected.
8.13.1 Fiducial Limits of Population Mean
If tα is the table of t at level of significance α at (n – 1) degrees of freedom.
X − μ
s n
/
 tα for acceptance of H0.
x – tα s/ n  μ  x + tα s/ n
95% confidence limits (level of significance 5%) are X ± t0.05 s n
/ .
99% confidence limits (level of significance 1%) are X ± t0.01 s n
/ .
Instead of calculating s, we calculate S for the sample.
Since s2 =
1
1 1
2
n i
n
i
−
−
=
∑ ( )
X X
∴ S2 =
1
1
2
n i
n
i
=
∑ −
( )
X X . | ∵ (n – 1)s2 = nS2
NOTE
TESTING OF HYPOTHESIS 693
EXAMPLES
Example 1. A random sample of size 16 has 53 as mean. The sum of squares of
the derivation from mean is 135. Can this sample be regarded as taken from the
population having 56 as mean? Obtain 95% and 99% confidence limits of the
mean of the population.
Sol. H0: There is no significant difference between the sample mean and
hypothetical population mean.
H0: μ = 56; H1: μ ≠ 56 (Two-tailed test)
t:
X − μ
s n
/
~ t(n – 1 difference)
Given: X = 53, μ = 56, n = 16, Σ(X X)
− 2 = 135
s =
Σ( )
X X
−
−
=
2
1
135
15
n
= 3; t =
53 56
3 16
−
/
= – 4
| t | = 4 . d.fv. = 16 – 1 = 15.
Conclusion. t0.05 = 1.753.
Since | t | = 4  t0.05 = 1.753, the calculated value of t is more than the table
value. The hypothesis is rejected. Hence, the sample mean has not come from
a population having 56 as mean.
95% confidence limits of the population mean
= X ± = ±
s
n
t0.05 53
3
16
(1.725) = 51.706; 54.293
99% confidence limits of the population mean
= X ± = ±
s
n
t0 01 53
3
16
. , (2.602) = 51.048; 54.951.
Example 2. The lifetime of electric bulbs for a random sample of 10 from a
large consignment gave the following data:
Item 1 2 3 4 5 6 7 8 9 10
Life in ‘000’ hrs. 4.2 4.6 3.9 4.1 5.2 3.8 3.9 4.3 4.4 5.6
Can we accept the hypothesis that the average lifetime of a bulb is 4000 hrs?
Sol. H0: There is no significant difference in the sample mean and population
mean. i.e., μ = 4000 hrs.
694 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Applying the t-test: t =
X − μ
s n
/
~ t(10 – 1 difference)
X 4.2 4.6 3.9 4.1 5.2 3.8 3.9 4.3 4.4 5.6
X – X – 0.2 0.2 – 0.5 – 0.3 0.8 – 0.6 – 0.5 – 0.1 0 1.2
( )
X X
− 2
0.04 0.04 0.25 0.09 0.64 0.36 0.25 0.01 0 1.44
X =
ΣX
n
=
44
10
= 4.4 Σ(X X)2
− = 3.12
s =
Σ(X X)2
−
−
=
n 1
3 12
9
.
= 0.589; t =
4 4 4
0 589
10
.
.
−
= 2.123
For γ = 9, t0.05 = 2.26.
Conclusion. Since the calculated value of t is less than table t0.05. ∴ The
hypothesis μ = 4000 hrs is accepted, i.e., the average lifetime of bulbs could be
4000 hrs.
Example 3. A sample of 20 items has mean 42 units and standard deviation 5
units. Test the hypothesis that it is a random sample from a normal population
with mean 45 units.
Sol. H0: There is no significant difference between the sample mean and the
population mean. i.e., μ = 45 units
H1: μ ≠ 45 (Two tailed test)
Given: n = 20, X = 42, S = 5; γ = 19 difference
s2 =
n
n −
=
−
L
NM O
QP
1
20
20 1
2
S (5)2 = 26.31 ∴ s = 5.129
Applying t-test t =
X −
=
−
μ
s n
/ . /
42 45
5 129 20
= – 2.615; | t | = 2.615
The tabulated value of t at 5% level for 19 d.f. is t0.05 = 2.09.
Conclusion. Since | t |  t0.05, the hypothesis H0 is rejected, i.e., there is
significant difference between the sample mean and population mean.
i.e., the sample could not have come from this population.
Example 4. The 9 items of a sample have the following values 45, 47, 50, 52,
48, 47, 49, 53, 51. Does the mean of these values differ significantly from the
assumed mean 47.5?
TESTING OF HYPOTHESIS 695
Sol. H0: μ = 47.5
i.e., there is no significant difference between the sample and population mean.
H1: μ ≠ 47.5 (two tailed test); Given: n = 9, μ = 47.5
X 45 47 50 52 48 47 49 53 51
X – X – 4.1 – 2.1 0.9 2.9 – 1.1 – 2.1 – 0.1 3.9 1.9
( )
X X
− 2
16.81 4.41 0.81 8.41 1.21 4.41 0.01 15.21 3.61
X =
Σx
n
=
442
9
= 49.11; Σ(X X)2
− = 54.89; s2 =
Σ( )
( )
X X
−
−
2
1
n
= 6.86
∴ s = 2.619
Applying t-test t =
X −
=
−
μ
s n
/
. .
. /
49 1 47 5
2 619 8
=
( )
.
1.6 8
2 619
= 1.7279
t0.05 = 2.31 for γ = 8.
Conclusion. Since | t |  t0.05, the hypothesis is accepted i.e., there is no
significant difference between their mean.
ASSIGNMENT 8.6
1. Ten individuals are chosen at random from a normal population of students and their
scores found to be 63, 63, 66, 67, 68, 69, 70, 70, 71, 71. In the light of these data discuss
the suggestion that mean score of the population of students is 66.
2. The following values gives the lengths of 12 samples of Egyptian cotton taken from a
consignment: 48, 46, 49, 46, 52, 45, 43, 47, 47, 46, 45, 50. Test if the mean length of the
consignment can be taken as 46.
3. A sample of 18 items has a mean 24 units and standard deviation 3 units. Test the
hypothesis that it is a random sample from a normal population with mean 27 units.
4. A filling machine is expected to fill 5 kg of powder into bags. A sample of 10 bags gave
the following weights: 4.7, 4.9, 5.0, 5.1, 5.4, 5.2, 4.6, 5.1, 4.6, and 4.7. Test whether the
machine is working properly.
8.14 TEST II: t-TEST FOR DIFFERENCE OF MEANS OF TWO SMALL
SAMPLES (FROM A NORMAL POPULATION)
This test is used to test whether the two samples x1, x2, ......, xn1
, y1, y2, ......,
yn2
of sizes n1, n2 have been drawn from two normal populations with mean μ1
696 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
and μ2 respectively, under the assumption that the population variance are
equal. (σ1 = σ2 = σ).
H0: The samples have been drawn from the normal population with means
μ1 and μ2, i.e., H0: μ1 ≠ μ2.
Let X , Y be their means of the two samples.
Under this H0 the test of statistic t is given by
t =
(X Y)
−
+
s
n n
1 1
1 2
~ t(n1 + n2 – 2 difference)
1. If the two sample’s standard deviations s1, s2 are given, then we have
s2 = n s n s
n n 2
1 1
2
2 2
2
1 2
+
+ −
.
2. If n1 = n2 = n, t =
X Y
s s
n 1
1
2
2
2
−
+
−
can be used as a test statistic.
3. If the pairs of values are in some way associated (correlated) we can’t use
the test statistic as given in Note 2. In this case, we find the differences of
the associated pairs of values and apply for single mean i.e., t =
X
s/ n
− μ
with degrees of freedom n – 1.
The test statistic is
t =
d
s n
/
or t =
d
s n
/ − 1
, where d is the mean of paired difference.
i.e., di = xi – yi
di = X Y
− , where (xi, yi) are the paired data i = 1, 2, ......, n.
NOTE
TESTING OF HYPOTHESIS 697
EXAMPLES
Example 1. Two samples of sodium vapor bulbs were tested for length of life
and the following results were obtained:
Size Sample mean Sample S.D.
Type I 8 1234 hrs 36 hrs
Type II 7 1036 hrs 40 hrs
Is the difference in the means significant to generalize that Type I is superior
to Type II regarding length of life?
Sol. H0: μ1 = μ2 i.e., two types of bulbs have same lifetime.
H1: μ1  μ2 i.e., type I is superior to Type II.
s2 =
n s n s
n n
1 1
2
2 2
2
1 2
2 2
2
8 36 7 40
8 7 2
+
+ −
=
+
+ −
( ) ( )
= 1659.076
∴ s = 40.7317
The t-statistic t =
X X
1 2
1 2
1 1
−
+
s
n n
=
1234 1036
40 7317
1
8
1
7
−
+
.
= 18.1480 ~ t(n1 + n2 – 2 difference)
t0.05 at difference 13 is 1.77 (one tailed test).
Conclusion. Since calculated | t |  t0.05, H0 is rejected, i.e. H1 is accepted.
∴ Type I is definitely superior to Type II.
where X =
i
n
i
i
n
=
∑1
1
X
, Y =
j
n
j
n
=
∑1 2
2
Y
; s2 =
1
2
1 2
2 2
n n
i j
+ −
− + −
[ ( ) ( ) ]
Σ X X Y Y
is an unbiased estimate of the population variance σ2.
t follows t-distribution with n1 + n2 – 2 degrees of freedom.
Example 2. Samples of sizes 10 and 14 were taken from two normal populations
with standard deviation 3.5 and 5.2. The sample means were found to be 20.3
and 18.6. Test whether the means of the two populations are the same at 5%
level.
Sol. H0: μ1 = μ2 i.e., the means of the two populations are the same.
H1 : μ1 ≠ μ2.
698 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Given X = 20.3, X2 = 18.6; n1 = 10, n2 = 14, s1 = 3.5, s2 = 5.2
s2 =
n s n s
n n
1 1
2
2 2
2
1 2
2 2
2
10 3 5 14 5 2
10 14 2
+
+ −
=
+
+ −
( . ) ( . )
= 22.775 ∴ s = 4.772
t =
X X
1
1
1
−
+
=
−
+
F
HG
I
KJ
2
2
1
20 3 18 6
1
10
1
14
4 772
s
n n
. .
.
= 0.8604
The value of t at 5% level for 22 difference is t0.05 = 2.0739.
Conclusion. Since | t | = 0.8604  t0.05 the hypothesis is accepted, i.e.,
there is no significant difference between their means.
Example 3. The height of 6 randomly chosen sailors in inches is 63, 65, 68, 69,
71, and 72. Those of 9 randomly chosen soldiers are 61, 62, 65, 66, 69, 70, 71,
72, and 73. Test whether the sailors are, on average, taller than soldiers.
Sol. Let X1 and X2 be the two samples denoting the heights of sailors and
soldiers.
Given the sample size n1 = 6, n2 = 9, H0: μ1 = μ2,
i.e., the means of both populations are the same.
H1: μ1  μ2 (one tailed test)
Calculation of two sample means:
X1 63 65 68 69 71 72
X1 – X1 – 5 – 3 0 1 3 4
(X X )
1 1
2
− 25 9 0 1 9 16
X1 =
ΣX1
n1
= 68; Σ(X X )
1 1
2
− = 60
X2 61 62 65 66 69 70 71 72 73
X2 – X2 – 6.66 – 5.66 – 2.66 1.66 1.34 2.34 3.34 4.34 5.34
(X X )
2 2
2
− 44.36 32.035 7.0756 2.7556 1.7956 5.4756 11.1556 18.8356 28.5156
X2 =
ΣX2
n2
= 67.66; Σ(X X )
2 2
2
− = 152.0002
TESTING OF HYPOTHESIS 699
s2 =
1
2
1 2
1 1
2 2
n n
+ −
− + −
[ ( ) ( ) ]
Σ Σ
X X X X
2 2
=
1
6 9 2
+ −
[60 + 152.0002] = 16.3077 ∴ s = 4.038
Under H0, t =
X X
1 2
1 2
1 1
68 67 666
4 0382
1
6
1
9
−
+
=
−
+
s
n n
.
.
= 0.3031 ~ t(n1 + n2 – 2 difference)
The value of t at 10% level of significance (∵ the test is one-tailed) for 13
difference is 1.77.
Conclusion. Since | t | = 0.3031  t0.05 = 1.77, the hypothesis H0 is accepted.
There is no significan difference between their average.
The sailors are not, on average, taller than the soldiers.
Example 4. A certain stimulus administered to each of 12 patients resulted in
the following increase in blood pressure: 5, 2, 8, – 1, 3, 0, – 2, 1, 5, 0, 4, 6. Can it
be concluded that the stimulus will in general be accompanied by an increase
in blood pressure?
Sol. To test whether the mean increase in blood pressure of all patients to
whom the stimulus is administered will be positive, we have to assume that
this population is normal with mean μ and standard deviation σ which are
unknown.
H0: μ = 0; H1: μ1  0
The test statistic under H0
t =
d
s n
/ − 1
~ t(n – 1 degrees of freedom)
d =
5 2 8 1 3 0 6 2 1 5 0 4
12
+ + + − + + + + − + + + +
( ) ( )
= 2.583
s2 =
Σd
n
d
2
2 1
12
− = [52 + 22 + 82 + (– 1)2 + 32 + 02 + 62
+ (– 2)2 + 12 + 52 + 02 + 42] – (2.583)2
= 8.744 ∴ s = 2.9571
t =
d
s n
/
.
. /
.
.
−
=
−
=
1
2583
2 9571 12 1
2583 11
2 9571
= 2.897 ~ t(n – 1 difference)
700 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Conclusion. The tabulated value of t0.05 at 11 difference is 2.2.
∵ | t |  t0.05, H0 is rejected.
i.e., the stimulus does not increase the blood pressure. The stimulus in general
will be accompanied by an increase in blood pressure.
Example 5. Memory capacity of 9 students was tested before and after a course
of meditation for a month. State whether the course was effective or not from
the data below (in same units):
Before 10 15 9 3 7 12 16 17 4
After 12 17 8 5 6 11 18 20 3
Sol. Since the data are correlated and concerned with the same set of students
we use paired t-test.
H0: Training was not effective μ1 = μ2
H1: μ1 ≠ μ2 (Two-tailed test).
Before training (X) After training (Y) d = X – Y d2
10 12 – 2 4
15 17 – 2 4
9 8 1 1
3 5 – 2 4
7 6 1 1
12 11 1 1
16 18 – 2 4
17 20 – 3 9
4 3 1 1
Σd = – 7 Σd2 = 29
d =
Σd
n
=
− 7
9
= – 0.7778; s2 =
Σd
n
d
2
2 29
9
− =
( ) – (– 0.7778)2 = 2.617
t =
d
s n
/
.
. /
.
.
−
=
−
=
− ×
1
07778
2 6172 8
07778 8
16177
= – 1.359
The tabulated value of t0.05 at 8 difference is 2.31.
Conclusion. Since | t | = 1.359  t0.05, H0 is accepted, training was not
effective in improving performance.
TESTING OF HYPOTHESIS 701
Example 6. The following figures refer to observations in live independent
samples:
Sample I 25 30 28 34 24 20 13 32 22 38
Sample II 40 34 22 20 31 40 30 23 36 17
Analyse whether the samples have been drawn from the populations of equal
means.
Sol. H0: The two samples have been drawn from the population of equal means,
i.e., there is no significant difference between their means
i.e., μ1 = μ2
H1: μ1 ≠ μ2 (Two tailed test)
Given n1 = Sample I size = 10 ; n2 = Sample II size = 10
To calculate the two sample mean and sum of squares of deviation from
mean. Let X1 be the Sample I and X2 be the Sample II.
X1 25 30 28 34 24 20 13 32 22 38
X1 – X1 – 1.6 3.4 1.4 7.4 – 2.6 – 6.6 – 13.6 5.4 4.6 11.4
(X X )
1 1
2
− 2.56 11.56 1.96 54.76 6.76 43.56 184.96 29.16 21.16 129.96
X2 40 34 22 20 31 40 30 23 36 17
X2 – X2 10.7 4.7 – 7.3 – 9.3 1.7 10.7 0.7 – 6.3 6.7 – 12.3
(X X )
2 2
2
− 114.49 22.09 53.29 86.49 2.89 114.49 0.49 39.67 44.89 151.29
X1 =
i
n
=
∑1
10
1
1
X
= 26.6 X2 =
i
n
=
∑ =
1
10
2
2
293
10
X
= 29.3
Σ( )
X X
1 1
2
− = 486.4 Σ( )
X X
2 2
2
− = 630.08
s2 =
1
2
1 2
1 1
2
2 2
2
n n
+ −
− + −
[ ( ) ( ) ]
Σ Σ
X X X X
=
1
10 10 2
+ −
[486.4 + 630.08] = 62.026
∴ s = 7.875
702 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Under H0 the test statistic is given by
t =
X X
1 2
−
+
=
−
+
s
n n
1 1
26 6 29 3
7 875
1
10
1
10
1 2
. .
.
= – 0.7666 ~ t(n1 + n2 – 2 difference)
| t | = 0.7666.
Conclusion. The tabulated value of t at 5% level of significance for 18
difference is 2.1. Since the calculated value | t | = 0.7666  t0.05, H0 is accepted.
There is no significant difference between their means.
The two samples have been drawn from the populations of equal means.
ASSIGNMENT 8.7
1. The mean life of 10 electric motors was found to be 1450 hrs with a standard deviation
of 423 hrs. A second sample of 17 motors chosen from a different batch showed a mean
life of 1280 hrs with a standard deviation of 398 hrs. Is there a significant difference
between means of the two samples ?
2. The scores obtained by a group of 9 regular course students and another group of 11
part time course students in a test are given below:
Regular: 56 62 63 54 60 51 67 69 58
Part time: 62 70 71 62 60 56 75 64 72 68 66
Examine whether the scores obtained by regular students and part time students differ
significantly at 5% and 1% level of significance.
3. A group of 10 boys fed on diet A and another group of 8 boys fed on a different diet B
recorded the following increase in weight (kgs):
Diet A: 5 6 8 1 12 4 3 9 6 10
Diet B: 2 3 6 8 10 1 2 8
Does it show the superiority of diet A over the diet B?
4. Two independent samples of sizes 7 and 9 have the following values:
Sample A: 10 12 10 13 14 11 10
Sample B: 10 13 15 12 10 14 11 12 11
Test whether the difference between the means is significant.
5. To compare the prices of a certain product in two cities, 10 shops were visited at random
in each city. The price was noted below:
City 1: 61 63 56 63 56 63 59 56 44 61
City 2: 55 54 47 59 51 61 57 54 64 58
Test whether the average prices can be said to be the same in two cities.
TESTING OF HYPOTHESIS 703
6. The average number of articles produced by two machines per day are 200 and 250 with
standard deviation 20 and 25 respectively on the basis of records of 25 days production.
Are both machines equally efficient at 5% level of significance?
8.15 SNEDECOR’S VARIANCE RATIO TEST OR F-TEST
In testing the significance of the difference of two means of two samples, we
assumed that the two samples came from the same population or populations
with equal variance. The object of the F-test is to discover whether two
independent estimates of population variance differ significantly or whether
the two samples may be regarded as drawn from the normal populations having
the same variance. Hence before applying the t-test for the significance of the
difference of two means, we have to test for the equality of population variance
by using the F-test.
Let n1 and n2 be the sizes of two samples with variance s1
2 and s2
2. The
estimate of the population variance based on these samples is s1
2 =
n s
n
1 1
2
1 1
−
and
s
n s
n
2
2 2 2
2
2 1
=
−
. The degrees of freedom of these estimates are ν1 = n1 – 1,
ν2 = n2 – 1.
To test whether these estimates, s1
2 and s2
2, are significantly different or if
the samples may be regarded as drawn from the same population or from two
populations with same variance σ2, we set-up the null hypothesis
H0: σ1
2 = σ2
2 = σ2,
i.e., the independent estimates of the common population do not differ
significantly.
To carry out the test of significance of the difference of the variances we
calculate the test statistic F =
s
s
1
2
2
2 , the Numerator is greater than the
Denominator, i.e., s1
2  s2
2.
Conclusion. If the calculated value of F exceeds F0.05 for (n1 – 1), (n2 – 1)
degrees of freedom given in the table, we conclude that the ratio is significant
at 5% level.
We conclude that the sample could have come from two normal population
with same variance.
The assumptions on which the F-test is based are:
1. The populations for each sample must be normally distributed.
2. The samples must be random and independent.
704 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
3. The ratio of σ1
2 to σ2
2 should be equal to 1 or greater than 1. That is why
we take the larger variance in the Numerator of the ratio.
Applications. F-test is used to test
(i) whether two independent samples have been drawn from the normal
populations with the same variance σ2.
(ii) Whether the two independent estimates of the population variance are
homogeneous or not.
EXAMPLES
Example 1. Two random samples drawn from 2 normal populations are as
follows:
A 17 27 18 25 27 29 13 17
B 16 16 20 27 26 25 21
Test whether the samples are drawn from the same normal population.
Sol. To test if two independent samples have been drawn from the same
population we have to test (i) equality of the means by applying the t-test and
(ii) equality of population variance by applying F-test.
Since the t-test assumes that the sample variances are equal, we shall first
apply the F-test.
F-test. 1. Null hypothesis H0: σ1
2 = σ2
2 i.e., the population variance do
not differ significantly.
Alternative hypothesis. H1: σ1
2 ≠ σ2
2
Test statistic: F =
s
s
1
2
2
2 , (if s1
2  s2
2)
Computations for s1
2 and s2
2
X1 X1 – X1 (X X )
1 1
2
− X2 X2 – X2 (X X )
2 2
2
−
17 – 4.625 21.39 16 – 2.714 7.365
27 5.735 28.89 16 – 2.714 7.365
18 – 3.625 13.14 20 1.286 1.653
25 3.375 11.39 27 8.286 68.657
27 5.735 28.89 26 7.286 53.085
29 7.735 54.39 25 6.286 39.513
13 – 8.625 74.39 21 2.286 5.226
17 – 4.625 21.39
TESTING OF HYPOTHESIS 705
X1 = 21.625; n1 = 8; Σ(X X )
1 1
2
− = 253.87
X2 = 18.714; n2 = 7; Σ(X X )
2 2
2
− = 182.859
s1
2 =
Σ( ) .
X X
1 1
2
1 1
253 87
7
−
−
=
n
= 36.267;
s2
2 =
Σ( ) .
X X
2 2
2
2 1
182 859
6
−
−
=
n
= 30.47
F =
s
s
1
2
2
2
36 267
30 47
=
.
.
= 1.190.
Conclusion. The table value of F for ν1 = 7 and ν2 = 6 degrees of freedom
at 5% level is 4.21. The calculated value of F is less than the tabulated value of
F. ∴ H0 is accepted. Hence we conclude that the variability in two populations
is same.
t-test: Null hypothesis. H0: μ1 = μ2 i.e., the population means are equal.
Alternative hypothesis. H1: μ1 ≠ μ2
Test of statistic
s2 =
Σ Σ
( ) ( ) . .
X X X X
1 1
2
2 2
2
1 2 2
253 87 182 859
8 7 2
− + −
+ −
=
+
+ −
n n
= 33.594
∴ s = 5.796
t =
X X 21.625
1 2
1 2
1 1
18 714
5 796
1
8
1
7
−
+
=
−
+
s
n n
.
.
= 0.9704 ~ t(n1 + n2 – 2) difference
Conclusion. The tabulated value of t at 5% level of significance for 13
difference is 2.16.
The calculated value of t is less than the tabulated value. H0 is accepted,
i.e., there is no significant difference between the population mean. i.e.,
μ1 = μ2. ∴ We conclude that the two samples have been drawn from the
same normal population.
Example 2. Two independent sample of sizes 7 and 6 had the following values:
Sample A 28 30 32 33 31 29 34
Sample B 29 30 30 24 27 28
Examine whether the samples have been drawn from normal populations
having the same variance.
706 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. H0: The variance are equal. i.e., σ1
2 = σ2
2
i.e., the samples have been drawn from normal populations with same variance.
H1: σ1
2 ≠ σ2
2
Under null hypothesis, the test statistic F =
s
s
1
2
2
2 (s1
2  s2
2)
Computations for s1
2 and s2
2
X1 X1 – X1 (X X )
1 1
2
− X2 X2 – X2 (X X )
2 2
2
−
28 – 3 9 29 1 1
30 – 1 1 30 2 4
32 1 1 30 2 4
33 2 4 24 – 4 16
31 0 0 27 – 1 1
29 – 2 4 28 0 0
34 3 9
28 26
X1 = 31, n1 = 7; Σ(X X )
1 1
2
− = 28
X2 = 28, n2 = 6; Σ(X X )
2 2
2
− = 26
s1
2 =
Σ( )
X X
1 1
2
1 1
28
6
−
−
=
n
= 4.666; s2
2 =
Σ( )
X X
2
2 2
2
1
26
5
−
−
=
n
= 5.2
F =
s
s
2
2
1
2
5 2
4 666
=
.
.
= 1.1158. (∵ s2
2  s1
2)
Conclusion. The tabulated value of F at ν1 = 6 – 1 and ν2 = 7 – 1 difference
for 5% level of significance is 4.39. Since the tabulated value of F is less than
the calculated value, H0 is accepted, i.e., there is no significant difference
between the variance. The samples have been drawn from the normal population
with same variance.
Example 3. The two random samples reveal the following data:
Sample number Size Mean Variance
I 16 440 40
II 25 460 42
Test whether the samples come from the same normal population.
TESTING OF HYPOTHESIS 707
Sol. A normal population has two parameters namely the mean μ and the
variance σ2. To test whether the two independent samples have been drawn
from the same normal population, we have to test
(i) the equality of means (ii) the equality of variance.
Since the t-test assumes that the sample variance are equal, we first apply
F-test.
F-test: Null hypothesis. σ1
2 = σ2
2
The population variance do not differ significantly.
Alternative hypothesis. σ1
2 ≠ σ2
2
Under the null hypothesis the test statistic is given by F =
s
s
1
2
2
2
, (s1
2  s2
2)
Given: n1 = 16, n2 = 25; s1
2 = 40, s2
2 = 42
∴ F =
s
s
n s
n
n s
n
1
2
2
2
1 1
2
1
2 2
2
2
1
1
=
−
−
=
16 40
15
24
25 42
×
×
×
= 0.9752.
Conclusion. The calculated value of F is 0.9752. The tabulated value of
F at 16 – 1, 25 – 1 difference for 5% level of significance is 2.11.
Since the calculated value is less than that of the tabulated value, H0 is
accepted, the population variance are equal.
t-test: Null hypothesis. H0: μ1 = μ2 i.e., the population means are equal.
Alternative hypothesis. H1: μ1 ≠ μ2
Given: n1 = 16, n2 = 25, X1 = 440, X2 = 460
s2 =
n s n s
n n
1 1
2
2 2
2
1 2 2
16 40 25 42
16 25 2
+
+ −
=
× + ×
+ −
= 43.333
∴ s = 6.582
t =
X X
1 2
−
+
=
−
+
s
n n
1 1
440 460
6 582
1
16
1
25
1 2
.
= – 9.490 for (n1 + n2 – 2) difference
Conclusion. The calculated value of | t | is 9.490. The tabulated value of
t at 39 difference for 5% level of significance is 1.96.
708 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Since the calculated value is greater than the tabulated value, H0 is rejected,
i.e., there is significant difference between means. i.e., μ1 ≠ μ2.
Since there is significant difference between means, and no significant
difference between variance, we conclude that the samples do not come from
the same normal population.
ASSIGNMENT 8.8
1. From the following two sample values, find out whether they have come from the same
population:
Sample 1 17 27 18 25 27 29 27 23 17
Sample 2 16 16 20 16 20 17 15 21
2. The daily wages in Rupees of skilled workers in two cities are as follows:
Size of sample of workers Standard deviation of wages in the sample
City A 16 25
City B 13 32
3. The standard deviation calculated from two random samples of sizes 9 and 13 are 2.1
and 1.8 respectively. Can the samples be regarded as drawn from normal populations
with the same standard deviation?
4. Two independent samples of size 8 and 9 had the following values of the variables:
Sample I 20 30 23 25 21 22 23 24
Sample II 30 31 32 34 35 29 28 27 26
Do the estimates of the population variance differ significantly?
8.16 CHI-SQUARE (χ2) TEST
When a coin is tossed 200 times, the theoretical considerations lead us to expect
100 heads and 100 tails. But in practice, these results are rarely achieved.
The quantity χ2 (a Greek letter, pronounced as chi-square) describes the
magnitude of discrepancy between theory and observation. If χ = 0, the observed
and expected frequencies completely coincide. The greater the discrepancy
between the observed and expected frequencies, the greater is the value of χ2.
Thus χ2 affords a measure of the correspondence between theory and
observation.
TESTING OF HYPOTHESIS 709
If Oi (i = 1, 2, ......, n) is a set of observed (experimental) frequencies and Ei
(i = 1, 2, ......, n) is the corresponding set of expected (theoretical or hypothetical)
frequencies, then, χ2 is defined as
χ2 =
i
n
i i
i
=
∑
−
L
NMM
O
QPP
1
2
( )
O E
E
where ΣOi = ΣEi = N (total frequency) and degrees of freedom (difference)
= (n – 1).
(i) If χ2 = 0, the observed and theoretical frequencies agree exactly.
(ii) If χ2  0 they do not agree exactly.
8.16.1 Degrees of Freedom
While comparing the calculated value of χ2 with the table value, we have to
determine the degrees of freedom.
If we have to choose any four numbers whose sum is 50, we can exercise
our independent choice for any three numbers only, the fourth being 50 minus
the total of the three numbers selected. Thus, though we were to choose any
four numbers, our choice was reduced to three because of one condition imposed.
There was only one restraint on our freedom and our degrees of freedom were
4 – 1 = 3. If two restrictions are imposed, our freedom to choose will be further
curtailed and degrees of freedom will be 4 – 2 = 2.
In general, the number of degrees of freedom is the total number of
observations less the number of independent constraints imposed on the
observations. Degrees of freedom (difference) are usually denoted by ν (the
letter ‘nu’ of the Greek alphabet).
Thus, ν = n – k, where k is the number of independent constraints in a set
of data of n observations.
(i) For a p × q contingency table (p columns and q rows), ν = (p – 1) (q – 1)
(ii) In the case of a contingency table, the expected frequency of any class
=
Total of rows in which it occurs Total of columns in which it occurs
Total number of observations
×
8.16.2 Applications
χ2 test is one of the simplest and the most general test known. It is applicable
to a very large number of problems in practice which can be summed up under
the following heads:
NOTE
NOTE
710 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(i) as a test of goodness of fit.
(ii) as a test of independence of attributes.
(iii) as a test of homogeneity of independent estimates of the population variance.
(iv) as a test of the hypothetical value of the population variance s2.
(v) as a list to the homogeneity of independent estimates of the population
correlation coefficient.
8.16.3 Conditions for Applying χ
χ
χ
χ
χ2 Test
Following are the conditions which should be satisfied before χ2 test can be
applied:
(a) N, the total number of frequencies should be large. It is difficult to say
what constitutes largeness, but as an arbitrary figure, we may say that N
should be atleast 50, however small the number of cells.
(b) No theoretical cell-frequency should be small. Here again, it is difficult to
say what constitutes smallness, but 5 should be regarded as the very
minimum and 10 is better. If small theoretical frequencies occur (i.e.,  10),
the difficulty is overcome by grouping two or more classes together before
calculating (O – E). It is important to remember that the number of
degrees of freedom is determined with the number of classes after
regrouping.
(c) The constraints on the cell frequencies, if any, should be linear.
If any one of the theoretical frequency is less than 5, then we apply a corrected
given by F Yates, which is usually known as ‘Yates correction for continuity’,
we add 0.5 to the cell frequency which is less than 5 and adjust the remaining
cell frequency suitably so that the marginal total is not changed.
8.17 THE χ2 DISTRIBUTION
For large sample sizes, the sampling distribution of χ2 can be closely
approximated by a continuous curve known as the chi-square distribution. The
probability function of χ2 distribution is given by
f(χ2) = c(χ2)(ν/2–1) e x
− 2
2
/
where e = 2.71828, ν = number of degrees of freedom; c = a constant depending
only on ν.
Symbolically, the degrees of freedom are denoted by the symbol ν or by
difference and are obtained by the rule ν = n – k, where k refers to the number
of independent constraints.
NOTE
TESTING OF HYPOTHESIS 711
In general, when we fit a binomial distribution the number of degrees of
freedom is one less than the number of classes; when we fit a Poisson distribution
the degrees of freedom are 2 less than the number of classes, because we use
the total frequency and the arithmetic mean to get the parameter of the Poisson
distribution. When we fit a normal curve the number of degrees of freedom are
3 less than the number of classes, because in this fitting we use the total
frequency, mean and standard deviation.
If the data is given in a series of “n” numbers then degrees of freedom
= n – 1.
In the case of Binomial distribution difference = n – 1
In the case of Poisson distribution difference = n – 2
In the case of Normal distribution difference = n – 3.
8.18 χ2 TEST AS A TEST OF GOODNESS OF FIT
χ2 test enables us to ascertain how well the theoretical distributions such as
Binomial, Poisson or Normal etc. fit empirical distributions, i.e., distributions
obtained from sample data. If the calculated value of χ2 is less than the
table value at a specified level (generally 5%) of significance, the fit is
considered to be good, i.e., the divergence between actual and expected
frequencies is attributed to fluctuations of simple sampling. If the calculated
value of χ2 is greater than the table value, the fit is considered to be poor.
EXAMPLES
Example 1. The following table gives the number of accidents that took place
in an industry during various days of the week. Test if accidents are uniformly
distributed over the week.
Day Mon Tue Wed Thu Fri Sat
Number of accidents 14 18 12 11 15 14
Sol. Null hypothesis H0: The accidents are uniformly distributed over the
week.
Under this H0, the expected frequencies of the accidents on each of these
days =
84
6
= 14
712 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Observed frequency Oi 14 18 12 11 15 14
Expected frequency Ei 14 14 14 14 14 14
(Oi – Ei)2 0 16 4 9 1 0
χ2 =
Σ( )
O E
E
i i
i
−
=
2
30
14
= 2.1428.
Conclusion. Table value of χ2 at 5% level for (6 – 1 = 5 d.f.) is 11.09.
Since the calculated value of χ2 is less than the tabulated value, H0 is
accepted, the accidents are uniformly distributed over the week.
Example 2. A die is thrown 270 times and the results of these throws are given
below:
Number appeared on the die 1 2 3 4 5 6
Frequency 40 32 29 59 57 59
Test whether the die is biased or not.
Sol. Null hypothesis H0: Die is unbiased.
Under this H0, the expected frequencies for each digit is
276
6
= 46.
To find the value of χ2
Oi 40 32 29 59 57 59
Ei 46 46 46 46 46 46
(Oi – Ei)2 36 196 289 169 121 169
χ2 =
Σ( )
O E
E
i i
i
−
=
2
980
46
= 21.30.
Conclusion. Tabulated value of χ2 at 5% level of significance for (6 – 1 = 5)
d.f. is 11.09. Since the calculated value of χ2 = 21.30  11.07 the tabulated
value, H0 is rejected.
i.e., die is not unbiased or die is biased.
TESTING OF HYPOTHESIS 713
Example 3. The following table shows the distribution of digits in numbers
chosen at random from a telephone directory:
Digits 0 1 2 3 4 5 6 7 8 9
Frequency 1026 1107 997 966 1075 933 1107 972 964 853
Test whether the digits may be taken to occur equally frequently in the
directory.
Sol. Null hypothesis H0: The digits taken in the directory occur equally
frequently.
i.e., there is no significant difference between the observed and expected
frequency.
Under H0, the expected frequency is given by =
10 000
10
,
= 1000
To find the value of χ2
Oi 1026 1107 997 996 1075 1107 933 972 964 853
Ei 1000 1000 1000 1000 1000 1000 1107 1000 1000 1000
(Oi – Ei)2 676 11449 9 1156 5625 11449 4489 784 1296 21609
χ2 =
Σ( )
O E
E
i i
i
−
=
2
58542
1000
= 58.542.
Conclusion. The tabulated value of χ2 at 5% level of significance for 9
difference is 16.919. Since the calculated value of χ2 is greater than the tabulated
value, H0 is rejected.
There is significant difference between the observed and theoretical
frequency.
The digits taken in the directory do not occur equally frequently.
Example 4. Records taken of the number of male and female births in 800
families having four children are as follows:
Number of male births 0 1 2 3 4
Number of female births 4 3 2 1 0
Number of families 32 178 290 236 94
Test whether the data are consistent with the hypothesis that the Binomial
law holds and the chance of male birth is equal to that of female birth, namely
p = q = 1/2.
714 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Sol. H0: The data are consistent with the hypothesis of equal probability for
male and female births, i.e., p = q = 1/2.
We use Binomial distribution to calculate theoretical frequency given by:
N(r) = N × P(X = r)
where N is the total frequency. N(r) is the number of families with r male
children:
P(X = r) = nCrprqn–r
where p and q are probability of male and female births, n is the number of
children.
N(0) = Number of families with 0 male children = 800 × 4C0
1
2
4
F
HG I
KJ
= 800 × 1 ×
1
24 = 50
N(1) = 800 × 4C1
1
2
1
2
1 3
F
HG I
KJ F
HG I
KJ = 200; N(2) = 800 × 4C2
1
2
1
2
2 2
F
HG I
KJ F
HG I
KJ
= 300
N(3) = 800 × 4C3
1
2
1
2
1 3
F
HG I
KJ F
HG I
KJ = 200; N(4) = 800 × 4C4
1
2
1
2
0 4
F
HG I
KJ F
HG I
KJ
= 50
Observed frequency Oi 32 178 290 236 94
Expected frequency Ei 50 200 300 200 50
(Oi – Ei)2 324 484 100 1296 1936
(O E )
E
i i
2
i
−
6.48 2.42 0.333 6.48 38.72
χ2 =
Σ( )
O E
E
i i
i
− 2
= 54.433.
Conclusion. Table value of χ2 at 5% level of significance for 5 – 1 = 4
difference is 9.49.
Since the calculated value of χ2 is greater than the tabulated value, H0 is
rejected.
TESTING OF HYPOTHESIS 715
The data are not consistent with the hypothesis that the Binomial law
holds and that the chance of a male birth is not equal to that of a female birth.
Since the fitting is Binomial, the degrees of freedom
ν = n – 1 i.e., ν = 5 – 1 = 4.
Example 5. Verify whether Poisson distribution can be assumed from the data
given below:
Number of defects 0 1 2 3 4 5
Frequency 6 13 13 8 4 3
Sol. H0: Poisson fit is a good fit to the data.
Mean of the given distribution =
Σ
Σ
f x
f
i i
i
=
94
47
= 2
To fit a Poisson distribution we require m. Parameter m = x = 2.
By Poisson distribution the frequency of r success is
N(r) = N × e–m .
m
r
r
!
, N is the total frequency.
N(0) = 47 × e–2 .
( )
!
2
0
0
= 6.36 ≈ 6; N(1) = 47 × e–2 .
( )
!
2
1
1
= 12.72 ≈ 13
N(2) = 47 × e–2 .
( )
!
2
2
2
= 12.72 ≈ 13; N(3) = 47 × e–2 .
( )
!
2
3
3
= 8.48 ≈ 9
N(4) = 47 × e–2 .
( )
!
2
4
4
= 4.24 ≈ 4; N(5) = 47 × e–2 .
( )
!
2
5
5
= 1.696 ≈ 2.
X 0 1 2 3 4 5
Oi 6 13 13 8 4 3
Ei 6.36 12.72 12.72 8.48 4.24 1.696
(O E )
E
i i
2
i
−
0.2037 0.00616 0.00616 0.02716 0.0135 1.0026
χ2 =
Σ( )
O E
E
i i
i
− 2
= 1.2864.
NOTE
716 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Conclusion. The calculated value of χ2 is 1.2864. Tabulated value of χ2 at
5% level of significance for γ = 6 – 2 = 4 d.f. is 9.49. Since the calculated value of
χ2 is less than that of tabulated value. H0 is accepted i.e., Poisson distribution
provides a good fit to the data.
Example 6. The theory predicts the proportion of beans in the four groups, G1,
G2, G3, G4 should be in the ratio 9: 3: 3: 1. In an experiment with 1600 beans the
numbers in the four groups were 882, 313, 287 and 118. Does the experimental
result support the theory.
Sol. H0: The experimental result support the theory. i.e., there is no significant
difference between the observed and theoretical frequency under H0, the
theoretical frequency can be calculated as follows:
E(G1) =
1600 9
16
×
= 900; E(G2) =
1600 3
16
×
= 300;
E(G3) =
1600 3
16
×
= 300; E(G4) =
1600 1
16
×
= 100
To calculate the value of χ2.
Observed frequency Oi 882 313 287 118
Expected frequency Ei 900 300 300 100
(O E )
E
i i
2
i
−
0.36 0.5633 0.5633 3.24
χ2 =
Σ( )
O E
E
i i
i
− 2
= 4.7266.
Conclusion. The table value of χ2 at 5% level of significance for 3 difference
is 7.815. Since the calculated value of χ2 is less than that of the tabulated
value. Hence H0 is accepted and the experimental results support the theory.
ASSIGNMENT 8.9
1. The following table gives the frequency of occupance of the digits 0, 1, ......, 9 in the last
place in four logarithm of numbers 10–99. Examine if there is any peculiarity.
Digits: 0 1 2 3 4 5 6 7 8 9
Frequency: 6 16 15 10 12 12 3 2 9 5
2. The sales in a supermarket during a week are given below. Test the hypothesis that the
sales do not depend on the day of the week, using a significant level of 0.05.
Days: Mon Tues Wed Thurs Fri Sat
Sales: 65 54 60 56 71 84
TESTING OF HYPOTHESIS 717
3. A survey of 320 families with 5 children each revealed the following information:
Number of boys: 5 4 3 2 1 0
Number of girls: 0 1 2 3 4 5
Number of families: 14 56 110 88 40 12
Is this result consistent with the hypothesis that male and female births are equally
probable?
4. 4 coins were tossed at a time and this operation is repeated 160 times. It is found that 4
heads occur 6 times, 3 heads occur 43 times, 2 heads occur 69 times, one head occurs 34
times. Discuss whether the coin may be regarded as unbiased?
5. Fit a Poisson distribution to the following data and best the goodness of fit:
x: 0 1 2 3 4
f : 109 65 22 3 1
6. In the accounting department of bank, 100 accounts are selected at random and esti-
mated for errors. The following results were obtained:
Number of errors: 0 1 2 3 4 5 6
Number of accounts: 35 40 19 2 0 2 2
Does this information verify that the errors are distributed according to the Poisson
probability law?
7. In a sample analysis of examination results of 500 students, it was found that 180
students failed, 170 secured a third class, 90 secured a second class and the rest, a first
class. Do these figures support the general belief that the above categories are in the
ratio 4:3:2:1, respectively?
8. What is χ2–test?
A die is thrown 90 times with the following results:
Face: 1 2 3 4 5 6 Total
Frequency: 10 12 16 14 18 20 90
Use χ2-test to test whether these data are consistent with the hypothesis that die is
unbiased.
Given χ2
0.05 = 11.07 for 5 degrees of freedom.
9. A survey of 320 families with 5 children shows the following distribution:
Number of boys 5 boys 4 boys 3 boys 2 boys 1 boy 0 boy Total
 girls:  0 girl  1 girl  2 girls  3 girls  4 girls  5 girls
Number of
families: 18 56 110 88 40 8 320
Given that values of χ2 for 5 degrees of freedom are 11.1 and 15.1 at 0.05 and 0.01
significance level respectively, test the hypothesis that male and female births are equally
probable.
718 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
8.19 χ2 TEST AS A TEST OF INDEPENDENCE
With the help of χ2 test, we can find whether or not two attributes are associated.
We take the null hypothesis that there is no association between the attributes
under study, i.e., we assume that the two attributes are independent. If
the calculated value of χ2 is less than the table value at a specified level
(generally 5%) of significance, the hypothesis holds good, i.e., the attributes
are independent and do not bear any association. On the other hand, if the
calculated value of χ2 is greater than the table value at a specified level of
significance, we say that the results of the experiment do not support the
hypothesis. In other words, the attributes are associated. Thus a very useful
application of χ2 test is to investigate the relationship between trials or attributes
which can be classified into two or more categories.
The sample data set out into two-way table, called contingency table.
Let us consider two attributes A and B divided into r classes A1, A2, A3,
......, Ar , and B divided into s classes B1, B2, B3, ......, Bs. If (Ai), (Bj) represents
the number of persons possessing the attributes Ai, Bj respectively, (i = 1, 2,
......, r, j = 1, 2, ......, s) and (Ai Bj) represent the number of persons possessing
attributes Ai and Bj. Also we have
i
r
i
j
s
j
= =
∑ ∑
=
1 1
A B = N where N is the total
frequency. The contingency table for r × s is given below:
A A1 A2 A3 ...Ar Total
B
B1 (A1B1) (A2B1) (A3B1) ......(ArB1) B1
B2 (A1B2) (A2B2) (A3B2) ......(ArB2) B2
B3 (A1B3) (A2B3) (A3B3) ......(ArB3) B3
...... ...... ...... ...... ...... ......
...... ...... ...... ...... ...... ......
Bs (A1Bs) (A2Bs) (A3Bs) ......(ArBs) (Bs)
Total (A1) (A2) (A3) ......(Ar) N
H0: Both the attributes are independent. i.e., A and B are independent
under the null hypothesis, we calculate the expected frequency as follows:
P(Ai) = Probability that a person possesses the attribute
Ai =
( )
A
N
i
i = 1, 2, ......, r
P(Bj) = Probability that a person possesses the attribute Bj =
( )
B
N
j
TESTING OF HYPOTHESIS 719
P(AiBj) = Probability that a person possesses both attributes Ai and Bj
=
( )
A B
N
i j
If (AiBj)0 is the expected number of persons possessing both the attributes
Ai and Bj
(AiBj)0 = NP(AiBj) = NP(Ai)(Bj)
= N
( ) ( ) ( )( )
A
N
B
N
A B
N
i j i j
= (∵ A and B are independent)
Hence χ2 =
i
r
j
s
i j i j
i j
= =
∑ ∑
−
L
N
MM
O
Q
PP
1 1
0
2
0
[( ) ( ) ]
( )
A B A B
A B
which is distributed as a χ2 variate with (r – 1)(s – 1) degrees of freedom.
1. For a 2 × 2 contingency table where the frequencies are
a b
c d
/
/
, χ2 can be
calculated from independent frequencies as
χ2 =
(a b c d)(ad bc)
(a b)(c d)(b d)(a c)
2
+ + + −
+ + + +
.
2. If the contingency table is not 2 × 2, then the formula for calculating χ2
as given in Note 1, can’t be used. Hence, we have another formula for
calculating the expected frequency (AiBj)0 =
(A )(B )
N
i j
i.e., expected
frequency in each cell is =
Product of column total and row total
whole total
.
3. If
a b
c d
|
|
is the 2 × 2 contingency table with two attributes, Q =
ad bc
ad bc
−
+
is
called the coefficient of association. If the attributes are independent
then
a
b
c
d
= .
4. Yates’s Correction. In a 2 × 2 table, if the frequencies of a cell is small,
we make Yates’s correction to make χ2 continuous.
Decrease by
1
2
those cell frequencies which are greater than expected
frequencies, and increase by
1
2
those which are less than expectation.
This will not affect the marginal columns. This correction is known as
Yates’s correction to continuity.
NOTE
720 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
After Yates’s correction χ2 =
N bc ad
1
2
N
(a c)(b d)(c d)(a b)
2
− −
F
HG I
KJ
+ + + +
when ad – bc  0
χ2 =
N ad bc
1
2
N
(a c)(b d)(c d)(a b)
2
− −
F
HG I
KJ
+ + + +
when ad – bc  0.
EXAMPLES
Example 1. What are the expected frequencies of 2 × 2 contingency tables given
below:
a b 2 10
(i) (ii)
c d 6 6
Sol. Observed frequencies Expected frequencies
(i) a b a + b
( )( )
a c a b
a b c d
+ +
+ + +
( )( )
b d a b
a b c d
+ +
+ + +
c d c + d
a + c b + d a + b + c + d = N
( )( )
a c c d
a b c d
+ +
+ + +
( )( )
b d c d
a b c d
+ +
+ + +
Observed frequencies Expected frequencies
(ii) 2 10 12
8 12
24
×
= 4
16 12
24
×
= 8
6 6 12
8 16 24
8 12
24
×
= 4
16 12
24
×
= 8
Example 2. From the following table regarding the color of eyes of father and
son test if the color of son’s eye is associated with that of the father.
Eye color of son
Light Not light
Eye color of father Light 471 51
Not light 148 230
→
TESTING OF HYPOTHESIS 721
Sol. Null hypothesis H0: The color of son’s eye is not associated with that of
the father, i.e., they are independent.
Under H0, we calculate the expected frequency in each cell as
=
Product of column total and row total
Whole total
Expected frequencies are:
Eye color
of son Light Not light Total
Eye color
of father
Light
619 522
900
×
= 359.02
289 522
900
×
= 167.62 522
Not light
619 378
900
×
= 259.98
289 378
900
×
= 121.38 378
Total 619 289 900
χ2 =
(471 359.02)
359.02
(51 167.62)
167.62
(148 259.98)
259.98
(230 121.38)
121.38
2 2 2 2
−
+
−
+
−
+
−
= 261.498.
Conclusion. Tabulated value of χ2 at 5% level for 1 difference is 3.841.
Since the calculated value of χ2  tabulated value of χ2, H0 is rejected. They
are dependent, i.e., the color of son’s eye is associated with that of the father.
Example 3. The following table gives the number of good and bad parts
produced by each of the three shifts in a factory:
Good parts Bad parts Total
Day shift 960 40 1000
Evening shift 940 50 990
Night shift 950 45 995
Total 2850 135 2985
Test whether or not the production of bad parts is independent of the shift
on which they were produced.
Sol. Null hypothesis H0: The production of bad parts is independent of the
shift on which they were produced.
The two attributes, production and shifts are independent.
722 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Under H0, χ2 =
i j
i j i j
i j
= =
∑ ∑
−
L
N
MM
O
Q
PP
1
2
1
3
0
2
0
[( ) ( )]
( )
A B A B
A B
Calculation of expected frequencies
Let A and B be the two attributes namely production and shifts. A is divided
into two classes A1, A2 and B is divided into three classes B1, B2, B3.
(A1B1)0 =
( )( ) ( ) ( )
A B
N
1 2 2850 1000
2985
=
×
= 954.77;
(A1B2)0 =
( )( ) ( ) ( )
A B
N
1 2 2850 990
2985
=
×
= 945.226
(A1B3)0 =
( )( ) ( ) ( )
A B
N
1 3 2850 995
2985
=
×
= 950;
(A2B1)0 =
( )( ) ( ) ( )
A B
N
2 1 135 1000
2985
=
×
= 45.27
(A2B2)0 =
( )( ) ( ) ( )
A B
N
2 2 135 990
2985
=
×
= 44.773;
(A2B3)0 =
( )( ) ( ) ( )
A B
N
2 3 135 995
2985
=
×
= 45.
To calculate the value of χ2
Class Oi Ei (Oi – Ei)2 (Oi – Ei)2/Ei
(A1B1) 960 954.77 27.3529 0.02864
(A1B2) 940 945.226 27.3110 0.02889
(A1B3) 950 950 0 0
(A2B1) 40 45.27 27.7729 0.61349
(A2B2) 50 44.773 27.3215 0.61022
(A2B3) 45 45 0 0
1.28126
Conclusion. The tabulated value of χ2 at 5% level of significance for 2
degrees of freedom (r – 1)(s – 1) is 5.991. Since the calculated value of χ2 is less
than the tabulated value, we accept H0, i.e., the production of bad parts is
independent of the shift on which they were produced.
TESTING OF HYPOTHESIS 723
ASSIGNMENT 8.10
1. In a locality 100 persons were randomly selected and asked about their educational
achievements. The results are given below:
Education
Middle High school College
Sex Male 10 15 25
Female 25 10 15
Based on this information can you say the education depends on sex.
2. The following data is collected on two characters:
Smokers Non smokers
Literate 83 57
Illiterate 45 68
Based on this information can you say that there is no relation between habit of smok-
ing and literacy.
3. In an experiment on the immunisation of goats from anthrax, the following results were
obtained. Derive your inferences on the efficiency of the vaccine.
Died anthrax Survived
Inoculated with vaccine 2 10
Not inoculated 6 6
724 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
TABLE 1: Significant values tv (α
α
α
α
α) of t-distribution (Two Tail Areas)
[| t |  tv(α)] = α
difference Probability (Level of significance)
(ν) 0.50 0.10 0.05 0.02 0.01 0.001
1 1.00 6.31 12.71 31.82 63.66 636.62
2 0.82 0.92 4.30 6.97 6.93 31.60
3 0.77 2.32 3.18 4.54 5.84 12.94
4 0.74 2.13 2.78 3.75 4.60 8.61
5 0.73 2.02 2.57 3.37 4.03 6.86
6 0.72 1.94 2.45 3.14 3.71 5.96
7 0.71 1.90 2.37 3.00 3.50 5.41
8 0.71 1.80 2.31 2.90 3.36 5.04
9 0.70 1.83 2.26 2.82 3.25 4.78
10 0.70 1.81 2.23 2.76 3.17 4.59
11 0.70 1.80 2.20 2.72 3.11 4.44
12 0.70 1.78 2.18 2.68 3.06 4.32
13 0.69 1.77 2.16 2.65 3.01 4.22
14 0.69 1.76 2.15 2.62 2.98 4.14
15 0.69 1.75 2.13 2.60 2.95 4.07
16 0.69 1.75 2.12 2.58 2.92 4.02
17 0.69 1.74 2.11 2.57 2.90 3.97
18 0.69 1.73 2.10 2.55 2.88 3.92
19 0.69 1.73 2.09 2.54 2.86 3.88
20 0.69 1.73 2.09 2.53 2.85 3.85
21 0.69 1.72 2.08 2.52 2.83 3.83
22 0.69 1.72 2.07 2.51 2.82 3.79
23 0.69 1.71 2.07 2.50 2.81 3.77
24 0.69 1.71 2.06 2.49 2.80 3.75
25 0.68 1.71 2.06 2.49 2.79 3.73
26 0.68 1.71 2.06 2.48 2.78 3.71
27 0.68 1.70 2.05 2.47 2.77 3.69
28 0.68 1.70 2.05 2.47 2.76 3.67
29 0.68 1.70 2.05 2.46 2.76 3.66
30 0.68 1.70 2.04 2.46 2.75 3.65
∞ 0.67 1.65 1.96 2.33 2.58 3.29
TESTING OF HYPOTHESIS 725
Degrees
of
freedom
for
numerator
1
2
3
4
5
6
7
8
9
10
12
15
20
24
20
40
60
120
∞
1
161
200
216
225
230
234
237
239
241
242
244
246
248
249
250
251
252
253
254
2
18.5
19.0
19.2
19.2
19.3
19.3
19.4
19.4
19.4
19.4
19.4
19.4
19.4
19.5
19.5
19.5
19.5
19.5
19.5
3
10.1
9.55
9.28
9.12
9.01
9.94
8.89
8.85
8.81
8.79
8.74
8.70
8.66
8.64
8.62
8.59
8.57
8.55
8.53
4
7.71
6.94
6.59
6.39
6.26
6.16
6.09
6.04
6.00
5.96
5.91
5.86
5.80
5.77
5.75
5.72
5.69
6.66
5.63
5
6.61
5.79
5.41
5.19
5.05
4.95
4.88
4.82
4.77
4.74
4.68
4.62
4.56
4.53
4.50
4.46
4.43
4.40
4.37
6
5.99
5.14
4.76
4.53
4.39
4.28
4.21
4.15
4.10
4.06
4.00
3.94
3.87
3.84
3.81
3.77
3.74
3.70
3.67
7
5.59
4.74
4.35
4.12
3.97
3.87
3.79
3.73
3.68
3.64
3.57
3.51
3.44
3.41
3.38
3.34
3.30
3.27
3.23
8
5.32
4.46
4.07
3.84
3.69
3.58
3.50
3.44
3.39
3.35
3.28
3.22
3.15
3.12
3.08
3.04
3.01
2.97
2.93
9
5.12
4.26
3.86
3.63
3.48
3.37
3.29
3.23
3.18
3.14
3.07
3.01
2.94
2.90
2.86
2.83
2.79
2.75
2.71
10
4.96
4.10
3.71
3.48
3.33
3.22
3.14
3.07
3.02
2.98
2.91
2.85
2.77
2.74
2.70
2.66
2.62
2.58
2.54
11
4.84
3.98
3.59
3.36
3.20
3.09
3.01
2.95
2.90
2.85
2.79
2.72
2.65
2.61
2.57
2.53
2.49
2.45
2.40
12
4.75
3.89
3.49
3.26
3.11
3.00
2.91
2.85
2.80
2.75
2.69
2.62
2.54
2.51
2.47
2.43
2.38
2.34
2.30
13
4.67
3.81
3.41
3.18
3.03
2.92
2.83
2.77
2.71
2.67
2.60
2.53
2.46
2.42
2.38
2.34
2.30
2.25
2.21
14
4.60
3.74
3.34
3.11
3.96
2.85
2.76
2.70
2.65
2.60
2.53
2.46
2.39
2.35
2.31
2.27
2.22
2.18
2.13
15
4.54
3.68
3.29
3.06
3.90
2.79
2.71
2.64
2.59
2.54
2.48
2.40
2.33
2.29
2.25
2.20
2.16
2.11
2.07
16
4.49
3.63
3.24
3.01
2.85
2.74
2.66
2.59
2.54
2.49
2.42
2.35
2.28
2.24
2.19
2.15
2.11
2.06
2.01
17
4.45
3.59
3.20
2.96
2.81
2.70
2.61
2.55
2.49
2.45
2.38
2.31
2.23
2.19
2.15
2.10
2.06
2.01
1.96
18
4.41
3.55
3.16
2.93
2.77
2.66
2.58
2.51
2.46
2.41
2.34
2.27
2.19
2.15
2.11
2.06
2.02
1.97
1.92
TABLE
2:
F-Distribution
Values
of
F
for
F-Distributions
with
0.05
of
the
Area
in
The
Right
Tall
726 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
19
4.38
3.52
3.13
2.90
2.74
2.63
2.54
2.48
2.42
2.38
2.31
2.23
2.16
2.11
2.07
2.03
1.98
1.93
1.88
20
4.35
3.49
3.10
2.87
2.17
2.60
2.51
2.45
2.39
2.35
2.28
2.20
2.12
2.08
2.04
1.99
1.95
1.90
1.84
21
4.32
3.47
3.07
2.84
2.68
2.57
2.49
2.42
2.37
2.32
2.25
2.18
2.10
2.05
2.01
1.96
1.92
1.87
1.81
22
4.30
3.44
3.05
2.82
2.66
2.55
2.46
2.40
2.34
2.30
2.23
2.15
2.07
2.03
1.98
1.94
1.89
1.84
1.78
23
4.28
3.42
3.03
2.80
2.64
2.53
2.44
2.37
2.32
2.27
2.20
2.13
2.05
2.01
1.96
1.91
1.86
1.81
1.76
24
4.26
3.40
3.01
2.78
2.62
2.51
2.42
2.36
2.30
2.25
2.18
2.11
2.03
1.98
1.94
1.98
1.84
1.79
1.73
25
4.24
3.39
2.99
2.76
2.60
2.94
2.40
2.34
2.28
2.24
2.16
2.29
2.01
1.96
1.92
1.87
1.82
1.77
1.71
30
4.17
3.32
2.92
2.69
2.53
2.42
2.33
2.27
2.21
2.16
2.09
2.01
1.93
1.89
1.84
1.79
1.74
1.64
1.62
40
4.08
3.23
2.84
2.61
2.45
2.34
2.25
2.18
2.12
2.08
2.00
1.92
1.84
1.79
1.74
1.69
1.64
1.58
1.51
60
4.00
3.15
2.76
2.53
2.37
2.25
2.17
2.10
2.04
1.99
1.92
1.84
1.75
1.70
1.65
1.59
1.53
1.47
1.39
120
3.92
3.07
2.68
2.45
2.29
2.18
2.09
2.02
1.96
1.91
1.83
1.75
1.66
1.61
1.55
1.50
1.43
1.35
1.25
∞
3.84
3.00
2.60
2.37
2.21
2.10
2.01
1.94
1.88
1.83
1.75
1.67
1.57
1.52
1.46
1.39
1.32
1.22
1.00
TESTING OF HYPOTHESIS 727
TABLE 3: CHI-SQUARE DISTRIBUTION
Significant Values χ2 (α) of Chi-Square Distribution Right Tail Areas for
Given Probability α, P = Pr (χ2  χ2 (α)) = α And ν Degrees of Freedom
(difference)
Degrees Probability (Level of significance)
of
freedom
(ν) 0 = .99 0.95 0.50 0.10 0.05 0.02 0.01
1 .000157 .00393 .455 2.706 3.841 5.214 6.635
2 .0201 .103 1.386 4.605 5.991 7.824 9.210
3 .115 .352 2.366 6.251 7.815 9.837 11.341
4 .297 .711 3.357 7.779 9.488 11.668 13.277
5 .554 1.145 4.351 9.236 11.070 13.388 15.086
6 .872 2.635 5.348 10.645 12.592 15.033 16.812
7 .1.239 2.167 6.346 12.017 14.067 16.622 18.475
8 3.646 2.733 7.344 13.362 15.507 18.168 20.090
9 2.088 3.325 8.343 14.684 16.919 19.679 21.669
10 2.558 3.940 9.340 15.987 18.307 21.161 23.209
11 3.053 4.575 10.341 17.275 19.675 22.618 24.725
12 3.571 5.226 11.340 18.549 21.026 24.054 26.217
13 4.107 5.892 12.340 19.812 22.362 25.472 27.688
14 4.660 6.571 13.339 21.064 23.685 26.873 29.141
15 4.229 7.261 14.339 22.307 24.996 28.259 30.578
16 5.812 7.962 15.338 23.542 26.296 29.633 32.000
17 6.408 8.672 15.338 24.769 27.587 30.995 33.409
18 7.015 9.390 17.338 25.989 28.869 32.346 34.805
19 7.633 10.117 18.338 27.204 30.144 33.687 36.191
20 8.260 10.851 19.337 28.412 31.410 35.020 37.566
21 8.897 11.591 20.337 29.615 32.671 36.343 38.932
22 9.542 12.338 21.337 30.813 33.924 37.659 40.289
23 10.196 13.091 22.337 32.007 35.172 38.968 41.638
24 10.856 13.848 23.337 32.196 36.415 40.270 42.980
25 11.524 14.611 24.337 34.382 37.65 41.566 44.314
26 12.198 15.379 25.336 35.363 38.885 41.856 45.642
27 12.879 16.151 26.336 36.741 40.113 41.140 46.963
28 13.565 16.928 27.336 37.916 41.337 45.419 48.278
29 14.256 17.708 28.336 39.087 42.557 46.693 49.588
30 14.933 18.493 29.336 40.256 43.773 47.962 50.892
For degrees of freedom (ν) greater than 30, the quantity 2 2 1
2
χ ν
− −
may be used as a normal variate with unit variance.
NOTE
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
APPENDICES
P a r t 6
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
APPENDIX A
ANSWERS TO
SELECTED EXERCISES
731
ASSIGNMENT 1.1
5. printf (“the given value is %f”, 22.23);
7. x = 10.0
Sum = 1 +
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
+ + + + + + + .
19. 3
ASSIGNMENT 2.1
1. 3.264, 35.47, 4986000, 0.7004, 0.0003222, 1.658, 30.06, 0.8594, 3.142.
3. 0.0005 5. 48.21, 2.37, 52.28, 2.38, 2.38, 81.26
7. (i) 0.004, 0.0015772 (ii) 0.006, 0.0023659
9. (34.5588, 35.9694)
732 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 2.2
3. 0.00355, 0.0089 5. 12
7. q = 3.43636, er = 0.020857
ASSIGNMENT 2.3
1. .4485 E 8
7. .1010 E 1, .1012 E 1; correct value = .1012034 E 1
9. (i) x = – .3217 E 2, y = .1666 E 2; yes
(ii) x = – .2352 E 2, y = .1250 E 2.
11. .168 × 103.
ASSIGNMENT 3.1
1. (i) x: – 4 – 3 – 2 – 1 0 1 2 3 4
f(x): 1.0625 .125 – .75 – 1.5 – 2 – 2 – 1 2 9
Roots lie in (– 3, – 2) and (2, 3).
(ii) 1.7281 in interval (1, 2).
3. 0.111 5. 2.02875625
7. 4.712389 9. 2.374
11. .56714333
13. (i) – 2.1048 (ii) 2.621 (iii) .682 (iv) .657, 1.834
15. .322 17. 0.39188
19. 2.94282
21. (i) (– 3, – 2) (ii) Root lies in the interval (– 2.5, – 2.25)
ASSIGNMENT 3.2
1. 0.0912 3. (i) 2.9353 (ii) – .420365 (iii) 1.83928
(iv) – .682327803 (v) 2.690647448 (vi) 2.594313016
5. 5.4772 7. 0.10260
ANSWERS TO SELECTED EXERCISES 733
ASSIGNMENT 3.3
1. 2.942821 3. 1.875
7. (i) 1.860, .2541 (ii) 1.69562
(iii) 1.2134 (iv) 2.7473
13. – 1.25115 and 0.55000
ASSIGNMENT 3.4
3. 0.5177573637
ASSIGNMENT 3.5
1. x2 – 2.40402 + 3.0927 3. x2 + 1.94184x + 1.95685
ASSIGNMENT 3.6
1. (i) 1.324 (ii) 1.839286755
3. (i) 2.279 (ii) 3.20056 (iii) .76759
ASSIGNMENT 3.7
1. 5.12487, 1.63668, 0.23845
ASSIGNMENT 3.8
1. (i) 2.7698 (ii) 2.231 (iii) 3.107
ASSIGNMENT 3.9
1. 1.856
3. (i) 2.094568 (ii) 2.279
5. (i) 0.511 (ii) 0.657 (iii) 2.908
(iv) – 2.533 (v) 1.171 (vi) .739
(vii) 1.896 (viii) 1.756 (ix) 4.4934
734 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
9. 4.9324 11. 1.442
13. (a) 5.099 (b) 5.384 (c) 5.916
15. p =
5
9
, q =
5
9
, r = –
1
9
; Third order
17. Roots lie in (0, 1) and (1, 2); 0.100336, 1.679631
19. 0.298 21. – 0.5081
ASSIGNMENT 3.10
1. (iii) Newton-Raphson method since it deals with multiple roots as well.
ASSIGNMENT 3.11
1. (i) 2, 1, 1 (ii) 2.556, 2.861, 0.8203 (iii) 1.3247, – .6624 ± .5622i
ASSIGNMENT 3.12
1. .56704980
3. 1, 0, 1.0, 0.5, .66666, .75000, .666666, .666666, .69230769
ASSIGNMENT 4.1
1. 239, 371 9. (i) 3x2 – 3x + 1 (ii) 6x
ASSIGNMENT 4.2
1. 16.1, 2x is not a polynomial 3. 0.4147
5. 27, 125
ASSIGNMENT 4.3
1. 244
ANSWERS TO SELECTED EXERCISES 735
ASSIGNMENT 4.4
1. 15.6993 nautical miles 3. 43.704
5. 0.23589625 7. 51
9. (a) 27 (b) 27 11. 0.1205
ASSIGNMENT 4.5
1. 0.3057 3. 15.47996
5. 421.875 7. 0.783172
9. 219 11. 6.36, 11.02
ASSIGNMENT 4.6
1. 19.407426 3. 2290.0017
5. .046
ASSIGNMENT 4.7
1. 22898 3. 1.2662
5. 0.70696
ASSIGNMENT 4.8
1. 0.9391002 3. 0.19573
5. 0.32495
ASSIGNMENT 4.9
1. 0.496798 3. 7957.1407
5. 1.904082 7. 3250.875
736 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 4.10
1. 3.3756 3. 4913, 5052, 5185, 5315
5. 3250.875 7. 14.620947
9. 19523.5, 215914
11. 3.7084096, 3.7325079, 3.7563005, 3.7797956
13. 1.904082 15. 6.7531
ASSIGNMENT 4.11
1. 37.8, 73; 2x is not a polynomial 3. (i) 100.99999 (ii) 25
5. 0.64942084 7. 1294.8437
9. x4 – 3x3 + 5x2 – 6 11. 12.45
13. 53 17. 2.4786
19. x5 – 9x4 + 18x3 – x2 + 9x – 18
ASSIGNMENT 4.12
1. 810 3. 521
5. 328 7. (x – 1)3 + 2(x – 1)2 + 4(x – 1) + 11
9.
1
2 1
1
2
1
2 1
( ) ( )
x x x
−
+
−
−
+
11. 2.49136 13. 10.
ASSIGNMENT 4.13
1. f(x) = 2x4 – x2 + x + 1,
11
8
,
3
8
. 3.
1
2
(5x3 – 3x5).
5. 0.86742375.
7. (1 + 3x) (1 – x)2 + (2 – x)ex2; 1.644; 1.859.
9. 1.02470. 11. 0.993252.
13. (i) 29.556 x3 – 85.793 x2 + 97.696 x – 34.07; 19.19125.
(ii) Same polynomial as in (i).
15. (i) 0.0068 x5 + 0.002 x4 – 0.1671 x3 – 0.0002 x2 + x; 0.6816.
(ii) x3 – 6x2 – 5x + 4; 0.125, – 13.625.
ANSWERS TO SELECTED EXERCISES 737
ASSIGNMENT 5.1
1. 3.946, – 3.545, 2.727, – 1.703 3. – 27.9, 117.67
5. (i) 0.5005, – 0.2732 (ii) 0.4473, – 0.1583 (iii) 0.4662, – 0.2043
7. 0.9848 9. 18, 18
11. 232.869 13. 0.10848
17. 0.0018 19. (a) – 52.4 (b) – 0.01908.
ASSIGNMENT 5.2
1. 0.69325; 0.0001 3. 1.8278
5. (i) 1.82765512 (ii) 1.82784789 7. 177.483
9. 0.83865 11. 1.61
13. 1.1615 15. 30.87 m/sec
17. (i) 591.85333 (ii) 591.855 19. 0.693255; 0.0001078
21. 1.0101996 23. (i) 0.6827 (ii) 0.658596
25. 1.14 27. 0.52359895
29. 1.019286497.
ASSIGNMENT 5.3
1. (i) 0.01138 (ii) 0.00083 3. 3.1428
5. 0.0490291.
ASSIGNMENT 6.1
1. .019984, .0200 3. 0.0214
5. 0.7432, 0.7439 9. y(0.1) = 3.005, y(0.2) = 3.020.
ASSIGNMENT 6.2
1. y(0.2) = 1.0199, y(0.5) = 1.1223
3. y(.02) = 1.0202, y(.04) = 1.0408, y(.06) = 1.0619
5. y(.1) = 1.222, y(.2) = 1.375, y(.3) = 1.573
7. 1.0526, 1.1104 9. 1.76393
11. y(.01) = 1.01, y(.02) = 1.0201.
738 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 6.3
1. 2.2052, 2.4214
3. y(x) = 1
2 2
5
8
10954
2 3
4
+ − + −
x
x x
x ; .
5. y(0.1) = 2.0845, z(0.1) = 0.5867
y(0.2) = 2.1366338, z(0.2) = 0.1549693.
ASSIGNMENT 6.4
1. 1.11034 3. y(1.2) = 2.4921, y(1.4) = 3.2320
5. y(0.5) = 1.375, y(1.0) = 1.6030 7. y(1.1) = 1.8955, y(1.2) = 2.5041.
9. y(0.1) = 1.1168873, y(0.2) = 1.2773914, y(0.3) = 1.50412
11. (i) 1.1749, (ii) y(0.6) = 0.61035, y (0.8) = 0.84899
13. y(1.2) = 0.246326, y(1.4) = 0.622751489
15. y(0.1) = 1.118057, y(0.2) = 1.291457, y(0.3) = 1.584057
17. y(0.2) = 1.195999, y(0.4) = 1.375269.
ASSIGNMENT 6.5
1. y4
(3) = y(0.8) = 1.218 3. 2.0444
5. y(0.3) = 1.0150
7. y(0.5) = 1.3571, y(1) = 1.5837, y(1.5) = 1.7555, y(2) = 1.8957
9. y(0.4) = 1.538, y(0.5) = 1.751 11. y(0.8) = 2.3164, y(1.0) = 2.3780
13. y(0.1) = 0.60475.
ASSIGNMENT 6.6
1. y(0.4) = 2.2089, y(0.5) = 3.20798
3. y(1.4) = 0.9996
5. 1.1107, 1.2459, 1.4111, 1.61287.
ANSWERS TO SELECTED EXERCISES 739
ASSIGNMENT 7.1
1. y = 2.4333 + 0.4x 3. y = – 4 + 6x
5. y = 54.35 + 0.5184x° 7. y = – 1.6071429x + 8.6428571
9. P = 2.2759 + 0.1879 W.
ASSIGNMENT 7.2
1. y = e0.5x 3. y = 4.642 e0.46x
5. y = 99.86 (1.2)x 7. y = 2.978 x0.5143
9. y = 0.509x2 –
2 04
.
x
11. y = 13.0065 +
6.7512 4.4738
x x
− 2
13. xy = 16.18x + 40.78 15. pv1.42 = 0.99.
ASSIGNMENT 7.3
1. x = 2.5, y = 0.7 3. x = 2.47, y = 3.55, z = 1.92
5. (i) x = 1.54, y = 1.27, z = – 1.08
(ii) x = 1.16, y = – .76, z = 2.8
(iii) x = 6.9, y = 3.6, z = 4.14.
ASSIGNMENT 7.4
1.
1
2
7
4
1
2
1
4
T T T T
0 1 2 3
( ) ( ) ( ) ( )
x x x x
+ − +
3. 2x + 2x2 7.
15
16
1
2
− x
9.
191
192
1
2
2
− x
11. M1 = 8, M2 = – 14
F(x) =
− + − +
11 45 40 18
3
3 2
x x x
; F(1.5) = 7.375
740 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
13. M1 = −
18
5
, M2 =
12
5
For 1 ≤ x ≤ 2, F(x) = − + − −
3 9 5
5
3 2
x x x
For 2 ≤ x ≤ 3, F(x) =
5 39 95 69
5
3 2
x x x
− + −
For 3 ≤ x ≤ 4, F(x) = − + − +
2 24 94 120
5
3 2
x x x
15. α = 1, β = 3
17. For 0 ≤ x ≤
1
3
, F(x) = 0.63x3 – 0.82x + 1
For
1
3
2
3
≤ ≤
x , F(x) = – 0.45x3 + 1.08x2 – 1.18x + 1.0
For
2
3
≤ x ≤ 1, F(x) = – 0.18x3 + 0.54x2 – 0.8x + 0.96
I = 0.695
ASSIGNMENT 7.5
1. y = 1.3x + 1.1
3. F = 0.18793W + 2.27595; F = 30.4654 kg wt.
5. x = 4, y = 7, r = – 0.5
7. y = 0.04765 + 0.004071 P; y = 0.6583 cm
9. x = 6, y = 1, r = – 0.48989 11. 7x – 11y + 6 = 0
13. r = 0.70, x = 11.5086, y = 11.5261, no
15. y = 1.68x + 1.044, x = 0.42y + 2.27; y = 14.484
17. y = x + 1; x = 0.16y + 2.36; x = 2.52
19. Regression line of y on x: y = 0.74306 x + 1.56821
Regression line of x on y: x = 0.63602 y + 2.0204.
ANSWERS TO SELECTED EXERCISES 741
ASSIGNMENT 7.6
1. y = 1.43 + 0.24x + 2.21x2
5. a = 5.358035714, b = – 38.89492857, c = 67.56.
ASSIGNMENT 7.7
1. CLX
= 0.4988, UCLX
= 0.5172, LCLX
= 0.4804, CLR = 0.018, UCLR = 0.0463,
LCLR = 0. The process is in control.
3. CLC = 2.4, UCLC = 7.05, LCLC = 0, the process is not under control
5. CLX
= 10.66, UCLX
= 14.295, LCLX
= 7.025, CLR = 0.3, UCLR = 13.32,
LCLR = 0 ; The process is under control
7. UCLC = 25.23, LCLC = 2.77. The process is in control.
ASSIGNMENT 8.1
1. H0 rejected at 5% level 3. H0 rejected at 5% level
5. H0 accepted at 5% level.
ASSIGNMENT 8.2
1. H0: Accepted 3. H0: Accepted.
ASSIGNMENT 8.3
1. H0 is rejected 3. 48.8 and 51.2
5. H0 rejected both at 1% to 5% level of significance.
ASSIGNMENT 8.4
1. Significant difference 3. Highly significant
5. 48.75, 51.25.
742 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
ASSIGNMENT 8.5
1. z = 2.315, Difference significant at 5% level; z = 1.31, Difference not
significant at 5% level.
ASSIGNMENT 8.6
1. accepted 3. rejected.
ASSIGNMENT 8.7
1. accepted 3. accepted
5. accepted.
ASSIGNMENT 8.8
1. rejected 3. accepted.
ASSIGNMENT 8.9
1. no 3. accepted
5. Poisson law fits the data 7. yes.
9. Accepted at 1% level of significance and rejected at 5% level of significance.
ASSIGNMENT 8.10
1. No 3. Not effective.
1. Attempt any FOUR parts of the following:
(a) Define the term ‘absolute error’. Given that
a = 10.00 ± 0.05, b = 0.0356 ± 0.0002
c = 15300 ± 100, d = 62000 ± 500
Find the maximum value of the absolute error in
(i) a + b + c + d (ii) a + 5c – d (iii) d3
(b) Use the series
loge
1
1
+
F
HG I
KJ
x
x
–
= 2 x
x x
+ + +
F
HG
I
KJ
3 5
3 5
......
to compute the value of loge (1.2) correct to seven decimal places and find the
number of terms retained.
(c) Explain underflow and overflow conditions of error with suitable examples
in floating point’s addition and subtraction.
(d) Explain the Bisection method to calculate the roots of an equation. Write an
algorithm and implement it in ‘C’.
(e) Using the method of false position, find the root of equation x6 – x4 – x3 – 1 = 0
up to four decimal places.
743
APPENDIX B
SAMPLE EXAMINATION
744 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
(f) Determine p, q, and r so that the order of the iterative method
xn+1 = pxn +
qa
x
ra
x
n n
2
2
5
+
for a1/3 becomes as high as possible.
2. Attempt any FOUR parts of the following:
(a) Prove that the nth differences of a polynomial of nth degree are constant and
all higher order differences are zero when the values of the independent
variable are at equal interval.
(b) Find the missing terms in the following table:
x 1 2 3 4 5 6 7 8
f (x) 1 8 ? 64 ? 216 343 512
(c) Find the number of students from the following data who secured scores not
more than 45:
Scores range 30–40 40–50 50–60 60–70 70–80
Number of students 35 48 70 40 22
(d) State and prove Stirling’s formula.
(e) By means of Lagrange’s formula, prove that
y1 = y3 – 0.3 (y5 – y–3) + 0.2 (y–3 – y–5)
(f) Prove that the nth divided differences of a polynomial of nth degree are
constant.
3. Attempt any TWO parts of the following:
(a) y is a function of x satisfying the equation xy″ + ay′ + (x – b) y = 0 where a and
b are integers. Find the values of constants a and b if y is given by the following
table:
x 0.8 1 1.2 1.4 1.6 1.8 2 2.2
y 1.73036 1.95532 2.19756 2.45693 2.73309 3.02549 2.3333 3.65563
(b) Find, from the following table, the area bounded by the curve and the x-axis
from x = 7.47 to x = 7.52.
x 7.47 7.48 7.49 7.50 7.51 7.52
f(x) 1.93 1.95 1.98 2.01 2.03 2.06
SAMPLE EXAMINATION 745
(c) Derive Simpson’s
1
3
F
HG I
KJ
rd
rule from Newton-Cote’s quadrature formula. Give
its algorithm and write a program in ‘C’ to implement.
4. Attempt any TWO parts of the following:
(a) Obtain y for x = 0.25, 0.5 and 1.0 correct to three decimal places using Picard’s
method, given the differential equation
dy
dx
x
y
=
+
2
2
1
with the initial condition y = 0 when x = 0.
(b) Use Runge-Kutta method to approximate y when x = 1.4 given that y = 2 at x
= 1 and
dy
dx
= xy taking h = 0.2.
(c) Explain Predictor-Corrector methods. Write the algorithm of Milne’s
Predictor-corrector method and also give a code in ‘C’ to implement.
5. Attempt any FOUR parts of the following:
(a) Write a short note on Frequency charts.
(b) Find the least square line for the data points:
(– 1, 10), (0, 9), (1, 7), (2, 5), (3, 4), (4, 3), (5, 0) and (6, – 1).
(c) Find the most plausible values of x and y from the following equations:
3x + y = 4.95, x + y = 3.00, 2x – y = 0.5, x + 3y = 7.25.
(d) Prove that the regression coefficients are independent of the origin but not of
scale.
(e) The average percentage of defectives in 27 samples of size 1500 each was
found to be 13.7%. Construct p-chart for this situation. Explain how the control
chart can be used to control quality.
(f) Fit a curve of the type xy = ax + b to the following data:
x 1 3 5 7 9 10
y 36 29 28 26 24 15
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
n Included on the CD-ROM are simulations, figures from the text, third party
software, and other files related to topics in numerical methods and
statistics.
n See the “README” files for any specific information/system requirements
related to each file folder, but most files will run on Windows 2000 or higher
and Linux.
747
APPENDIX C
ABOUT THE CD-ROM
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf
749
A
Absolute error, 37
Acceptance sampling, 655
Adams-Moulton (or Adams-Bashforth)
formula, 537
Adams-Moulton corrector formula, 539
Adams-Moulton predictor formula, 538
Advantages of statistical quality control, 656
Advantages/Features of ‘C’ language, 7
Algebraic and transcendental equations, 77
Algorithm for linear regression, 621
Algorithm of Euler’s method, 493
Algorithm of Milne’s predictor-corrector
method, 528
Algorithm of modified Euler’s method, 497
Algorithm of Runge-Kutta method, 516
Algorithm of second degree parabolic curve
fitting, 647
Algorithm of Simpson’s 1/3rd rule, 437
Algorithm of Simpson’s 3/8th rule, 433
Algorithm of trapezoidal rule, 429
Algorithmic errors, 31
Alternative hypothesis, 673
Analysis of data, 655
Angle between two lines of regression, 620
Applications of t-distribution, 691
Approximations, 601
Area diagrams, 555
Argument, 202
Arrays, 18
Assembler, 6
Assumptions for interpolation, 200
Asymptotic error constant, 80
Averaging operator μ, 205
B
Backward difference operator, 203
Backward differences, 203
INDEX
750 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Curve of regression, 614
Curve-Fitting by sum of exponentials, 588
D
Debugging, 80
Decision making instructions in “C”, 14
Degrees of freedom, 709
Detection of errors by use of difference tables,
234
Differences of a polynomial, 207
Discrete variables, 548
Divided differences, 361
E
Error formula, 42
Error in a series approximation, 56
Error in Lagrange’s interpolation formula, 357
Errors in numerical computations, 43
Errors in numerical differentiation, 422
Errors in polynomial interpolation, 200
Errors in sampling, 674
Escape sequences, 12
Euler-Maclaurin’s Formula, 461
Euler’s formula, 493
Euler’s method, 492
Euler’s modified method, 493
Evaluation of principal value integrals, 466
Expression of rational function as a sum of
partial fractions, 359
Extrapolation, 199
F
Factorial notation, 225
Fibonacci numbers, 27
Bell shaped curve, 553
Bessel’s interpolation formula, 312
Bisection (or Bolzano) method, 77
Boole’s rule, 426
C
‘C’ constants, 8
“C instructions”, 10
“C” variables, 9
χ2 test as a test of goodness of fit, 711
χ2 test as a test of independence, 718
Carl Runge, 513
Cartograms, 555
Central difference operator, 204
Central differences, 204
Chebyshev formula of third order, 175
Chebyshev polynomial approximation, 605
Chi-square (χ2) test, 708
Class frequency, 549
Comparison of correlation and regression
analysis, 618
Comparison of iterative methods, 189
Computational errors, 31
Conditions for applying χ2 test, 710
Confidence limits or fiducial limits, 684
Continuous variables, 548
Control chart, 655, 658
Control charts for attributes, 661
Convergence of a sequence, 81
Convergence of iteration method, 96
Convergence of regula-falsi method, 130
Critical region, 674
Critical value of t, 691
Cubic spline interpolation, 594
Cumulative frequency, 549
Cumulative frequency curve or the ogive, 553
Curve fitting, 556
INDEX 751
Finite differences, 202
Finite inverse, 671
First order Runge-Kutta method, 514
Floating point representation of numbers, 61
Flow-chart for trapezoidal rule, 430
Flow-chart of Euler’s method, 494
Flow-chart of Milne’s predictor-corrector
method, 529
Flow-chart of modified Euler’s method, 498
Flow-chart of Runge-Kutta method, 517
Flow-chart of second degree parabolic curve
fitting, 649
Flow-chart of Simpson’s 1/3rd rule, 438
Flow-chart of Simpson’s 3/8th rule, 434
Forward difference operator, 202
Forward differences, 202
Fourth order Runge-Kutta method, 515
Frequency charts, 548
Frequency curve, 552
Frequency distributions, 548, 655
Frequency polygon, 552
Fundamental operator, 205
G
Gauss’s backward difference formula, 289
Gauss’s forward difference formula, 278
Gaussian quadrature formula, 463
Graeffe’s root-squaring method, 190
Grouped frequency distribution, 549
H
Hermite’s interpolating polynomial, 381
Hermite’s interpolation formula, 381, 382
Horner’s method, 156
Hypothetical universe, 671
I
Initial-value and boundary-value problems,
480
Interpolating polynomial, 200
Interpolation by unevenly spaced points, 338
Inverse interpolation, 360
Inverse problems, 46
Iteration method, 94
J
J-shaped curve, 554
L
Lagrange’s interpolation formula, 339
Lanczos economization of power series, 606
Laplace-Everett’s formula, 327
Legendre and chebyshev polynomials, 601
Lin-bairstow’s method, 135
Linear regression, 614
Lines of regression, 614
Loop control structure, 17
Lower limit, 549
M
Machine computation, 71
Machine epsilon, 34
Maclaurin’s expansion, 61
Marching methods, 481
Mathematical preliminaries, 60
Maxima and minima of a tabulated function,
402
752 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES
Mean value theorem for derivatives, 61
Merits and demerits of Lagrange’s formula,
365
Method for complex root, 135
Method of false position, 113
Method of linear interpolation, 113
Method of separation of symbols, 234
Methods for multiple roots, 182
Milne’s corrector formula, 527
Milne’s method, 525
Milne’s predictor (extrapolation) formula, 526
Modified Euler’s method, 496
Muller’s method, 141
N
Natural spline, 597
Newton-Cote’s quadrature formula, 423
Newton-Raphson method, 158
Newton-Raphson’s extended formula, 175
Newton’s divided difference interpolation
formula, 363
Newton’s Gregory backward interpolation
formula, 262
Newton’s Gregory forward interpolation
formula, 243
Newton’s iterative formulae, 163
Non-periodic spline, 597
Normalized floating point, 62
np chart, 662
Numerical evaluation of singular integrals,
465
Numerical solution of ordinary differential
equations, 479
O
One-step predictor-corrector method, 497
Order of convergence, 80
Orthogonal properties, 603
Osculating interpolation formula, 381
P
P chart, 661
Periodic spline, 597
Picard, 481
Picard’s method of successive approximations,
481
Predictor-corrector methods, 525
Principle of least squares, 556
Prisms and cubes, 555
Procedual errors or numerical errors, 35
Program to implement trapezoidal method,
431
Program to implement simpson’s 3/8th
method, 435
Program in ‘C’ for second degree parabolic
curve fitting, 650
Program of Euler’s method, 495
Program of Milne’s method, 530
Program of modified Euler’s method, 499
Program of Runge-Kutta method, 517
Program to implement least square fit of a
regression, 622, 623
Program to implement Simpson’s 1/3rd
method, 439
Program writing, 80
Properties of chebyshev polynomials, 605
Properties of divided differences, 362
Properties of regression co-efficients, 619
Q
Quotient-difference method, 152
INDEX 753
R
Ramanujan’s method, 195
Region of rejection, 674
Regression analysis, 614
Regression equation, 614
Regression plane, 653
Regula-Falsi method, 113
Residuals, 557
Rolle’s theorem, 60
Runge-Kutta methods, 513
S
Scatter or dot diagram, 556
Secant method, 132
Second order formula, 161
Second order Runge-Kutta method, 514
Significant values χ2 (α) of Chi-square
distribution, 727
Significant values tv (α) of t-distribution, 724
Simpson’s one-third rule, 425
Simplson’s three-eighth rule, 426
Snedecor’s variance ratio test or F-test, 703
Special values of Chebyshev polynomials, 603
Spline function, 594
Spline interpolation, 594
Stability in the solution of ordinary
differential equations, 542
Statistical quality control, 654
Stirling’s formula, 301
Student’s t-distribution, 691
Successive approximation method, 94
T
t-statistic, 691
Taylor’s method, 506
Taylor’s series for a function of one variable,
61
Taylor’s series for a function of two variables,
61
Test of significance, 673
Test of significance for large samples, 676
Test of significance of small samples, 690
Test statistic, 675
Testing of hypothesis, 671
The χ2 distribution, 710
The t-table, 691
Third order Runge-Kutta method, 515
Trapezoidal rule, 424
Two point rule, 466
Type I error, 674
Type II error, 675
Types of frequency curves, 553
U
u-chart, 661
U-shaped curve, 554
Use of regression analysis, 618
V
Values of F for F-distributions, 725
W
Weddle’s rule, 427
Wilhelm Kutta, 513
Y
Yates’s correction, 719
COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf

More Related Content

PPTX
Biometric voting system_by_vinodh
PDF
AD3251 DSD BOOK.pdf,data structure design
PDF
Digital Signal Processing An Introduction R Anand
PDF
Fundamentals Of Signals And Systems 1st Ed Benoit Boulet Leo Chartrand
PDF
Remote Sensing Theory And Applications 1st Edition Garg P K
PDF
Software Engineering And Testing An Introduction 1st Edition B B Agarwal
PDF
Softwareimplemented Hardware Fault Tolerance 1st Edition Olga Goloubeva
PDF
Tensor Analysis For Engineers Transformations And Applications Mehrzad Tabata...
Biometric voting system_by_vinodh
AD3251 DSD BOOK.pdf,data structure design
Digital Signal Processing An Introduction R Anand
Fundamentals Of Signals And Systems 1st Ed Benoit Boulet Leo Chartrand
Remote Sensing Theory And Applications 1st Edition Garg P K
Software Engineering And Testing An Introduction 1st Edition B B Agarwal
Softwareimplemented Hardware Fault Tolerance 1st Edition Olga Goloubeva
Tensor Analysis For Engineers Transformations And Applications Mehrzad Tabata...

Similar to COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf (20)

PDF
(eBook PDF) Systems Analysis and Design 10th by Kenneth E. Kendall
PDF
Automation-Production-Systems-and-CIM-Mikell-P.-Groover-Edisi-4-2015 (1).pdf
PDF
Fundamentals of Signals and Systems 1st ed Edition Benoit Boulet
PDF
Mq peptide-quantitation-tutorial-en
PDF
X431 tool-english-user-manual 2011042217029503
PDF
PLC: Hands on PLC programing with RSLOGIX500 a and Logixpro
PDF
Methodology For The Digital Calibration Of Analog Circuits And Systems Marc P...
PDF
Game Programming Golden Rules Brownlow Martin Brownlow
PDF
Industrial Automation and Robotics 2nd Edition Jean Riescher Westcott A K Gup...
PDF
Google Gemini For Python Coding With Bard Converted Oswald Campesato
PDF
Testing Embedded Software Bart Broekman Edwin Notenboom
PDF
Monitoring Multimode Continuous Processes: A Data-Driven Approach Marcos Quiñ...
PDF
Process Algebra For Parallel And Distributed Processing Michael Alexander Wil...
PDF
(eBook PDF) Systems Analysis and Design 10th by Kenneth E. Kendall
PDF
Automated Continuous Process Control Carlos A Smith
PDF
C Programming Fundamentals Dheeraj Malhotra Neha Malhotra
PDF
D3 Data Driven Documents Pocket Primer 1st Edition Oswald Campesato
PDF
Optimal Design Of Queueing Systems 1st Edition Shaler Stidham Jr
PDF
LabVIEW based Automation Guide for Microwave Measurements 1st Edition Satya K...
PDF
LPG Booking System [ bookmylpg.com ] Report
(eBook PDF) Systems Analysis and Design 10th by Kenneth E. Kendall
Automation-Production-Systems-and-CIM-Mikell-P.-Groover-Edisi-4-2015 (1).pdf
Fundamentals of Signals and Systems 1st ed Edition Benoit Boulet
Mq peptide-quantitation-tutorial-en
X431 tool-english-user-manual 2011042217029503
PLC: Hands on PLC programing with RSLOGIX500 a and Logixpro
Methodology For The Digital Calibration Of Analog Circuits And Systems Marc P...
Game Programming Golden Rules Brownlow Martin Brownlow
Industrial Automation and Robotics 2nd Edition Jean Riescher Westcott A K Gup...
Google Gemini For Python Coding With Bard Converted Oswald Campesato
Testing Embedded Software Bart Broekman Edwin Notenboom
Monitoring Multimode Continuous Processes: A Data-Driven Approach Marcos Quiñ...
Process Algebra For Parallel And Distributed Processing Michael Alexander Wil...
(eBook PDF) Systems Analysis and Design 10th by Kenneth E. Kendall
Automated Continuous Process Control Carlos A Smith
C Programming Fundamentals Dheeraj Malhotra Neha Malhotra
D3 Data Driven Documents Pocket Primer 1st Edition Oswald Campesato
Optimal Design Of Queueing Systems 1st Edition Shaler Stidham Jr
LabVIEW based Automation Guide for Microwave Measurements 1st Edition Satya K...
LPG Booking System [ bookmylpg.com ] Report
Ad

Recently uploaded (20)

PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
master seminar digital applications in india
Yogi Goddess Pres Conference Studio Updates
Final Presentation General Medicine 03-08-2024.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Abdominal Access Techniques with Prof. Dr. R K Mishra
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
A systematic review of self-coping strategies used by university students to ...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
O7-L3 Supply Chain Operations - ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
master seminar digital applications in india
Ad

COMPUTER_BASED_NUMERICAL_and_STATISTICAL.pdf

  • 3. LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY The CD-ROM that accompanies this book may only be used on a single PC. This license does not permit its use on the Internet or on a network (of any kind). By purchasing or using this book/CD-ROM package(the “Work”), you agree that this license grants permission to use the products contained herein, but does not give you the right of ownership to any of the textual content in the book or ownership to any of the information or products contained on the CD-ROM. Use of third party software contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the publisher or the owner of the software in order to reproduce or network any portion of the textual material or software (in any media) that is contained in the Work. INFINITY SCIENCE PRESS LLC (“ISP” or “the Publisher”) and anyone involved in the creation, writing or production of the accompanying algorithms, code, or computer programs (“the software”) or any of the third party software contained on the CD-ROM or any of the textual material in the book, cannot and do not warrant the performance or results that might be obtained by using the software or contents of the book. The authors, developers, and the publisher have used their best efforts to insure the accuracy and functionality of the textual material and programs contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold “as is” without warranty (except for defective materials used in manufacturing the disc or due to faulty workmanship); The authors, developers, and the publisher of any third party software, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profit, or other incidental, physical, or consequential damages arising out of the use of this Work. The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or the CD-ROM, and only at the discretion of the Publisher. The use of “implied warranty” and certain “exclusions” vary from state to state, and might not apply to the purchaser of this product.
  • 4. COMPUTER-BASED NUMERICAL & STATISTICAL TECHNIQUES M. GOYAL INFINITY SCIENCE PRESS LLC Hingham, Massachusetts New Delhi, India
  • 5. Reprint & Revision Copyright © 2007. INFINITY SCIENCE PRESS LLC. All rights reserved. Copyright © 2007. Laxmi Publications Pvt. Ltd. This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means or media, electronic or mechanical, including, but not limited to, photocopy, recording, Internet postings or scanning, without prior permission in writing from the publisher. Publisher: David F. Pallai INFINITY SCIENCE PRESS LLC 11 Leavitt Street Hingham, MA 02043 Tel. 877-266-5796 (toll free) Fax 781-740-1677 info@infinitysciencepress.com www.infinitysciencepress.com This book is printed on acid-free paper. M. Goyal. Computer-Based Numerical & Statistical Techniques. ISBN: 978-0-9778582-5-5 The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others. Library of Congress Cataloging-in-Publication Data Goyal, M. Computer-based numerical & statistical techniques / M. Goyal. p. cm. Includes index. ISBN 978-0-9778582-5-5 (hardcover with cd-rom : alk. paper) 1. Engineering mathematics – – Data processing. I. Title. TA345.G695 2007 620.001’51 – – dc22 2007010557 07 6 7 8 9 5 4 3 2 1 Our titles are available for adoption, license or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 877-266-5796 (toll free). Requests for replacement of a defective CD-ROM must be accompanied by the original disc, your mailing address, telephone number, date of purchase and purchase price. Please state the nature of the problem, and send the information to INFINITY SCIENCE PRESS, 11 Leavitt Street, Hingham, MA 02043. The sole obligation of INFINITY SCIENCE PRESS to the purchaser is to replace the disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.
  • 6. CONTENTS PART 1 Chapter 1 Introduction 3—30 1.1 Introduction to Computers 4 1.2 Definitions 4 1.3 Introduction to “C” Language 6 1.4 Advantages/Features of ‘C’ language 7 1.5 ‘C’ Character Set 7 1.6 ‘C’ Constants 8 1.7 “C” Variables 9 1.8 ‘C’ Key Words 10 1.9 “C Instructions” 10 1.10 Hierarchy of Operations 11 1.11 Escape Sequences 12 1.12 Basic Structure of ‘‘C’’ Program 12 1.13 Decision Making Instructions in “C” 14 1.14 Loop Control Structure 17 1.15 Arrays and String 18 1.16 Pointers 19 1.17 Structure and Unions 20 1.18 Storage Classes in ‘C’ 21 Chapter 2 Errors 31—76 2.1 Errors and Their Analysis 31 2.2 Accuracy of Numbers 32 2.3 Errors 34 2.4 A General Error Formula 42 2.5 Errors in Numerical Computations 43 2.6 Inverse Problems 46 v
  • 7. vi CONTENTS 2.7 Error in a Series Approximation 56 2.8 Mathematical Preliminaries 60 2.9 Floating Point Representation of Numbers 61 2.10 Arithmetic Operations with Normalized Floating Point Numbers 63 2.11 Machine Computation 71 2.12 Computer Software 72 Chapter 3 Algebraic and Transcendental Equations 77—196 3.1 Bisection (or Bolzano) Method 77 3.2 Algorithm 78 3.3 Flow-Chart 79 3.4 Program Writing 80 3.5 Order of Convergence of Iterative Methods 80 3.6 Order of Convergence of Bisection Method 80 3.7 Convergence of a Sequence 81 3.8 Prove that Bisection Method Always Converges 81 3.9 Program to Implement Bisection Method 84 3.10 Iteration Method—(Successive Approximation Method) 94 3.11 Sufficient Condition for Convergence of Iterations 95 3.12 Theorem 95 3.13 Convergence of Iteration Method 96 3.14 Algorithm for Iteration Method 96 3.15 Flow-Chart for Iteration Method 98 3.16 Computer Program 99 3.17 The Method of Iteration for System of Non-Linear Equations 111 3.18 Method of False Position or Regula-Falsi Method 113 3.19 Algorithm 114 3.20 Flow-Chart 116 3.21 Convergence of Regula-Falsi Method 130 3.22 Secant Method 132 3.23 Lin-Bairstow’s Method or Method for Complex Root 135 3.24 Muller’s Method 141 3.25 Algorithm of Muller’s Method 142 3.26 Flow-Chart for Muller’s Method 144 3.27 The Quotient-Difference Method 152 3.28 Horner’s Method 156 3.29 Newton-Raphson Method 158 3.30 Convergence 159
  • 8. CONTENTS vii 3.31 Order of Convergence 159 3.32 Geometrical Interpretation 161 3.33 Algorithm of Newton-Raphson Method 161 3.34 Flow-Chart of Newton–Raphson Method 162 3.35 Newton’s Iterative Formulae for Finding Inverse, Square Root 163 3.36 Rate of Convergence of Newton’s Square Root Formula 164 3.37 Rate of Convergence of Newton’s Inverse Formula 164 3.38 Definitions 182 3.39 Methods for Multiple Roots 182 3.40 Nearly Equal Roots 187 3.41 Comparison of Newton’s Method with Regula-Falsi Method 189 3.42 Comparison of Iterative Methods 189 3.43 Graeffe’s Root-Squaring Method 190 3.44 Ramanujan’s Method 195 PART 2 Chapter 4 Interpolation 199—390 4.1 Introduction 199 4.2 Assumptions for Interpolation 200 4.3 Errors in Polynomial Interpolation 200 4.4 Finite Differences 202 4.5 Other Difference Operators 205 4.6 Relation Between Operators 205 4.7 Differences of a Polynomial 207 4.8 Factorial Notation 225 4.9 To Show that (i) Δn[x]n = n ! (ii) Δn+1 [x]n = 0 225 4.10 Reciprocal Factorial 226 4.11 Missing Term Technique 227 4.12 Method of Separation of Symbols 234 4.13 Detection of Errors by Use of Difference Tables 234 4.14 Newton’s Formulae for Interpolation 243 4.15 Newton’s Gregory Forward Interpolation Formula 243 4.16 Newton’s Gregory Backward Interpolation Formula 262 4.17 Central Difference Interpolation Formulae 278 4.18 Gauss’ Forward Difference Formula 278 4.19 Gauss’ Backward Difference Formula 289 4.20 Stirling’s Formula 301
  • 9. viii CONTENTS 4.21 Bessel’s Interpolation Formula 312 4.22 Laplace-Everett’s Formula 327 4.23 Interpolation by Unevenly Spaced Points 338 4.24 Lagrange’s Interpolation Formula 339 4.25 Error in Lagrange’s Interpolation Formula 357 4.26 Expression of Rational Function as a Sum of Partial Fractions 359 4.27 Inverse Interpolation 360 4.28 Divided Differences 361 4.29 Properties of Divided Differences 362 4.30 Newton’s General Interpolation Formula or Newton’s Divided Difference Interpolation Formula 363 4.31 Relation Between Divided Differences and Ordinary Differences 364 4.32 Merits and Demerits of Lagrange’s Formula 365 4.33 Hermite’s Interpolation Formula 381 PART 3 Chapter 5 Numerical Integration and Differentiation 393—476 5.1 Introduction 393 5.2 Numerical Differentiation 394 5.3 Formulae for Derivatives 394 5.4 Maxima and Minima of a Tabulated Function 402 5.5 Errors in Numerical Differentiation 422 5.6 Numerical Integration 423 5.7 Newton-cote’s Quadrature Formula 423 5.8 Trapezoidal Rule (n = 1) 424 5.9 Simpson’s One-third Rule (n = 2) 425 5.10 Simpson’s Three-Eighth Rule (n = 3) 426 5.11 Boole’s Rule 426 5.12 Weddle’s Rule (n = 6) 427 5.13 Algorithm of Trapezoidal Rule 429 5.14 Flow-Chart for Trapezoidal Rule 430 5.15 Program to Implement Trapezoidal Method of Numerical Integration 431 5.16 Output 433 5.17 Algorithm of Simpson’s 3/8th Rule 433 5.18 Flow-Chart of Simpson’s 3/8th Rule 434
  • 10. CONTENTS ix 5.19 Program to Implement Simpson’s 3/8th Method of Numerical Integration 435 5.20 Output 437 5.21 Algorithm of Simpson’s 1/3rd Rule 437 5.22 Flow-Chart of Simpson’s 1/3rd Rule 438 5.23 Program to Implement Simpson’s 1/3rd Method of Numerical Integration 439 5.24 Output 441 5.25 Euler-Maclaurin’s Formula 461 5.26 Gaussian Quadrature Formula 463 5.27 Numerical Evaluation of Singular Integrals 465 5.28 Evaluation of Principal Value Integrals 466 PART 4 Chapter 6 Numerical Solution of Ordinary Differential Equations 479—544 6.1 Introduction 479 6.2 Initial-Value and Boundary-Value Problems 480 6.3 Single Step and Multi-Step Methods 480 6.4 Comparison of Single-Step and Multi-Step Methods 480 6.5 Numerical Methods of Solution of O.D.E. 480 6.6 Picard’s Method of Successive Approximations 481 6.7 Picard’s Method for Simultaneous First Order Differential Equations 488 6.8 Euler’s Method 492 6.9 Algorithm of Euler’s Method 493 6.10 Flow-Chart of Euler’s Method 494 6.11 Program of Euler’s Method 495 6.12 Modified Euler’s Method 496 6.13 Algorithm of Modified Euler’s Method 497 6.14 Flow-Chart of Modified Euler’s Method 498 6.15 Program of Modified Euler’s Method 499 6.16 Taylor’s Method 506 6.17 Taylor’s Method for Simultaneous I Order Differential Equations 508 6.18 Runge-Kutta Methods 513 6.19 Fourth Order Runge-Kutta Method 515 6.20 Runge-Kutta Method for Simultaneous First Order Equations 519
  • 11. x CONTENTS 6.21 Predictor-Corrector Methods 525 6.22 Milne’s Method 525 6.23 Adams-Moulton (or Adams–Bashforth) Formula 537 6.24 Stability 541 6.25 Stability in the Solution of Ordinary Differential Equations 542 6.26 Stability of I Order Linear Differential Equation of Form dy/dx = Ay with Initial Condition y(x0) = y0 542 PART 5 Chapter 7 Statistical Computation 547—670 7.1 The Statistical Methods 547 7.2 Limitation of Statistical Methods 547 7.3 Frequency Charts 548 7.4 Graphical Representation of a Frequency Distribution 550 7.5 Types of Graphs and Diagrams 550 7.6 Histograms 551 7.7 Frequency Polygon 552 7.8 Frequency Curve 552 7.9 Cumulative Frequency Curve or the Ogive 553 7.10 Types of Frequency Curves 553 7.11 Diagrams 555 7.12 Curve Fitting 556 7.13 Principle of Least Squares 556 7.14 Fitting a Straight Line 558 7.15 Algorithm for Fitting a Straight Line of the Form y = a + bx for a Given Set of Data Points 559 7.16 Flow-Chart for Fitting a Straight Line y = a + bx for a Given Set of Data Points 560 7.17 Program to Implement Curve Fitting to Fit a Straight Line 561 7.18 Fitting of an Exponential Curve y = aebx 569 7.19 Fitting of the Curve y = axb 569 7.20 Fitting of the Curve y = abx 569 7.21 Fitting of the Curve pvr = k 570 7.22 Fitting of the Curve of Type xy = b + ax 570 7.23 Fitting of the Curve y = ax2 + b/x 570 7.24 Fitting of the Curve y = ax + bx2 571 7.25 Fitting of the Curve y = ax + b/x 572
  • 12. CONTENTS xi 7.26 Fitting of the Curve y = a + b/x + c/x2 573 7.27 Fitting of the Curve y = c0/x + c1 x 573 7.28 Fitting of the Curve 2x = ax2 + bx + c 574 7.29 Most Plausible Solution of a System of Linear Equations 586 7.30 Curve-Fitting by Sum of Exponentials 588 7.31 Spline Interpolation 594 7.32 Spline Function 594 7.33 Cubic Spline Interpolation 594 7.34 Steps to Obtain Cubic Spline for Given Data 597 7.35 Approximations 601 7.36 Legendre and Chebyshev Polynomials 601 7.37 Legendre Polynomials 601 7.38 Chebyshev Polynomials 602 7.39 Special Values of Chebyshev Polynomials 603 7.40 Orthogonal Properties 603 7.41 Recurrence Relations 603 7.42 Aliter to Find Chebyshev Polynomials 604 7.43 Expression of Powers of x in terms of Chebyshev Polynomials 604 7.44 Properties of Chebyshev Polynomials 605 7.45 Chebyshev Polynomial Approximation 605 7.46 Lanczos Economization of Power Series for a General Function 606 7.47 Regression Analysis 614 7.48 Curve of Regression and Regression Equation 614 7.49 Linear Regression 614 7.50 Lines of Regression 614 7.51 Derivation of Lines of Regression 615 7.52 Use of Regression Analysis 618 7.53 Comparison of Correlation and Regression Analysis 618 7.54 Properties of Regression Co-efficients 619 7.55 Angle between Two Lines of Regression 620 7.56 Algorithm for Linear Regression 621 7.57 Program to Implement Least Square Fit of a Regression Line of y on x 622 7.58 Program to Implement Least Square Fit of a Regression Line of x on y 623 7.59 Polynomial Fit: Non-linear Regression 639 7.60 Multiple Linear Regression 652 7.61 Statistical Quality Control 654
  • 13. xii CONTENTS 7.62 Advantages of Statistical Quality Control 656 7.63 Reasons for Variations in the Quality of a Product 657 7.64 Techniques of Statistical Quality Control 657 7.65 Control Chart 658 7.66 Objectives of Control Charts 658 7.67 Construction of Control Charts for Variables 659 7.68 Control Charts for Attributes 661 Chapter 8 Testing of Hypothesis 671—728 8.1 Population or Universe 671 8.2 Sampling 672 8.3 Parameters of Statistics 672 8.4 Standard Error 672 8.5 Test of Significance 673 8.6 Critical Region 674 8.7 Level of Significance 674 8.8 Errors in Sampling 674 8.9 Steps in Testing of Statistical Hypothesis 676 8.10 Test of Significance for Large Samples 676 8.11 Test of Significance of Small Samples 690 8.12 Student’s t-Distribution 691 8.13 Test I: t-test of Significance of the Mean of a Random Sample 692 8.14 Test II: t-test for Difference of Means of Two Small Samples (From a Normal Population) 695 8.15 Snedecor’s Variance Ratio Test or F-test 703 8.16 Chi-square (χ2) Test 708 8.17 The χ2 Distribution 710 8.18 χ2 Test as a Test of Goodness of Fit 711 8.19 χ2 Test as a Test of Independence 718 PART 6 APPENDICES Appendix A (Answers to Selected Exercises) 731 Appendix B (Sample Examination) 743 Appendix C (About the CD-ROM) 747 Index 749
  • 14. P a r t 1 n Introduction Numbers and Their Accuracy, Computer Arithmetic, Mathematical Preliminaries. n Errors Errors and Their Computation, General Error Formula, Error in a Series Approximation. n Algebraic and Transcendental Equations Bisection Method, Iteration Method, Method of False Position, Newton-Raphson Method, Methods of Finding Complex Roots, Muller’s Method, Rate of Convergence of Iterative Methods, Polynomial Equations.
  • 16. T he limitations of analytical methods in practical applications have led mathematicians to evolve numerical methods. We know that exact methods often fail in drawing plausible inferences from a given set of tabulated data or in finding roots of transcendental equations or in solving non-linear differential equations. Even if analytical solutions are available, they are not amenable to direct numerical interpretation. The aim of numerical analysis is, therefore, to provide constructive methods for obtaining answers to such problems in a numerical form. With the advent of high speed computers and increasing demand for numerical solutions to various problems, numerical techniques have become indispensible tools in the hands of engineers and scientists. We can solve equations x2 – 5x + 6 = 0, ax2 + bx + c = 0, y″ + 3y′ + 2y = 0 by analytical methods, but transcendental equations such as a cos2 x + bex = 0 cannot be solved by analytical methods. Such equations are solved by numerical analysis. Methods of numerical analysis are used to approximate the problem satisfactorily so that an approximate solution, amenable to precise analysis, within a desired degree of accuracy is obtained. To attain a desired degree of accuracy, insight into the process and resulting error is essential. Chapter 1 INTRODUCTION 3
  • 17. 4 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Consequently, numerical analysis may be regarded as a process to develop and evaluate the methods for computing required mathematical numerical results from the given numerical data. Three broad steps are incorporated in the process (i) Given data, called input information (ii) Algorithm (iii) The results obtained, called output information. Input Information The Algorithm Output Information Computers have changed, almost revolutionized, the field of numerical methods as a whole as well as many individual methods. That development is continuing. Much research is devoted to creating new methods, adapting existing methods to new computer generations, improving existing methods, and investigating stability and accuracy of methods. In large scale work, even small improvements bring large savings in time and storage space. 1.1 INTRODUCTION TO COMPUTERS The computer is an information-processing and an information-accessing tool. It accepts information or data from the outside world and processes it to produce new information. It also retrieves the stored information efficiency. Hence, “The computer is an electronic device capable of accepting information, applying prescribed processes to the information, and supplying the results of these processes.” A computer usually consists of input and output devices, storage, arithmetic and logical units, and a control unit. 1.2 DEFINITIONS Cursor A position indicator or blinking character employed in a display on a video terminal to indicate a character to be corrected or a position in which data is to be entered.
  • 18. INTRODUCTION 5 Algorithm A finite, step-by-step procedure made up of mathematical and/or logical operations designed to solve a problem is called an algorithm. Flow-chart A pictorial or graphical representation of a specific sequence of steps to be used by a computer is called a flow-chart. It is, essentially, a convenient way of planning the order of operations involved in an algorithm and helps in writing a program. A flow-chart contains certain symbols to represent the various operations . These symbols are connected by arrows to indicate the flow of information. The commonly used symbols with meanings are given below: 1. This oval shaped symbol is used to indicate ‘Start’ or ‘Stop/End’ of a program. It is also used to mark the end of a sub-program by writing ‘Return’. 2. This parallelogram shaped symbol is used to indicate an input or output of data. 3. This rectangle-shaped symbol is a processing symbol, e.g., addition, subtraction, or movement of data to computer memory. 4. This diamond shaped symbol is a decision- making symbol. A particular path is chosen depending on ‘Yes’ or ‘No’ answer. 5. A small circle with any number or letter in it is used as a connector symbol. It connects various parts of a flow-chart which are far apart or spread over pages. (Subprocess symbol) (Subroutine) (Connector arrows) G (Terminal point) (Input/output) (Processing operation box) (Decision logic) (Connector point)
  • 19. 6 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A rectangle with double vertical sides is used to denote a subprocess which is given elsewhere as indicated by connector symbol. When this box is encountered, the flow goes to the subroutine and it continues till a ‘Return’ statement is encountered. Then it goes back to main flow-chart and flow resumes onward processing. The flow-chart can be translated into any computer language and can also be executed on the computer. PROGRAM. A computer does not have the capability of reading and understanding instructions written in a natural language like English. Thus, it is necessary to express the algorithm in a language understood by the computer. An algorithm coded in a computer language is called a program and the language used for coding is called a programming language. INSTRUCTION. A single operation to be executed by the computer is called an instruction. LOGIC. The science that deals with the canons and criteria of validity in thought and demonstration, or the science of the formal principles of reasoning is called logic. LOOP. A series of instructions or one instruction in a program that is repeated for a prescribed number of times, followed by a branch instruction that exits the program from the loop. COMPILER. A program designed to translate high level language (source program into machine language object program) is called a compiler. ASSEMBLER. A machine language program that converts all instructions into the binary format. LOADER. A program required on practically all systems that loads the user’s program along with required system routines into the central processor for execution. SYNTAX. The set of grammatical rules defining the structure of a programming language is called syntax. GARBAGE. An accumulation of unwanted, meaningless data after processing of any program is called Garbage. 1.3 INTRODUCTION TO “C” LANGUAGE In 1960, a number of computer languages had come into existence, among them COBOL and FORTRAN. A drawback of these languages was that they were
  • 20. INTRODUCTION 7 only suitable for specific purposes. There was a need for a single computer language that could cater to the needs of different applications uniformly and efficiently. This led to the formation of an International Committee to develop such a language. The result was a language called ALGOL 60. It did not become popular as it was too abstract and too general. Successive refinements on ALGOL 60 resulted in the birth of language CPL (combined programming language), BCPL, and ‘B’ language. These languages were again found to be either very big and exhaustive or less powerful. Finally, in 1972, ‘Dennis Ritchie’ developed the ‘C’ language at AT and T Bell Laboratories, USA. He inherited the features of ‘B’ and BCPL languages and added some of his own in development of ‘C’ language. Languages can be classified into two categories: (i) High level languages (Problem Oriented Languages). e.g.,— FORTRAN, BASIC, PASCAL, etc. (ii) Low level languages (Machine Oriented Languages). e.g.,—Assembly and machine language. ‘C’ language was designed to give both a relatively good programming efficiency and a relatively good machine efficiency. Hence ‘C’ is said to be a Middle level language as it stands between the above two categories. 1.4 ADVANTAGES/FEATURES OF ‘C’ LANGUAGE Following are some advantages of ‘C’ language: (i) Portability (ii) Suitable for low level programming (iii) Fewer Key words (iv) ‘C’ is a structured language (v) ‘C’ is a programmers language 1.5 ‘C’ CHARACTER SET “Character” denotes any alphabet, digit or special symbol used to represent information. The following table shows the valid alphabets, digits, and special symbols allowed in ‘C’; Alphabets: A, B, C, ......, Y, Z. a, b, c, ......, y, z.
  • 21. 8 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Digits: 0, 1, 2, ......, 8, 9. Special Symbols: ‘–’, ‘–’, + , = , /, , {}, [ ], < >,?. The alphabets, digits, and special symbol, when properly combined, form constants, variables, and keywords. 1.6 ‘C’ CONSTANTS A constant is a quantity that doesn’t change. ‘C’ constants can be divided into two major categories: (i) Primary constants (also called primary data types). (ii) Secondary constants (also called secondary data types). Primary constants can be of three types: (a) Integer constant (b) Real constant (c) Character constant. Secondary data types or constants are: (a) Array (b) Pointer (c) Structure (d) Union (e) Enum. ¾® ¾® ¾® ¾® ¾® ¾® ¾® ¾® ¾® ¾® ¾® ¾¾® ¾¾® ¾¾® ¾¾® ¾¾® ¾¾® ¾¾® Short signed Integer constant Short unsigned Long signed Primary constants Real Float or constant Primary data types Double Signed Character constant Unsigned ‘C’ constants Array Secondary Pointer constants or Structure Secondary data types Union Enum ¾® ¾® ¾® ¾® ¾®
  • 22. INTRODUCTION 9 1.6.1 Primary Data Types Data types Byte Range Format occupied (i) Signed character One – 128 to + 127 % C (ii) Unsigned character One 0 to 255 % C (iii) Short signed integer Two – 32768 to + 32767 % d (iv) Short unsigned integer Two 0 to 65535 % u (v) Long signed integer Four – 2147483648 to + 214748 3647 % l (vi) Float Four ± 3.4 e – 38 to ± 3.4 e + 38 % f (vii) Double Eight ± 1.7 e – 308 to ± 1.7 e + 308 % lf 1.7 “C” VARIABLES Suppose we want to find the average of three numbers. The three numbers are the input and the average is the output. Following are the tasks to be performed by the computer. 1. Read the three numbers. 2. Calculate the average. 3. Output the average. The computer actually works as follows: n Reads the three numbers and stores them in three locations of memory. n Adds the contents of the three locations and divides the result by 3. The result is stored in a fourth location. n The content of the fourth location is printed as output.
  • 23. 10 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES String variable Integer variables C Variables Real variables Floating point Double Integer Unsigned integer Short integer Long integer Unsigned character Signed character Character variable When numbers are stored in various locations of memory, it becomes necessary to name each of the memory locations. The name of the memory location is called variable. Memory locations may contain integer, real, or character constants. Depending upon the data contained in the memory location, the variables are classified as integer, real, character, and string variables. Secondary variables can be (a) Array variables (b) Pointer variables (c) Structure variables (d) Union variables (e) Enum variables. 1.8 ‘C’ KEY WORDS Key words (also called reserved words) are an integral part of a language. Their meanings are predefined and hence these words cannot be used as variable names. There are 32 key words in C language. 1.9 “C INSTRUCTIONS” The constants, variables, and key words are combined to form instructions. Basically, there are four types of instructions in ‘C’:
  • 24. INTRODUCTION 11 (a) Type declaration Instruction: e.g.: int bas_sal; float tot_sal; char name; (b) Arithmetic Instruction: e.g.: int a; float b, C; C = a * b; assignment operator. (c) Input/Output Instruction: e.g.: printf (‘‘<format string>’’,<list of variables>); <format string> could be % f — for real values % d — for integer values % C — for character values % S — for printing a string (sequence of character). (d) Control Instruction: Control Instructions specify the order in which the various instructions in a program are to be executed by the computer. They define the flow of control in a program. There are four types of Control Instructions in ‘C’ (i) Sequence Control Instruction (ii) Selection or Decision Control Instruction (iii) Repetition or Loop Control Instruction (iv) Case Control Instruction 1.10 HIERARCHY OF OPERATIONS The order or priority in which the arithmetic operations are performed in an arithmetic statement is called the hierarchy of operations. Hierarchy of operations is given below: Priority Operators 1. Parentheses—All parentheses are evaluated first 2. Multiplication and division 3. Addition and Subtraction.
  • 25. 12 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 1.11 ESCAPE SEQUENCES In ‘C’ the backslash symbol () is called an escape character. t — Tab n — New line character takes control to the next line b — Backspace character moves the cursor one position to the left of its current position. r — Carriage return character takes the cursor to the beginning of the line in which it is currently placed. a — Alert character alerts the user by sounding the speaker inside the computer. 1.12 BASIC STRUCTURE OF ‘‘C’’ PROGRAM A program is defined as a valid set of instructions which perform a given task. Each instruction in C program is written as a separate statement. However big a problem or program is, the following rules are applicable to all ‘C’ Statements: (a) Blank spaces may be inserted between two words to improve readability of the statement. (b) All statements are usually entered in small case letters. (c) C is free from language, i.e., there is no restriction on position of statements within the program. (d) A ‘C’ statement always ends with a semicolon (;). Any ‘C’ program is a combination of functions. Main( ) is one such function. Empty parentheses after main is a must. The set of statements belonging to a function is enclosed within a pair of braces. For example, main( ) { Statement 1; Statement 2; Statement 3; } Functions can be of two types: (i) Library functions or Built-in functions or intrinsic functions (ii) User defined functions. Library functions are those which are available as a part of ‘C’ language (C Compiler). These can be used by the programmers (users) directly to do a specific task. For example, the input/output operations are performed by a group as
  • 26. INTRODUCTION 13 functions which belong to a particular set. These sets are called header files in ‘C’. The header file is denoted by the file extension h. The following table shows some popular library functions. S. Functions Meaning Argument Value No. 1. sqrt (x) x float float 2. log (x) loge x float float 3. abs (x) | x | integer integer 4. fabs (x) | x | float float 5. exp (x) ex float float 6. pow (x, y) xy float float 7. ceil (x) Rounding x to next float float integer value 8. f mod (x, y) returns the remainder float float of x/y 9. rand ( ) generates a (+) ve — integer random integer 10. srand (v) to initialize the random Unsigned — number generator 11. sin (x) sin x float in radian measure float 12. cos (x) cos x ’’ ’’ 13. tan (x) tan x float in radian measure float 14. toascii (x) returns integer value to character integer integer particular character 15. tolower (x) To convert character ’’ character to lower case 16. toupper (x) To convert character character ’’ to upper case 1.12.1. Simple ‘C’ Program #include<stdio.h> /*program for average of three numbers*/ main( ) { int a, b, c, d; a = 2; b = 3;
  • 27. 14 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES c = 6; d = (a + b + c)/3; Printf(‘‘% d’’, d); } In the above C-program, the first line contains a reference to a header file. Since any standard program will have some i/o functions, the above statement appears as the first line in every C program. Library functions of stdio.h are scanf , printf, getchr, putchr, putc, puts. If we want to use certain mathematical functions then the header file math.h is included using statement #include <math.h> Library functions of math.h are cos, cosh, sin, sinh, tan, log, a cos, a sin, exp. The second line of the above program is a comment line. It can be anywhere in the program and any number of comment lines are allowed. This comment line improves the readability and helps the programmer to understand the program. The function name main( ) is written next. Function name is always followed by a set of parentheses. Arguments, if any, are placed within the parentheses. The opening brace and the closing brace indicate the beginning and end of the function. Next the variables are declared as integers. The declaration part must be written as the first part of the function. Next, a, b, c values are assigned and d is calculated. In the next line, d is printed using printf function. The basic rules for a program can be stated as follows: 1. Proper header file must be referred to. 2. There should be one and only one main function. 3. Contents of the function should be enclosed by opening and closing braces. 4. Variables must be declared first in the function. 5. Every C statement except the comment line headlines and function names in a function must end with a semicolon. 1.13 DECISION MAKING INSTRUCTIONS IN “C” The ability to make decisions regarding execution of the instructions in a ‘‘C’’ program is accomplished using decision control instructions. C has three major decision-making instructions:
  • 28. INTRODUCTION 15 (i) The if statement; (ii) The if-else statement; and (iii) The switch statement. (i) The if statement. The general form (syntax) of this statement is as follows: if (this condition is true) execute this statement; e.g.,: if (exp > 5) { bonus = 3000; printf (“% d”, bonus); } (ii) The if-else statement. The if statement executes a single statement or a group of statements if the condition following if is true. The ability to execute a group of statements if the condition is true and to execute another group of statements if the condition is false is provided by if-else statement. The general syntax of if-else is as follows: if (condition) statement 1; else statement 2; or if (condition) { statement 1; statement 2; } else { statement 1; statement 2; } The group of statements after the if, up to and not including the else, is called as if block. Similarly, the statements after the else form the else block. (iii) Decision using switch. The control structure which allows decisions to be made from a number of choices is called as switch or switch-case-default. These 3 keywords together make up the control structure.
  • 29. 16 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Syntax is as follows: Switch (integer expression) { case constant 1; do this; break; case constant 2: do this; break; default: do this; } The integer expression following the keyword switch in any C expression will yield an integer value. The keyword case is followed by an integer or a character constant. Each constant in each case must be different from all others. The break statement helps in getting out of the control structure. There is no need for a break statement after the default, since the control automatically comes out of the control structure as it is last. e.g.,: main( ) { int i = 6; switch (i) { case 1: printf (‘‘This is case 1’’); break; case 2: printf (‘‘This is case 2’’); break; default: printf (‘‘This is default’’); } } Points to Remember. (i) The cases need not be arranged in any specific order. (ii) It is allowed to use char values in case and switch. (iii) There may be no statements in some of the cases in switch, but they can still be useful. (iv) The switch statement is very useful while writing menu-driven programs. NOTE
  • 30. INTRODUCTION 17 1.14 LOOP CONTROL STRUCTURE The process of repeating some portion of the program either a specified number of times or until a particular condition is satisfied is called looping. Three methods of implementing a loop in ‘‘C’’ are: (a) using a for statement (b) using a while statement (c) using a do-while statement. (a) The for statement. It is the most popular loop control structure. General form is as below: for (initialize counter; test counter; increment counter). This control structure allows us to specify 3 things about a loop in a single line. (i) Setting a loop counter to an initial value. (ii) Testing the loop counter to determine whether its value has reached the number of repetitions desired. (iii) Increasing the value of the loop counter each time the program segment within the loop has been executed. e.g.,: for (i = 1; i < = 10; i = i + 1) | i = i + 1 may be written as i++ printf (“% d”, i); o/p = prints values from 1 to 10. (b) The while loop. General form is: initialize the loop counter; while (test of loop counter using a condition) { do this; : Body of while loop increment loop counter; } (i) The statement within the loop keep on getting executed as long as the condition being tested remains true. As soon as it becomes false, the control passes to the first statement that follows the body of the while loop. (ii) The condition being tested may use relational or logical operators. O Q PPP NOTE
  • 31. 18 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (iii) Instead of incrementing the loop counter, it can be decremented also. e.g.: int i = 4; while (i > = 1) { printf (“% d”, i); i = i – 1; } (iv) The loop counter need not be of int type, it can be of float type also. (c) The do-while loop. General form (syntax) do { this; and this; and this; } while (this condition is true); The difference between while and do-while is that the do-while executes its statements at least once even if the condition fails for the first time itself. The while loop, however, does not execute the statements even once if the condition is false. The break and continue keywords are usually associated with all three loops, i.e., for, while, and do-while. A break keyword inside the loop takes the control out of the loop, bypassing the conditional test. A continue keyword, on the other hand, takes the control to the conditional test. 1.15 ARRAYS AND STRING Arrays. An array is a collection of similar elements. These elements could all be ints, or all floats or all charcs, etc. However, there are situations in which it is required to store more than one value at a time in a single variable. e.g.,: if it is required to arrange the scores obtained by 100 students in a particular subject, then the two following methods can be used. (a) Construct 100 variables to store scores obtained by 100 students in a particular subject. or (b) Construct a single variable (called as a subscripted variable) capable of holding all 100 values of the students is a particular subject.
  • 32. INTRODUCTION 19 A subscripted variable is a collective name given to a group of similar quantities. e.g.,: scores = {20, 50, 60, 80} Array declaration. In order to use an array in the program, we need to declare it in order to tell the ‘C’ Compiler what type and size of array we want. e.g.,: int scores [100]; An array can be of more than one dimension. The two dimensional array is also called a Matrix. e.g.,: Scores [i] [J]; String. The character arrays are called strings. Character arrays or strings are the data types used by programming languages to manipulate text such as words or sentences. e.g., : Static character name [ ] = {‘A’, ‘S’, ‘H’, ‘I’, ‘o’}; Static character name [ ] = ‘‘ASHISH’’; (i) The length of the string entered while using scanf should not exceed the size of the character array. (ii) Scanf is not capable of receiving multiword strings. Hence, names such as ‘‘Mansi Choubey’’ would be unacceptable. In order to get around this limitation of scanf function, gets ( ) and puts ( ) functions are used. Syntax: gets (Name); puts (‘‘ Hello ! ”); 1.16 POINTERS When a variable is declared in a program, the compiler does three things (i) Reserves space in memory for this variable. (ii) Associates the name of the variable with the memory location. (iii) If some value is assigned to the variable, this value is stored at this location. It is possible to find the memory address of a variable using an “address of” (&) operator. If the integer variable i is stored in memory as follows: Memory Value Location name location (address) 1000 2 i NOTE
  • 33. 20 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES then its memory address can be printed using a printf statement as shown below: printf (‘‘Address of i = % d”, and i); Similarly, there is another operator called ‘value at address’ (*) operator which returns the value stored at a particular address. printf (“value of i = % d”, * (& i)); 1.17 STRUCTURE AND UNIONS Structures. A structure is a data type which facilitates storage of similar or dissimilar types of information about a particular entity. all information regarding an employee. struct employee { char name [10]; int code; char address [20]; char sex; }; The keyword struct is used to declare a structure data type. Union. In ‘C’, a union is a memory location that is shared by two or more different variables, generally of different types, at different times. Defining a union is similar to defining a structure. Its general form is; union union_name { type variable_name; type variable_name; : } union_variables; Example: union item { int i; char ch; };
  • 34. INTRODUCTION 21 Unions are useful when: (i) It is required to produce portable (machine independent) code. This is, because the compiler keeps track of actual sizes of the variables that make up the union, so no machine dependecies are produced. (ii) When type conversions are needed because we can refer to the data held in the union in different ways. 1.18 STORAGE CLASSES IN ‘C’ In order to fully define a variable, two things are required: (i) The type of the variable (ii) The storage class of the variable. There are four storage classes provided in ‘C’ (a) Automatic storage classes (b) Register storage classes (c) Static storage classes (d) Extern storage classes EXAMPLES Example 1. Draw a flow-chart to find real roots of the equation ax2 + bx + c = 0 Sol. We know that the roots of quadratic equation ax2 + bx + c = 0 are given by x1 = − + − b b ac a 2 4 2 and x2 = − − − b b ac a 2 4 2 or x1 = − + b d a 2 , x2 = − − b d a 2 , where d = b2 – 4ac.
  • 35. 22 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES START Read a, b, c Is a = 0 ? d = b – 4 ac 2 Is d < 0 ? No No x = (– b + )/2a 1 d x = (– b – )/2a 2 d Print x , x 1 2 Print x1 STOP Print roots are complex Is b = 0 ? No x = – 1 c b STOP Yes Yes Yes Flow-chart
  • 36. INTRODUCTION 23 Example 2. Develop a flow-chart to select the largest number of a given set of 100 numbers. Sol. START Read n Max = n Count = 1 Is count = 100 ? Yes 1 Read n No Is n > Max ? No Count = Count + 1 1 Max = n Print Max STOP Yes Example 3. Write an algorithm to find the real roots of the equation ax2 + bx + c = 0 ; a, b, c are real and a, b ≠ 0. Sol. We know that the roots of the equation ax2 + bx + c = 0
  • 37. 24 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES are x1 = − + b e a 2 , x2 = − − b e a 2 where e = b ac d 2 4 − = Algorithm is Step 1. Input a, b, c. Step 2. Calculate d = b2 – 4ac. Step 3. Check if d < 0. If yes, then print roots are complex, go to step 8. Step 4. Calculate e = d . Step 5. Calculate x1 = − + b e a 2 . Step 6. Calculate x2 = − − b e a 2 . Step 7. Print x1 and x2. Step 8. Stop. Example 4. Write an algorithm for converting a temperature from centigrade to Fahrenheit. Also write its program in ‘C’. Sol. For this problem, the centigrade is the input and Fahrenheit is the output. Let c be the variable name for centigrade and f be the variable name for Fahrenheit. The formula for converting temperature from centigrade to Fahrenheit is f = (9/5) * c + 32 So, the algorithm is 1. read c 2. f = (9/5) * c + 32 3. printf 4. end In the first section, we name the header file to be included. 1. # include<stdio.h> Then the function name is written as main( ) In the second section, the variables c and f are declared as floating point variables.
  • 38. INTRODUCTION 25 2. float c, f; In the third section, reading the values for c, calculating f and printing the value of f takes place. 3. scanf (“% f ”, & c); f = (9.0 /5.0) * c + 32.0; printf (“Fahrenheit = % f”, f); The complete program is given below: # include<stdio.h> main( ) { float c, f; scanf (“% f”, & c); f = (9.0/5.0) * c + 32.0; printf (“Fahrenheit = % f”, f); } The sample output is shown below: 40.0 Fahrenheit = 104.00. Example 5. Write a C program to determine the area of a triangle using the formula area = s(s a) (s b) (s c) − − − , where s = a b c 2 + + . Sol. The algorithm is 1. read a, b, c 2. s = a b c + + 2 3. area = sqrt (s * (s – a) * (s – b) * (s – c)) 4. print area 5. end. The program is given below # include<stdio.h> # include<math.h> main( )
  • 39. 26 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES { float a, b, c, s, area; printf (“Type the sides a, b, c”); scanf (“%f %f %f”, & a, & b, & c ); s = (a + b + c) /2.0; area = sqrt (s * (s – a) * (s – b) * (s – c)); printf (“Area = % f ”, area); } Following is a sample output Type the sides a, b, c 2.0 3.0 4.0 Area = 2.905. Example 6. Write a flow-chart to evaluate the sum of the series 1 + x + x2 + x3 + ..... + xn. Sol. START Read x, n Sum = 1 i < n i = 0 i = i + 1 Sum = Sum + x i Print Sum STOP False True
  • 40. INTRODUCTION 27 Example 7. Write a C-program to print all the Fibonacci numbers less than 50. Sol. The following are the Fibonacci numbers. 0, 1, 1, 2, 3, 5, 8, 13, ....... The first Fibonacci number is 0. The second Fibonacci number is 1. Any kth Fibonacci number = (k – 1)th Fibonacci number + (k – 2)th Fibonacci number The algorithm is 1. n0 = 0 2. n1 = 1 3. print n0, n1 4. n = n0 + n1 5. if n > = 50 stop 6. print n 7. n0 = n1 8. n1 = n 9. goto step 4. For this problem, there is no input. The C–program is given below: /* Program for Fibonacci Numbers */ # include<stdio.h> main( ) { int n, n0, n1; n0 = 0; n1 = 1; printf (‘‘% d t %d”, n0, n1); step 1: n = n1 + n0; if (n > = 50) goto end; else { print f (“ t % d”, n); n0 = n1; n1 = n; goto step 1;} end: printf (“ ”); } The sample output is 0 1 1 2 3 5 8 13 21 34
  • 41. 28 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 8. Write a C-program to (i) print integers from 1 to 10 (ii) print odd numbers from 1 to 10. Sol. (i) # include<stdio.h> main( ) { int i; for (i = 1; i < = 10; i + +) printf (‘‘% dt’’ , i); } The output will be 1 2 3 4 5 6 7 8 9 10 (ii) # include<stdio.h> main( ) { int i; for (i = 1; i < = 10; i + = 2) printf (“%dt”, i); } The output will be 1 3 5 7 9 ASSIGNMENT 1.1 1. Write a C-program to find the magnitude of a vector a = a1i + a2j + a3k. 2. State whether the following statements are correct or not: (i) scanf (‘‘Enter the value of A% d’’, a); (ii) scanf (“%d; %d, %d”, & a, & b, & c); 3. Write a C program to solve a set of linear equations with two variables a1x + b1y = c1 a2x + b2y = c2 L NMHint: Solution is x = b c b c a b a b 2 1 1 2 1 2 2 1 − − , y = a c a c a b a b 1 2 2 1 1 2 2 1 − − O QP. 4. Write a C-program to read the principal, rate of interest, and the number of years and find the simple interest using the formula Simple interest = PNR 100 5. Write a printf statement to print “The given value is 22.23.” 6. Give an algorithm and write a program in C to check whether a given number is prime or not.
  • 42. INTRODUCTION 29 7. What will be the value of x and the sum after the execution of the following program? x = 1; sum = 0; step 1: if (x < 10) { sum + = 1.0/x; x + = 1; goto step 1 } 8. Write a program in C to determine whether a number is odd or even. Also, draw its flow- chart. 9. Given a circle x2 + y2 = c, Write a C-program to determine whether a point (x, y) lies inside the circle, on the circle, or outside the circle. 10. Draw a flow-chart for adding marks of 5 subjects for a student and print the total. 11. Write a C-program to print the message CRICKET WORLD CUP-2007 six times. 12. Give any five library functions in “C”. 13. Write a program in C to print the following triangle of numbers 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 14. Write an algorithm for addition of two matrices of same order. 15. Write a C-program to find the multiplication of two square matrices each of order 2. 16. Write a C-program to find factorial of a given number. 17. Give a flow-chart for finding the determinant of a square non-singular matrix. 18. Write an algorithm for finding the inverse of a square non-singular matrix. 19. What is the maximum length allowed in defining a variable in “C”? 20. Write a C-program to find whether a year is leap year. 21. Develop a flow-chart to select the largest number of a given set of 500 numbers.
  • 44. Chapter 2 ERRORS 31 2.1 ERRORS AND THEIR ANALYSIS 2.1.1 Sources of Errors F ollowing are the broad sources of errors in numerical analysis: (1) Input errors. The input information is rarely exact since it comes from the experiments and any experiment can give results of only limited accuracy. Moreover, the quantity used can be represented in a computer for only a limited number of digits. (2) Algorithmic errors. If direct algorithms based on a finite sequence of operations are used, errors due to limited steps don’t amplify the existing errors, but if infinite algorithms are used, exact results are expected only after an infinite number of steps. As this cannot be done in practice, the algorithm has to be stopped after a finite number of steps and the results are not exact. (3) Computational errors. Even when elementary operations such as multiplication and division are used, the number of digits increases greatly so that the results cannot be held fully in a register available in a given computer. In such cases, a certain number of digits must be discarded. Furthermore, the errors here accumulate
  • 45. 32 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES one after another from operation to operation, changing during the process and producing new errors. The following diagram gives a schematic sequence for solving a problem using a digital computer pointing out the sources of errors. Errors Real problem Model Algorithm Program- ming Compu- tation Result Our effort will be to minimize these errors so as to get the best possible results. We begin by explaining the various kinds of errors and approximations that may occur in a problem and derive some results on error propagation in numerical calculations. 2.2 ACCURACY OF NUMBERS (1) Approximate numbers. There are two types of numbers: exact and approximate. Exact numbers are 2, 4, 9, 7 2 , 6.45, ...... etc. but there are numbers such that 4 3 (= 1.333 ......), 2 (= 1.414213 ...) and π (= 3.141592......) which cannot be expressed by a finite number of digits. These may be approximated by numbers 1.3333, 1.4141, and 3.1416, respectively. Such numbers, which represent the given numbers to a certain degree of accuracy, are called approximate numbers. (2) Significant digits. The digits used to express a number are called significant digits. The digits 1, 2, 3, 4, 5, 6, 7, 8, 9 are significant digits. ‘0’ is also a significant digit except when it is used to fix the decimal point or to fill the places of unknown or discarded digits. For example, each of the numbers 7845, 3.589, and 0.4758 contains 4 significant figures while the numbers 0.00386, 0.000587, 0.0000296 contain only three significant figures (since zeros only help to fix the position of the decimal point).
  • 46. ERRORS 33 Similarly, in the number 0.0003090, the first four ‘0’ s’ are not significant digits since they serve only to fix the position of the decimal point and indicate the place values of the other digits. The other two ‘0’ s’ are significant. To be more clear, the number 3.0686 contains five significant digits. A. The significant figure in a number in positional notation consists of (i) All non-zero digits (ii) Zero digits which (a) lie between significant digits; (b) lie to the right of decimal point and at the same time to the right of a non-zero digit; (c) are specifically indicated to be significant. B. The significant figure in a number written in scientific notation (e.g., M × 10k) consists of all the digits explicitly in M. Significant digits are counted from left to right starting with the non- zero digit on the left. A list is provided to help students understand how to calculate significant digits in a given number: Number Significant digits Number of significant digits 3969 3, 9, 6, 9 04 3060 3, 0, 6 03 3900 3, 9 02 39.69 3, 9, 6, 9 04 0.3969 3, 9, 6, 9 04 39.00 3, 9, 0, 0 04 0.00039 3, 9 02 0.00390 3, 9, 0 03 3.0069 3, 0, 0, 6, 9 05 3.9 × 106 3, 9 02 3.909 × 105 3, 9, 0, 9 04 6 × 10–2 6 01 NOTE
  • 47. 34 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (3) Rounding-off. There are numbers with many digits, e.g., 22 7 = 3.142857143. In practice, it is desirable to limit such numbers to a manageable number of digits, such as 3.14 or 3.143. This process of dropping unwanted digits is called rounding-off. Numbers are rounded-off according to the following rule: To round-off a number to n significant digits, discard all digits to the right of the nth digit and if this discarded number is (i) less than 5 in (n + 1)th place, leave the nth digit unaltered. e.g., 7.893 to 7.89. (ii) greater than 5 in (n + 1)th place, increase the nth digit by unity, e.g., 6.3456 to 6.346. (iii) exactly 5 in (n + 1)th place, increase the nth digit by unity if it is odd, otherwise leave it unchanged. e.g., 12.675 ~ 12.68 12.685 ~ 12.68 The number thus rounded-off is said to be correct to n significant figures. A list is provided for explanatory proposes: Number Rounded-off to Three digits Four digits Five digits 00.543241 00.543 00.5432 00.54324 39.5255 39.5 39.52 39.526 69.4155 69.4 69.42 69.416 00.667676 00.668 00.6677 00.66768 2.3 ERRORS Machine epsilon We know that a computer has a finite word length, so only a fixed number of digits is stored and used during computation. Hence, even in storing an exact decimal number in its converted form in the computer memory, an error is introduced. This error is machine dependant and is called machine epsilon. Error = True value – Approximate value
  • 48. ERRORS 35 In any numerical computation, we come across the following types of errors: (1) Inherent errors. Errors which are already present in the statement of a problem before its solution are called inherent errors. Such errors arise either due to the fact that the given data is approximate or due to limitations of mathematical tables, calculators, or the digital computer. Inherent errors can be minimized by taking better data or by using high precision* computing aids. Accuracy refers to the number of significant digits in a value, for example, 53.965 is accurate to 5 significant digits. Precision refers to the number of decimal positions or order of magnitude of the last digit in the value. For example, in 53.965, precision is 10–3. Example. Which of the following numbers has the greatest precision? 4.3201, 4.32, 4.320106. Sol. In 4.3201, precision is 10–4 In 4.32, precision is 10–2 In 4.320106, precision is 10–6. Hence, the number 4.320106 has the greatest precision. (2) Rounding errors. Rounding errors arise from the process of rounding- off numbers during the computation. They are also called procedual errors or numerical errors. Such errors are unavoidable in most of the calculations due to limitations of computing aids. These errors can be reduced, however, by (i) changing the calculation procedure so as to avoid subtraction of nearly equal numbers or division by a small number (ii) retaining at least one more significant digit at each step and rounding-off at the last step. Rounding-off may be executed in two ways: (a) Chopping. In chopping, extra digits are dropped by truncation of number. Suppose we are using a computer with a fixed word length of four digits, then a number like 12.92364 will be stored as 12.92. We can express the number 12.92364 in the floating print form as True x = 12.92364 = 0.1292364 × 102 = (0.1292 + 0.0000364) × 102 = 0.1292 × 102 + 0.364 × 10–4 + 2 = fx . 10E + gx . 10E – d = Approximate x + Error *Concept of accuracy and precision are closely related to significant digits.
  • 49. 36 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ Error = gx . 10E – d, 0 ≤ gx ≤ d Here, gx is the mantissa, d is the length of mantissa and E is exponent Since 0 ≤ gx < 1 ∴ Absolute error ≤ 10E – d Case I. If gx < 0.5 then approximate x = fx . 10E Case II. If gx ≥ .5 then approximate x = fx . 10E + 10E – d Error = True value – Approximate value = fx . 10E + gx . 10E – d – fx .10E – 10E – d = (gx – 1) . 10E – d absolute error ≤ 0.5.(10)E – d. (b) Symmetric round-off. In symmetric round-off, the last retained significant digit is rounded up by unity if the first discarded digit is ≥ 5, otherwise the last retained digit is unchanged. (3) Truncation errors Truncation errors are caused by using approximate results or by replacing an infinite process with a finite one. If we are using a decimal computer having a fixed word length of 4 digits, rounding-off of 13.658 gives 13.66, whereas truncation gives 13.65. e.g., If S = a x i i i = ∞ ∑1 is replaced by or truncated to S = a x i i n 1 ∑ , then the error developed is a truncation error. A truncation error is a type of algorithm error. Also, if ex = 1 + x + x x x 2 3 4 2 3 4 ! ! ! + + + ...... ∞ = X (say) is truncated to 1 + x + x x 2 3 2 3 ! ! + = X′ (say), then truncation error = X – X′ Example. Find the truncation error for ex at x = 1 5 if (i) The first three terms are retained in expansion. (ii) The first four terms are retained in expansion. Sol. (i) Error = True value – Approximate value = 1 2 3 1 2 2 3 2 + + + + F HG I KJ − + + F HG I KJ x x x x x ! ! ...... ! = + + + x x x 3 4 5 3 4 5 ! ! ! ......
  • 50. ERRORS 37 NOTE Put x = 1 5 error = .008 .00032 6 0016 24 120 + + . + ...... = .0013333 + .0000666 + .0000026 + ... = .0014025 (ii) Similarly the error for case II may be found. (4) Absolute error. Absolute error is the numerical difference between the true value of a quantity and its approximate value. Thus, if X is the true value of a quantity and X′ is its approximate value, then | X – X′ | is called the absolute error ea. ea = | X – X′ | = | Error | (5) Relative error. The relative error er is defined by er = |Error | True value X – X X = ′ where X is true value and X – X′ is error. (6) Percentage error. Percentage error ep is defined as ep = 100 er = 100 X – X X ′ . 1. The relative and percentage errors are independent of units used while absolute error is expressed in terms of these units. 2. If a number is correct to n decimal places, then the error = 1 2 (10–n). e.g., if the number 3.1416 is correct to 4 decimal places, then the error = 1 2 (10–4) = .00005. 3. If the first significant digit of a number is k and the number is correct to n significant digits, then the relative error < 1 (k 10 ) n 1 × − .
  • 51. 38 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES EXAMPLES Example 1. Suppose 1.414 is used as an approximation to 2 . Find the absolute and relative errors. Sol. True value = 2 = 1.41421356 Approximate value = 1.414 Error = True value – Approximate value = 2 – 1.414 = 1.41421356 – 1.414 = 0.00021356 Absolute error ea = | Error | = | 0.00021356 | = 0.21356 × 10–3 Relative error er = ea True value = 0 21356 10 2 3 . × − = 0.151 × 10–3. Example 2. If 0.333 is the approximate value of 1 3 , find the absolute, relative, and percentage errors. Sol.True value (X) = 1 3 Approximate value (X′) = 0.333 ∴ Absolute error ea = | X – X′ | = − = − 1 3 0 333 0 333333 0 333 . | . . | = .000333 Relative error er = ea X = = . . . 000333 333333 000999 Percentage error ep = er × 100 = .000999 × 100 = .099%. Example 3. An approximate value of π is given by 3.1428571 and its true value is 3.1415926. Find the absolute and relative errors. Sol. True value = 3.1415926 Approximate value = 3.1428571 Error = True value – Approximate value = 3.1415926 – 3.1428571 = – 0.0012645
  • 52. ERRORS 39 Absolute error ea = | Error | = 0.0012645 Relative error er = ea True value = 0.0012645 3.1415926 = 0.000402502. Example 4. Three approximate values of the number 1 3 are given as 0.30, 0.33, and 0.34. Which of these three is the best approximation? Sol. The best approximation will be the one which has the least absolute error. True value = 1 3 = 0.33333. Case I. Approximate value = 0.30 Absolute error = | True value – Approximate value | = | 0.33333 – 0.30 | = 0.03333 Case II. Approximate value = 0.33 Absolute error = | True value – Approximate value | = | 0.33333 – 0.33 | = 0.00333. Case III. Approximate value = 0.34 Absolute error = | True value – Approximate value | = | 0.33333 – 0.34 | = | – 0.00667 | = 0.00667 Since the absolute error is least in case II, 0.33 is the best approximation. Example 5. Find the relative error of the number 8.6 if both of its digits are correct. Sol. Here, ea = .05 ∵ ea = × F HG I KJ − 1 2 10 1 ∴ er = .05 8.6 = .0058. Example 6. Find the relative error if 2 3 is approximated to 0.667. Sol. True value = 2 3 = 0.666666 Approximate value = 0.667
  • 53. 40 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Absolute error ea = | True value – approximate value | = | .666666 – .667 | = .000334 Relative error er = .000334 .666666 .0005 = . Example 7. Find the percentage error if 625.483 is approximated to three significant figures. Sol. ea = | 625.483 – 625 | = 0.483 er = ea 625.483 625.483 = = .483 .000772 ∴ ep = er × 100 = .077%. Example 8. Round-off the numbers 865250 and 37.46235 to four significant figures and compute ea, er, ep in each case. Sol. (i) Number rounded-off to four significant digits = 865200 X = 865250 X′ = 865200 Error = X – X′ = 865250 – 865200 = 50 Absolute error ea = | error | = 50 Relative error er = ea X = 50 865250 = 5.77 × 10–5 Percentage error ep = er × 100 = 5.77 × 10–3 (ii) Number rounded-off to four significant digits = 37.46 X = 37.46235 X′ = 37.46 Error = X – X′ = 0.00235 Absolute error ea = | error | = 0.00235 Relative error er = ea X 0.00235 = 37.46235 = 6.2729 × 10–5 Percentage error ep = er × 100 = 6.2729 × 10–3.
  • 54. ERRORS 41 Example 9. Round-off the number 75462 to four significant digits and then calculate the absolute error and percentage error. Sol. Number rounded-off to four significant digits = 75460 Absolute error ea = | 75462 – 75460 | = 2 Relative error er = ea 75462 2 75462 = = .0000265 Percentage error ep = er × 100 = .00265. Example 10. Find the absolute, relative, and percentage errors if x is rounded- off to three decimal digits. Given x = 0.005998. Sol. Number rounded-off to three decimal digits =.006 Error = .005998 – .006 = – .000002 Absolute error ea = | error | = .000002 Relative error er = ea .005998 .000002 .005998 = = .0033344 Percentage error ep = er × 100 = .33344. Example 11. Evaluate the sum S = 3 5 7 + + to 4 significant digits and find its absolute and relative errors. Sol. 3 = 1.732, 5 = 2.236, 7 = 2.646 Hence, S = 6.614 and ea = .0005 + .0005 + .0005 = .0015. The total absolute error shows that the sum is correct to 3 significant figures only. ∴ We take, S = 6.61 then, er = .0015 6.61 = 0.0002. Example 12. It is necessary to obtain the roots of X2 – 2X + log10 2 = 0 to four decimal places. To what accuracy should log10 2 be given? Sol. Roots of X2 – 2X + log10 2 = 0 are given by X = 2 4 4 2 2 1 1 2 10 10 ± − = ± − log log ∴ | ΔX | = 1 2 2 1 2 Δ(log ) log − < 0.5 × 10–4 or Δ(log 2) < 2 × .5 × 10–4 (1 – log 2)1/2 < .83604 × 10–4 ≈ 8.3604 × 10–5.
  • 55. 42 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 2.1 1. Round-off the following numbers correct to four significant digits: 3.26425, 35.46735, 4985561, 0.70035, 0.00032217, 1.6583, 30.0567, 0.859378, 3.14159. 2. The height of an observation tower was estimated to be 47 m. whereas its actual height was 45 m. Calculate the percentage of relative error in the measurement. 3. If the number p is correct to three decimal places, what will be the error? 4. If true value = 10 3 , approximate value = 3.33, find the absolute and relative errors. 5. Round-off the following numbers to two decimal places. 48.21416, 2.3742, 52.275, 2.375, 2.385, 81.255. 6. Calculate the value of 102 101 − correct to four significant digits. 7. If X = 2.536, find the absolute error and relative error when (i) X is rounded-off (ii) X is truncated to two decimal digits. 8. If π = 22 7 is approximated as 3.14, find the absolute error, relative error, and percentage of relative error. 9. Given the solution of a problem as X′ = 35.25 with the relative error in the solution atmost 2%, find, to four decimal digits, the range of values within which the exact value of the solution must lie. 10. Given that: a = 10.00 ± 0.05, b = 0.0356 ± 0.0002 c = 15300 ± 100, d = 62000 ± 500 Find the maximum value of the absolute error in (i) a + b + c + d (ii) a + 5c – d (iii) d3. 11. What do you understand by machine epsilon of a computer? Explain. 12. What do you mean by truncation error? Explain with examples. 2 . 4 A GENERAL ERROR FORMULA Let y = f (x1, x2) be a function of two variables x1, x2. Let δx1, δx2 be the errors in x1, x2, then the error δy in y is given by y + δy = f(x1 + δx1, x2 + δx2)
  • 56. ERRORS 43 Expanding R.H.S. by Taylor’s series, we get y + δy = f(x1, x2) + ∂ ∂ + ∂ ∂ F HG I KJ f x x f x x 1 1 2 2 δ δ + terms involving higher powers of δx1 and δx2 (1) If the errors δx1, δx2 are so small that their squares and higher powers can be neglected, then (1) gives δy = ∂ ∂ + ∂ ∂ f x x f x x 1 1 2 2 δ δ approximately Hence, δy = ∂ ∂ + ∂ ∂ y x x y x x 1 1 2 2 δ δ In general, the error δy in the function y = f(x1, x2, ......, xn) corresponding to the errors δxi in xi (i = 1, 2, ......, n) is given by δy ≈ ∂ ∂ + ∂ ∂ + + ∂ ∂ y x x y x x y x x n n 1 1 2 2 δ δ δ ...... and the relative error in y is er = δ δ δ δ y y y x x y y x x y y x x y n n = ∂ ∂ + ∂ ∂ + + ∂ ∂ 1 1 2 2 . ...... . . 2.5 ERRORS IN NUMERICAL COMPUTATIONS (1) Error in addition of numbers Let X = x1 + x2 + ...... + xn ∴ X + ΔX = (x1 + Δx1) + (x2 + Δx2) + ...... + (xn + Δxn) The absolute error is ∴ ΔX = Δx1 + Δx2 + ...... + Δxn ⇒ Δ Δ Δ Δ X X X X X = + + + x x xn 1 2 ...... which is the relative error. The maximum relative error is Δ Δ Δ Δ X X X X X ≤ + + + x x xn 1 2 ...... .
  • 57. 44 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES It is clear that if two numbers are added then the magnitude of absolute error in the result is the sum of the magnitudes of the absolute errors in the two numbers. While adding up several numbers of different absolute accuracies, the following procedure is adopted: (i) Isolate the number with the greatest absolute error. (ii) Round-off all other numbers, retaining in them one digit more than in the isolated number. (iii) Add up. (iv) Round-off the sum by discarding one digit. (2) Error in subtraction of numbers Let X = x1 – x2 ∴ X + ΔX = (x1 + Δx1) – (x2 + Δx2) = (x1 – x2) + (Δx1 – Δx2) ∴ ΔX = Δx1 – Δx2 is the absolute error and Δ Δ Δ X X X X = − x x 1 2 is the relative error. The maximum relative error = Δ Δ Δ X X X X ≤ + x x 1 2 and The maximum absolute error = | ΔX | ≤ | Δx1 | + | Δx2 | . (3) Error in product of numbers Let X = x1 x2 ......, xn We know that if X is a function of x1, x2, ......, xn then, ΔX = ∂ ∂ + ∂ ∂ + + ∂ ∂ X X X x x x x x x n n 1 1 2 2 Δ Δ Δ ...... Now, Δ Δ Δ Δ X X X X X X X X = ∂ ∂ + ∂ ∂ + + ∂ ∂ 1 1 1 1 1 2 2 x x x x x x n n ...... NOTE
  • 58. ERRORS 45 Now, 1 1 1 2 3 1 2 3 1 X X ∂ ∂ = = x x x x x x x x x n n . ...... ...... 1 1 2 1 3 1 2 3 2 X X ∂ ∂ = = x x x x x x x x x n n ...... ...... 1 1 X X ∂ ∂ = x x n n ∴ Δ Δ Δ Δ X X = + + + x x x x x x n n 1 1 2 2 ...... . ∴ The relative and absolute errors are given by, Maximum relative error = Δ Δ Δ Δ X X ≤ + + + x x x x x x n n 1 1 2 2 ...... Maximum absolute error = Δ Δ X X X = X X . ( ...... ) x x x xn 1 2 3 (4) Error in division of numbers Let, X = x x 1 2 ∴ Δ Δ Δ X X X X X X = ∂ ∂ + ∂ ∂ 1 1 1 1 2 2 x x x x . . = Δ Δ Δ Δ x x x x x x x x x x x x x 1 1 2 2 2 1 2 1 2 2 1 1 2 2 1 F HG I KJ + F HG I KJ − F HG I KJ = − . ∴ Δ Δ Δ X X ≤ + x x x x 1 1 2 2 which is relative error. Absolute error = | ΔX | ≤ ΔX X . X.
  • 59. 46 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (5) Error in evaluating xk X = xk , where k is an integer or fraction ΔX = d dx X Δx = kxk – 1 . Δx Δ Δ X X = k x x . ∴ Δ Δ X X ≤ k x x . The relative error in evaluating xk = k . Δx x . 2 . 6 INVERSE PROBLEMS Now we have to find errors in x1, x2, ......, xn, where X = f(x1, x2, ....., xn), to have a desired accuracy. We have Δ Δ Δ Δ X X X X = ∂ ∂ + ∂ ∂ + + ∂ ∂ x x x x x x n n 1 1 2 2 ...... According to the principle of equal effects, ∂ ∂ = ∂ ∂ = = ∂ ∂ X X X x x x x x x n n 1 1 2 2 Δ Δ Δ ...... ∴ ΔX = n x x ∂ ∂ X 1 1 Δ ∴ Δx1 = ΔX X n x ∂ ∂ F HG I KJ 1 Similarly, Δx2 = ΔX X n x ∂ ∂ 2 and so on. The above article is needed when we are to find errors in both independent variables involved and error in dependent variable is given. NOTE
  • 60. ERRORS 47 EXAMPLES Example 1. If u = 4x y z 2 3 4 and errors in x, y, z be 0.001, compute the relative maximum error in u when x = y = z = 1. Sol. δu = ∂ ∂ + ∂ ∂ + ∂ ∂ u x x u y y u z z δ δ δ = 8 12 16 3 4 2 2 4 2 3 5 x y z x x y z y x y z z δ δ δ + − Since the errors δx, δy, δz may be (+) ve or (–) ve, we take the absolute values of terms on R.H.S. giving, (δu)max. = 8 12 16 3 4 2 2 4 2 3 5 xy z x x y z y x y z z δ δ δ + + = 8(.001) + 12(.001) + 16(.001) = 0.036 ∴ Maximum relative error = .036 4 = .009. Example 2. Find the relative error in the function y ax x ...... x 1 m 2 m n m 1 2 n = . Sol. We have log y = log a + m1 log x1 + m2 log x2 + ...... + mn log xn ∴ 1 1 1 1 1 2 2 2 y y x m x y y x m x ∂ ∂ F HG I KJ = = ∂ ∂ = , ...... etc. ∴ er = ∂ ∂ + ∂ ∂ + + ∂ ∂ y x x y y x x y y x x y n n 1 1 2 2 . . ...... . δ δ δ = + + + m x x m x x m x x n n n 1 1 1 2 2 2 δ δ δ ...... . Since errors δx1, δx2 may be (+) ve or (–) ve we take the absolute values of terms on R.H.S. This gives, (er)max. ≤ m1 δ δ δ x x m x x m x x n n n 1 1 2 2 2 + + + ...... .
  • 61. 48 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Corollary. If y = x1 x2 ......, xn e x x x x x x r n n ≈ + + + δ δ δ 1 1 2 2 ...... ∴ The relative error of a product of n numbers is approximately equal to the algebraic sum of their relative errors. Example 3. Compute the percentage error in the time period T = 2π l g for l = 1 m if the error in the measurement of l is 0.01. Sol. T = 2π l g Taking log log T = log 2π + 1 2 1 2 log log l g − ⇒ 1 1 2 T T = δ δl l δ δ T T 0.5% × = × = × × = 100 2 100 01 2 1 100 l l . . Example 4. If u = 2 V6 – 5V, find the percentage error in u at V = 1 if error in V is .05. Sol. u = 2V6 – 5V δu = ∂ ∂ u V V δ = (12 V5 – 5) δV δ δ u u × = − − F HG I KJ × 100 12 5 2 5 V V V V 100 5 6 . = ( ) ( ) (. ) 12 5 2 5 05 100 − − × × = − 7 3 × 5 = – 11.667% The maximum percentage error = 11.667%. Example 5. If r = 3h(h6 – 2), find the percentage error in r at h = 1, if the percentage error in h is 5. Sol. δr = ∂ ∂ r h h δ = (21h6 – 6) δh
  • 62. ERRORS 49 δ δ r r h h h h × = − − F HG I KJ × 100 21 6 3 6 100 6 7 = 21 6 3 6 100 15 3 5% − − F HG I KJ × F HG I KJ = − δh h ( ) . = – 25% Percentage error = δr r × = 100 25%. Example 6. The discharge Q over a notch for head H is calculated by the formula Q = kH5/2, where k is a given constant. If the head is 75 cm and an error of 0.15 cm is possible in its measurement, estimate the percentage error in computing the discharge. Sol. Q = kH5/2 log Q = log k + 5 2 log H Differentiating, δ δ Q Q H H = 5 2 . δQ Q .15 75 × = × × = = 100 5 2 0 100 1 2 0 5 . . Example 7. The error in the measurement of the area of a circle is not allowed to exceed 0.1%. How accurately should the diameter be measured? Sol. A = π d2 4 log A = log π + 2 log d – log 4 δ δ A A × = × 100 2 100 d d ( ) δd d × = = 100 0.1 2 .05. Example 8. (i) Prove that the absolute error in the common logarithm of a number is less than half the relative error of the given number. (ii) Prove that the error in the antilogarithm is many times the error in the logarithm. Sol. (i) N = log10 x = .43429 loge x Hence, ΔN = 0.43429 Δ Δ x x x x F HG I KJ 1 2 .
  • 63. 50 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (ii) From (i), Δx = xΔN 0.43429 = 2.3026 x(ΔN). Example 9. Find the smaller root of the equation x2 – 32x + 1 = 0 correct to four significant figures. Sol. The roots of the equation x2 – 32x + 1 = 0 are 32 32 4 2 2 − − ( ) and 32 32 4 2 2 + − ( ) The smaller root is 32 1020 2 16 255 − = − I Algorithm. Smaller root = 16 255 − = 16 – 15.97 = 0.03 II Algorithm. Smaller root = ( ) . . . 16 255 16 255 16 255 1 16 15 97 1 31.97 0 0313 − + + = + = = The second algorithm is evidently a better one, as gives the result correct to 4 figures. Example 10. If X = x + e, prove that X x e 2 X − ≈ . Sol. X X X X X X − = − − = − − F HG I KJ x e e 1 1/2 = X X X − − F HG I KJ 1 2 e = X X X X – + ≈ e e 2 2 . Example 11. In a ΔABC, a = 6 cm, c = 15 cm, ∠B = 90°. Find the possible error in the computed value of A if the errors in measurements of a and c are 1 mm and 2 mm respectively. Sol. Here, tan A = a c ∴ A = tan–1 a c F HG I KJ δA = ∂ ∂ + ∂ ∂ A A a a c c δ δ = c a c a a a c c 2 2 2 2 + − + δ δ
  • 64. ERRORS 51 or | . . δ δ δ A|≤ + + + c a c a a a c c 2 2 2 2 = 15 261 . (0.1) 6 261 . (0.2) + = .0103 radians ∴ δA ≤ .0103 radians. Example 12. In a ΔABC, a = 30 cm, b = 80 cm, ∠B = 90°, find the maximum error in the computed value of A if possible errors in a and b are 1 3 % and 1 4 %, respectively. Sol. sin A = a b ⇒ A = sin–1 a b F HG I KJ |δ δ δ A| A A ∂ ∂ + ∂ ∂ a a b b (2) Here, δa a × = 100 1 3 ∴ δa = 0.1 δb b × = 100 1 4 ∴ δb = 0.2 ∴ ∂ ∂ = − A a b a 1 2 2 , ∂ ∂ = − − A b a b b a 2 2 Substituting in (2), we get δA .00135 + .00100 .00235. Example 13. The approximate values of 1 7 and 1 11 correct to 4 decimal places are 0.1429 and 0.0909, respectively. Find the possible relative error and absolute error in the sum of .1429 and .0909. Sol. Numbers 0.1429 and 0.0909 are correct to four places of decimal. The maximum error in each case is 1 2 × .0001 = 0.00005. (i) Relative error | | | | | | . . . . Δ Δ Δ X| |X| |X| X| 1 2 + + x x 0 00005 0 2338 0 00005 0 2338 (∵ X = x1 + x2) ΔX X 0.0001 0.2338 .00043 = .
  • 65. 52 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (ii) Absolute error ΔX = Δx1 + Δx2 = 0.00005 + 0.00005 = 0.0001. Example 14. The approximate values of 1 7 and 1 15 , correct to four decimal places, are 0.1429 and 0.0667 respectively. Find the relative error for the sum of 0.1429 and 0.0667. Sol. ΔX X 0.0001 0.2096 0.000477 = . Example 15. 29 = 5.385 and 11 = 3.317 are correct to four significant figures. Find the relative error in their sum and difference. Sol. Numbers 5.385 and 3.317 are correct to four significant figures ∴ The maximum error in each case is 1 2 × 10–3 = 0.0005 ∴ Δx1 = Δx2 = 0.0005 The relative error in their sum is Δ Δ Δ X X X X 1 ≤ + x x2 | ∵ X = x1 + x2 = 8.702 ≤ + × − 0 0005 8 702 0 0005 8 702 149 10 4 . . . . 1. The relative error in their difference is Δ Δ Δ X X X X ≤ + x x 1 2 , where X = x1 – x2 = 2.068 ≤ + × − 0 0005 2 068 0 0005 2 068 4 835 10 4 . . . . . . Example 16. Sum the following numbers: 0.1532, 15.45, 0.000354, 305.1, 8.12, 143.3, 0.0212, 0.643, and 0.1734, where digits are correct. Sol. 305.1 and 143.3 have the greatest absolute error of .05 in each. Rounding-off all other numbers to two decimal digits, we have 0.15, 15.45, 0.00, 8.12, 0.02, 0.64, and 0.17. The sum S is given by S = 305.1 + 143.3 + 0.15 + 15.45 + 0.00 + 8.12 + 0.02 + 0.64 + 0.17 = 472.59 = 472.6.
  • 66. ERRORS 53 To determine the absolute error, we note that the first two numbers have absolute errors of 0.05 and the remaining seven numbers have absolute errors of 0.005 each. ∴ The absolute error in all 9 numbers = 2(0.05) + 7(0.005) = 0.1 + 0.035 = 0.135 ≈ 0.14. In addition to the above absolute error, we have to take into account the rounding error, which is 0.01. Hence the total absolute error in S = 0.14 + 0.01 = 0.15 Thus, S = 472.6 ± 0.15. Example 17. 5.5 = 2.345 and 6.1 = 2.470 correct to four significant figures. Find the relative error in taking the difference of these numbers. Sol. The maximum error in each case = 1 2 × 0.001 = 0.0005 ∴ The relative error Δ Δ x x 1 2 X X + = = F HG I KJ = 2 2 0 0005 0 0 008 1 Δx X .125 . . . Example 18. 10 = 3.162 and e ~ – 2.718 correct to three decimal places. Find the percentage error in their difference. Sol. Relative error = 2 × 0 0005 3 2 718 0 001 444 . ( . ) . . .162 − = ∴ Percentage error = × 0.001 100 0.23 .444 . Example 19. Find the product of 346.1 and 865.2. State how many figures of the result are trustworthy, given that the numbers are correct to four significant figures. Sol. Δx1 = 0.05, Δx2 = 0.05 X = 346.1 × 865.2 = 299446 (correct to 6 digits) Maximum relative error (er) ≤ Δ Δ x x x x 1 1 2 2 + = 0 05 346.1 0 05 865 2 . . . + = 0.000144 + 0.000058 = 0.000202 ∴ Absolute error = er . X = 0.000202 × 299446 ~ – 60
  • 67. 54 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ The true value of the product of the numbers given lies between 299446 – 60 = 299386 and 299446 + 60 = 299506. The mean of these values is 299386 299506 2 + = 299446 which is 299.4 × 103, correct to four significant digits. There is some uncertainty about the last digit. Example 20. Two numbers are given as 2.5 and 48.289, both of which are correct to the significant figures given. Find their product. Sol. 2.5 is the number with the greatest absolute error. Rounding-off the other number to three significant digits, we get 48.3. Their product is given by, P = 48.3 × 2.5 = 120.75 = 1.2 × 102 where, we have retained only two significant digits. Example 21. Find the relative error in calculation of 7.342 0.241 . Numbers are correct to three decimal places. Determine the smallest interval in which true result lies. Sol. Δx1 = Δx2 = 0.0005 Relative error ≤ 0 0005 7 0 0005 0 . . .342 .241 + ≤ + F HG I KJ 0 0005 1 7 1 . .342 .241 = 0.0021 Absolute error = 0.0021 × x x 1 2 0 0021 7 0 0639 = × = . . .342 0.241 Now, x x 1 2 = 7.342 0.241 = 30.4647 ∴ The true value of x1/x2 lies between 30.4647 – 0.0639 = 30.4008 and 30.5286. Example 22. Find the number of trustworthy figures in (0.491)3, assuming that the number 0.491 is correct to the last figure. Sol. Relative error er = k Δ x x = 3 . 0.0005 0.491 = 0.003054989
  • 68. ERRORS 55 Absolute error er . X = (0.003054989) . (0.491)3 = 0.000361621 The error affects the fourth decimal place, therefore X is correct to three decimal places. Example 23. If R = 1 2 r h h 2 + F HG I KJ and the error in R is at the most 0.4%, find the percentage error allowable in r and h when r = 5.1 cm and h = 5.8 cm. Sol. Percentage error in R = ΔR R × 100 = 0.4 ∴ ΔR = 0 100 .4 R × = 0 4 100 1 2 5 5 8 0 0206 2 . ( ) . . × + L NM O QP= .1 5.8 (i) Percentage error in r = Δr r × 100 = 1 r . ΔR r 2 R ∂ ∂ F H GG I K JJ × 100 ∵ 2 2 ∂ ∂ R r r h = = F HG I KJ = 100 50 2 r r h h r . Δ Δ R 2 R = 50 5.8 (5.1)2 × × = 0 0206 0 22968% . . (ii) Percentage error in h = Δh h × 100 = 100 100 2 2 1 2 2 2 h h h r h × ∂ ∂ F HG I KJ = − + L NM O QP Δ Δ R 2 R R . = 100 1 100 5 0 0206 0 773186 1 2 2 h r h . . ( . ) ΔR .8 − + F HG I KJ = × − + = 2. 5.8 0.2268 1. 06 5659% × = .
  • 69. 56 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 24. Calculate the value of x – x cos θ correct to three significant figures if x = 10.2 cm, and θ = 5°. Find permissible errors also in x and θ. Sol. θ = 5° = 5 180 11 126 π = radian 1 – cos θ = 1 – 1 2 4 2 4 − + L NM O QP θ θ ! ! – ...... = θ θ 2 4 2 4 2 4 1 2 11 126 1 24 11 126 ! ! ...... ...... − + = F HG I KJ − F HG I KJ + = 0.0038107 – 0.0000024 ~ _ 0.0038083 ∴ X = x(1 – cos θ) = 10.2 (0.0038083) = 0.0388446 ~ 0.0388 Further, Δx = ΔX X 2 0 0005 2 0 0038083 0 0656 ∂ ∂ F HG I KJ = × x . . ~ – . Δθ = ΔX X 2 0 0005 2 0 0005 2 10 2 0 0871907 ∂ ∂θ F HG I KJ = = × × . sin . . . x θ where sin θ = θ θ − + = − F HG I KJ + = 3 3 3 11 126 1 6 11 126 0 0871907 ! ...... ...... . ∴ Δθ = 0 0005 20 4 0 0871907 0 0002809 0 00028 . . . ~ – . ~ – . × . 2.7. ERROR IN A SERIES APPROXIMATION The error committed in a series approximation can be evaluated by using the remainder after n terms. Taylor’s series for f(x) at x = a is given by f(x) = f(a) + (x – a) f ′(a) + ( ) ! x a − 2 2 f ″(a) + ...... + ( ) ( ) ! ( ) ( ) ( ) x a n f a x n n n − − + − − 1 1 1 R where Rn(x) = ( ) ! ( ) ( ) x a n f n n − ξ ; a ξ x.
  • 70. ERRORS 57 For a convergent series, Rn(x) → 0 as n → ∞. If we approximate f(x) first by n terms of series, then by maximum error committed, we get Rn(x). If the accuracy required is specified in advance, it would be possible to find n, the number of terms such that the finite series yields the required accuracy. EXAMPLES Example 1. Find the number of terms of the exponential series such that their sum gives the value of ex correct to six decimal places at x = 1. Sol. ex = 1 + x + x x x n x n n 2 3 1 2 3 1 ! ! ...... ( ) ! ( ) + + + − + − R (3) where Rn(x) = x n n ! eθ, 0 θ x Maximum absolute error (at θ = x) = x n e n x ! and Maximum relative error = x n n ! Hence, (er)max. at x = 1 is = 1 n ! For a six decimal accuracy at x = 1, we have 1 1 2 10 6 n ! × − i.e., n ! 2 × 106 which gives n = 10. Hence we need 10 terms of series (3) to ensure that its sum is correct to 6 decimal places. Example 2. Use the series log 1 x 1 x 2 x x 3 x 5 ...... e 3 5 + − F HG I KJ = + + + F HG I KJ to compute the value of log (1.2) correct to seven decimal places and find the number of terms retained. Sol. loge 1 1 2 3 5 2 1 3 5 2 1 + x x x x x x n n − F HG I KJ = + + + + − F HG I KJ − ... + Rn(x)
  • 71. 58 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES If we retain n terms, then Rn(x) = 2 2 1 1 1 2 1 x n n e + + + − F HG I KJ log ξ ξ ; 0 ξ x Maximum absolute error (at ξ = x) = 2 2 1 1 1 2 1 x n x x n e + + + − F HG I KJ log and maximum relative error = 2 2 1 n + x2n+1 Let 1 1 + − x x = 1.2 ⇒ x = 1 11 Hence (er)max. at x = 1 11 is 2 2 1 1 11 2 1 n n + F HG I KJ + . For seven decimal accuracy, 2 2 1 1 11 1 2 10 2 1 7 n n + F HG I KJ × + − . (2n + 1) (11)2n + 1 4 × 107 which gives n ≥ 3. Hence, retaining the first three terms of the given series, we get loge (1.2) = 2 3 5 3 5 x x x + + F HG I KJ at x = F HG I KJ 1 11 = 0.1823215 . Example 3. The function f(x) = tan–1x can be expanded as tan–1x = x x 3 x 5 ...... ( 1) . x 2n 1 3 5 n 1 2n 1 − + − + − − − − + ...... Find n such that the series determines tan–1(1) correct to eight significant digits. Sol. If we retain n terms, then (n + 1)th term = (– 1)n . x n n 2 1 2 1 + + For x = 1, (n + 1)th term = ( ) − + 1 2 1 n n
  • 72. ERRORS 59 For the determination of tan–1 (1) correct up to eight significant digit accuracy, ( ) − + × − 1 2 1 1 2 10 8 n n ⇒ 2n + 1 2 × 108 such as n = 108 + 1. Example 4. The function f(x) = cos x can be expanded as cos x = 1 – x 2 ! x 4 ! x 6 ! 2 4 6 + − + ... Compute the number of terms required to estimate cos π 4 F HG I KJ so that the result is correct to at least two significant digits. Sol. cos x = 1 – x x x 2 4 6 2 4 6 ! ! ! + − + ... + Rn(x) where Rn(x) = (– 1)n x n n 2 2 ! cos ξ; 0 ξ x Maximum absolute error (at ξ = x) = ( ) ( )! cos −1 2 2 n n x n x = x n n 2 2 ( )! cos x Maximum relative error = x n n 2 2 ( )! At x = π 4 , (er)max. = ( / ) ( ) ! π 4 2 2n n For two significant digit accuracy, ( / ) ( ) ! π 4 2 1 2 2n n ≤ × 10–2 i.e., ( ) ! ( / ) 2 4 2 n n π ≥ 200 n = 3 satisfies it.
  • 73. 60 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 2.2 1. If R = 4xy2z–3 and errors in x, y, z be 0.001, show that the maximum relative error at x = y = z = 1 is 0.006. 2. If R = 10x3y2z2 and errors in x, y, z are 0.03, 0.01, 0.02 respectively at x = 3, y = 1, z = 2. Calculate the absolute error and percentage relative error in evaluating R. 3. If R = 4x2y3z–4, find the maximum absolute error and maximum relative error in R when errors in x = 1, y = 2, z = 3, respectively, are equal to 0.001, 0.002, 0.003. 4. If u = 5 2 3 xy z and errors in x, y, z are 0.001 at x = 1, y = 1, z = 1, calculate the maximum relative error in evaluating u. 5. Find the number of terms of the exponential series such that their sum yields the value of ex correct to 8 decimal places at x = 1. 6. Find the product of the numbers 56.54 and 12.4, both of which are correct to the significant digits given. 7. Find the quotient q = x y , where x = 4.536 and y = 1.32; both x and y being correct to the digits given. Find also the relative error in the result. 8. Write a short note on error in a series approximation. 9. Explain the procedure of adding several numbers of different absolute accuracies. 10. Find the smaller root of the equation x2 – 30x + 1 = 0 correct to three decimal places. State different algorithms. Which algorithm is better and why? 11. Write a short note on Errors in numerical computation. 2.8 MATHEMATICAL PRELIMINARIES Following are certain mathematical results which would be useful in the sequel. Theorem 1. If f(x) is continuous in a ≤ x ≤ b and if f(a) and f(b) are of opposite signs then f(c) = 0 for at least one number c such that a c b. Theorem 2. Rolle’s theorem. If (i) f(x) in continuous in [a, b] (ii) f ′(x) exists in (a, b) (iii) f(a) = f(b) = 0. then ∃ at least one value of x, say c, such that f ′(c) = 0, a c b.
  • 74. ERRORS 61 Theorem 3. Mean value theorem for derivatives. If (i) f(x) is continuous in [a, b] (ii) f ′(x) exists in (a, b) then, ∃ at least one value of x, say c, between a and b such that f ′(c) = f b f a b a ( ) ( ) − − , a c b. Theorem 4. Taylor’s series for a function of one variable. If f(x) is continuous and possesses continuous derivatives of order n in an interval that includes x = a, then in that interval f(x) = f(a) + (x – a) f ′(a) + ( ) ! x a − 2 2 f ″(a) + ...... + ( ) ( ) ! ( ) ( ) ( ) x a n f a x n n n − − + − − 1 1 1 R where Rn(x) is remainder term, can be expressed in the form Rn(x) = ( ) ! ( ) x a n f c n n − , a c x. Theorem 5. Maclaurin’s expansion. f(x) = f(0) + x f ′(0) + x f x n f n n 2 2 0 0 ! ( ) ...... ! ( ) ...... ( ) ″ + + + Theorem 6. Taylor’s series for a function of two variables. f(x1 + Δx1, x2 + Δx2) = f(x1, x2) + ∂ ∂ + ∂ ∂ f x x f x x 1 1 2 2 Δ Δ + 1 2 2 2 1 2 1 2 2 1 2 1 2 2 2 2 2 2 ∂ ∂ + ∂ ∂ ∂ + ∂ ∂ L NMM O QPP f x x f x x x x f x x ( ) . ( ) Δ Δ Δ Δ + ...... 2.9 FLOATING POINT REPRESENTATION OF NUMBERS There are two types of arithmetic operations available in a computer. They are: (i) Integer arithmetic (ii) Real or floating point arithmetic. Integer arithmetic deals with integer operands and is used mainly in counting and as subscripts. Real arithmetic uses numbers with fractional parts as operands and is used in most computations. Computers are usually designed such that each location, called word, in memory stores only a finite number of digits. Consequently, all operands in arithmetic operations have only a finite number of digits.
  • 75. 62 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Let us assume a hypothetical computer having memory in which each location can store 6 digits and having provision to store one or more signs. One method of representing real numbers in that computer would be to assume a fixed position for the decimal point and store all numbers after appropriate shifting if necessary with an assumed decimal point. 5 6 5 2 3 1 assumed decimal point position + One memory location or word sign A memory location storing number 5652.31 In such a convention, the maximum and minimum possible numbers to be stored are 9999.99 and 0000.01, respectively, in magnitude. This range is quite inadequate in practice. For this, a new convention is adopted that aims to preserve the maximum number of significant digits in a real number and also increase the range of values of real numbers stored. This representation is called the normalized floating point mode of representing and storing real numbers. In this mode, a real number is expressed as a combination of a mantissa and an exponent. The mantissa is made less than 1 or ≥ .1 and the exponent is the power of 10 which multiplies the mantissa. For example, the number 43.76 × 106 is represented in this notation as .4376 E 8, where E 8 is used to represent 108. The mantissa is .4376 and the exponent is 8. The number is stored in memory location as: 4 3 7 6 0 8 + + sign of exponent sign of mantissa mantissa exponent implied decimal point . Moreover, the shifting of the mantissa to the left until its most significant digit is non-zero is called normalization. For example, the number .006831 may be stored as .6831 E–2 because the leading zeros serve only to locate the decimal point.
  • 76. ERRORS 63 The range of numbers that may be stored is .9999 × 1099 to .1000 × 10–99 in magnitude, which is obviously much larger than that used earlier in fixed decimal point notation. This increment in range has been obtained by reducing the number of significant digits in a number by 2. 2.10 ARITHMETIC OPERATIONS WITH NORMALIZED FLOATING POINT NUMBERS 2.10.1 Addition and Subtraction If two numbers represented in normalized floating point notation are to be added, the exponents of the two numbers must be made equal and the Mantissa shifted appropriately. The operation of subtraction is nothing but the addition of a negative number. Thus the principles are the same. EXAMPLES Example 1. Add the following floating point numbers: (i) .4546 E 5 and .5433 E 5 (ii) .4546 E 5 and .5433 E 7 (iii) .4546 E 3 and .5433 E 7 (iv) .6434 E 3 and .4845 E 3 (v) .6434 E 99 and .4845 E 99. Sol. (i) Here the exponents are equal ∴ Mantissas are added ∴ Sum = .9979 E 5 (ii) Here exponents are not equal. The operand with the larger exponent is kept as it is .5433 E 7 + .0045 E 7 | .4546 E 5 = .0045 E 7 .5478 E 7 (iii) The addition will be as follows: .5433 E 7 + .0000 E 7 | ∵ .4546 E 3 = .0000 E 7 .5433 E 7
  • 77. 64 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (iv) The exponents are equal but when the mantissas are added, the sum is 1.1279 E 3. As the mantissa has 5 digits and is 1, it is shifted right one place before it is stored. Hence Sum = .1127 E 4 (v) Here, again the sum of the mantissas exceeds 1. The mantissa is shifted right and the exponent increased by 1, resulting in a value of 100 for the exponent. The exponent part cannot store more than two digits. This condition is called an overflow condition and the arithmetic unit will intimate an error condition. Example 2. Subtract the following floating point numbers: (i) .9432 E – 4 from .5452 E – 3 (ii) .5424 E 3 from .5452 E 3 (iii) .5424E – 99 from .5452 E – 99. Sol. (i) .5452 E – 3 – .0943 E – 3 .4509 E – 3 (ii) .5452 E 3 – .5424 E 3 .0028 E 3 In a normalized floating point, the mantissa is ≥ .1 Hence, the result is .28 E 1 (iii) .5452 E – 99 – .5424 E – 99 .0028 E – 99 For normalization, the mantissa is shifted left and the exponent is reduced by 1. The exponent would thus become – 100 with the first left shift, which can not be accommodated in the exponent part of the number. This condition is called an underflow condition and the arithmetic unit will signal an error condition. If the result of an arithmetic operation gives a number smaller than .1000 E – 99 then it is called an underflow condition. Similarly, any result greater than .9999 E 99 leads to an overflow condition. NOTE
  • 78. ERRORS 65 Example 3. In normalized floating point mode, carry out the following mathematical operations: (i) (.4546 E 3) + (.5454 E 8) (ii) (.9432 E – 4) – (.6353 E – 5). Sol. (i) .5454 E 8 + .0000 E 8 | ∵ .4546 E 3 = .0000 E 8 .5454 E 8 (ii) .9432 E – 4 – .0635 E – 4 | ∵ .6353 E – 5 = .0635 E – 4 .8797 E – 4 2.10.2 Multiplication Two numbers are multiplied in the normalized floating point mode by multiplying the mantissas and adding the exponents. After the multiplication of the mantissas, the resulting mantissa is normalized as in an addition or subtraction operation, and the exponent is appropriately adjusted. EXAMPLES Example 1. Multiply the following floating point numbers: (i) .5543 E 12 and .4111 E – 15 (ii) .1111 E 10 and .1234 E 15 (iii) .1111 E 51 and .4444 E 50 (iv) .1234 E – 49 and .1111 E – 54. Sol. (i) .5543 E 12 × .4111 E – 15 = .2278 E – 3 (ii) .1111 E 10 × .1234 E 15 = .1370 E 24 (iii) .1111 E 51 × .4444 E 50 = .4937 E 100 The result overflows. (iv) .1234 E – 49 × .1111 E – 54 = .1370 E – 104 The result underflows. Example 2. Apply the procedure for the following multiplications: (.5334 × 109) * (.1132 × 10–25) (.1111 × 1074) * (.2000 × 1080) Indicate if the result is overflow or underflow. Sol. (i) .5334 E 9 × .1132 E – 25 = .6038 E – 17 (ii) .1111 E 74 × .2000 E 80 = .2222 E 153 Hence the above result overflows.
  • 79. 66 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 2.10.3 Division In division, the mantissa of the numerator is divided by that of the denominator. The denominator exponent is subtracted from the numerator exponent. The quotient mantissa is normalized to make the most significant digit non-zero and the exponent is appropriately adjusted. The mantissa of the result is chopped down to 4 digits. EXAMPLES Example 1. Perform the following operations: (i) .9998 E 1 ÷ .1000 E – 99 (ii) .9998 E – 5 ÷ .1000 E 98 (iii) .1000 E 5 ÷ .9999 E 3. Sol. (i) .9998 E 1 ÷ .1000 E – 99 = .9998 E 101 Hence the result overflows. (ii) .9998 E – 5 ÷ .1000 E 98 = .9998 E – 104 Hence the result underflows. (iii) .1000 E 5 ÷ .9999 E 3 = .1000 E 2. Example 2. Evaluate, applying normalized floating point arithmetic, for the following: 1 – cos x at x = .1396 radian Assume cos (.1396) = .9903 Compare it when evaluated 2 sin2 x 2 Assume sin .0698 = .6974 E – 1. Sol. 1 – cos (.1396) = .1000 E 1 – .9903 E 0 = .1000 E 1 – .0990 E 1 = .1000 E – 1 Now, sin x 2 = sin (.0698) = .6974 E – 1 2 sin2 x 2 = (.2000 E 1) × (.6974 E – 1) × (.6974 E – 1) = .9727 E – 2 The value obtained by the alternate formula is closer to the true value .9728 E – 2.
  • 80. ERRORS 67 Example 3. For x = .4845 and y = .4800, calculate the value of x y x y 2 2 − + using normalized floating point arithmetic. Compare with the value of (x – y). Indicate the error in the former. Sol. x + y = .4845 E 0 + .4800 E 0 = .9645 E 0 x2 = (.4845 E 0) × (.4845 E 0) = .2347 E 0 y2 = (.4800 E 0) × (.4800 E 0) = .2304 E 0 x2 – y2 = .2347 E 0 – .2304 E 0 = .0043 E 0 Now, x y x y 2 2 − + = .0043 E 0 ÷ .9645 E 0 = .4458 E – 2 Also, x – y = .4845 E 0 – .4800 E 0 = .0045 E 0 = .4500 E – 2 Relative error = .4500 0.4458 .4500 .93% − = . Example 4. For e = 2.7183, calculate the value of ex when x = .5250 E 1. The expression for ex is e 1 x x 2 ! x 3 ! x 2 3 = + + + . Sol. e.5250 E 1 = e5 * e.25 e5 = (.2718 E 1) × (.2718 E 1) × (.2718 E 1) × (.2718 E 1) × (.2718 E 1) = .1484 E 3 Also, e.25 = 1 + + + (.25) (.25) 2! (.25) 3 ! 2 3 = 1.25 + .03125 + .002604 = .1284 E 1 Now, e.5250 E 1 = (.1484 E 3) × (.1284 E 1) = .1905 E 3. Example 5. Find the solution of the following equation using floating point arithmetic with a 4 digit mantissa x2 – 1000x + 25 = 0 Give comments or the result so obtained. Sol. x2 – 1000 x + 25 = 0 ⇒ x = 1000 10 10 2 6 2 ± −
  • 81. 68 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, 106 = .1000 E 7 and 102 = .1000 E 3 ∴ 106 – 102 = .1000 E 7 ∴ 10 10 6 2 − = .1000 E 4 ∴ Roots are .1000 E 4 + .1000 E 4 2 F HG I KJ and .1000 E 4 – .1000 E 4 2 F HG I KJ which are .1000 E 4 and .0000 E 4 respectively. One of the roots becomes zero due to the limited precision allowed in calculation. Let us reformulate the problem and remember that in a quadratic equation ax2 + bx + c = 0, the product of roots is given by c a , so the smaller root may be obtained by dividing (c/a) by the larger root. So, First root = .1000 E 4 and Second root = 25 2500 1 .1000 E 4 E 2 .1000 E 4 .2500 E = = − . Such a situation may be recognized in an algorithm by checking to see if b2 | 4 ac |. Example 6. Find the smaller root of the equation x2 – 400 x + 1 = 0 using four digit arithmetic. Sol. Here b2 | 4ac | | See Example 5 The roots of the equation ax2 – bx + c = 0 are b b ac a + − 2 4 2 and b b ac a − − 2 4 2 The product of the roots is c a . ∴ The smaller root is c a b b ac a i e c b b ac / . ., + − F H GG I K JJ + − 2 2 4 2 2 4 Here a = 1 = .1000 E 1, b = 400 = .4000 E 3, c = 1 = .1000 E 1 b2 – 4ac = .1600 E 6 – .4000 E 1 = .1600 E 6 (to four digit accuracy) ∴ b ac 2 4 − = .4000 E 3 ∴ Smaller root = 2 (.1000 E 1) .4000 E 3 .4000 E 3 .2000 E 1 .8000 E 3 × + = = .25 E – 2 = .0025.
  • 82. ERRORS 69 Example 7. Compute the middle value of numbers a = 4.568 and b = 6.762 using four digit arithmetic and compare the result by taking c = a + b a 2 − F HG I KJ. Sol. a = .4568 E 1, b = .6762 E 1 Let c be the middle value of numbers, then c a b = + = = = 2 5665 .4568 E 1+ .6762 E 1 .2000 E 1 .1133 E 2 .2000 E 1 E 1 . However, if we use the formula c = a + b a − F HG I KJ 2 = .4568 E 1 + .6762 E 1 E E 1 − F HG I KJ . . 4568 1 2000 = .4568 E 1 + .1097 E 1 = .5665 E 1 The results are the same. Example 8. Obtain a second degree polynomial approximation to f(x) = (1 + x)1/2, x ∈ [0, 0.1] using Taylor’s series expansion about x = 0. Use the expansion to approximate f(0.05) and bound the truncation error. Sol. f(x) = (1 + x)1/2, f(0) = 1 f ′(x) = 1 2 (1 + x)–1/2, f ′(0) = 1 2 f ″(x) = – 1 4 (1 + x)–3/2, f ″(0) = – 1 4 f ″′(x) = 3 8 (1 + x)–5/2 Taylor’s series expansion with remainder term may be written as (1 + x)1/2 = 1 + x x x 2 8 1 16 1 2 3 1/2 5 − + + [( ) ] ξ ; 0 ξ 0.1 The truncation term is given by T = (1 + x)1/2 – 1 2 8 1 16 1 2 3 1/2 5 + − F HG I KJ = + x x x . [( ) ] ξ We have f(0.05) = 1 + 0 05 2 0 05 8 2 . ( . ) − = 0.10246875 × 101
  • 83. 70 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Bound of the truncation error, for x ∈ [0, 0.1] is | T | ≤ ( .1) 16 [(1+ ) .1 16 1/2 0 0 3 5 3 ξ ] ( ) ≤ = 0.625 × 10–4. Example 9. In a case of normalized floating point representation, associative and distributive laws are not always valid. Give examples to prove this statement. Or If the normalization on the floating point is carried out at each stage, prove the following: (i) a(b – c) ≠ ab – ac where a = .5555 E 1, b = .4545 E 1, c = .4535 E 1 (ii) (a + b) – c ≠ (a – c) + b where a = .5665 E 1, b = .5556 E – 1, c = .5644 E 1. Sol. This is a consequence of the normalized floating point representation that the associative and the distributive laws of arithmetic are not always valid. The following examples are chosen intentionally to illustrate the inaccura- cies that may build up due to shifting and truncation of numbers in arithmetic operations. Non-distributivity of arithmetic Let a = .5555 E 1 b = .4545 E 1 c = .4535 E 1 (b – c) = .0010 E 1 = .1000 E – 1 a(b – c) = (.5555 E 1) × (.1000 E – 1) = (.0555 E 0) = .5550 E – 1 Also, ab = (.5555 E 1) × (.4545 E 1) = .2524 E 2 ac = (.5555 E 1) × (.4535 E 1) = .2519 E 2 ∴ ab – ac = .0005 E 2 = .5000 E – 1 Thus, a(b – c) ≠ ab – ac which shows the non-distributivity of arithmetic. Non-associativity of arithmetic Let a = .5665 E 1 b = .5556 E – 1 c = .5644 E 1
  • 84. ERRORS 71 ∴ (a + b) = .5665 E 1 + .5556 E – 1 = .5665 E 1 + .0055 E 1 = .5720 E 1 (a + b) – c = .5720 E 1 – .5644 E 1 = .0076 E 1 = .7600 E – 1 a – c = .5665 E 1 – .5644 E 1 = .0021 E 1 = .2100 E – 1 (a – c) + b = .2100 E – 1 + .5556 E – 1 = .7656 E – 1 Thus, (a + b) – c ≠ (a – c) + b which proves the non-associativity of arithmetic. 2.11 MACHINE COMPUTATION To obtain meaningful results for a given problem using computers, there are five distinct phases: (i) Choice of a method (ii) Designing the algorithm (iii) Flow charting (iv) Programming (v) Computer execution A method is defined as a mathematical formula for finding the solution of a given problem. There may be more than one method available to solve the same problem. We should choose the method which suits the given problem best. The inherent assumptions and limitations of the method must be studied carefully. Once the method has been decided, we must describe a complete and unambiguous set of computational steps to be followed in a particular sequence to obtain the solution. This description is called an algorithm. It may be emphasized that the computer is concerned with the algorithm and not with the method. The algorithm tells the computer where to start, what information to use, what operations to be carried out and in which order, what information to be printed, and when to stop. An algorithm has five important features: (1) finiteness: an algorithm must terminate after a finite number of steps. (2) definiteness: each step of an algorithm must be clearly defined or the action to be taken must be unambiguously specified. (3) inputs: an algorithm must specify the quantities which must be read before the algorithm can begin. (4) outputs: an algorithm must specify the quantities which are to be outputted and their proper place. (5) effectiveness: an algorithm must be effective, which means that all operations are executable.
  • 85. 72 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A flow-chart is a graphical representation of a specific sequence of steps (algorithm) to be followed by the computer to produce the solution of a given problem. It makes use of the flow chart symbols to represent the basic operations to be carried out. The various symbols are connected by arrows to indicate the flow of information and processing. While drawing a flow chart, any logical error in the formulation of the problem or application of the algorithm can be easily seen and corrected. 2.12 COMPUTER SOFTWARE The purpose of computer software is to provide a useful computational tool for users. The writing of computer software requires a good understanding of numerical analysis and art of programming. Good computer software must satisfy certain criteria of self-starting, accuracy and reliability, minimum number of levels, good documentation, ease of use, and portability. Computer software should be self-starting as far as possible. A numerical method very often involves parameters whose values are determined by the properties of the problem to be solved. For example, in finding the roots of an equation, one or more initial approximations to the root have to be given. The program will be more acceptable if it can be made automatic in the sense that the program will select the initial approximations itself rather than requiring the user to specify them. Accuracy and reliability are measures of the performance of an algorithm on all similar problems. Once an error criterion is fixed, it should produce solutions of all similar problems to that accuracy. The program should be able to prevent and handle most of the exceptional conditions like division by zero, infinite loops, etc. The structure of the program should avoid many levels. For example, many programs used to find roots of an equation have three levels: Program calls zero-finder (parameters, function) Zero-finder calls function Function subprogram The more number of levels in the program, the more time is wasted in interlinking and transfer of parameters. Documentation that is accurate and easy to use is a very important criteria. The program must have some comment lines or comment paragraphs at various places giving explanation and clarification of the method used and steps involved. Accurate documentation should clarify what kind of problems can be solved using this software, what parameters are to be supplied, what accuracy can be achieved, which method has been used, and other relevant details.
  • 86. ERRORS 73 The criterion of portability means that the software should be made independent of the computer being used as far as possible. Since most machines have different hardware configuration, complete independence from the machine may not be possible. However, the aim of writing the computer software should be that the same program should be able to run on any machine with minimum modifications. Machine-dependent constants, for example machine error EPS, must be avoided or automatically generated. A standard dialect of the programming language should be used rather than a local dialect. Most of the numerical methods are available in the form of software, which is a package of thoroughly tested, portable, and self documented subprograms. The general purpose packages contain a number of subroutines for solving a variety of mathematical problems that commonly arise in scientific and engineering computation. The special purpose packages deal with specified problem areas. Many computer installations require one or both types of packages and make it available, on-line, to their users. Most of the software packages are available for PCs also. General Purpose Packages IMSL: (International Mathematical and Statistical Library). The IMSL is a general purpose library of over 900 subroutines written in ANSI Fortran for solving a large number of mathematical and statistical problems. NAG: (Numerical Algorithms Group). This package covers the basic areas of mathematical and statistical computation. The package is available in any one of the three languages ANSI Fortran, Algol 60 or Algol 68. Special Purpose Packages All the following packages are distributed by IMSL. BLAS: (Basic Linear Algebra Subroutines). BLAS contains 38 ANSI Fortran subroutines for the methods in numerical linear algebra. The objective is fast computer execution. B-Splines: A package of subroutines for performing calculations with piece- wise polynomials. DEPACK: (Differential Equations Package). DEPACK contains Fortran subprograms for the integration of initial value problems in ordinary differential equations. This package includes Runge-Kutta methods, variable step, variable order Adams type methods, and backward differentiation methods for stiff problems. EISPACK: (Matrix Eigensystem Routines). EISPACK contains 51 Fortran subprograms for computing the eigenvalues and/or eigenvectors of a matrix. ELLPACK: (Elliptic Partial Differential Equations Solver). ELLPACK contains over 30 numerical method modules for solving elliptic partial differential equations in two dimensions with general domains and in three dimensions with rectangular domains. The 5-point discretization is used
  • 87. 74 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES and the resulting system of equations is solved by Gauss elimination for band matrices and by SOR iterations. FISHPACK: (Routines for the Helmholtz Problems in Two or Three Dimensions). FISHPACK contains a set of Fortran programs for solving Helmholtz problems in two or three dimensions. There are separate programs for rectangular, polar, spherical and cylindrical coordinates. FUNPACK: (Special Function Subroutines). The FUNPACK package contains Fortran and assembly language subroutines for evaluating important special functions like exponential integral, elliptic integrals of first and second kind, Bessel functions, Dawson integrals, etc. ITPACK: (Iterative Methods). ITPACK contains Fortran subprograms for iterative methods for solving linear system of equations. The package is oriented towards the sparse matrices that arise in solving partial differential equations and in other applications. LINPACK: (Linear Algebra Package). LINPACK contains Fortran subprograms for direct methods for general, symmetric, symmetric positive definite, triangular, and tridiagonal matrices. The package also includes programs for least-squares problems, along with the QR and singular value decompositions of rectangular matrices. MINPACK: MINPACK is a package of subroutines for solving systems of nonlinear equations and nonlinear least-squares problems. The package also includes programs for minimization and optimization problems. QUADPACK: QUADPACK contains subroutines for evaluating a definite integral. Software packages for PCs are also available for most of the areas mentioned above. ASSIGNMENT 2.3 1. Represent 44.85 × 106 in normalized floating point mode. 2. Subtract the following two floating point numbers as (i) .36143448 E 7 – .36132346 E 7 (ii) (.9682 E – 7) – (.3862 E – 9). 3. Explain underflow and overflow conditions of error in floating point’s addition and subtraction. 4. Find the solution of the following equation using floating point arithmetic with 4-digit mantissa. x2 – 7x + 4 = 0 Give comments on the results so obtained.
  • 88. ERRORS 75 5. Discuss the consequences of normalized floating point representation of numbers. 6. Calculate the value of x2 + 2x – 2 and (2x – 2) + x2 where x = .7320 E 0 using normalized floating point arithmetic and prove that they are not the same. Compare with value of (x2 – 2) + 2x. 7. Find the value of (1 + x)2 and (x2 + 2x) + 1 when x = .5999 E – 2. 8. Find the value of sin x ~ ! ! − − + x x x 3 5 3 5 with an absolute error smaller than .005 for x = .2000 E 0 using normalized floating point arithmetic with a 4 digit mantissa. 9. Write a short note on machine computation. 10. Prove the following consequence of the normalized floating point representation of numbers by taking x = .6667 6x ≠ x + x + x + x + x + x. 11. Define normalized floating point representation of numbers and round off errors in representation. Find the sum of 0.123 × 103 and 0.456 × 102 and write the result in three digit mantissa form. 12. (i) Calculate the value of the polynomial p3(x) = 2.75x3 – 2.95x2 + 3.16x – 4.67 for x = 1.07 using both chopping and rounding-off to three digits, proceeding through the polynomial term by term from left to right. (ii) Explain how floating point numbers are stored in computers. What factors affect their accuracy and range?
  • 90. C onsider the equation of the form f(x) = 0. If f(x) is a quadratic, cubic, or biquadratic expression, then algebraic formulae are available for expressing the roots. But when f(x) is a polynomial of higher degree or an expression involving transcendental functions, for example, 1 + cos x – 5x, x tan x – cosh x, e–x – sin x, etc., algebraic methods are not available. In this unit, we shall describe some numerical methods for the solution of f(x) = 0, where f(x) is algebraic or transcendental or both. 3.1 BISECTION (OR BOLZANO) METHOD This method is based on the repeated application of intermediate value property. Let the function f(x) be continuous between a and b. For definiteness, let f(a) be (–)ve and f(b) be (+)ve. Then the first approximation to the root is x1 = 1 2 (a + b). If f(x1) = 0, then x1 is a root of f(x) = 0, otherwise, the root lies between a and x1 or x1 and b according to f(x1) is (+)ve or (–)ve. Then we bisect the interval as before and continue the process until the root is found to the desired accuracy. Chapter 3 ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 77
  • 91. 78 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES In the adjoining figure, f(x1) is (+)ve so that the root lies between a and x1. The second approximation to the root is x2 = 1 2 (a + x1). If f (x2) is (–)ve the root lies between x1 and x2. The third approximation to the root is x3 = 1 2 (x1 + x2), and so on. Y X O a x2 f(a) x3 x1 b f(b) y = f ( x ) Once the method of calculation has been decided, we must describe clearly the computational steps to be followed in a particular sequence. These steps constitute the algorithm of method. 3.2 ALGORITHM Step 01. Start of the program Step 02. Input the variables x1, x2 for the task Step 03. Check f(x1) *f(x2) 0 Step 04. If yes, proceed Step 05. If no exit and print error message Step 06. Repeat 7-11 if conditions are not satisfied Step 07. x0 = (x1 + x2)/2 Step 08. If f(x0) *f(x1) 0 Step 09. x2 = x0. Step 10. ELSE Step 11. x1 = x0 Step 12. Condition: Step 13. | (x1-x2)/x1 | maximum possible error or f(x0) = 0 Step 14. Print output Step 15. End of program.
  • 92. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 79 3.3 FLOW-CHART START Define F(x) Get the value of interval (a, b), error, iter Initialize i = 1 Call subroutine bisect mid Y is F(mid) 0 B = X Yes A = X B Subroutine bisect X = (A + B)/2 Iter + + Print ITER, Xl RETURN X Print iter, Xl STOP is Abs (XI-X) Aerr Yes Yes No No X Y i iter Print solution does not converge
  • 93. 80 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.4 PROGRAM WRITING Based on the flow-chart, we write the instructions in a code which the computer can understand. A series of such instructions is called a program. If there are any errors in the program, they will be pointed out by the computer during compilation. After correcting compilation errors, the program is executed with input data to check for logical errors which may be due to misinterpretation of the algorithm. The process of finding the errors and correcting them is called debugging. 3.5 ORDER OF CONVERGENCE OF ITERATIVE METHODS Convergence of an iterative method is judged by the order at which the error between successive approximations to the root decreases. An iterative method is said to be kth order convergent if k is the largest positive real number, such that lim i i i k e e →∞ + 1 ≤ A where A is a non-zero finite number called asymptotic error constant and it depends on derivative of f(x) at an approximate root x. ei and ei+1 are the errors in successive approximations. kth order convergence gives us the idea that in each iteration, the number of significant digits in each approximation increases k times. The error in any step is proportional to the kth power of the error in the previous step. 3.6 ORDER OF CONVERGENCE OF BISECTION METHOD In the Bisection method, the original interval is divided into half interval in each iteration. If we take mid-points of successive intervals to be the approximations of the root, one half of the current interval is the upper bound to the error. In Bisection method, ei + 1 = 0.5 ei or e e i i + 1 = 0.5 (1) where ei and ei + 1 are the errors in the ith and (i + 1)th iterations, respectively.
  • 94. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 81 Comparing (1) with lim i i i k e e →∞ + 1 ≤ A we get k = 1 and A = 0.5 Thus the Bisection method is I order convergent, or linearly convergent. 3.7 CONVERGENCE OF A SEQUENCE A sequence xn of successive approximations of a root x = α of the equation f(x) = 0 is said to converge to x = α with order p ≥ 1 iff | xn + 1 – α | ≤ c | xn – α |p, n ≥ 0 c being some constant greater than zero. Particularly, if | xn + 1 – α | = c | xn – α |, n ≥ 0, 0 c 1 then convergence is called geometric. Also, If p = 1 and 0 c 1, then convergence is called linear or of first order. Constant c is called the rate of linear convergence. Convergence is rapid or slow depending on whether c is near 0 or 1. Using induction, the condition for linear convergence can be simplified to the form | xn – α | ≤ cn | x0 – α |, n ≥ 0, 0 c 1. 3.8 PROVE THAT BISECTION METHOD ALWAYS CONVERGES Let [pn, qn] be the interval at nth step of bisection, having a root of the equation f(x) = 0. Let xn be the nth approximation for the root. Then, initially, p1 = a and q1 = b. ⇒ x1 = first approximation = p q 1 1 2 + F HG I KJ ⇒ p1 x1 q1 Now either the root lies in [a, x1] or in [x1, b]. ∴ either [p2, q2] = [p1, x1] or [p2, q2] = [x1, q1] ⇒ either p2 = p1, q2 = x1 or p2 = x1, q2 = q1 ⇒ p1 ≤ p2, q2 ≤ q1 Also, x2 = p q 2 2 2 + so that p2 x2 q2
  • 95. 82 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Continuing this way, we obtain that at nth step, xn = p q n n + 2 , pn xn qn and p1 ≤ p2 ≤ ...... ≤ pn and q1 ≥ q2 ≥ ...... ≥ qn ∴ p1, p2, ......, pn, ...... is a bounded, non-decreasing sequence bounded by b and q1, q2, ......, qn, ...... is a bounded, non-increasing sequence of numbers bounded by a. Hence, both these sequences converge. Let, lim n → ∞ pn = p and lim n → ∞ qn = q. Now, since the length of the interval is decreasing at every step, we get that lim n → ∞ (qn – pn) = 0 ⇒ q = p Also, pn xn qn ⇒ lim pn ≤ lim xn ≤ lim qn ⇒ p ≤ lim xn ≤ q ⇒ lim xn = p = q (2) Further, since a root lies in [pn, qn], we shall have f(pn) . f(qn) 0 ⇒ 0 ≥ → ∞ lim n n n f p f q [ ( ) . ( )] ⇒ 0 ≥ f(p) . f(q) ⇒ 0 ≥ [f(p)]2 But, [f(p)]2 ≥ 0 being a square ∴ we get f(p) = 0 ∴ p is a root of f(x) = 0 (3) From (2) and (3), we see that xn converges necessarily to a root of equation f(x) = 0 The method is not rapidly converging, but it is useful in the sense that it converges surely.
  • 96. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 83 EXAMPLES Example 1. Find the real root of the equation x log10 x = 1.2 by Bisection method correct to four decimal places. Also write its program in C-language. Sol. f(x) = x log10 x – 1.2 Since f(2.74) = – .000563 i.e., (–)ve and f(2.75) = .0081649 i.e., (+)ve Hence, the root lies between 2.74 and 2.75. ∴ First approximation to the root is x1 = 2 74 2 75 2 . . + = 2.745 Now f(x1) = f(2.745) = .003798 i.e., (+)ve Hence, the root lies between 2.74 and 2.745. ∴ Second approximation to the root is x2 = 2 74 2 745 2 . . + = 2.7425 Now f(x2) = f(2.7425) = .001617 i.e., (+)ve Hence, the root lies between 2.74 and 2.7425. ∴ Third approximation to the root is x3 = 2 74 2 7425 2 . . + = 2.74125 Now f(x3) = f(2.74125) = .0005267 i.e., (+)ve Hence, the root lies between 2.74 and 2.74125. ∴ Fourth approximation to the root is x4 = 2 74 2 74125 2 . . + = 2.740625 Now f(x4) = f(2.740625) = – .00001839 i.e., (–)ve. Hence, the root lies between 2.740625 and 2.74125. ∴ Fifth approximation to the root is x5 = 2 740625 2 74125 2 . . + = 2.7409375
  • 97. 84 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now f(x5) = f(2.7409375) = .000254 i.e., (+)ve Hence, the root lies between 2.740625 and 2.7409375. ∴ Sixth approximation to the root is x6 = 2 740625 2 7409375 2 . . + = 2.74078125 Now f(x6) = f(2.74078125) = .0001178 i.e., (+)ve Hence, the root lies between 2.740625 and 2.74078125. ∴ Seventh approximation to the root is x7 = 2 740625 2 74078125 2 . . + = 2.740703125 Now f(x7) = f(2.740703125) = .00004973 i.e., (+)ve Hence, the root lies between 2.740625 and 2.740703125 ∴ Eighth approximation to the root is x8 = 2 740625 2 740703125 2 . . + = 2.740664063 Now f(x8) = f(2.740664063) = .00001567 i.e., (+)ve Hence, the root lies between 2.740625 and 2.740664063. ∴ Nineth approximation to the root is x9 = 2 740625 2 740664063 2 . . + = 2.740644532 Since x8 and x9 are the same up to four decimal places, the approximate real root is 2.7406. C-program for above problem is given below: 3.9 PROGRAM TO IMPLEMENT BISECTION METHOD //...Included Header Files #includestdio.h #includemath.h #includeconio.h #includeprocess.h #includestring.h #define EPS 0.00000005 #define F(x) (x)*log10(x)–1.2
  • 98. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 85 //...Function Prototype Declaration void Bisect(); //...Global Variable Declaration field int count=1,n; float root=1; //... Main Function Implementation void main() { clrscr(); printf(n Solution by BISECTION method n); printf(n Equation is ); printf(nttt x*log(x) – 1.2 = 0nn); printf(Enter the number of iterations:); scanf(%d,n); Bisect(); getch(); } //... Function Declaration void Bisect() { float x0,x1,x2; float f0,f1,f2; int i=0; /*Finding an Approximate ROOT of Given Equation, Having +ve Value*/ for(x2=1;;x2++) { f2=F(x2); if (f20) { break; } } /*Finding an Approximate ROOT of Given Equation, Having -ve Value*/
  • 99. 86 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES for(x1=x2-1;;x2--) { f1=F(x1); if(f10) { break; } } //...Printing Result printf(tt-----------------------------------------); printf(ntt ITERATIONStt ROOTSn); printf(tt-----------------------------------------); for(;count=n;count++) { x0=(x1+x2)/2.0; f0=F(x0); if(f0==0) { root=x0; } if(f0*f10) { x2=x0; } else { x1=x0; f1=f0; } printf(ntt ITERATION %d, count); printf(t :t %f,x0); if(fabs((x1-x2)/x1) EPS) { printf(ntt---------------------------------); printf(ntt Root = %f,x0);
  • 100. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 87 printf(ntt Iterations = %dn, count); printf(tt------------------------------------); getch(); exit(0); } } printf(ntt----------------------------------------); printf(nttt Root = %7.4f,x0); printf(nttt Iterations = %dn, count-1); printf(tt------------------------------------------); getch(); } OUTPUT Solution by BISECTION method Equation is x* log(x) - 1.2=0 Enter the number of iterations: 30 ----------------------------------------- ITERATIONS ROOTS ----------------------------------------- ITERATION 1: 2.500000 ITERATION 2: 2.750000 ITERATION 3: 2.625000 ITERATION 4: 2.687500 ITERATION 5: 2.718750 ITERATION 10: 2.741211 ITERATION 11: 2.740723 ITERATION 12: 2.740479 ITERATION 13: 2.740601 ITERATION 14: 2.740662 ITERATION 15: 2.740631 ITERATION 16: 2.740646 ITERATION 17: 2.740639 ITERATION 18: 2.740643 ITERATION 19: 2.740644 ITERATION 20: 2.740645
  • 101. 88 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ITERATION 21: 2.740646 ITERATION 22: 2.740646 ITERATION 23: 2.740646 ITERATION 24: 2.740646 ITERATION 25: 2.740646 ITERATION 26: 2.740646 ITERATION 27: 2.740646 ITERATION 28: 2.740646 ITERATION 29: 2.740646 ITERATION 30: 2.740646 ----------------------------------------- Root = 2.7406 Iterations = 30 ----------------------------------------- C:tcexe Example 2. Find a root of the equation x3 – 4x – 9 = 0 using Bisection method in four stages. Sol. Let f(x) ≡ x3 – 4x – 9 Since f(2.706) = – .009488 i.e., (–)ve and f(2.707) = .008487 i.e., (+)ve Hence, the root lies between 2.706 and 2.707. ∴ First approximation to the root is x1 = 2 706 2 707 2 . . + = 2.7065 Now f(x1) = – .0005025 i.e., (–)ve Hence, the root lies between 2.7065 and 2.707. ∴ Second approximation to the root is x2 = 2 7065 2 707 2 . . + = 2.70675 Now f(x2) = .003992 i.e., (+)ve Hence, the root lies between 2.7065 and 2.70675.
  • 102. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 89 ∴ Third approximation to the root is x3 = 2 7065 2 70675 2 . . + = 2.706625 Now f(x3) = .001744 i.e., (+)ve Hence, the root lies between 2.7065 and 2.706625. ∴ Fourth approximation to the root is x4 = 2 7065 2 706625 2 . . + = 2.7065625 Hence, the root is 2.7065625, correct to three decimal places. Example 3. Find a positive real root of x – cos x = 0 by bisection method, correct up to 4 decimal places between 0 and 1. Sol. Let f(x) = x – cos x f(0.73) = (–)ve and f(0.74) = (+)ve Hence, the root lies between 0.73 and 0.74. First approximation to the root is x1 = 0 73 0 74 2 . . + = 0.735 Now f(0.735) = (–)ve Hence, the root lies between 0.735 and 0.74. Second approximation to the root is x2 = 0.73 0.74 2 + = 0.7375 Now f(0.7375) = (–)ve Hence, the root lies between 0.7375 and 0.74. Third approximation to the root is x3 = 0 7375 0 74 2 . . + = 0.73875 Now f(0.73875) = (–)ve Hence, the root lies between 0.73875 and 0.74. Fourth approximation to the root is x4 = 1 2 (0.73875 + 0.74) = 0.739375 Now f(x4) = f(0.739375) = (+)ve
  • 103. 90 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence, the root lies between 0.73875 and 0.739375. Fifth approximation to the root is x5 = 1 2 (0.73875 + 0.739375) = 0.7390625 Now f(0.7390625) = (–)ve Hence, the root lies between 0.7390625 and 0.739375 Sixth approximation to the root is x6 = 1 2 (0.7390625 + 0.739375) = 0.73921875 Now f(0.73921875) = (+)ve Hence, the root lies between 0.7390625 and 0.73921875 Seventh approximation to the root is x7 = 1 2 (0.7390625 + 0.73921875) = 0.73914 Now f(0.73914) = (+)ve Hence, the root lies between 0.7390625 and 0.73914 Eighth approximate to the root is x8 = 1 2 (0.7390625 + 0.73914) = 0.73910 Hence, the approximate real root is 0.7391. Example 4. Perform five iterations of the bisection method to obtain the smallest positive root of equation f(x) ≡ x3 – 5x + 1 = 0. Sol. f(x) = x3 – 5x + 1 Since f(.2016) = .0001935 i.e., (+)ve and f(.2017) = – .0002943 i.e., (–)ve Hence, the root lies between .2016 and .2017. First approximation to the root is x1 = . . 2016 2017 2 + = .20165 Now f(x1) = – .00005036 i.e., (–)ve
  • 104. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 91 Hence, the root lies between .2016 and .20165. Second approximation to the root is x2 = . . 2016 20165 2 + = .201625 Now f(x2) = .00007159 i.e., (+)ve Hence, the root lies between .201625 and .20165. Third approximation to the root is x3 = . . 201625 20165 2 + = .2016375 Now f(x3) = .00001061 i.e., (+)ve Hence, the root lies between .2016375 and .20165. Fourth approximation to the root is x4 = . . 2016375 20165 2 + = .20164375 Now f(x4) = – .00001987 i.e., (–)ve Hence, the root lies between .2016375 and .20164375. ∴ Fifth approximation to the root is x5 = . . 2016375 20164375 2 + = .201640625 Hence, after performing five iterations, the smallest positive root of the given equation is .20164, correct to five decimal places. Example 5. Find a real root of x3 – x = 1 between 1 and 2 by bisection method. Compute five iterations. Sol. Here, f(x) = x3 – x – 1 Since f(1.324) = – .00306 i.e., (–)ve and f(1.325) = .00120 i.e., (+)ve Hence, the root lies between 1.324 and 1.325. ∴ First approximation to the root is x1 = 1.324 1.325 2 + = 1.3245 Now f(x1) = – .000929 i.e., (–)ve Hence, the root lies between 1.3245 and 1.325 ∴ Second approximation to the root is x2 = 1.3245 1.325 2 + = 1.32475
  • 105. 92 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now f(x2) = .000136 i.e., (+)ve Hence, the root lies between 1.3245 and 1.32475. Third approximation to the root is x3 = 1.3245 1.32475 2 + = 1.324625 Now f(x3) = – .000396 i.e., (–)ve Hence, the root lies between 1.324625 and 1.32475. ∴ Fourth approximation to the root is x4 = 1.324625 1.32475 2 + = 1.3246875 Now f(x4) = – .0001298 i.e., (–)ve Hence, the root lies between 1.3246875 and 1.32475 ∴ Fifth approximation to the root is x5 = 1.3246875 1.32475 2 + = 1.32471875 Hence, the real root of the given equation is 1.324 correct to three decimal places after computing five iterations. Example 6. Use bisection method to find out the positive square root of 30 correct to 4 decimal places. Sol. Let f(x) = x2 – 30 Since f(5.477) = – .00247 i.e., (–)ve and f(5.478) = .00848 i.e., (+)ve Hence, the root lies between 5.477 and 5.478 ∴ First approximation to the root is x1 = 5 477 5 478 2 . . + = 5.4775 Now f(x1) = .003 i.e., (+)ve Hence, the root lies between 5.477 and 5.4775 ∴ Second approximation to the root is x2 = 5 477 5 4775 2 . . + = 5.47725
  • 106. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 93 Now f(x2) = .00026 i.e., (+)ve Hence, the root lies between 5.477 and 5.47725 ∴ Third approximation to the root is x3 = 5 477 5 47725 2 . . + = 5.477125 Now f(x3) = – .0011 i.e., (–)ve Hence, the root lies between 5.477125 and 5.47725 ∴ Fourth approximation to the root is x4 = 5 477125 5 47725 2 . . + = 5.4771875 Since x3 and x4 are the same up to four decimal places, the positive square root of 30, correct to 4 decimal places, is 5.4771. ASSIGNMENT 3.1 1. (i) Transcendental equation is given as f(x) = 2x – x – 3 Calculate f(x) for x = – 4, – 3, – 2, – 1, 0, 1, 2, 3, 4 and determine, between which integer the values roots are lying. (ii) The equation x2 – 2x – 3cos x = 0 is given. Locate the smallest root in magnitude in an interval of length one unit. 2. Find a real root of ex = 3x by Bisection method. 3. Find the smallest positive root of x3 – 9x + 1 = 0, using Bisection method correct to three decimal places. 4. Find the real root lying in interval (1, 2) up to four decimal places for the equation x6 – x4 – x3 – 1 = 0 by bisection method. 5. Find the root of tan x + x = 0 up to two decimal places which lies between 2 and 2.1 using Bisection method. 6. Compute the root of log x = cos x correct to 2 decimal places using Bisection method. 7. Compute the root of f(x) = sin 10x + cos 3x by computer using Bisection method. The initial approximations are 4 and 5. 8. Find the real root correct to three decimal places for the following equations: (i) x3 – x – 4 = 0 (ii) x3 – x2 – 1 = 0 (iii) x3 + x2 – 1 = 0 (iv) x3 – 3x – 5 = 0. 9. Find a root of x3 – x – 11 = 0 using Bisection method correct to 3 decimal places which lies between 2 and 3. 10. Find a real root of the equation x3 – 2x – 5 = 0 using Bisection method. 11. Find a positive root of the equation xex = 1 which lies between 0 and 1.
  • 107. 94 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 12. Apply Bisection method to find a root of the equation x4 + 2x3 – x – 1 = 0 in the interval [0, 1]. 13. Obtain a root correct to three decimal places for each of these equations using Bisection method. (i) x3 + x2 + x + 7 = 0 (ii) x3 – 18 = 0 (iii) x3 + x – 1 = 0 (iv) x3 – 5x + 3 = 0. 14. By displaying procedure in tabular form, use Bisection method to compute the root of 36. 15. Find a positive root of the equation x3 + 3x – 1 = 0 by bisection method. 16. Find a real root of x3 – 2x – 1 = 0 which lies between 1 and 2 by using Bisection method correct to 2 decimal places. 17. Find the approximate value of the root of the equation 3x – 1 + sin x = 0 by Bisection method. 18. (i) Explain the Bisection method to calculate the roots of an equation. Write an algo- rithm and implement it in ‘C’. (ii) Write computer program in a language of your choice which implements bisection method to compute the real root of the equation 3x + sin x – ex = 0 in a given interval. 19. Solve x3 – 9x + 1 = 0 for the root between x = 2 and x = 4 by the method of Bisection. 20. If a root of f(x) = 0 lies in the interval (a, b), then find the minimum number of iterations required when the permissible error is E. 21. The negative root of the smallest magnitude of the equation f(x) = 3x3 + 10x2 + 10x + 7 = 0 is to be obtained. (i) Find an interval of unit length which contains this root. (ii) Perform two iterations of the bisection method. 22. The smallest positive root of the equation f(x) = x4 – 3x2 + x – 10 = 0 is to be obtained. (i) Find an interval of unit length which contains this root. (ii) Perform two iterations of the bisection method. 3.10 ITERATION METHOD—(Successive Approximation Method) To find the roots of the equation f(x) = 0 by successive approximations, we write it in the form x = φ(x) The roots of f(x) = 0 are the same as the points of intersection of the straight line y = x and the curve representing y = φ(x).
  • 108. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 95 Y O X x0 x2 x3 x1 y = x y = (x) φ (Working of Iteration method) Let x = x0 be an initial approximation of the desired root α, then first approximation x1 is given by x1 = φ(x0) Now, treating x1 as the initial value, the second approximation is x2 = φ(x1) Proceeding in this way, the nth approximation is given by xn = φ(xn – 1). 3.11 SUFFICIENT CONDITION FOR CONVERGENCE OF ITERATIONS It is not definite that the sequence of approximations x1, x2, ......, xn always converges to the same number, which is a root of f(x) = 0. As such, we have to choose the initial approximation x0 suitably so that the successive approximations x1, x2, ......, xn converge to the root α. The following theorem helps in making the right choice of x0. 3.12 THEOREM If (i) α be a root of f(x) = 0 which is equivalent to x = φ(x)*. (ii) I be any interval containing x = α. (iii) | φ′(x) | 1 for all x in I, then the sequence of approximations x0, x1, x2, ......, xn will converge to the root a provided the initial approximation x0 is chosen in I. *x is obtained interms of φ(x) such that | φ′(x) | 1.
  • 109. 96 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES This method of iteration is particularly useful for finding the real roots of an equation given in the form of an infinite series. 3.13 CONVERGENCE OF ITERATION METHOD Since α is a root of x = φ(x), we have α = φ(α) If xn – 1 and xn are two successive approximations to α, we have xn = φ(xn – 1), xn – α = φ(xn – 1) – φ(α) (4) By mean value theorem, φ φ α α ( ) ( ) x x n n − − − − 1 1 = φ′(ξ), where xn – 1 ξ α Hence (4) becomes xn – α = (xn – 1 – α) φ′(ξ) If | φ′(xi) | ≤ k 1 for all i, then, | xn – α | ≤ k | xn – 1 – α |, k 1 Hence it is clear that the iteration method is linearly convergent. 1. The smaller the value of φ′(x), the more rapid will be the convergence. 2. For rapid convergence, f′(a) ≈ 0. 3.14 ALGORITHM FOR ITERATION METHOD 3.14.1 Algorithm 1 1. Read x0, e, n x0 is the initial guess, e is the allowed error in root, n is total iterations to be allowed for convergence. 2. x1 ← g(x0) Steps 4 to 6 are repeated until the procedure converges to a root or iterations reach n. NOTE NOTE NOTE NOTE
  • 110. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 97 3. For i = 1 to n in steps of 1 do 4. x0 ← x1 5. x1 ← g(x0) 6. If x x x 1 0 1 − ≤ e then, GO TO 9 end for. 7. Write ‘Does not converge to a root’, x0, x1 8. Stop 9. Write ‘converges to a root’, i, x1 10. Stop. 3.14.2 Algorithm 2 (Aliter) 1. Define function f(x) 2. Define function df(x) 3. Get the value of a, max_err. 4. Initialize j 5. If df(a) 1 then b = 1, a = f(a) 6. Print root after j, iteration is f(a) 7. If fabs(b – a) max_err then 8. j++, goto (5) End if Else print root doesn’t exist 9. End.
  • 111. 98 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.15 FLOW-CHART FOR ITERATION METHOD START STOP Define F(x) Get the value of x and max_error 0 Set n = 0. x = f(x ) n+1 n n = n + 1 Is | x – x | max. error n+1 n Yes No Print the root is x . n
  • 112. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 99 3.16 COMPUTER PROGRAM //Program for Solution by ITERATION method #includestdio.h #includemath.h #includeconio.h #define EPS 0.00005 #define F(x) (x*x*x + 1)/2 #define f(x) x*x*x - 2*x + 1 void ITER(); void main () { clrscr(); printf(nt Solution by ITERATION method n); printf(nt Equation is ); printf(ntttt X*X*X - 2*X + 1 = 0nn); ITER(); getch(); } void ITER() { float x1,x2,x0,f0,f1,f2,error; int i=0,n; for(x1=1;;x1++) { f1=F(x1); if (f10) break; } for(x0=x1-1;;x0--) { f0=f(x0); if(f00) break; }
  • 113. 100 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES x2=(x0+x1)/2; printf(Enter the number of iterations:); scanf(%d,n); printf(nntt The 1 approximation to the root is: %f,x2); for(;in-1;i++) { f2=F(x2); printf(nntt The %d approximation to the root is: %f,i+2,f2); x2=F(x2); error=fabs(f2-f1); if(errorEPS) break; f1=f2; } if(errorEPS) printf(nnt NOTE:- The number of iterations are not sufficient.); printf(nnnttt------------------------------); printf(nttt The root is %.4f,f2); printf(nttt-----------------------------); } 3.16.1 Output Solution by ITERATION method Equation is x*x*x-2*x+1=0 Enter the number of iterations: 15 The 1 approximation to the root is: 0.000000 The 2 approximation to the root is: 0.500000 The 3 approximation to the root is: 0.562500 The 4 approximation to the root is: 0.588989 The 5 approximation to the root is: 0.602163 The 6 approximation to the root is: 0.609172 The 7 approximation to the root is: 0.613029
  • 114. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 101 The 8 approximation to the root is: 0.615190 The 9 approximation to the root is: 0.616412 The 10 approximation to the root is:0.617107 The 11 approximation to the root is:0.617504 The 12 approximation to the root is:0.617730 The 13 approximation to the root is:0.617860 The 14 approximation to the root is:0.617934 The 15 approximation to the root is:0.617977 ----------------------------------------------------- The Root is 0.6179 (Correct to four decimal places) ----------------------------------------------------- 3.16.2 Insufficient Output Solution by ITERATION method Equation is x*x*x-2*x+1=0 Enter the number of Iterations:5 The 1 approximation to the root is: 0.000000 The 2 approximation to the root is: 0.500000 The 3 approximation to the root is: 0.562500 The 4 approximation to the root is: 0.588989 The 5 approximation to the root is: 0.602163 The number of Iterations are not sufficient. ----------------------------------------------------- The Root is 0.6022 EXAMPLES Example 1. Use the method of iteration to find a positive root between 0 and 1 of the equation xex = 1. Sol. Writing the equation in the form x = e–x we find, φ(x) = e–x so φ′(x) = – e–x Hence, | φ′(x) | 1 for x 1, which assures that iteration is convergent. NOTE
  • 115. 102 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Starting with x0 = 1, we find that successive iterates are given by x1 = 1 e = 0.3678794 x = e– 0.3678794 = 0.6922006 x20 = 0.5671477. Example 2. Find a real root of the equation cos x = 3x – 1 correct to 3 decimal places using iteration method. Sol. We have f(x) = cos x – 3x + 1 = 0 Now, f(0) = 2 and f(π/2) = – 3 2 π + 1 = (–)ve ∴ A root lies between 0 and π/2. Rewriting the given equation as x = 1 3 (cos x + 1) = φ(x) We have φ′(x) = – sin x 3 and | φ′(x) | = 1 3 | sin x | 1 in (0, π/2) Hence the iteration method can be applied and we start with x0 = 0. Then the successive approximations are x1 = φ(x0) = 1 3 (cos 0 + 1) = 0.6667 x2 = φ(x1) = 1 3 [cos 0.6667 + 1] = 0.5953 x3 = φ(x2) = 1 3 [cos (0.5953) + 1] = 0.6093 x4 = φ(x3) = 0.6067 x5 = φ(x4) = 0.6072 x6 = φ(x5) = 0.6071. Since x5 and x6 are almost the same, the root is 0.607 correct to three decimal places.
  • 116. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 103 Example 3. Find a real root of 2x – log10 x = 7 correct to four decimal places using the iteration method. Sol. We have f(x) = 2x – log10 x – 7 f(3) = 6 – log 3 – 7 = 6 – 0.4771 – 7 = – 1.4471 f(4) = 0.398 ∴ A root lies between 3 and 4. Rewriting the given equation as x = 1 2 (log10 x + 7) = φ(x), we have φ′(x) = 1 2 1 10 x e log F HG I KJ ∴ | φ′(x) | 1 when 3 x 4 (∵ log10 e = 0.4343) Since | f(4) | | f(3) |, the root is near 4. Hence the iteration method can be applied. The successive approximations of x0 = 3.6 are x1 = φ(x0) = 1 2 (log10 3.6 + 7) = 3.77815 x2 = φ(x1) = 1 2 (log10 3.77815 + 7) = 3.78863 x3 = φ(x2) = 3.78924 x4 = φ(x3) = 3.78927 Since x3 and x4 are almost equal, the root is 3.7892, correct to four decimal places. Example 4. Find the smallest root of the equation 1 – x + x (2 !) x (3 !) x (4 !) x (5 !) ...... 0 2 2 3 2 4 2 5 2 − + − + = . Sol. Writing the given equation as x = 1 + x x x x x 2 2 3 2 4 2 5 2 2 3 4 5 ( !) ( !) ( !) ( !) ...... ( ) − + − + = φ and omitting x2 and higher powers of x, we get x = 1 approximately.
  • 117. 104 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Taking x0 = 1, we obtain, x1 = φ(x0) = 1 1 2 1 3 1 4 1 5 2239 2 2 2 2 + − + − + = ( !) ( !) ( !) ( !) ...... 1. x2 = φ(x1) = 1 2239 2239 2239 4 2239 5 2 3 4 2 5 2 + − + − + ( ) ( ) ( ) ( !) ( ) ( !) ...... 1. (2 !) 1. (3!) 1. 1. 2 2 = 1.3263 Similarly, x3 = φ(x2) = 1.38 x4 = 1.409, x5 = 1.425, x6 = 1.434, x7 = 1.439, x8 = 1.442 Values of x7 and x8 indicate that the root is 1.44, correct to two decimal places. Example 5. If α, β are the roots of x2 + ax + b = 0, show that the iteration xn + 1 = – ax b x n n + F HG I KJ will converge near x = α if | α | | β | and the iteration xn + 1 = − + b x a n will converge near x = α if | α | | β |. Sol. Since α, β are the roots of x2 + ax + b = 0, we have α + β = – a and αβ = b The formula xn + 1 = – ax b x n n + F HG I KJ, which is of the form xn + 1 = f(xn), will converge to x = α if d dx ax b x x xn − + R S T U V W = ( ) 1 Using condition of iteration method ⇒ b xn 2 1 ⇒ | xn 2 | | b | or xn 2 | b | or | α |2 | b | as xn → α or | α |2 | α | | β | (∵ αβ = b) or | α | | β |
  • 118. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 105 Similarly, xn + 1 = − + b x a n will converge to x = α if d dx b x a x xn − + F HG I KJ L NM O QP = 1 or b x a n ( ) + 2 1 or (xn + a)2 | b | or (α + a)2 | b | as xn → α or β2 | b | (∵ α + a = – β) or | β |2 | α | | β | or | β | | α | or | α | | β |. Example 6. Show that the following rearrangement of equation x3 + 6x2 + 10x – 20 = 0 does not yield a convergent sequence of successive approximations by iteration method near x = 1, x = (20 – 6x2 – x3)/10. Sol. Here, x = 20 6 10 2 3 − − x x = f(x) Hence, f ′(x) = − − 12 3 10 2 x x Clearly, f ′(x) – 1 in neighborhood of x = 1. Hence | f ′(x) | 1, and neither the method nor the sequence xn converge. Example 7. Suggest a value of constant k, so that the iteration formula x = x + k(x2 – 3) may converge at a good rate, given that x = 3 is a root. Sol. Formula x = f(x) where f(x) = x + k(x2 – 3) will converge if | f ′(x) | 1 or – 1 f ′(x) 1 i.e., if – 1 1 + 2kx 1 Moreover, the convergence will be rapid if f ′(a) ~ – 0 i.e., if 1 + 2ka ~ – 0 i.e., 1 + 2k 3 ~ – 0 ⇒ k = – 1 2 3
  • 119. 106 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES We may take k = – 1 4 to insure a rapid convergence by this formula. Example 8. If F(x) is sufficiently differentiable and the iteration xn + 1 = F(xn) converges, prove that the order of convergence is a positive integer. Sol. Let x = a be a root of the equation x = F(x) then, a = F(a) Let, for some p(positive integer) F′(a) = 0, F″(a) = 0, ...... , F(p – 1) (a) = 0 and F(p) (a) ≠ 0 then expanding F(xn) about a, we get xn + 1 = F(xn) = F(a + xn – a) = F(a) + (xn – a) F′(a) + ...... + ( ) ( ) ! ( ) ( ) ! ( ) ( ) ( ) x a p a x a p n p p n p p − − + − − − 1 1 1 F F ξ where ξ is some point between x = xn and x = a. ⇒ xn + 1 = a + ( ) ! ( ) ( ) x a p n p p − F ξ ⇒ xn + 1 – a = (xn – a) p . F( ) ( ) ! p p ξ ∴ The order of convergence is p, a positive integer. Example 9. The equation sin x = 5x – 2 can be written as x = sin–1 (5x – 2) and also as x = 1 5 (sin x + 2), suggesting two iterating procedures for its solution. Which of these, if either, would succeed, and which would fail to give a root in the neighborhood of 0.5? Sol. In case I, φ(x) = sin–1 (5x – 2) ∴ φ′(x) = 5 1 5 2 2 − − ( ) x Hence, | φ′(x) | 1 for all x for which (5x – 2)2 1 or x 3/5 or x 0.6 in neighborhood of 0.5. Thus the method would not give a convergent sequence. In case II, φ(x) = 1 5 (sin x + 2) ∴ φ′(x) = 1 5 cos x
  • 120. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 107 Hence | φ′(x) | ≤ 1 5 for all x because | cos x | ≤ 1 ∴ φ(x) will succeed. Hence, taking x = φ(x) = 1 5 (sin x + 2) and the initial value x0 = 0.5, we have the first approximation x1 given by x1 = 1 5 (sin 0.5 + 2) = 0.4017 x2 = 1 5 [sin (0.4017) + 2] = 0.4014 x3 = 1 5 [sin (0.4014) + 2] = 0.4014 Hence, up to four decimal places, the value of the required root is 0.4014. Example 10. Starting with x = 0.12, solve x = 0.21 sin (0.5 + x) by using the iteration method. Sol. Here, x = 0.21 sin (0.5 + x) ∴ First approximation of x is given by x(1) = 0.21 sin (0.5 + 0.12) = 0.122 x(2) = 0.21 sin (0.5 + 0.122) = 0.1224 Similarly, x(3) = 0.12242, x(4) = 0.12242 Obviously, x(3) = x(4) Hence the required root is 0.12242. Example 11. Find a real root of the equation f(x) = x3 + x2 – 1 = 0 by using the iteration method. Sol. Here, f(0) = – 1 and f(1) = 1 so a root lies between 0 and 1. Now, x = 1 1 + x so that, φ(x) = 1 1 + x ∴ φ′(x) = – 1 2 1 3 2 ( ) / + x
  • 121. 108 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES We have, | φ′(x) | 1 for x 1 Hence the iterative method can be applied. Take x0 = 0.5, we get x1 = φ(x0) = 1 5 1. = 0.81649 x2 = φ(x1) = 1 81649 1. = 0.74196 x8 = 0.75487. Example 12. Find the reciprocal of 41 correct to 4 decimal places by iterative formula xi + 1 = xi(2 – 41xi). Sol. Iterative formula is xi + 1 = xi (2 – 41 xi) (5) Putting i = 0, x1 = x0(2 – 41 x0) Let x0 = 0.02 x1 = (0.02) (2 – 0.82) = 0.024 Put i = 1 in (5), x2 = (0.024) {2 – (41 × 0.024)} = 0.0244 Put i = 2, x3 = 0.02439 ∴ Reciprocal of 41 is 0.0244. Example 13. Find the square root of 20 correct to 3 decimal places by using recursion formula xi + 1 = 1 2 x 20 x i i + F HG I KJ. Sol. Put i = 0, x1 = 1 2 20 0 0 x x + F HG I KJ Let x0 = 4.5 ∴ x1 = 1 2 4 5 20 4 5 . . + F HG I KJ = 4.47 Put i = 1, x1 = 4.47, x2 = 1 2 4 47 20 4 47 . . + F HG I KJ = 4.472
  • 122. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 109 Put i = 2, x2 = 4.472, x3 = 4.4721 ∴ 20 ~ – 4.472 correct to three decimal places. Example 14. Find the cube root of 15 correct to four significant figures by iterative method. Sol. Let x = (15)1/3 ∴ x3 – 15 = 0 The real root of the above equation lies in (2, 3). The equation may be written as x = 15 20 20 3 + − x x = φ(x) Now, φ′(x) = 1 – 3 20 2 x ∴ | φ′(x) | 1 (for x ≈ 2.5) Iterative formula is xi + 1 = 15 20 20 3 + − x x i i (6) Put i = 0, x0 = 2.5, we get x1 = 2.47 Put i = 1 in (6), x2 = 2.466 (where x1 = 2.47) Similarly, x3 = 2.4661 ∴ 15 3 correct to 3 decimal places is 2.466. Example 15. The equation x4 + x = e where e is a small number has a root close to e. Computation of this root is done by the expression α = e – e4 + 4e7. (i) Find an iterative formula xn+1 = F(xn), x0 = 0 for the computation. Show that we get the above expression after three iterations when neglecting terms of higher order. (ii) Give a good estimate (of the form Nek, where N and k are integers) of the maximum error when the root is estimated by the above expression. Sol. x4 + x = e may be written as x = e x3 1 + Consider the formula xn+1 = e xn 3 1 + Starting with x0 = 0, we get x1 = e
  • 123. 110 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES x2 = e e 1 3 + = e(1 + e3)–1 = e(1 – e3 + e6 – ...) = e – e4 + e7 (neglecting higher powers of e) x3 = e e e e 1 4 7 3 + − + ( ) = e – e4 + 4e7 (neglecting higher powers of e) Taking α = e – e4 + 4e7, we find that error = α4 + α – e = (e – e4 + 4e7)4 + (e – e4 + 4e7) – e = 22e10 + higher powers of e. ASSIGNMENT 3.2 1. Apply iteration method to solve e–x = 10x. L NM Hint: | φ′(x) | = 1 10 1 ex 1 if x ≥ 0. O QP 2. Find by iterative method, the real root of the equation 3x – log10 x = 6 correct to four significant figures. 3. Solve by iteration method: (i) 1 + log x = x 2 (ii) sin x = x x + − 1 1 (iii) x3 = x2 + x + 1 near 2 (use 5 iterations) (iv) x3 + x + 1 = 0 (v) x3 – 2x2 – 5 = 0 (vi) x3 – 2x2 – 4 = 0. 4. Use the iterative method to find, correct to four significant figures, a real root of each of the following equations: (i) x = 1 1 2 ( ) x + (ii) x = (5 – x)1/3 (iii) sin x = 10(x – 1) (iv) x sin x = 1 (v) ex = cot x (vi) 1 + x2 – x3 = 0 (vii) x2 – 1 = sin2 x (viii) 5x3 – 20x + 3 = 0. 5. By iteration method, find 30 . 6. The root of the equation x = 1 2 + sin x by using the iteration method xn+1 = 1 2 + sin xn, x0 = 1
  • 124. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 111 x = 1.497300 is correct to 6 decimal places. Determine the number of iteration steps required to reach the root by the linear iteration. 7. The equation f(x) = 0, where f(x) = 0.1 – x + x x x 2 2 3 2 4 2 2 3 4 ( !) ( !) ( !) − + – ... has one root in the interval (0, 1). Calculate this root correct to 5 decimal places. 8. Find a catenary y = c cosh x a c − F HG I KJ passing through the points (1, 1) and (2, 3). [Hint: Eliminate a from c cosh 1 − F HG I KJ a c = 1 and c cosh 2 − F HG I KJ a c = 3 to get c = 1 1 3 1 1 + F HG I KJ F HG I KJ − − c c c cosh cosh = φ(c)] 9. The equation x2 + ax + b = 0 has two real roots, α and β. Show that the iteration method xn+1 = – x b a n 2 + F HG I KJ is convergent near x = α if 2 | α | | α + β |. 10. The equation x3 – 5x2 + 4x – 3 = 0 has one root near x = 4 which is to be computed by the iteration xn+1 = 3 4) 5 2 3 + − + − (k x x x k n n n , k integer; x0 = 4 (i) Determine which value of k will give the fastest convergence. (ii) Using this value of k, iterate three times and estimate the error in x3. [Hint: Put xn = α + en, α = 4 + δ, where α is the exact root. Find the error eqn. ken+1 = (k – 12) en + O(δen)] 3.17 THE METHOD OF ITERATION FOR SYSTEM OF NON-LINEAR EQUATIONS Let the equation be f(x, y) = 0, g(x, y) = 0 whose real roots are required within a specified accuracy. We assume, x = F(x, y) and y = G(x, y) where functions F and G satisfy conditions
  • 125. 112 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∂ ∂ + ∂ ∂ F F x y 1 and ∂ ∂ + ∂ ∂ G G x y 1 in neighborhood of root. Let (x0, y0) be the initial approximation to a root (α, β) of the system. We then construct successive approximations as x1 = F(x0, y0), y1= G(x0, y0) x2 = F(x1, y1), y2 = G(x1, y1) x3 = F(x2, y2), y3 = G(x2, y2) ........................................................ xn + 1 = F(xn, yn), yn + 1 = G(xn, yn) If the iteration process converges, we get α = F(α, β) β = G(α, β) in the limit. Thus α, β are the roots of the system. Example. Find a real root of the equations by the iteration method. x = 0.2x2 + 0.8, y = 0.3xy2 + 0.7. Sol. We have F(x, y) = 0.2x2 + 0.8 G(x, y) = 0.3xy2 + 0.7 ∂ ∂ F x = 0.4x ∂ ∂ G x = 0.3y2 ∂ ∂ F y = 0 ∂ ∂ G y = 0.6xy It is easy to see that x = 1 and y = 1 are the roots of the system. Choosing x0 = 1 2 , y0 = 1 2 , we find that ∂ ∂ + ∂ ∂ = F F x y x y x y ( , ) ( , ) . 0 0 0 0 0 2 1 and ∂ ∂ + ∂ ∂ = G G x y x y x y ( , ) ( , ) . 0 0 0 0 0 225 1
  • 126. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 113 ∴ Conditions are satisfied. Hence, x1 = F(x0, y0) = 0 2 4 . + 0.8 = 0.85 and y1 = G(x0, y0) = 0 8 .3 + 0.7 = 0.74* For approximation II, we obtain x2 = F(x1, y1) = 0.2(0.85)2 + 0.8 = 0.9445 and y2 = G(x1, y1) = 0.3(0.85) × (0.74)2 + 0.7 = 0.81 Convergence to the root (1, 1) is obvious. 3.18 METHOD OF FALSE POSITION Or REGULA-FALSI METHOD The bisection method guarantees that the iterative process will converge. It is, however, slow. Thus, attempts have been made to speed up** the bisection method retaining its guaranteed convergence. A method of doing this is called the method of false position. It is sometimes known as the method of linear interpolation. This is the oldest method for finding the real roots of a numerical equation and closely resembles the bisection method. In this method, we choose two points x0 and x1 such that f(x0) and f(x1) are of opposite signs. Since the graph of y = f(x) crosses the X-axis between these two points, a root must lie in between these points. Consequently, f(x0) f(x1) 0 Y O X {x , f(x )} 0 0 {x , f(x )} 1 1 P(x) x0 x3 x2 x1 B A *y1 can also be obtained more accurately by assigning the value of x1 = 0.85. **Order of convergence greater than 1.
  • 127. 114 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The equation of the chord joining points {x0, f(x0)} and {x1, f(x1)} is y – f(x0) = f x f x x x x x ( ) ( ) ( ) 1 0 1 0 0 − − − The method consists in replacing the curve AB by means of the chord AB and taking the point of intersection of the chord with the X-axis as an approximation to the root. So the abscissa of the point where the chord cuts y = 0 is given by x2 = x0 – x x f x f x f x 1 0 1 0 0 − − ( ) ( ) ( ) (7) which is an approximation to the root. If f(x0) and f(x2) are now of opposite signs, then the root lies between x0 and x2. So replacing x1 with x2 in (7), we obtain the next approximation, x3. However, the root could also lie between x1 and x2 and then we find x3 accordingly. This procedure is repeated until the root is found to the desired accuracy. The order of convergence of the Regula Falsi method is 1.618. 3.19 ALGORITHM Step 01. Start of the program. Step 02. Input the variables x0, x1, e, n for the task. Step 03. f0 = f(x0) Step 04. f1 = f(x1) Step 05. for i = 1 and repeat if i = n Step 06. x2 = (x0 f1-x1 f0)/(f1-f0) Step 07. f2 = x2 Step 08. if | f2 | = e Step 09. Print “convergent”, x2, f2 Step 10. If sign (f2) ! = sign (f0) Step 11. x1 = x2 f1 = f2 Step 12. else Step 13. x0 = x2 f0 = f2 Step 14. End loop Step 15. Print output Step 16. End of program. NOTE
  • 128. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 115 3.19.1 Aliter Algorithm: Method of False Position 1. Read x0, x1, e, n x0 and x1 are two initial guesses to the root such that sign f(x0) ≠ sign f(x1). The prescribed precision is e and n is maximum number of iterations. Steps 2 and 3 are initialization steps. 2. f0 ← f(x0) 3. f1 ← f(x1) 4. For i = 1 to n in steps of 1 do 5. x2 ← (x0 f1 – x1f0)/(f1 – f0) 6. f2 ← f(x2) 7. If | f2 | ≤ e then 8. Begin write ‘convergent solution’, x2, f2 9. Stop end 10. If sign (f2) ≠ sign (f0) 11. Then begin x1 ← x2 12. f1 ← f2 end 13. Else begin x0 ← x2 14. f0 ← f2 end end for 15. Write ‘Does not converge in n iterations’ 16. Write x2, f2 17. Stop. NOTE
  • 129. 116 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.20 FLOW-CHART START Define function f(x) Define function regula Get the value of x , x , aerr, mitr 0 1 initialize itr Call function regula with x , x , x f(x ), f(x ), itr 2 0 1 0 1 Call function regula with x , x , x f(x ), f(x ), itr 3 0 1 0 1 A B A x = x 1 2 x = x 0 2 Yes Yes Yes No No No Is f(x )*f(x ) 0 0 2 Is fabs (x – x ) aerr 3 2 C x = x 2 3 Is itr maxitr Print Not convergent STOP B
  • 130. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 117 A C x = x – (x – x )/(f(x ) – f(x ))*f(x ) 0 1 0 1 0 0 Print itr, x Print ‘‘solution’’ Return RETURN EXAMPLES Example 1. Find a real root of the equation 3x + sin x – ex = 0 by the method of false position correct to four decimal places. Also write its program in ‘C’ language. Sol. Let f(x) ≡ 3x + sin x – ex = 0 f(0.3) = – 0.154 i.e., (–)ve and f(0.4) = 0.0975 i.e., (+)ve ∴ The root lies between 0.3 and 0.4. Using Regula Falsi method, x2 = x0 – x x f x f x f x 1 0 1 0 0 − − ( ) ( ) ( ) = − − − − − ( ) ( . ) ( ) ( . ) ( ) ( ) 0 0 4 0 0 0975 0 0 .3 .3 .154 .154 | ∵ x0 = 0.3 and x1 = 0.4 (let) = + × F HG I KJ = ( ) 0 0 0 0 0 .3 .1 .154 .2515 .3612 Now f(x2) = f(0.3612) = 0.0019 = (+)ve
  • 131. 118 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence, the root lies between 0.3 and 0.3612. Now again, x3 = x0 – ( ) ( ) ( ) ( ) x x f x f x f x 2 0 2 0 0 − − Replacing by 1 2 x x = (0.3) .154 .154 − − − − R S T U V W − ( . ) ( . ) ( . ) ( ) ( ) 0 3612 0 3 0 0019 0 0 = (0.3) .1559 .154 + F HG I KJ = 0 0612 0 0 0 3604 . ( ) . Now f(x3) = f(0.3604) = – 0.00005 = (–)ve ∴ The root lies between 0.3604 and 0.3612. Now again, x4 = x x x f x f x f x 3 2 3 2 3 3 − − − R S T U V W ( ) ( ) ( ) Replacing by 0 3 x x = − − − − L NM O QP − ( . ) ( . . ) ( . ) ( . ) ( . ) 0 3604 0 3612 0 3604 0 0019 0 00005 0 00005 = + F HG I KJ 0 3604 0 0008 0 00195 . . . (0.00005) = 0.36042 Since x3 and x4 are approximately the same, the required real root is 0.3604, correct to four decimal places. /* ******************************************************** Program to Implement the Method of Regula Falsi (False Position) ******************************************************** */ // ... Included Header files #includestdio.h #includemath.h #includeconio.h #includestring.h #includeprocess.h //...Formulae declaration #define EPS 0.00005 #define f(x) 3*x+sin(x)-exp(x)
  • 132. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 119 //...Function Declaration Prototype void FAL_POS(); //...Main Execution Thread void main() { clrscr(); printf(n Solution by FALSE POSITION methodn); printf(n Equation is ); printf(nttt 3*x + sin(x)-exp(x)=0nn); FAL_POS(); } //...Function Definition void FAL_POS() { float f0,f1,f2; float x0,x1,x2; int itr; int i; printf(Enter the number of iteration:); scanf(%d,itr); for(x1=0.0;;) { f1=f(x1); if(f10) { break; { else { x1=x1+0.1; } } x0=x1-0.1; f0=f(x0);
  • 133. 120 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(ntt-----------------------------------------); printf(ntt ITERATIONt x2tt F(x)n); printf(tt--------------------------------------------); for(i=0;iitr;i++) { x2=x0-((x1-x0)/(f1-f0))*f0; f2=f(x2); if(f0*f20) { x1=x2; f1=f2; } else { x0=x2; f0=f2; } if(fabs(f(2))EPS) { printf(ntt%dt%ft%fn,i+1,x2,f2); } } printf(tt--------------------------------------------); printf(nttttRoot=%fn,x2); printf(tt-------------------------------------------); getch(); } OUTPUT Solution by FALSE POSITION method Equation is 3*x+sin(x)-exp(x)=0 Enter the number of iteration: 11
  • 134. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 121 ---------------------------------------------------- ITERATION X2 F(x) ---------------------------------------------------- 1 0.361262 0.002101 2 0.360409 -0.000031 3 0.360422 0.000000 4 0.360422 -0.000000 5 0.360422 0.000000 6 0.360422 0.000000 7 0.360422 0.000000 8 0.360422 0.000000 9 0.360422 0.000000 10 0.360422 0.000000 11 0.360422 0.000000 ---------------------------------------------------- Root=0.360422 ---------------------------------------------------- Example 2. Find the root of the equation xex = cos x in the interval (0, 1) using Regula-Falsi method correct to four decimal places. Write its computer programme in ‘C’ language. Sol. Let f(x) = cos x – xex = 0 so that f(0) = 1, f(1) = cos 1 – e = – 2.17798 i.e., the root lies between 0 and 1. By Regula-Falsi method, x2 = x0 – ( ) ( ) ( ) ( ) x x f x f x f x 1 0 1 0 0 − − = − − − = 0 1 0 3 1 0 31467 .17798 ( ) . Now f(x2) = f(0.31467) = 0.51987 i.e., the root lies between 0.31487 and 1. Again x3 = 0.31487 – ( ) ( . ) 1 0 2 0 51987 − − − .31487 .17798 (0.51987) = 0.44673
  • 135. 122 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now f(x3) = 0.20356 ∴ The root lies between 0.44673 and 1. Repeating this process, x10 = 0.51775, corrected as 0.5177 up to 4 decimal places. COMPUTER PROGRAMME METHOD OF FALSE POSITION #includestdio.h #includeconio.h #includemath.h float f(float x) { return cos(x)-x*exp(x); } void regula (float *x, float x0,float x1, float fx0, float fx1,int*itr) { *x=x0-((x1-x0)/(fx1-fx0))*fx0; ++(*itr); printf(Iteration no.%3d x=%7.5fn,*itr,*x); } main() { int itr=0,maxitr; float x0,x1,x2,x3,aerr; printf(Enter the values for x0,x1, allowed error, max.iterationn); scanf(%f%f%f%d,x0,x1,aerr,maxitr); regula(x2,x0,x1,f(x0),f(x1),itr); do { if(f(x0)*f(x2)0) x1=x2; else x0=x2; regula(x3,x0,x1,f(x0),f(x1),itr); if(fabs(x3-x2)aerr)
  • 136. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 123 { printf(After %d iterations, root=%6.4fn,itr,x3); getch(); return (0); } x2=x3; }while (itrmaxitr); printf(Solution does not converge, iterations not sufficientn); getch(); return(1); OUTPUT Enter the values for x0,x1, allowed error, max.iteration 0 1 .00005 20 Iteration number 1 x = 0.31467 Iteration number 2 x = 0.44673 Iteration number 3 x = 0.49402 Iteration number 4 x = 0.50995 Iteration number 5 x = 0.51520 Iteration number 6 x = 0.51692 Iteration number 7 x = 0.51748 Iteration number 8 x = 0.51767 Iteration number 9 x = 0.51773 Iteration number 10 x = 0.51775 After 10 iterations, root = 0.5177 Example 3. Find a real root of the equation x3 – 2x – 5 = 0 by the method of false position correct to three decimal places. Sol. Let f(x) = x3 – 2x – 5 so that f(2) = – 1 and f(3) = 16 i.e., A root lies between 2 and 3. Using Regula-Falsi method, x2 = x0 – ( ) ( ) ( ) ( ) x x f x f x f x 1 0 1 0 0 − −
  • 137. 124 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 2 – ( ) ( ) 3 2 16 1 − + (– 1) = 2.0588 Now f(x2) = f(2.0588) = – 0.3908 i.e., The root lies between 2.0588 and 3. Now again, x3 = 2.0588 – 3 0588 16 0 − + F HG I KJ 2. .3908 (– 0.3908) = 2.0813 Repeating this process, the successive approximations are x4 = 2.0862 ...... x8 = 2.0943 etc. Hence, the root is 2.094, correct to three decimal places. Example 4. Find the root of the equation tan x + tanh x = 0 which lies in the interval (1.6, 3.0) correct to four significant digits using the method of false position. Sol. Let f(x) ≡ tan x + tanh x = 0 Since f(2.35) = – 0.03 and f(2.37) = 0.009 Hence, the root lies between 2.35 and 2.37. Using Regula-Falsi method, x2 = x x x f x f x f x 0 1 0 1 0 0 − − − R S T U V W ( ) ( ) ( ) = − − + F HG I KJ − 2 35 2 37 2 35 0 009 0 03 0 03 . . . . . ( . ) Let and x x 0 1 2 35 2 37 = = . . = + F HG I KJ = 2 35 0 02 0 039 0 03 2 365 . . . ( . ) . Now f(x2) = – 0.00004 (–)ve Hence, the root lies between 2.365 and 2.37. Using Regula-Falsi method, x3 = x2 – x x f x f x f x 1 2 1 2 2 − − R S T U V W ( ) ( ) ( ) Replacing by x x 0 2 = − − + F HG I KJ − 2 365 2 37 2 365 0 009 0 00004 0 00004 . . . . . ( . )
  • 138. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 125 = + F HG I KJ = 2 365 0 005 0 00904 0 00004 2 365 . . . ( . ) . Hence, the required root is 2.365, correct to four significant digits. Example 5. Using the method of false position, find the root of the equation x6 – x4 – x3 – 1 = 0 up to four decimal places. Sol. Let f(x) = x6 – x4 – x3 – 1 f(1.4) = – 0.056 f(1.41) = 0.102 Hence, the root lies between 1.4 and 1.41. Using the method of false position, x2 = x0 – x x f x f x f x 1 0 1 0 0 − − R S T U V W ( ) ( ) ( ) = − − + F HG I KJ − 1. 1. 1. .102 4 41 4 0 0 056 0 056 . ( . ) Let, 1. and 1. x x 0 1 4 41 = = = + F HG I KJ = 1. .158 1. 4 0 01 0 0 056 4035 . ( . ) Now f(x2) = – 0.0016 (–)ve Hence, the root lies between 1.4035 and 1.41. Using the method of false position, x3 = x x x f x f x f x 2 1 2 1 2 2 − − − R S T U V W ( ) ( ) ( ) Replacing by x x 0 2 = − − + F HG I KJ − 1. 1. 1. 4035 41 4035 0 102 0 0016 0 0016 . . ( . ) = + F HG I KJ = 1. .1036 1. 4035 0 0065 0 0 0016 4036 . ( . ) Now f(x3) = – 0.00003 (–)ve Hence, the root lies between 1.4036 and 1.41. Using the method of false position, x4 = x3 – x x f x f x f x 1 3 1 3 3 − − R S T U V W ( ) ( ) ( )
  • 139. 126 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = + − + F HG I KJ 1. 1. 1. .102 4036 41 4036 0 0 00003 0 00003 . ( . ) = + F HG I KJ = 1. .10203 1. 4036 0 0064 0 0 00003 4036 . ( . ) Since x3 and x4 are approximately the same up to four decimal places, the required root of the given equation is 1.4036. Example 6. Find a real root of the equation x log10 x = 1.2 by Regula-Falsi method correct to four decimal places. Sol. Let f(x) = x log10 x – 1.2 Since f(2.74) = – .0005634 and f(2.741) = .0003087 Hence, the root lies between 2.74 and 2.741. Using the method of False position, x2 = x x x f x f x f x 0 1 0 1 0 0 − − − R S T U V W ( ) ( ) ( ) Let and x x 0 1 2 74 2 741 = = . . = 2 74 2 741 2 74 0003087 0005634 0005634 . . . . ( . ) ( . ) − − − − R S T U V W − = 2.74 + . . (. ) 001 0008721 0005634 F HG I KJ = 2.740646027 Now f(x2) = – .00000006016 i.e., (–)ve Hence, the root lies between 2.740646027 and 2.741. Using the method of false position, x3 = x x x f x f x f x 2 1 2 1 2 2 − − − R S T U V W ( ) ( ) ( ) | Replacing x0 by x2 = 2.740646027 – 2 741 2 740646027 0003087 00000006016 00000006016 . . . . ( . ) − + F HG I KJ − = 2.740646096 Since x2 and x3 agree up to seven decimal places, the required root, correct to four decimal places, is 2.7406.
  • 140. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 127 Example 7. (i) Apply False-position method to find the smallest positive root of the equation x – e–x = 0 correct to three decimal places. (ii) Find a positive root of xex = 2 by the method of false position. Sol. (i) Let f(x) = x – e–x Since f(.56) = – .01121 and f(.58) = .0201 Hence, the root lies between .56 and .58. Let x0 = .56 and x1 = .58 Using the method of false position, x2 = x x x f x f x f x 0 1 0 1 0 0 − − − R S T U V W ( ) ( ) ( ) = . . . . . ( . ) 56 58 56 0201 01121 01121 − − + F HG I KJ − = .56716 Now f(x2) = .00002619 i.e., (+)ve Hence, the root lies between .56 and .56716. Using the method of false position, x3 = x x x f x f x f x 0 2 0 2 0 0 − − − R S T U V W ( ) ( ) ( ) | Replacing x1 by x2 = . . . . . ( . ) 56 56716 56 00002619 01121 01121 − − + F HG I KJ − = .567143 Since x2 and x3 agree up to four decimal places, the required root correct to three decimal places is 0.567. (ii) Let f(x) = xex – 2 Since f(.852) = – .00263 and f(.853) = .001715 The root lies between .852 and .853. Let x0 = .852 and x1 = .853 Using the method of false position, x2 = x x x f x f x f x 0 1 0 1 0 0 − − − R S T U V W ( ) ( ) ( )
  • 141. 128 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = . . . . ( . ) ( . ) 852 853 852 001715 00263 00263 − − − − R S T U V W − = .852605293 Now f(x2) = – .00000090833 Hence, the root lies between .852605293 and .853 Using the method of false position, x3 = x x x f x f x f x 2 1 2 1 2 2 − − − R S T U V W ( ) ( ) ( ) | Replacing x0 by x2 = (.852605293) – . . ( . ) ( . ) 853 852605293 001715 00000090833 00000090833 − − − R S T U V W − = 0.852605501 Since x2 and x3 agree up to 6 decimal places, the required root correct to 6 decimal places is 0.852605. Example 8. (i) Solve x3 – 5x + 3 = 0 by using Regula-Falsi method. (ii) Use the method of false position to solve x3 – x – 4 = 0. Sol. (i) Let f(x) = x3 – 5x + 3 Since f(.65) = .024625 and f(.66) = – .012504 The root lies between .65 and .66. Let x0 = .65 and x1 = .66 Using the method of false position, x2 = x0 – x x f x f x f x 1 0 1 0 0 − − R S T U V W ( ) ( ) ( ) = .65 – . . . . (. ) 66 65 012504 024625 024625 − − − F HG I KJ = .656632282 Now f(x2) = – .00004392 Hence, the root lies between .65 and .656632282. Using the method of false position, x3 = x0 – x x f x f x f x 2 0 2 0 0 − − R S T U V W ( ) ( ) ( ) Replacing by x x 1 2
  • 142. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 129 = . . . . . (. ) 65 656632282 65 00004392 024625 024625 − − − − F HG I KJ = .656620474. Since x2 and x3 agree up to 4 decimal places, the required root is .6566, correct up to four decimal places. Similarly, the other roots of this equation are 1.8342 and – 2.4909. (ii) Let f(x) = x3 – x – 4 Since f(1.79) = – .054661 and f(1.80) = .032 The root lies between 1.79 and 1.80 Let x0 = 1.79 and x1 = 1.80 Using the method of false position, x2 = x x x f x f x f x 0 1 0 1 0 0 − − − R S T U V W ( ) ( ) ( ) = 1.79 1.80 1.79 − − − − R S T U V W − . ( . ) ( . ) 032 054661 054661 = 1.796307 Now, f(x2) = – .00012936 Hence, the root lies between 1.796307 and 1.80. Using the method of false position, x3 = x x x f x f x f x 2 1 2 1 2 2 − − − R S T U V W ( ) ( ) ( ) = 1.796307 – 1.8 1.796307 .032 ( .00012936) ( .00012936) − − − R S T U V W − = 1.796321. Since x2 and x3 are the same up to four decimal places, the required root is 1.7963, correct up to four decimal places.
  • 143. 130 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.21 CONVERGENCE OF REGULA-FALSI METHOD If xn is the sequence of approximations obtained from xn + 1 = xn – ( ) ( ) ( ) ( ) x x f x f x f x n n n n n − − − − 1 1 (8) and α is the exact value of the root of the equation f(x) = 0, then Let xn = α + en xn + 1 = α + en + 1 where en, en + 1 are the errors involved in nth and (n + 1)th approximations, respectively. Clearly, f(α) = 0. Hence, (8) gives α + en + 1 = α + en – ( ) ( ) ( ) . ( ) e e f e f e f e n n n n n − + − + − − 1 1 α α α + or en + 1 = e f e e f e f e f e n n n n n n − − − + − + + − + 1 1 1 ( ) ( ) ( ) ( ) α α α α = + ′ + ″ + L NMM O QPP − + ′ + ″ + L N MM O Q PP + ′ + ″ + L NMM O QPP − + ′ + ″ + L N MM O Q PP − − − − − e f e f e f e f e f e f f e f e f f e f e f n n n n n n n n n n 1 2 1 1 2 2 1 1 2 2 2 2 2 ( ) ( ) ! ( ) ...... ( ) ( ) ! ( ) ...... ( ) ( ) ! ( ) ...... ( ) ( ) ! ( ) ...... α α α α α α α α α α α α = − + − ″ + − ′ + − + ″ + − − − − − − ( ) ( ) ! ( ) ( ) ...... ( ) ( ) ( ) ( ) ! ( ) ...... e e f e e e e f e e f e e e e f n n n n n n n n n n n n 1 1 1 1 1 1 2 2 α α α α = ″ + ′ + + F HG I KJ ″ + − − e e f f e e f n n n n 1 1 2 2 ( ) ...... ( ) ( ) ...... α α α | ∵ f(α) = 0
  • 144. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 131 or en + 1 ≈ e e f f n n − ″ ′ 1 2 ! ( ) ( ) α α (9) (neglecting high powers of en, en – 1) Let en + 1 = c en k , where c is a constant and k 0. ∴ en = c ek n – 1 or en – 1 = c–1/k en 1/k ∴ From (9), c en k ≈ e c e f f n k n k − ″ ′ 1/ 1/ 2 ! . ( ) ( ) α α = ″ ′ − + c e f f k n k 1/ 1 1/ 2 ! . ( ) ( ) α α Comparing the two sides, we get k = 1 + 1 k and c = c f f k − ″ ′ 1/ 2 ! ( ) ( ) α α Now, k = 1 + 1 k ⇒ k2 – k – 1 = 0 ⇒ k = 1.618 Also, c = c–1/k . 1 2 ! ( ) ( ) f f ″ ′ α α c c f f k 1 1 1 2 + = = ″ ′ 1.618 ( ) ( ) α α or c = f f ″ ′ L NM O QP ( ) ( ) α α 2 0.618 This gives the rate of convergence and k = 1.618 gives the order of convergence. ASSIGNMENT 3.3 1. Solve x3 – 9x + 1 = 0 for the root lying between 2 and 4 by the method of false position. 2. Find real cube root of 18 by Regula-Falsi method. 3. Find the smallest positive root correct to three decimal places of the equation cosh x cos x = – 1. 4. Determine the real roots of f(x) = x3 – 98 using False position method within Es = 0.1%. 5. Write a short note on Regula-Falsi method. 6. Using the False-position method, find x when x2 – 9 = 0. Give computer program using ‘C’.
  • 145. 132 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7. Find the real root of the equations (i) x3 – 4x + 1 = 0 (ii) x3 – x2 – 2 = 0 (iii) x3 + x – 3 = 0 (iv) x3 – 5x – 7 = 0 by using the method of false-position. 8. Find the real root of the equations (i) x4 – x3 – 2x2 – 6x – 4 = 0 (ii) x6 – x4 – x3 – 3 = 0 (iii) xex = 3 (iv) x2 – loge x – 12 = 0 (v) x = tan x (vi) 3x = cos x + 1 by using the method of false position. 9. (i) Explain Regula-Falsi method by stating at least one advantage over the bisection method. (ii) Discuss the method of false position. 10. Solve the following equations by Regula-Falsi method. (i) (5 – x) ex = 5 near x = 5 (ii) x3 + x – 1 = 0 near x = 1 (iii) 2x – log10 x = 7 lying b/w 3.5 and 4 (iv) x3 + x2 – 3x – 3 = 0 lying b/w 1 and 2 (v) x3 – 3x + 4 = 0 b/w – 2 and – 3 (vi) x4 + x3 – 7x2 – x + 5 = 0 lying b/w 2 and 3. 11. Find the rate of convergence for Regula-Falsi method. 12. Illustrate the false position method by plotting the function on a graph and discuss the speed of convergence to the root. Develop the algorithm for computing the roots using the false-position technique. 13. Find all the roots of cos x – x2 – x = 0 to 5 decimal places. 14. A root of the equation f(x) = x – φ(x) = 0 can often be determined by combining the iteration method with Regula-Falsi. (i) With a given approximate value x0, we compute x1 = φ(x0), x2 = φ(x1) (ii) Observing that f(x0) = x0 – x1 and f(x1) = x1 – x2, we find a better approximation x′ using Regula-Falsi on the points (x0, x0 – x1) and (x1, x1 – x2). (iii) This last x′ is taken as a new x0 and we start from (i) all over again. Compute the smallest root of the equation x – 5 loge x = 0 with an error less than 0.5 × 10–4 starting with x0 = 1.3. 3.22 SECANT METHOD This method is quite similar to that of the Regula-Falsi method except for the condition f(x1) . f(x2) 0. Here the graph of the function y = f(x) in the neighborhood of the root is approximated by a secant line or chords. Further, the interval at each iteration may not contain the root. Let the limits of interval initially be x0 and x1.
  • 146. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 133 Then the first approximation is given by: x2 = x1 – x x f x f x 1 0 1 0 − − L NM O QP ( ) ( ) f(x1) Again, the formula for successive approximation in general form is xn+1 = xn – x x f x f x n n n n − − L NM O QP − − 1 1 ( ) ( ) f(xn) If at any stage f(xn) = f(xn–1), this method will fail. Hence this method does not always converge while the Regula-Falsi method will always converge. The only advantage in this method lies in the fact that if it converges, it will converge more rapidly than the Regula-Falsi method. x2 x1 x0 x3 X Y o Secant Method EXAMPLES Example 1. A real root of the equation f(x) = x3 – 5x + 1 = 0 lies in the interval (0, 1). Perform four iterations of the secant method. Sol. We have, x0 = 0, x1 = 1, f(x0) = 1, f(x1) = – 3 By Secant Method, The first approximation is x2 = x1 – x x f x f x 1 0 1 0 − − L NM O QP ( ) ( ) f(x1) = 0.25 f(x2) = – 0.234375.
  • 147. 134 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The second approximation is x3 = x2 – x x f x f x 2 1 2 1 − − L NM O QP ( ) ( ) f(x2) = 0.186441 f(x3) = 0.074276 The third approximation is x4 = x3 – x x f x f x 3 2 3 2 − − L NM O QP ( ) ( ) f(x3) = 0.201736 f(x4) = – 0.000470 The fourth approximation is x5 = x4 – x x f x f x 4 3 4 3 − − L NM O QP ( ) ( ) f(x4) = 0.201640. Example 2. Compute the root of the equation x2e–x/2 = 1 in the interval [0, 2] using the secant method. The root should be correct to three decimal places. Sol. We have, x0 = 1.42, x1 = 1.43, f(x0) = – .0086, f(x1) = .00034. By secant method, The first approximation is x2 = x1 – x x f x f x 1 0 1 0 − − L NM O QP ( ) ( ) f(x1) = 1.43 – 1.43 1.42 .00034 .0086 − + F HG I KJ (.00034) = 1.4296 f(x2) = – .000011 The second approximation is x3 = x2 – x x f x f x 2 1 2 1 − − L NM O QP ( ) ( ) f(x2) = 1.4296 – 1.4296 1.42 .000011 .00034 − − − F HG I KJ (– .000011) = 1.4292 Since x2 and x3 agree up to three decimal places, the required root is 1.429.
  • 148. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 135 ASSIGNMENT 3.4 1. Write the procedure of the secant method to find a root of a polynomial equation to implement it in ‘C’. 2. The equation x2 – 2x – 3 cos x = 0 is given (i) Locate the smallest root in magnitude in an interval of length one unit. (ii) Hence, find this root correct to 3 decimal points using the secant method. 3. Use the secant method to determine the root of the equation cos x – xex = 0. Now we proceed to discuss some methods useful for obtaining the complex roots of polynomial equations f(x) = 0. 3.23 LIN-BAIRSTOW’S METHOD OR METHOD FOR COMPLEX ROOT This method is applied to obtain complex roots of an algebraic equation with real coefficients. The complex roots of such an equation occur in pairs a ± ib. Each such pair corresponds to a quadratic factor {x – (a + ib)}{x – (a – ib)} = x2 – 2ax + a2 + b2 = x2 + px + q where coefficients p and q are real. Let f(x) = xn + a1 xn – 1 + ...... + an – 1 x + an If we divide f(x) by x2 + px + q, we obtain a quotient Qn – 2 = xn – 2 + b1 xn – 3 + ...... + bn – 2 and a remainder Rn = Rx + S Thus, f(x) = (x2 + px + q) (xn – 2 + b1 xn – 3 + ...... + bn – 2) + Rx + S (10) If x2 + px + q divides f(x) completely, the remainder Rx + S = 0 i.e., R = 0, S = 0. Therefore, R and S depend upon p and q. Our problem is to find p and q such that R(p, q) = 0, S(p, q) = 0 (11) Let p + Δp, q + Δq be the actual values of p and q which satisfy (11), then, R(p + Δp, q + Δq) = 0; S(p + Δp, q + Δq) = 0 To find the corrections Δp, Δq, we have the following equations: cn – 2 Δp + cn – 3 Δq = bn – 1 (cn – 1 – bn – 1) Δp + cn – 2 Δq = bn
  • 149. 136 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES After finding the values of bi’ s and ci’ s by synthetic division scheme, we obtain approximate values of Δp and Δq, say Δp0 and Δq0. If p0, q0 are the initial approximations, then their improved values are p1 = p0 + Δp0, q1 = q0 + Δq0. Now, taking p1 and q1 as the initial values and repeating the process, we can get better values of p and q. 1. Synthetic division scheme is as follows a0 (= 1) a1 a2 a3 ...... an – 2 an – 1 an – pb0 – pb1 – pb2 ...... – pbn – 3 – pbn – 2 – pbn – 1 – p – qb0 – qb1 ...... – qbn – 4 – qbn – 3 – qbn – 2 – q b0 (= 1) b1 b2 b3 ...... bn – 2 bn – 1 bn – pc0 – pc1 – pc2 ...... – pcn – 3 – pcn – 2 – p – qc0 – qc1 ...... – qcn – 4 – qcn – 3 – q c0 (= 1) c1 c2 c3 ...... cn – 2 cn – 1 2. Values of p0 and q0 should be given, otherwise we pick values of p and q which make R and S both zero. 3. Bairstow’s method works well only if the starting trial values of p and q are close to the correct values. In this case the convergence is quite rapid. If the starting values are arbitrarily chosen, then the method does not converge but very often diverges. 4. Δp, Δq provide new guesses. The process is repeated until the approximate error falls below the prespecified tolerance. | ∈p | = Δp p i i 1 + × 100% and | ∈q | = Δq q i i 1 + × 100%. EXAMPLES Example 1. Solve x4 – 5x3 + 20x2 – 40x + 60 = 0 given that all the roots of f(x) = 0 are complex, by using Lin-Bairstow method. Take the values as p0 = – 4, q0 = 8. NOTE
  • 150. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 137 Sol. Starting with the values p0 = – 4, q0 = 8, we have 1 – 5 20 – 40 60 – 4 – 4 32 0 4 – 8 8 – 64 – 8 1 – 1 8 0(= bn – 1) – 4(= bn) 4 12 48 4 – 8 – 24 – 8 1 3(= cn – 3) 12(= cn – 2) 24(= cn – 1) ∴ cn – 1 – bn – 1 = 24 – 0 = 24 (12) Corrections Δp0 and Δq0 are given by cn – 2 Δp0 + cn – 3 Δq0 = bn – 1 ⇒ 12 Δp0 + 3 Δq0 = 0 (13) and (cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn ⇒ 24 Δp0 + 12 Δq0 = – 4 (14) Solving (13) and (14), we get Δp0 = 0.1667, Δq0 = – 0.6667 ∴ p1 = p0 + Δp0 = – 3.8333 q1 = q0 + Δq0 = 7.3333 Also, | ∈p | = Δp p 0 1 × 100% = 0.1667 3.8333 − × 100% = 4.3487% and | ∈q | = Δq q 0 1 × 100% = − .6667 7.3333 × 100% = 9.0914%
  • 151. 138 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, repeating the same process, i.e., dividing f(x) by x2 – 3.8333x + 7.3333, we get 1 – 5 20 – 40 60 3.8333 – 4.4723 31.4116 – 0.125 3.8333 – 7.3333 8.5558 – 60.092 – 7.3333 1 – 1.1667 8.1944 – 0.0326 – 0.217 | | bn − F HG I KJ 1 | | bn F HG I KJ 3.8333 10.2219 42.4845 3.8333 – 7.3333 – 19.555 – 7.3333 1 2.6666 11.083 22.8969 (= cn – 3) (= cn – 2) (= cn – 1) ∴ cn – 1 – bn – 1 = 22.8969 – (– 0.0326) = 22.9295 Corrections Δp1 and Δq1 are given by 11.083 Δp1 + 2.6666 Δq1 = – 0.0326 22.9295 Δp1 + 11.083 Δq1 = – 0.217 Solving, we get Δp1 = 0.0033 Δq1 = – 0.0269 ∴ p2 = p1 + Δp1 = – 3.83 q2 = q1 + Δq1 = 7.3064 Also, | ∈p | = Δp p 1 2 × 100% = 0.0033 3.83 − × 100% = .08616% and | ∈q | = Δq q 1 2 × 100% = − 0.0269 7.3064 × 100% = .3682% So, one of the quadratic factors of f(x) is x2 – 3.83x + 7.3064 (15)
  • 152. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 139 If α ± iβ are its roots, then, 2α = 3.83, α2 + β2 = 7.3064 giving, α = 1.9149, β = 1.9077 Hence, the pair of roots is 1.9149 ± 1.9077i To find the remaining two roots of f(x) = 0, we divide f(x) by (15) as follows 1 – 5 20 – 40 60 3.83 – 4.4811 31.4539 3.83 – 7.3064 8.5485 – 60.0038 – 7.3064 1 – 1.17 8.2125 0.0024 – .0038 ≈ 0 ≈ 0 The other quadratic factor is x2 – 1.17x + 8.2125 If γ ± iδ are its roots, then 2δ = 1.17, γ2 + δ2 = 8.2125 giving, γ = 0.585, δ = 2.8054 Hence, the pair of roots is 0.585 ± 2.8054 i. Example 2. Find a quadratic factor of the polynomial x4 + 5x3 + 3x2 – 5x – 9 = 0 starting with p0 = 3, q0 = – 5 by using Bairstow’s method. Sol. We have 1 5 3 – 5 – 9 – 3 – 6 – 6 3 – 3 5 10 10 5 1 2 2 – 1(= bn – 1) 4(= bn) – 3 3 – 30 – 3 5 – 5 5 1 – 1 10 – 36 ↓ ↓ ↓ cn – 3 cn – 2 cn – 1 ∴ cn – 1 – bn – 1 = – 36 + 1 = – 35 Corrections Δp0 and Δq0 are given by cn – 2 Δp0 + cn – 3 Δq0 = bn – 1 ⇒ 10 Δp0 – Δq0 = – 1 (16) and (cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn ⇒ – 35 Δp0 + 10 Δq0 = 4 (17)
  • 153. 140 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Solving (16) and (17), we get Δp0 = – 0.09, Δq0 = 0.08 Thus p1, q1, the first approximations of p and q are given by p1 = p0 + Δp0 = 2.91 q1 = q0 + Δq0 = – 4.92 | ∈p | = Δp p 0 1 × 100% = − 0.09 2.91 × 100% = 3.0927% | ∈q | = Δq q 0 1 × 100% = 0.08 4.92 − × 100% = 1.6260%. Repeating the same process, i.e., dividing f(x) by x2 + 2.91x – 4.92, we get 1 5 3 – 5 – 9 – 2.91 – 6.08 – 5.35 0.20 – 2.91 4.92 10.28 9.05 4.92 1 2.09 1.84 – 0.07 0.25 – 2.91 2.37 – 26.57 – 2.91 4.92 – 4.03 4.92 1 – 0.82 9.13 – 30.67 At this step, the corrections Δp1 and Δq1 are given by 9.13 Δp1 – 0.82 Δq1 = – 0.07 – 30.60 Δp1 + 9.13 Δq1 = 0.25 ⇒ Δp1 = – 0.00745 Δq1 = 0.00241 Hence, the second approximations of p and q are given by p2 = p1 + Δp1 = 2.91 – 0.00745 = 2.90255 q2 = q1 + Δq1 = – 4.92 + 0.00241 = – 4.91759
  • 154. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 141 | ∈p | = Δp p 1 2 × 100% = − 0.00745 2.90255 × 100% = .2566% | ∈q | = Δq q 1 2 × 100% = 0.00241 4.91759 − × 100% = .04901%. Thus, a quadratic factor is x2 + 2.90255 x – 4.91759 Dividing the given equation by this factor, we can obtain the other quadratic factor. ASSIGNMENT 3.5 1. Find the quadratic factor of x3 – 3.7x2 + 6.25x – 4.069 after two iterations. Use p0 = – 2.5, q0 = 0. 2. Solve the equation x4 – 8x3 + 39x2 – 62x + 50 = 0 starting with p = q = 0. 3. Find the quadratic factor of x4 – 3x3 + 20x2 + 44x + 54 = 0 close to x2 + 2x + 2. [Hint: Take p0 = 2, q0 = 2] 3.24 MULLER’S METHOD In this method, f(x) is approximated by a second degree curve in the vicinity of a root. The roots of the quadratic are then assumed to be the approximations to the roots of the equation f(x) = 0. The method is iterative, converges almost quadratically, and can be used to obtain complex roots. Let xi – 2, xi – 1, xi be the three distinct approximations to a root of f(x) = 0 and let yi – 2, yi – 1, yi be the corresponding values of y = f(x). Assuming that P(x) = A(x – xi)2 + B(x – xi) + yi is the parabola passing through the points (xi – 2, yi – 2), (xi –1, yi – 1) and (xi, yi), we have yi – 1 = A(xi – 1 – xi)2 + B(xi – 1 – xi) + yi (18) and yi – 2 = A(xi – 2 – xi)2 + B(xi – 2 – xi) + yi (19)
  • 155. 142 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES From equations (18) and (19), we get yi – 1 – yi = A(xi – 1 – xi)2 + B(xi – 1 – xi) (20) and yi – 2 – yi = A(xi – 2 – xi)2 + B(xi – 2 – xi) (21) Solution of equations (20) and (21) gives, A = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 1 1 2 1 2 1 2 (22) and B = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 2 1 1 2 2 2 1 1 2 (23) with the values of A and B given in (22) and (23), the quadratic equation now gives next approximation xi + 1. ∴ xi + 1 – xi = − ± − B B A A 2 4 2 yi (24) A direct solution from (24) leads to inaccurate results and therefore it is usually written in the form, xi + 1 – xi = − ± − 2 4 y y i i B B A 2 (25) In (25), sign in denominator should be chosen so that the denominator will be largest in magnitude. With this choice, equation (25) gives the next approximation to the root. 3.25 ALGORITHM OF MULLER’S METHOD Step 01. Start of the program. Step 02. Input the variables xi, xi1, xi2 Step 03. Input absolute error-aerr Step 04. Repeat Steps 5-12 until |Xn-Xi| aerr Step 05. Yi = y(Xi) Step 06. Yil = y(Xi1) Step 07. Yi2 = y(Xi2) Step 08. a = A(Xi, Xi1, Xi2, Yi, Yi1, Yi2) Step 09. b = B(Xi, Xi1, Xi2, Yi, Yi1, Yi2);
  • 156. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 143 Step 10. Xn = approx (Xi, Yi, a, b); Step 11. Check loop condition Step 12. if no Step 13. exit loop Step 14. if yes Step 15. Xi = Xn Step 16. increment i Step 17. End loop Step 18. Print output Step 19. End of program Step 20. Start of section A Step 21. take Xa, Xb, Xc, Ya, Yb, Yc Step 22. x = ((Yb-Ya)*(Xc-Xa)-(Yc-Ya)*(Xb-Xa))/((Xb-Xa)*(Xc-Xa) *(Xb-Xc)) Step 23. Return x Step 24. End of section A Step 25. Start of section B Step 26. Take Xa, Xb, Xc, Ya, Yb, Yc Step 27. c = (((Yc-Ya)*pow((Xb-Xa),2))-((Yb-Ya) *pow((Xc-Xa),2)))/((Xb-Xa)*(Xc-Xa)*(Xb-Xc)) Step 28. Return c Step 29. End of section B Step 30. Start of section approx Step 31. Take x, y, a, b Step 32. c = sqrt(b*b-4*a*y) Step 33. If (b + c) (b-c): t = x-((2*y)/(b + c)) Step 34. Else: t = (x-((2*y)/(b-c))) Step 35. Return t Step 36. End of section approx
  • 157. 144 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.26 FLOW-CHART FOR MULLER’S METHOD Start Define fn. y(x) Get initial approximation in array x Get values of aerr, maxitr Loop for itr = 1 to maxitr Calculate li, di, mu, s Is mu 0 Yes No li = (2*y(x[0])*di)/(– mu + s) li = (2*yx[I]*di)/(– mu + s) x[I + 1] = x[I] + 1 * (x[I] – x[I – 1]) A
  • 158. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 145 A Print itr, x(1) Is fabs (x[1] – x[0]) aerr Yes No Loop for i = 0 to 2 x[i] = x[i + 1] End loop (i) End loop (itr) Print 'solution does not converge Print ‘‘solution’’ Stop EXAMPLE Example. Using Muller’s method, find the root of the equation y(x) = x3 – 2x – 5 = 0 which lies between 2 and 3. Write its program in ‘C’ language. Sol. Let xi – 2 = 1.9, xi – 1 = 2, xi = 2.1 then yi – 2 = – 1.941, yi – 1 = – 1, yi = .061
  • 159. 146 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 1 1 2 1 2 1 2 = ( .2) ( 1.061) ( .1) ( 2.002) (.1) ( .1) ( .2) − − − − − − − = . . . 2122 2002 002 − = 6 B = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 2 1 1 2 2 2 1 1 2 = ( .2) ( 1.061) ( .1) ( 2.002) ( .1) ( .1) ( .2) 2 2 − − − − − − − − = − + − . . . 04244 0 02002 002 = 11.21 The next approximation to the desired root is xi + 1 = xi – 2 4 2 y y i i B B A ± − = 2 1 2 061 1121 1121 24 061 2 . (. ) . ( . ) ( . ) − ± − × = 2.1 – 0.122 11.21 11.1445 + | Taking (+)ve sign = 2.094542 The procedure can now be repeated with the three approximations as 2, 2.1, and 2.094542. Let xi–2 = 2, xi–1 = 2.1 and xi = 2.094542 then yi–2 = – 1, yi–1 = .061 and yi = – .0001058 A = ( )( ) ( )( ) ( )( )( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 1 1 2 1 2 1 2 = ( )(. ) ( )( ) ( )( )( ) 2 061 1 2 2 − + − − − + − − − 2.094542 .0001058 2.1 2.094542 .0001058 2.1 2.1 2.094542 2.094542 = ( .094542)(.0611058) (.005458)( .9998942) (.1)(.005458)( .094542) − − − −
  • 160. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 147 = − + − .005777064 .005457422 .000051601 = − − .000319642 .000051601 = 6.194492 B = ( ) ( ) ( ) ( ) ( )( )( ) x x y y x x y y x x x x x x i i i i i i i i i i i i i i − − − − − − − − − − − − − − − − 2 2 1 1 2 2 2 1 1 2 = ( .094542) (.0611058) (.005458) ( .9998942) ( .1)(.005458)( .094542) 2 2 − − − − − = (. )(. ) (. )(. ) . 008938189 0611058 000029789 9998942 000051601 + = .000546175 + .000029785 .000051601 = 11.161799 The next approximation to the desired root is xi+1 = xi – 2 B B A 2 y y i i ± − 4 = 2.094542 – 2( .0001058) 11.161799 (11.161799) 4(6.194492)( .0001058) 2 − ± − − = 2.094542 + .0002116 11.161799 11.161916 + = 2.094551 Hence, the required root is 2.0945 correct up to 4 decimal places. The procedure can be repeated with the three approximations as 2.1, 2.094542, and 2.094551. /* ***************************************************** PROGRAM TO IMPLEMENT MULLER’S METHOD OF FINDING ROOTS ******************************************************** */ //...HEADER FILES DECLARATION #include stdio.h #include string.h #include conio.h
  • 161. 148 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES #include math.h #include process.h #include dos.h //... Function Prototype Declaration float y(float); float A(float,float,float,float,float,float); float B(float,float,float,float,float,float); float approx(float,float,float,float); void main() { //... Variable Declaration Field //... Floating Type float a,b; float Xi,Xi1,Xi2; float Yi,Yi1, Yi2; float Xn; float aerr; //... Integer Type int i=1; int loop=0; //... Invoke Function Clear Screen clrscr(); //...Input Section printf(nn ); printf(Enter the values of X(i),X(i-1),X(i-2), absolute errorn); printf(nn Enter the value of X(i) - ); scanf(%f,Xi); printf(nn Enter the value of X(i-1) - ); scanf(%f,Xi1); printf(nn Enter the value of X(i-2) - ); scanf(%f,Xi2);
  • 162. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 149 printf(nn Enter the value of Absolute Error – ); scanf(%f,aerr); printf(nn Processing ); for(loop=0; loop10;loop++) { delay(200); printf(...); } printf(nnn); //...Calculation And Processing Section while(1) { Yi=y(Xi); Yi1=y(Xi1); Yi2=y(Xi2); a=A(Xi,Xi1,Xi2,Yi,Yi1,Yi2); b=B(Xi,Xi1,Xi2,Yi,Yi1,Yi2); Xn=approx(Xi,Yi,a,b); printf(nn After Iteration %d value of x-%f,i,Xn); if(fabs(Xn-Xi)aerr) { goto jmp; } Xi=Xn; i++; } jmp: //...Output Section printf(nn After %d iterations root is-%6.6fn,i+1,Xn); //...Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch(); } //...Termination Of Main Execution Thread
  • 163. 150 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES //...Function y body float y(float x) { float t; t=(x*x*x)-(2*x)-5; return(t); } //...Termination of Function y //...Function A body float A(float Xa;float Xb,float Xc,float Ya,float Yb, float Yc) { float x; x=((Yb-Ya)*(Xc-Xa)-(Yc–Ya)*(Xb-Xa))/((Xb-Xa)*(Xc-Xa) *(Xb-Xc)); return(x); } //...Termination of function A //...Function B body float B(float Xa,float Xb,float Xc,float Ya,float Yb, float Yc) { float c; c=(((Yc-Ya)*pow((Xb-Xa),2))-((Yb-Ya)*pow((Xc-Xa),2))) /((Xb-Xa)*(Xc-Xa)*(Xb-Xc)); return(c); } //...Termination of Function B //...Function approx body float approx(float x,float y,float a,float b) { int c; float t;
  • 164. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 151 c=sqrt(b*b-4*a*y); if((b+c)(b-c)) { t=x-((2*y)/(b+c)); } else { t=(x-((2*y)/(b-c))); } return (t); } //...Termination of Function approx OUTPUT Enter the values of X(i),X(i-1),X(i-2), absolute error Enter the value of X(i) - 3 Enter the value of X(i-1) - 2 Enter the value of X(i-2) - 1 Enter the value of Absolute Error - 0.000001 Processing .................................. After Iteration 1 value of x - 2.085714 After Iteration 2 value of x - 2.094654 After Iteration 3 value of x - 2.094550 After Iteration 4 value of x - 2.094552 After Iteration 5 value of x - 2.094552 After 6 iteration root is - 2.094552 Press Enter to Exit ASSIGNMENT 3.6 1. Use Muller’s method to find a root of the equations: (i) x3 – x – 1 = 0 (ii) x3 – x2 – x – 1 = 0 which lie between 1 and 2. 2. Apply Muller’s method to find the root of the equation cos x = xex which lies between 0 and 1. 3. Using Muller’s method, find a root of the equations: (i) x3 – 3x – 5 = 0 which lie between 2 and 3 (ii) log x = x – 3 taking x0 = 0.25, x1 = 0.5 and x2 = 1
  • 165. 152 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (iii) x3 – 1 2 = 0 take x0 = 0, x1 = 1 and x2 = 1 2 . 4. Solve by Muller’s method: x3 + 2x2 + 10x – 20 = 0 by taking x = 0, x = 1, x = 2 as initial approximations. 3.27 THE QUOTIENT-DIFFERENCE METHOD This is a general method to obtain the approximate roots of polynomial equations. Let the given cubic equation be f(x) ≡ a0x3 + a1x2 + a2x + a3 = 0 (26) and let x1, x2, and x3 be its roots such that 0 | x1 | | x2 | | x3 |. The roots can be obtained, directly by considering the transformed equation a3x3 + a2x2 + a1x + a0 = 0 (27) whose roots are the reciprocals of those of (26). We then have 1 3 3 2 2 1 0 0 a x a x a x a x i i i + + + = = ∞ ∑ α so that, (a3 x3 + a2 x2 + a1x + a0) (α0 + α1x + α2x2 + ......) = 1 (28) Comparing the coefficients of like powers of x on both sides of (28), we get α0 = 1 0 a , α1 = − a a 1 0 2 , α2 = − + a a a a 2 0 2 1 2 0 3 Hence, q1 (1) = α α 1 0 1 0 = − a a q1 (2) = α α 2 1 2 0 1 2 0 1 = − a a a a a and so, Δ1 (1) = q1 (2) – q1 (1) = a a 2 1 , Δ2 (0) = a a 3 2 In general, Δm (m) = a a m m + 1 , m = 1, 2, 3, ......, (n – 1)
  • 166. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 153 qm (1 – m) = 0, m = 2, 3, ......, n (i.e., q1 (0), q2 (– 1), q3 (– 2), ......, top q’s are 0) We also set Δ0 (k) = Δn (k) = 0, for all k [i.e., First and last columns of Q-d table are zero]. Following is the Quotient-difference table for a cubic equation q1 (0) q2 (– 1) q3 (– 2) Δ0 (1) Δ1 (0) Δ2 (– 1) Δ3 (– 2) q1 (1) q2 (0) q3 (– 1) Δ0 (2) Δ1 (1) Δ2 (0) Δ3 (– 1) q1 (2) q2 (1) q3 (0) Δ0 (3) Δ1 (2) Δ2 (1) Δ3 (0) (i) If a Δ-element is at the top of a rhombus, then the product of one pair is equal to that of the other pair. For example, in rhombus Δ1 (1) q1 (2) q2 (1) Δ1 (2) we have Δ1 (1) . q2 (1) = Δ1 (2) . q1 (2) from which Δ1 (2) can be computed, since other quantities are known. (ii) If a q-element is at the top, then the sum of one pair is equal to that of the other pair. In the rhombus, q2 (0) Δ1 (1) Δ2 (0) q2 (1) we have q2 (0) + Δ2 (0) = q2 (1) + Δ1 (1) from which q2 (1) can be computed when q2 (0), Δ1 (1), Δ2 (0) are known.
  • 167. 154 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES As the building up of the table proceeds, the quantities q1 (i), q2 (i), q3 (i) tend to roots of cubic equations. The disadvantage of this method is that additional computation is also necessary. This method can be applied to find the complex roots and multiple roots of polynomials and also for determining the eigen values of a matrix. An important feature of this method is that it gives approximate values of all the roots simultaneously, enabling one to use this method to obtain the first approximation of all the roots and then apply a rapidly convergent method such as the generalized Newton method. EXAMPLE Example. Find the real roots of the equation x3 – 6x2 + 11x – 6 = 0 using the Quotient-difference method. Sol. Here, a0 = 1, a1 = – 6, a2 = 11, a3 = – 6 Now, q1 (1) = – a a 1 0 = 6 q1 (2) = a a a a a 2 0 1 2 0 1 11 36 6 − = − − = 4.167 Δ1 (1) = q1 (2) – q1 (1) = a a 2 1 = – 1.833 Also, q2 (0) = 0, q3 (– 1) = 0 Δ2 (0) = a a 3 2 6 11 = − = – 0.5454. The first two rows containing starting values of q1 (1) q2 (0) q3 (– 1) Δ0 (2) Δ1 (1) Δ2 (0) Δ3 (– 1) i.e., 6 0 0 0 – 1.833 – 0.5454 0
  • 168. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 155 The succeeding rows can be constructed as below: Δ0 q1 Δ1 q2 Δ2 q3 Δ3 6 0 0 0 – 1.833 – 0.5454 0 4.167 1.288 0.5454 0 – 0.5666 – 0.2310 0 3.600 1.624 0.7764 0 – 0.2556 – 0.1105 0 3.344 1.770 0.8869 0 – 0.1353 – 0.0553 0 3.209 1.8550 0.9422 0 – 0.0782 – 0.0281 0 3.131 1.9051 0.9703 0 – .0476 – .0143 0 3.083 1.9384 0.9846 0 – .0299 – .0073 0 3.053 1.961 .9919 0 – .0192 – .0037 0 3.0338 1.976 .9956 0 – .0125 – .0019 0 3.0213 1.987 .9975 It is evident that q1, q2, q3 are gradually converging to the roots 3, 2, and 1, respectively. ASSIGNMENT 3.7 1. Apply the quotient-difference method to obtain the approximate roots of the equation f(x) ≡ x3 – 7x2 + 10x – 2 = 0.
  • 169. 156 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3.28 HORNER’S METHOD This is the best method of finding the real root of a numerical polynomial equation. The method works as follows. Let a positive root of f(x) = 0 lie in between α and α + 1, where α is an integer. Then the value of the root is α . d1d2d3 ...... where α is the integral part and d1, d2, d3, ...... are the digits in the decimal part. Finding d1. First diminish the roots of f(x) = 0 by α so that the roots of the transformed equation lie between 0 and 1. i.e., the root of the transformed equation is 0 . d1d2d3 ...... Now multiply the roots of the transformed equation by 10 so that the root of the new equation is d1 . d2d3 ...... . Thus the first figure after the decimal place is d1. Again, diminish the root by d1 and multiply the roots of the resulting equation by 10 so that the root is d2 . d3 ...... i.e., the second figure after the decimal place is d2. Continue the process to obtain the root to any desired degree of accuracy digit by digit. EXAMPLE Example. Using Horner’s method, find the root of x3 + 9x2 – 18 = 0, correct to two decimal places. Sol. Let f(x) = x3 + 9x2 – 18 Then f(1) = 1 + 9 – 18 = – ve and f(2) = 8 + 36 – 18 = + ve i.e., f(1) and f(2) are of opposite signs. Hence f(x) = 0 has a root between 1 and 2. ∴ The integral part of the root of f(x) = 0 is 1. Now diminish the roots of the equation by 1. 1 1 9 0 – 18 0 1 10 10 1 1 10 10 – 8 0 1 11 1 1 11 21 0 1 1 12
  • 170. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 157 ∴ The transformed equation is x3 + 12x2 + 21x – 8 = 0. This equation has a root between 0 and 1. Multiply the roots of this equation by 10. ∴ The new equation is f1(x) = x3 + 120x2 + 2100x – 8000 = 0 We can see that f1(3) 0 and f1(4) 0 ∴ The root of f1(x) = 0 lies in between 3 and 4. Hence the first figure after the decimal place is 3. Now, diminish the roots of f1(x) = 0 by 3. 3 1 120 2100 – 8000 0 3 369 7407 3 1 123 2469 – 593 0 3 378 3 1 126 2847 0 3 3 129 The transformed equation is 3x3 + 129x2 + 2847x – 593 = 0, whose root lies between 0 and 1. Multiplying the roots of this equation by 10, we get the new equation: f2(x) = 3x3 + 1290x2 + 284700x – 593000 = 0 We can easily see that root of f2(x) lies between 2 and 3, since f2(2) 0 and f3(3) 0. ∴ The second figure after the decimal place is 2. Diminish the roots of f2(x) = 0 by 2 2 3 1290 284700 – 593000 0 6 2592 574584 2 3 1296 287292 – 18416 0 6 2604 2 3 1302 289896 0 6 3 1308 The transformed equation is 3x3 + 1308x2 + 289896x – 18416 = 0 whose root lies between 0 and 1.
  • 171. 158 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Multiplying the roots of this equation by 10, we get the new equation as f3(x) = 3x3 + 13080x2 + 28989600x – 18416000 = 0 We can easily see that f3(0) 0 and f3(1) 0, i.e., the root of f3(x) = 0 lies between 0 and 1. ∴ The third figure after the decimal is zero. We can stop here as the case requires that the root be correct to 2 decimals. Hence the root is 1.32. ASSIGNMENT 3.8 1. Find a root of the following equations correct to three decimal places using Horner’s method. (i) x3 + 3x2 – 12 x – 11 = 0 (ii) x4 + x3 – 4x2 – 16 = 0 (iii) x3 – 30 = 0. 2. Find the positive root of the equation x3 + x2 + x – 100 = 0, correct to four decimal places using Horner’s method. 3.29 NEWTON-RAPHSON METHOD This method is generally used to improve the result obtained by one of the previous methods. Let x0 be an approximate root of f(x) = 0 and let x1 = x0 + h be the correct root so that f(x1) = 0. Expanding f(x0 + h) by Taylor’s series, we get f(x0) + hf ′(x0) + h2 2! f″(x0) + ...... = 0 Since h is small, neglecting h2 and higher powers of h, we get f(x0) + hf ′(x0) = 0 or h = – f x f x ( ) ( ) 0 0 ′ (29) A better approximation than x0 is therefore given by x1, where x1 = x0 – f x f x ( ) ( ) 0 0 ′ Successive approximations are given by x2, x3, ....... , xn + 1, where xn + 1 = xn – f x f x n n ( ) ( ) ′ (30) (n = 0, 1, .......) which is the Newton-Raphson formula.
  • 172. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 159 1. This method is useful in cases of large values of f ′(x), i.e., when the graph of f(x) while crossing the x-axis is nearly vertical. 2. If f ′(x) is zero or nearly 0, the method fails. 3. Newton’s formula converges provided the initial approximation x0 is chosen sufficiently close to the root. In the beginning, we guess two numbers b and c such that f(b) and f(c) are of opposite signs. Then the first approximate root a lies between b and c. 4. This method is also used to obtain complex roots. 3.30 CONVERGENCE Comparing (30) with xn + 1 = φ (xn) of the iteration method, we get φ(xn) = xn + 1 = xn – f x f x n n ( ) ( ) ′ In general, φ(x) = x – f x f xn ( ) ( ) ′ which gives φ′(x) = f x f x f x ( ) ( ) [ ( )] ″ ′ 2 Since the iteration method converges if | φ′ (x) | 1 ∴ Newton’s method converges if | f (x) f ″ (x) | [ f ′ (x)]2 in the interval considered. Assuming f(x), f ′(x), and f ″(x) to be continuous, we can select a small interval in the vicinity of the root α in which the above condition is satisfied. The rate at which the iteration method converges if the initial approximation to the root is sufficiently close to the desired root is called the rate of convergence. 3.31 ORDER OF CONVERGENCE Suppose xn differs from the root α by a small quantity en so that xn = α + en and xn + 1 = α + en + 1 NOTE
  • 173. 160 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Then (30) becomes, en + 1 = en – f e f e n n ( ) ( ) α α + ′ + = en – f e f e f f e f n n n ( ) ( ) ! ( ) ...... ( ) ( ) ...... α α α α α + ′ + ″ + ′ + ″ + 2 2 (By Taylor’s expansion) = en – e f e f f e f n n n ′ + ″ + ′ + ″ + ( ) ( ) ....... ( ) ( ) ...... α α α α 2 2 | ∵ f(α) = 0 = e f f e f n n 2 2 ″ ′ + ″ ( ) [ ( ) ( )] α α α | Neglect high powers of en = en 2 2 f f e f f n ″ ′ + ″ ′ R S T U V W ( ) ( ) ( ) ( ) α α α α 1 = e f f e f f n n 2 1 2 1 . ( ) ( ) ( ) ( ) ″ ′ + ″ ′ R S T U V W − α α α α = e f f e f f n n 2 2 1 ″ ′ − ″ ′ + R S T U V W ( ) ( ) ( ) ( ) ....... α α α α = e f f e f f n n 2 3 2 2 2 ″ ′ − ″ ′ R S T U V W ( ) ( ) ( ) ( ) α α α α + ....... or e e n n +1 2 = 1 2 2 2 f f e f f n ″ ′ − ″ ′ R S T U V W ( ) ( ) ( ) ( ) α α α α + ....... ≈ f f ″ ′ ( ) ( ) α α 2 (Neglecting terms containing powers of en) Hence by definition, the order of convergence of Newton-Raphson method is 2, i.e., Newton-Raphson method is quadratic convergent. This also shows that subsequent error at each step is proportional to the square of the previous error and as such the convergence is quadratic. Hence, if at the first iteration we have an answer correct to one decimal place, then it should be correct to two places at the second iteration, and to four places at the third iteration. This means that the number of correct decimal places at each iteration is almost doubled.
  • 174. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 161 ∴ Method converges very rapidly. Due to its quadratic convergence, the formula (30) is also termed as a second order formula. 3.32 GEOMETRICAL INTERPRETATION Let x0 be a point near the root α of equation f(x) = 0, then tangent at A{x0, f(x0)} is y – f (x0) = f ′(x0) (x – x0) Y O X x2 A x1 x0 {x , f(x )} 0 0 A2 A1 y = f ( x ) a It cuts the x-axis at x1 = x0 – f x f x ( ) ( ) 0 0 ′ which is one approximation to root α. If A1 corresponds to x1 on the curve, then the tangent at A1 will cut the x-axis at x2, nearer to α and is therefore another approximation to root α. Repeating this process, we approach the root α quite rapidly. Hence the method consists of replacing the part of the curve between A and the x-axis by the means of the tangent to the curve at A0. 3.33 ALGORITHM OF NEWTON-RAPHSON METHOD Step 01. Start of the program Step 02. Input the variables x0, n for the task Step 03. Input Epsilon delta Step 04. for i = 1 and repeat if i = n Step 05. f0 = f(x0)
  • 175. 162 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Step 06. df0 = df(x1) Step 07. if |df0| = delta a. Print Slope too small b. Print x0, f0, df0, i c. End of Program Step 08. x1 = x0-(f0/df0) Step 09. if |(x1-x0)/x1| epsilon a. Print convergent b. Print x1, f(x1), i c. End of Program Step 10. x0 = x1 Step 11. End Loop 3.34 FLOW-CHART OF NEWTON–RAPHSON METHOD START Define function f(x) Define function d f(x) Get the values of x , aerr, maxitr 0 Loop for itr = 1 to maxitr h = f (x )/ d f(x ) x = x – h 0 0 1 0 Print itr, x1 Is fabs (h) aerr No x = x 0 1 Yes Print solution End loop (itr) STOP Print ‘‘solution does not converge” STOP
  • 176. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 163 3.35 NEWTON’S ITERATIVE FORMULAE FOR FINDING INVERSE, SQUARE ROOT 1. Inverse. The reciprocal or inverse of a number ‘a’ can be considered as a root of the equation 1 x – a = 0, which can be solved by Newton’s method. Since f(x) = 1 x – a, f ′(x) = – 1 2 x ∴ Newton’s formula gives xn + 1 = xn + 1 1 2 x a x n n − F HG I KJ F HG I KJ xn + 1 = xn (2 – axn) 2. Square root. The square root of ‘a’ can be considered a root of the equation x2 – a = 0, solvable by Newton’s method. Since f(x) = x2 – a, f ′(x) = 2x xn + 1 = xn – x a x n n 2 2 − xn + 1 = 1 2 x a x n n + F HG I KJ 3. Inverse square root. Equation is 1 2 x – a = 0 Iterative formula is xn + 1 = 1 2 xn (3 – a xn 2) 4. General formula for pth root. The pth root of a can be considered a root of the equation xp – a = 0. To solve this by Newton’s method, we have f(x) = xp – a and hence, f ′(x) = pxp – 1
  • 177. 164 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ The iterative formula is xn + 1 = xn – ( ) x a px n p n p − − 1 xn + 1 = ( ) p x a px n p n p − + − 1 1 Also, the general formula for the reciprocal of pth root of a is x n + 1 = xn p ax p n p + − F HG I KJ 1 . 3.36 RATE OF CONVERGENCE OF NEWTON’S SQUARE ROOT FOR- MULA Let a = α so that a = α2 . If we write xn = α 1 1 + − F HG I KJ e e n n then, xn + 1 = α 1 1 1 1 + − F HG I KJ + + e e n n (31) Also, by formula, xn + 1 = 1 2 x a x n n + F HG I KJ, we get xn + 1 = 1 2 1 1 1 1 α α + − F HG I KJ + − + F HG I KJ L N MM O Q PP e e a e e n n n n = α 1 1 2 2 + − F HG I KJ e e n n (32) (∵ a = α2) Comparing (31) and (32), we get en + 1 = en 2 confirming quadratic convergence of Newton’s method. 3.37 RATE OF CONVERGENCE OF NEWTON’S INVERSE FORMULA Let α = 1 a i.e., a = 1 α . If we write xn = α(1– en) then, xn + 1 = α (1 – en + 1)
  • 178. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 165 By formula, xn + 1 = xn (2 – axn), we get xn + 1 = α(1– en) [2 – aα (1– en)] = α(1– en 2) | ∵ aα = 1 Comparing, we get en+1 = en 2, hence, convergence is quadratic. EXAMPLES Example 1. Using Newton-Raphson method, find the real root of the equation 3x = cos x + 1 correct to four decimal places. Give computer program using ‘C’. Sol. Let f(x) = 3x – cos x – 1 Since f(0) = – 2 = (–)ve; f(1) = 1.4597 = (+)ve ∴ A root of f(x) = 0 lies between 0 and 1. It is nearer to 1. Let us take x0 = 0.6. Also, f ′(x) = 3 + sin x Newton’s iteration formula gives, xn + 1 = xn – f x f x n n ( ) ( ) ′ = xn – 3 1 3 x x x n n n − − + cos sin = x x x x n n n n sin cos sin + + + 1 3 If n = 0, the first approximation x1 is given by, x1 = x x x x 0 0 0 0 1 3 sin cos sin + + + = 0 6 6 0 6 1 3 0 6 . sin cos . sin . + + + = .6071 If n = 1, the second approximation is x2 = x x x x 1 1 1 1 1 3 sin cos sin + + + = . sin (. ) cos(. ) sin (. ) 6071 6071 6071 1 3 6071 + + + = 0.6071 Clearly x1 = x2. Hence the desired root is 0.6071, correct to 4 decimal places.
  • 179. 166 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES /* ******************************************************** Program made for NEWTON RAPHSON to solve the equation ******************************************************* * //....including source header files # include stdio.h # include conio.h # include math.h # include process.h # include string.h //....defining formulae # define f(x) 3*x -cos(x)-1 # define df(x) 3+sin(x) //...Function Declaration prototype void NEW_RAP(); //... Main Execution Thread void main() { clrscr(); printf (n Solution by NEWTON RAPHSON method n); printf (n Equation is: ); printf (nttt 3*X - COS X - 1=0 nn ); NEW_RAP(); getch(); } //...Function Declaration void NEW_RAP() { //...Internal Declaration Field long float x1,x0; long float f0,f1; long float df0; int i=1; int itr;
  • 180. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 167 float EPS; float error; /*Finding an Approximate ROOT of Given Equation, Having +ve Value*/ for(x1=0;;x1 +=0.01) { f1=f(x1); if (f1 0) { break; } } /*Finding an Approximate ROOT of Given Equation, Having -ve value*/ x0=x1-0.01; f0=f(x0); printf( Enter the number of iterations: ); scanf( %d,itr); printf( Enter the maximum possible error: ); scanf(%f,EPS); if (fabs(f0) f1) { printf(ntt The root is near to %.4fn,x1); } If (f1 fabs(f(x0))) { printf(ntt The root is near to %.4fn,x0); } x0=(x0+x1)/2; for(;i=itr;i++) { f0=f(x0); df0=df(x0); x1=x0 - (f0/df0); printf(ntt The %d approximation to the root is: %f,i,x1);
  • 181. 168 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES error=fabs(x1-x0); if(errorEPS) { break; } x0 = x1; } if(errorEPS) { prinf(nnt NOTE:- ); printf(The number of iterations are not sufficient.); } printf(nnnttt ------------------------------); printf(nttt The root is %.4f ,x1); printf(nttt ------------------------------); } OUTPUT Solution by NEWTON RAPHSON method Equation is: 3*X - cos X - 1=0 Enter the number of iterations: 10 Enter the maximum possible error: .0000001 The root is near to 0.6100 The 1 approximation to the root is:0.607102 The 2 approximation to the root is:0.607102 The 3 approximation to the root is:0.607102 -------------------------------- The root is 0.6071 -------------------------------- Example 2. Using Newton’s iterative method, find the real root of x log10 x = 1.2, correct to five decimal places. Sol. f(x) = x log10 x – 1.2 ∵ f(1) = – 1.2 = (–)ve f(3) = 3 log10 3 – 1.2 = (+)ve
  • 182. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 169 So a root of f(x) = 0 lies between 1 and 3. Let us take x0 = 2. and f ′(x) = log10 x + log10 e = log10 x + 0.43429 Newton’s iteration formula gives, xn + 1 = xn – f x f x n n ( ) ( ) ′ = xn – x x x n n n log . log . 10 10 12 43429 − + = .43429 1. .43429 x x n n + + 2 10 log (33) Given n = 0, the first approximation is x1 = .43429 1. .43429 x0 10 2 2 + + log = 2.81 (∵ x0 = 2) Similarly, given n = 1, 2, 3, 4 in (33), we get x2 = 2.741, x3 = 2.74064, x4 = 2.74065, x5 = 2.74065 Clearly, x4 = x5 Hence the required root is 2.74065, correct to five decimal places. Example 3. Evaluate 12 to four decimal places by Newton’s iterative method. Sol. Let x = 12 so that x2 – 12 = 0 (34) Take f(x) = x2 – 12, Newton’s iteration formula gives, xn + 1 = xn – f x f x n n ( ) ( ) ′ = xn – x x n n 2 12 2 − = 1 2 12 x x n n + F HG I KJ (35) Now, since f(3) = – 3 (–)ve f(4) = 4 (+)ve ∴ The root of (34) lies between 3 and 4. Given x0 = 3.5, (35) gives, x1 = 1 2 12 0 0 x x + F HG I KJ = 1 2 3 12 3 .5 .5 + F HG I KJ = 3.4643 x2 = 1 2 12 1 1 x x + F HG I KJ = 3.4641 x3 = 3.4641
  • 183. 170 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since x2 = x3 up to 4 decimal places, we have 12 = 3.4641. Example 4. Using Newton’s iterative method, find the real root of x sin x + cos x = 0 which is near x = π, correct to 3 decimal places. Sol. We have f(x) = x sin x + cos x and f ′(x) = x cos x The iteration formula is xn + 1 = xn – x x x x x n n n n n sin cos cos + with x0 = π, x1 = x0 – x x x x x 0 0 0 0 0 sin cos cos + = π – π π π π π sin cos cos + = 2.8233 Successive iteratives are x2 = 2.7986, x3 = 2.7984, x4 = 2.7984 Since x3 = x4, the required root is 2.798, correct to three decimal places. Example 5. Find a real root of the equation x = e–x using the Newton-Raphson method. Sol. We have f(x) = xex – 1 then, f ′(x) = (1+ x) ex Let x0 = 1 then, x1 = 1– e e − F HG I KJ 1 2 = 1 2 1 1 + F HG I KJ e = 0.6839397 Now, f(x1) = 0.3553424 and f ′(x1) = 3.337012 so that, x2 = 0.6839397 – 0 3553424 3 337012 . . = 0.5774545 Proceeding in this way, we obtain x3 = 0.5672297, x4 = 0.5671433 Hence the required root is 0.5671, correct to 4 decimal places. Example 6. Find to four decimal places, the smallest root of the equation e–x = sin x. Sol. The given equation is f(x) ≡ e–x – sin x = 0
  • 184. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 171 so that, xn + 1 = xn + e x e x x n x n n n − − − + sin cos Take x0 = .6 then, x1 = .58848, x2 = .588559 Hence, the desired value of the root is 0.5885. Example 7. (i) Find a positive value of (17)1/3, correct to four decimal places, by the Newton-Raphson method. (ii) Find the cube root of 10. Sol. (i) The iterative formula is xn + 1 = 1 3 2 2 x a x n n + F HG I KJ (36) Here a = 17 Take x0 = 2.5 ∵ 8 2 27 3 3 3 = = and Putting n = 0 in (36), we get x1 = 1 3 2 17 0 0 2 x x + F HG I KJ = 1 3 5 17 6 25 + F HG I KJ . = 2.5733 Putting n = 1 in (36), we get x2 = 1 3 2 17 1 1 2 x x + F HG I KJ = 1 3 5 1466 17 6 6220 . . + F HG I KJ = 2.5713 Again putting n = 2 in (36), we get x3 = 1 3 2 17 1 3 5 1426 17 6 61158 2 2 2 x x + F HG I KJ = + F HG I KJ . . = 2.57128 Putting n = 3 in (36), we get x4 = 1 3 2 17 1 3 5 14256 17 6 61148 3 3 2 x x + F HG I KJ = + F HG I KJ . . = 2.57128 Since x3 and x4 agree to four decimal places, the required root is 2.5713, correct to four decimal places. (ii) xn + 1 = 2 3 3 2 x a x n n + = 1 3 2 2 x a x n n + F HG I KJ
  • 185. 172 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Take x0 = 2.5 (∵ 8 3 = 2 and 27 3 = 3) ∴ x1 = 2.2 (n = 0) x2 = 2.155 (n = 1) x3 = 2.15466 (n = 2) ∴ 10 3 ≈ 2.15466. Example 8. Show that the following two sequences both have convergence of the second order with the same limit a. xn + 1 = 1 2 xn 1 a xn 2 + F HG I KJ and, xn + 1 = 1 2 xn 3 x a n 2 − F HG I KJ. Sol. Since, xn + 1 = 1 2 xn 1 2 + F HG I KJ a xn , we have xn + 1 – a = 1 2 xn 1 2 + F HG I KJ a xn – a = 1 2 x a x a n n + − F HG I KJ 2 = 1 2 x a x n n − F HG I KJ 2 = 1 2xn (xn – a)2 Thus, en + 1 = 1 2xn en 2 (37) which shows the quadratic convergence. Similarly for the second, xn + 1 – a = 1 2 xn 3 2 − F HG I KJ x a n – a = 1 2 xn 1 2 − F HG I KJ x a n + (xn – a) = x a n 2 (a – xn 2) + (xn – a) = (xn – a ) 1 − + L NM O QP x a x a n n 2 e j en + 1 = x a a n − 2 [2a – xn 2 – xn a] = x a a n − 2 [(a – xn 2) + (a – xn a)]
  • 186. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 173 = – x a a n − F HG I KJ 2 (xn – a ) (xn + 2 a ) en + 1 = – ( ) x a a n − 2 2 (xn + 2 a ) = – ( ) x a a n + 2 2 . en 2 (38) which shows the quadratic convergence. Example 9. If xn is a suitably close approximation to a, show that the error in the formula xn + 1 = 1 2 xn 1 a xn 2 + F HG I KJ is about 1 3 rd that in the formula, xn + 1 = 1 2 xn 3 x a n 2 − F HG I KJ, and deduce that the formula xn + 1 = x 8 n 6 3a x x a n 2 n 2 + − F HG I KJ gives a sequence with third order convergence. Sol. Since xn is very close to a en + 1 ~ − – x x x n n n 2 + F HG I KJ 2 2 en 2 | From (38) = 3 . 1 2xn en 2 (39) A simple observation shows that from (37) (see Ex. 8) and (39), the error in the first formula for en + 1 is about 1 3 rd of that in the second formula. To find the rate of convergence of the given formula, we have xn + 1 – a = xn 8 6 3 2 2 + − F HG I KJ a x x a n n – a = x x a a x ax n n n n ( ) 6 3 8 2 2 4 2 + − – a = 6 3 8 8 2 2 4 x a a x x a a x a n n n n + − − = − + − ( ) ( ) x a x a x a n n n 3 8 3 ∴ en + 1 = – x a x a n n + F HG I KJ 3 8 en 3 It shows that above formula has a convergence of third order.
  • 187. 174 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Exmaple 10. Apply Newton’s formula to find the values of (30)1/5. Sol. To find the pth root of a, we have xn + 1 = ( ) p x a p x n p n p − + − 1 1 Here, a = 30, p = 5, the first approximation is x1 = 4 30 5 0 5 0 4 x x + Take x0 = 1.9, we get x1 = 1.98 Again, x2 = 1.973 ∴ Value = 1.973 (correct to 3 decimal places). Example 11. Using the starting value 2(1 + i), solve x4 – 5x3 + 20x2 – 40x + 60 = 0 by Newton-Raphson method, given that all the roots of the given equation are complex. Sol. Let f(x) = x4 – 5x3 + 20x2 – 40x + 60 so that, f ′(x) = 4x3 – 15x2 + 40x – 40 ∴ Newton-Raphson method gives, xn + 1 = xn – f x f x n n ( ) ( ) ′ = xn – x x x x x x x n n n n n n n 4 3 2 3 2 5 20 40 60 4 15 40 40 − + − + − + − = 3 10 20 60 4 15 40 40 4 3 2 3 2 x x x x x x n n n n n n − + − − + − Put n = 0, take x0 = 2(1 + i) by trial, we get x1 = 1.92 (1 + i) Again, x2 = 1.915 + 1.908 i Since imaginary roots occur in conjugate pairs roots are 1.915 ± 1.908 i up to 3 decimal places. Assuming the other pairs of roots to be α ± iβ, then Sum = α β α β + + − + + + − F H GG I K JJ i i i i 1915 1908 1915 1908 . . . . = 2α + 3.83 = 5 ⇒ α = 0.585
  • 188. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 175 Also, the product of the roots = (α2 + β2) [(1.915)2 + (1.908)2] = 60 ⇒ β = 2.805 Hence, the other two roots are 0.585 ± 2.805 i. Example 12. Obtain Newton-Raphson’s extended formula x1 = x0 – f(x ) f (x ) 0 0 ′ – 1 2 . {f(x )} . f (x ) {f (x )} 0 2 0 0 3 ″ ′ for the root of the equation f(x) = 0, also known as Chebyshev formula of third order. Sol. Expanding f(x) by Taylor’s series in the neighborhood of x0, we get f(x) = 0 ⇒ f(x0) + (x – x0) f ′(x0) = 0 ⇒ x = x0 – f x f x ( ) ( ) 0 0 ′ This is I approximation to the root. ∴ x1 = x0 – f x f x ( ) ( ) 0 0 ′ Again By Taylor’s series, we have f(x) = f(x0) + (x – x0) f ′(x0) + ( ) x x − 0 2 2 f ″(x0) ∴ f(x1) = f(x0) + (x1 – x0) f ′(x0) + ( ) x x 1 0 2 2 − f ″(x0) But f(x1) = 0 as x1 is an approximation to the root. ∴ f(x0) + (x1– x0) f ′(x0) + 1 2 (x1 – x0)2 f ″(x0) = 0 or f(x0) + (x1 – x0) f ′(x0) + 1 2 { ( )} ( ) ( ) f x f x f x 0 2 0 0 ″ ′ 2 = 0 ⇒ x1 = x0 – f x f x ( ) ( ) 0 0 ′ – 1 2 { ( )} ( ) { ( )} f x f x f x 0 2 0 0 3 ″ ′ This formula can be used iteratively. Example 13. The graph of y = 2 sin x and y = log x + c touch each other in the neighborhood of point x = 8. Find c and the coordinates of point of contact. Sol. The graphs will touch each other if the values of dy/dx at their point of contact is same.
  • 189. 176 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES For y = 2 sin x, dy dx = 2 cos x For y = log x + c dy dx = 1 x ∴ 2 cos x = 1 x ⇒ x cos x – .5 = 0 Let f(x) = x cos x – .5 ∴ f ′(x) = cos x – x sin x ∴ Newton’s iterative formula is xn + 1 = xn – x x x x x n n n n n cos . cos sin − − 0 5 For n = 0, x0 = 8, first app. x1 = 7.793 Second approximation, x2 = 7.789 ≈ 7.79 Now, y = 2 sin 7.79 = 1.9960 ∴ Point of contact → (7.79, 1.996) Now, y = log x + c ⇒ 1.996 = log 7.79 + c ⇒ c = – 0.054. Example 14. Using the starting value x0 = i, find a zero of x4 + x3 + 5x2 + 4x + 4 = 0. Sol. By Newton’s method x1 = i – f i f i ( ) ( ) ′ = i – 3 1 6 i i + = .486 + .919 i Now, x2 = .486 + .919 i – f i f i (. . ) (. . ) 486 919 486 919 + ′ + = .486 + .919 i – − + + F HG I KJ . . . . 292 174 178 6 005 i i = – .499 + 0.866i The actual root is x = − + 1 3 2 i . Example 15. Show that the square root of N = AB is given by N ~ − S 4 N S + , where S = A + B.
  • 190. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 177 Sol. Let x = N ⇒ x2 – N = 0 Let f(x) = x2 – N ∴ f ′(x) = 2x By Newton-Raphson formula, xn + 1 = xn – f x f x n n ( ) ( ) ′ = x x x x x n n n n n − − = + 2 2 N 2 N 2 Let xn = A + B 2 then, xn + 1 = A + B 4 N A B + + ~ − + S 4 N S | Since S = A + B Example 16. Determine the value of p and q so that the rate of convergence of the iterative method xn + 1 = pxn + q N xn 2 for computing N1/3 becomes as high as possible. Sol. We have x3 = N ∴ f(x) = x3 – N Letting α be the exact root, we have α3 = N Substituting xn = α + en, xn + 1 = α + en + 1, N = α3 in xn + 1 = pxn + q N xn 2 , we get α + en + 1 = p(α + en) + q α α 3 2 ( ) + en = p e q e n n ( ) α α α α + + + F HG I KJ 3 2 2 1 = p(α + en) + qα 1 2 + F HG I KJ − en α = p e q e e n n n ( ) ......... α α α α + + − + F HG I KJ − R S | T | U V | W | 1 2 3 2
  • 191. 178 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = p e q qe q e n n n ( ) α α α + + − + 2 3 2 – ........ ⇒ en + 1 = (p + q – 1)α + (p – 2q)en + 0(en 2) + ....... Now for the method to become of the highest order as possible, i.e., of order 2, we must have p + q = 1 and p – 2q = 0 so that, p = 2 3 and q = 1 3 . Example 17. How should the constant α be chosen to ensure the fastest possible convergence with the iteration formula? xn+1 = α α x x 1 1 n n 2 + + + − . Sol. Since lim lim n n n n x x → ∞ → ∞ + = 1 = ξ, we have ξ = αξ ξ α + + + F H GG I K JJ 1 1 1 2 ⇒ (α + 1)ξ3 = αξ3 + ξ2 + 1 ⇒ ξ3 – ξ2 – 1 = 0 ξ can be obtained by finding a root of the equation x3 – x2 – 1 = 0. We have f(x) = x3 – x2 – 1 f ′(x) = 3x2 – 2x Since f(1.45) = (–)ve and f(1.47) = (+)ve ∴ Root lies between 1.45 and 1.47. Let x0 = 1.46 By Newton-Raphson method, First approximation is x1 = x0 – f x f x ( ) ( ) 0 0 ′ = x0 – x x x x 0 3 0 2 0 2 0 1 3 2 − − − F HG I KJ = 1.465601. Second approximation is x2 = x1 – f x f x ( ) ( ) 1 1 ′ = x1 – x x x x 1 3 1 2 1 2 1 1 3 2 − − − F HG I KJ = 1.46557
  • 192. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 179 Hence ξ = 1.465 correct to three decimal places. Now, we have xn+1 = α α x x n n + + + −2 1 1 (40) Putting xn = ξ + en and xn+1 = ξ + en+1 in (40), we get (α + 1)(ξ + en + 1) = α(ξ + en) + 1 2 ( ) ξ + en + 1 = α(ξ + en) + 1 1 2 2 ξ ξ + F HG I KJ − en + 1 which gives, (1 + α)en+1 = α ξ − F HG I KJ 2 3 en + O(en 2) For fastest convergence, we must have α = 2 3 ξ ∴ α = 2 (1.465)3 = 0.636. Example 18. Newton-Raphson’s method for solving the equation f(x) = c, where c is a real valued constant, is applied to the function f(x) = cos x, when|x| 1 cos x (x 1) , when|x| 1 2 2 ≤ + − ≥ R S T U V W For which c is xn = (– 1)n, when x0 = 1 and the calculations are carried out with no errors? Even in high precision arithmetic, the convergence is troublesome. Explain. Sol. f(x) – c = 0 (41) Applying the Newton-Raphson method to eqn. (41), we get xn+1 = xn – f x c f x n n ( ) ( ) − ′ L NM O QP For n = 0, we have x1 = x0 – f x c f x ( ) ( ) 0 0 − ′ L NM O QP
  • 193. 180 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 1 – cos sin 1 1 − − L NM O QP c | ∵ x0 = 1 – 1 = 1 + cos sin 1 1 − L NM O QP c | ∵ x1 = (– 1)1 = – 1 Hence – 2 sin 1 = cos 1 – c ⇒ c = cos 1 + 2 sin 1 with this value of c, we get x2 = 1, x3 = – 1, ..., xn = (– 1)n Since f ′(x) = 0 between x0 and the roots and also at x = 0, the convergence is troublesome inspite of high precision arithmetic. ASSIGNMENT 3.9 1. By using Newton-Raphson’s method, find the root of x4 – x – 10 = 0 which is near to x = 2, correct to three decimal places. 2. Compute one positive root of 2x – log10 x = 7 by the Newton-Raphson method correct to four decimal places. 3. (i) Use the Newton-Raphson method to find a root of the equation x3 – 2x – 5 = 0. (ii) Use Newton-Raphson method to find a root of the equation x3 – 3x – 5 = 0. 4. Find the real root of the equations (i) log x = cos x (ii) x2 + 4 sin x = 0 by Newton-Raphson method, correct to three decimal places. 5. Use Newton-Raphson method to obtain a root correct to three decimal places of the following equations: (i) sin x = 1 – x (ii) x3 – 5x + 3 = 0 (iii) x4 + x2 – 80 = 0 (iv) x3 + 3x2 – 3 = 0 (v) 4(x – sin x) = 1 (vi) x – cos x = 0 (vii) sin x = x 2 (viii) x + log x = 2 (ix) tan x = x. 6. Explain the method of Newton-Raphson for computing roots. Apply it for finding x from x2 – 25 = 0. Write a program using ‘C’. 7. Write a computer program in ‘C’ for finding out a real root of eqn. f(x) = 0 by the Newton- Raphson method. 8. Using the Newton-Raphson method, obtain the formula for N and find 20 correct to 2 decimal places. 9. Obtain the cube root of 120 using the Newton-Raphson method, starting with x0 = 4.5. 10. Develop an algorithm using the Newton-Raphson method to find the fourth root of a positive number N, and find 32 4 .
  • 194. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 181 11. Find the cube root of 3 correct to three decimal places by Newton’s iterative method. 12. Prove the recurrence formula xi + 1 = 1 3 2 2 x x i i + F HG I KJ N for finding the cube root of N. Find the cube root of 63. 13. Use Newton’s formula to prove that the square root of N can be obtained by the recursion formula, xi + 1 = xi 1 2 − F HG I KJ xi – N 2N Find the square root of (a) 26 (b) 29 (c) 35. 14. Show that the iterative formula for finding the reciprocal of n is xi + 1 = xi (2 – nxi), and find the value of 1 31 . 15. Determine p, q, and r so that the order of the iterative method xn + 1 = px qa x ra x n n n + + 2 2 5 for a1/3 becomes as high as possible. [Hint: p + q + r = 1, p – 2q – 5r = 0, 3q + 15r = 0.] 16. Derive the expression for the Newton-Raphson method to find a root of an equation. Find the order of the convergence of this method. 17. Find all positive roots of the equation 10 0 2 x x e dt z − – 1 = 0 with six correct decimals. 18. The equation 2e–x = 1 2 1 1 x x + + + has two roots greater than – 1. Calculate these roots correct to five decimal places. 19. The equation x = 0.2 + 0.4 sin x b F HG I KJ where b is a parameter, has one solution near x = 0.3. The parameter is known only with some uncertainty: b = 1.2 ± 0.05. Calculate the root with an accuracy reasonable with respect to the uncertainty of b. 20. Find the positive root of the equation ex = 1 + x + x x 2 3 2 6 + e0.3x correct to 6 decimal places.
  • 195. 182 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 21. Show that the equation f(x) = cos π( ) x + R S T U V W 1 8 + 0.148x – 0.9062 = 0 has one root in the interval (– 1, 0) and one in (0, 1). Calculate the negative root correct to 4 decimals. 3.38 DEFINITIONS 1. A number α is a solution of f(x) = 0 if f(α) = 0. Such a solution α is a root or a zero of f(x) = 0. Geometrically, a root of the eqn. f(x) = 0 is the value of x at which the graph of y = f(x) intersects x-axis. 2. If we can write f(x) = 0 as f(x) = (x – α)m g(x) = 0 where g(x) is bounded and g(α) ≠ 0 then α is called a multiple root of multiplicity m. In this case, f(α) = f ′(α) = .......... = f(m – 1) (α) = 0, f(m) (α) ≠ 0 For m = 1, the number α is said to be a simple root. 3.39 METHODS FOR MULTIPLE ROOTS If α is a multiple root of multiplicity m of the eqn. f(x) = 0, then we have f(α) = f ′(α) = ........ = f(m – 1)(α) = 0 and f(m)(α) ≠ 0 It can easily be verified that all the iteration methods discussed so far have only a linear rate of convergence when m 1. For example, in the Newton-Raphson method, we have f(xk) = f(α + ek) = e m f e m f k m m k m m ! ( ) ( ) ! ( ) ( ) ( ) α α + + + + 1 1 1 + + + + + e m f k m m 2 2 2 ( ) ! ( ) ....... ( ) α f ′(xk) = f e e m f e m f k k m m k m m ′ + = − + + − + ( ) ( ) ! ( ) ! ( ) ....... ( ) ( ) α α α 1 1 1
  • 196. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 183 The error equation for the Newton-Raphson method becomes, ek + 1 = 1 1 1 1 2 1 2 3 − F HG I KJ + + + + m e m m f f e e k m m k k ( ) ( ) ( ) ( ) ( ) ( ) α α O If m ≠ 1, we obtain, ek + 1 = 1 1 2 − F HG I KJ + m e e k k O ( ) (42) which shows that the method has only linear rate of convergence. However, if the multiplicity of the root is known in advance, we can modify the methods by introducing parameters dependent on the multiplicity of the root to increase their order of convergence. For example, consider the Newton-Raphson method in the form xk + 1 = x f f k k k − ′ β (43) where β is an arbitrary parameter to be determined. If α is a multiple root of multiplicity m, we obtain from (43), the error equation ek + 1 = 1 1 0 2 1 2 3 − F HG I KJ + + + + β β α α m e m m f f e e k m m k k ( ) ( ) ( ) ( ) ( ) ( ) If the method (43) is to have the quadratic rate of convergence, then the coefficient of ek must vanish, which gives 1− β m = 0 or β = m Thus the method xk + 1 = x m f f k k k − ′ has a quadratic rate of convergence for determining a multiple root of multiplicity m. If the multiplicity of the root is not known in advance, then we use the following procedure. It is known that if f(x) = 0 has a root α of multiplicity m, then f ′(x) = 0 has the same root α of multiplicity m – 1.
  • 197. 184 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence, g(x) = f x f x ( ) ( ) ′ has a simple root α and we can now use the Newton- Raphson method xk + 1 = x g x g x k k k − ′ ( ) ( ) to find the approximate value of the multiple root α. Simplifying, we have xk + 1 = xk – f f f f f k k k k k ′ − ′ ″ 2 which has a quadratic rate of convergence for multiple roots. If initial approximation x0 is sufficiently close to the root, then the expressions x m f x f x x m f x f x x m f x f x 0 0 0 0 0 0 0 0 0 1 2 − ′ − − ′ ″ − − ″ ″′ ( ) ( ) , ( ) ( ) ( ) , ( ) ( ) ( ) will have same value. EXAMPLES Example 1. Show that the modified Newton-Raphson’s method xn + 1 = xn – 2f(x ) f (x ) n n ′ gives a quadratic convergence when f(x) = 0 has a pair of double roots in the neighborhood of x = xn. Sol. en + 1 = en – 2f a e f a e n n ( ) ( ) + ′ + , where a, en, and en + 1 have their usual meanings. Expanding in powers of en and using f(a) = 0, f ′(a) = 0 since x = a is a double root near x = xn, we get e n + 1 = en – 2 2 2 2 2 e f a e f a e f a n n n ! ( ) ....... ( ) ! ( ) ....... ″ + L NMM O QPP ″ + ″′ + L NMM O QPP = en – 2 1 2 1 3 2 2 e f a f a e f a e f a n n n ! ( ) ! ( ) ....... ( ) ! ( ) ...... ″ + ″′ + L NM O QP ″ + ″′ + L NM O QP NOTE
  • 198. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 185 ~ − en – 2 1 2 1 3 2 e f a f a f a e f a n n ! ( ) ! ( ) ( ) ! ( ) ″ + ″′ L NM O QP ″ + ″′ en + 1 ~ − 1 6 en 2. f a f a e f a n ″ ′ ″ + ″ ′ L NM O QP ( ) ( ) ! ( ) 2 ∴ en + 1 ≈ 1 6 en 2 f a f a ″ ′ ″ ( ) ( ) ⇒ en + 1 ∝ en 2 and hence the convergence is quadratic. Example 2. Find the double root of the equation x3 – x2 – x + 1 = 0. Sol. Let f(x) = x3 – x2 – x + 1 so that f ′(x) = 3x2 – 2x – 1 f ″(x) = 6x – 2 Starting with x0 = 0.9, we have x0 – 2 f x f x ( ) ( ) 0 0 ′ = .9 – 2 019 37 × − . ( . ) = 1.003 and x0 – (2 – 1) f x f x ′ ″ ( ) ( ) 0 0 = .9 – ( . ) . − 37 3 4 = 1.009 The closeness of these values implies that there is a double root near x = 1. Choosing x1 = 1.01 for the next approximation, we get x1 – 2 f x f x ( ) ( ) 1 1 ′ = 1.01 – 2 × 0 0002 0 0403 . . = 1.0001 and x1 – (2 – 1) f x f x ′ ″ ( ) ( ) 1 1 = 1.01 – . . 0403 4 06 = 1.0001 This shows that there is a double root at x = 1.0001 which is quite near the actual root x = 1.
  • 199. 186 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 3. The equation f(x) = x3 – 7x2 + 16x – 12 = 0 has a double root at x = 2. Starting with the initial approximation x0 = 1, find the root correct to 3 decimal places using the modified Newton-Raphson method with m = 2. Sol. The modified Newton-Raphson method with m = 2 becomes, xn + 1 = xn – 2 x x x x x n n n n n 3 2 2 7 16 12 3 14 16 − + − − + L NMM O QPP, n = 0, 1, ....... Starting with x0 = 1, we get x1 = 1.8 x2 = 1.984615385 x3 = 1.999884332 x4 = 2.000000161 x5 = 2.000000161 ∴ The root correct to 3 decimal places is 2.000. Example 4. Show that the equation f(x) = 1 – xe1 – x = 0 has a double root at x = 1. The root is obtained by using the modified Newton- Raphson method with m = 2 starting with x0 = 0. Sol. Since f(1) = f ′(1) = 0 and f ″(1) ≠ 0, the root x = 1 is a double root. xn + 1 = xn – 2 1 1 1 1 − − L N MM O Q PP − − x e x e n x n x n n ( ) ; n = 0, 1, ....... Starting with x0 = 0, we get x1 = .735758882 x2 = .978185253 x3 = .999842233 x4 = 1.000000061 x5 = 1.000000061 Hence the root correct to six decimal places is 1.000000.
  • 200. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 187 3.40 NEARLY EQUAL ROOTS So far, Newton’s method is applicable when f ′(x) ≠ 0 in the neighborhood of actual root x = a, i.e., in the interval (a – h, a + h). If the quantity h is very very small, it will not satisfy the above restriction. The application of Newton’s method will not be practical in that case. This condition occurs when the roots are very close to one another. We know that in case of the double root x = a, f(x) and f ′(x) both vanish at x = a. Thus, while applying Newton’s method, if xi is simultaneously near zeros of f(x) and f ′(x), i.e., f(xi) and f ′(xi) are both very small, then it is usually practical to depart from the standard sequence and proceed to obtain two new starting values for the two nearly equal roots. To obtain these values, we first apply Newton’s method to the equation f ′(x) = 0, i.e., we use the iteration formula xi + 1 = xi – f x f x i i ′ ″ ( ) ( ) (44) with the last available iterate as the initial value x0 for (44). Suppose x = c is the solution obtained by (44). Now, by Taylor’s series, we have f(x) = f(c) + (x – c) f ′(c) + 1 2 (x – c)2 f ″(c) + ....... But f ′(c) = 0 f(x) = f(c) + 1 2 (x – c)2 f ″(c) + R Assuming R to be small, we conclude that the zero’s of f(x) near x = c are approximately given by f(c) + 1 2 (x – c)2 f ″(c) = 0 ⇒ x = c ± − ″ 2f c f c ( ) ( ) (45) Using these values as starting values, we can use the original iteration formula to get two close roots of f(x) = 0.
  • 201. 188 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES EXAMPLE Example. Use synthetic division to solve f(x) ≡ x3 – x2 – 1.0001 x + 0.9999 = 0 in the neighborhood of x = 1. Sol. To find f(1) and f ′(1), 1 –1 –1.0001 0.9999 1 1 0 – 1.0001 1 0 – 1.0001 – 0.0002 = f (1) 1 1 1 1 – .0001 = f ′(1) 1 1 2 = 1 2 f ″(1) From the above synthetic division, we observe that f(1) and f ′(1) are small. Hence there exists two nearly equal roots. Taking x0 = 1, we will use xi + 1 = xi – f x f x i i ′ ″ ( ) ( ) to modify the root. For this, we require f ″(1). From the above synthetic division, we have 1 2 f ″ (1) = 2 ⇒ f ″ (1) = 4 ∴ First approximation x1 = 1 – f f ′ ″ ( ) ( ) 1 1 = 1 – ( . ) − 0001 4 = 1.000025 Now we again calculate f(x1) and f ″(x1) by synthetic division. 1 –1 – 1.000100 0.999900 1.000025 1.000025 0.000025 – 1.000095 1 . 000025 – 1.00075 – 0.000 195 = f (x1) 1.000025 1.000075 1 1.000050 0 = f ′(x1) 1.000025 1 2.000075 = 1 2 f ″(x1) ∴ f(1.000025) = – 0.000195 and f ″(1.000025) = 4.000150
  • 202. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 189 Now, For nearly equal roots, x = c ± − ″ 2 f c f c ( ) ( ) , where c = 1.000025 = 1.000025 ± − − 2 000195 4 000150 ( . ) . = 1.009899, 0.990151. 3.41 COMPARISON OF NEWTON’S METHOD WITH REGULA-FALSI METHOD Regula-Falsi is surely convergent while Newton’s method is conditionally convergent. But once Newton’s method converges, it converges faster. In the Falsi method, we calculate only one more value of the function at each step i.e., f(x(n)) while in Newton’s method, we require two calculations f(xn) and f ′(xn) at each step. ∴ Newton’s method generally requires fewer iterations but also requires more time for computation at each iteration. When f ′(x) is large near the root the correction to be applied is smaller in the case of Newton’s method which is then preferred. If f ′(x) is small near the root, the correction to be applied is large and the curve becomes parallel to the x-axis. In this case the Regula-Falsi method should be applied. 3.42 COMPARISON OF ITERATIVE METHODS 1. Convergence in the case of the Bisection method is slow but steady. It is the simplest method and never fails. 2. The method of false position is slow and it is I order convergent. Convergence is guaranteed. 3. Newton’s method has the fastest rate of convergence. This method is quite sensitive to starting value. It may diverge if f ′(x) ≈ 0 during iterative cycle. 4. For locating complex roots, the bisection method cannot be applied. Newton’s and Muller’s methods are effective. 5. If all the roots of a given equation are required, Lin-Bairstow’s method is recommended. After a quadratic factor has been found, this method must be applied on the reduced polynomial.
  • 203. 190 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES If the location of some roots is known, first find these roots to a desired accuracy and then apply this method on the reduced polynomial. ASSIGNMENT 3.10 1. The equation f(x) = (x – 1)2 (x – 3)2 has roots at x = 1 and x = 3. Which of the following methods can be applied to find all the roots? (i) Bisection method (ii) False-position method (iii) Newton-Raphson method Justify your answer. 2. A sphere of wood, 2 m in diameter, floating in water sinks to a depth d given by d3 – 3d2 + 2.5 = 0 find d correct to 2 decimal places. 3. Discuss the working of modified Newton-Raphson method. 4. Find the root of the equation f(x) ≡ sin x – x x + − 1 1 = 0 near x = – .4 5. Give a comparative study of iterative methods. 6. Under what conditions does the Newton-Raphson method become linearly convergent? Explain. 3.43 GRAEFFE’S ROOT-SQUARING METHOD This method has a great advantage over the other methods in that it does not require prior information about the approximate values, etc., of the roots. It is applicable to polynomial equations only and is capable of giving all the roots. Here below we discuss the case of the polynomial equation having real and distinct roots. Consider the polynomial equation f(x) = xn + a1xn–1 + a2xn–2 + ...... + an–1x + an = 0 (46) Separating the even and odd powers of x and squaring, we get (xn + a2xn–2 + a4xn–4 + ......)2 = (a1xn–1 + a3xn–3 + a5xn–5 + ......)2 Putting x2 = y and simplifying, the new equation becomes yn + b1yn–1 + b2yn–2 + ...... + bn–1y + bn = 0 (47) where b1 = a1 2 + 2a2; b2 = a2 2 – 2a1a3 + 2a4 ...... bn = (– 1)n an2 (48)
  • 204. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 191 If p1, p2, ......... , pn are the roots of (46), then the roots of (47) are p1 2, p2 2, ......... , pn 2. Let us suppose that after m squarings, the new transformed equation is zn + λ1zn–1 + ...... + λn–1z + λn = 0 (49) whose roots are q1, q2, ......., qn such that qi = pi 2m , i = 1, 2, ......, n. Assuming the order of magnitude of the roots as | p1 | | p2 | ...... | pn |, we have | q1 | | q2 | ...... | qn | where stands for ‘much greater than’. Thus | | | | , ......, | | | | q q q q q q q q n n n n 2 1 2 1 1 1 = = − − (50) Also qi being an even power of pi, is always positive. Now, from (49), we have Σq1 = – λ1 ⇒ λ1 = – q1 1 2 1 3 1 + + + F HG I KJ q q q q ...... Σq1q2 = λ2 ⇒ λ2 = q1q2 1 3 1 + + F HG I KJ q q ...... Σq1q2q3 = – λ3 ⇒ λ3 = q1q2q3 1 4 1 + + F HG I KJ q q ...... ............................................................................ q1q2q3 ...... qn = (– 1)n λn ⇒ λn = (– 1)n q1q2q3 ...... qn. Hence by (50), we find q1 ≈ – λ1; q2 ≈ – λ λ λ λ λ λ 2 1 3 3 2 1 , , ......, q qn n n ≈ − ≈ − − But qi = pi 2m ∴ pi = (qi)1/2m = − F HG I KJ − λ λ i i m 1 1/2 (51) We can thus determine p1, p2, ......, pn the roots of the equation (46). Case 1. Double root. If the magnitude of λi is half the square of the magnitude of the corresponding coefficient in the previous equation after a few squarings, then it implies that pi is a double root of (46). We determine it as follows: qi = – λ λ i i−1 and qi+1 = – λ λ i i +1
  • 205. 192 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ qiqi+1 ≈ qi 2 ≈ λ λ i i + − 1 1 i.e., pi 2m = qi 2 = λ λ i i + − 1 1 (52) which gives the magnitude of the double root and substituting in (46), we can find the sign. Case 2. Complex roots. If pr and pr+1 form the complex pair Pr i e r ± φ , then the co-efficient of xn–r in successive squarings would vary both in magnitude and sign by an amount 2Pr m cos mφr. For sufficiently large Pr and φr can be determined by Pr r r m 2 2 1 1 ( ) ≈ + − λ λ ; 2 2 2 1 Pr m r r r m cos φ λ λ = − − (53) If there is only one pair of complex roots, say Pr i r r e i r ± = + φ ξ η then ξr is given by p1 + p2 + ...... + pr–1 + 2ξr + pr+2 + ...... + pn = – a1 (54) and ηr = Pr r 2 2 – ξ (55) If there are two pairs of complex roots, say Pr i r r e i r ± = ± φ ξ η and Ps i s s e i s ± = ± φ ξ η where p1 + p2 + ...... + pr–1 + 2ξr + Pr+2 + ...... + ps–1 + 2ξs + ps+2 + ...... + pn = – a1 (56) 2 1 1 2 2 1 1 ξ ξ r r s s n n a n a a P P + F HG I KJ = − + + + L NM O QP − ...... (57) and ηr = P P r r s s s 2 2 2 2 − = − ξ η ξ ; (58) EXAMPLES Example 1. Apply Graeffe’s root squaring method to solve the equation x3 – 8x2 + 17x – 10 = 0. Sol. Here f(x) = x3 – 8x2 + 17x – 10 = 0 (59) Clearly f(x) has three changes i.e., from + to –, – to + and + to –. Hence from Descartes rule of signs f(x) may have three positive roots. Rewriting (59) as x(x2 + 17) = (8x2 + 10) (60)
  • 206. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 193 Squaring on both sides and putting x2 = y, we get y(y + 17)2 = (8y + 10)2 or y3 + 34y2 + 289y = 64y2 + 160y + 100 or y(y2 + 129) = (30y2 + 100) (61) Squaring again and putting y2 = z, we get z(z + 129)2 = (30z + 100)2 or z3 + 258z2 + 16641z = 900z2 + 6000z + 10000 or z(z2 + 10641) = (642z2 + 10000) (62) Squaring again and putting z2 = u, we get u(u + 10641)2 = (642u + 10000)2 or u3 + 21282u2 + 113230881u = 412164u2 + 12840000u + 108 or u3 – 390882u2 + 100390881u – 108 = 0 (63) If the roots of (59) are p1, p2, p3 and those of (63) are q1, q2, q3, then p1 = (q1)1/8 = ( – λ1)1/8 = (390882)1/8 = 5.000411082 ≅ 5 p2 = (q2)1/8 = (– λ2/λ1)1/8 = 100390881 378882 1/8 L NM O QP = 2.000811036 ≅ 2 p3 = (q3)1/8 = (– λ3/λ2)1/8 = 10 100390881 8 L NM O QP = 0.99951247 ≅ 1 Now f(5) = f(1) = f(2) = 0. Hence the roots are 5, 2, and 1. Example 2. Find all the roots of the equation x4 – 3x + 1 = 0 by Graeffe’s method. Sol. Here f(x) = x4 – 3x + 1 = 0 (64) Now f(x) has two changes in sign i.e., + to – and – to +. Therefore it may have two positive real roots. Again f(– x) = x4 + 3x + 1. Since no change in sign of f(– x) there is no negative root. But f(x), being of degree four, will have four roots of which two are real positive and the remaining two are complex. Rewriting (64) as x4 + 1 = 3x. Squaring and putting x2 = y, we have (y2 + 1)2 = 9y Squaring again and putting, y2 = z (z + 1)4 = 81z
  • 207. 194 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES i.e., z4 + 4z3 + 6z2 – 77z + 1 = 0 (65) or z4 + 6z2 + 1 = – z(4z2 – 77) Squaring once again and putting z2 = u, we get (u2 + 6u + 1)2 = u(4u – 77)2 or u4 – 4u3 + 654u2 – 5917u + 1 = 0 (66) If p1, p2, p3, p4 are the roots of (64) and q1, q2, q3, q4 are the roots of (66), then p1 = (q1)1/8 = (– λ1)1/8 = (4)1/8 = 1.1892071 p2 = (q2)1/8 = − L NM O QP = L NM O QP λ λ 2 1 1/8 1/8 654 4 = 1.8909921 p3 = (q3)1/8 = − L NM O QP = L NM O QP λ λ 3 1 1/8 1/8 5917 654 = 1.3169384 p4 = (q4)1/8 = − L NM O QP = L NM O QP λ λ 4 3 1/8 1/8 1 5917 = 0.3376659 From (65) and (66), we observe that the magnitudes of the co-efficients λ1 and λ4 have become constant. ⇒ p, p4 are the real roots and p2, p3 are complex roots. Let these complex roots be ρ ξ η φ 2 2 2 2 e i i ± = ± . From (66), its magnitude is given by ρ λ λ 2 2 2 3 1 3 5917 4 ( ) ≈ = ∴ ρ2 = 1.5780749 also from (64) the sum of the roots = 0, i.e., p1 + 2ξ2 + p4 = 0 ∴ ξ2 = – 1 2 (p1 + p4) = – 0.7634365 and η2 = ρ ξ 2 2 2 2 9074851 − = 1. = 1.3811173 Hence, the four roots are 1.1892071, 0.3376659, – 0.7634365 ± 1.3811173i. ASSIGNMENT 3.11 1. Find all the roots of the following equations by Graeffe’s method squaring thrice: (i) x3 – 4x2 + 5x – 2 = 0 (ii) x3 – 2x2 + 5x + 6 = 0 (iii) x3 – x – 1 = 0.
  • 208. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS 195 3.44 RAMANUJAN’S METHOD S. Ramanujan (1887 – 1920) proposed an iterative method which can be used to determine the smallest root of the equation f(x) = 0 where f(x) is of the form f(x) = 1 – (a1x + a2x2 + a3x3 + ....) For smaller values of x, we can write, [1 – (a1x + a2x2 + a3x3 + ....)]–1 = b1 + b2x + b3x2 + .... ⇒ 1 + (a1x + a2x2 + a3x3 + ...) + (a1x + a2x2 + a3x3 + ....)2 + .... = b1 + b2x + b3x2 + .... Expanding L.H.S. by Binomial theorem Comparing the coefficient of like powers of x on both sides, we get b1 = 1 b2 = a1 = a1b1 b3 = a1 2 + a2 = a1b2 + a2b1 bn = a1bn – 1 + a2bn – 2 + ....... + an – 1b1 n = 2, 3, ..... Ramanujan stated that the successive convergents viz. b b n n + 1 approach a root of the equation f(x) = 0. EXAMPLE Example. Find the smallest root of the equation x3 – 6x2 + 11x – 6 = 0 using Ramanujan’s method. Sol. We have 1 11 6 6 2 3 1 − − + F HG I KJ L N MM O Q PP − x x x = b1 + b2x + b3x2 + ..... Here, a1 = 11 6 , a2 = – 1, a3 = 1 6 , a4 = a5 = a6 = ..... = 0 U V | | | W | | |
  • 209. 196 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence b1 = 1 b2 = a1 = 11 6 ∴ b b 1 2 6 11 = = .54545 b3 = a1b2 + a2b1 = 121 36 1 85 36 − = ; b b 2 3 66 85 = = .7764705 b4 = a1b3 + a2b2 + a3b1 = 575 216 ; b b 3 4 102 115 = = .8869565 b5 = a1b4 + a2b3 + a3b2 + a4b1 = 3661 1296 ; b b 4 5 3450 3661 = = .9423654 b6 = a1b5 + a2b4 + a3b3 + a4b2 + a5b1 = 22631 7776 ; b b 5 6 3138 3233 = = .9706155 The smallest root of the given equation is 1 and the successive convergents approach this root. ASSIGNMENT 3.12 1. Find a root of the equation xex = 1 using Ramanujan’s method. 2. Find a root of the equation sin x = 1 – x using Ramanujan’s method. 3. Using Ramanujan’s method, obtain the first eight convergents of the equation x + x3 = 1.
  • 210. P a r t 2 n Interpolation Finite Differences, Difference Tables, Errors in Polynomial Interpolation, Newton’s Forward and Backward Formula, Gauss’s Forward and Backward Formula, Stirling’s, Bessel’s, Everett’s Formula, Lagrange’s Interpolation, Newton’s Divided Difference Formula, Hermite’s Interpolation.
  • 212. 4.1 INTRODUCTION A ccording to Theile, ‘Interpolation is the art of reading between the lines of the table’. It also means insertion or filling up intermediate terms of the series. Suppose we are given the following values of y = f(x) for a set of values of x: x: x0 x1 x2 ...... xn y: y0 y1 y2 ...... yn Thus the process of finding the value of y corresponding to any value of x = xi between x0 and xn is called interpolation. Hence interpolation is the technique of estimating the value of a function for any intermediate value of the independent variable, while the process of computing the value of the function outside the given range is called extrapolation. Chapter 4 INTERPOLATION 199
  • 213. 200 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.2 ASSUMPTIONS FOR INTERPOLATION 1. There are no sudden jumps or falls in the values during the period under consideration. 2. The rise and fall in the values should be uniform. For example, if we are given data regarding deaths in various years in a particular town and some of the observations are for the years in which epidemic or war overtook the town, then interpolation methods are not applicable. 3. When we apply calculus of finite differences, we assume that the given set of observations is capable of being expressed in a polynomial form. If the function f(x) is known explicitly, the value of y corresponding to any value of x can be found easily. If the function f(x) is not known, it is necessary to find a simpler function, say φ(x), such that f(x) and φ(x) agree at the set of tabulated points. This process is called interpolation. If φ(x) is a polynomial, then the process is called polynomial interpolation and φ(x) is called the interpolating polynomial. 4.3 ERRORS IN POLYNOMIAL INTERPOLATION Let the function y(x) defined by (n + 1) points (xi, yi) i = 0, 1, 2, ......, n be continuous and differentiable (n + 1) times and let y(x) be approximated by a polynomial φn(x) of degree not exceeding n such that φn(xi) = yi; i = 0, 1, 2, ....., n (1) The problem lies in finding the accuracy of this approximation if we use φn(x) to obtain approximate values of y(x) at some points other than those defined above. Since the expression y(x) – φn(x) vanishes for x = x0, x1, ......, xn, we put y(x) – φn(x) = L Πn+1 (x) (2) where Πn+1(x) = (x – x0) (x – x1) ...... (x – xn) (3) and L is to be determined such that equation (2) holds for any intermediate value of x say x′ where x0 x′ xn. Clearly, L = y x x x n n ( ) ( ) ( ) ′ − ′ ′ + φ Π 1 (4) Construct a function, F(x) = y(x) – φn(x) – L Πn+1(x) (5) where L is given by (4).
  • 214. INTERPOLATION 201 It is clear that, F(x0) = F(x1) = ...... = F(xn) = F(x′) = 0 i.e., F(x) vanishes (n + 2) times in interval [x0, xn] consequently, by repeated application of Rolle’s theorem, F′(x) must vanish (n + 1) times, F″(x) must vanish n times in the interval [x0, xn] Particularly, F(n+1) (x) must vanish once in [x0, xn]. Let this point be x = ξ; x0 ξ xn. Differentiating (5) (n + 1) times with respect to x and put x = ξ, we get 0 = (y)(n+1) (ξ) – L ( )! n + 1 d dx x n n n n + + + = + 1 1 1 1 ( ) ( ) ! so that, L = y n n ( ) ( ) ( ) ! + + 1 1 ξ (6) Comparison of (4) and (6) give y(x′) – φn(x′) = y n n ( ) ( ) ( ) ! + + 1 1 ξ Πn+1(x′) Hence, the required expression of error is y(x) – φn(x) = Πn x n + + 1 1 ( ) ( ) ! yn+1(ξ), x0 ξ xn (7) Since y(x) is generally unknown, and we do not have any information concerning y(n+1)(x), equation (7) is useless in practical computations. We will use it to determine errors in Newton’s interpolating formulae. The various methods of interpolation are as follows: (1) The method of graph (2) The method of curve fitting (3) Use of calculus of finite difference formulae. The merits of the last method over the others are (i) It does not assume the form of function to be known. (ii) It is less approximate than the method of graphs. (iii) The calculations remain simple even if some additional observations are included in the given data. The demerit is there is no definite way to verify whether the assumptions for the application of finite difference calculus are valid for the given set of observations.
  • 215. 202 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.4 FINITE DIFFERENCES The calculus of finite differences deals with the changes that take place in the value of the function (dependent variable) due to finite changes in the independent variable. Suppose we are given a set of values (xi, yi); i = 1, 2, 3, ......, n of any function y = f(x). A value of the independent variable x is called argument and the corresponding value of the dependent variable y is called entry. Suppose that the function y = f(x) is tabulated for the equally spaced values x = x0, x0 + h, x0 + 2h, ....., x0 + nh, giving y = y0, y1, y2, ......, yn. To determine the values of f(x) or f ′(x) for some intermediate values of x, the following three types of differences are useful: 1. Forward differences. The differences y1 – y0, y2 – y1, y3 – y2, ......, yn – yn–1 when denoted by Δy0, Δy1, Δy2, ......, Δyn–1 are respectively, called the first forward differences where D is the forward difference operator. Thus the first forward differences are Δyr = yr+1 – yr Similarly, the second forward differences are defined by Δ2yr = Δyr+1 – Δyr Particularly, Δ2y0 = Δy1 – Δy0 = y2 – y1 – (y1 – y0) = y2 – 2y1 + y0 Similarly, Δ3y0 = y3 – 3y2 + 3y1 – y0 Δ4y0 = y4 – 4y3 + 6y2 – 4y1 + y0. Clearly, any higher order difference can easily be expressed in terms of ordinates since the coefficients occurring on R.H.S. are the binomial coefficients*. In general, Δpyr = Δp–1yr+1 – Δp–1yr defines the pth forward differences. ∗ Δn(y0) = yn – nC1 yn–1 + nC2yn–2 + ...... + (– 1)n y0
  • 216. INTERPOLATION 203 The following table shows how the forward differences of all orders can be formed. Forward difference table x y Δy Δ2y Δ3y Δ4y Δ5y x0 y0 Δy0 x1 y1 Δ2y0 (= x0 + h) Δy1 Δ3y0 x2 y2 Δ2y1 Δ4y0 (= x0 + 2h) Δy2 Δ3y1 Δ5y0 x3 y3 Δ2y2 Δ4y1 = (x0 + 3h) Δy3 Δ3y2 x4 y4 Δ2y3 = (x0 + 4h) Δy4 x5 y5 = (x0 + 5h) Here the first entry, y0, is called the leading term and Δy0, Δ2y0, ...... are called leading differences. Δ obeys distributive, commutative and index laws: 1. Δ [f(x) ± φ(x)] = Δf(x) ± Δφ (x) 2. Δ [c f(x)] = c Δ f(x); c is constant 3. Δm Δn f(x) = Δm+n f(x), m, n being (+)ve integers. But, Δ[f(x) . φ(x)] ≠ f(x) . Δ φ(x). 2. Backward differences. The differences y1 – y0, y2 – y1, ......, yn – yn–1 when denoted by ∇y1, ∇y2, ......, ∇yn, respectively, are called first backward differences where ∇ is the backward difference operator. Similarly, we define higher order backward differences as, ∇yr = yr – yr–1 ∇2yr = ∇yr – ∇yr–1 ∇3yr = ∇2yr – ∇2yr–1 etc. Particularly, ∇2y2 = ∇y2 – ∇y1 = y2 – y1 – (y1 – y0) = y2 – 2y1 + y0 ∇3y3 = ∇2y3 – ∇2y2 = y3 – 3y2 + 3y1 – y0 etc. NOTE
  • 217. 204 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Backward difference table x y ∇y ∇2y ∇3y ∇4y ∇5y x0 y0 ∇y1 x1 y1 ∇2y2 (= x0 + h) ∇y2 ∇3y3 x2 y2 ∇2y3 ∇4y4 (= x0 + 2h) ∇y3 ∇3y4 ∇5y5 x3 y3 ∇2y4 ∇4y5 (= x0 + 3h) ∇y4 ∇3y5 x4 y4 ∇2y5 (= x0 + 4h) ∇y5 x5 y5 (= x0 + 5h) 3. Central differences. The central difference operator d is defined by the relations y1 – y0 = δy1/2, y2 – y1 = δy3/2, ......, yn – yn–1 = δy n – 1 2 . Similarly, high order central differences are defined as δy3/2 – δy1/2 = δ2y1, δy5/2 – δy3/2 = δ2y2 and so on. These differences are shown as follows: Central difference table x y δy δ 2y δ3y δ4y δ 5y x0 y0 δy1/2 x1 y1 δ2y1 δy3/2 δ3y3/2 x2 y2 δ2y2 δ4y2 δy5/2 δ3y5/2 δ5y5/2 x3 y3 δ2y3 δ4y3 δy7/2 δ3y7/2 x4 y4 δ2y4 δy9/2 x5 y5
  • 218. INTERPOLATION 205 1. The central differences on the same horizontal line have the same suffix. 2. It is only the notation that changes, not the differences. e.g., y1 – y0 = Δy0 = ∇y1= δy1/2. 4.5 OTHER DIFFERENCE OPERATORS 1. Shift operator E. Shift operator E is the operation of increasing the argument x by h so that Ef(x) = f(x + h) E2f(x) = f(x + 2h) and so on. The inverse operator, E–1, is defined by E–1f(x) = f(x – h). Also Enyx = yx+nh. 2. Averaging operator μ. The averaging operator is defined by μyx = 1 2 L NMy y x h x h + − + 1 2 1 2 O QP In difference calculus, E is the fundamental operator and ∇, Δ, δ, μ can be expressed in terms of E. 4.6 RELATION BETWEEN OPERATORS 1. Δ = E – 1 or E = 1 + Δ. Proof. We know that, Δyx = yx+h – yx = Eyx – yx = (E – 1)yx ⇒ Δ = E – 1 or E = 1 + Δ 2. ∇ = 1 – E–1 Proof. ∇yx = yx – yx–h = yx – E–1yx ∴ ∇ = 1 – E–1 3. δ = E1/2 – E–1/2 NOTE
  • 219. 206 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Proof. δyx = y x h + 2 – y x h − 2 = E1/2 yx – E–1/2 yx = (E1/2 – E–1/2) yx ∴ δ = E1/2 – E–1/2 4. μ = 1 2 (E1/2 + E–1/2) Proof. μyx = 1 2 ( y x h + 2 + y x h − 2 ) = 1 2 (E1/2 + E–1/2) yx ⇒ μ = 1 2 (E1/2 + E–1/2) 5. Δ = E∇ = ∇E = δE1/2 Proof. E(∇yx) = E(yx – yx–h) = yx+h – yx = Δyx ⇒ E∇ = Δ ∇(E yx) = ∇ yx+h = yx+h – yx = Δyx ⇒ ∇E = Δ δE1/2 yx = δ y x h + 2 = yx+h – yx = Δyx ⇒ δE1/2 = Δ 6. E = ehD Proof. Ef(x) = f(x + h) = f(x) + h f ′(x) + h2 2 ! f ″(x) + ..... (By Taylor series) = f(x) + hDf(x) + h2 2! D2f(x) + ...... = 1 2 2 + + + L NM O QP h h D D ( ) ! ...... f(x) = ehD f(x) ∴ E = ehD or Δ = ehD – 1.
  • 220. INTERPOLATION 207 4.7 DIFFERENCES OF A POLYNOMIAL The nth differences of a polynomial of nth degree are constant and all higher order differences are zero when the values of the independent variable are at equal intervals. Let f(x) = axn + bxn–1 + cxn–2 + ...... + kx + l ∴ Δf(x) = f(x + h) – f(x) = a[(x + h)n – xn] + b [(x + h)n–1 – xn–1] + ...... + kh = anhxn–1 + b′xn–2 + c′xn–3 + ...... + k′x + l′ (8) where b′, c′, ...... l′ are new constant coefficients. ∴ First differences of a polynomial of nth degree is a polynomial of degree (n – 1). Similarly, Δ2f(x) = Δf(x + h) – Δf(x) = anh [(x + h)n–1 – xn–1] + b′[(x + h)n–2 – xn–2] + ...... + k′h = an(n – 1) h2xn–2 + b″xn–3 + ...... + k″ (9) ∴ Second differences represent a polynomial of degree (n – 2). Continuing this process, for nth differences, we get a polynomial of degree zero, i.e., Δn f(x) = an(n – 1) (n – 2) ...... 1 hn = a n! hn which is a constant. Hence the (n + 1)th and higher differences of a polynomial of nth degree will be zero. The converse of this theorem is also true. EXAMPLES Example 1. Construct the forward difference table, given that x: 5 10 15 20 25 30 y: 9962 9848 9659 9397 9063 8660 and point out the values of Δ2y10 , Δ4y5.
  • 221. 208 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Forward difference table is as follows: x y Δy Δ2y Δ3y Δ4y 5 9962 – 114 10 9848 – 75 – 189 2 15 9659 – 73 – 1 – 262 1 20 9397 – 72 2 – 334 3 25 9063 – 69 – 403 30 8660 From the table, Δ2y10 = – 73 and Δ4y5 = – 1. Example 2. If y = x3 + x2 – 2x + 1, calculate values of y for x = 0, 1, 2, 3, 4, 5 and form the difference table. Find the value of y at x = 6 by extending the table and verify that the same value is obtained by substitution. Sol. For x = 0, y = 1; x = 1, y = 1; x = 2, y = 9; x = 3, y = 31; x = 4, y = 73; x = 5, y = 141 Difference table is as follows: x y Δy Δ2y Δ3y 0 1 0 1 1 8 8 6 2 9 14 22 6 3 31 20 42 6 4 73 26 68 6 5 141 32 100 6 241
  • 222. INTERPOLATION 209 ∵ Third differences are constant. ∴ Δ3y3 = 6 ⇒ Δ2y4 – Δ2y3 = 6 ⇒ Δ2y4 – 26 = 6 ⇒ Δ2y4 = 32 Now, Δ2y4 = 42 ⇒ Δy5 – Δy4 = 32 ⇒ Δy5 – 68 = 32 ⇒ Δy5 = 100 Further, Δy5 = 100 y6 – y5 = 100 ⇒ y6 – 141 = 100 y6 = 241 Verification. y(6) = (6)3 + (6)2 – 2(6) + 1 = 241. Hence verified. Example 3. Construct a backward difference table for y = log x given that x: 10 20 30 40 50 y: 1 1.3010 1.4771 1.6021 1.6990 and find values of ∇3 log 40 and ∇4 log 50. Sol. Backward difference table is: x y ∇y ∇2y ∇3y ∇4y 10 1 0.3010 20 1.3010 – 0.1249 0.1761 0.0738 30 1.4771 – 0.0511 – 0.0508 0.1250 0.0230 40 1.6021 – 0.0281 0.0969 50 1.6990 From the table, ∇3 log 40 = 0.0738 and ∇4 log 50 = – 0.0508. Example 4. Construct a backward difference table from the data: sin 30° = 0.5, sin 35° = 0.5736, sin 40° = 0.6428 sin 45° = 0.7071 Assuming third differences to be constant, find the value of sin 25°.
  • 223. 210 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Backward difference table is: x y ∇y ∇2y ∇3y 25 .4225 .0775 30 0.5000 – .0039 0.0736 – .0005 35 0.5736 – .0044 0.0692 – .0005 40 0.6428 – .0049 0.0643 45 0.7071 Since third differences are constant ∴ ∇3y40 = – .0005 ⇒ ∇2y40 – ∇2y35 = – .0005 ⇒ – .0044 – ∇2y35 = – .0005 ⇒ ∇2y35 = – .0039 Again ∇y35 – ∇y30 = – .0039 ⇒ .0736 – ∇y30 = – .0039 ⇒ ∇y30 = .0775 Again y30 – y25 = .0775 ⇒ 0.5 – y25 = .0775 ⇒ y25 = 0.4225 ∴ sin 25° = .4225. Example 5. Evaluate: (i) Δ tan–1 x (ii) Δ2 cos 2x where h is the interval of differencing. Sol. (i) Δ tan–1 x = tan–1 (x + h) – tan–1 x = tan–1 x h x x x h + − + + R S T U V W 1 ( ) = tan–1 h hx x 1 2 + + F HG I KJ (ii) Δ2 cos 2x = Δ[cos 2(x + h) – cos 2x] = [cos 2(x + 2h) – cos 2(x + h)] – [cos 2(x + h) – cos 2x]
  • 224. INTERPOLATION 211 = – 2 sin (2x + 3h) sin h + 2 sin (2x + h) sin h = – 2 sin h [2 cos (2x + 2h) sin h] = – 4 sin2 h cos 2(x + h). Example 6. Evaluate: Δ2 5x 12 x 5x 6 2 + + + F HG I KJ; the interval of differencing being unity. Sol. Δ2 5 12 2 3 x x x + + + R S T U V W ( )( ) = Δ2 2 2 3 3 x x + + + F HG I KJ = Δ Δ Δ 2 2 3 3 x x + F HG I KJ + + F HG I KJ L NM O QP = Δ 2 1 3 1 2 3 1 4 1 3 x x x x + − + F HG I KJ + + − + F HG I KJ L NM O QP = – 2Δ 1 2 3 3 1 3 4 ( )( ) ( )( ) x x x x + + R S T U V W − + + R S T U V W Δ = – 2 1 3 4 1 2 3 ( )( ) ( )( ) x x x x + + − + + L NM O QP – 3 1 4 5 1 3 4 ( )( ) ( )( ) x x x x + + − + + L NM O QP = 4 2 3 4 6 3 4 5 ( )( )( ) ( )( )( ) x x x x x x + + + + + + + = 2 5 16 2 3 4 5 ( ) ( )( )( )( ) x x x x x + + + + + . Example 7. If f(x) = exp(ax), evaluate Δnf(x). Sol. Δeax = ea(x+h) – eax = (eah – 1)eax Δ2eax = Δ(Δeax) = Δ[(eah – 1)eax] = (eah – 1)(eah – 1)eax = (eah – 1)2 eax Similarly Δ3 eax = (eah – 1)3 eax Δn eax = (eah – 1)n eax.
  • 225. 212 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 8. With usual notations, prove that Δn 1 x F HG I KJ = (– 1)n . n ! h x (x h) ......(x nh) n + + . Sol. Δn 1 x F HG I KJ = Δn–1 Δ 1 x F HG I KJ = Δn–1 1 1 x h x + − L NM O QP = Δn–1 − + R S T U V W h x x h ( ) = (– h) Δn–2 Δ 1 x x h ( ) + R S T U V W = (– 1) Δn–2 Δ 1 1 x x h − + F HG I KJ L NM O QP = (– 1) Δn–2 1 1 1 2 1 x h x x h x h + − F HG I KJ − + − + F HG I KJ L NM O QP = (– 1) Δn–2 2 1 1 2 x h x x h + − − + L NM O QP = (– 1) Δn–2 − + + L NM O QP 2 2 2 h x x h x h ( )( ) = (– 1)2 Δn–2 2 2 2 ! ( )( ) h x x h x h + + L NM O QP = (– 1)3 Δn–3 3 2 3 3 ! ( )( )( ) h x x h x h x h + + + L NM O QP = (– 1)n n h x x h x nh n ! ( ) ...... ( ) + + . Example 9. Assuming that the following values of y belong to a polynomial of degree 4, compute the next three values: x: 0 1 2 3 4 5 6 7 y: 1 – 1 1 – 1 1 – – –
  • 226. INTERPOLATION 213 Sol. Difference table is: x y Δy Δ2y Δ3y Δ4y 0 1 – 2 1 – 1 4 2 – 8 2 1 – 4 16 – 2 8 3 – 1 4 16 2 Δ3y2 4 1 Δ2y3 16 Δy4 Δ3y3 5 y5 Δ2y4 16 Δy5 Δ3y4 6 y6 Δ2y5 Δy6 7 y7 Since values of y belong to a polynomial of degree 4, the fourth differences must be constant. But Δ4y0 = 16 ∴ Other fourth order differences will be 16. Thus, Δ4y1 = 16 ∴ Δ3y2 – Δ3y1 = 16 ⇒ Δ3y2 = 24 ∴ Δ2y3 – Δ2y2 = 24 ⇒ Δ2y3 = 28 Δy4 – Δy3 = 28 ⇒ Δ y4 = 30 y5 – y4 = 30 ⇒ y5 = 31 Again, Δ4y2 = 16 and solving, we get y6 = 129 and Δ4y3 = 16 gives y7 = 351.
  • 227. 214 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 10. Prove that Δ log f(x) = log 1 f(x) f(x) + L NM O QP Δ . Sol. L.H.S. = log f(x + h) – log f(x) = log [f(x) + Δf(x)] – log f(x) | ∵ Δf(x) = f(x + h) – f(x) = log f x f x f x ( ) ( ) ( ) + L NM O QP Δ = log 1 + L NM O QP Δf x f x ( ) ( ) = R.H.S. Example 11. Prove that ex = Δ2 E F HG I KJ ex . Ee e x 2 x Δ . Sol. Δ2 E F HG I KJ ex = Δ2 E–1 ex = Δ2 ex–h = e–h Δ2 ex R.H.S. = e–h . Δ2 ex . E e e x x Δ2 = e–h . E ex = e–h ex+h = ex. Example 12. Prove that hD = – log (1 – ∇) = sin h–1 (μδ). Sol. hD = log E = – log (E–1) = – log (1 – ∇) | ∵ E–1 = 1 – ∇ Also, μ = 1 2 (E1/2 + E–1/2) δ = E1/2 – E–1/2 ∴ μδ = 1 2 (E – E–1) = 1 2 (ehD – e–hD) = sin h (hD) or hD = sin h–1 (μδ). Example 13. Prove that (i) (E1/2 + E–1/2) (1 + Δ)1/2 = 2 + Δ (ii) Δ = 1 2 δ2 + δ 1 /4 2 + δ (iii) Δ3y2 = ∇3y5. Sol. (i) (E1/2 + E–1/2) E1/2 = E + 1 = 1 + Δ + 1 = Δ + 2 (ii) 1 2 δ2 + δ 1 4 2 + δ = 1 2 (E1/2 – E–1/2)2 + (E1/2 – E–1/2) 1 1 4 1/2 1/2 2 + − − ( ) E E = 1 2 (E + E–1 – 2) + (E1/2 – E–1/2) E E 1/2 1/2 2 + F HG I KJ − = 1 2 (2E – 2) = E – 1 = Δ
  • 228. INTERPOLATION 215 (iii) Δ3y2 = (E – 1)3 y2 = (E3 – 3E2 + 3E – 1) y2 = y5 – 3y4 + 3y3 – y2 ∇3y5 = (1 – E–1) y5 = (1 – 3 E–1 + 3E–2 – E–3) y5 = y5 – 3y4 + 3y3 – y2. Example 14. Prove that (i) Δ + ∇ = Δ Δ ∇ − ∇ where Δ and ∇ are forward difference and backward difference operators respectively. (ii) Δ2 yr r 0 n 1 = − ∑ = Δyn – Δy0 (iii) Δryk = ∇ryk+r. Sol. (i) Δ Δ ∇ − ∇ F HG I KJ yx = E 1 1 E 1 E E 1 1 1 − − − − − F HG I KJ − − yx = E 1 E 1 E E 1 E E 1 − − F HG I KJ − − F HG I KJ − R S | | T | | U V | | W | | yx = E 1 E − F HG I KJ yx = (E – E–1)yx = {(1 + Δ) – (1 – ∇)}yx = (Δ + ∇)yx Hence, Δ Δ ∇ − ∇ = Δ + ∇ (ii) Δ Δ Δ 2 1 0 1 0 1 y y y r r r r n r n = − + = − = − ∑ ∑ ( ) = Δy1 – Δy0 + Δy2 – Δy1 + ...... + Δyn – Δyn–1 = Δyn – Δy0. (iii) ∇ryk+r = (1 – E–1)ryk+r = E 1 E − F HG I KJ r yk+r = (E – 1)r E–ryk+r = Δryk. Example 15. Denoting x n x x 1 x n 1 n F HG I KJ = − − + ( ) ...... ( ) ! , prove that for any polyno- mial φ(x) of degree k φ(x) = i 0 k x i = ∑ F HG I KJ Δi φ(0).
  • 229. 216 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. We have En f(a) = f(a + nh) = f(a) + nC1 Δf(a) + nC2 Δ2f(a) + ...... + nCn Δn f(a) Put a = 0, n = x, we get for h = 1 f(x) = f(0) + xC1 Δf(0) + xC2 Δ2f(0) + ...... + xCx Δx f(0) Again, f(x) = φ(x) is the given polynomial of degree k ∴ Δk φ(x) = constant and higher order differences will be zero. ∴ φ(x) = φ(0) + xC1 Δ φ(0) + ...... + xCk Δk φ(0) = i k x i = ∑ F HG I KJ 1 Δi φ(0). Example 16. Obtain the first term of the series whose second and subsequent terms are 8, 3, 0, – 1, 0. Sol. f(1) = E–1 f(2) = (1 + Δ)–1 f(2) = (1 – Δ + Δ2 – Δ3 + ......) f(2) Since five observations are given ∴ Δ4 f(x) = constant and Δ5f(x) = 0 We construct the table as: x f(x) Δf(x) Δ2f(x) 2 8 – 5 3 3 2 – 3 4 0 2 – 1 5 – 1 2 1 6 0 Hence, f(1) = f(2) – Δf(2) + Δ2 f(2) = 8 – (– 5) + 2 = 15. Example 17. Given u0, u1, u2, u3, u4, and u5, and assuming the fifth order differences to be constant, prove that u 1 2 c 25 (c b) 3(a c) 256 2 1 2 = + − + − where a = u0 + u5, b = u1 + u4, c = u2 + u3. Sol. u 2 1 2 = E5/2 u0 = (1 + Δ)5/2 u0
  • 230. INTERPOLATION 217 = 1 5 2 5 2 5 2 1 2 5 2 5 2 1 5 2 2 5 2 3 5 2 4 5 2 5 + + − F HG I KJ + + − F HG I KJ − F HG I KJ − F HG I KJ − F HG I KJ L N MMMM O Q PPPP Δ Δ Δ ! ...... ! u0 = u0 + 5 2 Δu0 + 15 8 Δ2u0 + 5 16 Δ3u0 – 5 128 Δ4u0 + 3 256 Δ5u0 = u0 + 5 2 (u1 – u0) + 15 8 (u2 – 2u1 + u0) + 5 16 (u3 – 3u2 + 3u1 – u0) + ...... + 3 256 (u5 – 5u4 + 10u3 – 10u2 + 5u1 – u0) = 3 256 (u0 + u5) – 25 256 (u1 + u4) + 75 128 (u2 + u3) = 3 256 25 256 a − b + 75 128 c = 3 256 25 256 a b − + 1 2 11 128 + F HG I KJ c = c a c c b 2 3 25 256 + − + − ( ) ( ) . Example 18. (i) Prove the relation: (1 + Δ)(1 – ∇) ≡ 1 (ii) Find the function whose first difference is ex. (iii) If Δ3ux = 0 prove that: u 1 2 x 1 2 + = (ux + ux+1) – 1 16 (Δ2ux + Δ2ux+1). Sol. (i) (1 + Δ)(1 – ∇) f(x) = (1 + Δ) [f(x) – ∇ f(x)] = (1 + Δ) [f(x) – {f(x) – f(x – h)}] = (1 + Δ) [f (x – h)] = E f(x – h) = 1 . f(x) (1 + Δ) (1 – ∇) ≡ 1. (ii) Δ ex = ex+h – ex = (eh – 1) ex ⇒ ex = Δe e x h − 1 Hence, Δ e e x h − F HG I KJ 1 = ex or f(x) = e e x h − 1 . (iii) u x + 1 2 = E1/2 ux = (1 + Δ)1/2 ux = 1 1 2 1 8 2 + − F HG I KJ Δ Δ ux (10) | ∵ Δ3 ux = 0
  • 231. 218 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, Δ3 ux = 0 ⇒ Δ2ux+1 – Δ2 ux = 0 ⇒ Δ2ux+1 = Δ2ux and Δux = ux+1 – ux ∴ From (10), u x + 1 2 = ux + 1 2 (ux+1 – ux) – 1 8 Δ Δ 2 2 1 2 2 u u x x + F HG I KJ + = 1 2 (ux + ux+1) – 1 16 (Δ2ux + Δ2ux+1). Example 19. (i) Find f(6) given f(0) = – 3, f(1) = 6, f(2) = 8, f(3) = 12; third difference being constant. (ii) Find Δ10(1 – ax)(1 – bx2)(1 – cx3)(1 – dx4). (iii) Evaluate Δn(axn + bxn–1). Sol. (i) The difference table is: x f(x) Δf(x) Δ2f(x) Δ3f(x) 0 – 3 9 1 6 – 7 2 9 2 8 2 4 3 12 f(0 + 6) = E6f(0) = (1 + Δ)6f(0) = (1 + 6Δ + 15Δ2 + 20Δ3) f(0) = – 3 + 6 (9) + 15 (– 7) + 20 (9) = – 3 + 54 – 105 + 180 = 126. (ii) Maximum power of x in the polynomial will be 10 and the coefficient of x10 will be abcd. Here k = abcd, h = 1, n = 10 ∴ Expression = k hn n ! = abcd 10 !. (iii) Δn(axn + bxn–1) = a Δn(xn) + b Δn(xn–1) = a(n) ! + b(0) = a(n) !. Example 20. (i) Prove that if m is a (+)ve integer, then (x 1) m ! (m) + = x m ! (m) + x (m 1) ! (m 1) − −
  • 232. INTERPOLATION 219 (ii) Given u0 + u8 = 1.9243, u1 + u7 = 1.9590 u2 + u6 = 1.9823, u3 + u5 = 1.9956. Find u4. Sol. (i) R.H.S. = x x x m m x x x m m ( ) ...... ( ) ! ( ) ...... ( ) ( ) ! − − + + − − + − 1 1 1 2 1 = x x x x m m ( ) ( ) ...... ( ) ! − − − + 1 2 2 [(x – m + 1) + m] = ( ) ( )( ) ...... ( ) ! ( ) ! ( ) x x x x x m m x m m + − − − + = + 1 1 2 2 1 = L.H.S. (ii) Taking Δ8 u0 = 0 ⇒ (E – 1)8 u0 = 0 ⇒ u8 – 8c1u7 + 8c2u6 – 8c3u5 + 8c4u4 – 8c5u3 + 8c6u2 – 8c7u1 + 8c8u0 = 0 ⇒ (u0 + u8) – 8(u1 + u7) + 28(u2 + u6) – 56(u3 + u5) + 70 u4 = 0 ⇒ u4 = 0.99996. (After giving the values) Example 21. Prove that (i) δ[f(x) g(x)] = μf(x) δg(x) + μg(x) δf(x) (ii) δ f(x) g(x) g(x) f(x) f(x) g(x) g(x ) g(x ) 1 2 1 2 L NM O QP= − − + μ δ μ δ (iii) μ f(x) g(x) f(x) g(x) f(x) g(x) g(x ) g(x ) 1 4 1 2 1 2 L NM O QP= − − + μ μ δ δ The interval of difference is said to be unity. Sol. (i) R.H.S. = μf(x) δg(x) + μg(x) δf(x) = E E 1/2 1/2 2 + − f(x) . (E1/2 – E–1/2) g(x) + E E 1/2 1/2 2 + − g(x) (E1/2 – E–1/2) f(x) = 1 2 [{f(x + 1 2 ) + f(x – 1 2 )}{g(x + 1 2 ) – g(x – 1 2 )} + {g(x + 1 2 ) + g(x – 1 2 )} {f(x + 1 2 ) – f(x – 1 2 )}] = 1 2 [{f(x + 1 2 )g (x + 1 2 ) – f(x + 1 2 ) g(x – 1 2 ) + f(x – 1 2 ) g(x + 1 2 ) – f(x – 1 2 ) g(x – 1 2 )} + {f(x + 1 2 ) g(x + 1 2 ) + f(x + 1 2 ) g(x – 1 2 ) – f(x – 1 2 ) g(x + 1 2 ) – f(x – 1 2 ) g(x – 1 2 )}]
  • 233. 220 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 1 4 f(x + 1 2 ) g(x + 1 2 ) – f(x – 1 2 ) g(x – 1 2 ) = E1/2 f(x) g(x) – E–1/2 f(x) g(x) = (E1/2 – E–1/2)f(x) g(x) = δf(x) g(x). (ii) R.H.S. = μ δ μ δ g x f x f x g x g x g x ( ) ( ) ( ) ( ) ( ) ( ) − − + 1 2 1 2 Numerator of R.H.S. = E E 1/2 1/2 2 + − g(x) (E1/2 – E–1/2) f(x) – E E 1/2 1/2 2 + − f(x) (E1/2 – E–1/2) g(x) = 1 2 [{g(x + 1 2 ) + g(x – 1 2 )}{f(x + 1 2 ) – f(x – 1 2 )} – {f(x + 1 2 ) + f(x – 1 2 )}{g(x + 1 2 ) – g(x – 1 2 )}] = 1 2 [f(x + 1 2 ) g(x + 1 2 ) + f(x + 1 2 ) g(x – 1 2 ) – f(x – 1 2 ) g(x + 1 2 ) – f(x – 1 2 ) g(x – 1 2 )] – 1 2 [f(x + 1 2 ) g(x + 1 2 ) – f(x + 1 2 )g(x – 1 2 ) + f(x – 1 2 ) g(x + 1 2 ) – f(x – 1 2 ) g(x – 1 2 )] = f(x + 1 2 ) g(x – 1 2 ) – f(x – 1 2 ) g(x + 1 2 ) ∴ R.H.S. = f x g x f x g x g x g x ( ) ( ) ( ) ( ) ( ) ( ) + − − − + − + 1 2 1 2 1 2 1 2 1 2 1 2 = f x g x f x g x f x g x f x g x ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) + + − − − = L NM O QP− L NM O QP 1 2 1 2 1 2 1 2 1/2 1/2 E E = (E1/2 – E–1/2) f x g x f x g x ( ) ( ) ( ) ( ) F HG I KJ = L NM O QP δ . (iii) R.H.S. = μ μ δ δ f x g x f x g x g x g x ( ) ( ) ( ) ( ) ( ) ( ) − − + 1 4 1 2 1 2 Numerator of R.H.S. = 1 2 [E1/2 + E–1/2] f(x) . 1 2 (E1/2 + E–1/2) g(x) – 1 4 (E1/2 – E–1/2) f(x) (E1/2 – E–1/2) g(x) = 1 4 [f(x + 1 2 ) + f(x – 1 2 )][g(x + 1 2 ) + g(x – 1 2 )] – 1 4 [f(x + 1 2 ) – f(x – 1 2 )][g(x + 1 2 ) – g(x – 1 2 )]
  • 234. INTERPOLATION 221 = 1 4 [f(x + 1 2 ) g(x + 1 2 ) + f(x + 1 2 ) g(x – 1 2 ) + f(x – 1 2 ) g(x + 1 2 ) + f(x – 1 2 ) g(x – 1 2 ) – 1 4 [f(x + 1 2 ) g(x + 1 2 ) – f(x + 1 2 ) g(x – 1 2 ) – f(x – 1 2 ) g(x + 1 2 ) + f(x – 1 2 ) g(x – 1 2 ) = 1 2 [f(x + 1 2 ) g(x – 1 2 ) + f(x – 1 2 ) g(x + 1 2 )] ∴ R.H.S. = 1 2 1 2 1 2 1 2 1 2 1 2 1 2 [ ( ) ( ) ( ) ( )] ( ) ( ) f x g x f x g x g x g x + − + − + − + = 1 2 2 1 2 1 2 1 2 1 2 1/2 1/2 f x g x f x g x ( ) ( ) ( ) ( ) + + + − − L N MM O Q PP= + − E E f x g x f x g x ( ) ( ) ( ) ( ) L NM O QP= L NM O QP μ . Example 22. Evaluate: (i) Δ(eax log bx) (ii) Δ 2 (x 1) ! x + F HG I KJ; h = 1. Sol. (i) Let f(x) = eax, g(x) = log bx Δ f(x) = ea(x+h) – eax = eax (eah – 1) Also, Δg(x) = log b(x + h) – log bx = log 1 + F HG I KJ h x We know that, Δ f(x) g(x) = f(x + h) Δ g(x) + g(x) Δf(x) ∴ Δ (eax log bx) = ea(x+h) log 1 + F HG I KJ h x + (log bx) eax(eah – 1) = eax e h x e bx ah ah log ( ) log 1 1 + F HG I KJ + − L NM O QP. (ii) Let f(x) = 2x, g(x) = (x + 1) ! ∴ Δf(x) = 2x+1 – 2x = 2x and Δ g(x) = (x + 1 + 1) ! – (x + 1) ! = (x + 1) (x + 1) ! We know that, Δ f x g x ( ) ( ) L NM O QP = g x f x f x g x g x h g x ( ) ( ) ( ) ( ) ( ) ( ) Δ Δ − + = ( ) !. . ( ) ( ) ! ( ) ! ( )! x x x x x x x + − + + + + + 1 2 2 1 1 1 1 1 (∵ h = 1) = 2 1 1 1 2 1 2 x x x x x x x ( ) ! ( ) ( ) ! ( ) ! ( ) ! + − − + + = − + 2x.
  • 235. 222 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 23. Evaluate: (i) Δn [sin (ax + b)] (ii) Δn [cos (ax + b)]. Sol. (i) Δ sin (ax + b) = sin [a (x + h) + b] – sin (ax + b) = 2 sin ah 2 cos a x h b + F HG I KJ + L NM O QP 2 = 2 sin ah 2 sin ax b ah + + + F HG I KJ π 2 ∴ Δ2 sin (ax + b) = Δ 2 2 2 sin sin ah ax b ah + + + F HG I KJ L NM O QP π = 2 2 2 2 2 2 sin sin sin ah ah ax b ah ah F HG I KJ F HG I KJ + + + + + L NM O QP π π = 2 2 2 sin ah F HG I KJ sin ax b ah + + + F HG I KJ L NM O QP 2 2 π Proceeding in the same manner, we get Δ3 sin (ax + b) = 2 2 3 2 3 sin sin ( ) ah ax b ah F HG I KJ + + + L NM O QP π Δn sin (ax + b) = 2 2 2 sin sin ( ) ah ax b n ah n F HG I KJ + + + L NM O QP π Similarly, (ii) Δn cos (ax + b) = 2 2 2 sin cos ah ax b n ah n F HG I KJ + + + F HG I KJ L NM O QP π . Example 24. Prove that (i) μδ = 1 2 (Δ + ∇) (ii) 1 + δ δ μ 2 2 2 2 1 F HG I KJ = + (iii) ∇2 = h2D2 – h3D3 + 7 12 h4D4. ...... (iv) ∇ – Δ = – ∇Δ Sol. (i) μδyx = μ(E1/2 – E–1/2)yx = μ( y y x h x h + − − 2 2 ) = μ( ) ( ) y y x h x h + − − 2 2 μ
  • 236. INTERPOLATION 223 = 1 2 (E1/2 + E–1/2)( ) y x h + − 2 1 2 (E1/2 + E–1/2)( ) y x h − 2 = 1 2 (yx+h + yx) – 1 2 (yx + yx–h) = 1 2 (yx+h – yx) + 1 2 (yx – yx–h) = 1 2 (Δyx) + 1 2 (∇yx) = 1 2 (Δ + ∇)yx Hence, μδ = 1 2 (Δ + ∇) (ii) L.H.S. = 1 2 2 + F HG I KJ R S | T | U V | W | δ yx = 1 (E E ) 2 1/2 1/2 2 + − R S T | U V W | − yx = 1 E E 2 –1 + + − F HG I KJ R S | T | U V | W | 2 yx = 1 2 (E + E–1)yx R.H.S. = ( ) 1 2 2 + δ μ yx = 1 1 4 1/2 1/2 2 1/2 1/2 2 1/2 + − + R S T U V W L NM O QP − − ( ) . ( ) E E E E yx = 1 1/2 + − F HG I KJ R S | T | U V | W | − (E E ) 4 1 2 yx = E E 2 4 2 2 1/2 + + F HG I KJ − yx = E E 2 1 + F HG I KJ − yx Hence L.H.S. = R.H.S. (iii) E = ehD and ∇ = 1 – E–1 ∴ ∇2 = (1 – E–hD)2 = 1 1 2 3 4 2 3 4 2 − − + − + − R S T U V W L N MM O Q PP h h h h D D D D ( ) ! ( ) ! ( ) ! ... = h h h h D D D D − + − + R S T U V W ( ) ! ( ) ! ( ) ! ... 2 3 4 2 2 3 4 = h2D2 1 2 6 2 − − + R S T U V W L N MM O Q PP h h D D)2 ( ...
  • 237. 224 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = h2D2 1 2 6 2 2 6 2 + − + R S T U V W − − + R S T U V W L N MM O Q PP h h h h D D) D D) 2 2 ( ... ( ... = h2D2 1 1 4 1 3 2 − + + F HG I KJ − L NM O QP h h D D ( ) ... = h2D2 1 7 12 2 2 − + − F HG I KJ h h D D ... = h2D2 – h3D3 + 7 12 h4D4 – ... (iv) ∇ – Δ = (1 – E–1) – (E – 1) = E 1 E − F HG I KJ – (E – 1) = (E – 1)(E–1 – 1) = – (E – 1) (1 – E–1) = – ∇Δ ASSIGNMENT 4.1 1. Form a table of differences for the function: f(x) = x3 + 5x – 7 for x = – 1, 0, 1, 2, 3, 4, 5 Continue the table to obtain f(6) and f(7). 2. Given the set of values x: 10 15 20 25 30 35 y: 19.97 21.51 22.47 23.52 24.65 25.89. Form the difference table and find the values of Δ2 y10 , Δy20 , Δ3 y15 , and Δ5y10. 3. Write the forward difference table for x: 10 20 30 40 y: 1.1 2.0 4.4 7.9. 4. Construct the table of differences for the data below: x: 0 1 2 3 4 f(x): 1.0 1.5 2.2 3.1 4.6 Evaluate Δ3 f(2). 5. Prove that: (i) ∇ = ΔE–1 = E–1Δ = 1 – E–1 (ii) E1/2 = μ + 1 2 δ (iii) δ = ΔE–1/2 = ∇E1/2 (iv) δ(E1/2 + E–1/2) = ΔE–1 + Δ (v) Δ∇ = ∇Δ = δ2 (vi) δ = Δ(1 + Δ)–1/2 = ∇(1 – ∇)–1/2 (vii) E = (1 – Δ)–1.
  • 238. INTERPOLATION 225 6. ux is a function of x for which fifth differences are constant and u1 + u7 = –786, u2 + u6 = 686, u3 + u5 = 1088. Find u4. 7. Prove that: (i) u4 = u3 + Δu2 + Δ2u1 + Δ3u1 (ii) u4 = u0 + 4Δu0 + 6 Δ2u–1 + 10 Δ3u–1. 8. Prove that: Δ sin–1 x = sin–1 [(x + 1) 1 2 − x – x 1 1 2 − + ( ) x ]. 9. Evaluate: (i) (E–1 Δ) x3 (ii) Δ2 3 E F HG I KJx ; h = 1. 10. Evaluate: (i) Δ e e e x x x + F HG I KJ − (ii) Δ cos ax the interval of difference being h. 4.8 FACTORIAL NOTATION A product of the form x(x – 1)(x – 2) ...... (x – r + 1) is denoted by [x]r and is called a factorial. Particularly, [x] = x; [x]2 = x(x – 1); [x]3 = x (x – 1)(x – 2), etc. In case the interval of difference is h, then [x]n = x(x – h) (x – 2h) ...... (x – n − 1 h) Factorial notation helps in finding the successive differences of a polynomial directly by the simple rule of differentiation. 4.9 TO SHOW THAT (i) Δn[x]n = n ! (ii) Δn+1 [x]n = 0 Δ[x]n = [(x + h)]n – [x]n = (x + h)(x + h – h) (x + h – 2h) ...... (x + h – n − 1 h) – x(x – h) (x – 2h) ...... (x – n − 1 h) = x(x – h) ...... (x – n − 2 h) [x + h – (x – nh + h)] = nh [x]n–1
  • 239. 226 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Similarly, Δ2[x]n = Δ[nh [x]n–1] = nh Δ[x]n–1 = n(n – 1) h2 [x]n–2 Δn[x]n = n(n – 1) ..... 2 . 1 . hn–1 (x + h – x) = n ! hn Also, Δn + 1[x]n = n ! hn – n ! hn = 0 when h = 1, Δ[x]n = n[x]n–1 and Δn[x]n = n ! Hence the result of difference [x]r is analogous to that of difference xr when h = 1. 4.10 RECIPROCAL FACTORIAL x(–n) = 1 ( )( ) x n n + , the interval of difference being unity. By definition of x(n), we have x(n) = (x – n − 1 h) x(n–1) (11) when the interval of difference is h. ∴ When n = 0, we have x(0) = (x + h) x(– 1) (12) Since, Δx(n) = nhx(n–1) (13) when n = 1, Δx(1) = hx(0). ⇒ Δx = h x(0) ⇒ h = hx(0) ⇒ x(0) = 1 From (12), x(–1) = 1 ( ) x h + (14) when n = – 1, from (11), x(–1) = (x + 2h) x(–2) ⇒ 1 x h + = (x + 2h) x(–2) ⇒ x(–2) = 1 2 ( )( ) x h x h + + In general, x(–n) = 1 2 ( )( ) ...... ( ) x h x h x nh + + + (15) x(–n) = 1 ( )( ) x nh n + Here x(–n) is called the reciprocal factorial where n is a (+)ve integer. Particular case. When h = 1, x(–n) = 1 ( )( ) x n n + .
  • 240. INTERPOLATION 227 4.11 MISSING TERM TECHNIQUE Suppose n values out of (n + 1) values of y = f(x) are given, the values of x being equidistant. Let the unknown value be N. We construct the difference table. Since only n values of y are known, we can assume y = f(x) to be a polynomial of degree (n – 1) in x. Equating to zero the nth difference, we can get the value of N. EXAMPLES Example 1. Express y = 2x3 – 3x2 + 3x – 10 in factorial notation and hence show that Δ3y = 12. Sol. Let y = A[x]3 + B[x]2 + c[x] + D Using the method of synthetic division, we divide by x, x – 1, x – 2 etc. successively, then 1 2 – 3 3 – 10 = D 2 – 1 2 2 – 1 2 = C 4 3 2 3 = B 2 = A Hence, y = 2[x]3 + 3[x]2 + 2[x] – 10 ∴ Δy = 6[x]2 + 6[x] + 2 Δ2y = 12[x] + 6 Δ3y = 12 which shows that the third differences of y are constant. Example 2. Express f(x) = x4 – 12x3 + 24x2 – 30x + 9 and its successive differences in factorial notation. Hence show that Δ5f(x) = 0. Sol. Let f(x) = A[x]4 + B[x]3 + C[x]2 + D[x] + E Using the method of synthetic division, we divide by x, x – 1, x – 2, x – 3, etc. successively, then
  • 241. 228 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 1 1 – 12 24 – 30 9 = E 1 – 11 13 2 1 – 11 13 – 17 = D 2 – 18 3 1 – 9 – 5 = C 3 4 1 – 6 = B 1 = A Hence, f(x) = [x]4 – 6[x]3 – 5[x]2 – 17[x] + 9 ∴ Δf(x) = 4[x]3 – 18[x]2 – 10[x] – 17 Δ2f(x) = 12[x]2 – 36[x] – 10 Δ3f(x) = 24[x] – 36 Δ4f(x) = 24 and Δ5f(x) = 0. Example 3. Obtain the function whose first difference is 9x2 + 11x + 5. Sol. Let f(x) be the required function so that Δf(x) = 9x2 + 11x + 5 Let 9x2 + 11x + 5 = 9[x]2 + A[x] + B = 9x(x – 1) + Ax + B Putting x = 0, B = 5 x = 1, A = 20 ∴ Δf(x) = 9[x]2 + 20[x] + 5 Integrating, we get f(x) = 9 [ ] x 3 3 + 20 [ ] x 2 2 + 5[x] + c = 3x(x – 1) (x – 2) + 10x(x – 1) + 5x + c = 3x3 + x2 + x + c where c is the constant of integration. Example 4. Find the missing values in the table: x: 45 50 55 60 65 y: 3 – 2 – – 2.4.
  • 242. INTERPOLATION 229 Sol. The difference table is as follows: x y Δy Δ2y Δ3y 45 3 y1 – 3 50 y1 5 – 2y1 2 – y1 3 y1 + y3 – 9 55 2 y1 + y3 – 4 y3 – 2 3.6 – y1 – 3y3 60 y3 – 0.4 – 2y3 – 2.4 – y3 65 – 2.4 As only three entries y0, y2, y4 are given, the function y can be represented by a second degree polynomial. ∴ Δ3y0 = 0 and Δ3y1 = 0 ⇒ 3y1 + y3 = 9 and y1 + 3y3 = 3.6 Solving these, we get y1 = 2.925, y2 = 0.225. Example 5. Express f(x) = x 1 (x 1)(x 3) − + + in terms of negative factorial polynomials. Sol. f(x) = x x x x x x x x − + + = − + + + + 1 1 3 1 2 1 2 3 ( )( ) ( )( ) ( )( )( ) = 1 1 4 1 2 4 1 2 3 x x x x x x + − + + + + + + ( )( ) ( )( )( ) = x(–1) – 4x(–2) + 4x(–3). Example 6. Find the relation between α, β, and γ in order that α + βx + γx2 may be expressible in one term in the factorial notation. Sol. Let f(x) = α + βx + γx2 = (a + bx)(2) where a and b are certain unknown constants. Now, (a + bx)(2) = (a + bx) [a + b(x – 1)] = (a + bx) (a – b + bx) = (a + bx)2 – ab – b2x = (a2 – ab) + (2ab – b2)x + b2x2 = α + βx + γx2
  • 243. 230 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Comparing the coefficients of various powers of x, we get α = a2 – ab, β = 2ab – b2, γ = b2 Eliminating a and b from the above equations, we get γ2 + 4αγ = β2 which is the required relation. Example 7. Given, log 100 = 2, log 101 = 2.0043, log 103 = 2.0128, log 104 = 2.0170. Find log 102. Sol. Since four values are given, Δ4f(x) = 0. Let the missing value be y2. x y Δy Δ2y Δ3y Δ4y 100 2 .0043 101 2.0043 y2 – 2.0086 y2 – 2.0043 6.0257 – 3y2 102 y2 4.0171 – 2y2 6y2 – 12.0514 2.0128 – y2 3y2 – 6.0257 103 2.0128 y2 – 2.0086 .0042 104 2.0170 Since Δ4y = 0 ∴ 6y2 – 12.0514 = 0 ⇒ y2 = 2.0086. Example 8. Estimate the missing term in the following table: x: 0 1 2 3 4 y = f(x): 1 3 9 ? 81. Sol. We are given 4 values ∴ Δ4f(x) = 0 ∀ x ⇒ (E – 1)4 f(x) = 0 ∀ x ⇒ (E4 – 4E3 + 6E2 – 4E + 1) f(x) = 0 ∀ x ⇒ f(x + 4) – 4f(x + 3) + 6f(x + 2) – 4f(x + 1) + f(x) = 0 ∀ x where the interval of difference is 1. Now given x = 0, we obtain f(4) – 4f(3) + 6f(2) – 4f(1) + f(0) = 0
  • 244. INTERPOLATION 231 ⇒ 81 – 4f(3) + 54 – 12 + 1 = 0 (From table) ⇒ 4f(3) = 124 ⇒ f(3) = 31. Example 9. A second degree polynomial passes through (0, 1), (1, 3), (2, 7), (3, 13). Find the polynomial. Sol. Let f(x) = Ax2 + Bx + C The difference table is: x f(x) Δf(x) Δ2f(x) 0 1 2 1 3 2 4 2 7 2 6 3 13 Δf(x) = A Δx2 + BΔx + ΔC = A {(x + 1)2 – x2} + B(x + 1 – x) + 0 = A(2x + 1) + B Put x = 0, Δf(0) = A + B ⇒ A + B = 2 Also, Δ2f(x) = 2A ⇒ Δ2f(0) = 2 = 2A ⇒ A = 1 Also, B = 1 ∴ Polynomial is f(x) = x2 + x + 1. Example 10. Estimate the production for 1964 and 1966 from the following data: Year: 1961 1962 1963 1964 1965 1966 1967 Production: 200 220 260 — 350 — 430 Sol. Since five figures are known, assume all the fifth order differences as zero. Since two figures are unknown, we need two equations to determine them. Hence Δ5y0 = 0 and Δ5y1 = 0 ⇒ (E – 1)5y0 = 0 and (E – 1)5y1 = 0 ⇒ y5 – 5y4 + 10y3 – 10y2 + 5y1 – y0 = 0 and y6 – 5y5 + 10y4 – 10y3 + 5y2 – y1 = 0
  • 245. 232 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Substituting the known values, we get y5 – 1750 + 10y3 – 2600 + 1100 – 200 = 0 and 430 – 5y5 + 3500 – 10y3 + 1300 – 220 = 0 ⇒ y5 + 10y3 = 3450 (16) and – 5y5 – 10y3 = – 5010 (17) Adding (16) and (17), we get – 4y5 = – 1560 ⇒ y5 = 390 From (16), 390 + 10y3 = 3450 ⇒ 10y3 = 3060 ⇒ y3 = 306 Hence, production for year 1964 = 306 and production for year 1966 = 390. Example 11. Find the missing figures in the following table: x: 2 2.1 2.2 2.3 2.4 2.5 2.6 y: 0.135 — 0.111 0.100 — 0.082 0.074. Sol. Here five values are given. ∴ It is assumed that fifth differences are zero and hence both Δ5 y2.0 and Δ5 y2.1 are zero. Δ5 y2.0 = (E – 1)5 y2.0 = (E5 – 5E4 + 10E3 – 10E2 + 5E – 1)y2.0 = y2.5 – 5y2.4 + 10y2.3 – 10y2.2 + 5y2.1 – y2.0 |∵ h = 0.1 = .082 – 5y2.4 + 1 – 1.11 + 5y2.1 – .135 = – 5y2.4 + 5y2.1 – .163 Since Δ5 y2.0 = 0 ∴ – 5y2.4 + 5y2.1 – .163 = 0 (18) Further, Δ5 y2.1 = (E – 1)5 y2.1 = (E5 – 5E4 + 10E3 – 10E2 + 5E – 1)y2.1 = y2.6 – 5y2.5 + 10y2.4 – 10y2.3 + 5y2.2. – y2.1 = .074 – (5 × .082) + 10y2.4 – 1 + .555 – y2.1
  • 246. INTERPOLATION 233 = .074 – .41 + 10y2.4 – 1 + .555 – y2.1 = 10y2.4 – y2.1 – .781 Since Δ5 y2.1 = 0 ∴ 10y2.4 – y2.1 – .781 = 0 (19) Solving (18) and (19), we get y2.1 = .123 and y2.4 = .0904. Example 12. Find the missing value of the following data: x: 1 2 3 4 5 f(x): 7 × 13 21 37. Sol. Since four values are known, assume all the fourth order differences are zero. Since one value is unknown we assume Δ4y1 = 0 ⇒ (E – 1)4 y1 = 0 ⇒ (E4 – 4E3 + 6E2 – 4E + 1)y1 = 0 ⇒ y5 – 4y4 + 6y3 – 4y2 + y1 = 0 | ∵ h = 1 ⇒ 37 – 4(21) + 6(13) – 4y2 + 7 = 0 ⇒ 38 – 4y2 = 0 ⇒ y2 = 9.5 Hence the required missing value is 9.5. ASSIGNMENT 4.2 1. Estimate the missing term in the following: x: 1 2 3 4 5 6 7 y: 2 4 8 — 32 64 128 Explain why the result differs from 16? 2. Estimate the production of cotton in the year 1935 from the data given below: Year x: 1931 1932 1933 1934 1935 1936 1937 Production f(x): 17.1 13 14 9.6 — 12.4 18.2 (in millions)
  • 247. 234 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3. From the following data, find the value of U47: U46 = 0.2884, U48 = 0.5356, U49 = 0.6513, U50 = 0.7620. [Hint: Δ4 Ux = 0 ⇒ (E – 1)4 Ux = 0.] 4. Find by constructing the difference table, the tenth term of the series 3, 14, 39, 84, 155, 258, ...... [Hint: f(10) = E9 f(1) = (1 + Δ)9 f(1)] 5. Find the missing terms in the following table: x: 1 2 3 4 5 6 7 8 f(x): 1 8 ? 64 ? 216 343 512 6. Represent the following polynomials: (i) 11x4 + 5x3 + x – 15 (ii) 2x3 – 3x2 + 3x + 10 and its successive differences in factorial notation. 4.12 METHOD OF SEPARATION OF SYMBOLS The relationship E = 1 + Δ can be used to prove a number of useful identities. The method is known as separation of symbols. 4.13 DETECTION OF ERRORS BY USE OF DIFFERENCE TABLES Difference tables can be used to check errors in tabular values. Let f(x1), f(x2), ......, f(xn) be the true values of f(x) at x = x1, x2, ......, xn. If f(x) at x = xi is incorrect, we have to determine the error in such cases and correct the functional value. In particular, let the functional value at x = x5 be f(x5) + e and let other true functional values f(x1), f(x2), ......, f(x4), f(x6) , ......, f(x9) be known.
  • 248. INTERPOLATION 235 x f(x) Δf(x) Δ2f(x) Δ3f(x) Δ4f(x) x1 f(x1) Δf(x1) x2 f(x2) Δ2f(x1) Δf(x2) Δ3f(x1) x3 f(x3) Δ2f(x2) Δ4f(x1) + e Δf(x3) Δ3f(x2) + e x4 f(x4) Δ2f(x3) + e Δ4f(x2) – 4e Δ f(x4) + e Δ3 f(x3) – 3e x5 f x ( ) 5 Δ2 f(x4) – 2e Δ4f(x3) + 6e Δ f(x5) – e Δ3 f(x4) + 3e x6 f(x6) Δ2f(x5) + e Δ4f(x4) – 4e Δ f(x6) Δ3f(x5) – e x7 f(x7) Δ2f(x6) Δ4 f(x5) + e Δ f(x7) Δ3f(x6) x8 f(x8) Δ2f(x7) Δ f(x8) x9 f(x9) From the table, we observe that, (i) Error spreads in triangular form. (ii) Coefficient of e’s are binomial coefficient with alternate signs + , –, ....... (iii) Algebraic sum of errors in each column is 0. (iv) In even differences columns, the maximum error occurs in a horizontal line in which incorrect y lies. (v) In odd differences columns, the incorrect value of y lies between two middle terms. (vi) If nth differences are constant, (n + 1)th differences vanish. The sum of all the values in (n + 1)th differences column is zero or the sum is very small as compared to the functional values These observations help us in finding out the error, and hence the required correct value of y can be found. EXAMPLES Example 1. Find the error and correct the wrong figure in the following functional values: 2, 5, 10, 18, 26, 37, 50. ⎯⎯⎯⎯→ R S | T | R S | | | T | | | R S | | | | T | | | | R S | | | | | | T | | | | | | ⎯⎯⎯⎯→
  • 249. 236 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. x y Δy Δ2y Δ3y 1 2 3 2 5 2 5 1 3 10 3 8 – 3 4 18 ←⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 0 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 8 3 5 26 3 11 – 1 6 37 2 13 7 50 Sum of all the third differences is zero. Adjacent values – 3, 3 are equal in magnitude. The horizontal line between – 3 and 3 points out the incorrect functional value 18. The coefficient of the first middle term on expansion of (1– p)3 = – 3 ⇒ – 3e = – 3 ⇒ e = 1 ∴ The correct functional value = 18 – 1 = 17. Example 2. Locate the error in the following entries and correct it: 1.203, 1.424, 1.681, 1.992, 2.379, 2.848, 3.429, and 4.136. Sol. Difference table is as follows: 103y 103Δy 103Δ2y 103Δ3y 103Δ4y 1203 221 1424 36 257 18 1681 54 4 311 22 1992 76 – 16 387 6 2379←⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 82 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 24 469 30 2848 112 – 16 581 14 3429 126 707 4136
  • 250. INTERPOLATION 237 The sum of all values in the column of fourth difference is – .004, which is very small as compared to the sum of values in other columns. ∴ Δ4y = 0 The errors in this column are e, – 4e, 6e, – 4e, and e. The term of maximum value = 24 ⇒ 6e = 24 ⇒ e = 4 The error lies in 2379. Hence, the required correct entry = 2379 – 4 = 2375 Hence, the correct value = 2.375. Example 3. Using the method of separation of symbols, show that u0 – u1 + u2 – u3 + ... = 1 2 u 1 4 u 1 8 0 0 − + Δ Δ2u0 – ...... . Sol. R.H.S. = 1 2 1 1 2 1 2 1 2 2 3 − + F HG I KJ − F HG I KJ + L N MM O Q PP Δ Δ Δ ...... u0 = 1 2 1 1 1 2 1 2 1 1 2 0 1 . + F HG I KJ = + F HG I KJ − Δ Δ u u0 = (2 + Δ)–1 u0 = (1 + E)–1 u0 = (1 – E + E2 – E3 + ...) u0 = u0 – u1 + u2 – u3 + ...... = L.H.S. Example 4. Using the method of separation of symbols, show that: Δn ux–n = ux – nux–1 + n(n 1) 2 − ux–2 + ...... + (– 1)n ux–n. Sol. R.H.S. = ux – nE–1 ux + n n ( ) − 1 2 E–2 ux + ...... + (– 1)n E–n ux = 1 1 2 1 1 2 − + − + + − L NM O QP − − − n n n n n E E E ( ) ...... ( ) ux = (1 – E–1)n ux = 1 1 − F HG I KJ E n ux = E 1 E − F HG I KJ n ux = Δn n E ux = Δn E–n ux = Δn ux–n = L.H.S.
  • 251. 238 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 5. Show that: ex u x u x 2 ! u ....... 0 0 2 2 0 + + + F HG I KJ Δ Δ = u0 + u1x + u2 x 2 ! 2 + ...... . Sol. L.H.S. = ex 1 2 2 2 + + + F HG I KJ x x Δ Δ ! ...... u0 = ex . exΔ u0 = ex(1+Δ) u0 = exE u0 = 1 2 2 2 + + + F HG I KJ x x E E ! ...... u0 = u xu x u ....... 0 1 2 2 2 + + + F HG I KJ ! = R.H.S. Example 6. Prove the following identity: u1x + u2x2 + u3x3 + ...... = x 1 x − u1 + x (1 x) 2 2 − Δu1 + ..... Sol. L.H.S. = xu1 + x2 E u1 + x3 E2u1 + ...... = x (1 + xE + x2E2 + ......) u1 = x . 1 1 ( ) − xE u1 = x . 1 1 1 [ ( )] − + x Δ u1 = x 1 1 − − L NM O QP x x Δ u1 = x x 1− 1 1 1 − − L N MM O Q PP x x Δ u1 = x x x x 1 1 1 1 − − − L NM O QP − Δ (u1) = x x x x x x 1 1 1 1 2 2 2 − + − + − + L NM O QP Δ Δ ( ) ...... u1 = x x 1 − u1 + x x 2 2 1 ( ) − Δu1 + x x 3 3 1 ( ) − Δ2u1 + ...... = R.H.S. Example 7. Prove that: ux = ux–1 + Δux–2 + Δ2ux–3 + ...... + Δn–1 ux–n + Δnux–n Hence, or otherwise, prove that: u3 = u2 + Δu1 + Δ2u0 + Δ3u0. Sol. ux – Δn ux–n = (1 – Δn E–n)ux = 1 − F HG I KJ L N MM O Q PP Δ E n ux = 1 En (En – Δn) ux = 1 E E E n n n − − F HG I KJ Δ Δ ux | ∵ 1 + Δ = E = 1 En [En–1 + ΔEn–2 + Δ2En–3 + ...... + Δn–1] ux = (E–1 + ΔE–2 + Δ2E–3 + ...... + Δn–1 E–n) ux
  • 252. INTERPOLATION 239 = ux–1 + Δux–2 + Δ2ux–3 + ...... + Δn–1 ux–n To prove the second result, put x = 3 and n = 3. Example 8. Prove that: Δxn – 1 2 Δ2xn + 1.3 2.4 Δ3xn – 1 . 3 . 5 2 . 4 .6 Δ4xn + ...... n terms = x 1 2 n + F HG I KJ – x 1 2 n − F HG I KJ Sol. L.H.S. = Δ 1 1 2 1 2 3 2 1 2 2 − + − F HG I KJ − F HG I KJ + ∞ L N MMMM O Q PPPP Δ Δ . . ...... xn = Δ (1 + Δ)–1/2 xn = Δ E–1/2 xn = Δ x n − F HG I KJ 1 2 = x n + − F HG I KJ 1 1 2 – x n − F HG I KJ 1 2 = x n + F HG I KJ 1 2 – x n − F HG I KJ 1 2 = R.H.S. Example 9. Prove that: ux – 1 8 Δ2ux–1 + 1.3 8.16 Δ4ux–2 – 1 . 3 . 5 8 .16 . 24 Δ6 ux–3 + ...... = u x 1 2 + – 1 2 Δu x 1 2 + + 1 4 Δ2u x 1 2 + – 1 8 Δ3u x 1 2 + + .... Sol. L.H.S. = ux – 1 8 Δ2 E–1 ux + 1.3 8.16 Δ4 E–2ux – 1 3 5 8 16 24 . . . . Δ6 E–3 ux + ...... = ux – 1 2 4 2 Δ E F HG I KJ ux + − F HG I KJ − − F HG I KJ F HG I KJ 1 2 1 2 1 1 2 4 2 2 . Δ E ux + − F HG I KJ − − F HG I KJ − − F HG I KJ F HG I KJ 1 2 1 2 1 1 2 2 1 2 3 4 2 3 . . Δ E ux + ...... = 1 1 2 4 1 2 1 2 1 2 4 2 2 2 + − F HG I KJ F HG I KJ + − F HG I KJ − − F HG I KJ F HG I KJ + L N MMMM O Q PPPP Δ Δ E E ! ...... ux
  • 253. 240 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 1 4 2 1/2 + F HG I KJ − Δ E ux = 4 4 2 1/2 E E + F HG I KJ − Δ ux = 4 1 4 2 1/2 ( ) + + L NM O QP − Δ Δ E ux = ( ) 2 4 2 1/2 + L NM O QP − Δ E ux = 4 1/2 E (2 + )2 Δ L NM O QP ux = 2 E1/2 1 2 + Δ F HG I KJ ux = E1/2 1 1 + F HG I KJ − Δ 2 ux = E1/2 1 2 2 2 − + − F HG I KJ Δ Δ 2 ...... ux = u x + 1 2 – 1 2 Δu x + 1 2 + 1 4 Δ2u x + 1 2 – ...... = R.H.S. Example 10. Use the method of separation of symbols to prove the following identities: (i) ux + xC1 Δ2ux–1 + xC2Δ4ux–2 + ...... = u0 + xC1 Δu1 + xC2Δ2u2 + ...... (ii) ux+n = un + xC1 Δun–1 + x+1C2 Δ2un–2 + x+2C3 Δ3un–3 + ...... (iii) u0 + u1 + u2 + ....... + un = n+1C1 u0 + n+1C2 Δu0 + n+1C3 Δ2u0 + ...... + Δnu0. Sol. (i) L.H.S. = (1 + xC1 Δ2E–1 + xC2 Δ4 E–2 + ......) ux = (1 + Δ2E–1)x ux = E E + F HG I KJ Δ2 x ux = E E E 2 − + F HG I KJ 1 x ux = 1 Ex [1 + E (E – 1)]x ux = E–x (1 + ΔE)x ux = (1 + ΔE)x u0 = (1 + xC1 ΔE + xC2 Δ2E2 + .....) u0 = u0 + xC1 Δu1 + xC2 Δ2u2 + ...... = R.H.S. (ii) R.H.S. = un + xC1 ΔE–1 un + x+1C2 Δ2E–2 un + x+2C3 Δ3E–3un + ...... = (1 + xC1 ΔE–1 + x+1C2 Δ2E–2 + ......) un = (1 – ΔE–1)–x un = 1 − F HG I KJ − Δ E x un = E E − F HG I KJ − Δ x un = 1 E F HG I KJ −x un = Exun = un+x = L.H.S.
  • 254. INTERPOLATION 241 (iii) L.H.S. = u0 + Eu0 + E2 u0 + ..... + Enu0 = (1 + E + E2 + ....... + En) u0 = E E 1 n+ − − F HG I KJ 1 1 u0 = ( ) 1 1 1 + − L NM O QP + Δ Δ n u0 = 1 Δ [(1 + n+1C1 Δ + n+1C2 Δ2 + n+1C3 Δ3 + ...... + Δn+1) – 1] u0 = n+1C1 u0 + n+1C2 Δ u0 + n+1C3 Δ2 u0 + ...... + Δn u0 = R.H.S. Example 11. Sum the following series 13 + 23 + 33 + ...... + n3 using the calculus of finite differences. Sol. Let us denote 13, 23, 33, ...... by u0, u1, u2, ......, respectively, we get S = u0 + u1 + u2 + ...... + un–1 = (1 + E + E2 + ...... + En–1) u0 = E E n n u − − F HG I KJ = + − L NM O QP 1 1 1 1 0 ( ) Δ Δ u0 = 1 1 1 2 1 2 3 1 2 3 0 Δ Δ Δ Δ Δ + + − + − − + + − L NM O QP n n n n n n u n ( ) ! ( )( ) ! ...... = n + n n ( ) ! − 1 2 Δ u0 + n n n ( ) ( ) ! − − 1 2 3 Δ2 u0 + ...... Now, Δ u0 = u1 – u0 = 23 – 13 = 7 and Δ2 u0 = u2 – 2u1 + u0 = 33 – 2(2)3 + (1)3 = 12 Similarly, Δ3 u0 = u3 – 3u2 + 3u1 – u0 = (4)3 – 3(3)3 + 3(2)3 – (1)3 = 6 and Δ4u0 , Δ5u0 , ......are all zero as ur = r3 is a polynomial of the third degree. ∴ S = n + n n ( ) ! − 1 2 (7) + n n n ( ) ( ) − − 1 2 6 (12) + n n n n ( ) ( ) ( ) − − − 1 2 3 24 (6) = n2 4 (n2 + 2n + 1) = n n ( ) + L NM O QP 1 2 2 . Example 12. Sum to n terms, the series 1.2Δxn – 2.3Δ2xn + 3.4Δ3xn – 4.5Δ4xn + ... Sol. Since Δn+m xn = 0 for m ≥ 1, the sum of the above series to n terms is the same up to infinity. Let, S = 1.2Δxn – 2.3Δ2xn + 3.4Δ3xn – ... ΔS = 1.2Δ2xn – 2.3Δ3xn + 3.4Δ4xn – ...
  • 255. 242 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence, (Δ + 1)S = 1.2Δxn – 2.2Δ2xn + 2.3Δ3xn – 2.4Δ4xn + ... = 2Δ(1 – 2Δ + 3Δ2 – ...)xn = 2Δ(1 + Δ)–2 xn or S = 2Δ(1 + Δ)–3 xn = 2ΔE–3 xn = 2Δ(x – 3)n = 2(E – 1)(x – 3)n = 2[E(x – 3)n – (x – 3)n] = 2[(x – 2)n – (x – 3)n]. ASSIGNMENT 4.3 1. The values of a polynomial of degree 5 are tabulated below: If f(3) is known to be in error, find its correct value. x: 0 1 2 3 4 5 6 f(x): 1 2 33 254 1025 3126 7777. 2. If y = f(x) is a polynomial of degree 3 and the following table gives the values of x and y, locate and correct the wrong values of y x: 0 1 2 3 4 5 6 y: 4 10 30 75 160 294 490. 3. Prove the identities: (i) ux – Δ2ux + Δ3ux – Δ5ux + Δ6ux – Δ8ux + ...... = ux – Δ2ux – 1 + Δ4 ux – 2 – Δ6 ux – 3 + Δ8 ux – 4 – ...... (ii) u u x x x x 2 0 0 2 1 2 1 4 1 2 4 = ∞ = ∞ ∑ ∑ = + − + − F HG I KJ Δ Δ ...... u0. 4. Prove that: x2 + 1 2 (1 + x)2 + 1 22 (2 + x)2 + 1 23 (3 + x)2 + ...... = 2 (x2 + 2x + 3) using the calculus of finite differences and taking the interval of difference unity. [Hint: (1+ x)2 = Ex2, (2 + x)2 = E2x2 , (3 + x)2 = E3x3, ......] 5. If f(E) is a polynomial in E such that f(E) = a0En + a1 En – 1 + a2 En – 2 + ...... + an Prove that f(E) ex = ex f(e), taking the interval of differencing unity. We now proceed to study the use of finite difference calculus for the purpose of interpo- lation. This we shall do in three cases as follows: (i) The value of the argument in the given data varies by an equal interval. The tech- nique is called an interpolation with equal intervals. (ii) The values of argument are not at equal intervals. This is known as interpolation with unequal intervals. (iii) The technique of central differences.
  • 256. INTERPOLATION 243 4.14 NEWTON’S FORMULAE FOR INTERPOLATION Newton’s formula is used for constructing the interpolation polynomial. It makes use of divided differences. This result was first discovered by the Scottish mathematician James Gregory (1638–1675) a contemporary of Newton. Gregory and Newton did extensive work on methods of interpolation but now the formula is referred to as Newton’s interpolation formula. Newton has derived general forward and backward difference interpolation formulae. 4.15 NEWTON’S GREGORY FORWARD INTERPOLATION FORMULA Let y = f(x) be a function of x which assumes the values f(a), f(a + h), f(a + 2h), ......., f(a + nh) for (n + 1) equidistant values a, a + h, a + 2h, ......, a + nh of the independent variable x. Let f(x) be a polynomial of nth degree. Let f(x) = A0 + A1 (x – a) + A2 (x – a) (x – a – h) + A3 (x – a) (x – a – h) (x – a – 2h ) + ....... + An (x – a) ...... (x – a – n − 1h) (20) where A0, A1, A2 , ......., An are to be determined. Put x = a, a + h, a + 2h, ......., a + nh in (20) successively. For x = a, f(a) = A0 (21) For x = a + h, f(a + h) = A0 + A1h ⇒ f(a + h) = f(a) + A1h | By (21) ⇒ A1 = Δf a h ( ) (22) For x = a + 2h, f(a + 2h) = A0 + A1 (2h) + A2 (2h) h = f(a) + 2h Δf a h ( ) R S T U V W + 2h2 A2 ⇒ 2h2A2 = f(a + 2h) – 2f(a + h) + f(a) = Δ2f(a) ⇒ A2 = Δ2 2 2 f a h ( ) ! Similarly, A3 = Δ3 3 3 f a h ( ) ! and so on. Thus, An = Δn n f a n h ( ) ! .
  • 257. 244 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES From (20), f(x) = f(a) + (x – a) Δ f a h ( ) + (x – a) (x – a – h) Δ2 2 2 f a h ( ) ! + ....... + (x – a) ...... (x – a – n − 1 h) Δn n f a n h ( ) ! Put x = a + hu ⇒ u = x a h − , we have f(a + hu) = f(a) + hu Δ f a h ( ) + ( ) ( ) ! hu hu h h − 2 2 Δ2 f (a) +...... + ( ) ( ) ( ) ....... ( ) ! hu hu h hu h hu n h n hn − − − − 2 1 Δn f(a) ⇒ f(a + hu) = f(a) + uΔ f(a) + u u ( ) ! − 1 2 Δ2 f(a) + ... + u u u u n n ( )( ) ... ( ) ! − − − + 1 2 1 Δn f(a) which is the required formula. This formula is particularly useful for interpolating the values of f(x) near the beginning of the set of values given. h is called the interval of difference, while Δ is forward difference operator. 4.15.1 Algorithm for Newton’s Forward Difference Formula Step 01. Start of the program Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h=ax[1] – ax[0] Step 06. for i=0; in-1; i++ Step 07. diff[i] [1]=ay[i + 1] – ay[i] Step 08. End Loop i Step 09. for j=2; j=4; j++ Step 10. for i = 0; i n – j; i++ Step 11. diff[i][j]=diff [i + 1] [j – 1]-diff [i][j – 1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until ax[i]x Step 16. i=i + 1 Step 17. i=i – 1;
  • 258. INTERPOLATION 245 Step 18. p=(x – ax [i])/h Step 19. y1=p∗diff[i – 1][1] Step 20. y2=p∗(p+1)∗diff [i – 1][2]/2 Step 21. y3=(p+1)∗p∗(p-1)∗diff[i –2 ][3]/6 Step 22. y4=(p+2)∗(p+1)∗p∗(p – 1)∗diff[i – 3][4]/24 Step 23. y=ay[i]+y1+y2+y3+y4 Step 24. Print output x, y Step 25. End of program. 4.15.2 Flow-chart
  • 259. 246 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A B B i = 0 i = i + 1 Is ax[i] x No Yes i = i – 1 p = (x – ax[i])/h y = p * diff[i – 1][1] 1 y = p * (p + 1) * diff[i – 1][2]/2 2 y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6 3 y = (p + 2) * (p + 1) * p * (p – 1) * diff[i – 3][4]/24 4 y = ay[i] + y + y + y + y 1 2 3 4 Print output x, y STOP ax is an array containing values of x, ay is an array containing values of y, Diff. is a two dimensional array containing difference table, h is spacing between values of x NOTE
  • 260. INTERPOLATION 247 * *********************************************************************************** 4.15.3 Program to Implement Newton’s Forward Method of Interpolation *********************************************************************************** */ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... MAIN EXECUTION THREAD void main() { //... Variable declaration Field //... Integer Type int n; //... Number of terms int i,j; //... Loop Variables //...Floating Type float ax[10]; //... array limit 9 float ay[10]; //... array limit 9 float x; //... User Querry float y = 0; //... Initial value 0 float h; //... Calc. section float p; //... Calc. section float diff[20][20]; //... array limit 19,19 float y1,y2,y3,y4; //... Formulae variables //... Invoke Function Clear Screen clrscr(); //... Input Section printf(n Enter the number of terms – ); scanf(%d,n); //... Input Sequel for array X
  • 261. 248 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Printf (nn Enter the value in the form of x - ); //... Input Loop for X for (i=0;in;i++) { printf(nn Enter the value of x%d - ,i+1); scanf(%f,ax[i]); } //... Input Sequel for array Y printf(nn Enter the value in the form of y – ); //... Input Loop for Y for (i=0;in;i++) { printf (nn Enter the value of y%d – , i+1); scanf (%f,ay [i]); } //... Inputting the required value quarry printf(nEnter the value of x for); printf(nwhich you want the value of y - ); scanf(%f,x); //... Calculation and Processing Section h=ax[1]-ax[0]; for(i=0;in-1;i++) { diff[i][1]=ay[i+1]-ay[i]; } for(j=2;j=4;j++) { for(i=0;in-j;i++) { diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } }
  • 262. INTERPOLATION 249 i=0; do { i++; }while(ax[i]x); i--; p=(x–ax[i])/h; y1=p*diff[i-1][1]; y2=p*(p+1)*diff[i-1][2]/2; y3=(p+1)*p*(p–1)*diff[i–2][3]/6; y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24; //... Taking Sum y=ay[i]+y1+y2+y3+y4; //... Output Section printf(nwhen x=%6.4f, y=%6.8f ,x,y); //... Invoke User Watch Halt Function Printf(nnn Press Enter to Exit); getch(); } //... Termination of Main Execution Thread 4.15.4 Output Enter the number of terms – 7 Enter the value in the form of x - Enter the value of x1 - 100 Enter the value of x2 - 150 Enter the value of x3 - 200 Enter the value of x4 - 250 Enter the value of x5 - 300 Enter the value of x6 - 350 Enter the value of x7 - 400 Enter the value in the form of y - Enter the value of y1 - 10.63 Enter the value of y2 - 13.03 Enter the value of y3 - 15.04
  • 263. 250 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Enter the value of y4 - 16.81 Enter the value of y5 - 18.42 Enter the value of y6 - 19.9 Enter the value of y7 - 21.27 Enter the value of x for which you want the value of y-218 When X=218.0000, Y=15.69701481 Press Enter to Exit EXAMPLES Example 1. Find the value of sin 52° from the given table: θ° 45° 50° 55° 60° sin θ 0.7071 0.7660 0.8192 0.8660 Sol. a = 45°, h = 5, x = 52 ∴ u = x a h − = 7 5 = 1.4 Difference table is: Differences x° 104y 104Δy 104 Δ2y 104 Δ3y 45° 7071 589 50° 7660 – 57 532 – 7 55° 8192 – 64 468 60° 8660 By forward difference formula, f(a + hu) = f(a) + u Δ f(a) + u u f a u u u ( ) ! ( ) ( )( ) ! − + − − 1 2 1 2 3 2 Δ Δ3 f(a) ⇒ 104 f(x) = 104 f(a) + 104 u Δ f(a) + 104 u u ( ) ! − 1 2 Δ2 f(a) + 104 u u u ( )( ) ! − − 1 2 3 Δ3 f(a)
  • 264. INTERPOLATION 251 ⇒ 104 f(52) = 104 f(45) + (1.4) 104 Δ f(45) + (1.4)(1.4 1) 2! − 104 Δ2 f(45) + (1.4)(1.4 1)(1.4 2) 3 ! − − 104 Δ3 f(45) = 7071 + (1.4)(589) + (1.4)(.4) 2 (1.4)(.4)( .6) 6 ( ) − + − 57 (– 7) = 7880 ∴ f(52) = .7880. Hence, sin 52° = 0.7880. Example 2. The population of a town in the decimal census was as given below. Estimate the population for the year 1895. Year x: 1891 1901 1911 1921 1931 Population y: 46 66 81 93 101 (in thousands) Sol. Here a = 1891, h = 10, a + hu = 1895 ⇒ 1891 + 10 u = 1895 ⇒ u = 0.4 The difference table is as under: x y Δy Δ2y Δ3y Δ4y 1891 46 20 1901 66 – 5 15 2 1911 81 – 3 – 3 12 – 1 1921 93 – 4 8 1931 101 Applying Newton’s forward difference formula, y(1895) = y(1891) + u Δy(1891) + u u ( ) ! − 1 2 Δ2y(1891) + u u u ( )( ) ! − − 1 2 3 Δ3y(1891) + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4y(1891)
  • 265. 252 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ⇒ y(1895) = 46 + (.4)(20) + (.4)(.4 1) 2 − (– 5) + (.4)(.4 1)(.4 2) 6 .4 .4 .4 − − + − − ( ) ( )( )(. – )( ) 2 1 4 2 3 24 (– 3) ⇒ y(1895) = 54.8528 thousands Hence the population for the year 1895 is 54.8528 thousands approximately. Example 3. The values of f(x) for x = 0, 1, 2, ......, 6 are given by x: 0 1 2 3 4 5 6 f(x): 2 4 10 16 20 24 38 Estimate the value of f(3.2) using only four of the given values. Choose the four values that you think will give the best approximation. Sol. Last four values of f(x) for x = 3, 4, 5, 6 are taken into consideration so that 3.2 occurs in the beginning of the table. Here a = 3, h = 1, x = 3.2 ∴ a + h u = 3.2 i.e., 3 + 1 × u = 3.2 or u = 0.2 The difference table is: x f(x) Δf(x) Δ2f(x) Δ3f(x) 3 16 4 4 20 0 4 10 5 24 10 14 6 38 Applying Newton’s forward difference formula, f(3.2) = f(3) + u Δ f(3) + u u f u u u f ( ) ! ( ) ( )( ) ! ( ) − + − − 1 2 3 1 2 3 3 2 3 Δ Δ = 16 + (.2)(4) + (.2)(.2 1) 2 (0) (.2)(.2 1)(.2 2) 6 − + − − (10) = 17.28. Example 4. From the following table, find the value of e0.24 x: 0.1 0.2 0.3
  • 266. INTERPOLATION 253 Sol. The difference table is: x 105y 105Δy 105Δ2y 105 Δ3y 104Δ4y 0.1 110517 11623 0.2 122140 1223 12846 127 0.3 134986 1350 17 14196 144 0.4 149182 1494 15690 0.5 164872 Here h = 0.1. ∴ 0.24 = 0.1 + 0.1 × u or u = 1.4 Newton-Gregory forward formula is y(.24) = y(.1) + u Δ y(.1) + u u y u u u ( ) ! ( ) ( )( ) ! − + − − 1 2 1 2 3 2 Δ .1 Δ3y(.1) + u u u u ( )( )( ) 4 ! − − − 1 2 3 Δ4 y(.1) ⇒ 105 y(.24) = 105 y(.1) + u 105 Δy(.1) + u u ( ) 2 ! − 1 105 Δ2y(.1) + u u u ( )( ) 3 ! − − 1 2 105 Δ3y(.1) + u u u u ( )( )( ) 4 ! − − − 1 2 3 105 Δ4y(.1) ⇒ 105 y(.24) = 110517 + (1.4)(11623) + (1.4)(1.4 1) 2 − (1223) + (1.4)(1.4 1)(1.4 2) 3 ! 1.4)(1.4 1.4 1.4 − − + − − − ( ) ( )( )( ) ! 127 1 2 3 4 (17) = 127124.9088 ∴ y(.24) = 1.271249088 Hence, e.24 = 1.271249088. Example 5. From the following table of half-yearly premiums for policies maturing at different ages, estimate the premium for policies maturing at age of 46. Age 45 50 55 60 65 Premium 114.84 96.16 83.32 74.48 68.48 (in dollars)
  • 267. 254 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. The difference table is: Age Premium Δy Δ2y Δ3y Δ4y (x) (in dollars) (y) 45 114.84 – 18.68 50 96.16 5.84 – 12.84 – 1.84 55 83.32 4 .68 – 8.84 – 1.16 60 74.48 2.84 – 6 65 68.48 Here h = 5, a = 45, a + hu = 46 ∴ 45 + 5u = 46 ⇒ u = .2 By Newton’s forward difference formula, y46 = y45 + u Δy45 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 45 Δ Δ3y45 + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4 y45 = 114.84 + (.2)(– 18.68) + (.2)(.2 1) 2 ! − (5.84) + (.2)(.2 1)(.2 2) − − 3 ! (– 1.84) + (.2)(.2 1)(.2 2)(.2 3) − − − 4 ! (.68) = 110.525632 Hence the premium for policies maturing at the age of 46 is $ 110.52. Example 6. From the table, estimate the number of students who obtained scores between 40 and 45. Scores: 30—40 40—50 50—60 60—70 70—80 Number of students: 31 42 51 35 31.
  • 268. INTERPOLATION 255 Sol. The difference table is: Scores less than (x) y Δy Δ2y Δ3y Δ4y 40 31 42 50 73 9 51 – 25 60 124 – 16 37 35 12 70 159 – 4 31 80 190 We shall find y45, number of students with scores less than 45. a = 40, h = 10, a + hu = 45. ∴ 40 + 10u = 45 ⇒ u = .5 By Newton’s forward difference formula, y(45) = y(40) + u Δ y(40) + u u ( ) ! − 1 2 Δ2 y(40) + u u u ( )( ) ! − − 1 2 3 Δ3 y(40) + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4 y(40) = 31 + (.5)(42) + (.5)(.5 1) 2 (.5)(.5 1)(.5 2) 6 − + − − ( ) 9 (– 25) + (.5)(.5 1)(.5 2)(.5 3) 24 − − − (37) = 47.8672 ≈ 48 Hence, the number of students getting scores less than 45 = 48 By the number of students getting scores less than 40 = 31 Hence, the number of students getting scores between 40 and 45 = 48 – 31 = 17. Example 7. Find the cubic polynomial which takes the following values: x: 0 1 2 3 f(x): 1 2 1 10.
  • 269. 256 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Let us form the difference table: x y Δy Δ2 y Δ3 y 0 1 1 1 2 – 2 – 1 12 2 1 10 9 3 10 Here, h = 1. Hence, using the formula, x = a + hu and choosing a = 0, we get x = u ∴ By Newton’s forward difference formula, y = y0 + x Δy0 + x x y x x x y ( ) ! ( ) ( ) ! − + − − 1 2 1 2 3 2 0 3 0 Δ Δ = 1 + x(1) + x x ( ) ! − 1 2 (– 2) + x x x ( ) ( ) ! − − 1 2 3 (12) = 2x3 – 7x2 + 6x + 1 Hence, the required cubic polynomial is y = f(x) = 2x3 – 7x2 + 6x + 1. Example 8. The following table gives the scores secured by100 students in the Numerical Analysis subject: Range of scores: 30—40 40—50 50—60 60—70 70—80 Number of students: 25 35 22 11 7 Use Newton’s forward difference interpolation formula to find. (i) the number of students who got scores more than 55. (ii) the number of students who secured scores in the range between 36 and 45. Sol. The given table is re-arranged as follows: Scores obtained Number of students Less than 40 25 Less than 50 60 Less than 60 82 Less than 70 93 Less than 80 100
  • 270. INTERPOLATION 257 (i) Here, a = 40, h = 10, a + hu = 55 ∴ 40 + 10u = 55 ⇒ u = 1.5 First, we find the number of students who got scores less than 55. The difference table follows: Scores obtained Number of Δy Δ2y Δ3y Δ4y less than students = y 40 25 35 50 60 – 13 22 2 60 82 – 11 5 11 7 70 93 – 4 7 80 100 Applying Newton’s forward difference formula, y55 = y40 + u Δ y40 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 40 Δ Δ3 y40 + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4 y40 = 25 + (1.5)(35) + (1.5)(.5) 2 ! ( 13) (1.5)(.5)( .5) 3 ! − + − (2) + (1.5)(.5)( .5)( 1.5) 4 ! − − (5) = 71.6171875 ≈ 72 There are 72 students who got scores less than 55. ∴ Number of students who got scores more than 55 = 100 – 72 = 28 (ii) To calculate the number of students securing scores between 36 and 45, take the difference of y45 and y36. u = x a h − = − 36 40 10 = – .4 Also, u = 45 40 10 − = .5
  • 271. 258 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Newton’s forward difference formula: y36 = y40 + u Δ y40 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 40 Δ Δ3 y40 + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4 y40 = 25 + (– .4)(35) + ( )( ) ! ( ) ( )( )( ) ! − − − + − − − .4 1.4 .4 1.4 2.4 2 13 3 (2) + ( )( )( )( ) ! − − − − .4 1.4 2.4 3.4 4 (5) = 7.864 ≈ 8 Also, y45 = y40 + u Δ y40 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 40 Δ Δ3 y40 + u u u u y ( ) ( ) ( ) ! − − − 1 2 3 4 4 40 Δ = 25 + (.5)(35) + (.5)( .5) 2 ( 13) (.5)( .5)( 1.5) 6 − − + − − (2) + (.5)( .5)( 1.5)( 2.5) 24 − − − (5) = 44.0546 ≈ 44. Hence, the number of students who secured scores between 36 and 45 is y45 – y36 = 44 – 8 = 36. Example 9. The following are the numbers of deaths in four successive ten year age groups. Find the number of deaths at 45—50 and 50—55. Age group: 25—35 35—45 45—55 55—65 Deaths: 13229 18139 24225 31496. Sol. Difference table of cumulative frequencies: Age upto Number of deaths Δf(x) Δ2f(x) Δ3f(x) x f(x) 35 13229 18139 45 31368 6086 24225 1185 55 55593 7271 31496 65 87089
  • 272. INTERPOLATION 259 Here, h = 10, a = 35, a + hu = 50 ∴ 35 + 10u = 50 ⇒ u = 1.5 By Newton’s forward difference formula, y50 = y35 + u Δ y35 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 35 Δ Δ3 y35 = 13229 + (1.5)(18139) + (1.5)(.5) 2 (1.5)(.5)(– .5) 6 ( ) 6086 + (1185) = 42645.6875 ≈ 42646 ∴ Deaths at ages beween 45 – 50 are 42646 – 31368 = 11278 and Deaths at ages between 50 – 55 are 55593 – 42646 = 12947. Example 10. If p, q, r, s are the successive entries corresponding to equidistant arguments in a table, show that when the third differences are taken into account, the entry corresponding to the argument half way between the arguments at q and r is A + B 24 F HG I KJ, where A is the arithmetic mean of q and r and B is arithmetic mean of 3q – 2p – s and 3r – 2s – p. Sol. A = q r + 2 ⇒ q + r = 2A B = ( ) ( ) 3 2 3 2 2 q p s r s p − − + − − = 3 3 3 3 2 q r p s + − − = 3 2 3 2 ( ) ( ) q r p s + − + Let the entries p, q, r, and s correspond to x = a, a + h, a + 2h, and a + 3h, respectively. Then the value of the argument lying half way between a + h and a + 2h will be a h h + + F HG I KJ 2 i.e., a h + 3 2 . Hence a + mh = a h + 3 2 ⇒ m = 3 2 Let us now construct the difference table: x f(x) Δf(x) Δ2f(x) Δ3f(x) a p q – p a + h q r – 2q + p r – q s – 3r + 3q – p a + 2h r s – 2r + q s – r a + 3h s
  • 273. 260 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Using Newton’s Gregory Interpolation formula up to third difference only and taking m = 3/2, we get f a h + F HG I KJ 3 2 = f(a) + 3 2 3 2 3 2 1 2 3 2 3 2 1 3 2 2 6 2 3 Δ Δ Δ f a f a f a ( ) ( ) ( ) + − F HG I KJ + − F HG I KJ − F HG I KJ = p + 3 2 (q – p) + 3 8 (r – 2q + p) – 1 16 (s – 3r + 3q – p) = ( ) 16 24 24 6 12 6 3 3 16 p q p r q p s r q p − − + − + − + − + = 1 16 (– p + 9q + 9r – s) = 9 16 (q + r) – p s + F HG I KJ 16 = 9 16 (2A) – 2 3 3A B 16 − F HG I KJ = 9 8 A – 1 8 A + B 24 = A + B 24 . ASSIGNMENT 4.4 1. The following table gives the distance in nautical miles of the visible horizon for the given heights in feet above the earth’s surface. x: 100 150 200 250 300 350 400 y: 10.63 13.03 15.04 16.81 18.42 19.9 21.27 Use Newton’s forward formula to find y when x = 218 ft. 2. If lx represents the number of persons living at age x in a life table, find, as accurately as the data will permit, lx for values of x = 35, 42 and 47. Given l20 = 512, l30 = 390, l40 = 360, l50 = 243. 3. The values of f(x) for x = 0, 1, 2, ......, 6 are given by x: 0 1 2 3 4 5 6 f(x): 1 3 11 31 69 131 223 Estimate the value of f(3.4), using only four of the given values. 4. Given that: x: 1 2 3 4 5 6 y(x): 0 1 8 27 64 125 Find the value of f(2.5).
  • 274. INTERPOLATION 261 5. Ordinates f(x) of a normal curve in terms of standard deviation x are given as x: 1.00 1.02 1.04 1.06 1.08 f(x): 0.2420 0.2371 0.2323 0.2275 0.2227 Find the ordinate for standard deviation x = 1.025. 6. Using Newton’s formula for interpolation, estimate the population for the year 1905 from the table: Year Population 1891 98,752 1901 132,285 1911 168,076 1921 195,690 1931 246,050 7. Find the number of students from the following data who secured scores not more than 45 Scores range: 30—40 40—50 50—60 60—70 70—80 Number of students: 35 48 70 40 22 8. Find the number of men getting wages between $ 10 and $ 15 from the following table: Wages (in $): 0—10 10—20 20—30 30—40 Frequency: 9 30 35 42 9. Following are the scores obtained by 492 candidates in a certain examination Scores Number of candidates 0—40 210 40—45 43 45—50 54 50—55 74 55—60 32 60—65 79 Find out the number of candidates (a) who secured scores more than 48 but not more than 50; (b) who secured scores less than 48 but not less than 45. 10. Use Newton’s forward difference formula to obtain the interpolating polynomial f(x), satisfying the following data: x: 1 2 3 4 f(x): 26 18 4 1 If another point x = 5, f(x) = 26 is added to the above data, will the interpolating polyno- mial be the same as before or different. Explain why.
  • 275. 262 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 11. The table below gives value of tan x for .10 ≤ x ≤ .30. x: .10 .15 .20 .25 .30 tan x: .1003 .1511 .2027 .2553 .3093 Evaluate tan 0.12 using Newton’s forward difference formula 12. (i) Estimate the value of f(22) from the following available data: x: 20 25 30 35 40 45 f(x): 354 332 291 260 231 204 (ii) Find the cubic polynomial which takes the following values: y(0) = 1, y(1) = 0, y(2) = 1 and y(3) = 10 Hence or otherwise obtain y(4). (iii) Use Newton’s method to find a polynomial p(x) of lowest possible degree such that p(n) = 2n for n = 0, 1, 2, 3, 4. 4.16 NEW TON’S GREGORY BACKWARD INTERPOLATION FORMULA Let y = f(x) be a function of x which assumes the values f(a), f(a + h), f (a + 2h), ......, f(a + nh) for (n + 1) equidistant values a, a + h, a + 2h, ......, a + nh of the independent variable x. Let f(x) be a polynomial of the nth degree. Let, f(x) = A0 + A1(x – a – nh) + A2 (x – a – nh) (x – a – n − 1 h) + ...... + An (x – a – nh) (x – a – n − 1 h) ...... (x – a – h) where A0, A1, A2, A3, ......, An are to be determined. (23) Put x = a + nh, a + n − 1 h, ......, a in (23) respectively. Put x = a + nh, then f (a + nh) = A0 (24) Put x = a + (n – 1) h, then f(a + n − 1 h) = A0 – h A1 = f(a + nh) – h A1 | By (24) ⇒ A1 = ∇ + f a nh h ( ) (25) Put x = a + (n – 2)h, then f (a + n − 2 h) = A0 – 2hA1 + (– 2h) (– h) A2
  • 276. INTERPOLATION 263 ⇒ 2 ! h2 A2 = f(a + n − 2 h) – f(a + nh) + 2∇f(a + nh) = ∇2 f(a + nh) A2 = ∇ + 2 2 2 f a nh h ( ) ! (26) Proceeding, we get An = ∇ + n n f a nh n h ( ) ! (27) Substituting the values in (24), we get f(x) = f(a + nh) + (x – a – nh) ∇ + f a nh h ( ) + ...... + (x – a – nh) (x – a – n − 1 h) ..... (x – a – h) ∇ + n n f a nh n h ( ) ! (28) Put x = a + nh + uh, then x – a – nh = uh and x – a – (n – 1)h = (u + 1)h x – a – h = (u + n − 1) h ∴ (28) becomes, f(x) = f(a + nh) + u ∇f(a + nh) + u u ( ) ! + 1 2 ∇2 f(a + nh) + ...... + uh . (u + 1)h ..... (u + n − 1)(h) ∇ + n n f a nh n h ( ) ! or f(a + nh + uh) = f(a + nh) + u ∇f(a + nh) + u u ( ) ! + 1 2 ∇2f(a + nh) + ...... + u u u n n ( ) ...... ( ) ! + + − 1 1 ∇n f(a + nh) which is the required formula. This formula is useful when the value of f(x) is required near the end of the table.
  • 277. 264 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.16.1 Algorithm for Newton’s Backward Difference formula Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h=ax[1]-ax[0] Step 06. for i=0; in–1; i++ Step 07. diff[i][1]=ay[i+1]–ay[i] Step 08. End Loop i Step 09. for j = 2; j = 4; j + + Step 10. for i=0; in–j; i++ Step 11. diff[i][j]=diff[i+1][j–1]–diff [i][j–1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until (!ax[i]x) Step 16. i=i+1 Step 17. x0=mx[i] Step 18. sum=0 Step 19. y0=my[i] Step 20. fun=1 Step 21. p=(x–x0)/h Step 22. sum=y0 Step 23. for k=1; k=4; k++ Step 24. fun=(fun*(p–(k–1)))/k Step 25. sum=sum+fun*diff[i][k] Step 26. End loop k Step 27. Print Output x,sum Step 28. End of Program
  • 278. INTERPOLATION 265 4.16.2 Flow-chart START Input number of terms n Input array ax ay h = ax[1] – ax[0] Start loop i = 0 to n – 1 Diff[i][1] = ay[i + 1] – ay[i] End loop i Start loop j = 2 to 4 Start loop i = 0 to n – j Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1] End loop i End loop j i = 0 i = i + 1 A Is ! ax[i] x Yes
  • 279. 266 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A x0 = mx[i] Sum = 0 y0 = my[i] Fun = 1 p = (x – x0)/n Sum = y0 End loop k Print Output , x, sum ‘‘ ’’ Start loop k = 1 to 4 fun = (fun * (p – (k – 1)))/k Sum = sum + fun * diff[i][k] STOP * ***********************************************************************************
  • 280. INTERPOLATION 267 4.16.3 Program to Implement Newton’s Backward Method of Interpolation ************************************************************************************/ //...HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... MAIN EXECUTION THREAD void main() { //...Variable declaration Field //...Integer Type int n; //...Number of terms int i,j,k; //...Loop Variables //...Floating Type float my[10]; //... array limit 9 float my[10]; //... array limit 9 float x; //... User Querry float x0 = 0; //... Initial value 0 float y0; //... Calc. Section float sum; //... Calc. Section float h; //... Calc. Section float fun; //... Calc. Section float p; //... Calc. Section float diff[20][20]; //... array limit 19,19 float y1, y2, y3, y4; //... Formulae variables //...Invoke Function Clear Screen clrscr(); //...Input Section
  • 281. 268 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(n Enter the number of terms - ); scanf(%d,n); //...Input Sequel for array X printf(nn Enter the value in the form of x - ); //...Input Loop for X for (i=0;in;i++) { printf(nn Enter the value of x%d - ,i+1); scanf (“%f”,mx[i]); } //...Input Sequel for array Y printf (nn Enter the value in the form of y -); //...Input Loop for Y for (i=0;in;i++) { printf (nn Enter the value of y%d - ,i+1); scanf (%f,my[i]); } //...Inputting the required value query printf (nEnter the value of x for); printf(nwhich you want the value of y - ); scanf(%f,x); //...Calculation and Processing Section h=mx[1]-mx[0]; for(i=0;in-1;i++) { diff[i][1]=my[i+1]-my[i]; } for (j=2;j=4;j++) { for (i=0;in-j;i++) { diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } }
  • 282. INTERPOLATION 269 i=0; while(!mx[i]x) { i++; } x0=mx[i]; sum=0; y0=my[i]; fun=1; p=(x-x0)/h; sum=y0; for (k=1;k=4;k++) { fun=(fun*(p-(k-1)))/k; sum=sum+fun*diff[i][k]; } //...Output Section printf (nwhen x=%6.4f,y=%6.8f,x,sum); //...Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch( ); } //...Termination of Main Execution Thread 4.16.4 Output Enter the number of terms-7 Enter the value in the form of x- Enter the value of x1 - 100 Enter the value of x2 - 150 Enter the value of x3 - 200 Enter the value of x4 - 250 Enter the value of x5 - 300 Enter the value of x6 - 350 Enter the value of x7 - 400
  • 283. 270 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Enter the value in the form of y - Enter the value of y1 - 10.63 Enter the value of y2 - 13.03 Enter the value of y3 - 15.04 Enter the value of y4 - 16.81 Enter the value of y5 - 18.42 Enter the value of y6 - 19.90 Enter the value of y7 - 21.27 Enter the value of x for which you want the value of y - 410 When x = 410.0000, y = 21.34462738 Press Enter to Exit EXAMPLES Example 1. The population of a town was as given. Estimate the population for the year 1925. Year (x): 1891 1901 1911 1921 1931 Population (y): 46 66 81 93 101 (in thousands) Sol. Here, a + nh = 1931, h = 10, a + nh + uh = 1925 ∴ u = 1925 1931 10 − = – 0.6 The difference table is: x y ∇y ∇2y ∇3y ∇4y 1891 46 20 1901 66 – 5 15 2 1911 81 – 3 – 3 12 – 1 1921 93 – 4 8 1931 101
  • 284. INTERPOLATION 271 Applying Newton’s Backward difference formula, we get y1925 = y1931 + u∇y1931 + u u ( ) ! + 1 2 ∇2y1931 + u u u ( )( ) ! + + 1 2 3 ∇3y1931 + u u u u ( )( )( ) ! + + + 1 2 3 4 ∇4y1931 = 101 + (– .6)(8) + ( )(. ) ! ( ) ( )( )( ) ! − − + − .6 .6 .4 1.4 4 2 4 3 (– 1) + ( .6)(.4)(1.4)(2.4) 4 ! − (– 3) = 96.8368 thousands. Hence the population for the year 1925 = 96836.8 ≈ 96837. Example 2. The population of a town is as follows: Year: 1921 1931 1941 1951 1961 1971 Population: 20 24 29 36 46 51 (in Lakhs) Estimate the increase in population during the period 1955 to 1961. Sol. Here, a + nh = 1971, h = 10, a + nh + uh = 1955 ∴ 1971 + 10u = 1955 ⇒ u = – 1.6 The difference table is: x y ∇y ∇2y ∇3y ∇4y ∇5y 1921 20 4 1931 24 1 5 1 1941 29 2 0 7 1 – 9 1951 36 3 – 9 10 – 8 1961 46 – 5 5 1971 51
  • 285. 272 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Applying Newton’s backward difference formula, we get y1955 = y1971 + u∇y1971 + u u ( ) ! + 1 2 ∇2y1971 + u u u ( )( ) ! + + 1 2 3 ∇3y1971 + u u u u ( )( )( ) ! + + + 1 2 3 4 ∇4 y1971 + u u u u u ( )( )( )( ) ! + + + + 1 2 3 4 5 ∇5 y1971 = 51 + (– 1.6)(5) + ( )( . ) ! − − 1.6 0 6 2 (– 5) + ( )( . )( . ) − − 1.6 0 6 0 4 6 (– 8) + ( )( . )(. )( ) − − 1. 1. 6 0 6 4 4 24 (– 9) + ( )( . )( . )( )( ) − − 1. 1. 2. 6 0 6 0 4 4 4 120 (– 9) = 39.789632 ∴ Increase in population during period 1955 to 1961 is = 46 – 39.789632 = 6.210368 Lakhs = 621036.8 Lakhs. Example 3. In the following table, values of y are consecutive terms of a series of which 23.6 is the 6th term. Find the first and tenth terms of the series. x: 3 4 5 6 7 8 9 y: 4.8 8.4 14.5 23.6 36.2 52.8 73.9. Sol. The difference table is: x y Δy Δ2y Δ3y Δ4y 3 4.8 3.6 4 8.4 2.5 6.1 0.5 5 14.5 3 0 9.1 0.5 6 23.6 3.5 0 12.6 0.5 7 36.2 4 0 16.6 0.5 8 52.8 4.5 21.1 9 73.9 To find the first term, we use Newton’s forward interpolation formula.
  • 286. INTERPOLATION 273 Here, a = 3, h = 1, x = 1 ∴ u = x a h − = – 2 We have y1 = y3 + uΔy3 + u u ( ) ! − 1 2 Δ2y3 + u u u ( )( ) ! − − 1 2 3 Δ3y3 = 4.8 + (– 2) × 3.6 + ( )( ) − − 2 3 2 (2.5) + ( )( )( ) − − − 2 3 4 6 (0.5) = 3.1 To obtain the tenth term, we use Newton’s Backward interpolation formula a + nh = 9, h = 1, a + nh + uh = 10 ∴ 10 = 9 + u ⇒ u = 1 ∴ y10 = y9 + u∇y9 + u u ( ) ! + 1 2 ∇2y9 + u u u ( )( ) ! + + 1 2 3 ∇3y9 = 73.9 + 21.1 + 4.5 + .5 = 100. Example 4. Given log x for x = 40, 45, 50, 55, 60 and 65 according to the following table: x: 40 45 50 55 60 65 log x: 1.60206 1.65321 1.69897 1.74036 1.77815 1.81291 Find the value of log 5875. Sol. The difference table is: x 105 log x = 105 yx 105 ∇yx 105 ∇2 yx 105 ∇3yx 105∇4 yx 105∇5yx 40 160206 5115 45 165321 – 539 4576 102 50 169897 – 437 – 25 4139 77 5 55 174036 – 360 – 20 3779 57 60 177815 – 303 3476 65 181291
  • 287. 274 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Newton’s Backward difference formula is f(a + nh + uh) = f(a + nh) + u∇f(a + nh) + u u ( ) ! + 1 2 ∇2f(a + nh) + u u u ( )( ) ! + + 1 2 3 ∇3f(a + nh) + u u u u ( )( )( ) ! + + + 1 2 3 4 ∇4 f(a + nh) + u u u u u ( )( )( )( ) ! + + + + 1 2 3 4 5 ∇5 f(a + nh) (29) First we shall find the value of log(58.75). Here, a + nh = 65, h = 5, a + nh + uh = 58.75 ∴ 65 + 5u = 58.75 ⇒ u = – 1.25 From (29), 105 f(58.75) = 181291 + (– 1.25)(3476) + ( )( ) ! − − 1.25 .25 2 (– 303) + ( )( )( ) ! ( ) ( )( )( )( ) ! − − + − − 1.25 .25 .75 1.25 .25 .75 1.75 3 57 4 (– 20) + ( )( )( )( )( ) ! − − 1.25 .25 .75 1.75 2.75 5 (5) ⇒ 105 f(58.75) = 176900.588 ∴ f(58.75) = log 58.75 = 176900.588 × 10–5 = 1.76900588 Hence, log 5875 = 3.76900588 | ∵ Mantissa remain the same Example 5. Calculate the value of tan 48° 15′ from the following table: x°: 45 46 47 48 49 50 tan x°: 1.00000 1.03053 1.07237 1.11061 1.15037 1.19175 Sol. Here a + nh = 50, h = 1, a + nh + uh = 48° 15′ = 48.25° ∴ 50 + u(1) = 48.25 ⇒ u = – 1.75
  • 288. INTERPOLATION 275 The difference table is: x° 105y 105∇y 105∇2y 105∇3y 105∇4y 105∇5y 45 100000 3553 46 103553 131 3648 9 47 107237 140 3 3824 12 – 5 48 111061 152 – 2 3976 10 49 115037 162 4138 50 119175 ya+nh+uh = ya+nh + u∇ya+nh + u u ( ) + 1 2 ∇2ya+nh + u u u ( )( ) ! + + 1 2 3 ∇3ya+nh + u u u u ( )( )( ) ! + + + 1 2 3 4 ∇4ya+nh + u u u u u ( )( )( )( ) ! + + + + 1 2 3 4 5 ∇5 ya+nh ∴ 105y48.25 = 119175 + (– 1.75) × 4138 + ( ) ( . ) − × − 1.75 0 75 2 × 162 + ( 1.75)( 0.75)(0.25) 3 ! − − × 10 + ( 1.75)( .75)(.25)(1.25) 4 ! − − (– 2) + ( )( )( )( )( ) ! − − 1.75 .75 .25 .25 2.25 1 5 (– 5) ⇒ 105 y48.25 = 112040.2867 ∴ y48.25 = tan 48°15′ = 1.120402867. Example 6. From the following table of half-yearly premium for policies maturing at different ages, estimate the premium for a policy maturing at the age of 63: Age: 45 50 55 60 65 Premium: 114.84 96.16 83.32 74.48 68.48 (in dollars)
  • 289. 276 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. The difference table is: Age Premium ∇y ∇2y ∇3y ∇4y (x) (in dollars) (y) 45 114.84 – 18.68 50 96.16 5.84 – 12.84 – 1.84 55 83.32 4 .68 – 8.84 – 1.16 60 74.48 2.84 – 6 65 68.48 Here a + nh = 65, h = 5, a + nh + uh = 63 ∴ 65 + 5u = 63 ⇒ u = – .4 By Newton’s backward difference formula, y(63) = y(65) + u∇y(65) + u u y u u u y ( ) ! ( ) ( )( ) ! ( ) + ∇ + + + ∇ 1 2 65 1 2 3 65 2 3 + + + + ∇ u u u u y ( )( )( ) ! ( ) 1 2 3 4 65 4 = 68.48 + (– .4)(– 6) + ( . )(. ) ( . ) ( . )(. )( . ) ( . ) ( . )(. )( . )( . ) (. ) − + − − + − 4 6 2 2 84 4 6 16 6 116 4 6 16 2 6 24 68 = 70.585152 ASSIGNMENT 4.5 1. From the following table find the value of tan 17° θ°: 0 4 8 12 16 20 24 tan θ°: 0 0.0699 0.1405 0.2126 0.2867 0.3640 0.4402 2. Find the value of an annuity at 5 3 8 %, given the following table: Rate: 4 4 1 2 5 5 1 2 6 Annuity value: 172.2903 162.8889 153.7245 145.3375 137.6483
  • 290. INTERPOLATION 277 3. The values of annuities are given for the following ages. Find the value of annuity at the age of 27 1 2 . Age: 25 26 27 28 29 Annuity: 16.195 15.919 15.630 15.326 15.006 4. The table below gives the value of tan x for 0.10 ≤ x ≤ 0.30. x: 0.10 0.15 0.20 0.25 0.30 y = tan x: 0.1003 0.1511 0.2027 0.2553 0.3093 Find: (i) tan 0.50 (ii) tan 0.26 (iii) tan 0.40. 5. Given: x: 1 2 3 4 5 6 7 8 f(x): 1 8 27 64 125 216 343 512 Find f(7.5) using Newton’s Backward difference formula. 6. From the following table of values of x and f(x), determine (i) f(0.23) (ii) f(0.29) x: 0.20 0.22 0.24 0.26 0.28 0.30 f(x): 1.6596 1.6698 1.6804 1.6912 1.7024 1.7139 7. The probability integral P = 2 0 1 2 2 π x t e dt z − has following values: x: 1.00 1.05 1.10 1.15 1.20 1.25 P: 0.682689 0.706282 0.728668 0.749856 0.769861 0.788700 Calculate P for x = 1.235. 8. In an examination, the number of candidates who obtained scores between certain lim- its are as follows: Scores Number of candidates 0—19 41 20—39 62 40—59 65 60—79 50 80—99 17 Estimate the number of candidates who obtained fewer than 70 scores.
  • 291. 278 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 9. Estimate the value of f(42) from the following available data: x: 20 25 30 35 40 45 f(x): 354 332 291 260 231 204 10. The area A of a circle of diameter d is given for the following values: d: 80 85 90 95 100 A: 5026 5674 6362 7088 7854 Calculate the area of a cricle of diameter 105. 11. From the following table, find y, when x = 1.84 and 2.4 by Newton’s interpolation for- mula: x: 1.7 1.8 1.9 2.0 2.1 2.2 2.3 y = ex: 5.474 6.050 6.686 7.389 8.166 9.025 9.974 12. Using Newton’s backward difference formula, find the value of e–1.9 from the following table of values of e–x: x: 1 1.25 1.50 1.75 2.00 e–x: 0.3679 0.2865 0.2231 0.1738 0.1353 4.17 CENTRAL DIFFERENCE INTERPOLATION FORMULAE We shall study now the central difference formulae most suited for interpolation near the middle of a tabulated set. 4.18 GAUSS’ FORWARD DIFFERENCE FORMULA Newton’s Gregory forward difference formula is f(a + hu) = f(a) + uΔf(a) + u u f a u u u f a ( ) ! ( ) ( )( ) ! ( ) − + − − 1 2 1 2 3 2 3 Δ Δ + − − − + u u u u f a ( )( )( ) ! ( ) ...... 1 2 3 4 4 Δ (30) Given a = 0, h = 1, we get f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( )( ) ! ( ) − + − − 1 2 0 1 2 3 0 2 3 Δ Δ + − − − + u u u u f ( )( )( ) ! ( ) ...... 1 2 3 4 0 4 Δ (31)
  • 292. INTERPOLATION 279 Now, Δ3f(– 1) = Δ2f(0) – Δ2f(– 1) ⇒ Δ2f(0) = Δ3f(– 1) + Δ2f(– 1) Also, Δ4f(– 1) = Δ3f(0) – Δ3f(– 1) ⇒ Δ3f(0) = Δ4f(– 1) + Δ3f(– 1) and Δ5f(– 1) = Δ4f(0) – Δ4f(– 1) ⇒ Δ4f(0) = Δ5f(– 1) + Δ4f(– 1) and so on. ∴ From (31), f(u) = f(0) + uΔf(0) + − − + − u u f f ( ) ! { ( ) ( )} 1 2 1 1 2 3 Δ Δ + − − − + − u u u f f ( )( ) ! { ( ) ( )} 1 2 3 1 1 3 4 Δ Δ + − − − − + − + u u u u f f ( )( )( ) ! { ( ) ( )} ...... 1 2 3 4 1 1 4 5 Δ Δ = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) − − + − + − R S T U V W − 1 2 1 1 2 1 2 3 1 2 3 Δ Δ + − − + − R S T U V W − u u u u f ( )( ) ( ) 1 2 6 1 3 4 1 4 Δ + − − − − + u u u u f ( )( )( ) ! ( ) ...... 1 2 3 4 1 5 Δ = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − + − − − − + ( ) ( )( ) ! ( ) ( )( )( ) ! ( ) ...... u u u u f u u u u f 1 1 2 4 1 1 2 3 4 1 4 5 Δ Δ (32) But, Δ5f(– 2) = Δ4f(– 1) – Δ4f(– 2) ∴ Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2) then (32) becomes, f(u) = f(0) + uΔf(0) + − − + + − − u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − + − ( ) ( )( ) ! { ( ) ( )} u u u u f f 1 1 2 4 2 2 4 5 Δ Δ + − − − − + u u u u f ( )( )( ) ! ( ) ...... 1 2 3 4 1 5 Δ
  • 293. 280 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES f(u) = f(0) + uΔf(0) + − − + + − − u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − + ( ) ( )( ) ! ( ) ...... u u u u f 1 1 2 4 2 4 Δ This is called Gauss’ forward difference formula. This formula is applicable when u lies between 0 and 1 2 . 4.18.1 Algorithm Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h=ax[1]-ax[0] Step 06. for i=0;in–1;i++ Step 07. diff[i][1]=ay[i+1]-ay[i] Step 08. End Loop i Step 09. for j=2;j=4;j++ Step 10. for i=0;in–j;i++ Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until ax[i]x Step 16. i=i+1 Step 17. i=i–1; Step 18. p=(x–ax[i])/h Step 19. y1=p*diff[i][1] Step 20. y2=p*(p–1)*diff[i–1][2]/2 Step 21. y3=(p+1)*p*(p-1)*diff[i–2][3]/6 Step 22. y4=(p+1)*p*(p–1)*(p–2)*diff[i–3][4]/24 Step 23. y=ay[i]+y1+y2+y3+y4 Step 24. Print Output x,y Step 25. End of Program NOTE
  • 294. INTERPOLATION 281 4.18.2 Flow-chart START Input n, ax, ay h = ax[i] – ax[0] Loop i to (n – 1) Diff[i][1] = ay[i + 1] – ay[i] End loop i Loop j = 2 to 4 Loop i = 0 to (n – j) Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – i] End loop i End loop j i = 0 Y X If ax[i] x
  • 295. 282 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES X y i = i + 1 i = i – 1 p = (x – ax[i])/n y = p * diff[i][1] y = p * (p – 1) * diff[i – 1][2]/2 y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6 1 2 3 y = ay[i] + y + y + y 1 2 3 Print Output , x, y ‘‘ ’’ STOP /* *********************************************************************** 4.18.3 Program to Implement Gauss’s Forward Method of Interpolation *********************************************************************** */ //...HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //...MAIN EXECUTION THREAD void main() { //...Variable declaration Field
  • 296. INTERPOLATION 283 //...Integer Type int n; int i,j; //...Floating Type float ax[10]; //...array limit 9 float ax[10]; //...array limit 9 float x; float nr,dr; float y=0; //...Initial value 0 float h; float p; float diff[20][20]; //...array limit 19,19 float y1,y2,y3,y4; //...Invoke Function Clear Screen clrscr(); //...Input Section printf(n Enter the number of terms – ); scanf(%d,n); //...Input Sequel for array X printf(nn Enter the value in the form of x – ); //...Input loop for Array X for (i=0;in;i++) { printf(nn Enter the value of x%d – ,i+i); scanf(%f”,ax[i]); } printf(nn Enter the value in the form of y – ); //...Input Loop for Array Y for(i=0;in;i++) { printf(nn Enter the value of y%d–,i+1); scanf(%f,ay[i]); }
  • 297. 284 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES //...Inputting the required value query printf(nEnter the value of x for); printf(nwhich you want the value of y–); scanf (%f,x); //... Calculation and Processing Section h=ax[1]–ax[0]; for(i=0;in–1;i++) { diff[i][1]=ay[i+1]–ay[i]; } for(j=2;j=4;j++) { for(i=0;in–j;i++) { diff[i][j]=diff[i+1][j–1]–diff[i][j–1]; } } i=0; do { i++; }while(ax[i]x); i--; p=(x–ax[i])/h; y1=p*diff[i][1]; y2=p*(p–1)*diff[i-1][2]/2; y3=(p+1)*p*(p–1)*diff[i–2][3]/6; y4=(p+1)*p*(p–1)*(p–2)*diff[i–3][4]/24; //...Taking Sum y=ay[i]+y1+y2+y3+y4; //...Output Section printf(nwhen x=%6.4f,y=%6.8f ,x,y); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch(); } //...Termination of Main Execution Thread
  • 298. INTERPOLATION 285 4.18.4 Output Enter the number of terms – 7 Enter the value in the form of x – Enter the value of x1 – 1.00 Enter the value of x2 – 1.05 Enter the value of x3 – 1.10 Enter the value of x4 – 1.15 Enter the value of x5 – 1.20 Enter the value of x6 – 1.25 Enter the value of x7 – 1.30 Enter the value in the form of y – Enter the value of y1 – 2.7183 Enter the value of y2 – 2.8577 Enter the value of y3 – 3.0042 Enter the value of y4 – 3.1582 Enter the value of y5 – 3.3201 Enter the value of y6 – 3.4903 Enter the value of y7 – 3.6693 Enter the value of x for which you want the value of y – 1.17 When x = 1.17, y = 3.2221 Press Enter to Exit EXAMPLES Example 1. Apply a central difference formula to obtain f(32) given that: f(25) = 0.2707 f(35) = 0.3386 f(30) = 0.3027 f(40) = 0.3794. Sol. Here a + hu = 32 and h = 5 Take origin at 30 ∴ a = 30 then u = 0.4
  • 299. 286 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The forward difference table is: u x f(x) Δf(x) Δ2f(x) Δ3f(x) – 1 25 .2707 .032 0 30 .3027 .0039 .0359 .0010 1 35 .3386 .0049 .0408 2 40 .3794 Applying Gauss’ forward difference formula, we have f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ ∴ f(.4) = .3027 + (.4)(.0359) + (. )(. ) ! (. ) ( . )(. )(. ) ! (. ) 4 4 1 2 0039 14 4 4 1 3 0010 − + − = 0.316536. Example 2. Use Gauss’ forward formula to find a polynomial of degree four which takes the following values of the function f(x): x: 1 2 3 4 5 f(x): 1 – 1 1 – 1 1 Sol. Taking origin at 3 and h = 1 a + hu = x ⇒ 3 + u = x ⇒ u = x – 3 The difference table is: u x f(x) Δf(x) Δ2f(x) Δ3f(x) Δ4f(x) – 2 1 1 – 2 – 1 2 – 1 4 2 – 8 0 3 1 – 4 16 – 2 8 1 4 – 1 4 2 2 5 1
  • 300. INTERPOLATION 287 Gauss’ forward difference formula is f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − ( ) ( )( ) ! ( ) u u u u f 1 1 2 4 2 4 Δ = 1 + (x – 3)(– 2) + ( )( ) ( ) ( )( )( ) ( ) x x x x x − − − + − − − 3 4 2 4 2 3 4 6 8 + − − − − ( )( )( )( ) ( ) x x x x 2 3 4 5 24 16 = 1 – 2x + 6 – 2x2 + 14x – 24 + 4 3 (x3 – 9x2 + 26x – 24) + 2 3 (x4 – 14x3 + 71x2 – 154x + 120) ∴ F(x) = 2 3 x4 – 8x3 + 100 3 2 x – 56x + 31 Example 3. The values of e–x at x = 1.72 to x = 1.76 are given in the following table: x: 1.72 1.73 1.74 1.75 1.76 e–x: 0.17907 0.17728 0.17552 0.17377 0.17204 Find the value of e–1.7425 using Gauss’ forward difference formula. Sol. Here taking the origin at 1.74 and h = 0.01. ∴ x = a + uh ⇒ u = x a h − = − 1.7425 1.7400 0.01 = 0.25 The difference table is as follows: u x 105f(x) 105Δf(x) 105Δ2f(x) 105Δ3f(x) 105Δ4f(x) – 2 1.72 17907 – 179 – 1 1.73 17728 3 – 176 – 2 0 1.74 17552 1 3 – 175 1 1.75 17377 2 1 – 173 2 1.76 17204
  • 301. 288 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Gauss’s forward formula is f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − ( ) ( )( ) ! ( ) u u u u f 1 1 2 4 2 4 Δ ∴ 105f(.25) = 17552 + (.25)(– 175) + (. )( . ) ( ) ( . )(. )( . ) ( ) 25 75 2 1 125 25 75 6 1 − + − + − − ( . )(. )( . )( . ) ( ) 125 25 75 175 24 3 = 17508.16846 ∴ f(0.25) = e–1.7425 = 0.1750816846. Example 4. Apply Gauss’s forward formula to find the value of u9, if u0 = 14, u4 = 24, u8 = 32, u12 = 35, u16 = 40. Sol. The difference table is (taking origin at 8): u x f(x) Δf(x) Δ2f(x) Δ3f(u) Δ4f(x) – 2 0 14 10 – 1 4 24 – 2 8 – 3 0 8 32 – 5 10 3 7 1 12 35 2 5 2 16 40 Here a = 8, h = 4, a + hu = 9 ∴ 8 + 4u = 9 ⇒ u = .25 Gauss’ forward difference formula is f(.25) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − ( ) ( )( ) ! ( ) u u u u f 1 1 2 4 2 4 Δ = 32 + (.25)(3) + (. )( . ) ( ) ( . )(. )( . ) ( ) 25 75 2 5 125 25 75 6 7 − − + − + − − ( . )(. )( . )( . ) ( ) 125 25 75 175 24 10
  • 302. INTERPOLATION 289 = 33.11621094 Hence u9 = 33.11621094. ASSIGNMENT 4.6 1. Apply Gauss’s forward formula to find the value of f(x) at x = 3.75 from the table: x: 2.5 3.0 3.5 4.0 4.5 5.0 f(x): 24.145 22.043 20.225 18.644 17.262 16.047. 2. Given that x: 25 30 35 40 45 log x: 1.39794 1.47712 1.54407 1.60206 1.65321 Find the value of log 3.7, using Gauss’s forward formula. 3. Find the value of f(41) by applying Gauss’s forward formula from the following data: x: 30 35 40 45 50 f(x): 3678.2 2995.1 2400.1 1876.2 1416.3 4. From the following table, find the value of e1.17 using Gauss forward formula: x: 1 1.05 1.10 1.15 1.20 1.25 1.30 ex: 2.7183 2.8577 3.0042 3.1582 3.3201 3.4903 3.6693 5. From the following table find y when x = 1.45 x: 1.0 1.2 1.4 1.6 1.8 2.0 y: 0.0 – .112 – .016 .336 .992 2.0 4.19 GAUSS’S BACKWARD DIFFERENCE FORMULA Newton’s Gregory forward difference formula is f(a + hu) = f(a) + uΔf(a) + u u f a u u u f a ( ) ! ( ) ( )( ) ! ( ) ...... − + − − + 1 2 1 2 3 2 3 Δ Δ (33) Put a = 0, h = 1, we get f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( )( ) ! ( ) − + − − 1 2 0 1 2 3 0 2 3 Δ Δ + − − − + u u u u f ( )( )( ) ! ( ) ...... 1 2 3 4 0 4 Δ (34)
  • 303. 290 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, Δf(0) = Δf(– 1) + Δ2f(– 1) Δ2f(0) = Δ2f(– 1) + Δ3f(– 1) Δ3f(0) = Δ3f(– 1) + Δ4f(– 1) Δ4f(0) = Δ4f(– 1) + Δ5f(– 1) and so on. ∴ From (34), f(u) = f(0) + u[Δf(– 1) + Δ2f(– 1)] + u u ( ) ! − 1 2 [Δ2f(–1) + Δ3f(– 1)] + u u u f f ( )( ) ! [ ( ) ( )] − − − + − 1 2 3 1 1 3 4 Δ Δ + u u u u ( )( )( ) ! − − − 1 2 3 4 [Δ4f(–1) + Δ5f(– 1)] + ...... (35) = f(0) + uΔf(– 1) + u u 1 1 2 + − F HG I KJ Δ2f(– 1) + u u u f ( ) ( ) − + − F HG I KJ − 1 2 1 2 3 1 3 Δ + u u u u f u u u u f ( )( ) ( ) ( )( )( ) ! ( ) ...... − − + − R S T U V W − + − − − − + 1 2 6 1 3 4 1 1 2 3 4 1 4 5 Δ Δ = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f + − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − + ( ) ( )( ) ! ( ) ...... u u u u f 1 1 2 4 1 4 Δ (36) Again, Δ3f(– 1) = Δ3f(– 2) + Δ4f(– 2) and Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2) and so on ∴ (36) gives f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! u u f u u u + − + + − 1 2 1 1 1 3 2 Δ {Δ3f(– 2) + Δ4f(– 2)} + ( ) ( )( ) ! u u u u + − − 1 1 2 4 {Δ4f(– 2) + Δ5f(– 2)} + ......
  • 304. INTERPOLATION 291 f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f + − + + − − 1 2 1 1 1 3 2 2 3 Δ Δ + + + − − + ( ) ( ) ( ) ! ( ) ...... u u u u f 2 1 1 4 2 4 Δ (37) This is known as Gauss’ backward difference formula. This formula is useful when u lies between − 1 2 and 0. 4.19.1 Algorithm of Gauss’s Backward Formula Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h=ax[1]-ax[0] Step 06. for i=0;in-l;i++ Step 07. diff[i][1]=ay[i+1]-ay[i] Step 08. End Loop i Step 09. for j=2;j=4;j++ Step 10. for i=0;in–j;i++ Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until ax[i]x Step 16. i=i+1 Step 17. i=i–1; Step 18. p=(x–ax[i])/h Step 19. y1=p*diff[i-1][1] Step 20. y2=p*(p+1)*diff[i–1][2]/2 Step 21. y3=(p+1)*p*(p-1)*diff[i–2][3]/6 Step 22. y4=(p+2)*(p+1)*p*(p–1)*diff[i–3][4]/24 Step 23. y=ay[i]+y1+y2+y3+y4 Step 24. Print Output x,y Step 25. End of Program
  • 305. 292 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.19.2 Flow-chart START Input n, ax, ay h = ax[1] – ax[0] Loop i = 0 to n – 1 diff[i][1] = ay[i + 1] – ay[i] End loop i Loop for j = 2 to 4 Loop for i = 0 to (n – j) Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – i] End loop i End loop j i = 0 Y X No Yes Is ax[i] x
  • 306. INTERPOLATION 293 X Y i = i + 1 i = i – 1 p = (x – ax[i])/h y = p * diff[i – 1][1] y = p * (p + 1) * diff[i – 1][2]/2 y = (p + 1) * p * (p – 1) * diff[i – 2][3]/6 y = (p + 2) * (p + 1) * p * (p – 1) * diff[i – 3][4]/24 1 2 3 4 y = ay[i] + y + y + y + y 1 2 3 4 Print x, y STOP /* ******************************************************************** 4.19.3 Program to Implement Gauss’s Backward Method of Interpolation **********************************************************************/* //...HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //...MAIN EXECUTION THREAD void main()
  • 307. 294 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES { //...Variable declaration Field //...Integer Type int n; //... No. of terms int i,j; //... Loop Variables //...Floating Type float ax[10]; //... array limit 9 float ay[10]; //... array limit 9 float x; //... User Querry float y=0; //... Initial value 0 float h; //... Calc. section float p; //... Calc. section float diff[20][20]; //... array limit 19, 19 float y1,y2,y3,y4; //... Formulae variables //... Invoke Function Clear Screen clrscr(); //... Input Section printf(n Enter the number of terms – ); scanf(%d,n); //... Input Sequel for array X printf(nn Enter the value in the form of x – ); //... Input loop for X for (i=0;in;i++) { printf(nn Enter the value of x%d–,i+1); scanf(%f”,ax[i]); } //...Input Sequel for array Y printf(nn Enter the value in the form of y–); //...Input Loop for Y for(i=0;in;i++) { printf(nn Enter the value of y%d–,i+1);
  • 308. INTERPOLATION 295 scanf(%f,ay[i]); } //... Inputting the required value query printf(nEnter the value of x for); printf(nwhich you want the value of y – ); scanf(%f,x); //... Calculation and Processing Section h=ax[1]–ax[0]; for(i=0;in–1;i++) { diff[i][1]=ay[i+1]–ay[i]; } for(j=2;j=4;j++) { for(i=0;in–j;i++) { diff[i][j]=diff[i+1][j–1]–diff[i][j–1]; } } i=0; do { i++; }while (ax[i]x); i—–; p=(x-ax[i])/h; y1=p*diff[i–1][1]; y2=p*(p+1)*diff[i-1][2]/2; y3=(p+1)*p*(p–1)*diff[i–2][3]/6; y4=(p+2)*(p+1)*p*(p–1)*diff[i–3][4]/24; //... Taking Sum y=ay[i]+y1+y2+y3+y4; //... Output Section printf(nwhen x=%6.1f,y=%6.4f ,x,y); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit);
  • 309. 296 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES getch(); } //... Termination of Main Execution Thread 4.19.4 Output Enter the number of terms – 7 Enter the value in the form of x – Enter the value of x1 – 1.00 Enter the value of x2 – 1.05 Enter the value of x3 – 1.10 Enter the value of x4 – 1.15 Enter the value of x5 – 1.20 Enter the value of x6 – 1.25 Enter the value of x7 – 1.30 Enter the value in the form of y – Enter the value of y1 – 2.1783 Enter the value of y2 – 2.8577 Enter the value of y3 – 3.0042 Enter the value of y4 – 3.1582 Enter the value of y5 – 3.3201 Enter the value of y6 – 3.4903 Enter the value of y7 – 3.6693 Enter the value of x for which you want the value of y – 1.35 When x = 1.35, y=3.8483 Press Enter to Exit EXAMPLES Example 1. Given that 12500 = 111.803399, 12510 = 111.848111 12520 = 111.892806, 12530 = 111.937483 Show by Gauss’s backward formula that 12516 = 111.8749301. Sol. Taking the origin at 12520 ∴ u = x a h − = 12516 12520 10 − = – 4 10 = – 0.4
  • 310. INTERPOLATION 297 Gauss’s backward formula is f(u) = f(0) + uΔf(– 1) + ( ) ! u u + 1 2 Δ2 f(– 1) + ( ) ( ) ! u u u + − 1 1 3 Δ3f(– 2) + ...... (38) The difference table is: u x 106 f(x) 106Δ f(x) 106 Δ2 f(x) 106 Δ3 f(x) – 2 12500 111803399 44712 – 1 12510 111848111 – 17 44695 – 1 0 12520 111892806 – 18 44677 1 12530 111937483 From (38), 106f(– .4) = 111892806 + (– .4)(44695) + (. )( . ) ! ( ) (. )( . )( . ) ! ( ) 6 4 2 18 6 4 14 3 1 − − + − − − = 111874930.1 ∴ f(– .4) = 111.8749301 Hence, 12516 = 111.8749301. Example 2. Find the value of cos 51° 42′ by Gauss’s backward formula. Given that x: 50° 51° 52° 53° 54° cos x: 0.6428 0.6293 0.6157 0.6018 0.5878. Sol. Taking the origin at 52° and h = 1 ∴ u = (x – a) = 51° 42′ – 52° = – 18′ = – 0.3° Gauss’s backward formula is f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f + − + + − − 1 2 1 1 1 3 2 2 3 Δ Δ + + + − − ( )( ) ( ) ! ( ) u u u u f 2 1 1 4 2 4 Δ (39)
  • 311. 298 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The difference table is as below: u x 104 f(x) 104 Δ f(x) 104 Δ2 f(x) 104 Δ3 f(x) 104 Δ4 f(x) – 2 50° 6428 – 135 – 1 51° 6293 – 1 – 136 – 2 0 52° 6157 – 3 4 – 139 2 1 53° 6018 – 1 – 140 2 54° 5878 From (39), 104f(– .3) = 6157 + (– .3)(– 136) + (. )( . ) ! ( ) (. )( . )( . ) ! ( ) 7 3 2 3 7 3 13 3 2 − − + − − − + − − ( . )(. )( . )( . ) ! ( ) 17 7 3 13 4 4 = 6198.10135 ∴ f(– .3) = .619810135 Hence cos 51°42′ = 0.619810135. Example 3. Using Gauss’s backward interpolation formula, find the population for the year 1936 given that Year: 1901 1911 1921 1931 1941 1951 Population: 12 15 20 27 39 52 (in thousands) Sol. Taking the origin at 1941 and h = 10, x = a + uh ∴ u = x a h − = 1936 1941 10 − = – 0.5 Gauss’s backward formula is f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f + − + + − − 1 2 1 1 1 3 2 2 3 Δ Δ + + + − − + + + − − − ( )( ) ( ) ! ( ) ( )( ) ( )( ) ! ( ) u u u u f u u u u u f 2 1 1 4 2 2 1 1 2 5 3 4 5 Δ Δ (40)
  • 312. INTERPOLATION 299 The difference table is: u f(u) Δf(u) Δ2f(u) Δ3f(u) Δ4f(u) Δ5f(u) – 4 12 3 – 3 15 2 5 0 – 2 20 2 3 7 3 – 10 – 1 27 5 – 7 12 – 4 0 39 1 13 1 52 From (40), f(– .5) = 39 + (– .5)(12) + (. )( . ) ( ) (. )( . )( . ) ( ) 5 5 2 1 5 5 15 6 4 − + − − − = 32.625 thousands Hence, the population for the year 1936 = 32625 Example 4. f(x) is a polynomial of degree four and given that f(4) = 270, f(5) = 648, Δf(5) = 682, Δ3 f(4) = 132. Find the value of f(5.8) using Gauss’s backward formula. Sol. Δf(5) = f(6) – f(5) ∴ f(6) = f(5) + Δf(5) = 648 + 682 = 1330 Δ3f(4) = (E – 1)3 f(4) = f(7) – 3 f(6) + 3 f(5) – f(4) = 132 ∴ f(7) = 3f(6) – 3f(5) + f(4) + 132 = 3 × 1330 – 3 × 648 + 270 + 132 = 2448. The difference table is (Taking origin at 6): u x f(x) Δ f(x) Δ2 f(x) Δ3 f(x) – 2 4 270 378 – 1 5 648 304 682 132 0 6 1330 436 1118 1 7 2448
  • 313. 300 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Here, a = 6, h = 1, a + hu = 5.8 ∴ 6 + u = 5.8 ⇒ u = – .2 Gauss’s backward formula is f(– .2) = f(0) + uΔf(– 1) + + − + + − − ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f 1 2 1 1 1 3 2 2 3 Δ Δ = 1330 + (– .2)(682) + (. )( . ) ( ) (. )( . )( . ) ( ) 8 2 2 436 8 2 12 6 132 − + − − = 1162.944 ∴ f(5.8) = 1162.944. ASSIGNMENT 4.7 1. The population of a town in the years 1931, ......, 1971 are as follows: Year: 1931 1941 1951 1961 1971 Population: 15 20 27 39 52 (in thousands) Find the population of the town in 1946 by applying Gauss’s backward formula. 2. Apply Gauss’s backward formula to find the value of (1.06)19 if (1.06)10 = 1.79085, (1.06)15 = 2.39656, (1.06)20 = 3.20714, (1.06)25 = 4.29187 and (1.06)30 = 5.74349. 3. Given that x: 50 51 52 53 54 tan x: 1.1918 1.2349 1.2799 1.3270 1.3764 Using Gauss’s backward formula, find the value of tan 51° 42′. 4. Interpolate by means of Gauss’s backward formula, the population of a town for the year 1974 given that: Year: 1939 1949 1959 1969 1979 1989 Population: 12 15 20 27 39 52 (in thousands) 5. Apply Gauss’s backward formula to find sin 45° from the following table: θ°: 20 30 40 50 60 70 80 sin θ: 0.34202 0.502 0.64279 0.76604 0.86603 0.93969 0.98481
  • 314. INTERPOLATION 301 6. Using Gauss’s backward formula, estimate the number of persons earning wages be- tween $ 60 and $ 70 from the following data: Wages ($): Below 40 40—60 60—80 80—100 100—120 Number of people: 250 120 100 70 50 (in thousands) 4.20 STIRLING’S FORMULA Gauss’s forward formula is f(u) = f(0) + uΔf(0) + u u f u u u f ( ) ! ( ) ( ) ( ) ! ( ) − − + + − − 1 2 1 1 1 3 1 2 3 Δ Δ + + − − − + ( ) ( )( ) ! ( ) ...... u u u u f 1 1 2 4 2 4 Δ (41) Gauss’s backward formula is f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) ( ) ( ) ! ( ) u u f u u u f + − + + − − 1 2 1 1 1 3 2 2 3 Δ Δ + + + − − + ( )( ) ( ) ! ( ) ...... u u u u f 2 1 1 4 2 4 Δ (42) Take the mean of (41) and (42), f(u) = f(0) + + − R S T U V W+ − u f f u f Δ Δ Δ ( ) ( ) ! ( ) 0 1 2 2 1 2 2 + + − ( ) ( ) ! u u u 1 1 3 Δ Δ 3 3 1 2 2 f f ( ) ( ) − + − R S T U V W + u u f 2 2 4 1 4 2 ( ) ! ( ) ...... − − + Δ (43) This is called Stirling’s formula. It is useful when | u | 1 2 or − 1 2 1 2 u . It gives the best estimate when − 1 4 1 4 u .
  • 315. 302 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.20.1 Algorithm of Stirling’s Formula Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h = ax[1]-ax[0] Step 06. for i = 1;i n-1; i++ Step 07. diff [i][1] = ay[i + 1]-ay[i] Step 08. End loop i Step 09. for j = 2; j = 4; j++ Step 10. for i = 0; i n-j; i++ Step 11. diff[i][j] = diff[i + 1][j-1]-diff[i][j-1] Step 12. End loop i Step 13. End loop j Step 14. i = 0 Step 15. Repeat step 16 until ax[i] x Step 16. i = i + 1 Step 17. i = i-1; Step 18. p = (x-ax[i])/h Step 19. y1= p*(diff[i][1] + diff[i-1][1])/2 Step 20. y2 = p*p*diff[i-1][2]/2 Step 21. y3 = p*(p*p-1)*(diff[i-1][3]+diff[i-2][3])/6 Step 22. y4 = p*p*(p*p-1)*diff[i-2][4]/24 Step 23. y = ay[i]+y1 + y2 + y3 + y4 Step 24. Print output Step 25. End of program
  • 316. INTERPOLATION 303 4.20.2 Flow-chart START Enter n, ax, ay h = ax[1] – ax[0] loop i = 1 to (n – 1) diff[i][1] = ay[i + 1] – ay[i] End loop i loop j = 2 to 4 loop i = 0 to (n – j) diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1] End loop i End loop j i = 0 Y X No Yes If ax[i] x
  • 317. 304 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES X i = i + 1 i = i – 1 p = (x – ax[i])/h y = p * (diff[i][1] + diff[i – 1][1])/2 y = p * p * diff[i – 1][2]/2 y = p * (p * p – 1) * (diff[i – 1][3] + diff[i – 2][3])/6 y = (p * (p * (p * (p – 1))) * diff[i – 2][4]/24 1 2 3 4 y = ay[i] + y + y + y + y 1 2 3 4 Print ‘‘output’’, y STOP Y */ ******************************************************************** 4.20.3 Program to Implement Stirling Method of Interpolation ******************************************************************** /* //... HEADER FILES DECLARATION #includestdio.h #includeconio.h #includemath.h #includeprocess.h //...MAIN EXECUTION THREAD void main()
  • 318. INTERPOLATION 305 { //...Variable declaration Field //...Integer Type int n; int i,j; //...Floating Type float ax[10]; //... array-limit 9 float ax[10]; //... array-limit 9 float h; float p; float diff[20][20]; //...array 2d-limit 19,19 float x,y; float y1,y2,y3,y4; clrscr(); //... Clear Screen //... Input Section printf(n Enter the value of terms); scanf(%d,%n); //... Input Section Array X printf(”n Enter the values for x n”); //...Input Section Loop for X for(i=0;in;i++) { printf(n Enter the value for x%d-,i+1); scanf(%f”,ax[i]); } //... Input Section for Y printf(n Enter the values for y n); //... Input Section Loop for Y for(i=0;in;i++) { printf(n Enter the value for y%d-,i+1); scanf(%f,ay[i]); } //... Input Section Loop for Value of X for Y printf(n Enter the value of x for);
  • 319. 306 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(n which you want the value of y); scanf(%f,x); //...Calculation and Processing Section h=ax[1]-ax[0]; for(i=0;in-1;i++) { diff[i][1]=ay[i+1]-ay[i]; } for(j=2;j=4;j++) { for(i=0;in-j;i++) { diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } } i=0; do { i++; }while(ax[i]x); i--; p=(x-ax[i])/h; y1=p*(diff[i][1]+diff[i-1][1])/2; y2=p*p*diff[i-1][2]/2; y3=p*(p*p-1)*(diff[i-1][3]+diff[i-2][3])/6; y4=p*p*(p*p-1)*diff[i-2][4]/24; y=ay[i]+y1+y2+y3+y4; //...Output Section printf(nn When x=%6.2f, y=%6.8f,x,y); //... Producing User Watch Halt Function getch(); } 4.20.4 Output Enter the value of terms-7 Enter the values for x
  • 320. INTERPOLATION 307 Enter the value for x1 - .61 Enter the value for x2 - .62 Enter the value for x3 - .63 Enter the value for x4 - .64 Enter the value for x5 - .65 Enter the value for x6 - .66 Enter the value for x7 - .67 Enter the values for y Enter the value for y1 - 1.840431 Enter the value for y2 - 1.858928 Enter the value for y3 - 1.877610 Enter the value for y4 - 1.896481 Enter the value for y5 - 1.915541 Enter the value for y6 - 1.934792 Enter the value for y7 - 1.954237 Enter the value of x for which you want the value of y - 0.6440 When x=0.6440,y=1.90408230 Press Enter to Continue EXAMPLES Example 1. Given: θ: 0° 5° 10° 15° 20° 25° 30° tan θ: 0 0.0875 0.1763 0.2679 0.364 0.4663 0.5774 Find the value of tan 16° using Stirling formula. Sol. Take origin at 15° ∴ a = 15°, h = 5 a + hu = 16 ⇒ 15 + 5u = 16 ⇒ u = .2
  • 321. 308 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The difference table is: u θ 104f(θ) 104Δf(θ) 104Δ2f(θ) 104Δ3f(θ) 104Δ4f(θ) 104Δ5f(θ) 104Δ6f(θ) – 3 0 0 875 – 2 5 875 13 888 15 – 1 10 1763 28 2 916 17 – 2 0 15 2679 45 0 11 961 17 9 1 20 3640 62 9 1023 26 2 25 4663 88 1111 3 30 5774 Using Stirling’s formula, 104f(.2) = 2679 + (.2) 961 916 2 2 2 45 12 2 8 3 17 17 2 2 + F HG I KJ + + − + F HG I KJ (. ) ! ( ) ( . )(. )( . ) ! + − + − − + − R S T U V W (. ) (. ) ! ( ) ( . )( . )(. )( . )( . ) ! ( ) 2 2 1 4 0 2 2 12 2 8 18 5 9 2 2 2 2 o t + − − (. ) {(. ) }{(. ) } ! ( ) 2 2 1 2 4 6 11 2 2 2 = 2866.980499 ∴ f(.2) = .2866980499 Hence tan 16° = 0.2866980499. Example 2. Apply Stirling’s formula to find the value of f(1.22) from the following table which gives the values of f(x) = 1 2 e x 2 0 x 2 π − z dx, at intervals of x = 0.5 from x = 0 to 2. x: 0 0.5 1.0 1.5 2.0 f(x): 0 0.191 0.341 0.433 0.477.
  • 322. INTERPOLATION 309 Sol. Let the origin be at 1 and h = 0.5 ∴ x = a + hu, u = x a h − = − = 1. 1. 22 00 0 5 0 44 . . Applying Stirling’s formula f(u) = f(0) + u . 1 2 0 1 2 1 2 2 Δ Δ Δ f f u f ( ) ( ) ! ( ) + − + − + − − + − + − − + u u f f u u f ( ) ! . [ ( ) ( )] ( ) ! . ( ) ...... 2 3 3 2 2 4 1 3 1 2 1 2 1 4 2 Δ Δ Δ ∴ f(0.44) = f(0) + (0.44) 1 2 0 1 0 44 2 1 2 2 [ ( ) ( )] ( . ) ( ) Δ Δ Δ f f f + − + − + − − + − + − − ( . )[( . ) ] . [ ( ) ( )] ( . ) [( . ) ] ( ) 0 44 0 44 1 6 1 2 1 2 0 44 0 44 1 24 2 2 3 3 2 2 4 Δ Δ Δ f f f ~ − f(0) + (0.22)[Δf(0) + Δf(– 1)] + 0.0968 Δ2 f(– 1) – 0.029568 [Δ3f(– 1) + Δ3f(– 2)] – 0.06505 Δ4f(– 2) + ...... The difference table is as follows: u x 103f(x) 103 Δf(x) 103Δ2f(x) 103Δ3f(x) 103Δ4f(x) – 2 0 0 191 – 1 .5 191 – 41 150 – 17 0 1 341 … – 58 27 1 1.5 433 92 10 44 – 48 2 2 477 f(0) and the differences are being multiplied by 103 ∴ 103f(0.44) ~ − 341 + 0.22 × (150 + 92) + 0.0968 × (– 58) – 0.029568 × [– 17 + 10] – 0.006505 × 27 ~ − 341 + 0.22 × 242 – 0.0968 × 58 + 0.029568 × 7 – 0.006505 × 27 ~ − 341 + 53.24 – 5.6144 + 0.206276 – 0.175635 ~ − 388.66 ∴ f(0.44) = 0.389 Hence the required value of f(x) at x = 1.22 is 0.389.
  • 323. 310 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 3. Use Stirling’s formula to find y28, given y20 = 49225, y25 = 48316, y30 = 47236, y35 = 45926, y40 = 44306. Sol. Let the origin be at 30 and h = 5 a + hu = 28 ⇒ 30 + 5u = 28 ⇒ u = – .4 The difference table is as follows: u x y Δy Δ2y Δ3y Δ4y – 2 20 49225 – 909 – 1 25 48316 – 171 – 1080 – 59 0 30 47236 – 230 – 21 – 1310 – 80 1 35 45926 – 310 – 1620 2 40 44306 By Stirling’s formula, f(– .4) = 47236 + (– .4) − − F HG I KJ + − 1080 1310 2 4 2 2 ( . ) ! (– 230) + − − − − F HG I KJ + − − − − (. )( . )( . ) ! ( . ) {( . ) } ! ( ) 6 4 14 3 59 80 2 4 4 1 4 21 2 2 = 47691.8256 Hence y28 = 47691.8256. Example 4. Use Stirling’s formula to find y35, given y20 = 512, y30 = 439, y40 = 346 and y50 = 243. Sol. Let the origin be at 30 and h = 10 a + hu = 35 30 + 10u = 35 ⇒ u = .5
  • 324. INTERPOLATION 311 The difference table is as follows: u x y Δy Δ2y Δ3y – 1 20 512 – 73 0 30 439 – 20 – 93 10 1 40 346 – 10 – 103 2 50 243 By Stirling’s formula, f(.5) = 439 + (.5) − − F HG I KJ + − + − F HG I KJ 93 73 2 5 2 20 15 5 5 3 10 2 2 (. ) ! ( ) ( . )(. )( . ) ! = 394.6875 Hence, y35 = 394.6875. ASSIGNMENT 4.8 1. Use Stirling’s formula to find the value of f(1.22) from the table. x f(x) 1.0 0.84147 1.1 0.89121 1.2 0.93204 1.3 0.96356 1.4 0.98545 1.5 0.99749 1.6 0.99957 1.7 0.99385 1.8 0.97385 2. Find f(0.41) using Stirling’s formula, if f(0.30) = 0.1179, f(0.35) = 0.1368, f(0.40) = 0.1554 f(0.45) = 0.1736, f(0.50) = 0.1915.
  • 325. 312 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3. Evaluate sin (0.197) from the data given below: x: 0.15 0.17 0.19 0.21 0.23 sin x: 0.14944 0.16918 0.18886 0.20846 0.22798 4. Use Stirling’s formula to find u32 from the following table: u20 = 14.035 u30 = 13.257 u40 = 12.089 u25 = 13.674 u35 = 12.734 u45 = 11.309. 5. Employ Stirling’s formula to evaluate y12.2 from the following table (yx = 1 + log10 sin x): x°: 10 11 12 13 14 105 yx: 23967 28060 31788 35209 38368. 6. The following table gives the values of ex for certain equidistant values of x. Find the value of ex when x = 0.644 using Stirling’s method. x: 0.61 0.62 0.63 0.64 0.65 0.66 0.67 y = ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237 4.21 BESSEL’S INTERPOLATION FORMULA Gauss’s forward formula is f(u) = f(0) + uΔf(0) + u u f ( ) ! ( ) − − 1 2 1 2 Δ + + − − ( ) ( ) ! ( ) u u u f 1 1 3 1 3 Δ + ( ) ( ) ( ) ! ( ) ..... u u u u f + − − − 1 1 2 4 2 4 Δ (44) Gauss’s backward formula is f(u) = f(0) + uΔf(– 1) + ( ) ! ( ) u u f + − 1 2 1 2 Δ + + − − ( ) ( ) ! ( ) u u u f 1 1 3 2 3 Δ + ( ) ( ) ( ) ! ( ) u u u u f + + − − 2 1 1 4 2 4 Δ + ..... (45)
  • 326. INTERPOLATION 313 In eqn. (45), shift the origin to 1 by replacing u by u – 1 and adding 1 to each argument 0, – 1, – 2, ....., we get f(u) = f(1) + (u – 1) Δf(0) + u u f ( ) ! ( ) − 1 2 0 2 Δ + u u u f ( ) ( ) ! ( ) − − − 1 2 3 1 3 Δ + ( ) ( ) ( ) ! ( ) u u u u f + − − − 1 1 2 4 1 4 Δ + ..... (46) Taking mean of (44) and (46), we get f(u) = f f u u f ( ) ( ) ( ) ( ) 0 1 2 1 2 0 + R S T U V W+ + − R S T U V WΔ + u u f f ( ) ! ( ) ( ) − − + R S T U V W 1 2 1 0 2 2 2 Δ Δ + u u u u f ( ) ! ( ) ( ) − + + − − 1 3 1 2 1 2 3 Δ + ( ) ( ) ( ) ! ( ) ( ) u u u u f f + − − − + − R S T U V W 1 1 2 4 2 1 2 4 4 Δ Δ + ..... Finally, we get f(u) = f f u f ( ) ( ) ( ) 0 1 2 1 2 0 + R S T U V W+ − F HG I KJ Δ + − − + R S T | U V W | u u f f ( ) ! ( ) ( ) 1 2 1 0 2 2 2 Δ Δ + ( ) ! ( ) u u u f − − F HG I KJ − 1 1 2 3 1 3 Δ + ( ) ( ) ( ) ! ( ) ( ) u u u u f f + − − − + − R S T U V W 1 1 2 4 2 1 2 4 4 Δ Δ + ...... (47)
  • 327. 314 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES This is called Bessel’s formula. It is very useful when u = 1 2 . It gives a better estimate when 1 4 u 3 4 . It is used mainly to compute entry against any argument between 0 and 1. 4.21.1 Algorithm of Bessel’s Formula Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. h=ax[1]-ax[0] Step 06. for i=1;in-l;i++ Step 07. diff[i][1]=ay[i+1]-ay[i] Step 08. End Loop i Step 09. for j=2;j=4;j++ Step 10. for i=0;in–j;i++ Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until ax[i]x Step 16. i=i+1 Step 17. i=i–1; Step 18. p=(x–ax[i])/h Step 19. y1=p*(diff[i][1]) Step 20. y2=p*(p-1)*(diff[i][2]+diff[i–1][2])/4 Step 21. y3=p*(p-1)*(p-0.5)*(diff[i–1][3])/6 Step 22. y4=(p+1)*p*(p–1)*(p–2)*(diff[i–2][4]+diff[i–1][4])/48 Step 23. y=ay[i]+y1+y2+y3+y4 Step 24. Print Output Step 25. End of Program
  • 328. INTERPOLATION 315 4.21.2 Flow-chart START Enter n, ax, ay h = ax[i] – ax[0] Loop i = 1 to n – 1 Diff[i][1] = ay[i + 1] – ay[i] End loop i Loop j = 2 to 4 Loop i = 0 to (n – j) Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1] End loop i End loop j i = 0 Y X No Yes Is ax[i] x
  • 329. 316 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES X i = i + 1 i = i – 1 p = (x – ax[i])/h y = p * (diff[i][1]) y = p * (p – 1) * (diff[i][2] + diff[i – 1][2])/4 y = p * (p – 1) * (p – 0.5) * (diff[i – 1][3])/6 y = (p + 1) * p*(p – 1) * (p – 2) * (diff[i – 2][4] + diff[i – 1][4])/48 1 2 3 4 y = ay[i] + y + y + y + y 1 2 3 4 Print ‘‘output’’x, y STOP Y /* *********************************************************************** 4.21.3 Program to Implement Bessel’s Method of Interpolation *********************************************************************** */ //...HEADER FILES DECLARATION #includestdio.h #includeconio.h #includemath.h #includeprocess.h //... MAIN EXECUTION THREAD void main() { //...Variable declaration Field
  • 330. INTERPOLATION 317 //...Integer Type int n; int i,j; //...Floating Type float ax[10]; //...array – limit 9 float ay[10]; //...array – limit 9 float h; float p; float diff[20][20]; //... array 2d – limit 19, 19 float x,y; float y1,y2,y3,y4, //...Invoke Clear Screen Function clrscr(); //... Clear Screen //... Input Section printf(n Enter the number of terms); scanf(%d,n); //... Input Section Array X printf(n Enter the values for x n); //... Input Section Loop for X for(i=0;in;i++) { printf(n Enter the value for x%d–,i+1); scanf(%f,ax[i]); } //... Input Section for Array Y printf(n Enter the values for yn); //...Input Section Loop for Y for(i=0;in;i++) { printf(n Enter the value for y%d–,i+1); scanf(%f,ay[i]); } //...Input Section Loop for Value Of X for Y printf(n Enter the value of x for ); printf(n which you want the value of y );
  • 331. 318 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES scanf (%f,x); //...Input X //...Calculation and Processing Section h=ax[1]–ax[0]; for(i=0;in–1;i++) { diff[i][1]=ay[i+1]–ay[i]; } for(j=2;j=4;j++) { for(i=0;in–j;i++) { diff[i][j]=diff[i+1][j–1]–diff[i][j–1]; } } i=0; do { i++; }while (ax[i]x); i––; //... Bessel formulae Calculation p=(x-ax[i])/h; y1=p*(diff[i][1]); y2=p*(p-1)*diff[i][2]+diff[i-1][2])/4; y3=p*(p–1)*(p–0.5)*(diff[i–1][3])/6; y4=(p+1)*p*(p–1)*(p–2)*(diff[i–2][4]+diff[i–1][4])/48; //...Taking Sum y=ay[i]+y1+y2+y3+y4; //...Output Section printf(nwhen x=%6.2f,y=%6.8f ,x,y); //...Invoke User Watch Halt Function printf(nn Press Enter to Exit t); getch(); } *End of Main Execution Thread */
  • 332. INTERPOLATION 319 4.21.4 Output Enter the number of terms - 7 Enter the values of x Enter the value of x1 - .61 Enter the value of x2 - .62 Enter the value of x3 - .63 Enter the value of x4 - .64 Enter the value of x5 - .65 Enter the value of x6 - .66 Enter the value of x7 - .67 Enter the values of y Enter the value of y1 - 1.840431 Enter the value of y2 - 1.858928 Enter the value of y3 - 1.877610 Enter the value of y4 - 1.896481 Enter the value of y5 - 1.915541 Enter the value of y6 - 1.934792 Enter the value of y7 - 1.954237 Enter the value of x for which you want the value of y - .644 When x = 0.644, y=1.90408230 Press Enter to Exit EXAMPLES Example 1. Given y20 = 24, y24 = 32, y28 = 35 and y32 = 40 find y25 by Bessel’s interpolation formula. Sol. Take origin at 24. Here, a = 24, h = 4, a + hu = 25 ∴ 24 + 4u = 25 ⇒ u = .25
  • 333. 320 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The difference table is: u x y Δy Δ2y Δ3y – 1 20 24 8 0 24 32 – 5 3 7 1 28 35 2 5 2 32 40 Using Bessel’s formula, f(u) = f f u f ( ) ( ) ( ) 0 1 2 1 2 0 + R S T U V W+ − F HG I KJ Δ + − − + R S T | U V W | u u f f ( ) ( ) ( ) 1 2 1 0 2 2 2 Δ Δ + ( ) ! ( ) u u u f − − F HG I KJ − 1 1 2 3 1 3 Δ ⇒ f(.25) = 32 35 2 + F HG I KJ + (.25 – .5) (3) + (. ) (. ) 25 25 1 2 5 2 2 − − + R S T U V W + (. ) (. . ) (. ) ! ( ) 25 1 25 5 25 3 7 − − = 32.9453125 Hence y25 = 32.9453125. Example 2. Apply Bessel’s formula to find the value of f(27.4) from the table: x: 25 26 27 28 29 30 f(x): 4.000 3.846 3.704 3.571 3.448 3.333. Sol. Taking origin at 27 and h = 1 x = a + uh ⇒ 27.4 = 27 + u × 1 ∴ u = 0.4
  • 334. INTERPOLATION 321 The difference table is as follows: u 103f(u) 103 Δf(u) 103 Δ2f(u) 103 Δ3f(u) 103 Δ4f(u) 103 Δ5f(u) – 2 4000 – 154 – 1 3847 12 – 142 – 3 0 3704 9 4 – 133 1 – 7 1 3571 10 – 3 – 123 – 2 2 3448 8 – 115 3 3333 Bessel’s formula is f(u) = f f u f ( ) ( ) ( ) 0 1 2 1 2 0 + R S T U V W+ − F HG I KJ Δ + u u f f ( ) ! ( ) ( ) − + − R S T U V W 1 2 0 1 2 2 2 Δ Δ + ( ) ! ( ) u u u f − − F HG I KJ − 1 1 2 3 1 3 Δ + ( ) ( ) ( ) ! ( ) ( ) u u u u f f + − − − + − R S T U V W 1 1 2 4 1 2 2 4 4 Δ Δ + ( ) ( ) ( ) ! ( ) u u u u u f − − − F HG I KJ + − 2 1 1 2 1 5 2 5 Δ ∴ 103f(0.4) = 3704 3571 2 + R S T U V W + (.4 – .5) (– 133) + (. ) (. ) ! 4 4 1 2 10 9 2 − + F HG I KJ + (. ) (. . ) (. ) ! ( ) 4 1 4 5 4 3 1 − − + (. ) (. ) (. ) (. ) ! 4 1 4 4 1 4 2 4 3 4 2 + − − − + F HG I KJ + (. ) (. ) (. . ) (. ) (. ) ! ( ) 4 2 4 1 4 5 4 4 1 5 7 − − − + − = 3649.678336 ⇒ f(.4) = 3.649678336 Hence f(27.4) = 3.649678336.
  • 335. 322 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 3. Probability distribution function values of a normal distribution are given as follows: x: 0.2 0.6 1.0 1.4 1.8 p(x): 0.39104 0.33322 0.24197 0.14973 0.07895 Find the value of p(x) for x = 1.2. Sol. Taking the origin at 1.0 and h = 0.4 x = a + uh ⇒ 1.2 = 1.0 + u × 0.4 ∴ u = 1. 1. 0.4 2 0 1 2 − = The difference table is: u 105f(u) 105 Δf(u) 105 Δ2f(u) 105 Δ3f(u) 105 Δ4f(u) – 2 39104 – 5782 – 1 33332 – 3343 – 9125 3244 0 24197 – 99 – 999 – 9224 2245 1 14973 2146 – 7078 2 7895 Bessel’s formula is f(u) = f f u f ( ) ( ) ( ) 0 1 2 1 2 0 + R S T U V W+ − F HG I KJ Δ + u u f f ( ) ! ( ) ( ) − + − R S T U V W 1 2 0 1 2 2 2 Δ Δ + ( ) ( ) ! ( ) u u u f − − F HG I KJ − 1 1 2 3 1 3 Δ 105 f (.5) = 24197 14973 2 0 1 2 1 2 1 2 2146 99 2 0 + F HG I KJ + + F HG I KJ − F HG I KJ − F HG I KJ + ! = 19457.0625
  • 336. INTERPOLATION 323 ∴ f(.5) = 0.194570625 Hence p(1.2) = 0.194570625. Example 4. Given that x: 4 6 8 10 12 14 f(x): 3.5460 5.0753 6.4632 7.7217 8.8633 9.8986 Apply Bessel’s formula to find the value of f(9). Sol. Taking the origin at 8, h = 2, 9 = 8 + 2u or u = 1 2 The difference table is: u 104 yu 104 Δ2yu 104 Δ2yu 104 Δ3yu 104 Δ4yu 105 Δ5yu – 2 35460 15293 – 1 50753 – 1414 13879 120 0 64632 – 1294 5 1258 125 – 24 1 77217 – 1169 – 19 11416 106 2 88633 – 1063 10353 3 98986 Bessel’s formula is yu = 1 2 1 2 1 2 1 2 1 0 0 2 0 2 1 ( ) ( ) ! ( ) y y u y u u y y + + − F HG I KJ + − + − Δ Δ Δ + u u u y − F HG I KJ − − 1 2 1 3 3 1 ( ) ! Δ + ( ) ( )( ) ! ( ) u u u u y y + − − × + − − 1 1 2 4 1 2 4 3 4 2 Δ Δ + ( ) ( ) ( ) ! u u u u u y − − − F HG I KJ + − 2 1 1 2 1 5 5 2 Δ
  • 337. 324 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 104y1/2 = 1 2 77217 64632 0 1 2 1 2 2 1 2 1169 1294 ( ) . ( ) + + + − F HG I KJ − − + + − F HG I KJ − F HG I KJ − + 0 3 2 1 2 1 2 3 2 24 1 2 19 5 . . . ( ) + 0 ⇒ 104y1/2 = 71078.27344 ∴ y1/2 = 7.107827344 Hence, f(9) = 7.107827344. Example 5. Given y0, y1, y2, y3, y4, y5 (fifth differences constant), prove that y 1 2 c 25(c b) 3(a c) 256 2 1 2 = + − + − where a = y0 + y5, b = y1 + y4, c = y2 + y3 . Sol. Put u = 1 2 in Bessel’s formula, we get y1/2 = 1 2 1 16 3 256 0 1 2 0 2 1 4 1 4 2 ( ) ( ) ( ) y y y y y y + − + + + − − − Δ Δ Δ Δ Shifting the origin to 2, we have y y y y y y y 2 1 2 2 3 2 2 2 1 4 1 4 0 1 2 1 16 3 256 = + − + + + ( ) ( ) ( ) Δ Δ Δ Δ = − c 2 1 16 (y3 – 2y2 + y1 + y4 – 2y3 + y2) + 3 256 (y5 – 3y4 + 2y3 + 2y2 – 3y1 + y0) y c y y y y a b c 2 1 2 4 3 2 1 2 1 16 3 256 3 2 = − − − + + − + ( ) ( ) = − − + − + c b c a b c 2 1 16 3 256 3 2 ( ) ( ) y c c b a c 2 1 2 2 1 256 25 3 = + − + − [ ( ) ( )].
  • 338. INTERPOLATION 325 Example 6. If third differences are constant, prove that y 1 2 (y y ) 1 16 ( y y ) x 1 2 x x 1 2 x 1 2 x + + − = + − + Δ Δ . Sol. Putting u = 1 2 in Bessel’s formula, we get y y y y y 1/2 0 1 2 0 2 1 1 2 1 16 = + − + − ( ) ( ) Δ Δ Shifting the origin to x, y y y y y x x x x x + + − = + − + 1 2 1 2 2 1 1 2 1 16 ( ) ( ) Δ Δ . Example 7. Find the value of y15 ,using Bessel’s formula, if y10 = 2854, y14 = 3162, y18 = 3544, y22 = 3992. Sol. Taking the origin at 14, h = 4 ∴ 15 = 14 + 4 . u ∴ u = 1 4 The difference table is: u x f(x) Δ f(x) Δ2 f(x) Δ3 f(x) – 1 10 2854 308 0 14 3162 74 382 – 8 1 18 3544 66 448 2 22 3992 Bessel’s formula is f(u) = f f u f u u f f ( ) ( ) ( ) ( ) ! ( ) ( ) 0 1 2 1 2 0 1 2 1 0 2 2 2 + R S T U V W+ − F HG I KJ + − − + R S T U V W Δ Δ Δ + ( ) ! ( ) u u u f − − F HG I KJ − 1 1 2 3 1 3 Δ
  • 339. 326 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ f (.25) = 3162 3544 2 + F HG I KJ + (.25 – .5) (382) + (. ) (. ) 25 25 1 2 74 66 2 − + F HG I KJ + (. ) (. . ) (. ) 25 1 25 5 25 6 − − (– 8) = 3250.875 Hence y15 = 3250.875. ASSIGNMENT 4.9 1. Apply Bessel’s formula to find the value of y2.73 given that y2.5 = 0.4938, y2.6 = 0.4953, y2.7 = 0.4965 y2.8 = 0.4974, y2.9 = 0.4981, y3.0 = 0.4987. 2. Find the value of y if x = 3.75, given that x: 2.5 3.0 3.5 4.0 4.5 5.0 y: 24.145 22.043 20.225 18.644 17.262 16.047. Using Bessel’s formula. 3. Apply Bessel’s formula to find u62.5 from the following data: x: 60 61 62 63 64 65 ux: 7782 7853 7924 7993 8062 8129. 4. Apply Bessel’s formula to find the value of f(12.2) from the following table: x: 0 5 10 15 20 25 30 f(x): 0 0.19146 0.34634 0.43319 0.47725 0.49379 0.49865 5. The following table gives the values of ex for certain equidistant values of x. Find the value of ex when x = 0.644 using Bessel’s formula: x: .61 .62 .63 .64 .65 .66 .67 ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237 6. Find y(0.543) from the following values of x and y: x: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 y(x): 2.631 3.328 4.097 4.944 5.875 6.896 8.013 7. Apply Bessel’s formula to obtain y25 given y20 = 2854, y24 = 3162, y28 = 3544, y32 = 3992. 8. The pressure p of wind corresponding to velocity v is given by following data. Estimate p when v = 25. v: 10 20 30 40 p: 1.1 2 4.4 7.9
  • 340. INTERPOLATION 327 4.22 LAPLACE-EVERETT’S FORMULA Gauss’ forward formula is f(u) = f(0) + uΔf(0) + u u f ( ) ! ( ) − − 1 2 1 2 Δ + ( ) ( ) ! ( ) u u u f + − − 1 1 3 1 3 Δ + ( ) ( ) ( ) ! ( ) u u u u f + − − − 1 1 2 4 2 4 Δ + ( ) ( ) ( ) ( ) ! ( ) u u u u u f + + − − − 2 1 1 2 5 2 5 Δ + .... (48) We have, Δf(0) = f(1) – f(0) Δ3f(– 1) = Δ2f(0) – Δ2f(– 1) Δ5f(– 2) = Δ4f(– 1) – Δ4f(– 2) ∴ From (48), f(u) = f(0) + u{f(1) – f(0)} + u u ( ) ! − 1 2 Δ2f(– 1) + ( ) ( ) ! u u u + − 1 1 3 {Δ2f(0) – Δ2f(– 1)} + ( ) ( ) ( ) ! ( ) u u u u f + − − − 1 1 2 4 2 4 Δ + ( ) ( ) ( ) ( ) ! u u u u u + + − − 2 1 1 2 5 {Δ4f(– 1) – Δ4f(– 2)} + ...... = (1 – u) f(0) + uf(1) + ( ) ( ) ! ( ) u u u f + − 1 1 3 0 2 Δ – u u u f ( ) ( ) ! ( ) − − − 1 2 3 1 2 Δ + ( ) ( ) ( ) ( ) ! ( ) u u u u u f + + − − − 2 1 1 2 5 1 4 Δ – ( ) ( ) ( ) ( ) ! ( ) u u u u u f + − − − − 1 1 2 3 5 2 4 Δ + .....
  • 341. 328 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = u f u u u f ( ) ( ) ( ) ! ( ) 1 1 1 3 0 2 + + − R S T Δ + + + − − − + U V W ( ) ( ) ( ) ( ) ! ( ) ..... u u u u u f 2 1 1 2 5 1 4 Δ + ( ) ( ) ( ) ( ) ( ) ! ( ) 1 0 1 1 1 1 1 3 1 2 − + − + − − − − R S T u f u u u f Δ + ( ) ( ) ( ) ( ) ( ) ! ( ) ..... 1 2 1 1 1 1 1 1 2 5 2 4 − + − + − − − − − − + U V W u u u u u f Δ f(u) = uf u u u f ( ) ( ) ( ) ! ( ) 1 1 1 3 0 2 + + − R S T Δ + + + − − − + U V W ( ) ( ) ( ) ( ) ! ( ) ..... u u u u u f 2 1 1 2 5 1 4 Δ + wf w w w f ( ) ( ) ( ) ! ( ) 0 1 1 3 1 2 + + − − R S T Δ + + + − − − + U V W ( ) ( ) ( ) ( ) ! ( ) ..... w w w w w f 2 1 1 2 5 2 4 Δ (49) where w = 1 – u This is called Laplace–Everett’s formula. It gives the best estimate when u 1 2 . It is used to compute any entry against any argument between 0 and 1. It is useful when intervening values in successive intervals are required. 4.22.1 Algorithm of Laplace’ Everett Formula Step 01. Start of the program. Step 02. Input number of terms n Step 03. Input the array ax
  • 342. INTERPOLATION 329 Step 04. Input the array ay Step 05. h=ax[1]-ax[0] Step 06. for i=0; in-l; i++ Step 07. diff[i][1]=ay[i+1]-ay[i] Step 08. End Loop i Step 09. for j=2; j=4; j++ Step 10. for i=0; in–j; i++ Step 11. diff[i][j]=diff[i+1][j–1]–diff[i][j–1] Step 12. End Loop i Step 13. End Loop j Step 14. i=0 Step 15. Repeat Step 16 until ax[i]x Step 16. i=i+1 Step 17. i=i–1; Step 18. p=(x–ax[i])/h Step 19. q=1–p Step 20. y1=q*(ay[i]) Step 21. y2=q*(q*q–1)*diff[i–1][2]/6 Step 22. y3=q*(q*q–1)*(q*q–4)*(diff[i–2][4])/120 Step 23. py1=p*ay[i+1] Step 24. py2=p*(p*p–1)*diff[i][2]/6 Step 25. py3=p*(p*p–1)*(p*p–4)*(diff[i–1][4])/120 Step 26. y=y1+y2+y3+y4+py1+py2+py3 Step 27. Print Output x, y Step 28. End of Program
  • 343. 330 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.22.2 Flow-chart Input n, ax, ay h = ax[1] – ax[0] Start loop for i = 0 to n – 1 Diff[i][1] = ay[i + 1] – ay[i] End loop i For loop i = 2 to 4 For loop j = 0 to (n – j) Diff[i][j] = diff[i + 1][j – 1] – diff[i][j – 1] End loop j End loop i i = 0 i = i – 1 A Yes No Is ax[i] x i = i + 1 Start
  • 344. INTERPOLATION 331 A p = (x – ax[i])/h q = 1 – p y = q * (ay[i]) y = q * (q * q – 1) * diff[i – 1] y = q * (q * q – 1) * (q * (q – 4)) * diff[i – 2][4])/120 1 2 3 py = p * ay[i + 1] py = p * (p * p – 1) * diff[i][2]/6 py = p * (p * p – 1) * (p * p – 4) * (diff[i – 1][4])/120 1 2 3 y = y + y + y + py + py + py 1 2 3 1 2 3 Print ‘‘output’’, x, y STOP /* ************************************************************************ 4.22.3 Program to Implement Laplace Everett’s Method of Interpolation ********************************************************************** */ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... MAIN EXECUTION THREAD
  • 345. 332 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES void main() { //... Variable declaration Field //... Integer Type int n; int i,j; //... Floating Type float ax[10]; //... array limit 9 float ay[10]; //... array limit 9 float x; float nr,dr; float y=0; //... Initial value 0 float h; float p,q; float diff[20][20]; //... array limit 19,19 float y1,y2,y3,y4; float py1,py2,py3,py4; //... Invoke Function Clear Screen clrscr(); //... Input Section printf (n Enter the number of terms - ); scanf(%d,n); //... Input Sequel for array X printf(nn Enter the value in the form of x - ); //... Input Loop for Array X for (i=0;in;i++) { Printf(nn Enter the value of x%d - ,i+1); scanf(%f,ax[i]); } //... Input Sequel for Array X printf (nn Enter the value in the form of y - );
  • 346. INTERPOLATION 333 //... Input Loop Array Y for (i=0;in;i++) { printf (nn Enter the value of y%d - ,i+1); scanf(%f,ay[i]); } //... Inputting the required value query printf(nEnter the value of x for ); printf(nwhich you want the value of y - ); scanf(%f,x); //... Calculation and Processing Section h=ax[1]-ax[0]; for(i=0;in-1;i++) { diff[i][1]=ay[i+1]-ay[i]; } for(j=2;j=4;j++) { for(i=0;in-j;i++) { diff[i][j]=diff[i+1][j-1]-diff[i][j-1]; } } i=0; do { i++; }while(ax[i]x); i--; p=(x-ax[i])/h; q=1-p; y1=q*(ay[i]); y2=q*(q*q-1)*diff[i-1][2]/6; y3=q*(q*q-1)*(q*q-4)*(diff[i-2][4])/120; py1=p*ay[i+1];
  • 347. 334 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES py2=p*(p*p-1)*diff[i][2]/6; py3=p*(p*p-1)*(p*p-4)*(diff[i-1][4])/120; //... Taking sum y=y1+y2+y3+y4+py1+py2+py3; //... Output Section printf(n when x=%6.2f,y=%6.8f ,x,y); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit ); getch(); } //... Termination of Main Execution Thread 4.22.4 Output Enter the number of terms - 7 Enter the value in the form of x - Enter the value of x1 - 1.72 Enter the value of x2 - 1.73 Enter the value of x3 - 1.74 Enter the value of x4 - 1.75 Enter the value of x5 - 1.76 Enter the value of x6 - 1.77 Enter the value of x7 - 1.78 Enter the value in the form of y - Enter the value of y1 - .1790661479 Enter the value of y2 - .1772844100 Enter the value of y3 - .1755204006 Enter the value of y4 - .1737739435 Enter the value of y5 - .1720448638 Enter the value of y6 - .1703329888 Enter the value of y7 - .1686381473 Enter the value of x for which you want the value of y - 1.7475 When x = 1.7475, y = 0.17420892 Press Enter to Exit
  • 348. INTERPOLATION 335 EXAMPLES Example 1. Using Everett’s formula, evaluate f(30) if f(20) = 2854, f(28) = 3162 f(36) = 7088, f(44) = 7984. Sol. Take origin at 28. ∴ a = 28, h = 8 a + hu = 30 ⇒ 28 + 8u = 30 ⇒ u = .25 Also, w = 1 – u = 1 – .25 = .75 The difference table is: u f(u) Δf(u) Δ2f(u) Δ3f(u) – 1 2854 308 0 3162 3618 3926 – 6648 1 7088 – 3030 896 2 7984 By Everett’s formula, ∴ f(.25) = (. ) ( ) ( . ) (. ) ( . ) ! ( ) ..... 25 7088 125 25 75 3 3030 + − − + R S T U V W + (. ) ( ) ( . ) (. ) ( . ) ! ( ) ..... 75 3162 175 75 25 3 3618 + − + R S T U V W = 4064 Hence f(30) = 4064. Example 2. Find the value of f(27.4) from the following table: x: 25 26 27 28 29 30 f(x): 4.000 3.846 3.704 3.571 3.448 3.333. Sol. Here u = 27 4 27 0 1 . . − = 0.4 ∵ origin is at 27.0, h = 1 Also, w = 1 – u = 0.6 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→ ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→
  • 349. 336 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The difference table is: u 103 f(u) 103 Δf(u) 103Δ2f(u) 103Δ3f(u) 103Δ4f(u) – 2 4000 – 154 – 1 3846 12 – 142 – 3 0 3704 9 4 – 133 1 1 3571 10 – 3 – 123 – 2 2 3448 8 – 115 3 3333 By Laplace Everett’s formula, f(.4) = (. )( ) ( . ) (. ) ( . ) ! ( ) 4 3571 14 4 6 3 10 + − R S T + − − − + U V W ( . ) ( . ) (. ) ( . ) ( . ) ! ( ) ..... 2 4 14 4 6 16 5 3 + (. ) ( ) ( . ) (. ) ( . ) ! ( ) 6 3704 16 6 4 3 9 + − R S T + − − U V W ( . ) ( . ) (. ) ( . ) ( . ) ! ( ) 2 6 16 6 4 14 5 4 = 3649.678336. Hence f(27.4) = 3649.678336. ASSIGNMENT 4.10 1. Given the table x: 21 22 23 24 25 26 log x: 1.3222 1.3424 1.3617 1.3802 1.3979 1.4150 Apply Laplace-Everett’s formula to find the value of log 2375. ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ ⎯⎯⎯⎯⎯⎯⎯⎯⎯→
  • 350. INTERPOLATION 337 2. From the following present value annuity an table: x: 20 25 30 35 40 an: 11.4699 12.7834 13.7648 14.4982 15.0463 find the present value of the annuity a31, a32, a33, a34. 3. Find the value of f(31), f(32), f(33), f(34). Given that f(20) = 3010, f(25) = 3979, f(30) = 4771 f(35) = 5441, f(40) = 6021 and f(45) = 6532. 4. Find y12 if y0 = 0, y10 = 43214, y20 = 86002 and y30 = 128372. 5. Obtain the values of y25, given that y20 = 2854, y24 = 3162 y28 = 3544 and y32 = 3992 6. Find the value of e–x when x = 1.748 from the following: x: 1.72 1.73 1.74 1.75 1.76 1.77 e–x: 0.1790 0.1773 0.1755 0.1738 0.1720 0.1703 7. Use Everett’s formula to find the present value of the annuity for n = 36 from the table: x: 25 30 35 40 45 50 ax: 12.7834 13.7648 14.4982 15.0463 15.4558 15.7619. 8. Apply Everett’s formula to find the value of f(26) and f(27) from the table: x: 15 20 25 30 35 40 f(x): 12.849 16.351 19.524 22.396 24.999 27.356. 9. Find the compound interest on the sum of Rs. 10,000 at 7% for the period 16 and 17 years if: x: 5 10 15 20 25 30 (1.07)n: 1.40255 1.96715 2.75903 3.86968 5.42743 7.61236. 10. Apply Everett’s formula to find the values of e–x for x = 3.2, 3.4, 3.6, 3.8, if x: 1 2 3 4 5 6 e–x: 0.36788 0.13534 0.04979 0.01832 0.00674 0.00248. 11. Given that x: 40 45 50 55 60 65 x1/3: 3.4200 3.3569 3.6840 3.8030 3.9149 4.0207 Find the values of x1/3 when x = 51 to 54.
  • 351. 338 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 12. Prove that if third differences are assumed to be constant, yx = xy1 + x x ( ) ! 2 1 3 − Δ2y0 + uy0 + u u ( ) ! 2 1 3 − Δ2y–1 where u = 1 – x. Apply this formula to find the value of y11 and y16, given that y0 = 3010, y5 = 2710, y10 = 2285, y15 = 1860, y20 = 1560, y25 = 1510, y30 = 1835. 13. The following table gives the values of ex for certain equidistant values of x. Find the value of ex when x = 0.644 using Everett’s formula x: 0.61 0.62 0.63 0.64 0.65 0.66 0.67 y = ex: 1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237. 14. The values of the elliptic integral, k(m) = ( sin ) / 1 2 1 2 0 2 − − z m d θ θ π for certain equidistant values of m are given below. Use Everett’s or Bessel’s formula to determine k(0.25). m: 0.20 0.22 0.24 0.26 0.28 0.30 k(m): 1.659624 1.669850 1.680373 1.691208 1.702374 1.713889. 15. From the following table of values of x and y = ex, interpolate the value of y when x = 1.91 x: 1.7 1.8 1.9 2.0 2.1 2.2 y = ex: 5.4739 6.0496 6.6859 7.3891 8.1662 9.0250. 16. Given the table: x: 310 320 330 340 350 360 log x: 2.49136 2.50515 2.51851 2.53148 2.54407 2.55630. Find the value of log 337.5 by Laplace Everett’s formula. 4.23 INTERPOLATION BY UNEVENLY SPACED POINTS The interpolation formulae derived sofar possess the disadvantage of being applicable only to equally spaced values of the argument. It is then desirable to develop interpolation formulae for unequally spaced values of x. We shall study two such formulae: (1) Lagrange’s interpolation formula (2) Newton’s general interpolation formula with divided differences.
  • 352. INTERPOLATION 339 4.24 LAGRANGE’S INTERPOLATION FORMULA Let f(x0), f(x1) ,......, f(xn) be (n + 1) entries of a function y = f(x), where f(x) is assumed to be a polynomial corresponding to the arguments x0, x1, x2, ......, xn. The polynomial f(x) may be written as f(x) = A0 (x – x1) (x – x2) ...... (x – x n) + A1(x – x0)(x – x2) ...... (x – xn) + ...... + An (x – x0) (x – x1) ...... (x – xn –1) (50) where A0, A1, ......, An are constants to be determined. Putting x = x0, x1, ......, xn in (50), we get f(x0) = A0 (x0 – x1) (x0 – x2) ....... (x0 – xn) ∴ A0 = f x x x x x x xn ( ) ( ) ( ) ...... ( ) 0 0 1 0 2 0 − − − (51) f(x1) = A1 (x1 – x0) (x1 – x2) ...... (x1 – xn) ∴ A1 = f x x x x x x xn ( ) ( ) ( ) ...... ( ) 1 1 0 1 2 1 − − − (52) Similarly, An = f x x x x x x x n n n n n ( ) ( ) ( ) ...... ( ) − − − − 0 1 1 (53) Substituting the values of A0, A1, ......, An in equation (50), we get f(x) = ( ) ( ) ...... ( ) ( ) ( ) ...... ( ) x x x x x x x x x x x x n n − − − − − − 1 2 0 1 0 2 0 f(x0) + ( ) ( ) ...... ( ) ( ) ( ) ...... ( ) x x x x x x x x x x x x n n − − − − − − 0 2 1 0 1 2 1 f(x1) + ...... + ( ) ( ) ...... ( ) ( ) ( ) ...... ( ) x x x x x x x x x x x x n n n n n − − − − − − − − 0 1 1 0 1 1 f(xn) (54) This is called Lagrange’s Interpolation Formula. In eqn. (54), dividing both sides by (x – x0) (x – x1) ..... (x – xn), Lagrange’s formula may also be written as
  • 353. 340 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES f x x x x x x xn ( ) ( ) ( ) ...... ( ) − − − 0 1 = f x x x x x x x x x n ( ) ( ) ( ) ...... ( ) . ( ) 0 0 1 0 2 0 0 1 − − − − + f x x x x x x x x x n ( ) ( ) ( ) ...... ( ) . ( ) 1 1 0 1 2 1 1 1 − − − − + ...... + f x x x x x x x x x n n n n n n ( ) ( ) ( ) ...... ( ) . ( ) − − − − − 0 1 1 1 . (55) 4.24.1 Another form of Lagrange’s Formula § Prove that the Lagrange’s formula can be put in the form Pn(x) = φ φ ( ) ( ) ( ) ( ) x f x x x x r r r r n − ′ = ∑0 where φ(x) = ( ) x xr r n − = ∏ 0 and φ′(xr) = d dx x x xr { ( )} φ L NM O QP = We have the Lagrange’s formula, Pn(x) = ( ) ( ) ... ( ) ( ) ... ( ) ( ) ( ) ... ( ) ( ) ... ( ) ( ) x x x x x x x x x x x x x x x x x x x x f x r r n r r r r r r r n r r n − − − − − − − − − − − + − + = ∑ 0 1 1 1 0 1 1 1 0 = φ ( ) ( ) ( ) ( ) ... ( ) ( ) ... ( ) x x x f x x x x x x x x x x x r r r r r r r r r n r n − R S T U V W − − − − − R S | T | U V | W | − + = ∑ 0 1 1 1 0 (56) Now, φ(x) = ( ) x xr r n − = ∏ 0 = (x – x0)(x – x1) ..... (x – xr – 1) (x – xr) (x – xr + 1) ..... (x – xn) ∴ φ′(x) = (x – x1) (x – x2) ..... (x – xr) ..... (x – xn) + (x – x0) (x – x2) ..... (x – xr) ..... (x – xn) + ..... + (x – x0) (x – x1) ..... (x – xr – 1) (x – xr + 1) ..... (x – xn) + ..... + (x – x0) (x – x1) ..... (x – xr) ..... (x – xn – 1)
  • 354. INTERPOLATION 341 ⇒ φ′(xr) = [ ( )] φ′ = x x xr = (xr – x0) (xr – x1) ..... (xr – xr – 1) (xr – xr + 1) ..... (xr – xn) (57) Hence from (56), Pn(x) = φ φ ( ) ( ) ( ) ( ) x f x x x x r r r r n − ′ = ∑0 |using (57) 4.24.2 Algorithm Step 01. Start of the program Step 02. Input number of terms n Step 03. Input the array ax Step 04. Input the array ay Step 05. for i=0; in; i++ Step 06. nr=1 Step 07. dr=1 Step 08. for j=0; jn; j++ Step 09. if j !=i a. nr=nr∗(x-ax[j]) b.dr∗(ax[i]-ax[j]) Step 10. End Loop j Step 11. y+=(nr/dr)∗ay[i] Step 12. End Loop i Step 13. Print Output x, y Step 14. End of Program
  • 355. 342 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4.24.3 Flow-chart START STOP Get the value of n Get the values of ax, ay Get the values of x y = 0 Loop for i = 0 to n nr = dr = 1 Loop for j = 0 to n nr = x – ax[j] ∗ dr = ax[i] – ax[j] ∗ End loop[j] Print x, y as solution B B No Yes Is J ! = i
  • 356. INTERPOLATION 343 /* ******************************************************************** 4.24.4 Program to Implement Lagrange’s Method of Interpolation ********************************************************************** */ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... MAIN EXECUTION THREAD void main() { //... Variable declaration Field //... Integer Type int n; //... Number of terms int i,j; //... Loop Variables //... Floating Type float ax[100]; //... array limit 99 float ay[100]; //... array limit 99 float x=0; //... User Querry float y=0; //... Initial value 0 float nr; //... Calc. section float dr; //... Calc. section //... Invoke Function Clear Screen clrscr(); //... Input Section printf(n Enter the number of terms - ); scanf(%d,n); //... Input Sequel for array X
  • 357. 344 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(nn Enter the value in the form of x - ); //... Input Loop for X for (i=0;in;i++) { printf (nn Enter the value of x%d - , i+1); scanf(%f,ax[i]); } //... Input Sequel for array Y printf(nn Enter the value in the form of y - ); //... Input Loop for Y for (i=0;in;i++) { printf(nn Enter the value of y%d - , i+1); scanf (%f,ay[i]); } //... Inputting the required value query printf(n Enter the value of x for ); printf(n which you want the value of y - ); scanf(%f,x); //... Calculation Processing Section for(i=0;in;i++) { nr=1; dr=1; for(j=0;jn;j++) { if(j!=i) { nr=nr*(x-ax[j]); dr=dr*(ax[i]–ax[j]); } y+=(nr/dr)*ay[i]; } }
  • 358. INTERPOLATION 345 //... Output Section printf(nn When x=%5.2f,y=%5.2f ,x,y); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch(); } //... Termination of Main Execution Thread 4.24.5 Output Enter the number of terms - 5 Enter the value in the form of x - Enter the value of x1- 5 Enter the value of x2 - 7 Enter the value of x3 - 11 Enter the value of x4 - 13 Enter the value of x5 - 17 Enter the value in the form of y - Enter the value of y1 - 150 Enter the value of y2 - 392 Enter the value of y3 - 1452 Enter the value of y4 - 2366 Enter the value of y5 - 5202 Enter the value of x for Which you want the value of y - 9.0 When x = 9.00, y = 810.00 Press Enter to Exit EXAMPLES Example 1. Using Lagrange’s interpolation formula, find y(10) from the following table: x 5 6 9 11 y 12 13 14 16 Sol. Here x0 = 5, x1 = 6, x2 = 9, x3 = 11 f(x0) = 12, f(x1) = 13, f(x2) = 14, f(x3) = 16
  • 359. 346 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Lagrange’s formula is f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 1 2 3 0 1 0 2 0 3 0 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 3 2 0 2 1 2 3 2 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 1 2 3 0 3 1 3 2 3 f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 6 9 11 5 6 5 9 5 11 12 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x 5 9 11 6 5 6 9 6 11 13 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 5 6 11 9 5 9 6 9 11 14 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x 5 6 9 11 5 11 6 11 9 16 = – 1 2 6 9 11 13 15 5 9 11 ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − − + − − − – 7 12 5 6 11 ( ) ( ) ( ) x x x − − − + 4 15 5 6 9 ( ) ( ) ( ) x x x − − − Putting x = 10, we get f(10) = – 1 2 10 6 10 9 10 11 13 15 10 5 10 9 10 11 ( ) ( ) ( ) ( ) ( ) ( ) − − − + − − − – 7 12 10 5 10 6 10 11 4 15 10 5 10 6 10 9 ( ) ( ) ( ) ( ) ( ) ( ) − − − + − − − = 14.66666667 Hence, y(10) = 14.66666667.
  • 360. INTERPOLATION 347 Example 2. Compute the value of f(x) for x = 2.5 from the following table: x: 1 2 3 4 f(x): 1 8 27 64 using Lagrange’s interpolation method. Sol. Here x0 = 1, x1 = 2, x2 = 3, x3 = 4 f(x0) = 1, f(x1) = 8, f(x2) = 27, f(x3) = 64 Lagrange’s formula is f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 1 2 3 0 1 0 2 0 3 0 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 3 2 0 2 1 2 3 2 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 1 2 3 0 3 1 3 2 3 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − − − − − + − − − − − − 2 3 4 1 2 1 3 1 4 1 1 3 4 2 1 2 3 2 4 8 + ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 1 2 4 3 1 3 2 3 4 (27) + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 1 2 3 4 1 4 2 4 3 64 = − − − − + − − − 1 6 2 3 4 4 1 3 4 ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x – 27 2 1 2 4 ( ) ( ) ( ) x x x − − − + 32 3 1 2 3 ( ) ( ) ( ) x x x − − − Given x = 2.5, we get f(2.5) = − 1 6 (2.5 – 2) (2.5 – 3) (2.5 – 4) + 4(2.5 – 1) (2.5 – 3) (2.5 – 4)
  • 361. 348 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES – 27 2 (2.5 – 1) (2.5 – 2) (2.5 – 4) + 32 3 (2.5 – 1) (2.5 – 2) (2.5 – 3) = 15.625 Hence, f(2.5) = 15.625. Example 3. Find the cubic Lagrange’s interpolating polynomial from the following data: x: 0 1 2 5 f(x): 2 3 12 147. Sol. Here x0 = 0, x1 = 1, x2 = 2, x3 = 5 f(x0) = 2, f(x1) = 3, f(x2) = 12, f(x3) = 147 Lagrange’s formula is f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 1 2 3 0 1 0 2 0 3 0 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 3 2 0 2 1 2 3 2 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 1 2 3 0 3 1 3 2 3 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − − − − − + − − − − − − 1 2 5 0 1 0 2 0 5 2 0 2 5 1 0 1 2 1 5 3 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 0 1 5 2 0 2 1 2 5 12 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 0 1 2 5 0 5 1 5 2 147 = − − − + − − 1 5 1 2 3 4 2 5 ( ) ( ) ( ) ( ) x x x x x – 2x(x – 1) (x – 5) + 49 20 1 2 x x x ( ) ( ) − −
  • 362. INTERPOLATION 349 = − − + − + − + 1 5 8 17 10 3 4 7 10 3 2 3 2 ( ) ( ) x x x x x x – 2(x3 – 6x2 + 5x) + 49 20 (x3 – 3x2 + 2x) ⇒ f(x) = x3 + x2 – x + 2 which is the required Lagrange’s interpolating polynomial. Example 4. Find the unique polynomial P(x) of degree 2 such that: P(1) = 1, P(3) = 27, P(4) = 64 Use the Lagrange method of interpolation. Sol. Here, x0 = 1, x1 = 3, x2 = 4 f(x0) = 1, f(x1) = 27, f(x2) = 64 Lagrange’s interpolation formula is P(x) = ( ) ( ) ( ) ( ) ( ) x x x x x x x x f x − − − − 1 2 0 1 0 2 0 + − − − − ( ) ( ) ( ) ( ) ( ) x x x x x x x x f x 0 2 1 0 1 2 1 + − − − − ( ) ( ) ( ) ( ) ( ) x x x x x x x x f x 0 1 2 0 2 1 2 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x − − − − + − − − − 3 4 1 3 1 4 1 1 4 3 1 3 4 27 + − − − − ( ) ( ) ( ) ( ) ( ) x x 1 3 4 1 4 3 64 = 1 6 7 12 27 2 5 4 64 3 4 3 2 2 2 ( ) ( ) ( ) x x x x x x − + − − + + − + = 8x2 – 19x + 12 Hence the required unique polynomial is P(x) = 8x2 – 19x + 12. Example 5. The function y = f(x) is given at the points (7, 3), (8, 1), (9, 1) and (10, 9). Find the value of y for x = 9.5 using Lagrange’s interpolation formula. Sol. We are given x: 7 8 9 10 f(x): 3 1 1 9 Here, x0 = 7, x1 = 8, x2 = 9, x3 = 10 f(x0) = 3, f(x1) = 1, f(x2) = 1, f(x3) = 9
  • 363. 350 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Lagrange’s interpolation formula is f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 1 2 3 0 1 0 2 0 3 0 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 3 2 0 2 1 2 3 2 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 2 3 0 3 1 3 2 3 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − − − − − + − − − − − − 8 9 10 7 8 7 9 7 10 3 7 9 10 8 7 8 9 8 10 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 7 8 10 9 7 9 8 9 10 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x − − − − − − 7 8 9 10 7 10 8 10 9 9 = − − − − + − − − 1 2 8 9 10 1 2 7 9 10 ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x – 1 2 7 8 10 ( ) ( ) ( ) x x x − − − + 3 2 7 8 9 ( ) ( ) ( ) x x x − − − (58) Given x = 9.5 in eqn. (58), we get f(9.5) = − − − − + − − − 1 2 9 5 8 9 5 9 9 5 10 1 2 9 5 7 9 5 9 9 5 10 ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) – 1 2 9 5 7 9 5 8 9 5 10 3 2 9 5 7 9 5 8 9 5 9 ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) − − − + − − − = 3.625. Example 6. Use Lagrange’s interpolation formula to fit a polynomial to the data: x: – 1 0 2 3 ux: – 8 3 1 12 Hence or otherwise find the value of u1.
  • 364. INTERPOLATION 351 Sol. Here, x0 = – 1, x1 = 0, x2 = 2, x3 = 3 f(x0) = – 8, f(x1) = 3, f(x2) = 1, f(x3) = 12 Lagrange’s interpolation formula is f(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 1 2 3 0 1 0 2 0 3 0 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x − − − − − − 0 1 3 2 0 2 1 2 3 2 + − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x x x f x 0 1 2 3 0 3 1 3 2 3 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − − − − − − − − − + + − − + − − 0 2 3 1 0 1 2 1 3 8 1 2 3 0 1 0 2 0 3 3 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x + − − + − − 1 0 3 2 1 2 0 2 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x + − − + − − 1 0 2 3 1 3 0 3 2 12 = 2 3 2 3 1 2 1 2 3 x x x x x x ( ) ( ) ( ) ( ) ( ) − − + + − − – 1 6 1 3 1 2 ( ) ( ) ( ) ( ) x x x x x x + − + + − = 2 3 5 6 1 2 4 6 3 2 3 2 ( ) ( ) x x x x x x − + + − + + – 1 6 2 3 2 3 2 3 2 ( ) ( ) x x x x x x − − + − − ⇒ f(x) = 2x3 – 6x2 + 3x + 3 Hence, ux = 2x3 – 6x2 + 3x + 3 (59) Given x = 1 in (59), we get u1 = 2(1)3 – 6(1)2 + 3(1) + 3 = 2.
  • 365. 352 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 7. By means of Lagrange’s formula, prove that (i) y0 = 1 2 (y y ) 1 8 1 2 (y y ) 1 2 (y y ) 1 1 3 1 1 3 + − − − − L NM O QP − − − (ii) y 0.05 (y y ) 0.3 (y y ) 0.75 (y y ) 3 0 6 1 5 2 4 = + − + + + (iii) y1 = y3 – 0.3 (y5 – y– 3 ) + 0.2 (y–3 – y– 5 ). Sol. (i) For the arguments – 3, – 1, 1, 3, the Lagrange’s formula is yx = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x y x x x y + − − − + − − − − + + − − − + − − − − − − 1 1 3 3 1 3 1 3 3 3 1 3 1 3 1 1 1 3 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) x x x + + − + + − 3 1 3 1 3 1 1 1 3 y1 + ( ) ( ) ( ) ( ) ( ) ( ) x x x y + + − + + − 3 1 1 3 3 3 1 3 1 3 = ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x y x x x y + − − − + + − − − − 1 1 3 48 3 1 3 16 3 1 + ( ) ( ) ( ) ( ) x x x y + + − − 3 1 3 16 1 + ( ) ( ) ( ) x x x y + + − 3 1 1 48 3 (60) Given x = 0 in (60), we get y0 = − + + − − − 1 16 9 16 9 16 1 16 3 1 1 3 y y y y = 1 2 1 8 1 2 1 2 1 1 3 1 1 3 ( ) ( ) ( ) y y y y y y + − − − − L NM O QP − − − (ii) For the arguments 0, 1, 2, 4, 5, 6, the Lagrange’s formula is yx = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y − − − − − − − − − − 1 2 4 5 6 0 1 0 2 0 4 0 5 0 6 0 + − − − − − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y 0 2 4 5 6 1 0 1 2 1 4 1 5 1 6 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y − − − − − − − − − − 0 1 4 5 6 2 0 2 1 2 4 2 5 2 6 2
  • 366. INTERPOLATION 353 + − − − − − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y 0 1 2 5 6 4 0 4 1 4 2 4 5 4 6 4 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y − − − − − − − − − − 0 1 2 4 6 5 0 5 1 5 2 5 4 5 6 5 + − − − − − − − − − − ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x y 0 1 2 4 5 6 0 6 1 6 2 6 4 6 5 6 (61) Given x = 3 in (61), we get y3 = 0.05 y0 – 0.3 y1 + 0.75 y2 + 0.75 y4 – 0.3 y5 + 0.05 y6 = 0.05 (y0 + y6) – 0.3(y1 + y5) + 0.75 (y2 + y4). (iii) For the arguments – 5, – 3, 3, 5, the Lagrange’s formula is yx = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x y x x x y + − − − + − − − − + + − − − + − − − − − − 3 3 5 5 3 5 3 5 5 5 3 5 3 5 3 3 3 5 5 3 + ( ) ( ) ( ) ( ) ( ) ( ) x x x y + + − + + − 5 3 5 3 5 3 3 3 5 3 + ( ) ( ) ( ) ( ) ( ) ( ) x x x y + + − + + − 5 3 3 5 5 5 3 5 3 5 (62) Given x = 1 in eqn. (62), we get y1 = – 0.2 y– 5 + 0.5y–3 + y3 – 0.3 y5 = y3 – 0.3 (y5 – y–3) + 0.2 (y–3 – y–5). Example 8. If four equidistant values u–1, u0, u1, and u2 are given, a value is interpolated by Lagrange’s formula, show that it may be written in the form ux = yu0 + xu1 + y(y 1) 3 ! 2 − Δ2u–1 + x(x 1) 3 ! 2 − Δ2u0 where x + y = 1. Sol. Δ2u1 = (E – 1)2u–1 = (E2 – 2E + 1) u–1 = u1 – 2u0 + u–1 Δ2u0 = (E2 – 2E + 1) u0 = u2 – 2u1 + u0 R.H.S. = (1 – x) u0 + xu1 + ( ) {( ) } ! 1 1 1 3 2 − − − x x (u1 – 2u0 + u–1) + x x u u u ( ) ! ( ) 2 2 1 0 1 3 2 − − + |where y = 1 – x = − − − + − − + − + − − x x x u x x x u x x x u ( ) ( ) ( ) ( ) ( ) ( ) ( ) 1 2 6 2 1 1 2 1 2 2 1 0 1 + ( ) ( ) x x x u + − 1 1 6 2 (63)
  • 367. 354 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Applying Lagrange’s formula for the arguments – 1, 0 , 1 and 2. ux = x x x u x x x u ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) − − − − − + + − − − − − 1 2 1 2 3 1 1 2 1 1 2 1 0 + ( ) ( ) ( ) ( ) ( ) x x x u + − − 1 2 2 1 1 1 + ( ) ( ) ( ) ( ) ( ) x x x u + − 1 1 3 2 1 2 = − − − + − − + − + − − x x x u x x x u x x x u ( ) ( ) ( ) ( ) ( ) ( ) ( ) 1 2 6 2 1 1 2 1 2 2 1 0 1 + ( ) ( ) x x x u + − 1 1 6 2 (64) From (63) and (64), we observe that R.H.S. = L.H.S. Hence the result. Example 9. Prove that Lagrange’s formula can be expressed in the form P (x) 1 x x ... ... x f(x ) 1 x x ... ... x f(x ) 1 x x ... ... x ... ... ... ... ... ... ... f(x ) 1 x x ... ... x n 2 n 0 0 0 2 0 n 1 1 1 2 1 n n n n 2 n n = 0 where Pn(x) = f(x). Sol. Let Pn(x) = a0 + a1x + a2x2 + ... + anxn Given x = x0, x1, ..., xn, and Pn(xi) = f(xi), i = 0, 1, 2, ..., n f(x0) = a0 + a1x0 + a2x0 2 + ... + anx0 n f(x1) = a0 + a1x1 + a2x1 2 + ... + anx1 n ... ... ... ... ... ... f(xn) = a0 + a1xn + a2xn 2 + ... + anxn n ... (n + 2) Eliminating a0, a1, a2, ......, an from these equations, we get − − − − P x x x x f x x x x f x x x x f x x x x n n n n n n n n n ( ) ... ... ( ) ... ... ( ) 1 ... ... ... ... ... ... ... ... ... ( ) ... ... 1 1 1 2 0 0 0 2 0 1 1 1 2 1 2 = 0
  • 368. INTERPOLATION 355 or P x x x x f x x x x f x x x x f x x x x n n n n n n n n n ( ) ... ... ( ) ... ... ( ) 1 ... ... ... ... ... ... ... ... ... ( ) ... ... 1 1 1 2 0 0 0 2 0 1 1 1 2 1 2 = 0 ASSIGNMENT 4.11 1. Apply Lagrange’s formula to find f(5) and f(6) given that f(2) = 4, f(1) = 2, f(3) = 8, f(7) = 128 Explain why the result differs from those obtained by completing the series of powers of 2? 2. Values of f(x) for values of x are given as f(1) = 4, f(2) = 5, f(7) = 5, f(8) = 4 Find f(6) and also the value of x for which f(x) is maximum or minimum. 3. Find by Lagrange’s formula, the value of (i) u5 if u0 = 1, u3 = 19, u4 = 49, u6 = 181 (ii) u4 if u3 = 16, u5 = 36, u7 = 64, u8 = 81 and u9 = 100. 4. Using Lagrange’s formula, find the values of (i) y5 if y1 = 4, y3 = 120, y4 = 340, y5 = 2544 (ii) y0 if y–30 = 30, y–12 = 34, y3 = 38, y18 = 42. 5. Find the value of tan 33° by Lagrange’s formula if tan 30° = 0.5774, tan 32° = 0.6249, tan 35° = 0.7002, tan 38° = 0.7813. 6. Use Lagrange’s formula to find f(6) from the following table: x: 2 5 7 10 12 f(x): 18 180 448 1210 2028. 7. Apply Lagrange’s formula to find f(15), if x: 10 12 14 16 18 20 f(x): 2420 1942 1497 1109 790 540. 8. If y0, y1, ..., y9 are consecutive terms of a series, prove that y5 = 1 70 [56(y4 + y6) – 28(y3 + y7) + 8(y2 + y8) – (y1 + y9)]
  • 369. 356 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 9. Using the following table, find f(x) as a polynomial in x: x: – 1 0 3 6 7 f(x): 3 – 6 39 822 1611. 10. If y(1) = – 3, y(3) = 9, y(4) = 30, and y(6) = 132, find the four-point Lagrange interpolation polynomial that takes the same values as the function y at the given points. 11. Given the table of values x: 150 152 154 156 y = x : 12.247 12.329 12.410 12.490 Evaluate 155 using Lagrange’s interpolation formula. 12. Applying Lagrange’s formula, find a cubic polynomial which approximates the follow- ing data: x: – 2 – 1 2 3 y(x): – 12 – 8 3 5. 13. Given the table of values x: 50 52 54 56 x 3 : 3.684 3.732 3.779 3.825 Use Lagrange’s formula to find x when x 3 = 3.756. 14. Find the equation of the cubic curve that passes through the points (4, – 43), (7, 83), (9, 327) and (12, 1053). 15. Values of f(x) are given at a, b, and c. Show that the maximum is obtained by x = f a b c f b c a f c a b f a b c f b c a f c a b ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) 2 2 2 2 2 2 − + − + − − + − + − . 16. The following table gives the viscosity of an oil as a function of temperature. Use Lagrange’s formula to find the viscosity of oil at a temperature of 140°. Temp° : 110 130 160 190 Viscosity: 10.8 8.1 5.5 4.8 17. Certain corresponding values of x and log10x are given below: x: 300 304 305 307 log10 x: 2.4771 2.4829 2.4843 2.4871 Find log10 310 by Lagrange’s formula. 18. The following table gives the normal weights of babies during the first 12 months of life: Age in months: 0 2 5 8 10 12 Weight in lbs: 7.5 10.25 15 16 18 21
  • 370. INTERPOLATION 357 19. Given f(0) = – 18, f(1) = 0, f(3) = 0, f(5) = – 248, f(6) = 0, f(9) = 13104; find f(x). 20. (i) Determine by Lagrange’s formula, the percentage number of criminals under 35 years: Age % number of criminals under 25 years 52 under 30 years 67.3 under 40 years 84.1 under 50 years 94.4 (ii) Find a Lagrange’s interpolating polynomial for the data given below: x0 = 1, x1 = 2.5, x2 = 4 and x3 = 5.5 f(x0) = 4, f(x1) = 7.5, f(x2) = 13 and f(x3) = 17.5 Also, find the value of f(5). 4.25 ERROR IN LAGRANGE’S INTERPOLATION FORMULA Remainder, y(x) – Ln(x) = Rn(x) = Πn x n + + 1 1 ( ) ( ) ! y(n+1) (ξ) , a ξ b where Lagrange’s formula is for the class of functions having continuous derivatives of order upto (n + 1) on [a, b]. Quantity EL = max. [ , ] a b | Rn(x) | may be taken as an estimate of error. Let us assume | y(n+1) (ξ) | ≤ Mn+1, a ≤ ξ ≤ b then, EL ≤ Mn n + + 1 1 ( ) ! max. [ , ] a b | Πn+1(x) |. EXAMPLES Example 1. Show that the truncation error of quadratic interpolation in an equidistant table is bounded by h 9 3 3 max | f ″′(ξ) | where h is the step size and f is the tabulated function.
  • 371. 358 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Let xi–1, xi, xi+1 denote three consecutive equispaced points with step size h. The truncation error of the quadratic Lagrange interpolation is bounded by | E2(f; x) | ≤ M3 6 max | (x – xi–1)(x – xi)(x – xi+1) | where xi–1 ≤ x ≤ xi+1 and M3 = max a x b ≤ ≤ | f ″′(x) | Substitute t = x x h i − then, x – xi–1 = x – (xi – h) = x – xi + h = th + h = (t + 1)h x – xi+1 = x – (xi + h) = x – xi – h = th – h = (t – 1)h and (x – xi–1)(x – xi)(x – xi+1) = (t + 1) t(t – 1)h3 = t(t2 – 1)h3 = g(t) Setting g ′(t) = 0, we get 3t2 – 1 = 0 ⇒ t = ± 1 3 . For both these values of t, we obtain max | (x – xi–1)(x – xi)(x – xi+1) | = h3 max − ≤ ≤ 1 1 t | t(t2 – 1) | = 2 3 3 3 h Hence, the truncation error of the quadratic interpolation is bounded by | E2(f; x) | ≤ h3 3 9 3 M or, | E2(f; x) | ≤ h3 9 3 max | f ″′(ξ) |. Example 2. Determine the step size that can be used in the tabulation of f(x) = sin x in the interval 0, 4 π L NM O QP at equally spaced nodal points so that the truncation error of the quadratic interpolation is less than 5 × 10–8. Sol. From Example 1, we have | E2(f; x) | ≤ h3 9 3 M3 For f(x) = sin x, we get f ″′(x) = – cos x and M3 = max |cos | / 0 4 ≤ ≤ x x π = 1
  • 372. INTERPOLATION 359 Hence the step size h is given by h3 9 3 ≤ 5 × 10–8 or h ≈ 0.009 Example 3. Using Lagrange’s interpolation formula, find the value of sin π 6 F HG I KJ from the following data: x: 0 π/4 π/2 y = sin x: 0 0.70711 1.0 Also estimate the error in the solution. Sol. sin π 6 F HG I KJ = π π π π π π 6 0 6 2 4 0 4 2 − F HG I KJ − F HG I KJ − F HG I KJ − F HG I KJ (0.70711) + π π π π π π 6 0 6 4 2 0 2 4 − F HG I KJ − F HG I KJ − F HG I KJ − F HG I KJ (1) = 8 9 (0.70711) – 1 9 = 4 65688 9 . = 0.51743 Now, y(x) = sin x, y′(x) = cos x, y″(x) = – sin x, y′″(x) = – cos x Hence, | y′″ (ξ) | 1 when x = π/6. | Rn(x) | ≤ π π π π π 6 0 6 4 6 2 3 − F HG I KJ − F HG I KJ − F HG I KJ ! = 0.02392 which agrees with the actual error in problem. 4.26 EXPRESSION OF RATIONAL FUNCTION AS A SUM OF PARTIAL FRACTIONS Let f(x) = 3 1 1 2 3 2 x x x x x + + − − − ( )( )( ) Consider φ(x) = 3x2 + x + 1 and tabulate its values for x = 1, 2, 3, we get x: 1 2 3 3x2 + x + 1: 5 15 31
  • 373. 360 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Using Lagrange’s interpolation formula, we get f(x) = ( )( ) ( )( ) x x − − − − 2 3 1 2 1 3 (5) + ( )( ) x x − − − 1 3 1 (15) + ( )( ) x x − − 1 2 2 (31) = 5 2 (x – 2)(x – 3) – 15 (x – 1)(x – 3) + 31 2 (x – 1)(x – 2) = 5 2 1 ( ) x − – 15 2 x − + 31 2 3 ( ) x − . 4.27 INVERSE INTERPOLATION The process of estimating the value of x for the value of y not in the table is called inverse interpolation. When values of x are unevenly spaced, Lagrange’s method is used by interchanging x and y. EXAMPLES Example 1. Values of elliptic integral F(θ) = 2 0 θ z d 1 cos2 θ θ + are given below: θ: 21° 23° 25° F(θ): 0.3706 0.4068 0.4433 Find θ for which F(θ) = 0.3887. Sol. By inverse interpolation formula θ = (F F )(F F ) (F F )(F F ) 1 2 0 1 0 2 − − − − θ0 + (F F )(F F ) (F F )(F F ) 0 2 1 0 1 2 − − − − θ1 + (F F )(F F ) (F F )(F F ) 0 1 2 0 2 1 − − − − θ2 = ( . ) ( . ) ( . )( . ) 0 0 4068 0 0 4433 0 0 4068 0 0 4433 .3887 .3887 .3706 .3706 − − − − (.3706) + ... + ... = 7.884 + 17.20 – 3.087 = 22°. Example 2. From the given table: x: 20 25 30 35 y(x): 0.342 0.423 0.5 0.65 Find the value of x for y(x) = 0.390.
  • 374. INTERPOLATION 361 Sol. By inverse interpolation formula, x = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) y y y y y y y y y y y y x y y y y y y y y y y y y x − − − − − − + − − − − − − 1 2 3 0 1 0 2 0 3 0 0 2 3 1 0 1 2 1 3 1 + ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) y y y y y y y y y y y y x y y y y y y y y y y y y x − − − − − − + − − − − − − 0 1 3 2 0 2 1 2 3 2 0 1 2 3 0 3 1 3 2 3 = (. . ) (. . ) (. . ) (. . ) (. . ) (. . ) ( ) 39 423 39 5 39 65 342 423 342 5 342 65 20 − − − − − − + (. . ) (. . ) (. . ) (. . ) )(. . ) (. . ) ( ) 39 342 39 5 39 65 423 342 423 5 423 65 25 − − − − − − + (. . ) (. . ) (. . ) (. . ) (. . ) (. . ) ( ) 39 342 39 423 39 65 5 342 5 423 5 65 30 − − − − − − + (. . ) (. . ) (. . ) (. . ) (. . ) (. . ) ( ) 39 342 39 423 39 5 65 342 65 423 65 5 35 − − − − − − = 22.84057797. 4.28 DIVIDED DIFFERENCES Lagrange’s interpolation formula has the disadvantage that if another interpolation point were added, the interpolation coefficient will have to be recomputed. We therefore seek an interpolation polynomial which has the property that a polynomial of higher degree may be derived from it by simply adding new terms. Newton’s general interpolation formula is one such formula and it employs divided differences. If (x0, y0), (x1, y1), (x2, y2) ...... be given points then the first divided difference for the arguments x0, x1 is defined by Δ | x1 y0 = [x0, x1] = y y x x 1 0 1 0 − − Similarly, [x1, x2] = y y x x 2 1 2 1 − − and so on. The second divided difference for x0, x1, x2 is defined as Δ | , 2 1 2 x x y0 = [x0, x1, x2] = [ , ] [ , ] x x x x x x 1 2 0 1 2 0 − −
  • 375. 362 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Third divided difference for x0, x1, x2, x3 is defined as [x0, x1, x2, x3] = [ , , ] [ , , ] x x x x x x x x 1 2 3 0 1 2 3 0 − − and so on. 4.29 PROPERTIES OF DIVIDED DIFFERENCES 1. The divided differences are symmetrical in their arguments, i.e., independent of the order of arguments. [x0, x1] = y x x 1 1 0 − + y x x 0 0 1 − = [x1, x0] Also, [x0, x1, x2] = y x x x x 0 0 1 0 2 ( )( ) − − + y x x x x 1 1 0 1 2 ( )( ) − − + y x x x x 2 2 0 2 1 ( )( ) − − = [x2, x0, x1] or [x1, x2, x0] 2. The nth divided differences of a polynomial of nth degree are constant. Let the arguments be equally spaced so that x1 – x0 = x2 – x1 = ..... = xn – xn–1 = h then, [x0, x1] = y y x x 1 0 1 0 − − = Δy h 0 [x0, x1, x2] = [ , ] [ , ] ( ) x x x x x x 1 2 0 1 2 0 − − = 1 2h Δ Δ y h y h 1 0 − F HG I KJ = 1 2 1 2 ! . h (Δ2 y0) In general, [x0, x1, x2, ......, xn] = 1 n ! . 1 hn Δny0 If tabulated function is a nth degree polynomial. ∴ Δny0 = constant ∴ nth divided differences will also be constant.
  • 376. INTERPOLATION 363 4.30 NEWTON’S GENERAL INTERPOLATION FORMULA O R NEWTON’S DIVIDED DIFFERENCE INTERPOLATION FORMULA Let y0, y1, ......, yn be the values of y = f(x) corresponding to the arguments x0, x1, ......, xn then from the definition of divided differences, we have [x, x0] = y y x x − − 0 0 so that, y = y0 + (x – x0) [x, x0] (65) Again, [x, x0, x1] = [ , ] [ , ] x x x x x x 0 0 1 1 − − which gives, [x, x0] = [x0, x1] + (x – x1) [x, x0, x1] (66) From (65) and (66), y = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x, x0, x1] (67) Also [x, x0, x1, x2] = [ , , ] [ , , ] x x x x x x x x 0 1 0 1 2 2 − − which gives [x, x0, x1] = [x0, x1, x2] + (x – x2) [x, x0, x1, x2] (68) From (67) and (68), y = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x0, x1, x2] + (x – x0) (x – x1) (x – x2) [x, x0, x1, x2] Proceeding in this manner, we get y = f(x) = y0 + (x – x0) [x0, x1] + (x – x0) (x – x1) [x0, x1, x2] + (x – x0) (x – x1) (x – x2) [x0, x1, x2, x3] + ..... + (x – x0) (x – x1) (x – x2) ..... (x – xn–1) [x0, x1, x2, x3, ......, xn] + (x – x0) (x – x1) (x – x2) ..... (x – xn) [x, x0, x1, x2, ......, xn] which is called Newton’s general interpolation formula with divided differences, the last term being the remainder term after (n + 1) terms.
  • 377. 364 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Newton’s divided difference formula can also be written as y = y0 + (x – x0) Δ | y0 + (x – x0) (x – x1) Δ | 2y0 + (x – x0) (x – x1) (x – x2) Δ | 3y0 + (x – x0) (x – x1) (x – x2) (x – x3) Δ | 4y0 + ..... + (x – x0) (x – x1) ..... (x – xn–1) Δ | ny0 4.31 RELATION BETWEEN DIVIDED DIFFERENCES AND ORDINARY DIFFERENCES Let the arguments x0, x1, x2, ....., xn be equally spaced such that x1 – x0 = x2 – x1 = ... = xn – xn–1 = h ∴ x1 = x0 + h x2 = x0 + 2h ......... xn = x0 + nh Now Δ | x1 f(x0) = f x f x x x ( ) ( ) 1 0 1 0 − − = f x h f x h ( ) ( ) 0 0 + − = Δ f x h ( ) 0 (69) | Δ2 1 2 x x f(x0) = 1 2 0 x x − [f(x1, x2) – f(x0, x1)] = 1 2 0 x x − f x f x x x f x f x x x ( ) ( ) ( ) ( ) 2 1 2 1 1 0 1 0 − − − − − L NM O QP = 1 2 2 0 0 0 0 h f x h f x h h f x h f x h ( ) ( ) ( ) ( ) + − + − + − L NM O QP = 1 2 2 2 2 0 0 0 h f x h f x h f x [ ( ) ( ) ( )] + − + + = Δ2 0 2 2 f x h ( ) ! . (70)
  • 378. INTERPOLATION 365 | , , Δ3 1 2 3 x x x f(x0) = 1 2 0 x x − [f(x1, x2, x3) – f(x0, x1, x2)] = 1 3h Δ Δ 2 1 2 2 0 2 2 2 f x h f x h ( ) ( ) − L NMM O QPP = Δ Δ 2 1 2 0 3 6 f x f x h ( ) ( ) − [From (69)] = Δ3 0 3 3 f x h ( ) ! ... ... ... Δ | ,....., n x xn 1 f(x0) = Δn n f x n h ( ) ! 0 . 4.32 MERITS AND DEMERITS OF LAGRANGE’S FORMULA 1. The formula is simple and easy to remember. 2. There is no need to construct the divided difference table and we can directly interpolate the unknown value with the help of given observations. 3. The calculations in the formula are more complicated than in the divided difference formula. 4. The application of the formula is not speedy 5. There is always a chance of commiting some error due to a number of (+)ve and (–)ve sign in the denominator and numerator of each term. 6. The calculations provide no check whether the functional values used are taken correctly or not, whereas the differences used in a difference formula provide a check on the functional values. EXAMPLES Example 1. Construct a divided difference table for the following: x: 1 2 4 7 12 f(x): 22 30 82 106 216.
  • 379. 366 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) Δ | 4f(x) 1 22 30 22 2 1 − − = 8 2 30 26 8 4 1 − − = 6 82 30 4 2 − − = 26 − − − 3 6 6 7 1 . = – 1.6 4 82 8 26 7 2 − − = – 3.6 0 6 12 1 .535 1. + − = 0.194 106 82 7 4 − − = 8 175 3 6 12 2 . . + − = 0.535 7 106 22 8 12 4 − − = 1.75 216 106 5 − = 22 12 216 Example 2. (i) Find the third divided difference with arguments 2, 4, 9, 10 of the function f(x) = x3 – 2x. (ii) If f(x) = 1 x2 , find the first divided differences f(a, b), f(a, b, c), f(a, b, c, d). (iii) If f(x) = g(x) h(x), prove that f(x1, x2) = g(x1) h(x1, x2) + g(x1, x2) h (x2). Sol. (i) x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) 2 4 56 4 4 2 26 − − = 4 56 131 26 9 2 15 − − = 711 56 9 4 131 − − = 23 15 10 2 1 − − = 9 711 269 131 10 4 23 − − = 980 711 10 9 269 − − = 10 980 Hence, the third divided difference is 1.
  • 380. INTERPOLATION 367 (ii) x f(x) = 1 x2 Δ | f(x) Δ | 2f(x) Δ | 3f(x) a 1 2 a 1 1 2 2 b a b a − F HG I KJ − = – a b a b + F HG I KJ 2 2 b 1 2 b ab bc ca a b c + + 2 2 2 − + F HG I KJ b c b c 2 2 – abc acd abd bcd a b c d + + + F HG I KJ 2 2 2 2 c 1 2 c bc cd db b c d + + 2 2 2 − + F HG I KJ c d c d 2 2 d 1 2 d From the above divided difference table, we observe that the first divided differences, f(a, b) = – a b a b + F HG I KJ 2 2 f(a, b, c) = ab bc ca a b c + + 2 2 2 and f(a, b, c, d) = – abc acd abd bcd a b c d + + + F HG I KJ 2 2 2 2 (iii) R.H.S. = g(x1) h x h x x x g x g x x x h x ( ) ( ) ( ) ( ) ( ) 2 1 2 1 2 1 2 1 2 − − + − − = 1 2 1 x x − [{g(x1) h(x2) – g(x1)h(x1)} + {g(x2) h(x2) – g(x1) h(x2)}] = g x h x g x h x x x ( ) ( ) ( ) ( ) 2 2 1 1 2 1 − − = Δ | x2 g(x1) h(x1) = Δ | x2 f(x1) = f(x1, x2) = L.H.S. Hence the result.
  • 381. 368 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 3. (i) Prove that Δ | bcd 3 1 a 1 abcd F HG I KJ = − (ii) Show that the nth divided differences [x0, x1, ....., xn] for ux = 1 x is ( 1) x x ..... x n 0 1 n − L NM O QP. Sol. (i) x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) a 1 a 1 1 b a b a − − = – 1 ba b 1 b (– 1)2 1 abc 1 1 c b c b − − = – 1 bc (– 1)3 1 abcd c 1 c (– 1)2 1 bdc 1 1 d c d c − − = – 1 dc d 1 d From the table, we observe that Δ | 3 bcd 1 a F HG I KJ = – 1 abcd . (71) (ii) From (71), we see that Δ | 3 bcd 1 a F HG I KJ = – 1 abcd = (– 1)3 f(a, b, c, d) ∴ In general, Δ | , , ....., n x x xn x 0 1 1 0 F HG I KJ = (– 1)n f (x0, x1, x2, ....., xn) = ( ) ..... − L NM O QP 1 0 1 2 n n x x x x .
  • 382. INTERPOLATION 369 Example 4. Using Newton’s divided difference formula, find a polynomial function satisfying the following data: x: – 4 – 1 0 2 5 f(x): 1245 33 5 9 1335 Hence find f(1). Sol. The divided difference table is: x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) Δ | 4f(x) – 4 1245 – 404 – 1 33 94 – 28 – 14 0 5 10 3 2 13 2 9 88 442 5 1335 Applying Newton’s divided difference formula f(x) = 1245 + (x + 4) (– 404) + (x + 4) (x + 1) 94 + (x + 4) (x + 1) (x – 0) (– 14) + (x + 4)(x + 1)x(x – 2)(3) = 3x4 – 5x3 + 6x2 – 14x + 5 Hence, f(1) = 3 – 5 + 6 – 14 + 5 = – 5. Example 5. By means of Newton’s divided difference formula, find the values of f(8) and f(15) from the following table: x: 4 5 7 10 11 13 f(x): 48 100 294 900 1210 2028. Sol. Newton’s divided difference formula, using the arguments 4, 5, 7, 10, 11, and 13 is f(x) = f(4) + (x – 4) Δ | 5 f(4) + (x – 4)(x – 5) Δ | , 5 7 f(4) + (x – 4)(x – 5)(x – 7) Δ | , 3 5 7, 10 f(4) + (x – 4)(x – 5)(x – 7)(x – 10) Δ | , , 4 5 7, 10 11 f(4) + (x – 4)(x – 5)(x – 7) (x – 10)(x – 11) Δ | , , , 4 5 7, 10 11 13 f(4) (72)
  • 383. 370 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The divided difference table is as follows: x f(x) Δ | f(x) Δ | 2 f(x) Δ | 3f(x) Δ | 4f(x) 4 48 100 48 5 4 − − = 52 5 100 97 52 7 4 − − = 15 294 100 7 5 97 − − = 21 15 10 4 − − = 1 7 294 202 97 10 5 21 − − = 0 900 294 10 7 202 − − = 27 21 11 5 1 − − = 10 900 310 202 11 7 27 − − = 0 1210 900 11 10 310 − − = 33 27 13 7 − − = 1 11 1210 409 310 13 10 − − = 33 2028 1210 13 11 409 − − = 13 2028 Substituting the values of the divided differences in (72), f(x) = 48 + (x – 4) × 52 + (x – 4)(x – 5) × 15 + (x – 5)(x – 4)(x – 7) × 1 = 48 + 52(x – 4) + 15(x – 4)(x – 5) + (x – 4)(x – 5)(x – 7) Putting x = 8 and 15 f(8) = 48 + 52 × 4 + 15 × 4 × 3 + 4 × 3 × 1 = 48 + 208 + 180 + 12 = 448 f(15) = 48 + 52 × 11 + 15 × 11 × 10 + 11 × 10 × 8 = 48 + 572 + 1650 + 880 = 3150. Example 6. Given the following table, find f(x) as a polynomial in powers of (x – 5) x: 0 2 3 4 7 9 f(x): 4 26 58 112 466 922.
  • 384. INTERPOLATION 371 Sol. The divided difference table is: x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) 0 4 11 2 26 7 32 1 3 58 11 54 1 4 112 16 118 1 7 466 22 228 9 922 By Newton’s divided difference formula, we get f(x) = 4 + (x – 0)(11) + (x – 0)(x – 2)7 + (x – 0)(x – 2)(x – 3) 1 = x3 + 2x2 + 3x + 4 In order to express it in power of (x – 5), we use synthetic division, as 5 1 2 3 4 5 35 190 5 1 7 38 194 5 60 5 1 12 98 5 1 17 ∴ 2x2 + x3 + 3x + 4 = (x – 5)3 + 17(x – 5)2 + 98 (x – 5) + 194. Example 7. Given log10 654 = 2.8156, log10 658 = 2.8182, log10 659 = 2.8189 and log10 661 = 2.8202, find by the divided difference formula the value of log10 656. Sol. For the arguments 654, 658, 659, and 661, the divided difference formula is f(x) = f(654) + (x – 654) Δ | 658 f(654) + (x – 655) (x – 658) Δ | , 658 659 2 f(654) + (x – 654) (x – 658) (x – 659) Δ | , , 658 659 661 3 f(654) (73)
  • 385. 372 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The divided difference table is as follows: x 105 f(x) 105 Δ | f(x) 105 Δ | 2f(x) 105 Δ | 3 f(x) 654 281560 260 4 = 65 658 281820 70 65 5 − = 1 70 1 = 70 − − 166 1 7 . = – 0.38 659 281890 65 70 3 − = – 1.66 130 2 = 65 661 282020 From (73), 105f(x) = 281560 + (x – 654) (65) + (x – 654) (x – 658) (1) + (x – 654) (x – 658) (x – 659) (0.38) Putting x = 656, we get 105 f(656) = 281560 + (2) (65) + (2) (– 2) (1) + (2) (– 2) (– 3) (.38) = 281690.56 ∴ f(656) = 2.8169056 Hence, log10 656 = 2.8169056. Example 8. Find f ′(10) from the following data: x: 3 5 11 27 34 f(x): – 13 23 899 17315 35606.
  • 386. INTERPOLATION 373 Sol. The divided difference table is: x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) Δ | 4f(x) 3 – 13 18 5 23 16 146 1 11 899 40 0 1026 1 27 17315 69 2613 34 35606 By Newton’s divided difference formula, f(x) = – 13 + (x – 3) 18 + (x – 3)(x – 5)16 + (x – 3)(x – 5)(x – 11)1 ∴ f ′(x) = 3x2 – 6x – 7 Put x = 10, f ′(10) = 3(10)2 – 6(10) – 7 = 233. Example 9. Given that log10 2 = 0.3010, log10 3 = 0.4771, log10 7 = 0.8451, find the value of log10 33. Sol. log 30 = 1.4771, log 32 = 5 log 2 = 5 × 0.3010 = 1.5050 log 36 = 2 (log 2 + log 3) = 2 × (0.3010 + 0.4771) = 1.5562 log 35 = log 70 2 = log 70 – log 2 = 1.8451 – 0.3010 = 1.5441. The divided difference table is as follows: x 104 log10 x 104 Δ | log10 x 104 Δ | 2 log10 x 104Δ | 3log10 x 30 14771 279 2 139 5 = . 32 15050 – 9 2 5 184 . . = − 391 3 130 3 = . – 0 48 6 0 08 . . = − 35 15441 – 9 3 7 2 32 . . = − 121 1 = 121 36 15562
  • 387. 374 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Applying Newton’s divided difference formula, we get 104 log10 x = 14771 + (x – 30) (139.5) + (x – 30)(x – 32) (– 1.84) + (x – 30)(x – 32)(x – 35)(– 0.08) Putting x = 33 104 log10 33 = 14771 + 3 × 139.5 + 3 × 1 × (– 1.84) + 3 × 1 × (– 2)(– 0.08) = 14771 + 418.5 – 5.52 + 0.48 = 15184.46 ∴ log10 33 = 1.5184. Example 10. Find approximately the real root of the equation x3 – 2x – 5 = 0. Sol. Let f(x) = x3 – 2x – 5. The real root of f(x) = 0 lies between 2 and 2.1. ∴ Values of f(x) at x = 1.9, 2, 2.1, 2.2 are – 1.941, – 1.000, 0.061, 1.248, respectively. Let x: – 1.941 – 1.000 0.061 1.248 ux: 1.9 2.0 2.1 2.2 We have to find ux at u = 0. The divided difference table is: x ux Δ | ux Δ | 2 ux Δ | 3 ux – 1.941 1.9 0.1062699 – 1.000 2.0 – 0.0060035 0.0942507 0.0004869 0.061 2.1 – 0.0044505 0.0842459 1.248 2.2 Applying the Newton-divided difference formula, ux = 1.9 + (x + 1.941) × 0.1062699 + (x + 1.941)(x + 1)(– 0.0060035) + (x + 1.941)(x + 1)(x – 0.061) × 0.0004869. Given x = 0 u0 = 1.9 + 0.2062698 – 0.0116527 – 0.0000576 = 2.0945595 ∴ The required root is 2.0945595.
  • 388. INTERPOLATION 375 Example 11. The mode of a certain frequency curve y = f(x) is very near to x = 9 and the values of frequency density f(x) for x = 8.9, 9.0 and 9.3 are respectively equal to 0.30, 0.35, and 0.25. Calculate the approximate value of mode. Sol. The divided difference table is as follows: x 100 f(x) 100Δ | f(x) 100 Δ | 2f(x) 8.9 30 5 0 9 50 9 . = 9.0 35 – 350 9 0 4 3500 36 × = − . – 10 0 3 100 3 . = − 9.3 25 Applying Newton’s divided difference formula 100 f(x) = 30 + (x – 8.9) × 50 9 + (x – 8.9)(x – 9) − F HG I KJ 3500 36 = – 97.222 x2 + 1745.833x – 1759.7217. ∴ f(x) = – .9722x2 + 17.45833x – 17.597217 f ′(x) = – 1.9444 x + 17.45833 Given f ′(x) = 0, we get x = 17 45833 19444 . . = 8.9788 Also, f ″(x) = – 1.9444 i.e., (–)ve ∴ f(x) is maximum at x = 8.9788 Hence, the mode is 8.9788. Example 12. The following are the mean temperatures (°F) on three days, 30 days apart during summer and winter. Estimate the approximate dates and values of maximum and minimum temperature.
  • 389. 376 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Summer Winter Day Date Temp. Date Temp. 0 15 June 58.8 16 Dec. 40.7 30 15 July 63.4 15 Jan. 38.1 60 14 August 62.5 14 Feb. 39.3 Sol. The divided difference table for summer is: x f(x) Δ | f(x) Δ | 2f(x) 0 58.8 4.6 1 63.4 – 2.75 – 0.9 2 62.5 ∴ f(x) = 58.8 + (x – 0)(4.6) + (x – 0)(x – 1)(– 2.75) = – 2.75 x2 + 7.35 x + 58.8 For maximum and minimum of f(x), we have f ′ (x) = 0 ⇒ – 5.5 x + 7.35 = 0 ⇒ x = 1.342 Again, f ″ (x) = – 5.5 0 ∴ f(x) is maximum at x = 1.342 Since unit 1 ≡ 30 days ∴ 1.342 ≡ 30 × 1.342 = 40.26 days ∴ The maximum temperature was on 15 June + 40 days, i.e., on 25 July, and the value of the maximum temperature is [f(x)]max. = [f(x)]1.342 = 63.711°F. approximately. The divided difference table for winter is as follows: x f(x) Δ | f(x) Δ | 2f(x) 0 40.7 – 2.6 1 38.1 1.9 1.2 2 39.3
  • 390. INTERPOLATION 377 ∴ f(x) = 40.7 + (x – 0) (– 2.6) + x(x – 1)(1.9) = 1.9x2 – 4.5x + 40.7 For f(x) to be maximum or minimum, we have f ′(x) = 0 3.8x – 4.5 = 0 ⇒ x = 1.184 Again, f ″ (x) = 3.8 0 ∴ f(x) is minimum at x = 1.184 Again, unit 1 ≡ 30 days ∴ 1.184 ≡ 30 × 1.184 = 35.52 days ∴ The minimum temperature was on 16 Dec. + 35.5 days, i.e., at mid- night on the 20th of January and its value can be obtained similarly. [f(x)]min. = [f(x)]1.184 = 63.647°F approximately. Example 13. Using Newton’s divided difference formula, calculate the value of f(6) from the following data: x: 1 2 7 8 f(x): 1 5 5 4. Sol. The divided difference table is: x f(x) Δ | f(x) Δ | 2f(x) Δ | 3f(x) 1 1 4 2 5 − 2 3 0 1 14 7 5 − 1 6 – 1 8 4 Applying Newton’s divided difference formula, f(x) = 1 + (x – 1) (4) + (x – 1) (x – 2) − F HG I KJ 2 3 + (x – 1) (x – 2) (x – 7) 1 14 F HG I KJ
  • 391. 378 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ f(6) = 1 + 20 + (5) (4) − F HG I KJ 2 3 + (5) (4) (– 1) 1 14 F HG I KJ = 6.2381. Example 14. Referring to the following table, find the value of f(x) at point x = 4: x: 1.5 3 6 f(x): – 0.25 2 20. Sol. The divided difference table is: x f(x) Δ | f(x) Δ | 2f(x) 1.5 – 0.25 1.5 3 2 1 6 6 20 Applying Newton’s divided difference formula, f(x) = – 0.25 + (x – 1.5) (1.5) + (x – 1.5) (x – 3) (1) Putting x = 4, we get f(4) = 6. Example 15. Using Newton’s divided difference formula, prove that f(x) = f(0) + xΔf(– 1) + (x 1)x 2 ! + Δ2 f(– 1) + (x 1)x(x 1) 3 ! + − Δ3f(– 2) + ...... Sol. Taking the arguments, 0, – 1, 1, – 2, ...... the divided Newton’s difference formula is f(x) = f(0) + x Δ | − 1 f(0) + x(x + 1) Δ | , − 1 1 2 f(0) + x(x + 1)(x – 1) Δ | , , 3 1 1 2 − − f(0) + ... (74) = f(0) + x Δ | 0 f(– 1) + x(x + 1) Δ | , 2 0 1 f(– 1) + (x + 1)x(x – 1) Δ | , , 3 1 0 1 − f(– 2) + ....
  • 392. INTERPOLATION 379 Now Δ | 0 f(– 1) = f f ( ) ( ) ( ) 0 1 0 1 − − − − = Δ f(– 1) Δ | , 2 0 1 f(– 1) = 1 1 1 − − ( ) [Δ | 1 f(0) – Δ | 0 f(– 1)] = 1 2 [Δ f(0) – Δ f(– 1)] = 1 2 Δ2 f(– 1) Δ | , , 3 1 0 1 − f(– 2) = 1 1 2 − − ( ) [Δ | , 2 0 1 f(– 1) – Δ | , 2 1 0 − f(– 2)] = 1 3 Δ Δ 2 2 1 2 2 2 f f ( ) ( ) − − − L NM O QP = Δ Δ 3 3 2 3 2 2 3 f f ( ) . ( ) ! − = − and so on. Substituting these values in (74) f(x) = f(0) + xΔ f(– 1) + ( ) ! x x + 1 2 Δ2 f(– 1) + ( ) ( ) ! x x x + − 1 1 3 Δ3 f(– 2) + ...... ASSIGNMENT 4.12 1. Given the values: x: 5 7 11 13 17 f(x): 150 392 1452 2366 5202 Evaluate f(9) using Newton’s divided difference formula. 2. The observed values of a function are, respectively, 168, 120, 72, and 63 at the four positions 3, 7, 9, and 20 of the independent variable. What is the best estimate you can give for value of the function at the position 6 of the independent variable? 3. Apply Newton’s divided difference formula to find the value of f(8) if f(1) = 3, f(3) = 31, f(6) = 223, f(10) = 1011, f(11) = 1343. 4. Given that x: 1 3 4 6 7 yx: 1 27 81 729 2187 Find y5. Why does it differ from 35? 5. Use Newton’s divided difference formula to find f(7) if f(3) = 24, f(5) = 120, f(8) = 504, f(9) = 720, and f(12) = 1716.
  • 393. 380 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6. The following table is given: x: 0 1 2 5 f(x): 2 3 12 147 What is the form of the function? 7. Find the function ux in powers of x – 1, given that u0 = 8, u1 = 11, u4 = 68, u5 = 123. 8. Find ux in powers of x – 4 where u0 = 8, u1 = 11, u4 = 68, u5 = 125. 9. Using Lagrange’s interpolation formula express the function x x x x x 2 3 2 3 2 2 + − − − + as sums of portial fractions 10. Express the function x x x x x 2 2 6 1 1 4)( 6 + − − − − ( )( ) as a sum of partial fractions. 11. Certain corresponding values of x and log10 x are given below: x: 300 304 305 307 log10 x: 2.4771 2.4829 2.4843 2.4871 Find log10 310 by Newton’s divided difference formula. 12. (i) The following table gives the values of x and y: x: 1.2 2.1 2.8 4.1 4.9 6.2 y: 4.2 6.8 9.8 13.4 15.5 19.6 Find the value of x corresponding to y = 12 using Lagrange’s technique of inverse inter- polation. (ii) Obtain the value of t when A = 85 from the following table using Lagrange’s method t: 2 5 8 14 A: 94.8 87.9 81.3 68.7 13. Using Newton’s divided difference method, compute f(3) from the following table x: 0 1 2 4 5 6 f(x): 1 14 15 5 6 19 14. Find the Newton’s divided difference interpolation polynomial for: x: 0.5 1.5 3.0 5.0 6.5 8.0 f(x): 1.625 5.875 31.0 131.0 282.125 521.0
  • 394. INTERPOLATION 381 15. If f(x) = U(x)V(x), find the divided difference f(x0, x1) in terms of U(x0), V(x1) and the divided differences U(x0, x1), V(x0, x1). Write a code in C to implement. 16. Write an algorithm to compute the value of a function using Lagrange’s interpolation. 4.33 HERMITE’S INTERPOLATION FORMULA So far we have considered the interpolation formulae which make use only of a certain number of function values. We now derive an interpolation formula in which both the function and its first derivative are to be assigned at each point of interpolation. This is called Hermite’s interpolation formula or osculating interpolation formula. Let the set of data points (xi, yi, yi′), 0 ≤ i ≤ n be given. A polynomial of the least degree say H(x) is to be determined such that H(xi) = yi and H′(xi) = yi′; i = 0, 1, 2, ... n (75) H(x) is called Hermite’s interpolating polynomial. Since there are 2n + 2 conditions to be satisfied, H(x) must be a polynomial of degree ≤ 2n + 1. The required polynomial may be written as H(x) = u x y v x y i i i i i n i n ( ) ( ) + ′ = = ∑ ∑ 0 0 (76) where ui(x) and vi(x) are polynomials in x of degree ≤ (2n + 1) and satisfy (i) ui(xj) = 0 1 , , i j i j ≠ = R S T U V W (77 (i)) (ii) vi(xj) = 0 ∀ i, j (77 (ii)) (iii) ui′(xj) = 0 ∀ i, j (77 (iii)) (iv) vi′(xj) = 0 1 , , i j i j ≠ = R S T U V W (77 (iv)) Using the Lagrange fundamental polynomials Li(x), we choose ui(x) = Ai(x) [Li(x)]2 and vi(x) = Bi(x) [Li(x)]2 (78) where Li(x) is defined as Li(x) = ( )( ) ... ( )( ) ... ( ) ( )( ) ... ( )( ) ... ( ) x x x x x x x x x x x x x x x x x x x x i i n i i i i i i i n − − − − − − − − − − − + − + 0 1 1 1 0 1 1 1 U V W
  • 395. 382 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since Li 2(x) is a polynomial of degree 2n, Ai(x) and Bi(x) must be linear polynomials. Let Ai(x) = aix + bi and Bi(x) = cix + di so that from (78), ui(x) = (aix + bi) [Li(x)]2 vi(x) = (cix + di) [Li(x)]2 (79) using conditions (77(i)) and (77(ii)) in (79), we get aix + bi = 1 (80 (i)) and cix + di = 0 (80 (ii)) | since [Li(xi)]2 = 1 Again, using conditions (77(iii)) and (77(iv)) in (79), we get ai + 2Li′(xi) = 0 (80 (iii)) and ci = 1 (80 (iv)) From equations (80(i)), (80(ii)), (80(iii)) and (80(iv)), we deduce ai = – 2Li′(xi) bi = 1 + 2xiLi′(xi) (81) ci = 1 and di = – xi Hence, from (79), ui(x) = [– 2x Li′(xi) + 1 + 2xiLi′(xi)] [Li(x)]2 = [1 – 2(x – xi) Li′(xi)] [Li(x)]2 and vi(x) = (x – xi) [Li(x)]2 Therefore from (76), H(x) = i n = ∑ 0 [1 – 2(x – xi) Li′(xi)] [Li(x)]2 yi + ( ) [ ( )] x x x y i i i i n − ′ = ∑ L 2 0 which is the required Hermite’s interpolation formula. EXAMPLES Example 1. Apply Hermite’s interpolation formula to find a cubic polynomial which meets the following specifications. U V W U V | | W | |
  • 396. INTERPOLATION 383 xi yi yi′ 0 0 0 1 1 1 Sol. Hermite interpolation formula is H(x) = [ ( ) ( )][ ( )] 1 2 2 0 1 − − ′ = ∑ x x x x y i i i i i i L L + i i i i x x x y = ∑ − ′ 0 1 2 ( ) [ ( )] L = [1 – 2 (x – x0) L0′(x0)] [L0(x)]2 y0 + [1 – 2(x – x1) L1′(x1)] [L1(x)]2 y1 + (x – x0) [L0(x)]2 y0′ + (x – x1) [L1 (x)]2 y1′ (82) Now, L0(x) = x x x x x − − = − − 1 0 1 1 0 1 = 1 – x L1 (x) = x x x x x − − = − − 0 1 0 0 1 0 = x ∴ L0′(x) = – 1 and L1′(x) = 1 Hence, L0′(x0) = – 1 and L1′(x1) = 1 ∴ From (82), H(x) = [1 – 2 (x – 0) (– 1) [ (1 – x)2 (0) + [1 – 2 (x – 1) (1) ] x2 (1) + (x – 0) (1 – x)2 (0) + (x – 1) x2 (1) = x2 – 2x2(x – 1) + x2 (x – 1) = x2 – x2 (x – 1) = x2(2 – x) = 2x2 – x3. Example 2. Apply Hermite’s formula to find a polynomial which meets these specifications xk yk yk′ 0 0 0 1 1 0 2 0 0
  • 397. 384 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Hermite’s interpolation formula is H(x) = i i i i i i i i i i x x x x y x x x y = = ∑ ∑ − − ′ + − ′ 0 2 2 0 2 2 1 2 [ ( ) ( )][ ( )] ( )[ ( )] L L L = [1 – 2(x – x0) L0′(x0)] [L0 (x)]2 y0 + [1 – 2(x – x1) L1′(x1)] [L1(x)]2 y1 + [1 – 2 (x – x2) L2′(x2)] [L2(x)]2 y2 + (x – x0) [L0(x)]2 y0′ + (x – x1) [L1(x)]2 y1′ + (x – x2) [L2(x)]2 y2′ (83) Now, L0(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x − − − − = − − − − = 1 2 0 1 0 2 1 2 0 1 0 2 1 2 (x2 – 3x + 2) L1 (x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x − − − − = − − − − 0 2 1 0 1 2 0 2 1 0 1 2 = 2x – x2 L2(x) = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x x x x x − − − − = − − − − = 0 1 2 0 2 1 0 1 2 0 2 1 1 2 (x2 – x) ∴ L0′(x) = 2 3 2 x − , L1′(x) = 2 – 2x, L2′(x) = 2 1 2 x − Hence, L0′(x0) = – 3 2 , L1′(x1) = 0, L2′(x2) = 3 2 ∴ From (83), H(x) = 1 2 0 3 2 1 4 − − − F HG I KJ L NM O QP ( ) x (x2 – 3x + 2)2 (0) + [1 – 2(x – 1) (0)] (2x – x2)2 (1) + 1 2 2 3 2 1 4 − − F HG I KJ L NM O QP ( ) x (x2 – x)2 (0) + (x – 0) 1 4 (x2 – 3x + 2)2 (0) + (x – 1) (2x – x2)2 (0) + (x – 2) 1 4 (x2 – x)2 (0) = (2x – x2)2 = x4 – 4x3 + 4x2. Example 3. A switching path between parallel railroad tracks is to be a cubic polynomial joining positions (0, 0) and (4, 2) and tangent to the lines y = 0 and y = 2 as shown in the figure. Apply Hermite’s interpolation formula to obtain this polynomial.
  • 398. INTERPOLATION 385 (0, 0) (4, 2) X Y Sol. Since tangents are parallel to X-axis, y′ = 0 in both the cases. ∴ We have the table of values, x y y′ 0 0 0 4 2 0 The hermite interpolation formula is H(x) = [ ( ) ( )][ ( )] ( )[ ( )] 1 2 2 0 1 0 1 2 − − ′ + − ′ = = ∑ ∑ x x x x y x x x y i i i i i i i i i i L L L (84) Now, L0(x) = x x x x x x − − = − − = − 1 0 1 4 0 4 1 4 L1(x) = x x x x x x − − = − − = 0 1 0 0 4 0 4 ∴ L0′( x) = – 1 4 and L1′(x) = 1 4 Hence, L0′(x0) = – 1 4 and L1′(x1) = 1 4 ∴ From (84), H(x) = 1 2 0 1 4 1 4 2 − − − F HG I KJ L NM O QP − F HG I KJ ( ) x x (0) + 1 2 4 1 4 4 2 − − F HG I KJ L NM O QPF HG I KJ ( ) x x (2) + (x – 0) 1 4 2 − F HG I KJ x (0) + (x – 4) x 4 2 F HG I KJ (0) = 1 4 2 8 2 − − F HG I KJ L NM O QP x x = ( ) 6 16 1 16 2 − = x x (6x2 – x3).
  • 399. 386 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 4.13 1. Apply Hermite’s interpolation formula to find f(x) at x = 0.5 which meets the following requirement: xi f(xi) f ′(xi) – 1 1 – 5 0 1 1 1 3 7 Also find f(– 0.5). 2. Apply Hermite’s interpolating formula to obtain a polynomial of degree 4 for the follow- ing data: xi yi yi′ 0 1 0 1 0 0 2 9 24 3. Apply Hermite’s formula to find a polynomial which meets the following specifications: xi yi yi′ – 1 – 1 0 0 0 0 1 1 0 4. Apply osculating interpolation formula to find a polynomial which meets the following requirements: xi yi yi′ 0 1 0 1 0 0 2 9 0
  • 400. INTERPOLATION 387 5. Apply Hermite’s formula to interpolate for sin 1.05 from the following data: x sin x cos x 1.00 0.84147 0.54030 1.10 0.89121 0.45360 6. Find y = f(x) by Hermite’s interpolation from the table: xi yi yi′ – 1 1 – 5 0 1 1 1 3 7 Compute y2 and y2′. 7. Compute e by Hermite’s formula for the function f(x) = ex at the points 0 and 1. Com- pare the value with the value obtained by using Lagrange’s interpolation. 8. Show that f a b f a f b b a f a f b + F HG I KJ = + + − ′ − ′ 2 2 8 ( ) ( ) ( ) [ ( ) ( )] by Hermite’s interpolation. 9. Apply Hermite’s interpolation to find f(1.05) given: x f f ′ 1 1.0 0.5 1.1 1.04881 0.47673 10. Apply Hermite’s interpolation to find log 2.05 given that x log x 1 x 2.0 0.69315 0.5 2.1 0.74194 0.47619
  • 401. 388 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 11. Determine the Hermite polynomial of degree 5 which fits the following data and hence find an approximate value of loge 2.7. x y = logex y′ = 1 x 2.0 0.69315 0.5 2.5 0.91629 0.4 3.0 1.09861 0.33333 12. Using Hermite’s interpolation formula, estimate the value of ln (3.2) from the following table: x 3 3.5 4.0 y = ln (x) 1.09861 1.25276 1.38629 y′ = 1 x 0.33333 0.28571 0.25000 13. (i) Construct the Hermite interpolation polynomial that fits the data: x f(x) f ′(x) 1 7.389 14.778 2 54.598 109.196 Estimate the value of f(1.5). (ii) Consider the cubic polynomial P(x) = c0 + c1x + c2 x2 + c3 x3. Fit the data in problem 13(i) and find P(x). Are these polynomials different? Comment. 14. (i) Construct the Hermite interpolation polynomial that fits the data: x f(x) f ′(x) 2 29 50 3 105 105 Interpolate f(x) at x = 2.5. (ii) Fit the cubic polynomial P(x) = c0 + c1x + c2x2 + c3x3 to the data given in problem 14(i). Are these polynomials same?
  • 402. INTERPOLATION 389 15. (i) Construct the Hermite interpolation polynomial that fits the data: x f(x) f ′(x) 0 0 1 0.5 0.4794 0.8776 1.0 0.8415 0.5403 Estimate the value of f(0.75). (ii) Construct the Hermite interpolation polynomial that fits the data: x y(x) y′(x) 0 4 – 5 1 – 6 – 14 2 – 22 – 17 Interpolate y(x) at x = 0. 5 and 1.5. 16. Obtain the unique polynomial p(x) of degree 3 or less corresponding to a function f(x) where f(0) = 1, f ′(0) = 2, f(1) = 5, f ′(1) = 4.
  • 404. P a r t 3 n Numerical Integration and Differentiation Introduction, Numerical Differentiation, Numerical Integration, Trapezoidal Rule, Simpson’s 1 3 rd F HG I KJ and 3 8 th F HG I KJ Rule, Boole’s Rule, Weddle’s Rule.
  • 406. 5.1 INTRODUCTION C onsider a function of a single variable y = f(x). If f(x) is defined as an expression, its derivative or integral may often be determined using the techniques of calculus. However, when f(x) is a complicated function or when it is given in a tabular form, numerical methods are used. This section discusses numerical methods for approximating the derivative(s) f(r)(x), r ≥ 1 of a given function f(x) and for the evaluation of the integral a b f x dx z ( ) where a, b may be finite or infinite. The accuracy attainable by these methods would depend on the given function and the order of the polynomial used. If the polynomial fitted is exact then the error would be, theoretically, zero. In practice, however, rounding errors will introduce errors in the calculated values. The error introduced in obtaining derivatives is, in general, much worse than that introduced in determining integrals. It may be observed that any errors in approximating a function are amplified while taking the derivative whereas they are smoothed out in integration. Thus numerical differentiations should be avoided if an alternative exists. Chapter 5 NUMERICAL INTEGRATION AND DIFFERENTIATION 393
  • 407. 394 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 5.2 NUMERICAL DIFFERENTIATION In the case of numerical data, the functional form of f(x) is not known in general. First we have to find an appropriate form of f(x) and then obtain its derivatives. So “Numerical Differentiation” is concerned with the method of finding the successive derivatives of a function at a given argument, using the given table of entries corresponding to a set of arguments, equally or unequally spaced. Using the theory of interpolation, a suitable interpolating polynomial can be chosen to represent the function to a good degree of approximation in the given interval of the argument. For the proper choice of interpolation formula, the criterion is the same as in the case of interpolation problems. In the case of equidistant values of x, if the derivative is to be found at a point near the beginning or the end of the given set of values, Newton’s forward or backward difference formula should be used accordingly. Also if the derivative is to be found at a point near the middle of the given set of values, then any one of the central difference formulae should be used. However, if the values of the function are not known at equidistant values of x, Newton’s divided difference or Lagrange’s formula should be used. 5.3 FORMULAE FOR DERIVATIVES (1) Newton’s forward difference interpolation formula is y = y0 + u Δy0 + u u y u u u y ( ) ! ( )( ) ! .... − + − − + 1 2 1 2 3 2 0 3 0 Δ Δ (1) where u = x a h − (2) Differentiating eqn. (1) with respect to u, we get dy du y u y u u = + − + − + Δ Δ 0 2 0 2 2 1 2 3 6 2 6 Δ3y0 + ... (3) Differentiating eqn. (2) with respect to x, we get du dx h = 1 (4) We know that dy dx dy du du dx h y u y u u y = = + − F HG I KJ + − + F HG I KJ + L N MM O Q PP . ... 1 2 1 2 3 6 2 6 0 2 0 2 3 0 Δ Δ Δ (5)
  • 408. NUMERICAL INTEGRATION AND DIFFERENTIATION 395 Expression (5) provides the value of dy dx at any x which is not tabulated. Formula (5) becomes simple for tabulated values of x, in particular when x = a and u = 0 Putting u = 0 in (5), we get dy dx h y y y y y x a F HG I KJ = − + − + − L NM O QP = 1 1 2 1 3 1 4 1 5 0 2 0 3 0 4 0 5 0 Δ Δ Δ Δ Δ ... (6) Differentiating eqn. (5) with respect to x, we get d y dx d dx dy dx 2 2 = F HG I KJ = d du dy dx du dx F HG I KJ = 1 1 6 18 11 12 1 2 0 3 0 2 4 0 h y u y u u y h Δ Δ Δ + − + − + F HG I KJ + L N MM O Q PP ( ) ... = 1 1 6 18 11 12 2 2 0 3 0 2 4 0 h y u y u u y Δ Δ Δ + − + − + F HG I KJ + L N MM O Q PP ( ) ... (7) Putting u = 0 in (7), we get d y dx h y y y x a 2 2 2 2 0 3 0 4 0 1 11 12 F HG I KJ = − + + F HG I KJ = Δ Δ Δ ... (8) Similarly, we get d y dx h y y x a 3 3 3 3 0 4 0 1 3 2 F HG I KJ = − + F HG I KJ = Δ Δ ... (9) and so on. Formulae for computing higher derivatives may be obtained by successive differentiation. Aliter: We know that E = ehD ⇒ 1 + Δ = ehD ∴ hD = log (1 + Δ) = Δ Δ Δ Δ − + − + 2 3 4 2 3 4 ...
  • 409. 396 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ⇒ D = 1 1 2 1 3 1 4 2 3 4 h Δ Δ Δ Δ − + − + L NM O QP ... Similarly, D2 = 1 1 2 1 3 1 4 1 11 12 5 6 2 2 3 4 2 2 2 3 4 5 h h Δ Δ Δ Δ Δ Δ Δ Δ − + − + F HG I KJ = − + − + F HG I KJ ... ... and D3 = 1 3 2 3 3 4 h Δ Δ − + F HG I KJ ... (2) Newton’s backward difference interpolation formula is y = yn + u ∇yn + u u y u u u n ( ) ! ( )( ) ! + ∇ + + + 1 2 1 2 3 2 ∇3yn + ... (10) where u = x x h n − (11) Differentiating (10) with respect to, u, we get dy du y u y u u n n = ∇ + + F HG I KJ ∇ + + + F HG I KJ 2 1 2 3 6 2 6 2 2 ∇3yn + ... (12) Differentiating (11) with respect to x, we get du dx h = 1 (13) Now, dy dx dy du du dx = . = 1 2 1 2 3 6 2 6 2 2 3 h y u y u u y n n n ∇ + + F HG I KJ ∇ + + + F HG I KJ ∇ + L N MM O Q PP ... (14) Expression (14) provides us the value of dy dx at any x which is not tabulated. At x = xn, we have u = 0 ∴ Putting u = 0 in (14), we get dy dx h y y y y x x n n n n n F HG I KJ = ∇ + ∇ + ∇ + ∇ + F HG I KJ = 1 1 2 1 3 1 4 2 3 4 ... (15)
  • 410. NUMERICAL INTEGRATION AND DIFFERENTIATION 397 Differentiating (14) with respect to x, we get d y dx d du dy dx du dx 2 2 = F HG I KJ = 1 1 6 18 11 12 2 2 3 2 4 h y u y u u y n n n ∇ + + ∇ + + + F HG I KJ ∇ + L N MM O Q PP ( ) ... (16) Putting u = 0 in (16), we get d y dx h y y y x x n n n n 2 2 2 2 3 4 1 11 12 F HG I KJ = ∇ + ∇ + ∇ + F HG I KJ = ... (17) Similarly, we get d y dx h y y x x n n n 3 3 3 3 4 1 3 2 F HG I KJ = ∇ + ∇ + F HG I KJ = ... (18) and so on. Formulae for computing higher derivatives may be obtained by successive differentiation. Aliter: We know that E–1 = 1 – ∇ e–hD = 1 – ∇ ∴ – hD = log (1 – ∇) = – ∇ + ∇ + ∇ + ∇ + F HG I KJ 1 2 1 3 1 4 2 3 4 ... ⇒ D = 1 1 2 1 3 1 4 2 3 4 h ∇ + ∇ + ∇ + ∇ + F HG I KJ ... Also, D2 = 1 1 2 1 3 2 2 3 2 h ∇ + ∇ + ∇ + F HG I KJ ... = ∇ + ∇ + ∇ + F HG I KJ 1 11 12 2 2 3 4 h ... Similarly, D3 = 1 3 2 3 3 h ∇ + ∇ + F HG I KJ 4 ... and so on.
  • 411. 398 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (3) Stirling’s central difference interpolation formula is y = y0 + u y y u y u u y y 1 2 2 1 3 2 0 1 2 2 1 2 2 3 1 3 2 ! ! ( ) ! Δ Δ Δ Δ Δ + F HG I KJ + + − + F HG I KJ − − − − + u u y u u u y y 2 2 2 4 2 2 2 2 2 5 2 5 3 1 4 1 2 5 2 ( ) ! ( )( ) ! − + − − + F HG I KJ − − − Δ Δ Δ + ... (19) where u = x a h − (20) Differentiating eqn. (19) with respect to u, we get dy du y y u y u y y = + + + − F HG I KJ + F HG I KJ − − − − Δ Δ Δ Δ Δ 0 1 2 1 2 3 1 3 2 2 3 1 6 2 + 4 2 4 5 15 4 5 2 3 4 2 4 2 5 2 5 3 u u y u u y y − F HG I KJ + − + F HG I KJ + F HG I KJ − − − ! ! Δ Δ Δ + ... (21) Differentiating (20) with respect to x, we get du dx h = 1 (22) Now, dy dx dy du du dx = . = 1 2 3 1 6 2 0 1 2 1 2 3 1 3 2 h y y u y u y y Δ Δ Δ Δ Δ + + + − F HG I KJ + F HG I KJ L N MM − − − − + 4 2 4 5 15 4 5 2 3 4 2 4 2 5 2 5 3 u u y u u y y − F HG I KJ + − + F HG I KJ + F HG I KJ + O Q PP − − − ! ! ... Δ Δ Δ (23) Expression (23) provides the value of dy dx at any x which is not tabulated. Given x = a, we have u = 0
  • 412. NUMERICAL INTEGRATION AND DIFFERENTIATION 399 ∴ Given u = 0 in (23), we get dy dx h y y y y x a F HG I KJ = + F HG I KJ − + F HG I KJ L N MM = − − − 1 2 1 6 2 0 1 3 1 3 2 Δ Δ Δ Δ + 1 30 2 5 2 5 3 Δ Δ y y − − + F HG I KJ − O Q PP ... (24) Differentiating (23) with respect to x, we get d y dx d du dy dx du dx 2 2 = F HG I KJ = 1 2 6 1 12 2 2 1 3 1 3 2 2 h y u y y u Δ Δ Δ − − − + + F HG I KJ + − F HG I KJ L N MM Δ4y–2 + 2 3 12 2 3 5 2 5 3 u u y y − F HG I KJ + F HG I KJ + O Q PP − − Δ Δ ... (25) Given u = 0 in (25), we get d y dx h y y y x a 2 2 2 2 1 4 2 6 3 1 1 12 1 90 F HG I KJ = − + − F HG I KJ = − − − Δ Δ Δ ... (26) and so on. Formulae for computing higher derivatives may be obtained by successive differentiation. (4) Bessel’s central difference interpolation formula is y = y y u y u u y y 0 1 0 2 1 2 0 2 1 2 1 2 2 + F HG I KJ + − F HG I KJ + − + F HG I KJ − Δ Δ Δ ( ) ! + u u u y ( ) ! − − F HG I KJ − 1 1 2 3 3 1 Δ + + − − + F HG I KJ − − ( ) ( )( ) ! u u u u y y 1 1 2 4 2 4 2 4 1 Δ Δ + ( ) ( )( ) ! u u u u u y + − − − F HG I KJ − 1 1 2 1 2 5 5 2 Δ + ( )( ) ( )( )( ) ! u u u u u u y y + + − − − + F HG I KJ − − 2 1 1 2 3 6 2 6 3 6 2 Δ Δ + ... (27) where u = x a h − (28)
  • 413. 400 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Differentiating eqn. (27) with respect to u, we get dy du y u y y = + − F HG I KJ + F HG I KJ − Δ Δ Δ 0 2 1 2 0 2 1 2 2 ! + 3 3 1 2 3 2 u u − + F H GG I K JJ ! Δ3y–1 + 4 6 2 2 4 2 5 10 5 1 5 3 2 4 2 4 1 4 3 u u u y y u u u − − + F HG I KJ + F HG I KJ + − + − F HG I KJ − − ! ! Δ Δ Δ5y–2 + 6 15 20 45 8 12 6 2 5 4 3 2 6 3 6 2 u u u u u y y − − + + − F HG I KJ + F HG I KJ − − ! Δ Δ + ... (29) Differentiating (28) with respect to x, we get du dx h = 1 Now, dy dx dy du du dx = . = 1 2 1 2 2 3 3 1 2 3 0 2 1 2 0 2 h y u y y u u Δ Δ Δ + − F HG I KJ + F HG I KJ + − + F H GG I K JJ L N MMMM − ! ! Δ3y–1 + 4 6 2 2 4 2 5 10 5 1 5 3 2 4 2 4 1 4 3 u u u y y u u u − − + F HG I KJ + F HG I KJ + − + − F HG I KJ − − ! ! Δ Δ Δ5y–2 + 6 15 20 45 8 12 6 2 5 4 3 2 6 3 6 2 u u u u u y y − − + + − F HG I KJ + F HG I KJ + O Q PP − − ! ... Δ Δ (30) Expression (30) provides us the value of dy dx at any x which is not tabu- lated. Given x = a, we have u = 0 ∴ Given u = 0 in (30), we get dy dx h y y y y y y x a F HG I KJ = − + F HG I KJ + + + F HG I KJ L N MM = − − − − 1 1 2 2 1 12 1 12 2 0 2 1 2 0 3 1 4 2 4 1 Δ Δ Δ Δ Δ Δ – 1 120 60 2 5 2 6 3 6 2 Δ Δ Δ y y y − − − − 1 + F HG I KJ + O Q PP ... (31)
  • 414. NUMERICAL INTEGRATION AND DIFFERENTIATION 401 Differentiating (30) with respect to x, we get d y dx d dx dy dx 2 2 = F HG I KJ = d du dy dx du dx F HG I KJ = 1 2 2 1 2 6 6 1 12 2 2 1 2 0 3 1 2 h y y u y u u Δ Δ Δ − − + F HG I KJ + − F HG I KJ + − − F HG I KJ L N MM Δ Δ 4 4 1 2 y y –2 + F HG I KJ − + 4 6 1 24 3 2 u u − + F HG I KJ Δ5y–2 + 15 30 30 45 4 360 2 4 3 2 6 3 6 2 u u u u y y − − + + F HG I KJ + F HG I KJ + O Q PP − − Δ Δ ... (32) Given u = 0 in (32), we get d y dx h y y y y y x a 2 2 2 2 1 2 0 3 1 4 2 4 1 1 2 2 1 12 2 F HG I KJ = + F HG I KJ − 1 − + F HG I KJ L N MM = − − − − Δ Δ Δ Δ Δ + 1 24 1 90 2 5 2 6 3 6 2 Δ Δ Δ y y y − − − + + F HG I KJ + O Q PP ... (33) and so on. (5) For unequally spaced values of the argument (i) Newton’s divided difference formula is f(x) = f(x0) + (x – x0) f(x0) + (x – x0)(x – x1) 2f(x0) + (x – x0)(x – x1) (x – x2) 3f(x0) + (x – x0)(x – x1) (x – x2)(x – x3) 4f(x0) + ... (34) f ′(x) is given by f ′(x) = f(x0) + {2x – (x0 + x1)} 2f(x0) + {3x2 – 2x(x0 + x1 + x2) + (x0x1 + x1x2 + x2x0)} 3f(x0) + ... (35) (ii) Lagrange’s interpolation formula is f(x) = ( )( ) ... ( ) ( )( ) ... ( ) x x x x x x x x x x x x n n − − − − − − 1 2 0 1 0 2 0 f(x0) + ( )( ) ... ( ) ( )( ) ... ( ) x x x x x x x x x x x x n n − − − − − − 0 2 1 0 1 2 1 f(x1) + ... (36) f ′(x) can be obtained by differentiating f(x) in eqn. (36).
  • 415. 402 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 1. Formula (8) can be extended as d y dx 1 h 11 12 5 6 137 180 7 10 363 560 ... 2 2 x a 2 2 3 4 5 6 7 8 F HG I KJ = − + − + − + + F H GGG I K JJJ = Δ Δ Δ Δ Δ Δ Δ y0 2. Formula (17) can be extended as d y dx 1 h 11 12 5 6 137 180 7 10 363 560 ... 2 2 x x 2 2 3 4 5 6 7 8 n F HG I KJ = ∇ + ∇ + ∇ + ∇ + ∇ + ∇ + ∇ + F H GGG I K JJJ = yn. 5.4 MAXIMA AND MINIMA OF A TABULATED FUNCTION Since maxima and minima of y = f(x) can be found by equating dy dx to zero and solving the equation for the argument x, the same method can be used to determine maxima and minima of tabulated function by differentiating the interpolating polynomial. For example, if Newton’s forward difference formula is used, we have y = y0 + u Δy0 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 0 Δ Δ3y0 + ... (37) Differentiating (37) with respect to u, we get dy du y u y u u = + − + − + Δ Δ 0 2 0 2 2 1 2 3 6 2 3 ! ! Δ3y0 + ... For maxima or minima, dy du = 0 ⇒ Δy0 + 2 1 2 3 6 2 3 2 0 2 u y u u − + − + ! ! Δ Δ3y0 + ... = 0 (38) If we terminate L.H.S. series after third differences for convenience, eqn. (38) being a quadratic in u gives two values of u. Corresponding to these values, x = a + uh will give the corresponding x at which function may be maximum or minimum. NOTE
  • 416. NUMERICAL INTEGRATION AND DIFFERENTIATION 403 For maximum, d y du 2 2 = (–)ve For minimum, d y du 2 2 = (+)ve. EXAMPLES Example 1. Find dy dx at x = 0.1 from the following table: x: 0.1 0.2 0.3 0.4 y: 0.9975 0.9900 0.9776 0.9604. Sol. Take a = 0.1. The difference table is: x y Δy Δ2y Δ3y 0.1 0.9975 – 0.0075 0.2 0.9900 – 0.0049 – 0.0124 0.0001 0.3 0.9776 – 0.0048 – 0.0172 0.4 0.9604 Here h = 0.1 and y0 = 0.9975 dy dx h y y y x L NM O QP = − + L NM O QP = 0.1 0 2 0 3 0 1 1 2 1 3 Δ Δ Δ = 1 0 0 0075 1 2 0 0049 1 3 0 0001 .1 − − − + L NM O QP . ( . ) ( . ) = – 0.050167. Example 2. The table given below reveals the velocity ‘v’ of a body during the time ‘t’ specified. Find its acceleration at t = 1.1. t: 1.0 1.1 1.2 1.3 1.4 v: 43.1 47.7 52.1 56.4 60.8.
  • 417. 404 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. The difference table is: t v Δv Δ2v Δ3v Δ4v 1.0 43.1 4.6 1.1 47.7 – 0.2 4.4 0.1 1.2 52.1 – 0.1 0.1 4.3 0.2 1.3 56.4 0.1 4.4 1.4 60.8 Let a = 1.1, ∴ v0 = 47.7 and h = 0.1 Acceleration at t = 1.1 is given by dv dt h v v v t L NM O QP = − + L NM O QP= − − + L NM O QP = 1.1 1 0.1 4.4 1 2 ( 0.1) 1 3 (0.2) 1 1 2 1 3 0 2 0 3 0 Δ Δ Δ = 45.1667 Hence the required acceleration is 45.1667. Example 3. Find f ′(1.1) and f ″(1.1) from the following table: x: 1.0 1.2 1.4 1.6 1.8 2.0 f(x): 0.0 0.1280 0.5540 1.2960 2.4320 4.000. Sol. Since we are to find f ′(x) and f ″(x) for non-tabular value of x, we proceed as follows: Newton’s forward difference formula is y = y0 + u Δy0 + u u y u u u ( ) ! ( )( ) ! − + − − 1 2 1 2 3 2 0 Δ Δ3y0 + u u u u ( )( )( ) ! − − − 1 2 3 4 Δ4y0 + ... (39) where u = x a h − (40)
  • 418. NUMERICAL INTEGRATION AND DIFFERENTIATION 405 Differentiating eqn. (39) with respect to u, we get dy du y u y u u = + − F HG I KJ + − + F HG I KJ Δ Δ 0 2 0 2 2 1 2 3 6 2 6 Δ3y0 + 2 9 11 3 12 3 2 u u u − + − F HG I KJ Δ4y0 + ... (41) Differentiating eqn. (40) with respect to x du dx h = 1 (42) ∴ dy dx dy du du dx = . = 1 2 1 2 3 6 2 6 0 2 0 2 h y u y u u Δ Δ + − F HG I KJ + − + F HG I KJ L N MM Δ3 0 y + − + − F HG I KJ + O Q PP 2 9 11 3 12 3 2 4 0 u u u y Δ ... (43) Also, at x = 1.1, u = 1.1 1.0 0.2 − = 1 2 Here 1.0 and 0.2 a h = = The forward difference table is as follows: x f(x) = y Δy Δ2y Δ3y Δ4y Δ5y 1.0 0.0 0.1280 1.2 0.1280 0.298 0.4260 0.018 1.4 0.5540 0.316 0.06 0.7420 0.078 – 0.1 1.6 1.2960 0.394 – 0.04 1.1360 0.038 1.8 2.4320 0.432 1.5680 2.0 4.000
  • 419. 406 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES From eqn. (43), dy dx h y u y u u y = + − F HG I KJ + − + F HG I KJ L N MM 1 2 1 2 3 6 2 6 0 2 0 2 3 0 Δ Δ Δ + − + − F HG I KJ 2 9 11 3 12 3 2 u u u Δ4y0 + 5 40 105 100 24 120 4 3 2 5 0 u u u u y − + − + F HG I KJ + O Q PP Δ ... (44) At x = 1.1, we get f ′(1.1) = dy dx x F HG I KJ =1.1 = 1 0.2 L N MMM0.1280 + 2 1 2 1 2 F HG I KJ − R S | T | U V | W | (0.298) + 3 1 2 6 1 2 2 6 2 F HG I KJ − F HG I KJ + R S | T | U V | W | (0.018) + 2 1 2 9 1 2 11 1 2 3 12 3 2 F HG I KJ − F HG I KJ + F HG I KJ − R S | T | U V | W | (.06) + 5 1 2 40 1 2 105 1 2 100 1 2 24 120 4 3 2 F HG I KJ − F HG I KJ + F HG I KJ − F HG I KJ + R S | T | U V | W |(– 0.1) O Q PPP = 0.66724. Differentiating eqn. (44), with respect to x, we get d y dx d du dy du du dx 2 2 = F HG I KJ = 1 1 6 18 11 12 2 2 0 3 0 2 4 0 h y u y u u y Δ Δ Δ + − + − + F HG I KJ L N MM ( ) + 2 12 21 10 12 3 2 5 0 u u u y − + − F HG I KJ + O Q PP Δ ...
  • 420. NUMERICAL INTEGRATION AND DIFFERENTIATION 407 At x = 1.1, we get f ″(1.1) = d y dx x 2 2 F HG I KJ =1.1 = 1 2 ( ) 0.2 L N MMM0.298 + 1 2 1 − F HG I KJ (0.018) + 6 1 2 18 1 2 11 12 2 F HG I KJ − F HG I KJ + R S | T | U V | W | (0.06) + 2 1 2 12 1 2 21 1 2 10 12 3 2 F HG I KJ − F HG I KJ + F HG I KJ − R S | T | U V | W |(– 0.1) O Q PPP = 8.13125. Example 4. The distance covered by an athlete for the 50 meter race is given in the following table: Time (sec): 0 1 2 3 4 5 6 Distance (meter): 0 2.5 8.5 15.5 24.5 36.5 50 Determine the speed of the athlete at t = 5 sec., correct to two decimals. Sol. Here we are to find derivative at t = 5 which is near the end of the table, hence we shall use the formula obtained from Newton’s backward difference formula. The backward difference table is as follows: t s ∇s ∇2s ∇3s ∇4s ∇5s ∇6s 0 0 2.5 1 2.5 3.5 6 – 2.5 2 8.5 1 3.5 7 1 – 3.5 3 15.5 2 0 1 9 1 – 2.5 4 24.5 3 – 2.5 12 – 1.5 5 36.5 1.5 13.5 6 50
  • 421. 408 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The speed of the athlete at t = 5 sec is given by ds dt h s s s s s t F HG I KJ = ∇ + ∇ + ∇ + ∇ + ∇ L NM O QP =5 5 2 5 3 5 4 5 5 5 1 1 2 1 3 1 4 1 5 = 1 1 12 1 2 3 1 3 1 1 4 0 1 5 + + + + − L NM O QP ( ) ( ) ( ) ( ) 3.5 = 13.1333 ≈ 13.13 metre/sec. Example 5. Find dy dx and d y dx 2 2 at x = 6, given that x: 4.5 5.0 5.5 6.0 6.5 7.0 7.5 y: 9.69 12.90 16.71 21.18 26.37 32.34 39.15. Sol. Here a = 6.0 ∴ y0 = 21.18 and h = 0.5 The forward difference table is: x y Δy Δ2y Δ3y Δ4y 4.5 9.69 3.21 5.0 12.9 0.60 3.81 0.06 5.5 16.71 0.66 0 4.47 0.06 6.0 21.18 0.72 0 5.19 0.06 6.5 26.37 0.78 0 5.97 0.06 7.0 32.34 0.84 6.81 7.5 39.15 We know that dy dx h y y y x L NM O QP = − + F HG I KJ = 6 0 2 0 3 0 1 1 2 1 3 Δ Δ Δ = 1 0.5 5.19 1 2 (0.78) 1 3 (0.06) − + L NM O QP = 9.64
  • 422. NUMERICAL INTEGRATION AND DIFFERENTIATION 409 and d y dx h y y y x 2 2 6 2 2 0 3 0 4 0 1 11 12 L NM O QP = − + L NM O QP = Δ Δ Δ = 1 0.25 [0.78 – 0.06] = 4(0.72) = 2.88. Example 6. From the following table of values of x and y, obtain dy dx and d y dx 2 2 for x = 1.2, 2.2 and 1.6 x: 1.0 1.2 1.4 1.6 1.8 2.0 2.2 y: 2.7183 3.3201 4.0552 4.9530 6.0496 7.3891 9.0250. Sol. The forward difference table is: x y Δy Δ2y Δ3y Δ4y Δ5y Δ6y 1.0 2.7183 0.6018 1.2 3.3201 0.1333 0.7351 0.0294 1.4 4.0552 0.1627 0.0067 0.8978 0.0361 0.0013 1.6 4.9530 0.1988 0.0080 0.0001 1.0966 0.0441 0.0014 1.8 6.0496 0.2429 0.0094 1.3395 0.0535 2.0 7.3891 0.2964 1.6359 2.2 9.0250 (i) Here a = 1.2 ∴ y0 = 3.3201; h = 0.2 dy dx x L NM O QP = − + − + L NM O QP = 1.2 1 0.2 0.7351 1 2 (0.1627) 1 3 (0.0361) 1 4 (0.008) 1 5 (0.0014) = 3.3205 d y dx x 2 2 1 2 1 0 L NM O QP = − + − L NM O QP = .2 ( ) .2 0.1627 0.0361 11 12 (0.0080) 5 6 (0.0014) = 3.318
  • 423. 410 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (ii) Here a = 2.2, ∴ yn = 9.02 and h = 0.2 dy dx x L NM O QP = + + L NM = 2 2 . 1 0.2 1.6359 1 2 (0.2964) 1 3 (0.0535) + + O QP 1 4 (0.0094) 1 5 (0.0014) = 9.0228 d y dx x 2 2 1 L NM O QP = + + + L NM O QP = 2.2 0.04 0.2964 0.0535 11 12 (0.0094) 5 6 (0.0014) = 8.992. (iii) Here a = 1.6 ∴ y0 = 4.9530, y–1 = 4.0552 y–2 = 3.3201, y–3 = 2.7183 and h = 0.2 By using Stirling’s formula for derivatives, we get dy dx x L NM O QP = + F HG I KJ − + F HG I KJ L NM = 1.6 1 0.2 1.0966 0.8978 2 1 6 0.0441 0.0361 2 + + F HG I KJO QP 1 30 0.0014 0.0013 2 = 4.9530 and d y dx x 2 2 L NM O QP = − + L NM O QP = 1.6 1 0.04 0.1988 1 12 (.0080) 1 90 (.0001) = 4.9525. Example 7. Using Bessel’s formula, find f ′(7.5) from the following table: x: 7.47 7.48 7.49 7.5 7.51 7.52 7.53 f(x): 0.193 0.195 0.198 0.201 0.203 0.206 0.208.
  • 424. NUMERICAL INTEGRATION AND DIFFERENTIATION 411 Sol. The difference table is: x y Δy Δ2y Δ3y Δ4y Δ5y Δ6y 7.47 0.193 0.002 7.48 0.195 0.001 0.003 – 0.001 7.49 0.198 0.000 0.000 0.003 – 0.001 0.003 7.50 0.201 – 0.001 0.003 – 0.01 0.002 0.002 – 0.007 7.51 0.203 0.001 – 0.004 0.003 – 0.002 7.52 0.206 – 0.001 0.002 7.53 0.208 Let a = 7.5, h = 0.01 f ′(7.5) = dy dx y y y y x F HG I KJ = − + F HG I KJ + L N MM = − − 7.5 0.01 1 1 2 2 1 12 0 2 1 2 0 3 1 Δ Δ Δ Δ + 1 12 2 1 120 1 60 2 4 2 4 1 5 2 6 3 6 2 Δ Δ Δ Δ Δ y y y y y − − − − − + F HG I KJ − − + F HG I KJ + O Q PP ... = 1 1 2 2 1 12 1 12 0.01 .002 .001 .001 0.002 ( ) ( ) − − + R S T U V W+ + L NM .003 .004 0.007 .01 2 + − R S T U V W− − − − F HG I KJO QP ( ) ( ) 2 1 120 1 60 = 0.226667. Example 8. A rod is rotating in a plane. The following table gives the angle θ (in radians) through which the rod has turned for various values of time t (in seconds) t: 0 0.2 0.4 0.6 0.8 1.0 1.2 θ: 0 0.12 0.49 1.12 2.02 3.20 4.67. Calculate the angular velocity and angular acceleration of the rod at t = 0.6 sec.
  • 425. 412 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. The forward difference table is: t θ Δθ Δ2θ Δ3θ Δ4θ 0 0 0.12 0.2 0.12 0.25 0.37 0.01 0.4 0.49 0.26 0 0.63 0.01 0.6 1.12 0.27 0 0.9 0.01 0.8 2.02 0.28 0 1.18 0.01 1.0 3.20 0.29 1.47 1.2 4.67 Here a = 0.6 ∴ θ0 = 1.12 and h = 0.2 Since the goal is to find derivatives at t = 0.6 sec, which is in the middle of the table, use the formula obtained from Stirling’s or Bessel’s central difference formula. Choose the formula obtained from Bessel’s central difference formula. Angular velocity at t = 0.6 sec is given by d dt h t θ θ θ θ F HG I KJ = − + F HG I KJ + L N MM O Q PP = − − 0.6 1 1 2 2 1 12 0 2 1 2 0 3 1 Δθ Δ Δ Δ = 1 1 2 2 1 12 0.2 0.9 0.27 0.28 0.01 − + F HG I KJ + L NM O QP ( ) = 3.81667 rad./sec. Angular acceleration at t = 0.6 sec is given by d dt h t 2 2 2 2 1 2 0 3 1 1 2 1 2 θ θ θ θ F HG I KJ = + F HG I KJ − L N MM O Q PP = − − 0.6 Δ Δ Δ = 1 2 1 2 2 ( ) ( ) 0.2 0.27 0.28 0.01 + F HG I KJ − L NM O QP = 6.75 rad./sec2.
  • 426. NUMERICAL INTEGRATION AND DIFFERENTIATION 413 In case we choose the formula obtained from Stirling’s formula, at t = 0.6 sec., angular velocity d dt 1 h 2 1 6 2 0 1 3 1 3 2 θ θ θ F HG I KJ = + F HG I KJ − + F HG I KJ L N MM O Q PP − − − Δθ Δθ Δ Δ = 1 0.2 .9 + .63 2 1 6 .01 .01 2 F HG I KJ − + F HG I KJ L NM O QP = 3.81667 rad./sec. and angular acceleration d dt 1 h 1 (0.2) 2 2 2 2 1 2 θ θ F HG I KJ = = − ( ) Δ (0.27) = 6.75 rad./sec2. Example 9. The table below gives the result of an observation. θ is the observed temperature in degrees centigrade of a vessel of cooling water, t is the time in minutes from the beginning of observations: t: 1 3 5 7 9 θ: 85.3 74.5 67.0 60.5 54.3 Find the approximate rate of cooling at t = 3 and 3.5. Sol. The forward difference table is: t θ Δθ Δ2θ Δ3θ Δ4θ 1 85.3 – 10.8 3 74.5 3.3 – 7.5 – 2.3 5 67.0 1.0 1.6 – 6.5 – 0.7 7 60.5 0.3 – 6.2 9 54.3 (i) When t = 3, θ0 = 74.5 Here h = 2 Rate of cooling = d dt θ NOTE
  • 427. 414 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ d dt h t θ θ θ θ F HG I KJ = − + − L NM O QP =3 0 2 0 3 0 4 0 1 1 2 1 3 1 4 Δθ Δ Δ Δ = 1 2 1 1 3 − − + − L NM O QP 7.5 1 2 0.7 ( ) ( ) = – 4.11667°C/min. (ii) t = 3.5 is the non-tabular value of t so, we have from Newton’s forward difference formula, dy dx h y u y u u y = + − F HG I KJ + − + F HG I KJ L N MM 1 2 1 2 3 6 2 6 0 2 0 2 3 0 Δ Δ Δ + 2 9 11 3 12 3 2 4 0 u u u y − + − F HG I KJ + O Q PP Δ ... Here, d dt h u u u θ θ θ = + − F HG I KJ + − + F HG I KJ L N MM 1 2 1 2 3 6 2 6 0 2 0 2 3 0 Δθ Δ Δ + 2 9 11 3 12 3 2 4 0 u u u − + − F HG I KJ + O Q PP Δ θ ... (45) At t = 3.5, u = 3.5 3.0 0.5 − = 2 2 = 0.25 | Here a = 3.0 and h = 2 From (45), d dt t θ F HG I KJ = − + − R S T U V W + − + R S T U V W − L N MM O Q PP =3.5 .25 .25 .25 .7 1 2 7 5 2 1 2 1 3 6 2 6 2 . ( ) ( ) ( ) ( ) ( ) = – 3.9151°C/min. Example 10. Find x for which y is maximum and find this value of y x: 1.2 1.3 1.4 1.5 1.6 y: 0.9320 0.9636 0.9855 0.9975 0.9996.
  • 428. NUMERICAL INTEGRATION AND DIFFERENTIATION 415 Sol. The difference table is as follows: x y Δ Δ2 Δ3 Δ4 1.2 0.9320 0.0316 1.3 0.9636 – 0.0097 0.0219 – 0.0002 1.4 0.9855 – 0.0099 0.0002 0.0120 0 1.5 0.9975 – 0.0099 0.0021 1.6 0.9996 Let y0 = 0.9320 and a = 1.2 By Newton’s forward difference formula, y = y0 + u Δy0 + u u y ( ) ... − + 1 2 2 0 Δ = 0.9320 + 0.0316 u + u u ( ) (– ) − 1 2 0.0097 | Neglecting higher differences dy du u = + − F HG I KJ − 0.0316 0.0097 2 1 2 ( ) At a maximum, dy du = 0 ⇒ 0.0316 = u − F HG I KJ 1 2 (0.0097) ⇒ u = 3.76 ∴ x = a + hu = 1.2 + (0.1) (3.76) = 1.576 To find ymax., we use the backward difference formula, x = xn + hu ⇒ 1.576 = 1.6 + (0.1)u ⇒ u = – 0.24 y(1.576) = yn + u ∇yn + u u y u u u y n n ( ) ! ( )( ) ! + ∇ + + + ∇ 1 2 1 2 3 2 3
  • 429. 416 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 0.9996 – (0.24 × 0.0021) + ( 0.24)(1 0.24) 2 − − (– 0.0099) = 0.9999988 = 0.9999 nearly ∴ Maximum y = 0.9999 approximately. Example 11. Assuming Bessel’s interpolation formula, prove that d dx (y ) y 1 24 y x x 1/2 3 x 3/2 = − − − Δ Δ + ... Sol. Bessel’s formula is yx = y y x y x x y y 0 1 0 2 1 2 0 2 1 2 1 2 2 + F HG I KJ + − F HG I KJ + − + F HG I KJ − Δ Δ Δ ( ) ! + x x x ( ) ! − − F HG I KJ 1 1 2 3 Δ3y–1 + ... (46) Replacing x by x + 1 2 , we get yx+1/2 = y y x y x x 0 1 0 2 1 2 1 2 2 + F HG I KJ + + + F HG I KJ − F HG I KJ Δ ! Δ Δ 2 1 2 0 2 y y − + F HG I KJ + + F HG I KJ − F HG I KJ − x x x y 1 2 1 2 3 3 1 ! Δ + ... (47) Differentiating (47) with respect to x, we get d dx y y x y y x ( ) ! + − = + + F HG I KJ 1/2 0 2 1 2 0 2 2 2 Δ Δ Δ + 3 1 4 3 2 x − F H GG I K JJ ! Δ3y–1 + ... Given x = 0, we get d dx y y x ( ) + = − 1/2 0 1 24 Δ Δ3y–1 + ... Shifting the origin from x = 0 to x – 1 2 , we get d dx y y y x x x ( ) / = − − − Δ Δ 1/2 3 3 2 1 24 + ...
  • 430. NUMERICAL INTEGRATION AND DIFFERENTIATION 417 Example 12. Find f ″′(5) from the data given below: x: 2 4 9 13 16 21 29 f(x): 57 1345 66340 402052 1118209 4287844 21242820 Sol. In this case, the values of argument x are not equally spaced and therefore we shall apply Newton’s divided difference formula. f(x) = f(x0) + (x – x0) f(x0) + (x – x0)(x – x1) 2f(x0) + (x – x0)(x – x1)(x – x2) 3f(x0) + (x – x0) (x – x1)(x – x2)(x – x3) 4f(x0) + ... (48) Newton’s divided difference table is as follows: x f(x) f(x) 2 f(x) 3 f(x) 4 f(x) 5 f(x) 6 f(x) 2 57 644 4 1345 1765 12999 556 9 66340 7881 45 83928 1186 1 13 402052 22113 64 0 238719 2274 1 16 1118209 49401 89 633927 4054 21 4287844 114265 2119372 29 21242820 Substituting values in eqn. (48), we get f(x) = 57 + (x – 2)(644) + (x – 2)(x – 4)(1765) + (x – 2)(x – 4)(x – 9)(556) + (x – 2)(x – 4)(x – 9)(x – 13)(45) + (x – 2)(x – 4)(x – 9)(x – 13)(x – 16)(1) = 57 + 644(x – 2) + 1765(x2 – 6x + 8) + 556(x3 – 15x2 + 62x – 72) + 45(x4 – 28x3 + 257x2 – 878x + 936) + x5 – 44x4 + 705x3 – 4990x2 + 14984x – 14976
  • 431. 418 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES f ′(x) = 644 + 1765(2x – 6) + 556(3x2 – 30x + 62) + 45(4x3 – 84x2 + 514x – 878) + 5x4 – 176x3 + 2115x2 – 9980x + 14984 f ″(x) = 3530 + 556(6x – 30) + 45(12x2 – 168x + 514) + 20x3 – 528x2 + 4230x – 9980 f ″′(x) = 3336 + 45(24x – 168) + 60x2 – 1056x + 4230 = 60x2 + 24x + 6 where x = 5, f ″′ (5) = 60(5)2 + 24(5) + 6 = 1626 Example 13. Find f ′(4) from the following data: x: 0 2 5 1 f(x): 0 8 125 1. Sol. Though this problem can be solved by Newton’s divided difference formula, we are giving here, as an alternative, Lagrange’s method. Lagrange’s polynomial, in this case, is given by f(x) = ( )( )( ) ( )( )( ) ( ) ( )( )( ) ( )( )( ) x x x x x x − − − − − − + − − − − − − 2 5 1 0 2 0 5 0 1 0 0 5 1 2 0 2 5 2 1 (8) + ( )( )( ) ( )( )( ) ( ) ( )( )( ) ( )( )( ) x x x x x x − − − − − − + − − − − − − 0 2 1 5 0 5 2 5 1 125 0 2 5 1 0 1 2 1 5 (1) = – 4 3 (x3 – 6x2 + 5x) + 25 12 (x3 – 3x2 + 2x) + 1 4 (x3 – 7x2 + 10x) = x3 ∴ f ′(x) = 3x2 when x = 4, f ′(4) = 3(4)2 = 48 Example 14. State the three different finite difference approximations to the first derivative f ′(x0) together with the order of their truncation errors. Derive the forward difference approximation and its leading error term. Sol. (i) Newton’s forward difference approximation is given by f(x) = f0 + u Δf0 + u u ( ) − 1 2 Δ2f0 where u = x x h − 0 and E = 1 6 u(u – 1) (u – 2) h3 f ′″(ξ)
  • 432. NUMERICAL INTEGRATION AND DIFFERENTIATION 419 We have, f ′(x) = df du du dx . = 1 h Δ Δ f u f 0 2 0 1 2 2 1 + − L NM O QP ( ) and | E′(x0) | = | E′(u = 0) | ≤ h2 3 M3 where M3 = max| ( )| ′′′ ≤ ≤ f x x x x 0 2 (ii) Newton’s backward difference approximation is given by f(x) = f2 + u ∇f2 + 1 2 u(u + 1) ∇2 f2 where u = x x h − 2 and E = 1 6 u (u + 1) (u + 2) h3 f ′″(ξ) We have, f ′(x) = 1 1 2 2 1 2 2 2 h f u f ∇ + + ∇ L NM O QP ( ) and | E′(x2) | = | E′ (u = 0) | ≤ h2 3 M3 (iii) Central difference approximation is given by f(x) = f0 + u 2 (δf1/2 + δf–1/2) where u = x x h − 0 . We have f ′(x) = 1 2h (δf1/2 + δf–1/2) = 1 2h [(f1 – f0) + (f0 – f–1)] = 1 2h (f1 – f–1) and | E′(x) | ≤ h2 6 M3.
  • 433. 420 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 5.1 1. Given that x: 1.0 1.1 1.2 1.3 1.4 1.5 1.6 y: 7.989 8.403 8.781 9.129 9.451 9.750 10.031 Find dy dx and d y dx 2 2 at (i) x = 1.1 (ii) x = 1.6. 2. Find first and second derivatives of the function tabulated below at x = 0.6 x: 0.4 0.5 0.6 0.7 0.8 y: 1.5836 1.7974 2.0442 2.3275 2.6511. 3. Find y′(0) and y″(0) from the given table: x: 0 1 2 3 4 5 y: 4 8 15 7 6 2 4. Find y′(1.5) and y″(1.5) from the following table: x: 1.5 2.0 2.5 3 3.5 4 f(x): 3.375 7 13.625 24 38.875 59. 5. Given the following table of values of x and y: x: 1 1.05 1.1 1.15 1.2 1.25 1.30 y: 1 1.0247 1.0488 1.0723 1.0954 1.1180 1.1401 Find dy dx and d y dx 2 2 at (i) x = 1 (ii) x = 1.25 (iii) x = 1.15. 6. Find y′(4) from the given table: x: 1 2 4 8 10 y: 0 1 5 21 27. 7. Find the numerical value of y′(10°) for y = sin x given that: sin 0° = 0.000, sin 10° = 0.1736, sin 20° = 0.3420, sin 30° = 0.5000, sin 40° = 0.6428. 8. Find d dx ( ) J0 at x = 0.1 from the following table: x: 0.0 0.1 0.2 0.3 0.4 J0(x): 1 0.9975 0.99 0.9776 0.9604. 9. Find the first and second derivatives for the function tabulated below at the point x = 3.0: x: 3 3.2 3.4 3.6 3.8 4.0 y: – 14 – 10.032 – 5.296 0.256 6.672 14. 10. (i) A slider in a machine moves along a fixed straight rod. Its distance x cm along the rod is given below for various values of the time t seconds. Find the velocity of the slider and its acceleration when t = 0.3 second.
  • 434. NUMERICAL INTEGRATION AND DIFFERENTIATION 421 t: 0 0.1 0.2 0.3 0.4 0.5 0.6 x: 30.13 31.62 32.87 33.64 33.95 33.81 33.24. (ii) A slider in a machine moves along a fixed straight rod. Its distance x(in cm) along the rod is given at various times t (in secs). t: 0 0.1 0.2 0.3 0.4 0.5 0.6 x: 30.28 31.43 32.98 33.54 33.97 33.48 32.13 Evaluate dx dt at t = .1 and at t = .5. 11. Using Newton’s divided difference formula, find f ′(10) from the following data: x: 3 5 11 27 34 f(x): – 13 23 899 17315 35606 12. From the table below, for what value of x, y is minimum? Also find this value of y x: 3 4 5 6 7 8 y: 0.205 0.240 0.259 0.262 0.250 0.224. 13. Given the following table of values, find f ′(8): x: 6 7 9 12 f(x): 1.556 1.690 1.908 2.158. 14. Find the minimum value of y from the following table: x: 0.2 0.3 0.4 0.5 0.6 0.7 y: 0.9182 0.8975 0.8873 0.8862 0.8935 0.9086 15. Prove that d dx y h x ( ) = 1 (yx+h – yx–h) – 1 2h (yx+2h – yx–2h) + 1 3h (yx+3h – yx–3h) – ... Hint: R.H.S. = 1 E 1 E E D 1 1 1 h y h y y x x x log log ( ) + + F HG I KJ = F HG I KJ = L N MM O Q PP − 16. Find f ′(6) from the following table: x: 0 1 3 4 5 7 9 f(x): 150 108 0 – 54 – 100 – 144 – 84 17. Take 10 figure logarithm to base 10 from x = 300 to x = 310 by unit increments. Calculate the first derivative of log10 x when x = 310. 18. Given the following table: x: 1 1.05 1.1 1.15 1.2 1.25 1.3 f(x) = x : 1 1.0247 1.04881 1.07238 1.09544 1.11803 1.14014 Apply the above results to find f ′(1), f ″(1) and f ″′(1). 19. The following table gives values of pressure P and specific volume V of saturated steam: P: 105 42.7 25.3 16.7 13 V: 2 4 6 8 10
  • 435. 422 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Find (a) the rate of change of pressure with respect to volume at V = 2 (b) the rate of change of volume with respect to pressure at P = 105. 20. y is a function of x satisfying the equation xy″ + ay′ + (x – b) y = 0, where a and b are integers. Find the values of constants a and b if y is given by the following table: x: 0.8 1 1.2 1.4 1.6 1.8 2 2.2 y: 1.73036 1.95532 2.19756 2.45693 2.73309 3.02549 2.3333 3.65563. 5.5 ERRORS IN NUMERICAL DIFFERENTIATION In numerical differentiation, the error in the higher order derivatives occurs due to the fact that, although the tabulated function and its approximating polynomial would agree at the set of data points, their slopes at these points may vary considerably. Numerical differentiation is, therefore, an unsatisfactory process and should be used only in rare cases. The numerical computation of derivatives involves two types of errors: truncation errors and rounding errors. The truncation error is caused by replacing the tabulated function by means of an interpolating polynomial. The truncation error in the first derivative = 1 6 2 3 2 3 1 h y y Δ Δ − − + . The truncation error in the second derivative = 1 12 2 4 2 h y | | Δ − . The rounding error is proportional to 1 h in the case of the first derivatives, while it is proportional to 1 2 h in the case of the second derivatives, and so on. The maximum rounding error in the first derivative = 3 2 ε h The maximum rounding error in the second derivative = 4 2 ε h where ε is the maximum error in the value of yi. Example. Assuming that the table of values given in Example 6 and the function values are correct to the accuracy given, estimate the errors in dy dx at x = 1.6.
  • 436. NUMERICAL INTEGRATION AND DIFFERENTIATION 423 Sol. Since the values are correct to four decimals, it follows that ε = 0.5 × 10–4 Truncation error = 1 6 2 1 2 3 1 3 0 h y y Δ Δ − + = + F HG I KJ 1.2 0.0361 0.0441 | See difference table in Example 6 = 0.03342 Rounding error = 3 2 ε h = × × × − 3 0.5 10 2 0.2 4 = 0.00038. 5.6 NUMERICAL INTEGRATION Given a set of tabulated values of the integrand f(x), determining the value of x xn f x dx 0 z ( ) is called numerical integration. The given interval of integration is subdivided into a large number of subintervals of equal width h and the function tabulated at the points of subdivision is replaced by any one of the interpolating polynomials like Newton-Gregory’s, Stirling’s, Bessel’s over each of the subintervals and the integral is evaluated. There are several formulae for numerical integration which we shall derive in the sequel. Y O x0 y0 y1 y2 yn x + h 0 x + 2h 0 x + nh 0 X y = f(x) 5.7 NEWTON-COTE’S QUADRATURE FORMULA Let I = y dx a b z , where y takes the values y0, y1, y2, ......., yn for x = x0, x1, x2, ......, xn.
  • 437. 424 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Let the interval of integration (a, b) be divided into n equal sub-intervals, each of width h = b a n − so that x0 = a, x1 = x0 + h, x2 = x0 + 2h, ......., xn = x0 + nh = b. ∴ I = f x dx x x nh ( ) 0 0 + z Since any x is given by x = x0 + rh and dx = hdr ∴ I = h f x rh dr n ( ) 0 0 + z = h y r y r r y r r r y dr n 0 0 2 0 3 0 0 1 2 1 2 3 + + − + − − + L NM O QP z Δ Δ Δ ( ) ! ( )( ) ! ....... [by Newton’s forward interpolation formula] = h ry r y r r y 0 2 0 3 2 2 0 2 1 2 3 2 + + − F HG I KJ L N MM Δ Δ + − + F HG I KJ + O Q PP 1 6 4 4 3 2 3 0 0 r r r y n Δ ....... = nh y n y n n y n n y 0 0 2 0 2 3 0 2 2 3 12 2 24 + + − + − + L NM O QP Δ Δ Δ ( ) ( ) ........ (49) This is a general quadrature formula and is known as Newton-Cote’s quadrature formula. A number of important deductions viz. Trapezoidal rule, Simpson’s one-third and three-eighth rules, Weddle’s rule can be immediately deduced by putting n = 1, 2, 3, and 6, respectively, in formula (49). 5.8 TRAPEZOIDAL RULE (n = 1) Putting n = 1 in formula (49) and taking the curve through (x0, y0) and (x1, y1) as a polynomial of degree one so that differences of an order higher than one vanish, we get f x dx h y y h y y y h y y x x h ( ) [ ( )] ( ) = + F HG I KJ = + − = + + z 0 0 0 1 0 0 1 1 2 2 2 2 0 0 Δ
  • 438. NUMERICAL INTEGRATION AND DIFFERENTIATION 425 Similarly, for the next sub-interval (x0 + h, x0 + 2h), we get f x dx h y y x h x h ( ) ( ) , ......, = + + + z 2 1 2 2 0 0 f x dx h y y n n x n h x nh ( ) ( ) ( ) = + − + − + z 2 1 1 0 0 Adding the above integrals, we get f x dx h y y y y y n n x x nh ( ) [( ) ( ...... )] = + + + + + − + z 2 2 0 1 2 1 0 0 which is known as Trapezoidal rule. By increasing the number of subintervals, thereby making h very small, we can improve the accuracy of the value of the given integral. 5.9 SIMPSON’S ONE-THIRD RULE (n = 2) Putting n = 2 in formula (49) and taking the curve through (x0, y0), (x1, y1) and (x2, y2) as a polynomial of degree two so that differences of order higher than two vanish, we get f x dx h y y y x x h ( ) = + + L NM O QP + z 2 1 6 0 0 2 0 2 0 0 Δ Δ = 2 6 6 2 0 1 0 2 1 0 h y y y y y y [6 ( ) ( )] + − + − + = h y y y 3 4 0 1 2 ( ) + + Similarly, f x dx h x h x h ( ) = + + z 3 0 0 2 4 (y2 + 4y3 + y4), ...... , f x dx h y y y n n n x n h x nh ( ) ( ) ( ) = + + − − + − + z 3 4 2 1 2 0 0 Adding the above integrals, we get f x dx h x x nh ( ) = + z 3 0 0 [(y0 + yn) + 4(y1 + y3 + ... + yn–1) + 2(y2 + y4 + ... + yn–2)] which is known as Simpson’s one-third rule.
  • 439. 426 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES While using this formula, the given interval of integration must be divided into an even number of sub-intervals, since we find the area over two sub-intervals at a time. 5.10 SIMPSON’S THREE-EIGHTH RULE (n = 3) Putting n = 3 in formula (49) and taking the curve through (x0, y0), (x1, y1), (x2, y2), and (x3, y3) as a polynomial of degree three so that differences of order higher than three vanish, we get f x dx h y y y y x x h ( ) = + + + F HG I KJ + z 3 3 2 3 4 1 8 0 0 2 0 3 0 3 0 0 Δ Δ Δ = 3 8 h [8y0 + 12(y1 – y0) + 6(y2 – 2y1 + y0) + (y3 – 3y2 + 3y1 – y0)] = 3 8 h [y0 + 3y1 + 3y2 + y3] Similarly, f x dx h x h x h ( ) = + + z 3 8 0 0 3 6 [y3 + 3y4 + 3y5 + y6], ... f x dx h x n h x h ( ) ( = + − + z 3 8 0 0 3) 6 [yn–3 + 3yn–2 + 3yn–1 + yn] Adding the above integrals, we get f x dx h x x nh ( ) = + z 3 8 0 0 [(y0 + yn) + 3(y1 + y2 + y4 + y5 + ..... + yn–2 + yn–1) + 2(y3 + y6 + ...... + yn–3)] which is known as Simpson’s three-eighth rule. While using this formula, the given interval of integration must be divided into sub-intervals whose number n is a multiple of 3. 5.11 BOOLE’S RULE Putting n = 4 in formula (49) and neglecting all differences of order higher than four, we get
  • 440. NUMERICAL INTEGRATION AND DIFFERENTIATION 427 x x h f x dx 0 0 4 + z ( ) = h y r y r r y r r r y 0 0 2 0 3 0 0 4 1 2 1 2 3 + + − + − − L NM z Δ Δ Δ ( ) ! ( )( ) ! + − − − O QP r r r r y dr ( )( )( ) ! 1 2 3 4 4 0 Δ | By Newton’s forward interpolation formula = 4h y n y n n y n n y 0 0 2 0 2 3 0 2 2 3 12 2 24 + + − + − L N MM Δ Δ Δ ( ) ( ) + − + − F HG I KJ O Q PP n n n n y 4 3 2 4 0 0 4 5 3 2 11 3 3 4 Δ ! = 4 2 5 3 3 2 7 90 0 0 2 0 3 0 4 0 h y y y y y + + + + L NM O QP Δ Δ Δ Δ = 2 45 h (7y0 + 32y1 + 12y2 + 32y3 + 7y4) Similarly, f x dx h x h x h ( ) 0 0 4 8 2 45 + + z = (7y4 + 32y5 + 12y6 + 32y7 + 7y8) and so on. Adding all these integrals from x0 to x0 + nh, where n is a multiple of 4, we get f x dx h x x nh ( ) = + z 2 45 0 0 [7y0 + 32y1 + 12y2 + 32y3 + 14y4 + 32 y5 + 12y6 + 32y7 + 14y8 + ......] This is known as Boole’s rule. While applying Boole’s rule, the number of sub-intervals should be taken as a multiple of 4. 5.12 WEDDLE’S RULE (n = 6) Putting n = 6 in formula (49) and neglecting all differences of order higher than six, we get
  • 441. 428 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES x x h f x dx h y r y r r y r r r y 0 0 6 0 0 2 0 3 0 0 6 1 2 1 2 3 + z z = + + − + − − L NM ( ) ( ) ! ( )( ) ! Δ Δ Δ + − − − + − − − − r r r r y r r r r r y ( )( )( ) ! ( )( )( )( ) ! 1 2 3 4 1 2 3 4 5 4 0 5 0 Δ Δ + − − − − − O QP r r r r r r y dr ( )( )( )( )( ) ! 1 2 3 4 5 6 6 0 Δ = h ry r y r r y r r r y 0 2 0 3 2 2 0 4 3 2 3 0 2 1 2 3 2 1 6 4 + + − F HG I KJ + − + F HG I KJ L N MM Δ Δ Δ + − + − F HG I KJ 1 24 5 3 2 11 3 3 5 4 3 2 4 0 r r r r y Δ + − + − + F HG I KJ 1 120 6 2 35 4 50 3 12 6 5 4 3 2 5 0 r r r r r y Δ + − + − + − F HG I KJ O Q PP 1 720 7 5 2 17 225 4 274 3 60 7 6 5 4 3 2 6 0 0 6 r r r r r r y Δ = 6h y y y y y 0 0 2 0 3 0 4 0 3 9 2 4 41 20 + + + + L NM Δ Δ Δ Δ + + O QP 11 20 41 840 5 0 6 0 Δ Δ y y = 6 20 20 60 90 80 41 0 0 2 0 3 0 4 0 h y y y y y + + + + L N MM Δ Δ Δ Δ + + O QP 11 41 42 5 0 6 0 Δ Δ y y = 3 10 h [20y0 + 60(y1 – y0) + 90(y2 – 2y1 + y0) + 80(y3 – 3y2 + 3y1 – y0) + 41(y4 – 4y3 + 6y2 – 4y1 + y0) + 11 (y5 –5y4 + 10y3 – 10y2 + 5y1 – y0) + (y6 – 6y5 + 15y4 – 20y3 + 15y2 – 6y1 + y0)] ∵ 41 42 1 ~ − L NM O QP
  • 442. NUMERICAL INTEGRATION AND DIFFERENTIATION 429 = 3 10 h [y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6] Similarly, f x dx h x h x h ( ) = + + z 3 10 0 0 6 12 [y6 + 5y7 + y8 + 6y9 + y10 + 5y11 + y12] ................................................................................................... ................................................................................................... f x dx h x n h x nh ( ) ( ) = + − + z 3 10 0 0 6 [yn–6 + 5yn–5 + yn–4 + 6yn–3 + yn–2 + 5yn–1 + yn] Adding the above integrals, we get f x dx h x x nh ( ) = + z 3 10 0 0 [y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + 2y6 + 5y7 + y8 + 6y9 + y10 + 5y11 + 2y12 + ......] which is known as Weddle’s rule. Here n must be a multiple of 6. 5.13 ALGORITHM OF TRAPEZOIDAL RULE Step 01. Start of the program. Step 02. Input Lower limit a Step 03. Input Upper Limit b Step 04. Input number of sub intervals n Step 05. h=(b-a)/n Step 06. sum=0 Step 07. sum=fun(a)+fun(b) Step 08. for i=1; in; i++ Step 09. sum +=2*fun(a+i) Step 10. End Loop i Step 11. result =sum*h/2; Step 12. Print Output result Step 13. End of Program Step 14. Start of Section fun Step 15. temp = 1/(1+(x*x)) Step 16. Return temp Step 17. End of Section fun.
  • 443. 430 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 5.14 FLOW-CHART FOR TRAPEZOIDAL RULE START STOP Define function y(x) Get values x , x , n 0 n h = (x – x )/n n 0 s = y(x ) + y(xn) 0 Loop for i = 1 to n – 1 s + = 2 * y * (x + i * h) 0 End loop(i) t = (h/2) * s Print ‘‘soln.’’, t
  • 444. NUMERICAL INTEGRATION AND DIFFERENTIATION 431 /* *********************************************************** 5.15 PROGRAM TO IMPLEMENT TRAPEZOIDAL METHOD OF NUMERICAL INTEGRATION *********************************************************** */ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... Function Prototype Declaration float fun(float); //... Main Execution Thread void main() { //... Variable Declaration Field //... Floating Type float result=1; float a,b; float h,sum; //... Integer Type int i,j; int n; //... Invoke Clear Screen Function clrscr(); //... Input Section //... Input Range printf(“nn Enter the range - ”); printf(“nn Lower Limit a - ”); scanf(“%f” ,a);
  • 445. 432 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(“nn Upper Limit b - ); scanf(“%f” ,b); //... Input Number of subintervals printf(“nn Enter number of subintervals - ”); scanf(“%d” ,n); //... Calculation and Processing Section h=(b-a)/n; sum=0; sum=fun(a)+fun(b); for(i=1;in;i++) { sum+=2*fun(a+i); } result=sum*h/2; //... Output Section printf(“nnnn Value of the integral is %6.4ft”,result); //...Invoke User Watch Halt Function printf(“nnn Press Enter to Exit”); getch(); } //... Termination of Main Execution Thread //... Function Body float fun(float x) { float temp; temp = 1/(1+(x*x)); return temp; } //... Termination of Function Body
  • 446. NUMERICAL INTEGRATION AND DIFFERENTIATION 433 5.16 OUTPUT Enter the range - Lower Limit a - 0 Upper Limit b - 6 Enter number of subintervals - 6 Value of the integral is 1.4108 Press Enter to Exit 5.17 ALGORITHM OF SIMPSON’S 3/8th RULE Step 01. Start of the program. Step 02. Input Lower limit a Step 03. Input Upper limit b Step 04. Input number of sub itervals n Step 05. h = (b – a)/n Step 06. sum = 0 Step 07. sum = fun(a) + fun (b) Step 08. for i = 1; i n; i++ Step 09. if i%3=0: Step 10. sum + = 2*fun(a + i*h) Step 11. else: Step 12. sum + = 3*fun(a+(i)*h) Step 13. End of loop i Step 14. result = sum*3*h/8 Step 15. Print Output result Step 16. End of Program Step 17. Start of Section fun Step 18. temp = 1/(1+(x*x)) Step 19. Return temp Step 20. End of section fun
  • 447. 434 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 5.18 FLOW-CHART OF SIMPSON’S 3/8th RULE START STOP Define fn. f(x) Get values x , x , n 0 n h = (x – x )/n n 0 Sum = 0 Sum = f(a) + f(b) Loop for i = 1 to n Sum + = 2 * f(a + i * h) Sum + = 3 * f(a + i * h) End loop i Print sum Yes No Is i% 3 = 0
  • 448. NUMERICAL INTEGRATION AND DIFFERENTIATION 435 /************************************************************* 5.19 PROGRAM TO IMPLEMENT SIMPSON’S 3/8th METHOD OF NUMERICAL INTEGRATION ***************************************************************/ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... Function Prototype Declaration float fun(float); //... Main Execution Thread void main() { //... Variable Declaration Field //... Floating Type float result=1; float a,b; float h,sum; //...Integer Type int i,j; int n; //...Invoke Clear Screen Function clrscr(); //...Input Section //...Input Range printf(nn Enter the range - ); printf(nn Lower Limit a - ); scanf(%f ,a);
  • 449. 436 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(nn Upper Limit b - ); scanf(%f ,b); //...Input Number of Subintervals printf(nn Enter number of subintervals - ); scanf(%d ,n); //...Calculation and Processing Section h=(b-a)/n; sum=0; sum=fun(a)+fun(b); for(i=1;in;i++) { if(i%3==0) { sum+=2*fun(a+i*h) } else { sum+=3*fun(a+(i)*h); } } result=sum*3*h/8; //... Output Section printf(nnnn Value of the integral is %6.4ft,result); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch(); } //... Termination of Main Execution Thread //... Function Body
  • 450. NUMERICAL INTEGRATION AND DIFFERENTIATION 437 float fun(float x) { float temp; temp=1/(1+(x*x)); return temp; } //... Termination of Function Body 5.20 OUTPUT Enter the range - Lower Limit a - 0 Upper Limit b - 6 Enter number of subintervals - 6 Value of the integral is 1.3571 Press Enter to Exit 5.21 ALGORITHM OF SIMPSON’S 1/3rd RULE Step 01. Start of the program. Step 02. Input Lower limit a Step 03. Input Upper limit b Step 04. Input number of subintervals n Step 05. h=(b–a)/n Step 06. sum=0 Step 07. sum=fun(a)+4*fun(a+h)+fun(b) Step 08. for i=3; in; i + = 2 Step 09. sum + = 2*fun(a+(i – 1)*h) + 4*fun(a+i*h) Step 10. End of loop i Step 11. result=sum*h/3 Step 12. Print Output result Step 13. End of Program Step 14. Start of Section fun Step 15. temp = 1/(1+(x*x))
  • 451. 438 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Step 16. Return temp Step 17. End of Section fun 5.22 FLOW-CHART OF SIMPSON’S 1/3rd RULE START STOP Define fn y(x) Get values of x , x , n 0 n h = (x – x )/n n 0 s = y + y + 4y 0 n 1 Loop for i = 3 to n – 1 step 2 s + = 4 * y + 2 * y i i + 1 End loop (i) P = s * (h/3) Print ''solution'', P
  • 452. NUMERICAL INTEGRATION AND DIFFERENTIATION 439 /* *********************************************************** 5.23 PROGRAM TO IMPLEMENT SIMPSON’S 1/3rd METHOD OF NUMERICAL INTEGRATION *********************************************************** */ //... HEADER FILES DECLARATION # include stdio.h # include conio.h # include math.h # include process.h # include string.h //... Function Prototype Declaration float fun(float); //... Main Execution Thread void main() { //...Variable Declaration Field //... Floating Type float result=1; float a,b; float h,sum; //... Integer Type int i,j; int n; //... Invoke Clear Screen Function clrscr(); //... Input Section //...Input Range printf(nn Enter the range - );
  • 453. 440 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES printf(nn Lower Limit a - ); scanf(%f ,a); printf(nn Upper Limit b - ); scanf(%f ,b); //... Input Number of Subintervals printf(nn Enter number of subintervals - ); scanf(%d,n); //... Calculation and Processing Section h=(b-a)/n; sum=0; sum=fun(a)+4*fun(a+h)fun(b); for(i=3;in;i+=2) { sum+=2*fun(a+(i-1)*h)+4*fun(a+i*h); } result=sum*h/3; //... Output Section printf(nnnn Value of the integral is %6.4ft,result); //... Invoke User Watch Halt Function printf(nnn Press Enter to Exit); getch(); } //... Termination of Main Execution Thread //... Function Body float fun(float x) { float temp; temp=1/(1+(x*x)); return temp; } //... Termination of Function Body
  • 454. NUMERICAL INTEGRATION AND DIFFERENTIATION 441 5.24 OUTPUT Enter the range - Lower Limit a - 0 Upper Limit b - 6 Enter number of subintervals - 6 Value of the integral is 1.3662 Press Enter to Exit EXAMPLES Example 1. Use Trapezoidal rule to evaluate x dx 3 0 1 z considering five sub- intervals. Sol. Dividing the interval (0, 1) into 5 equal parts, each of width h = 1 0 5 − = 0.2, the values of f(x) = x3 are given below: x: 0 0.2 0.4 0.6 0.8 1.0 f(x): 0 0.008 0.064 0.216 0.512 1.000 y0 y1 y2 y3 y4 y5 By Trapezoidal rule, we have x dx h 3 0 1 2 = z [(y0 + y5) + 2(y1 + y2 + y3 + y4)] = 0.2 2 [(0 + 1) + 2(0.008 + 0.064 + 0.216 + 0.512)] = 0.1 × 2.6 = 0.26. Example 2. Evaluate dx 1 x2 0 1 + z using (i) Simpson’s 1 3 rule taking h = 1 4 (ii) Simpson’s 3 8 rule taking h = 1 6 (iii) Weddle’s rule taking h = 1 6 Hence compute an approximate value of π in each case.
  • 455. 442 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. (i) The values of f(x) = 1 1 2 + x at x = 0, 1 4 2 4 3 4 1 , , , are given below: x: 0 1 4 1 2 3 4 1 f(x): 1 16 17 0.8 0.64 0.5 y0 y1 y2 y3 y4 By Simpson’s 1 3 rule, dx x h 1 3 2 0 1 + = z [(y0 + y4) + 4(y1 + y3) + 2y2] = 1 12 1 4 16 17 2 ( ) ( ) + + + R S T U V W+ L NM O QP 0.5 .64 0.8 = 0.785392156 Also dx x x 1 1 4 2 0 1 0 1 + = L N MM O Q PP = = z tan tan –1 –1 π ∴ π 4 ~ – 0.785392156 ⇒ π ~ – 3.1415686 (ii) The values of f(x) = 1 1 2 + x at x = 0, 1 6 2 6 3 6 4 6 5 6 1 , , , , , are given below: x: 0 1 6 2 6 3 6 4 6 5 6 1 f(x): 1 36 37 9 10 4 5 9 13 36 61 1 2 y0 y1 y2 y3 y4 y5 y6 By Simpson’s 3 8 rule, 0 1 2 1 3 8 z + = dx x h [(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
  • 456. NUMERICAL INTEGRATION AND DIFFERENTIATION 443 = 3 1 6 8 1 1 2 3 36 37 9 10 9 13 36 61 2 4 5 F HG I KJ + F HG I KJ + + + + R S T U V W+ F HG I KJ L NM O QP = 0.785395862 Also, 0 1 2 1 4 z + = dx x π ∴ π 4 = 0.785395862 ⇒ π = 3.141583 (iii) By Weddle’s rule, using the values as in (ii), 0 1 2 1 3 10 z + = dx x h (y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6) = 3 1 6 10 1 5 36 37 9 10 6 4 5 9 13 5 36 61 1 2 F HG I KJ + F HG I KJ + + F HG I KJ + + F HG I KJ + R S T U V W = 0.785399611 Since 0 1 2 1 4 z + = dx x π ∴ π 4 = 0.785399611 ⇒ π = 3.141598. Example 3. Evaluate 0 6 2 dx 1 x z + by using (i) Simpson’s one-third rule (ii) Simpson’s three-eighth rule (iii) Trapezoidal rule (iv) Weddle’s rule.
  • 457. 444 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Divide the interval (0, 6) into six parts each of width h = 1. The values of f(x) = 1 1 2 + x are given below: x: 0 1 2 3 4 5 6 f(x): 1 0.5 0.2 0.1 1 17 1 26 1 37 y0 y1 y2 y3 y4 y5 y6 (i) By Simpson’s one-third rule, 0 6 2 1 3 z + = dx x h [(y0 + y6) + 4(y1 + y3 + y5) + 2(y2 + y4)] = 1 3 1 1 37 4 2 1 17 + F HG I KJ + + + F HG I KJ + + F HG I KJ L NM O QP 0.5 0.1 1 26 0.2 = 1.366173413. (ii) By Simpson’s three-eighth rule, 0 6 2 1 3 8 z + = dx x h [(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3] = 3 8 1 1 37 3 1 17 1 26 2 + F HG I KJ + + + + F HG I KJ + L NM O QP .5 .2 .1 ( ) = 1.357080836. (iii) By Trapezoidal rule, 0 6 2 1 2 z + = dx x h [(y0 + y6) + 2(y1 + y2 + y3 + y4 + y5)] = 1 2 1 1 37 2 1 17 1 26 + F HG I KJ + + + + + F HG I KJ L NM O QP .5 .2 .1 = 1.410798581. (iv) By Weddle’s rule, 0 6 2 1 3 10 z + = dx x h [y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6]
  • 458. NUMERICAL INTEGRATION AND DIFFERENTIATION 445 = 3 10 1 5 5 1 26 1 37 + + + F HG I KJ + L NM O QP ( ) .5 .2 + 6(.1) + 1 17 = 1.373447475. Example 4. The speed, v meters per second, of a car, t seconds after it starts, is shown in the following table: t 0 12 24 36 48 60 72 84 96 108 120 v 0 3.60 10.08 18.90 21.60 18.54 10.26 5.40 4.50 5.40 9.00 Using Simpson’s rule, find the distance travelled by the car in 2 minutes. Sol. If s meters is the distance covered in t seconds, then ds dt = v ∴ s v dt t t L NM O QP = = = z 0 0 120 120 since the number of sub-intervals is 10 (even). Hence, by using Simpson’s 1 3 rd rule, 0 120 3 z = v dt h [(v0 + v10) + 4(v1 + v3 + v5 + v7 + v9) + 2(v2 + v4 + v6 + v8)] = 12 3 [(0 + 9) + 4(3.6 + 18.9 + 18.54 + 5.4 + 5.4) + 2(10.08 + 21.6 + 10.26 + 4.5)] = 1236.96 meters. Hence, the distance travelled by car in 2 minutes is 1236.96 meters. Example 5. Evaluate 0.6 2 y dx z , where y is given by the following table: x: 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 y: 1.23 1.58 2.03 4.32 6.25 8.36 10.23 12.45. Sol. Here the number of subintervals is 7, which is neither even nor a multiple of 3. Also, this number is neither a multiple of 4 nor a multiple of 6, hence using Trapezoidal rule, we get
  • 459. 446 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 0.6 2 2 z = y dx h [(y0 + y7) + 2(y1 + y2 + y3 + y4 + y5 + y6)] = 0.2 2 [(1.23 + 12.45) + 2(1.58 + 2.03 + 4.32 + 6.25 + 8.36 + 10.23)] | Here h = 0.2 = 7.922. Example 6. Find 1 11 f(x) dx z , where f(x) is given by the following table, using a suitable integration formula. x: 1 2 3 4 5 6 7 8 9 10 11 f(x): 543 512 501 489 453 400 352 310 250 172 95 Sol. Since the number of subintervals is 10 (even) hence we shall use Simpson’s 1 3 rd rule. f x dx h ( ) 1 11 3 z = [(y0 + y10) + 4(y1 + y3 + y5 + y7 + y9) + 2(y2 + y4 + y6 + y8)] = 1 3 [(543 + 95) + 4(512 + 489 + 400 + 310 + 172) + 2(501 + 453 + 352 + 250)] = 1 3 [638 + 7532 + 3112] = 3760.67. Example 7. Evaluate dx 1 x 0 1 + z by dividing the interval of integration into 8 equal parts. Hence find loge 2 approximately. Sol. Since the interval of integration is divided into an even number of subintervals, we shall use Simpson’s one-third rule. Here, y = 1 1 + x = f(x) y0 = f(0) = 1 1 0 + = 1, y1 = f 1 8 1 1 1 8 8 9 F HG I KJ = + = , y2 = f 2 8 4 5 F HG I KJ = y3 = f 3 8 8 11 F HG I KJ = , y4 = f 4 8 2 3 F HG I KJ = , y5 = f 5 8 8 13 F HG I KJ =
  • 460. NUMERICAL INTEGRATION AND DIFFERENTIATION 447 y6 = f 6 8 4 7 F HG I KJ = , y7 = f 7 8 8 15 F HG I KJ = and y8 = f(1) = 1 2 Hence the table of values is x: 0 1 8 2 8 3 8 4 8 5 8 6 8 7 8 1 y: 1 8 9 4 5 8 11 2 3 8 13 4 7 8 15 1 2 y0 y1 y2 y3 y4 y5 y6 y7 y8 By Simpson’s 1 3 rd rule, 0 1 1 3 z + = dx x h [(y0 + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)] = 1 24 1 1 2 4 8 9 8 11 8 13 8 15 2 4 5 2 3 4 7 + F HG I KJ + + + + F HG I KJ + + + F HG I KJ L NM O QP | Here h = 1/8 = 0.69315453 Since, 0 1 0 1 1 1 z + = + L NMM O QPP dx x x e log ( ) = loge 2 ∴ loge 2 = 0.69315453. Example 8. Find, from the following table, the area bounded by the curve and the x-axis from x = 7.47 to x = 7.52. x: 7.47 7.48 7.49 7.50 7.51 7.52 f(x): 1.93 1.95 1.98 2.01 2.03 2.06. Sol. We know that Area = 7.47 7.52 z f x dx ( ) with h = 0.01, the trapezoidal rule gives, Area = .01 2 [(1.93 + 2.06) + 2(1.95 + 1.98 + 2.01 + 2.03)] = 0.09965.
  • 461. 448 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 9. Use Simpson’s rule for evaluating − z0.6 0.3 f(x) dx from the table given below: x: – 0.6 – 0.5 – 0.4 – 0.3 – 0.2 – 0.1 0 .1 .2 .3 f(x): 4 2 5 3 – 2 1 6 4 2 8 Sol. Since the number of subintervals is 9(a multiple of 3), we will use Simpson’s 3/8th rule here. ∴ − z = 0.6 0.3 .1 f x dx ( ) ( ) 3 8 [(4 + 8) + 3{2 + 5 + (– 2) + 1 + 4 + 2} + 2(3 + 6)] = 2.475. Example 10. Evaluate 1 2 1 2 x e dx z − using four intervals. Sol. The table of values is: x: 1 1.25 1.5 1.75 2 y = e–x/2: .60653 .53526 .47237 .41686 .36788 y0 y1 y2 y3 y4 Since we have four (even) subintervals here, we will use Simpson’s 1 3 rd rule. ∴ 1 2 1 2 3 z − = e dx h x [(y0 + y4) + 4(y1 + y3) + 2y2] = .25 3 [(.60653 + .36788) + 4(.53526) + .41686) + 2(.47237)] = 0.4773025. Example 11. Find e 1 x dx x 0 6 + z approximately using Simpson’s 3 8 th rule on integration. Sol. Divide the given integral of integration into 6 equal subintervals, the arguments are 0, 1, 2, 3, 4, 5, 6; h = 1. f(x) = e x x 1+ ; y0 = f(0) = 1
  • 462. NUMERICAL INTEGRATION AND DIFFERENTIATION 449 y1 = f(1) = e 2 , y2 = f(2) = e2 3 , y3 = f(3) = e3 4 , y4 = f(4) = e4 5 , y5 = f(5) = e5 6 , y6 = f(6) = e6 7 The table is as below: x: 0 1 2 3 4 5 6 y: 1 e 2 e2 3 e3 4 e4 5 e5 6 e6 7 y0 y1 y2 y3 y4 y5 y6 Applying Simpson’s three-eighth rule, we have 0 6 1 3 8 z + = e x dx h x [(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3] = 3 8 1 7 3 2 3 5 6 2 4 6 2 4 5 3 + F HG I KJ + + + + F HG I KJ + L N MM O Q PP e e e e e e = 3 8 [(1 + 57.6327) + 3(1.3591 + 2.463 + 10.9196 + 24.7355 + 2(5.0214)] = 70.1652. It is not possible to evaluate 0 6 x e 1 x dx z + by using usual calculus method. Numerical integration comes to our rescue in such situations. Example 12. A train is moving at the speed of 30 m/sec. Suddenly brakes are applied. The speed of the train per second after t seconds is given by Time (t): 0 5 10 15 20 25 30 35 40 45 Speed (v): 30 24 19 16 13 11 10 8 7 5 Apply Simpson’s three-eighth rule to determine the distance moved by the train in 45 seconds. Sol. If s meters is the distance covered in t seconds, then ds dt v = ⇒ s v dt t t L NM O QP = = = z 0 0 45 45 NOTE
  • 463. 450 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since the number of subintervals is 9 (a multiple of 3) hence by using Simpson’s 3 8 F HG I KJ th rule, 0 45 3 8 z = v dt h [(v0 + v9) + 3(v1 + v2 + v4 + v5 + v7 + v8) + 2(v3 + v6)] = 15 8 [(30 + 5) + 3(24 + 19 + 13 + 11 + 8 + 7) + 2(16 + 10)] = 624.375 meters. Hence the distance moved by the train in 45 seconds is 624.375 meters. Example 13. Evaluate 0 4 2 dx 1 x z + using Boole’s rule taking (i) h = 1 (ii) h = 0.5 Compare the results with the actual value and indicate the error in both. Sol. (i) Dividing the given interval into 4 equal subintervals (i.e., h = 1), the table is as follows: x: 0 1 2 3 4 y: 1 1 2 1 5 1 10 1 17 y0 y1 y2 y3 y4 using Boole’s rule, 0 4 2 45 z = y dx h [7y0 + 32y1 + 12y2 + 32y3 + 7y4] = 2 1 45 7 1 32 1 2 12 1 5 32 1 10 7 1 17 ( ) ( ) + F HG I KJ + F HG I KJ + F HG I KJ + F HG I KJ L NM O QP = 1.289412 (approx.) ∴ 0 4 2 1 z + dx x = 1.289412.
  • 464. NUMERICAL INTEGRATION AND DIFFERENTIATION 451 (ii) Dividing the given interval into 8 equal subintervals (i.e., h = 0.5), the table is as follows: x: 0 .5 1 1.5 2 2.5 3 3.5 4 y: 1 0.8 0.5 4 13 .2 4 29 .1 4 53 1 17 y0 y1 y2 y3 y4 y5 y6 y7 y8 using Boole’s rule, 0 4 z ydx = 2 45 7 32 12 32 7 0 1 2 3 4 h y y y y y [ ( ) ( ) ( ) ( ) ( ) + + + + + 7 32 12 32 7 4 5 6 7 8 ( ) ( ) ( ) ( ) ( )] y y y y y + + + + = 1 45 7 1 32 8 12 5 32 4 13 7 2 7 2 ( ) (. ) (. ) (. ) (. ) + + + F HG I KJ + + L NM + F HG I KJ + 32 4 29 12 1 (. ) + F HG I KJ + F HG I KJO QP 32 4 53 7 1 17 = 1.326373 ∴ 0 4 2 1 z + dx x = 1.326373 But the actual value is 0 4 2 1 z + dx x = tan− F HG I KJ 1 0 4 x = tan–1 (4) = 1.325818 Error in result I = 1325818 1289412 1325818 100 . . . − F HG I KJ × = 2.746% Error in result II = 1325818 1326373 1325818 100 . . . − F HG I KJ × = – 0.0419%. Example 14. A river is 80 m wide. The depth ‘y’ of the river at a distance ‘x’ from one bank is given by the following table: x: 0 10 20 30 40 50 60 70 80 y: 0 4 7 9 12 15 14 8 3
  • 465. 452 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Find the approximate area of cross-section of the river using (i) Boole’s rule. (ii) Simpson’s 1 3 rd rule. Sol. The required area of the cross-section of the river = 0 80 z y dx Here the number of sub intervals is 8. (i) By Boole’s rule, 0 80 2 45 z = y dx h [7y0 + 32y1 + 12y2 + 32y3 + 7y4 + 7y4 + 32y5 + 12y6 + 32y7 + 7y8] = 2 10 45 ( ) [7(0) + 32(4) + 12(7) + 32(9) + 7(12) + 7(12) + 32(15) + 12(14) + 32(8) + 7(3)] = 708 Hence the required area of the cross-section of the river = 708 sq. m. (ii) By Simpson’s 1 3 rd rule 0 80 3 z = y dx h [(y0 + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)] = 10 3 [(0 + 3) + 4(4 + 9 + 15 + 8) + 2(7 + 12 + 14)] = 710 Hence the required area of the cross-section of the river = 710 sq. m. Example 15. Evaluate 0.2 1.4 z (sin x – loge x + ex) dx approximately using Weddle’s rule correct to 4 decimals. Sol. Let f(x) = sin x – log x + ex. Divide the given interval of integration into 12 equal parts so that the arguments are: 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4.
  • 466. NUMERICAL INTEGRATION AND DIFFERENTIATION 453 The corresponding entries are y0 = f(0.2) = 3.0295, y1 = f(0.3) = 2.8494, y2 = f(0.4) = 2.7975, y3 = f(0.5) = 2.8213, y4 = f(0.6) = 2.8976, y5 = f(0.7) = 3.0147 y6 = f(0.8) = 3.1661, y7 = f(0.9) = 3.3483, y8 = f(1) = 3.5598, y9 = f(1.1) = 3.8001, y10 = f(1.2) = 4.0698, y11 = f(1.3) = 4.3705 y12 = f(1.4) = 4.7042 Now, by Weddle’s rule, 0.2 1.4 z = f x dx h ( ) 3 10 [y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6 + y6 + 5y7 + y8 + 6y9 + y10 + 5y11 + y12] = 3 10 (0.1)[3.0295 + 14.2470 + 2.7975 + 16.9278 + 2.8976 + 15.0735 + 3.1661 + 3.1661 + 16.7415 + 3.5598 + 22.8006 + 4.0698 + 21.8525 + 4.7042] = (0.03)[135.0335] = 4.051. Example 16. A solid of revolution is formed by rotating about x-axis, the lines x = 0 and x = 1 and a curve through the points with the following coordinates. x: 0 0.25 0.5 0.75 1 y: 1 0.9896 0.9589 0.9089 0.8415 Estimate the volume of the solid formed using Simpson’s rule. Sol. If V is the volume of the solid formed then we know that V = π y dx 2 0 1 z Hence we need the values of y2 and these are tabulated below correct to four decimal places x 0 .25 .5 .75 1 y2 1 .9793 .9195 .8261 .7081 with h = 0.25, Simpson’s rule gives V = π ( . ) 0 25 3 [(1 + .7081) + 4(.9793 + .8261) + 2(.9195)] = 2.8192.
  • 467. 454 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 17. A tank is discharging water through an orifice at a depth of x meter below the surface of the water whose area is A m2. Following are the values of x for the corresponding values of A. A: 1.257 1.39 1.52 1.65 1.809 1.962 2.123 2.295 2.462 2.650 2.827 x: 1.5 1.65 1.8 1.95 2.1 2.25 2.4 2.55 2.7 2.85 3 Using the formula (0.018) T = 1.5 3.0 A x dx z , calculate T, the time (in seconds) for the level of the water to drop from 3.0 m to 1.5 m above the orifice. Sol. Here h = 0.15 The table of values of x and the corresponding values of A x is x 1.5 1.65 1.8 1.95 2.1 2.25 2.4 2.55 2.7 2.85 3 y = A x 1.025 1.081 1.132 1.182 1.249 1.308 1.375 1.438 1.498 1.571 1.632 Using Simpson’s 1 3 rd rule, we get 1 5 3 15 3 . . z = A x dx [(1.025+1.632) + 4(1.081 + 1.182 + 1.308 + 1.438 + 1.571) + 2(1.132 + 1.249 + 1.375 + 1.498)] = 1.9743 Using the formula (0.018)T = 1 5 3 . z A x dx We get 0.018T = 1.9743 ⇒ T = 110 sec. (approximately). Example 18. Using the following table of values, approximate by Simpson’s rule, the arc length of the graph y = 1 x between the points (1, 1) and 5, 1 5 F HG I KJ x: 1 2 3 4 5 1 x x 4 4 + : 1.414 1.031 1.007 1.002 1.001.
  • 468. NUMERICAL INTEGRATION AND DIFFERENTIATION 455 Sol. The given curve is y = 1 x ∴ dy dx x = − 1 2 ∴ ds dx dy dx x x x = + F HG I KJ = + = + 1 1 1 1 2 4 4 4 ∴ The arc length of the curve between the points (1, 1) and 5 1 5 , F HG I KJ = 1 5 4 4 1 z + x x dx = h 3 [(1.414 + 1.001) + 4(1.031 + 1.002) + 2(1.007)] = 1 3 (2.415 + 8.132 + 2.014) = 4.187 Example 19. From the following values of y = f(x) in the given range of values of x, find the position of the centroid of the area under the curve and the x-axis x: 0 1 4 1 2 3 4 1 y: 1 4 8 4 1 Also find (i) the volume of solid obtained by revolving the above area about x-axis. (ii) the moment of inertia of the area about x-axis. Sol. Centroid of the plane area under the curve y = f(x) is given by ( , ) x y where and x xy dx y dx y y y dx y dx y dx y dx = = = O Q PPPPPPPPP z z z z z z 0 1 0 1 0 1 0 1 0 1 2 0 1 2 2 . (50)
  • 469. 456 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES From the given data, we obtain x: 0 1 4 1 2 3 4 1 y: 1 4 8 4 1 xy: 0 1 4 3 1 y2 2 : 1 2 8 32 8 1 2 ∴ By Simpson’s rule, 0 1 1 4 3 z = xy dx ( / ) [(0 + 1) + 4(1 + 3) + 2(4)] = 25 12 0 1 2 2 1 12 1 2 1 2 4 8 8 2 32 z = + F HG I KJ + + + L NM O QP y dx ( ) ( ) = 129 12 0 1 1 12 z = y dx [(1 + 1) + 4(4 + 4) + 2(8)] = 50 12 From (50), x = = 25 12 50 12 1 2 / / = 0.5 y = = 129 12 50 12 129 50 / / = 2.58 ∴ Centroid is the point (0.5, 2.58). (i) We know that V = Volume = π 0 1 2 z y dx ∴ Required volume = π.2 2 0 1 2 z y dx = 2 129 12 π × = 67.5442 (ii) We know that moment of inertia of the area about the x-axis is given by M.I. = 1 3 3 ρ a b y dx z where ρ is the mass per unit area.
  • 470. NUMERICAL INTEGRATION AND DIFFERENTIATION 457 Table for y3 is x: 0 1 4 1 2 3 4 1 y: 1 4 8 4 1 y3: 1 64 512 64 1 0 1 3 1 12 z = y dx [(1 + 1) + 4(64 + 64) + 2(512)] = 769 6 ∴ Reqd. M.I. = 1 3 769 6 ρ F HG I KJ = 769 18 ρ = 42.7222 ρ. Example 20. A reservoir discharging water through sluices at a depth h below the water surface, has a surface area A for various values of h as given below: h (in meters): 10 11 12 13 14 A (in sq. meters): 950 1070 1200 1350 1530 If t denotes time in minutes, the rate of fall of the surface is given by dh dt 48 A h = − Estimate the time taken for the water level to fall from 14 to 10 m above the sluices. Sol. From dh dt h = − 48 A , we have dt = − A 48 dh h Integration yields, t = − = z z 1 48 1 48 14 10 10 14 A A h dh h dh Here, y = A h . The table of values is as follows: h: 10 11 12 13 14 A: 950 1070 1200 1350 1530 A h : 300.4164 322.6171 346.4102 374.4226 408.9097
  • 471. 458 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Applying Simpson’s 1 3 rd rule, we have time t = 1 48 1 3 . [(300.4164 + 408.9097) + 4(322.6171 + 374.4226) + 2(346.4102)] = 29.0993 minutes. ASSIGNMENT 5.2 1. Evaluate 1 2 1 z x dx by Simpson’s 1 3 rd rule with four strips and determine the error by direct integration. 2. Evaluate the integral 0 2 π θ θ / cos z d by dividing the interval into 6 parts. 3. Evaluate log . e x dx 4 5 2 z by Simpson’s 3 8 th rule. Also write its programme in ‘C’ language. 4. Evaluate 30 90 10 ° ° z log sin x dx by Simpson’s 1 3 rd rule by dividing the interval into 6 parts. 5. Evaluate 4 5 2 . log z e x dx using (i) Trapezoidal rule (ii) Weddle’s rule. 6. Evaluate using Trapezoidal rule (i) t t dt sin 0 π z (ii) t dt t 5 2 2 2 + − z 7. Evaluate 3 7 z x2 log x dx taking 4 strips. 8. The velocities of a car running on a straight road at intervals of 2 minutes are given below: Time (in minutes): 0 2 4 6 8 10 12 Velocity (in km/hr): 0 22 30 27 18 7 0 Apply Simpson’s rule to find the distance covered by the car. 9. Evaluate 0 1 z cos x dx using h = 0.2.
  • 472. NUMERICAL INTEGRATION AND DIFFERENTIATION 459 10. Evaluate 0 4 z ex dx by Simpson’s rule, given that e = 2.72, e2 = 7.39, e3 = 20.09, e4 = 54.6 and compare it with the actual value. 11. Find an approximate value of loge 5 by calculating to 4 decimal places, by Simpson’s 1 3 rd rule, 0 5 4 5 z + dx x dividing the range into 10 equal parts. 12. Use Simpson’s rule, taking five ordinates, to find an approximate value of 1 2 1 z − x x dx to 2 decimal places. 13. Evaluate 0 2 π/ sin z x dx given that x: 0 π/12 π/6 π/4 π/3 5π/12 π/2 sin x : 0 0.5087 0.7071 0.8409 0.9306 0.9878 1 14. The velocity of a train which starts from rest is given by the following table, time being reckoned in minutes from the start and speed in kilometers per hour: Minutes: 0 2 4 6 8 10 12 14 16 18 20 Speed (km/hr): 0 10 18 25 29 32 20 11 5 2 0 Estimate the total distance in 20 minutes. Hint: Here step-size h = L NM O QP 2 60 15. A rocket is launched from the ground. Its acceleration is registered during the first 80 seconds and is given in the following table. Using Simpson’s 1 3 rd rule, find the velocity of the rocket at t = 80 seconds. t(sec): 0 10 20 30 40 50 60 70 80 f(cm/sec2): 30 31.63 33.34 35.47 37.75 40.33 43.25 46.69 50.67. 16. A curve is drawn to pass through the points given by the following table: x: 1 1.5 2 2.5 3 3.5 4 y: 2 2.4 2.7 2.8 3 2.6 2.1 Find (i) Center of gravity of the area. (ii) Volume of the solid of revolution. (iii) The area bounded by the curve, the x-axis and lines x = 1, x = 4. 17. In an experiment, a quantity G was measured as follows: G(20) = 95.9, G(21) = 96.85, G(22) = 97.77 G(23) = 98.68, G(24) = 99.56, G(25) = 100.41, G(26) = 101.24. Compute 20 26 z G(x dx ) by Simpson’s and Weddle’s rule, respectively.
  • 473. 460 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 18. Using the data of the following table, compute the integral 0 5 1 1 . . z xy dx by Simpson’s rule: x: 0.5 0.6 0.7 0.8 0.9 1.0 1.1 y: 0.4804 0.5669 0.6490 0.7262 0.7985 0.8658 0.9281 19. Find the value of loge 2 from 0 1 2 3 1 . z + x x dx using Simpson’s 1 3 rd rule by dividing the range of integration into four equal parts. Also find the error. 20. Use Simpson’s rule dividing the range into ten equal parts to show that 0 1 2 2 1 1 z + + log ( ) x x dx = 0.173 21. Find by Weddle’s rule the value of the integral I = 0 4 1 6 . . sinh z x x dx by taking 12 sub-intervals. 22. Evaluate 0 5 0 7 1/2 . . z − x e dx x approximately by using a suitable formula. 23. (i) Compute the integral I = 2 0 1 2) 2 π z − e dx x ( / Using Simpson’s 1 3 rd rule, taking h = 0.125. (ii) Compute the value of I given by I = 0 2 15 2 . . z − e dx x Using Simpson’s 1 3 F HG I KJ rule with four subdivisions. 24. Using Simpson’s 1 3 rd rule, Evaluate the integrals: (i) 10 1 8 2 . . z + − e e dx x x (taking h = 0.2) (ii) 0 2 2 2 1 4 π/ sin cos z + dx x x
  • 474. NUMERICAL INTEGRATION AND DIFFERENTIATION 461 25. Evaluate 0 1 z + sin cos x x dx correct to two decimal places using seven ordinates. 26. Use Simpson’s three-eighths rule to obtain an approximate value of 0 0 3 3 1/2 1 8 . ( ) z − x dx 27. Evaluate 0 1/2 2 1 z − dx x using Weddle’s rule. 28. Evaluate 0 1 2 2 2 1 z + + x x dx using Weddle’s rule correct to four places of decimals. 29. Using 3 8 th Simpson’s rule, Evaluate: 0 6 4 1 z + dx x . 30. Apply Simpson’s 1 3 rd rule to evaluate the integral I = 0 1 z e dx x by choosing step size h = 0.1 Show that this step size is sufficient to obtain the result correct to five decimal places. 31. (i) Obtain the global truncation error term of trapezoidal method of integration. (ii) Compute the approximate value of the integral l = ( ) 1 2 + + z x x dx Using Simpson’s rule by taking interval size h as 1. Write a C program to imple- ment. 32. The function f(x) is known at one point x* in the interval [a, b]. Using this value, f(x) can be expressed as f(x) = p0(x) + f ′{ξ(x)} (x – x*) for x ∈ (a, b) where p0(x) is the zeroth-order interpolating polynomial p0(x) = f(x*) and ξ (x) ∈ (a, b). Integrate this expression from a to b to derive a quadrature rule with error term. Sim- plify the error term for the case when x* = a. 5.25 EULER-MACLAURIN’S FORMULA This formula is based on the expansion of operators. Suppose ΔF(x) = f(x), then an operator Δ–1, called inverse operator, is defined as F(x) = Δ–1 f(x) (51)
  • 475. 462 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Also, ΔF(x) = f(x) gives F(x1) – F(x0) = f(x0) Similarly, F( F( F( F( x x f x x x f x n n n 2 1 1 1 1 ) ) ( ) ) ) ( ) − = − = − − On adding, F(xn) – F(x0) = i n i f x = − ∑ 0 1 ( ) (52) where x0, x1, ......, xn are the (n + 1) equidistant values of x with difference h. From (51), F(x) = (E – 1)–1 f(x) = (ehD – 1)–1 f(x) = 1 2 3 1 1 + + + F HG I KJ − L N MM O Q PP − h h h f x D + D D 2 2 3 3 ! ! ...... ( ) = h h h f x D + D D 2 2 3 3 2 3 1 ! ! ...... ( ) + + L N MM O Q PP − = + + + F HG I KJ L N MM O Q PP − − ( ! ! ...... ( ) h h h f x D) D D 1 2 2 1 2 3 1 = 1 1 2 3 h h h D D D 1 2 2 − − + + F HG I KJ L N MM ! ! ...... + − − + + F HG I KJ + O Q PP ( ) ( ) ! ! ! ...... ...... ( ) 1 2 2 2 3 2 h h f x D D 2 2 = 1 1 2 12 720 1 4 h h h h f x D D D D 2 2 4 − − + − + L NM O QP ...... ( ) F(x) = 1 1 2 12 720 3 h f x dx f x h f x h f x ( ) ( ) ( ) ( ) ...... − + ′ − ′ ″ + z (53)
  • 476. NUMERICAL INTEGRATION AND DIFFERENTIATION 463 Putting x = xn and x = x0 in (53) and then subtracting, we get F(xn) – F(x0) = 1 1 2 0 h f x dx x xn z − ( ) [f(xn) – f(x0)] + h 12 [f ′(xn) – f′(x0)] − h3 720 [f′″(xn) – f′″(x0)] + ...... ⇒ f x h f x dx f x f x h f x f x i i n x x n n n ( ) ( ) [ ( ) ( )] [ ( ) ( )] = − ∑ z = − − + ′ − ′ 0 1 0 0 1 1 2 12 0 − ′″ − ′″ + h f x f x n 3 0 720 [ ( ) ( )] ...... | using (52) ⇒ 1 1 2 12 0 0 1 0 0 h f x dx f x f x f x h f x f x x x i n i n n n z ∑ = + − − ′ − ′ = − ( ) ( ) [ ( ) ( )] [ ( ) ( )] + ′″ − ′″ − h f x f x n 3 0 720 [ ( ) ( )] ...... (54) or x x n n y dx h y y y y 0 2 2 2 0 1 2 z = + + + + [ ...... ] − ′ − ′ + ′ ″ − ′ ″ − h y y h y y n n 2 0 4 0 12 720 ( ) ( ) ...... = h y y y y y n n 2 2 0 1 2 1 [( ) ( ...... )] + + + + + − − ′ − ′ + ′ ″ − ′ ″ h y y h y y n n 2 0 4 0 12 720 ( ) ( ) – ...... (55) which is called Euler-Maclaurin’s formula. The first term on the R.H.S. of (55) represents the approximate value of the integral obtained from trapezoidal rule and the other terms denote the successive corrections to this value. This formula is often used to find the sum of a series of the form y(x0) + y(x0 + h) + y(x0 + 2h) + ...... + y(x0 + nh). 5.26 GAUSSIAN QUADRATURE FORMULA Consider the numerical evaluation of the integral a b f x dx z ( ) (56)
  • 477. 464 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES So far, we studied some integration formulae which require values of the function at equally spaced points of the interval. Gauss derived a formula which uses the same number of function values but with different spacing and gives better accuracy. Gauss’s formula is expressed in the form F( ) u du − z1 1 = W1 F(u1) + W2 F(u2) + ...... + Wn F(un) = W F i i i n u ( ) = ∑1 (57) where Wi and ui are called the weights and abscissae respectively. The formula has an advantage that the abscissae and weights are symmetrical with respect to the middle point of the interval. In equation (57), there are altogether 2n arbitrary parameters and therefore the weights and abscissae can be determined so that the formula is exact when F(u) is a polynomial of degree not exceeding 2n – 1. Hence, we start with F(u) = C0 + C1 u + C2 u2 + C3 u3 + ...... + C2n – 1 u2n – 1 (58) Then from (57), F( ) u du − z1 1 = ( ...... ) C C C C C 0 1 2 2 3 3 2 1 2 1 1 1 + + + + + − − − z u u u u du n n = 2 C0 + 2 3 2 5 2 4 C C + + ....... (59) Set u = ui in (58), we get F(ui) = C0 + C1 ui + C2 ui 2 + C3 ui 3 + ...... + C2n – 1 ui 2n – 1 From (57), F( ) u du − z1 1 = W1 (C0 + C1 u1 + C2 u1 2 + ........ + C2n – 1 u1 2n – 1) + W2 (C0 + C1 u2 + C2 u2 2 + ...... + C2n – 1 u2 2n – 1) + W3 (C0 + C1 u3 + C2 u3 2 + ...... + C2n – 1 u3 2n – 1) + ...... + Wn (C0 + C1 un + C2 un 2 + ...... + C2n – 1 un 2n – 1) which can be written as F( ) u du − z1 1 = C0 (W1 + W2 + ....... + Wn) + C1(W1 u1 + W2 u2 + W3 u3 + ...... + Wn un) + C2(W1 u1 2 + W2 u2 2 + W3 u3 2 + ...... + Wn un 2) + ...... + C2n – 1(W1 u1 2n – 1 + W2 u2 2n – 1 + W3 u3 2n – 1 + ...... + Wn un 2n – 1) (60)
  • 478. NUMERICAL INTEGRATION AND DIFFERENTIATION 465 Now equations (59) and (60) are identical for all values of Ci and hence comparing the coefficients of Ci, we obtain 2n equations W1 + W2 + W3 + ....... + Wn = 2 W1 u1 + W2 u2 + W3 u3 + ....... + Wn un = 0 W1 u1 2 + W2 u2 2 + W3 u3 2 + ........ + Wn un 2 = 2 3 (61) W1 u1 2n – 1 + W2 u2 2n – 1 + W3 u3 2n – 1 + ........ + Wn un 2n – 1 = 0 in 2n unknowns Wi and ui (i = 1, 2, ......, n). The abscissae ui and the weights Wi are extensively tabulated for different values of n. The table up to n = 5 is given below: n ± ui Wi 2 0.57735, 02692 1.0 0.0 0.88888 88889 3 0.77459 66692 0.55555 55556 4 0.33998 10436 0.65214 51549 0.86113 63116 0.34785 48451 0.0 0.56888 88889 5 0.53846 93101 0.47862 86705 0.90617 98459 0.23692 68851 In general case, the limits of integral in (56) have to be changed to those in (57) by transformation x = 1 2 u (b – a) + 1 2 (a + b). 5.27 NUMERICAL EVALUATION OF SINGULAR INTEGRALS The various numerical integration formulae we have discussed so far are valid if integrand f(x) can be expanded by a polynomial or, alternatively can be expanded in a Taylor’s series in the interval [a, b]. In a case where function has a singularity, the preceding formulae cannot be applied and special methods will have to be adopted. U V | | | | W | | | |
  • 479. 466 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 5.28 EVALUATION OF PRINCIPAL VALUE INTEGRALS Consider, I(f) = f x x t dx a b ( ) − z (62) which is singular at t = x. Its Principal value, P(I) = lim ( ) ( ) ε ε ε → − + − + − L NM O QP z z 0 f x x t dx f x x t dx a t t b ; a t b (63) = I(f) (for t a or t b) Set x = a + uh and t = a + kh in (1), we get P(I) = P f a hu u k du p ( ) + − z0 (64) Replacing f(a + hu) by Newton’s forward difference formula at x = a and simplifying, we get I(f) = Δj j j f a j ( ) ! = ∞ ∑0 C (65) where the constants Cj are given by Cj = P ( ) u u k du j p − z0 (66) In (66), (u)0 = 1, (u)1 = u, (u)2 = u (u – 1) etc. Various approximate formulae can be obtained by truncating the series on R.H.S. of (65). Eqn. (65) may be written as In(f) = Δj j n j f a j ( ) ! = ∑0 C (67) We obtain rules of orders 1, 2, 3, ...... etc. by setting n = 1, 2, 3, ...... respectively. (i) Two point rule (n = 1): I1(f) = Δj j f a j ( ) ! = ∑0 1 Cj = C0 f(a) + C1 Δ f(a) = (C0 – C1) f(a) + C1 f (a + h) (68)
  • 480. NUMERICAL INTEGRATION AND DIFFERENTIATION 467 (ii) Three-point rule (n = 2): I2 (f) = Δj j f a j ( ) ! = ∑0 2 Cj = C0 f(a) + C1 Δ f(a) + C2 Δ2 f(a) = C C C 0 1 2 1 2 − + F HG I KJ f(a) + (C1 – C2) f (a + h) + 1 2 C2 f (a + 2h) (69) In above relations (68) and (69), values of Cj are given by, C0 = log e p k k − C1 = p + C0 k C2 = 1 2 p2 + p (k – 1) + C0 k (k – 1) . EXAMPLES Example 1. Apply Euler-Maclaurin formula to evaluate 1 51 1 53 1 55 ....... 1 99 2 2 2 2 + + + + . Sol. Take y = 1 2 x , x0 = 51, h = 2, n = 24, we have y′ = − 2 3 x , y′″ = − 24 5 x Then from Euler-Maclaurin’s formula, dx x2 51 99 z = 2 2 1 51 2 53 2 55 2 97 1 99 2 2 2 2 2 + + + + + L NM O QP ...... – ( ) ( ) ( ) ( ) ( ) 2 12 2 99 2 51 2 3 3 − − − L NM O QP + ( ) ( ) ( ) ( ) ( ) 2 720 24 99 24 51 4 5 5 − − − L NM O QP ∴ 1 51 2 53 2 55 2 97 1 99 2 2 2 2 2 + + + + + ...... = dx x2 51 99 z + 2 3 1 51 1 99 3 3 ( ) ( ) − L NM O QP – 8 15 1 51 1 99 5 5 ( ) ( ) − L NM O QP +......
  • 481. 468 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ⇒ 2 1 51 1 53 1 55 1 99 2 2 2 2 + + + + L NM O QP ...... = dx x2 2 2 51 99 1 51 1 99 + + F HG I KJ z + 2 3 1 51 1 99 3 3 ( ) ( ) − L NM O QP – 8 15 1 51 1 99 5 5 ( ) ( ) − L NM O QP + ...... ⇒ 1 51 1 53 1 55 1 99 2 2 2 2 ( ) ( ) ( ) ...... ( ) + + + + = 1 2 2 51 99 dx x z + 1 2 1 51 1 99 2 2 ( ) ( ) + L NM O QP + 1 3 1 51 1 99 3 3 ( ) ( ) − L NM O QP – 4 15 1 51 1 99 5 5 ( ) ( ) − L NM O QP + ...... = 1 2 − F HG I KJ 1 51 99 x + 1 2 1 51 1 99 2 2 ( ) ( ) + L NM O QP + 1 3 1 51 1 99 3 3 ( ) ( ) − L NM O QP – 4 15 1 51 1 99 5 5 ( ) ( ) − L NM O QP + ....... = 0.00475 + 0.000243 + 0.0000022 + ...... = 0.00499 approximately. Example 2. Using Euler-Maclaurin’s formula, find the value of loge 2 from dx 1 x 0 1 + z . Sol. Take y = 1 1+ x , x0 = 0, n = 10, h = 0.1, we have y′ = − + 1 1 2 ( ) x and y′″ = − + 6 1 4 ( ) x
  • 482. NUMERICAL INTEGRATION AND DIFFERENTIATION 469 Then from Euler-Maclaurin’s formula, we have dx x 1 0 1 + z = 0 2 .1 1 1 0 2 1 01 2 1 0 2 2 1 03 2 1 0 4 + + + + + + + + + L NM . . . . + + + + + + + + + + + + O QP 2 1 05 2 1 0 6 2 1 07 2 1 0 8 2 1 0 9 1 1 1 . . . . . – ( . ) ( ) ( ) ( ) ( ) 0 1 12 1 1 1 1 1 0 2 2 2 − + − − + L NM O QP + ( . ) ( ) ( ) ( ) ( ) 0 1 720 6 1 1 6 1 0 4 4 4 − + − − + L NM O QP = 0.693773 – 0.000625 + 0.000001 = 0.693149 Also, dx x 1 0 1 + z = log ( ) 1 0 1 + x = log 2 Hence loge 2 = 0.693149. Example 3. Evaluate sin x dx 0 /2 π z using the Euler-Maclaurin formula. Sol. sin 0 /2 x dx π z = h 2 [y0 + 2y1 + 2y2 + ....... + 2yn – 1 + yn] + h h h 2 4 6 12 720 30240 + + + ...... To evaluate the integral, let us take h = π 4 . Then we obtain, sin 0 /2 x dx π z = π 8 (0 + 2 + 0) + π2 192 + π4 184320 + ...... = π π π 4 192 184320 2 4 + + (approximately) = 0.785398 + 0.051404 + 0.000528 = 0.837330 If we take h = π 8 , we get sin 0 /2 x dx π z = π 16 [0 + 2(0.382683 + 0.707117 + 0.923879) + 1] = 0.987119 + 0.012851 + 0.000033 = 1.000003.
  • 483. 470 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 4. Use Euler-Maclaurin’s formula to prove that x2 1 n ∑ = n (n 1) (2n 1) 6 + + . Sol. By Euler–Maclaurin’s formula, y dx x xn 0 z = h 2 [y0 + 2y1 + 2y2+ ......... + 2yn – 1 + yn] – h2 12 (yn′ – y0′) + h4 720 (yn′″ – y0′″) – h6 30240 (yn (v) – y0 (v)) + ..... ⇒ 1 2 y0 + y1 + y2 + ...... + yn – 1 + 1 2 yn = 1 h y dx x xn 0 z + h 12 (yn′ – y0′) – h3 720 (yn′″ – y0′″) + h5 30240 (yn (v) – y0 (v)) – ....... (70) Here y(x) = x2, y′(x) = 2x and h = 1 ∴ From (70), Sum = x dx n 2 1 z + 1 2 (n2 + 1) + 1 12 (2n – 2) ∵ 1 2 y0 = 1 2 , 1 2 yn = n2 2 = 1 3 (n3 – 1) + 1 2 (n2 + 1) + 1 6 (n – 1) = n n n ( ) ( ) + + 1 2 1 6 . Example 5. Find x dx 0 1 z by Gaussian formula. Sol. Let us change the limits as x = 1 2 u(1– 0) + 1 2 (1 + 0) = 1 2 (u + 1) This gives, I = 1 4 ( ) u du + − z 1 1 1 = 1 4 W F i i i n u ( ) = ∑1 where F(ui) = ui + 1
  • 484. NUMERICAL INTEGRATION AND DIFFERENTIATION 471 For simplicity, let n = 4 and using the abscissae and weights corresponding to n = 4 in the table, we get I = 1 4 [(– 0.86114 + 1) (0.34785 ) + (– 0.33998 + 1) (0.65214) + (0.33998 + 1) (0.65214) + (0.86114 + 1) (0.34785)] = 0.49999 ..... where the abscissae and weights have been rounded to 5 decimal places. Example 6. Show that the integration formula f(x) dx 0 h z = hf h 2 F HG I KJ is exact for all polynomials of degree less than or equal to 1. Obtain an estimate for the truncation error. If |f ″(x)| 1 for all x, then find the step size h so that the truncation error is less than 10–3. Sol. If f(x) = k (a constant or zero degree polynomial) then the result is obvious since f x dx h ( ) 0 z = kh (71) and hf h 2 F HG I KJ = hk (72) ∴ From (71) and (72), f x dx h ( ) 0 z = hf h 2 F HG I KJ If f(x) is a polynomial of degree one then f(x) = ax + b f x dx h ( ) 0 z = ( ) ax b dx h + z0 = ah bh 2 2 + (73) hf h 2 F HG I KJ = h ah b 2 + F HG I KJ = ah bh 2 2 + (74) From (73) and (74), we have the result. Now, y dx h 0 z = y x x y x x y dx h 0 0 0 0 2 0 0 2 + − ′ + − ″ + L NMM O QPP z ( ) ( ) .....
  • 485. 472 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = hy0 + h y h y 2 0 3 0 2 3 ! ! ..... ′ + ″ + (75) (where x – x0 = h) Also, hf h 2 F HG I KJ = h y h y h y 0 0 2 0 2 2 2 + ′ + F HG I KJ ″ + L N MMMMM O Q PPPPP ! ..... (76) (75) – (76) gives the truncation error = h3 1 6 1 8 − F HG I KJ y0″ (nearly) Now, h y 3 0 24 ″ 1 24 h3 ⇒ 1 24 h3 10–3 or | h3 | 24 × 10– 3 = 0.024 ⇒ – 0 024 3 . h 0 024 3 . . Example 7. Find λ such that the quadrature formula f(x) x dx 0 1 z ≈ Af(0) + Bf(λ) + Cf(1) may be exact for polynomials of degree 3. Sol. f x x dx ( ) 0 1 z = Af(0) + Bf(λ) + Cf(1) Set f(x) = 1, x, x2 and x3 in turn, 2 = A + B + C (77) 2 3 = Bλ + C (78) 2 5 = Bλ2 + C (79) 2 7 = Bλ3 + C (80) Subtracting (78) from (79), we get Bλ (λ – 1) = − 4 15
  • 486. NUMERICAL INTEGRATION AND DIFFERENTIATION 473 Subtracting (79) from (80), we get Bλ2(λ – 1) = – 4 35 ∴ λ = 3 7 . Example 8. Determine W0, W1 and W2 as functions of α such that the error R in f(x) dx –1 1 z = W0 f(– α) + W1 f(0) + W2 f(α) + R, α ≠ 0 Vanishes when f(x) is an arbitrary polynomial of degree at most 3. Show that the precision is five when α = 3 5 and three otherwise. Compute the error R when α = 3 5 . Sol. f x dx ( ) –1 1 z = W0 f(– α) + W1 f(0) + W2 f(α) is exact for f(x) = 1, x, x2, x3. f(x) = 1 ⇒ W0 + W1 + W2 = 2 f(x) = x ⇒ W0 = W2 f(x) = x2 ⇒ 2W0α2 = 2 3 f(x) = x3 ⇒ W0 = W2 Solving, we find W0 = W2 = 1 3 2 α , W1 = 2 1 1 3 2 − F HG I KJ α Choosing f(x) = x4, we get 2 5 = 2W0α4 = 2 3 α2 ⇒ α = 3 5 With this value, f(x) = x5 gives exact value. ∴ The precision is 5.
  • 487. 474 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES If α ≠ 3 5 the precision is 3. With α = 3 5 , we have f x dx ( ) –1 1 z = 5 9 f f − F HG I KJ + F HG I KJ L N MM O Q PP 3 5 3 5 + 8 9 f(0) + R Hence the error term R is given by R = 2 7! f (vi) (0) + terms involving higher order derivatives = f vi ( ) ( ) 0 2520 . Example 9. Determine a, b and c such that the formula f(x) dx 0 h z = h af(0) bf h 3 cf (h) + F HG I KJ + R S T U V W is exact for polynomials of as high order as possible and determine the order of truncation error. Sol. Making the method exact for polynomials of degree up to 2, we get For f(x) = 1: h = h (a + b + c) ⇒ a + b + c = 1 For f(x) = x: h2 2 = h bh ch 3 + F HG I KJ ⇒ b 3 + c = 1 2 For f(x) = x2: h3 3 = h bh ch 2 2 9 + F HG I KJ ⇒ b 9 + c = 1 3 Solving above eqns., we get a = 0, b = 3 4 , c = 1 4 Truncation error of the formula = c 3! f ′″(ξ); 0 ξ h and c = x dx h 3 0 z – h bh ch 3 3 27 + F HG I KJ = – h4 36
  • 488. NUMERICAL INTEGRATION AND DIFFERENTIATION 475 Hence, we have Truncation error = − h4 216 f ′″ (ξ) = 0 (h4). ASSIGNMENT 5.3 1. Using Euler-Maclaurin’s formula, evaluate (i) 1 400 + 1 402 + 1 404 + ....... + 1 500 (ii) 1 201 2 ( ) + 1 203 2 ( ) + 1 205 2 ( ) + ...... + 1 299 2 ( ) . 2. Prove that x n 3 1 ∑ = n n ( ) + R S T U V W 1 2 2 applying Euler-Maclaurin’s formula. 3. Use Euler-Maclaurin’s formula to find the value of π from the formula π 4 = dx x 1 2 0 1 + z . 4. Find the sum of the fourth powers of first n natural numbers by means of Euler- Maclaurin’s formula. OR Prove that, i n 4 0 ∑ = n n n n 5 4 3 5 2 3 30 + + + . 5. Sum the series 1 100 1 101 1 102 1 103 1 104 + + + + . 6. Determine α, β, γ and δ such that the relation y′ a b + F HG I KJ 2 = αy (a) + βy (b) + γ y″ (a) + δ y″ (b) is exact for polynomials of as high degree as possible. 7. Find the values of α0 , α1, α2 so that the given rule of differentiation f ′(x0) = α0 f0 + α1f1 + α2f2 (xk = x0 + kh) is exact for f ∈ P2. 8. Find the values a, b, c such that the truncation error in the formula f x dx h h ( ) − z = h [af(– h) + bf (0) + af(h) + h2 c {f ′ (– h) – f ′ (h)}] is minimized. 9. Show that i i i n i n 7 1 5 1 + = = ∑ ∑ = 2 i i n 3 1 2 = ∑ F H GG I K JJ . 10. Evaluate: 1 10 2 0 ( ) + = ∞ ∑ m m by applying Euler-Maclaurin’s formula.
  • 490. P a r t 4 n Numerical Solution of Ordinary Differential Equations Picard’s Method, Euler’s Method, Taylor’s Method, Runge-Kutta Methods, Predictor-Corrector Methods, Milne’s Method, Adams- Moulton Formula, Stability in the Solution of Ordinary Differential Equations.
  • 492. Chapter 6 NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 479 6.1 INTRODUCTION A physical situation concerned with the rate of change of one quantity with respect to another gives rise to a differential equation. Consider the first order ordinary differential equation dy dx = f (x, y) (1) with the initial condition y(x0) = y0 (2) Many analytical techniques exist for solving such equations, but these methods can be applied to solve only a selected class of differential equations. However, a majority of differential equations appearing in physical problems cannot be solved analytically. Thus it becomes imperative to discuss their solution by numerical methods. In numerical methods, we do not proceed in the hope of finding a relation between variables but we find the numerical values of the dependent variable for certain values of independent variable. It must be noted that even the differential equations which are solvable by analytical methods can be solved numerically as well.
  • 493. 480 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.2 INITIAL-VALUE AND BOUNDARY-VALUE PROBLEMS Problems in which all the conditions are specified at the initial point only are called initial-value problems. For example, the problem given by eqns. (1) and (2) is an initial value problem. Problems involving second and higher order differential equations, in which the conditions at two or more points are specified, are called boundary-value problems. To obtain a unique solution of nth order ordinary differential equation, it is necessary to specify n values of the dependent variable and/or its derivative at specific values of independent variable. 6.3 SINGLE STEP AND MULTI-STEP METHODS The numerical solutions are obtained step-by-step through a series of equal intervals in the independent variable so that as soon as the solution y has been obtained at x = xi , the next step consists of evaluating yi+1 at x = xi+1. The methods which require only the numerical value yi in order to compute the next value yi+1 for solving eqn. (1) given above are termed as single step methods. The methods which require not only the numerical value yi but also at least one of the past values yi–1, yi–2, ...... are termed as multi-step methods. 6.4 COMPARISON OF SINGLE-STEP AND MULTI-STEP METHODS The single step method has obvious advantages over the multi-step methods that use several past values (yn, yn–1, ......, yn–p) and that require initial values (y1, y2, ......, yn) that have to be calculated by another method. The major disadvantage of single-step methods is that they use many more evaluations of the derivative to attain the same degree of accuracy compared with the multi-step methods. 6.5 NUMERICAL METHODS OF SOLUTION OF O.D.E. In this chapter we will discuss various numerical methods of solving ordinary differential equations. We know that these methods will yield the solution in one of the two forms: (a) A series for y in terms of powers of x from which the value of y can be obtained by direct substitution.
  • 494. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 481 (b) A set of tabulated values of x and y. Picard’s method and Taylor’s method belong to class (a) while those of Euler’s, Runge-Kutta, Adams-Bashforth, Milne’s, etc. belong to class (b). Methods which belong to class (b) are called step-by-step methods or marching methods because the values of y are computed by short steps ahead for equal intervals of the independent variable. In Euler’s and Runge-Kutta methods, the interval range h should be kept small, hence they can be applied for tabulating y only over a limited range. To get functional values over a wider range, the Adams-Bashforth, Milne, Adams-Moulton, etc. methods may be used since they use finite differences and require starting values, usually obtained by Taylor’s series or Runge-Kutta methods. 6.6 PICARD’S METHOD OF SUCCESSIVE APPROXIMATIONS Picard was a distinguished Professor of Mathematics at the university of Paris, France. He was famous for his research on the Theory of Functions. Consider the differential equation dy dx = f (x, y); y(x0) = y0 (3) Integrating eqn. (3) between the limits x0 and x and the corresponding limits y0 and y, we get y y x x dy f x y dx 0 0 z z = ( , ) ⇒ y – y0 = x x f x y dx 0 z ( , ) or, y = y0 + x x f x y dx 0 z ( , ) (4) In equation (4), the unknown function y appears under the integral sign. This type of equation is called integral equation. This equation can be solved by the method of successive approximations or iterations. To obtain the first approximation, we replace y by y0 in the R.H.S. of eqn. (4). Now, the first approximation is y(1) = y0 + x x f x y dx 0 0 z ( , ) The integrand is a function of x alone and can be integrated.
  • 495. 482 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES For a second approximation, replace y0 by y(1) in f (x, y0) which gives y(2) = y0 + x x f x y dx 0 z { , } (1) Proceeding in this way, we obtain y(3), y(4), ......., y(n–1) and y(n) where y(n) = y0 + x x n f x y dx 0 1 z − { , } ( ) with y(x0) = y0 As a matter of fact, the process is stopped when the two values of y viz. y(n–1) and y(n) are the same to the desired degree of accuracy. Picard’s method is of considerable theoretical value. Practically, it is unsatisfactory because of the difficulties which arise in performing the necessary integrations. However, each step gives a better approximation of the required solution than the preceding one. EXAMPLES Example 1. Given the differential eqn. dy dx x y 1 2 2 = + with the initial condition y = 0 when x = 0. Use Picard’s method to obtain y for x = 0.25, 0.5 and 1.0 correct to three decimal places. Sol. (a) The given initial value problem is dy dx = f(x, y) = x y 2 2 1 + where y = y0 = 0 at x = x0 = 0 We have first approximation, y(1) = y0 + x x f x y dx 0 0 z ( , ) = 0 + 0 2 0 1 x x z + dx = 1 3 x3 (5) Second approximation, y(2) = y0 + x x f x y dx 0 1 z { , } ( ) = 0 + 0 2 3 2 3 1 x x x dx z F HG I KJ +
  • 496. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 483 = tan− L NM O QP 1 3 0 3 x x = tan–1 x3 3 = 1 3 x3 – 1 3 1 3 3 3 x F HG I KJ + ...... = 1 3 x3 – 1 81 x9 + ..... (6) From (5) and (6), we see that y(1) and y(2) agree to the first term x3 3 . To find the range of values of x so that the series with the term 1 3 x3 alone will give the result correct to three decimal places, we put 1 81 x9 ≤ .0005 which gives, x9 ≤ .0405 or x ≤ 0.7 Hence, y(.25) = 1 3 (.25)3 = .005 and y(0.5) = 1 3 (0.5)3 = .042 To find y(1.0), we make use of eqn. (6) which gives, y(1.0) = 1 3 – 1 81 = 0.321. Example 2. Use Picard’s method to obtain y for x = 0.2. Given: dy dx = x – y with initial condition y = 1 when x = 0. Sol. Here f(x, y) = x – y, x0 = 0, y0 = 1 We have first approximation, y(1) = y0 + f x y dx x ( , ) 0 0 z = 1 + ( ) x dx x − z 1 0 = 1 – x + x2 2 Second approximation, y(2) = y0 + 0 1 x f x y dx z { , } ( ) = 1 + 0 x x y dx z − { } (1) = 1 + 0 2 1 2 x x x x dx z − + − F HG I KJ = 1 – x + x2 – x3 6
  • 497. 484 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Third approximation, y(3) = y0 + 0 2 x f x y dx z { , } ( ) = 1 + 0 2 x x y dx z − { } ( ) = 1 + 0 2 3 1 6 x x x x x dx z − + − + F HG I KJ = 1 – x + x2 – x x 3 4 3 24 + Fourth approximation, y(4) = y0 + 0 3) x f x y dx z { , } ( = 1 + 0 3) x x y dx z − { } ( = 1 + 0 2 3 4 1 3 24 x x x x x x dx z − + − + − F HG I KJ = 1 – x + x2 – x x x 3 4 5 3 12 120 + − Fifth approximation, y(5) = y0 + 0 4 x f x y dx z { , } ( ) = 1 + 0 4 x x y dx z − { } ( ) = 1 + 0 2 3 4 5 1 3 12 120 x x x x x x x dx z − + − + − + F HG I KJ = 1 – x + x2 – x x x x 3 4 5 6 3 12 60 720 + − + When x = 0.2, we get y(1) = .82, y(2) = .83867, y(3) = .83740 y(4) = .83746, y(5) = .83746 Thus, y = .837 when x = .2. Example 3. Use Picard’s method to obtain y for x = 0.1. Given that: dy dx = 3x + y2; y = 1 at x = 0. Sol.Here f(x, y) = 3x + y2, x0 = 0, y0 = 1
  • 498. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 485 First approximation, y(1) = y0 + f x y dx x ( , ) 0 0 z = 1 + ( ) 3 1 0 x dx x + z = 1 + x + 3 2 x2 Second approximation, y(2) = 1 + x + 5 2 x2 + 4 3 x3 + 3 4 x4 + 9 20 x5 Third approximation, y(3) = 1 + x + 5 2 x2 + 2x3 + 23 12 x4 + 25 12 x5 + 68 45 x6 + 1157 1260 x7 + 17 32 x8 + 47 240 x9 + 27 400 x10 + 81 4400 x11 when x = 0.1, we have y(1) = 1.115, y(2) = 1.1264, y(3) = 1.12721 Thus, y = 1.127 when x = 0.1. Example 4. If dy dx y x y x = − + , find the value of y at x = 0.1 using Picard’s method. Given that y(0) = 1. Sol. First approximation, y(1) = y0 + y x y x dx x 0 0 0 − + z = 1 + 0 1 1 x x x dx z − + F HG I KJ = 1 + 0 2 1 1 x x dx z + − F HG I KJ = 1 – x + 2 log (1 + x) Second approximation, y(2) = 1 + x – 2 0 1 2 1 x x dx x z + + log ( ) which is difficult to integrate. Thus, when, x = 0.1, y(1) = 1 – 0.1 + 2 log (1.1) = 0.9828 Here in this example, only I approximation can be obtained and so it gives the approximate value of y for x = 0.1.
  • 499. 486 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 5. Solve dy dx = 1 + xy with x0 = 2, y0 = 0 using Picard’s method of successive approximations. Sol. Here, y(1) = y0 + 2 0 x f x y dx z ( , ) = 0 + 2 1 0 x x dx z + [ ( )] = x – 2 y(2) = 0 + 2 1 2 x x x dx z + − { ( )} = x x x x − + F HG I KJ 2 3 2 3 = – 2 3 + x – x2 + x3 3 And third approximation, y(3) = 0 + 2 2 1 x x y dx z + { } ( ) = – 22 15 + x – 1 3 3 4 15 2 3 4 5 x x x x + − + which is the required solution. Example 6. Obtain y when x = 0.1, x = 0.2, given that dy dx = x + y; y(0) = 1. Check the result with exact value. Sol. We have dy dx = f(x, y) = x + y, x0 = 0, y0 = 1 Now first approximation, y(1) = 1 + ( ) 1 0 + z x dx x = 1 + x + x2 2 Second approximation, y(2) = 1 + x x x dx x + + + F HG I KJ z 1 2 2 0 = 1 + x + x2 + x3 6 Third approximation, y(3) = 1 + x + x2 + x x 3 4 3 24 + When x = .1, y(1) = 1.105 y(2) = 1.11016 y(3) = 1.11033 (closer appr.)
  • 500. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 487 When x = .2, y(3) = 1.2427 We can continue further to get the better approximations. Now we shall obtain exact value. dy dx – y = x is the given differential equation. General sol. is ye–x = – e–x (1 + x) + c | I.F. = e–x Putting y = 1, x = 0 we obtain, c = 2 ∴ y = – x – 1 + 2ex When x = 0.1, y = 1.11034 and x = 0.2, y = 1.24281 These results reveal that the approximations obtained for x = 0.1 is correct to four decimal places while that for x = 0.2 is correct to 3 decimal places. Example 7. Find the solution of dy dx = 1 + xy, y(0) = 1 which passes through (0, 1) in the interval (0, 0.5) such that the value of y is correct to three decimal places (use the whole interval as one interval only). Take h = 0.1. Sol. The given initial value problem is dy dx = f(x, y) = 1 + xy; y(0) = 1 i.e., y = y0 = 1 at x = x0 = 0 Here, y(1) = 1 + x + x2 2 y(2) = 1 + x + x x x 2 3 4 2 3 8 + + y(3) = 1 + x + x x x x x 2 3 4 5 6 2 3 8 15 48 + + + + y(4) = y(3) + x x 7 8 105 384 + when x = 0, y = 1.000 x = 0.1, y(1) = 1.105, y(2) = 1.1053 .... ∴ y = 1.105 (correct up to 3 decimals) x = 0.2, y(1) = 1.220, y(2) = 1.223 = y(3)
  • 501. 488 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ y = 1.223 (correct up to 3 decimals) x = 0.3, y = 1.355 as y(2) = 1.355 = y(3) x = 0.4, y = 1.505 (similarly) x = 0.5, y = 1.677 as y(4) = y(3) = 1.677 Thus, x 0 0.1 0.2 0.3 0.4 0.5 y 1.000 1.105 1.223 1.355 1.505 1.677 We have numerically solved the given differential eqn. for x = 0, .1, .2, .3, .4, and .5. 6.7 PICARD’S METHOD FOR SIMULTANEOUS FIRST ORDER DIF- FERENTIAL EQUATIONS Let dy dx = φ(x, y, z) and dz dx = f(x, y, z) be the simultaneous differential eqns. with initial conditions y(x0) = y0; z(x0) = z0. Picard’s method gives y(1) = y0 + x x x y z dx 0 0 0 z φ( , , ) ; z(1) = z0 + x x f x y z dx 0 0 0 z ( , , ) y(2) = y0 + x x x y z dx 0 1 1 z φ{ , , } ( ) ( ) ; z(2) = z0 + x x f x y z dx 0 1 1 z { , , } ( ) ( ) and so on as successive approximations. EXAMPLES Example 1. Approximate y and z by using Picard’s method for the particular solution of dy dx = x + z, dz dx = x – y2 given that y = 2, z = 1 when x = 0. Sol. Let φ(x, y, z) = x + z, f(x, y, z) = x – y2 Here, x0 = 0, y0 = 2, z0 = 1 We have, dy dx = φ(x, y, z) ⇒ y = y0 + x x x y z dx 0 z φ( , , )
  • 502. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 489 Also, dz dx = f(x, y, z) ⇒ z = z0 + x x f x y z dx 0 z ( , , ) First approximation, y(1) = y0 + x x x y z dx 0 0 0 z φ( , , ) = 2 + 0 0 x x z dx z + ( ) = 2 + 0 1 x x dx z + ( ) = 2 + x + x2 2 and z(1) = z0 + x x f x y z dx 0 0 0 z ( , , ) = 1 + 0 0 2 x x y dx z − ( ) = 1 + 0 4 x x dx z − ( ) = 1 – 4x + x2 2 Second approximation, y(2) = y0 + x x x y z dx 0 1 1 z φ{ , , } ( ) ( ) = 2 + 0 1 x x z dx z + { } ( ) = 2 + 0 2 1 4 2 x x x x dx z + − + F HG I KJ = 2 + x – 3 2 x2 + x3 6 z(2) = z0 + x x f x y z dx 0 z { , , } (1) (1) = 1 + 0 2 2 2 2 x x x x dx z − + + F HG I KJ L N MM O Q PP = 1 – 4x – 3 2 x2 – x3 – x4 4 – x5 20 . Example 2. Solve by Picard’s method, the differential equations dy dx = z, dz dx = x3 (y + z) where y = 1, z = 1 2 at x = 0. Obtain the values of y and z from III approximation when x = 0.2 and x = 0.5.
  • 503. 490 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Let φ(x, y, z) = z, f(x, y, z) = x3(y + z) Here x0 = 0, y0 = 1, z0 = 1 2 First approximation, y(1) = y0 + 0 0 0 x x y z dx z φ( , , ) = 1 + 0 0 x z dx z = 1 + 1 2 x z(1) = z0 + 0 0 0 0 3 0 0 1 2 x x f x y z dx x y z dx z z = + + ( , , ) ( ) = 1 2 3 2 4 4 + x . Second approximation, y(2) = 1 + 0 1 x z dx z ( ) = 1 + 0 4 1 2 3 8 x x dx z + F HG I KJ = 1 + x 2 3 40 + x5 z(2) = 1 2 0 3 1 1 + + zx x y z dx { } ( ) ( ) = 1 2 3 2 2 3 8 0 3 4 + + + F HG I KJ zx x x x dx = 1 2 3 8 10 3 64 4 5 8 + + + x x x Third approximation, y(3) = 1 + z dx x ( ) 2 0 z = 1 + 0 4 5 8 1 2 3 8 10 3 64 x x x x dx z + + + F HG I KJ = 1 + x x x x 2 3 40 60 3 576 5 6 9 + + + z(3) = 1 2 3 2 2 0 + + z x y z dx x { } ( ) ( ) = 1 2 3 2 2 3 8 7 40 3 64 0 3 4 5 8 + + + + + R S T U V W zx x x x x x dx = 1 2 3 2 4 1 2 5 3 8 8 7 40 9 3 64 12 4 5 8 9 12 + + + + + . . . . . x x x x x
  • 504. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 491 = 1 2 3 8 + x4 + x5 10 3 64 + x8 + 7 360 x9 + 3 768 x12 when x = 0.2 y(3) = 1 + 0.1 + 3 40 (0.2)5 + ( . ) 0 2 60 3 576 6 + (0.2)9 = 1.100024 (leaving higher terms) z(3) = 1 2 3 8 + (.2)4 + (. ) 2 10 3 64 5 + (.2)8 + 7 360 (.2)9 + 3 768 (.2)12 = .500632 (leaving higher terms) when x = 0.5 y(3) = 1 + .5 2 3 40 + (.5)5 + (. ) 5 60 3 576 6 + (.5)9 = 1.25234375 z(3) = 1 2 3 8 + (.5)4 + (. ) 5 10 3 64 5 + (.5)8 + 7 360 (.5)9 + 3 768 (.5)12 = .5234375. ASSIGNMENT 6.1 1. For the differential equation dy dx = x – y2, y(0) = 0 Calculate y(0.2) by Picard’s method to third approximations and round-off the value at the 4th place of decimals. 2. Find y(0.2) if dy dx = log (x + y); y(0) = 1. Use Picard’s method. 3. Employ Picard’s method to obtain the solution of dy dx = x2 + y2 for x = 0.1 correct to four decimal places, given that y = 0 when x = 0. 4. Find an approximate value of y when x = 0.1 if dy dx = x – y2 and y = 1 at x = 0 using Picard’s method. 5. Solve numerically dy dx = 2x – y, y(0) = 0.9 at x = 0.4 by Picard’s method with three iterations and compare the result with the exact value. 6. Employ Picard’s method to find y (0.2) and y (0.4) given that dy dx = 1 + y2 and y (0) = 0. 7. Explain Picard’s method of successive approximation for numerical solution of ordinary differential equations.
  • 505. 492 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 8. Approximate y and z by using Picard’s method for the solution of simultaneous differential equations dy dx = 2x + z, dz dx = 3xy + x2z with y = 2, z = 0 at x = 0 up to third approximation. 9. Using Picard’s method, obtain the solution of dy dx = x(1 + x3y), y (0) = 3 Tabulate the values of y(0.1), y(0.2). 6.8 EULER’S METHOD Euler’s method is the simplest one-step method and has a limited application because of its low accuracy. This method yields solution of an ordinary differential equation in the form of a set of tabulated values. In this method, we determine the change Δy is y corresponding to small increase in the argument x. Consider the differential equation dy dx f x y = ( , ) , y(x0) = y0 (7) Let y = g(x) be the solution of (7). Let x0, x1, x2, ...... be equidistant values of x. In this method, we use the property that in a small interval, a curve is nearly a straight line. Thus at the point (x0, y0), we approximate the curve by the tangent at the point (x0, y0). Y O X Q1 Q2 P0 x0 x1 x2 y0 y1 y2 slope f(x , y ) 0 0 slope f(x , y ) 1 1 y = g ( x ) The eqn. of the tangent at P0(x0, y0) is y – y0 = dy dx x x F HG I KJP0 0 ( – ) = f(x0, y0) (x – x0) ⇒ y = y0 + (x – x0) f(x0, y0) (8)
  • 506. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 493 This gives the y-coordinate of any point on the tangent. Since the curve is approximated by the tangent in the interval (x0, x1), the value of y on the curve corresponding to x = x1 is given by the above value of y in eqn. (8) approximately. Putting x = x1(= x0 + h) in eqn. (8), we get y1 = y0 + hf(x0, y0) Thus Q1 is (x1, y1) Similarly, approximating the curve in the next interval (x1, x2) by a line through Q1(x1, y1) with slope f(x1, y1), we get y2 = y1 + hf(x1, y1) In general, it can be shown that, yn+1 = yn + hf(xn, yn) This is called Euler’s Formula. A great disadvantage of this method lies in the fact that if dy dx changes rapidly over an interval, its value at the beginning of the interval may give a poor approximation as compared to its average value over the interval and thus the value of y calculated from Euler’s method may be in much error from its true value. These errors accumulate in the succeeding intervals and the value of y becomes erroneous. In Euler’s method, the curve of the actual solution y = g(x) is approximated by a sequence of short lines. The process is very slow. If h is not properly chosen, the curve P0Q1Q2 ...... of short lines representing numerical solution deviates significantly from the curve of actual solution. To avoid this error, Euler’s modified method is preferred because in this, we consider the curvature of the actual curve inplace of approximating the curve by sequence of short lines. 6.9 ALGORITHM OF EULER’S METHOD 1. Function F(x,y)=(x–y)/(x+y) 2. Input x0,y0,h,xn 3. n=((xn–x0)/h)+1 4. For i=1,n 5. y=y0+h*F(x0,y0) 6. x=x+h NOTE
  • 507. 494 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7. Print x0,y0 8. If xxn then x0=x y0=y ELSE 9. Next i 10. Stop 6.10 FLOW-CHART OF EULER’S METHOD For i = 1, n START F(x, y) = (x – y)/(x + y) Input x0, y0, h, xn n = (xn – x0)/h + 1 y = y0 + h*F(x0, y0) x = x + h Print x0, y0 If x xn x0 = x y0 = y STOP No Yes
  • 508. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 495 6.11 PROGRAM OF EULER’S METHOD #includestdio.h #define F(x,y) (x–y)/(x+y) main ( ) { int i,n; float x0,y0,h,xn,x,y; printf(n Enter the values: x0,y0,h,xn: n); scanf (%f%f%f%f,x0,y0,h,xn); n=(xn–x0)/h+1; for (i=1;i=n;i++) { y=y0+h*F(x0,y0); x=x0+h; printf(n X=%f Y=%f,x0,y0); if(xxn) { x0=x; y0=y; } } return; } 6.11.1 Output Enter the values: x0,y0,h,xn: 0 1 0.02 0.1 X=0.000000 Y=1.000000 X=0.020000 Y=0.980000 X=0.040000 Y=0.960800 X=0.060000 Y=0.942399 X=0.080000 Y=0.924793 X=0.100000 Y=0.907978
  • 509. 496 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.11.2 Notations used in the Program (i) x0 is the initial value of x. (ii) y0 is the initial value of y. (iii) h is the spacing value of x. (iv) xn is the last value of x at which value of y is required. 6.12 MODIFIED EULER’S METHOD The modified Euler’s method gives greater improvement in accuracy over the original Euler’s method. Here the core idea is that we use a line through (x0, y0) whose slope is the average of the slopes at (x0, y0)and (x1, y1 (1)) where y1 (1) = y0 + hf(x0, y0). This line approximates the curve in the interval (x0, x1). Geometrically, if L1 is the tangent at (x0, y0), L2 is a line through (x1, y1 (1)) of slope f(x1, y1 (1)) and L is the line through (x1, y1 (1)) but with a slope equal to the average of f(x0, y0) and f(x1, y1 (1)) then the line L through (x0, y0) and parallel to L is used to approximate the curve in the interval (x0, x1). Thus the ordinate of the point B will give the value of y1. Now, the eqn. of the line AL is given by Y O X x0 x1 A L1 L2 L L B (x , y ) 1 1 (x , y ) 1 1 (1) (x , y ) 0 0 y1 = y0 + (x1 – x0) f x y f x y ( , ) ( , ) (1) 0 0 1 1 2 + L N MM O Q PP = y0 + h f x y f x y ( , ) ( , ) ( ) 0 0 1 1 1 2 + L NMM O QPP
  • 510. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 497 A generalised form of Euler’s modified formula is y1 (n+1) = y0 + h 2 [f(x0, y0) + f{x1, y1 (n)}] ; n = 0, 1, 2, ...... where y1 (n) is the nth approximation to y1. The above iteration formula can be started by choosing y1 (1) from Euler’s formula y1 (1) = y0 + hf(x0, y0) Since this formula attempts to correct the values of yn+1 using the predicted value of yn+1 (by Euler’s method), it is classified as a one-step predictor-corrector method. 6.13 ALGORITHM OF MODIFIED EULER’S METHOD 1. Function F(x)=(x–y)/(x+y) 2. Input x(1),y(1),h,xn 3. yp=y(1)+h*F(x(1),y(1)) 4. itr=(xn–x(1))/h 5. Print x(1),y(1) 6. For i=1,itr 7. x(i+1)=x(i)+h 8. For n=1,50 9. yc(n+1)=y(i)+(h/2*(F(x(i),y(i))+F(x(i+1),yp)) 10. Print n,yc(n+1) 11. p=yc (n+1)-yp 12. If abs(p).0001 then goto Step 14 ELSE yp=yc(n+1) 13. Next n 14. y(i+1)=yc(n+1) 15. print x(i+1),yp 16. Next i 17. Stop
  • 511. 498 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.14 FLOW-CHART OF MODIFIED EULER’S METHOD START F(x) = (x – y)/(x + y) Input x(1), y(1), h, xn itr = (xn – x(1))/h Print x(1), y(1) yp = y(1) + h*F(x(1), y(1)) For i = 1, itr x(i + 1) = x(i) + h Print n, yc(n + 1) If abs(p) 0.0001 yp = yc(n + 1) STOP No Yes For n = 1, 50 yc(n + 1) = y(i) + (h/2*(F(x(i), y(i)) + F(x(i + 1), yp)) p = yc(n + 1) – yp y(i + 1) = yc(n + 1) Print x(i + 1), yp
  • 512. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 499 6.15 PROGRAM OF MODIFIED EULER’S METHOD #includestdio.h #includemath.h #define F(x,y) (x-y)/(x+y) main () { int i,n,itr ; float x[5],y[50],yc[50],h,yp,p,xn; printf(n Enter the values: x[1],y[1],h,xn:n); scanf(%f%f%f%f,x[1],y[1],h,xn); yp=y[1]+h*F(x[1],y[1]); itr=(xn-x[1])/h; printf(nn X=%f Y=%fn,x[1],y[1]; for (i=1;i=itr;i++) { x[i+1]=x[i]+h; for (n=1;n=50;n++) { yc[n+1]=y[i]+(h/2.0)*(F(x[i],y[i])+F(x[i+1],yp)); printf(nN=%d Y=%f,n,yc[n+1]); p=yc[n+1]-yp; if(fabs (p)0.0001) goto next; else yp=yc[n+1]; } next: y[i+1]=yc[n+1]; printf(nn X=%f Y=%fn,x[i+1], yp); } return; }
  • 513. 500 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.15.1 Output Enter the values: x[1],y[1],h,xn: 0 1 0.02 0.06 X=0.000000 Y=1.000000 N=1 Y=0.980400 N=2 Y=0.980400 X=0.020000 Y=0.980400 N=1 Y=0.961584 N=2 Y=0.961598 X=0.040000 Y=0.961584 N=1 Y=0.943572 N=2 Y=0.943593 X=0.060000 Y=0.943572 6.15.2 Notations used in the Program (i) x(1) is an array of the initial value of x. (ii) y(1) is an array of the initial value of y. (iii) h is the spacing value of x. (iv) xn is the last value of x at which value of y is required. EXAMPLES Example 1. Given dy dx y – x y x = + with y = 1 for x = 0. Find y approximately for x = 0.1 by Euler’s method. Sol. We have dy dx = f(x, y) = y x y x – + ; x0 = 0, y0 = 1, h = 0.1 Hence the approximate value of y at x = 0.1 is given by y1 = y0 + hf(x0, y0) | using yn+1 = yn + hf(xn, yn) = 1 + (.1) + 1 0 1 0 – + F HG I KJ = 1.1 Much better accuracy is obtained by breaking up the interval 0 to 0.1 into five steps. The approximate value of y at xA = .02 is given by,
  • 514. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 501 y1 = y0 + hf(x0, y0) = 1 + (.02) 1 0 1 0 – + F HG I KJ = 1.02 At xB = 0.04, y2 = y1 + hf(x1, y1) = 1.02 + (.02) 102 02 102 02 . – . . . + F HG I KJ = 1.0392 At xC = .06, y3 = 1.0392 + (.02) 1.0392 – .04 1.0392 .04 + F HG I KJ = 1.0577 At xD = .08, y4 = 1.0577 + (.02) 1.0577 – .06 1.0577 .06 + F HG I KJ = 1.0756 At xE = .1, y5 = 1.0756 + (.02) 1.0756 – .08 1.0756 .08 + F HG I KJ = 1.0928 Hence y = 1.0928 when x = 0.1 Y O X A¢ A B C D E B¢ C¢ D¢ E¢ Example 2. Solve the equation dy dx 1 – y = with the initial condition x = 0, y = 0 using Euler’s algorithm and tabulate the solutions at x = 0.1, 0.2, 0.3. Sol. Here, f(x, y) = 1 – y Taking h = 0.1, x0 = 0, y0 = 0, we obtain y1 = y0 + hf(x0, y0) = 0 + (.1) (1 – 0) = .1 ∴ y(0.1) = 0.1
  • 515. 502 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Again, y2 = y1 + hf(x1, y1) = 0.1 + (0.1) (1 – .1) = 0.1 + .09 = .19 ∴ y(0.2) = 0.19 Again, y3 = y2 + hf(x2, y2) = .19 + (.1) (1 – .19) = .19 + (.1) (.81) = .271 ∴ y(0.3) = .271 Tabulated values are x y(x) 0 0 0.1 0.1 0.2 0.19 0.3 0.271 Example 3. Using Euler’s modified method, obtain a solution of the equation dy dx x | y| f(x, y) = + = with initial condition y = 1 at x = 0 for the range 0 ≤ x ≤ 0.6 in steps of 0.2. Sol. Here f(x, y) = x +| | y ; x0 = 0, y0 = 1, h = .2 ∴ f(x0, y0) = x0 +| | y 0 = 0 + 1 = 1 We have y1 (1) = y0 + hf(x0, y0) = 1 + (.2) . 1 = 1.2 ∴ f(x1, y1 (1)) = x1 + | | ( ) y 1 1 = 0.2 +| . | 12 = 1.2954 The second approximation to y1 is y1 (2) = y0 + h f x y f x y ( , ) { , } ( ) 0 0 1 1 1 2 + L NMM O QPP = 1 + (0.2) 1 12954 2 + F HG I KJ . = 1.2295
  • 516. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 503 Again, f{x1, y1 (2)} = x1 +| | ( ) y1 2 = 0.2 + 12295 . = 1.3088 So, y1 (3) = y0 + h 2 [f(x0, y0) + f{x1, y1 (2)}] = 1 + 0 2 2 . [1 + 1.3088] = 1.2309 We have f{x1, y1 (3)} = 0.2 + 12309 . = 1.309 Then y1 (4) = 1 + .2 2 [1 + 1.309] = 1.2309 Since, y1 (4) = y1 (3) hence y1 = 1.2309 Now, y2 (1) = y1 + hf(x1, y1) = 1.2309 + (0.2) [0.2 + 12309 . ] = 1.4927 |∵ x1 = 0.2 f{x2, y2 (1)} = x2 + y2 1 ( ) = 0.4 + 14927 . = 1.622 |∵ x2 = 0.4 Then, y2 (2) = y1 + h 2 [f(x1, y1) + f{x2, y2 (1)}] = 1.2309 + 0 2 2 2 12309 1622 . [(. . ) . ] + + = 1.524 Now, y2 (3) = y1 + h f x y f x y 2 1 1 2 2 2 [ ( , ) { , }] ( ) + = 1.2309 + 0 2 2 2 12309 4 1524 . [(. . ) (. . )] + + + = 1.5253 y2 (4) = 1.2309 + 0.2 2 [(. . ) (. . )] 2 12309 4 15253 + + + Since, y2 (4) = y2 (3) hence y2 = 1.5253 Now, y3 (1) = y2 + hf(x2, y2) = 1.5253 + (0.2) [.4 + 15253 . ] = 1.8523 y3 (2) = y2 + h 2 [f(x2, y2) + f{x3, y3 (1)}] = 1.5253 + 0 2 2 4 15253 6 18523 . [(. . ) (. . )] + + + = 1.8849
  • 517. 504 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Similarly, y3 (3) = 1.8861 = y3 (4) Since, y3 (3) = y3 (4) Hence, we take y3 = 1.8861. Example 4. Given that dy dx log (x y) 10 = + with the initial condition that y = 1 when x = 0. Find y for x = 0.2 and x = 0.5 using Euler’s modified formula. Sol. Let x = 0, x1 = 0.2, x2 = .5 then y0 = 1 y1 and y2 are yet to be computed. Here, f(x, y) = log (x + y) ∴ f(x0, y0) = log 1 = 0 ∴ y1 (1) = y0 + hf(x0, y0) = 1 f{x1, y1 (1)} = log {x1 + y1 (1)} = log (.2 + 1) = log (1.2) ∴ y1 (2) = y0 + h 2 [f(x0, y0) + f{x1, y1 (1)}] = 1 + .2 2 [0 + log (1.2)] = 1.0079 Also, y1 (3) = 1 + .2 2 [0 + log (.2 + 1.0079)] = 1.0082 y1 (4) = 1 + .2 2 [0 + log (.2 + 1.0082)] = 1.0082 Since, y1 (4) = y1 (3) hence y1 = 1.0082 To obtain y2, the value of y at x = 0.5, we take, y2 (1) = y1 + hf(x1, y1) = 1.0082 + 0.3 log (.2 + 1.0082) = 1.0328 (∵ h = .5 – .2 = .3 here) Now, y2 (2) = y1 + h 2 [f(x1, y1) + f{x2, y2 (1)}] = 1.0082 + .3 2 [log (.2 + 1.0082) + log (.5 + 1.0328)] = 1.0082 + 0.0401 = 1.0483 Also, y2 (3) = 1.0082 + .3 2 [log (.2 + 1.0082) + log (.5 + 1.0483)] = 1.0082 + .0408 = 1.0490
  • 518. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 505 Similarly, y2 (4) = 1.0490 Since, y2 (3) = y2 (4) hence, y2 = 1.0490. Example 5. Given : dy dx = x – y2 ; y(.2) = 0.2, find y(.4) by modified Euler’s method correct to 3 decimal places, taking h = 0.2. Sol. Here, f(x, y) = x – y2 ; x0 = 0.2, y0 = .02 and h = 0.2 Let x1 = 0.4 then we are to find y1 = y(0.4) We have f(x0, y0) = x0 – y0 2 = 0.2 – (.02)2 = 0.2 – .0004 = 0.1996 ∴ y1 (1) = y0 + hf(x0, y0) = .02 + (.2) (.1996) = .060 f{x1, y1 (1)} = x1 – {y1 (1)}2 = .4 – (.06)2 = .3964 ∴ y1 (2) = y0 + h 2 [f(x0, y0) + f{x1, y1 (1)}] = .02 + .2 2 [.1996 + .3964] = .0796 ~ − .080 Now, f{x1, y1 (2)} = x1 – [y1 (2)]2 = .4 – (.08)2 = .3936 ∴ y1 (3) = y0 + h 2 [f(x0, y0) + f{x1, y1 (2)}] = .02 + .2 2 [.1996 + .3936] = .07932 ~ − .079 f{x1, y1 (3)} = x1 – [y1 (3)]2 = .4 – (.079)2 = .3938 ∴ y1 (4) = y0 + h 2 [f(x0, y0) + f{x1, y1 (3)}] = .02 + .2 2 [.1996 + .3938] = .0793 ~ − .079 Since y1 (3) = y1 (4) hence y1 = .079. ASSIGNMENT 6.2 1. Find y for x = 0.2 and x = 0.5 using modified Euler’s method, given that dy dx x y e = + log ( ); y(0) = 1 2. Taking h = .05, determine the value of y at x = 0.1 by Euler’s modified method, given that, dy dx = x2 + y; y(0) = 1
  • 519. 506 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3. Given dy dx x y = + 2 , y(0) = 1, find y(.02), y(.04) and y(.06) using Euler’s modified method. 4. Apply Euler’s method to the initial value problem dy dx = x + y, y(0) = 0 at x = 0 to x = 1.0 taking h = 0.2. 5. Use Euler’s method with h = 0.1 to solve the differential equation dy dx = x2 + y2, y(0) = 1 in the range x = 0 to x = 0.3. 6. Solve for y at x = 1.05 by Euler’s method, the differential equation dy dx y x = F HG I KJ 2 – where y = 2 when x = 1. (Take h = 0.05). 7. Use Euler’s modified method to compute y for x = .05 and .10. Given that dy dx x y = + with the initial condition x0 = 0, y0 = 1. Give the correct result up to 4 decimal places. 8. Using Euler’s method, compute y(0.04) for the differential eqn. dy dx y = – ; y(0) = 1. Take h = 0.01. 9. Compute y(0.5) for the differential eqn. dy dx = y2 – x2 with y(0) = 1 using Euler’s method. 10. Find y(2.2) using modified Euler’s method for dy dx = – xy2; y(2) = 1. Take h = .1. 11. Given dy dx x y y = + = 3 0 1 , ( ) . Compute y (0.02) by Euler’s method taking h = 0.01. 12. Find y(1) by Euler’s method from the differential equation dy dx y x = + – 1 when y(0.3) = 2. Convert up to four decimal places taking step length h = 0.1. 6.16 TAYLOR’S METHOD Consider the differential equation dy dx = f(x, y) U V W (9) with the initial condition y(x0) = y0. If y(x) is the exact solution of (9) then y(x) can be expanded into a Taylor’s series about the point x = x0 as y(x) = y0 + (x – x0) y0′ + ( ) ! x x − 0 2 2 y0″ + ( ) ! x x − 0 3 3 y0′″ + ...... (10) where dashes denote differentiation with respect to x.
  • 520. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 507 Differentiating (9) successively with respect to x, we get y″ = ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ f x f y dy dx f x f f y x f y + = + = + F HG I KJf (11) ∴ y″′ = d dx (y″) = ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ x f y f x f f y + F HG I KJ + F HG I KJ = ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ ∂ 2 2 2 2 2 2 2 2 f x f x f y f f x y f f y x f f y f f y + + + + F HG I KJ + (12) and so on. Putting x = x0 and y = y0 in the expressions for y′, y″, y″′, ....... and substituting them in eqn. (10), we get a power series for y(x) in powers of x – x0. i.e., y(x) = y0 + (x – x0)y0′ + ( ) ! x x − 0 2 2 y0″ + ( ) ! x x − 0 3 3 y0″′ + ....... (13) Putting x = x1 (= x0 + h) in (13), we get y1 = y(x1) = y0 + hy0′ + h2 2 ! y0″ + h3 3 ! y0″′ + ....... (14) Here y0′, y0″, y0″′, ...... can be found by using (9) and its successive differentiations (11) and (12) at x = x0 . The series (14) can be truncated at any stage if h is small. After obtaining y1, we can calculate y1′, y1″, y1″′, ...... from (9) at x1 = x0 + h. Now, expanding y(x) by Taylor’s series about x = x1, we get y2 = y1 + hy′1 + h2 2 ! y1″ + h3 3 ! y1″′ + ....... Proceeding, we get yn = yn –1 + hyn–1′ + h2 2 ! yn–1″ + h3 3 ! yn–1″′ + ........ Practically, this method is not of much importance because of its need of partial derivatives. Moreover if we are interested in a better approximation with a small truncation error, the evaluation of higher order derivatives is needed which are complicated in evaluation. Besides its impracticability, it is useful in judging the degree of accuracy of the approximations given by other methods.
  • 521. 508 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES We can determine the extent to which any other formula agrees with the Taylor’s series expansion. Taylor’s method is one of those methods which yield the solution of a differential equation in the form of a power series. This method suffers from a serious disadvantage that h should be small enough so that successive terms in the series diminish quite rapidly. 6.17 TAYLOR’S METHOD FOR SIMULTANEOUS I ORDER DIFFERENTIAL EQUATIONS Simultaneous differential equations of the type dy dx = f(x, y, z) (15) and dz dx = φ(x, y, z) (16) with initial conditions y(x0) = y0 and z(x0) = z0 can be solved by Taylor’s method. If h is the step-size then y1 = y(x0 + h) and z1 = z(x0 + h) Taylor’s algorithm for (15) and (16) gives y1 = y0 + hy0′ + h2 2! y0″ + h3 3 ! y0″′ + ...... (17) and z1 = z0 + hz0′ + h2 2! z0″ + h3 3 ! z0″′ + ...... (18) Differentiating (15) and (16) successively, we get y″, y″′, ......., z″, z″′, ...... etc. So the values y0″, y0″′, ...... and z0″, z0″′, ...... can be obtained. Substituting them in (17) and (18), we get y1, z1 for the next step. y2 = y1 + hy1′ + h2 2 ! y1″ + h3 3 ! y1′″ + ...... and z2 = z1 + hz1′ + h2 2 ! z1″ + h z 3 1 3! ″ ′ + ....... Since y1 and z1 are known, y1′, y1″, y1″′......., z1′, z1″, z1″′, ....... can be calculated. Hence y2 and z2 can be obtained. Proceeding in this manner, we get other values of y, step-by-step.
  • 522. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 509 EXAMPLES Example 1. Use Taylor’s series method to solve dy dx = x + y; y(1) = 0 numerically up to x = 1.2 with h = 0.1. Compare the final result with the value of explicit solution. Sol. Here, x0 = 1, y0 = 0 y′ = x + y i.e., y0′ = x0 + y0 = 1 ⇒ y″ = 1 + y′ i.e., y0″ = 1 + y0′ = 2 ⇒ y″′ = y″ i.e., y0″′ = y0″ = 2 ⇒ y(iv) = y″′ i.e., y0 (iv) = 2 ⇒ y(v) = y(iv) i.e., y0 (v) = 2 By Taylor’s series, we have y1 = y0 + hy0′ + h2 2! y0″ + h3 3 ! y0″′ + h4 4 ! y0 (iv) + ...... y(1 + h) = 0 + (0.1) 1 + (0.1) 2 ! 2 2 + (0.1) 3 ! 3 2 + (0.1) 4 ! 4 2 + ...... ⇒ y(1.1) = 0.1103081 = 0.110 (app.) Also, x1 = x0 + h = 1.1 Again, y1′ = x1 + y1 = 1.1 + 0.11 = 1.21 y1″ = 1 + y1′ = 1 + 1.21 = 2.21 y1″′ = y1″ = 2.21 y1 (iv) = 2.21 y1 (v) = 2.21 Now, y(1.1 + h) = y1 + hy1′ + h2 2 ! y1″ + h3 3 ! y1″′ + ...... = 0 . 11 + (0.1) (1.21) + ( . ) 0 1 2 2 (2.21) + ...... ⇒ y(1.2) = 0.232 (app.)
  • 523. 510 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The analytical solution of the given differential equation is y = – x – 1 + 2ex –1 when x = 1.2, we get y = – 1.2 – 1 + 2e0.2 = 0.242. Example 2. For the differential eqn., dy dx = – xy2, y (0) = 2. Calculate y(0. 2) by Taylor’s series method retaining four non-zero terms only. Sol. Here x0 = 0, y0 = 2 Also y′ = – xy2 Taylor’s series for y(x) is given by y(x) = y0 + xy0′ + x2 2 y0″ + x3 6 y0″′ + x4 24 y0 (iv) + x5 120 y0 (v) + ....... (19) The values of the derivatives y0′, y0″, ......., etc. are obtained as follows: y′ = – xy2 y0′ = – x0y0 2 = 0 y″ = – y2 – 2xyy′ y 0″ = – 22 – 0 = – 4 y′″ = – 4yy′ – 2xy′2 – 2xyy″ y0′″ = 0 y(iv) = – 6y′2 – 6y′y″ – 6xy′y″ – 2xyy′″ y0 (iv) = 48 y(v) = – 24y′y″ – 8yy′″ – 6xy″2 y0 (v) = 0 – 8xy′y″′ – 2xyy(iv) y(vi) = – 40y′y′″ – 30y″2 – 10 yy(iv) – 20xy″y″′ y0 (vi) = – 1440 – 10xy′ y(iv) – 2xyy(v). We stop here as we shall get four non-zero terms in the Taylor’s series (19). ∴ y(x) = 2 + x2 2 (– 4) + x4 24 (48) + x6 720 (– 1440) + ...... = 2 – 2x2 + 2x4 – 2x6 + ....... ∴ y(0.2) = 2 – 2(0.2)2 + 2(0.2)4 – 2 (0.2)6 + ...... = 2 – 0.08 + 0.0032 – 0.000128 = 1.923072 ~ − 1.9231 correct up to four decimal places. Example 3. From the Taylor’s series, for y(x), find y(0.1) correct to four decimal places if y(x) satisfies dy dx = x – y2 and y(0) = 1. Also find y(0.2).
  • 524. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 511 Sol. Here x0 = 0, y0 = 1 y′ = x – y2 y0′ = 0 – 1 = – 1 y″ = 1 – 2yy′ y0″ = 3 y″′ = – 2yy″ – 2y′2 y0′″ = – 8 y(iv) = – 2yy′″ – 6y′y″ y0 (iv) = 34 y(v) = – 2yy(iv) – 8y′y′″ – 6y″2 y0 (v) = – 186 y(vi) = – 2yy(v) – 10y′y(iv) – 20 y″y′″ y0 (vi) = 1192 U V W y(vii) = – 2yy(vi) – 12y′y(v) – 50 y″y(iv) y0 (vii) = – 10996 only for y(0.2) – 20 y′″2 Using these values, Taylor’s series becomes y(x) = 1 – x + 3 2 x2 – 4 3 x3 + 17 12 x4 – 31 20 x5 + ...... (20) Put x = 0.1 in (20), we get y(0.1) = 0.91379 ~ − 0.9138 (upto four decimal places) To determine y(0.2), we have y(x) = 1 – x + 3 2 x2 – 4 3 x3 + 17 12 x4 – 31 20 x5 + 1192 720 x6 – 10996 5040 x7 + ........ = 0.8512 (correct to four decimal places). Example 4. Using Taylor’s series, find the solution of the differential equation xy′ = x – y, y(2) = 2 at x = 2.1 correct to five decimal places. Sol. Here x0 = 2, y0 = 2 Also, y′ = 1 – y x y0′ = 0 y″ = – ′ + y x y x2 y0″ = – 0 + 2 4 1 2 = y″′ = − ′′ + ′ − y x y x y x 2 2 2 3 y0″′ = − 3 4 y(iv) = – ′′′ + ′′ − ′ + y x y x y x y x 3 6 6 2 3 4 y0 (iv) = 3 2 and so on. Putting these values in Taylor’s series, we get y(2 + h) = 2 + h h h 2 3 4 4 8 16 − + + .......
  • 525. 512 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Put h = 0.1, we get y (2.1) = 2.00238 (correct to 5 decimal places). Example 5. Find y(1) for dy dx = 2y + 3ex , y(0) = 0. Also check the value. Sol. Here x0 = 0, y0 = 0 y′(x) = 2y + 3ex y0′ = 3, y0″ = 9, y″(x) = 2y′ + 3ex y0″′ = 21, y0 (iv) = 45 : : : : y0 (v) = 93, y0 (vi) = 189 y(viii) (x) = 2y(vii) + 3ex y0 (vii) = 381, y0 (viii) = 765 Now, y(h) = 3h + 9 2 h2 + 7 2 h3 + 15 8 h4 + 31 40 h5 + 21 80 h6 + 127 1680 h7 + 17 896 h8 + ....... Put h = 1, y(1) = 14.01 Exact solution. dy dx – 2y = 3ex Solution is ye–2x = – 3e–x + c x = 0, y = 0 ∴ c = 3 ∴ ye–2x = – 3e–x + 3 ⇒ y = 3(e2x – ex) when x = 1, y = 3(e2 – e) = 14.01 correct to two decimal places. Example 6. Solve the simultaneous equations y′ = 1 + xyz, y (0) = 0 z′ = x + y + z, z(0) = 1. Sol. Differentiating the given equations y″ = yz + xy′z + xyz′, y″′ = 2y′z + 2yz′ + 2xy′z′ + xy″z + xyz″ z″ = 1 + y′ + z′, z″′ = y″ + z″ with x = 0, y = 0, z = 1; we get y′ = 1, y″ = 0, y″′ = 2
  • 526. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 513 Also z′ = 1, z″ = 3, z″′ = 3 Hence, y(x) = x + x3 3 and z(x) = 1 + x + 3 2 x2 + 1 2 x3. ASSIGNMENT 6.3 1. Compute y for x = 0.1 and 0.2 correct to four decimal places given: y′ = y – x, y (0) = 2. 2. Solve by Taylor’s method, y′ = x2 + y2, y(0) = 1 compute y(0.1). 3. Solve by Taylor’s method: y′ = y – 2x y ; y(0) = 1. Also compute y(0.1). 4. Using Taylor series method, solve dy dx = x2 – y, y(0) = 1 at x = 0.1, 0.2, 0.3 and 0.4. Compare the values with exact solution. 5. Solve dy dx = x + z, dz dx = x – y2 with y(0) = 2, z(0) = 1 to get y(0. 1), y(0. 2), z(0. 1) and z(0. 2) approximately by Taylor’s algorithm. 6. Given the differential equation dy dx x y = + 1 2 with y(4) = 4 Obtain y (4.1) and y(4.2) by Taylor’s series method. 6.18 RUNGE-KUTTA METHODS More efficient methods in terms of accuracy were developed by two German Mathematicians Carl Runge (1856-1927) and Wilhelm Kutta (1867-1944). These methods are well-known as Runge-Kutta methods. They are distinguished by their orders in the sense that they agree with Taylor’s series solution up to terms of hr where r is the order of the method. These methods do not demand prior computation of higher derivatives of y(x) as in Taylor’s method. In place of these derivatives, extra values of the given function f(x, y) are used. The fourth order Runge-Kutta method is used widely for finding the numerical solutions of linear or non-linear ordinary differential equations. Runge-Kutta methods are referred to as single step methods. The major disadvantage of Runge-Kutta methods is that they use many more evaluations of the derivative f(x, y) to obtain the same accuracy compared with multi-step methods. A class of methods known as Runge-Kutta methods combines the advantage of high order accuracy with the property of being one step.
  • 527. 514 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.18.1 First Order Runge-Kutta Method Consider the differential equation dy dx = f(x, y); y (x0) = y0 (21) Euler’s method gives y1 = y0 + hf(x0, y0) = y0 + hy0′ (22) Expanding by Taylor’s series, we get y1 = y(x0 + h) = y0 + hy0′ + h2 2 ! y0″ + ....... (23) Comparing (22) and (23), it follows that Euler’s method agrees with Taylor’s series solution up to the term in h. Hence Euler’s method is the first order Runge-Kutta method. 6.18.2 Second Order Runge-Kutta Method Consider the differential equation y′ = f(x, y) with the initial condition y(x0) = y0 Let h be the interval between equidistant values of x then in II order Runge- Kutta method, the first increment in y is computed from the formulae k1 = hf (x0, y0) k2 = hf(x0 + h, y0 + k1) Δy = 1 2 (k1 + k2) taken in the given order. Then, x1 = x0 + h y1 = y0 + Δy = y0 + 1 2 (k1 + k2) In a similar manner, the increment in y for the second interval is computed by means of the formulae, k1 = hf (x1, y1) k2 = hf (x1 + h, y1 + k1) Δy = 1 2 (k1 + k2) and similarly for the next intervals. The inherent error in the second order Runge-Kutta method is of order h3.
  • 528. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 515 6.18.3 Third Order Runge-Kutta Method This method gives the approximate solution of the initial value problem dy dx = f (x, y); y(x0) = y0 as y1 = y0 + δy U V W (24) where δy = h 6 (k1 + 4k2 + k3) Here, k1 = f (x0, y0) k2 = f x h y k 0 0 1 2 2 + + R S T U V W , k3 = f (x0 + h, y0 + k′); k′ = hf (x0 + h, y0 + k1) Formula (24) can be generalized for successive approximations. Expression in (24) agrees with Taylor’s series expansion for y1 up to and including terms in h3. This method is also known as Runge’s method. 6.19 FOURTH ORDER RUNGE-KUTTA METHOD The fourth order Runge-Kutta Method is one of the most widely used methods and is particularly suitable in cases when the computation of higher derivatives is complicated. Consider the differential equation y′ = f(x, y) with the initial condition y(x0) = y0. Let h be the interval between equidistant values of x, then the first increment in y is computed from the formulae k1 = hf (x0, y0) k2 = hf x h y k 0 0 1 2 2 + + F HG I KJ , k3 = hf x h y k 0 0 2 2 2 + + F HG I KJ , U V | | | | | W | | | | | (25) k4 = hf (x0 + h, y0 + k3) Δy = 1 6 (k1 + 2k2 + 2k3 + k4) taken in the given order. Then, x1 = x0 + h and y1 = y0 + Δy
  • 529. 516 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES In a similar manner, the increment in y for the II interval is computed by means of the formulae k1 = hf (x1, y1) k2 = hf x h y k 1 1 1 2 2 + + F HG I KJ , k3 = hf x h y k 1 1 2 2 2 + + F HG I KJ , k4 = hf (x1 + h, y1 + k3) Δy = 1 6 (k1 + 2k2 + 2k3 + k4) and similarly for the next intervals. This method is also simply termed as Runge-Kutta’s method. It is to be noted that the calculations for the first increment are exactly the same as for any other increment. The change in the formula for the different intervals is only in the values of x and y to be substituted. Hence, to obtain Δy for the nth interval, we substitute xn–1, yn–1, in the expressions for k1, k2, etc. The inherent error in the fourth order Runge-Kutta method is of the order h5. 6.19.1 Algorithm of Runge-Kutta Method 1. Function F(x)=(x-y)/(x+y) 2. Input x0,y0,h,xn 3. n=(xn-x0)/h 4. x=x0 5. y=y0 6. For i=0, n 7. k1=h*F(x,y) 8. k2=h*F(x+h/2,y+k1/2) 9. k3=h*F(x+h/2,y+k2/2) 10. k4=h*F(x+h,y+k3) 11. k=(k1+(k2+k3)2+k4)/6 12. Print x,y 13. x=x+h 14. y=y+k 15. Next i 16. Stop
  • 530. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 517 6.19.2 Flow-Chart of Runge-Kutta Method For i = 0, n START F(x) = (x – y)/(x + y) Input x0, y0, h, xn n = (xn – x0)/h x = x0 y = y0 k1 = h*F(x, y) k2 = h*F(x + h/2, y + k1/2) k3 = h*F(x + h/2, y + k2/2) k4 = h*F(x + h, y + k3) k = (k1 + 2(k2 + k3) + k4)/6 Print x, y x = x + h y = y + k STOP 6.19.3 Program of Runge-Kutta Method #includestdio.h #define F(x,y) (x-y)/(x+y) main() { int i,n; float x0,y0,h,xn,k1,k2,k3,k4,x,y,k; printf(n Enter the values: x0,y0,h,xn:n);
  • 531. 518 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES scanf(%f%f%f%f, x0,y0,h,xn); n=(xn-x0)/h; x=x0; y=y0; for(i=0;i=n;i++) { k1=h*F(x,y); k2=h*F(x+h/2.0,y+k1/2.0); k3=h*F(x+h/2.0,y+k2/2.0); k4=h*F(x+h,y+k3); k=(k1+(k2+k3)*2.0+k4)/6.0; printf(n X=%f Y=%f, x, y); x=x+h; y=y+k; } return; } 6.19.4 Output Enter the values: x0,y0,h,xn: 0 1 0.02 0.1 X=0.000000 Y=1.000000 X=0.020000 Y=0.980000 X=0.040000 Y=0.960816 X=0.060000 Y=0.942446 X=0.080000 Y=0.924885 X=0.100000 Y=0.908128 Notations used in the Program (i) x0 is the initial value of x. (ii) y0 is the initial value of y. (iii) h is the spacing value of x. (iv) xn is the last value of x at which value of y is required.
  • 532. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 519 6.20 RUNGE-KUTTA METHOD FOR SIMULTANEOUS FIRST ORDER EQUATIONS Consider the simultaneous equations dy dx = f1(x, y, z) dz dx = f2 (x, y, z) With the initial condition y(x0) = y0 and z(x0) = z0. Now, starting from (x0, y0, z0), the increments k and l in y and z are given by the following formulae: k1 = hf1(x0, y0, z0); l1 = hf2(x0, y0, z0) k2 = hf1 x h y k z l 0 0 1 0 1 2 2 2 + + + F HG I KJ , , ; l2 = hf2 x h y k z l 0 0 1 0 1 2 2 2 + + + F HG I KJ , , k3 = hf1 x h y k z l 0 0 2 0 2 2 2 2 + + + F HG I KJ , , ; l3 = hf2 x h y k z l 0 0 2 0 2 2 2 2 + + + F HG I KJ , , k4 = hf1(x0 + h, y0 + k3 , z0 + l3); l4 = hf2(x0 + h, y0 + k3 , z0 + l3) k = 1 6 (k1 + 2k2 + 2k3 + k4); l = 1 6 (l1 + 2l2 + 2l3 + l4) Hence y1 = y0 + k, z1 = z0 + l To compute y2, z2, we simply replace x0, y0, z0 by x1, y1, z1 in the above formulae.
  • 533. 520 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES EXAMPLES Example 1. Solve the equation dy dx = x + y with initial condition y(0) = 1 by Runge-Kutta rule, from x= 0 to x = 0.4 with h = 0.1. Sol. Here f(x, y) = x + y, h = 0.1, x0 = 0, y0 = 1 We have, k1 = hf (x0, y0) = 0.1 (0 + 1) = 0.1 k2 = hf x h y k 0 0 1 2 2 + + F HG I KJ , = 0.1 (0.05 + 1.05) = 0.11 k3 = hf x h y k 0 0 2 2 2 + + F HG I KJ , = 0.1105 k4 = hf (x0 + h, y0 + k3) = 0.12105 ∴ Δy = 1 6 (k1 + 2k2 + 2k3 + k4) = 0.11034 Thus, x1 = x0 + h = 0.1 and y1 = y0 + Δy = 1.11034 Now for the second interval, we have k1 = hf (x1, y1) = 0.1 (0.1 + 1.11034) = 0.121034 k2 = hf x h y k 1 1 1 2 2 + + F HG I KJ , = 0.13208 k3 = hf x h y k 1 1 2 2 2 + + F HG I KJ , = 0.13263 k4 = hf (x1 + h, y1 + k3) = 0.14429 ∴ Δy = 1 6 (k1 + 2k2 + 2k3 + k4) = 0.132460 Hence x2 = 0.2 and y2 = y1 + Δy = 1.11034 + 0.13246 = 1.24280 Similarly, for finding y3, we have k1 = hf (x2, y2) = 0.14428 k2 = 0.15649 k3 = 0.15710 Repeating the above process k4 = 0.16999
  • 534. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 521 ∴ y3 = 0.13997 and for y4 = y(0.4), we calculate k1 = 0.16997 k2 = 0.18347 k3 = 0.18414 k4 = 0.19838 ∴ y4 = 1.5836 Example 2. Given dy dx = y – x, y(0) = 2. Find y(0.1) and y(0.2) correct to four decimal places (use both II and IV order methods). Sol. By II order Method To find y(0.1) Here y′ = f (x, y) = y – x, x0 = 0, y0 = 2 and h = 0.1 Now, k1 = hf (x0, y0) = 0.1(2 – 0) = 0.2 k2 = hf (x0 + h, y0 + k1) = 0.21 ∴ Δy = 1 2 (k1 + k2) = 0.205 Thus, x1 = x0 + h = 0.1 and y1 = y0 + Δy = 2.205 To find y(0.2) we note that, x1 = 0.1, y1 = 2.205, h = 0.1 For interval II, we have k1 = hf (x1, y1) = 0.2105 k2 = hf (x1 + h, y1 + k1) = 0.22155 ∴ Δy = 1 2 (k1 + k2) = 0.216025 Thus, x2 = x1 + h = 0.2 and y2 = y1 + Δy = 2.4210 Hence y(0.1) = 2.205, y(0.2) = 2.421. By IV order method- As before k1 = 0.2, k2 = 0.205, k3 = hf (x0 + h/2, y0 + k2/2) = 0.20525 and k4 = hf (x0 + h, y0 + k3) = 0.210525
  • 535. 522 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ Δy = 1 6 (k1 + 2k2 + 2k3 + k4) = 0.2052 Thus, x1 = x0 + h = 0 + 0.1 = 0.1 y1 = y0 + Δy = 2 + 0.2052 = 2.2052 Now to determine y2 = y(0.2), we note that x1 = x0 + h = 0.1, y1 = 2.2052, h = 0.1 For interval II, k1 = hf (x1, y1) = 0.21052 k2 = hf x h y k 1 1 1 2 2 + + F HG I KJ , = 0.21605 k3 = hf x h y k 1 1 2 2 2 + + F HG I KJ / , = 0.216323 and k4 = hf (x1 + h, y1 + k3) = 0.221523 ∴ Δy = 1 6 (k1 + 2k2 + 2k3 + k4) = 0.21613 Thus, x2 = x1 + h = 0.1 + 0.1 = 0.2 and y2 = y1 + Δy = 2.2052 + 0.21613 = 2.4213 Hence y(0.1) = 2.2052, y(0.2) = 2.4213. Example 3. Solve dy dx = yz + x, dz dx = xz + y; given that y(0) = 1, z(0) = – 1 for y(0.1), z(0.1). Sol. Here, f1(x, y, z) = yz + x f2 (x, y, z) = xz + y h = 0.1, x0 = 0, y0 = 1, z0 = – 1 k1 = hf1 (x0, y0, z0) = h (y0 z0 + x0) = – 0.1 l1 = hf2(x0, y0, z0) = h(x0 z0 + y0) = 0.1 k2 = hf1 x h y k z l 0 0 1 0 1 2 2 2 + + + F HG I KJ , , = hf1(0.05, 0.95, – 0.95) = – 0.08525 l2 = hf2 x h y k z l 0 0 1 0 1 2 2 2 + + + F HG I KJ , , = hf2 (0.05, 0.95, – 0.95) = 0.09025
  • 536. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 523 k3 = hf1 x h y k z l 0 0 2 0 2 2 2 2 + + + F HG I KJ , , = hf1(0.05, 0.957375, – 0.954875) = – 0.0864173 l3 = hf2 x h y k z l 0 0 2 0 2 2 2 2 + + + F HG I KJ , , = hf2 (0.05, 0.957375, – 0.954875) = – 0.0864173 k4 = hf1 x h y k z l 0 0 3 0 3 + + + , , b g = – 0.073048. l4 = hf2(x0 + h, y0 + k3, z0 + l3) = 0.0822679 k = 1 6 (k1 + 2k2 + 2k3 + k4) = – 0.0860637 l = 1 6 (l1 + 2l2 + 2l3 + l4) = 0.0907823 ∴ y1 = y(0.1) = y0 + k = 1 – 0.0860637 = 0.9139363 z1 = z(0.1) = z0 + k = – 1 + 0.0907823 = – 0.9092176 ASSIGNMENT 6.4 1. Use the Runge-Kutta Method to approximate y when x = 0.1 given that x = 0 when y = 1 and dy dx = x + y. 2. Apply the Runge-Kutta Fourth Order Method to solve 10 dy dx = x2 + y2; y (0) = 1 for 0 x ≤ 0. 4 and h = 0.1. 3. Use Runge-Kutta Fourth Order Formula to find y(1.4) if y (1) = 2 and dy dx = xy. Take h = 0.2. 4. Prove that the solution of y′ = y, y(0) = 1 by Second Order Runge-Kutta Method yields ym = 1 2 2 + + F HG I KJ h h m . 5. Solve y′ = 1 x y + , y(0) = 1 for x = 0.5 to x = 1 by Runge-Kutta Method (h = 0.5). 6. Solve y′ = – xy2 and By Runge-Kutta Fourth Order Method, find y(0.6) given that y = 1.7231 at x = 0.4. Take h = 0.2.
  • 537. 524 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7. Use Runge-Kutta Method to find y when x = 1.2 in steps of 0.1 given that dy dx = x2 + y2 and y(1) = 1.5 8. Given y′ = x2 – y, y (0) = 1 find y(0.1), y(0.2) using Runge-Kutta Methods of (i) Second Order (ii) Fourth Order. 9. Using Runge-Kutta Method of Fourth Order, solve for y(0.1), y(0.2) and y(0.3), given that y′ = xy + y2, y(0) = 1. 10. Using Runge-Kutta Method, find y(0.2) for the equation dy dx y x y x = − + , y (0) = 1. Take h = 0.2 11. (i) Using Runge-Kutta Method, find y(0.2) given that dy dx = 3x + 1 2 y, y(0) = 1 taking h = 0.1. (ii) Use the classical Runge-Kutta Formula of Fourth Order to find the numerical solution at x = 0.8 for the differential equation y′ = x y + , y (0.4) = 0.41 Assume the step length h = 0.2. 12. Solve dy dx = x + z dz dx = x – y2 for y(0.1), z(0.1) given that y(0) = 2, z(0) = 1 by Runge-Kutta Method. 13. Use classical Runge-Kutta Method of Fourth Order to find the numerical solution at x = 1.4 for dy dx = y2 + x2, y(1) = 0. Assume step size h = 0.2. 14. Explain Runge-Kutta Method with a suitable example. Write a program in C to implement. 15. Write the main steps to be followed in using the Runge-Kutta Method of Fourth Order to solve an ordinary differential equation of the First Order. Hence solve dy dx = x3 + y3, y(0) = 1 and step length h = 0.1 upto three iterations. 16. Given dy dx = xy with y(1) = 5. Using the Fourth Order Runge-Kutta Method, find the solution in the interval (1, 1.5) using step size h = 0.1.
  • 538. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 525 17. Using the Runge-Kutta Method of Fourth Order, solve the following differential equation: dy dx y x y x = − + 2 2 2 2 with y (0) = 1 at x = 0.2, 0.4. Also write computer program in ‘C’ 18. Discuss the Fourth Order Runge-Kutta Method for solving differential equations. Give program for the solution of differential equation using Fourth Order Runge- Kutta Method. Use ‘C’ language. 6.21 PREDICTOR-CORRECTOR METHODS In Runge-Kutta Methods, we need only the information at (xi, yi) to calculate the value of yi + 1 and no attention is paid to the nature of the solution at the earlier points. To overcome this defect, Predictor-Corrector Methods are useful. The technique of refining an initially crude predicted estimate of yi by means of a more accurate corrector formula is called, Predictor-Corrector Method. The modified Euler’s Method of solving the initial value problem, y′ = f(x, y), y(x0) = y0 (26) can be stated as y1 p = y0 + hf(x0, y0) (27) y1 c = y0 + h 2 [f(x0, y0) + f(x1, y1 p)] (28) Here we predict the value of y1 by Euler’s Method and use it in (28) to get a corrected or improved value. This is a typical case of Predictor-Corrector Method. In this section, we will obtain two important Predictor-Corrector Methods, namely, Milne’s Simpson Method and Adams-Moulton (or Adams-Bash Fourth) Method. Both of these methods are of IV order and the error is of order h5. These methods make use of four starting values of y, namely, y0, y1, y2, and y3. Hence, these methods are also called as Multi-Step Methods. 6.22 MILNE’S METHOD Milne’s Method is a simple and reasonably accurate method of solving differential equations numerically. To solve the differential equation y′ = f(x, y) by this method, first we get the approximate value of yn + 1 by predictor formula and then improve this value using a corrector formula. These formula are derived from Newton’s Formula.
  • 539. 526 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Newton’s Forward Interpolation Formula in terms of y′ and u is y′ = y0′ + uΔy0′ + u u ( ) − 1 2 Δ2 y0′ + u u u ( ) ( ) − − 1 2 6 Δ3 y0′ + u u u u ( ) ( ) ( ) − − − 1 2 3 24 Δ4 y0′ + ....... (29) where u = x x h − 0 or x = x0 + uh Now integrating (29) over the interval x0 to x0 + 4h (or u = 0 to 4), we get ′ = ′ + z z y dx h y du x x h 0 0 4 0 4 | ∵ dx = h du or y4 – y0 = h 0 4 0 0 2 0 3 0 1 2 1 2 6 z ′ + ′ + − ′ + − − ′ L NMy u y u u y u u u y Δ Δ Δ ( ) ( ) ( ) + u u u u y du ( ) ( ) ( ) ...... − − − ′ + O QP 1 2 3 24 4 0 Δ = h 4 8 20 3 8 3 28 90 0 0 2 0 3 0 4 0 ′ + ′ + ′ + ′ + ′ F HG I KJ y y y y y Δ Δ Δ Δ | keeping up to IV differences Here, y0 and y4 stand for values of y at x = x0 and x = x0 + 4h respectively. Substituting the values of I, II and III differences, we get y4 – y0 = h 4 8 1 20 3 1 8 3 1 28 90 0 0 2 0 3 0 4 0 ′ + − ′ + − ′ + − ′ + ′ F HG I KJ y y y y y ( ) ( ) ( ) E E E Δ (30) = 4 3 h (2y1′ – y2′ + 2y3′) + 28 90 hΔ4y0′ or y4 = y0 + 4 3 h (2y1′ – y2′ + 2y3′) + 28 90 hΔ4 y0′ (31) This is Milne’s Predictor (Extrapolation) formula. It is used to predict the value of y4 when the value of y0, y1, y2, and y3 are known. To obtain the corrector formula, we integrate (29) over the interval x0 to x0 + 2h (or u = 0 to 2) and consequently. y2 – y0 = h 2 2 1 3 1 90 0 0 2 0 4 0 ′ + ′ + ′ − ′ F HG I KJ y y y y Δ Δ Δ
  • 540. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 527 Expressing the I, II and III differences in terms of the function value by using D ≡ E – 1, we obtain, y2 – y0 = h 3 (y0′ + 4y1′ + y2′) – h 90 Δ4y0′ ⇒ y2 = y0 + h 3 (y0′ + 4y1′ + y2′) – h 90 Δ4 y0′ (32) This is Milne’s Corrector Formula. The value of y4 obtained from (31) and (32) can be put as yn + 1 = yn–3 + 4 3 h (2y′n–2 – y′n–1 + 2yn′) (33) y′n + 1 = yn–1 + h 3 (y′n–1 + 4yn′ + y′n + 1) (34) It is to be noted that we have considered the differences up to the third order because we fit up a polynomial of degree four. The terms containing Δ4y0′ are not used explicitly in the formula, but they give the principal parts of the errors in the two values of yn + 1 as computed from (33) and (34). We notice that this error in (34) is of opposite sign to that in (33) but it is very small in magnitude. So we may take, (yn + 1)exact = yn + 1 + 28 90 hΔ4y′ and (yn + 1)exact = y(1) n + 1 – h 90 Δ4y′ where yn + 1 and y(1) n + 1 denote the predicted and first corrected value of y at x = xn + 1. Equating these two values, we get yn + 1 – y(1) n +1 = – 29 90 hΔ4y′ = 29 δ where δ = – h 90 Δ4y′ denotes the principal part of the error in (34). Thus it gives δ = 1 29 [yn + 1 – y(1) n + 1 ] Thus we observe that the error in (34) is 1 29 th of the difference between the predicted and corrected values.
  • 541. 528 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.22.1 Algorithm of Milne’s Predictor-Corrector Method 1. Function F(x,y)=x+y 2. Input xn 3. For i=0,3 4. Input x(i),y(i) 5. Next i 6. h=x(1)-x(0) 7. n=(xn-x(0))/h 8. For i=3,n 9. x(i+1)=x(i)+h 10. f=F(x(i),y(i)) 11. f1=F(x(i-1),y(i-1)) 12. f2=F(x(i-2),y(i-2)) 13. yp=y(i-3)+4h/3(2f2-f1+2f) 14. yc=y(i-1)+h/3(f1+4f+F(x(i+1),yp)) 15. If abs (yp-yc)0.0005 then y(i+1)=yc print x(i+1), y(i+1) ELSE yp=yc 16. Next i 17. Stop
  • 542. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 529 6.22.2 Flow-Chart of Milne’s Predictor Corrector Method For i = 0, 3 START F(x, y) = x + y Input xn Input x(i), y(i) h = x(1) – x(0) n = (xn – x(0)/h STOP For i = 3, n x(i + 1) = x(i) + h f = F(x(i), y(i)) f1 = F(x(i – 1), y(i – 1)) f2 = F(x(i – 2), y(i – 2)) yp = y(i – 3) + 4h/3 (2f2 – f1 + 2f) yc = y(i – 1) + h/3 (f1 + 4f + F(x(i + 1), yp)) If abs (yp – yc) 0.0005 Yes y(i + 1) = yc Print x(i + 1), y(i + 1) No yp = yc
  • 543. 530 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.22.3 Program of Milne’s Method #includestdio.h #includemath.h #define F(x,y) x+y main() { int i,n; float x[20],y[20],h,f,f1,f2,yp,yc,xn; printf(n Enter the value: xn: }; scanf{%f,xn); printf(n Enter the value: x{i], y[i]:n}; for(i=0;i=3;i++) scanf(%f%f,x[i],y[i]); h=x[1]-x[0]; n=(xn-x[0]/h; for(i=3;i=n;i++) { x[i+1]=x[i]+h; f=F[x[i],y[i]); f1=F(x[i-1],y[i-1]); f2=F(x[i-2],y[i-2]); yp=y[i-3]+4.0*h/3.0*(2.0*f2-f1+2.0*f); yc=y[i-1]+h/3.0*(f1+4.0*f+F(x[i+1],yp)); printf(nnPredicated Y=%f Correctd Y=%f, yp,yc); If(fabs (yp-yc)0.00005) goto next; yp=yc; next; y[i+1]=yc; printf(nn X=%f Y=%f, x[i+1], y[i+1]); } return; }
  • 544. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 531 6.22.4 Output Enter the value: xn: 1 Enter the value: x[i], y[i]: 0.0 0.0 0.2 0.02 0.4 0.0906 0.6 0.2214 Predicted Y=0.423147 Corrected Y=0.429650 X=0.800000 Y=0.429650 Predicted Y=0.721307 Corrected Y=0.718820 X=1.000000 Y=0.718820 Notations used in the Program (i) xn is the last value of x at which value of y is required. (ii) x(i) is an array for prior values of x. (iii) y(i) is an array for prior values of y. (iv) yp is the predicted value of y. (v) yc is the corrected value of y. EXAMPLES Example 1. Tabulate by Milne’s Method the numerical solution of dy dx = x + y with initial conditions x0 = 0, y0 = 1 from x = 0.20 to x = 0.30. Sol. To obtain the solution, we find three consecutive values of y and y′ corresponding to x = 0.05, 0.10 and 0.15, i.e., taking h = 0.05 x y y′ = dy/dx 0.00 1 1 0.05 1.0525 1.1025 0.10 1.1103 1.2103 0.15 1.1736 1.3236 (using y = 2ex – x – 1 (35) as explicit solution of given equations) In general form, Milne’s Predictor and Corrector Formulae are yn + 1 = yn – 3 + 4 3 h (2y′n – 2 – y′n – 1 + 2yn′) (36)
  • 545. 532 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES and yn + 1 (1) = yn – 1 + h 3 (y′n – 1 + 4yn′ + y′n + 1) (37) Put n = 3, h = 0.05 in (36), we get y4 = y0 + 4 3 h (2y1′ – y2′ + 2y3′) = 1 + 4 0 05 3 ( . ) [2.205 – 1.2103 + 2.6472] = 1.2428 (predicted value) It is corrected by y4 (1) = y2 + h 3 (y2′ + 4y3′ + y4′) = 1.1103 + 0 05 3 . [1.2103 + 5.2944 + 1.4428] = 1.2428 which is the same as predicted value. Put x = 0.20 and y = 1.2428 in dy dx = x + y, we get y4′ = 1.4428 Hence, y = 1.2428 when x = 0.20 and y′ = 1.4428 Now, put n = 4, h = 0.05 in (36), we get y5 = y1 + 4 3 h (2y2′ – y3′ + 2y4′) = 1.0525 + 4 0 05 3 ( . ) [2.4206 – 1.3236 + 2.8856] = 1.3180 which is corrected by y5 (1) = y3 + h 3 (y3′ + 4y4′ + y5′) = 1.1736 + 005 3 . (1.3236 + 5.7712 + 1.568) = 1.3180 which is same as predicted value. Thus, y5 = y0.25 = 1.3180 and y5′ = 1.5680 Again putting n = 5, h = 0.05, we get y6 = 1.3997 which is corrected by y6 (1) = 1.3997 = y0.30
  • 546. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 533 The same as the predicted value. y6 = 1.3997, y′6 = 1.6997 (y′ = x + y) Collecting the results in Tabular form, we get x y y′ = dy/dx x4 = 0.20 y4 = 1.2428 y4′ = 1.4428 x5 = 0.25 y5 = 1.3180 y5′ = 1.5680 x6 = 0.30 y6 = 1.3997 y6′ = 1.6997 Example 2. Find y(2) if y(x) is the solution of dy dx = 1 2 (x + y) where y(0) = 2, y(0.5) = 2.636, y(1) = 3.595, y(1.5) = 4.968 Sol. Let x0 = 0, x1 = 0.5, x2 = 1, x3 = 1.5 then we are given y0, y1, y2, y3 and we require y4 corresponding to x4 = 2. By Predictor Formula, we get y4 = y0 + 4 3 h (2y1′ – y2′ + 2y3′) (38) we have, y′ = 1 2 (x + y) ∴ y1′ = 1 2 (x1 + y1) = 1.568 Similarly y2′ = 2.2975, y3′ = 3.234 ∴ from (38), y4 = 2 + 4 0 5 3 ( . ) [3.136 – 2.2975 + 6.468] = 6.871 ⇒ y4′ = 1 2 (x4 + y4) = 4.4355 This is corrected by y4 (1) = y2 + h 3 (y2′ + 4y3′ + y4′) = 3.595 + 0 5 3 . [2.2975 + 12.936 + 4.4355] = 6.87317 Now, (y4 (1))′ = 1 2 [x4 + y4 (1)] = 1 2 (2 + 6.87317) = 4.43659
  • 547. 534 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Again by the Corrector Formula, we get the second corrected value i.e., y2.00. y4 (2) = y2 + h 3 [y2′ + 4y3′ + (y4 (1))′] = 3.595 + 0 5 3 . [2.2975 + 12.936 + 4.43659] = 6.87335 Example 3. Using Milne’s Method, solve y′ = 1 + y2 with y(0) = 0, y(0.2) = 0.2027, y(0.4) = 0.4228, y(0.6) = 0.6841, obtain y(0.8) and y(1) Sol. Let x0 = 0, x1 = 0.2, x2 = 0.4, x3 = 0.6. We are given y0, y1, y2, y3, and we require y4 = y(0.8) and y5 = y(1.0). Here h = 0.2 We have, y′ = 1 + y2 ∴ y1′ = 1 + y1 2 = 1 + (0.2027)2 = 1.0411 y2′ = 1 + y2 2 = 1 + (0.4228)2 = 1.1788 y3′ = 1 + y3 2 = 1 + (0.6841)2 = 1.4680 By Predictor Formula, we get y4 = y0 + 4 3 h (2y1′ – y2′ + 2y3′) = 0 + 0 8 3 . [2.0822 – 1.1788 + 2.936] = 1.0238 y4′ = 1 + y4 2 = 1 + (1.0238)2 = 2.0482 This is corrected by y4 (1) = y2 + h 3 (y2′ + 4y3′ + y4′) = 0.4228 + 0 2 3 . [1.1788 + 5.872 + 2.0482] = 1.0294 Now, [y4 (1)]′ = 1 + [y4 (1)]2 = 1 + (1.0294)2 = 2.0597 The second corrected value is, y4 (2) = y2 + h 3 [y2′ + 4y3′ + y4 (1) ′] = 0.4228 + 0 2 3 . [1.1788 + 5.872 + 2.0597] = 1.0302 Again, [y4 (2)]′ = 1 + [y4 (2)]2 = 1 + (1.0302)2 = 2.0613 Again, y4 (3) = 1.0303 = y4 (4) hence, y4 = y(0.8) = 1.0303
  • 548. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 535 Now, by Predictor Formula, also y5 = y1 + 4 3 h (2y2′ – y3′ + 2y4′) = 0.2027 + 0.8 3 [2.3576 – 1.468 + 4.123] | y4′ = 1 + (1.0303)2 = 1.5394 y5′ = 1 + y5 2 = 3.3698 This is corrected by y5′ = y3 + h 3 ( y3′ + 4y4′ + y5′) = 0.6841 + 0 2 3 . (1.468 + 8.246 + 3.3698) = 1.5564 Now, [y5 (1)]′ = 1 + (1.5564)2 = 3.4224 The second corrected value is y5 (2) = 1.55999 Now, [y5 (2)]′ = 3.4333 Also, y5 (3) = 1.5606 Similarly y5 (4) = 1.5607 = y5 (5) Hence, y5 = y(1.0) = 1.5607. ASSIGNMENT 6.5 1. Apply Milne’s Method to solve the differential equation dy dx = – xy2 at x = 0.8, given that y(0) = 2, y(0.2) = 1.923, y(0.4) = 1.724, y(0.6) = 1.471 2. Solve 10 dy dx = x2 + y2, y(0) = 1 and compute y(0.4) and y(0.5) by Milne’s Method given x: 0.1 0.2 0.3 y: 1.0101 1.0206 1.0317 3. Part of a numerical solution of the differential equation dy dx = 0.2x + 0.1y
  • 549. 536 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES is shown in the following table: x: 0 0.05 0.10 0.15 y: 2 2.0103 2.0212 2.0323 Use Milne’s Method to find the next entry in the table. 4. Given dy dx = 1 2 (1 + x2) y2 and y(0) = 1, y(0.1) = 1.06, y(0.2) = 1.12, y(0.3) = 1.21, evaluate y(0.4) by Milne’s Predictor-Corrector Method. 5. The differential equation dy dx + 1 10 y2 = x satisfies the following pairs of values of x and y: x: – 0.2 – 0.1 0.0 0.1 0.2 y: 1.04068 1.01513 1 0.99507 1.00013 Compute the values of y when x = 0.3 by Milne’s Method. 6. Solve the differential equation dy dx = y – x2 by Milne’s Method and compute y at x = 0.80 when: x: 0 0.2 0.4 0.6 y: 1 1.12186 1.46820 1.73790 7. Solve y′ = – y with y(0) = 1 by the using Milne’s Method from x = 0.5 to x = 0.8 with h = 0.1. Given: x: 0.1 0.2 0.3 0.4 y: 0.9048 0.8188 0.7408 0.6705 8. Given: dy dx = 2 – xy2 and y(0) = 1. Show that by Milne’s Method, y(1) = 1.6505 taking h = 0.2. You may use Picard’s Method to obtain the values of y(0.2), y(0.4), y(0.6). 9. Solve the initial value problem dy dx = 1 + xy2, y(0) = 1 for x = 0.4, 0.5 by using Milne’s Method. It is given that, x: 0.1 0.2 0.3 y: 1.105 1.223 1.355 10. Derive Milne’s Predictor Formula and find the solution of the equation. dy dx = x – y2 for y(0.8) and y(1), given the starting values. x: 0 0.2 0.4 0.6 y: 0 0.02 0.0795 0.1762
  • 550. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 537 11. Given: y(0) = 2, y(0.2) = 2.0933, y(0.4) = 2.1755, y(0.6) = 2.2493, find y(0.8) and y(1.0) by solving dy dx = 1 x y + by Milne’s Method. 12. Solve numerically dy dx = 2ex – y at x = 0.4 and 0.5 by Milne’s Method given: x: 0 0.1 0.2 0.3 y: 2 2.010 2.040 2.090 13. Given dy dx = – xy with y(0) = 1. Solve the equation in the interval (0, 1) using step size = 0.5 using Predictor-Corrector Method. Give algorithm of Predictor-Corrector Method. 14. Apply Predictor-Corrector Method on a differential equation dx dt = f (t, x). Let x = x(t) The method is of order IV with step-size h is x(t + h) = x(t) + 1 6 (k1 + 2k2 + 2k3 + k4) where, k1 = h f (t, x) k2 = h f t h x k + + F HG I KJ 2 2 1 , k3 = h f t h x k + + F HG I KJ 2 2 2 , k4 = h f (t + h, x + k3) Use this method with h = 0.1 to find x(0.1) and x(0.2) where dx dt = t – x and x(0) = 0. 15. Discuss Predictor-Corrector Method for solving differential equation. Illustrate method using figure. Give program of Predictor-Corrector Method in ‘C’ language. 6.23 ADAMS–MOULTON (OR ADAMS–BASHFORTH) FORMULA Consider the initial value problem dy dx = f (x, y) with y(x0) = y0 (39) We compute y–1 = y(x0 – h), y–2 = y (x0 – 2h), y– 3 = y(x0 – 3h),......
  • 551. 538 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now integrating (39) on both sides with respect to x in [x0, x0 + h], we get y1 = y0 + x x h f x y dx 0 0 + z ( , ) (40) Replacing f (x, y) by Newton’s Backward Interpolation Formula, we get y1 = y0 + h 0 1 0 0 2 0 3 0 1 2 1 2 6 z + ∇ + + ∇ + + + ∇ + R S T U V W f u f u u f u u u f ( ) ( ) ( ) ... du ∵ x x hu dx h du u = + ∴ = 0 0 1 Limits of are from to = y0 + h f f f f 0 0 2 0 3 0 1 2 5 12 3 8 + ∇ + ∇ + ∇ + F HG I KJ ... (41) Neglecting the fourth order and higher order differences and using ∇ f0 = f0 – f–1 ∇2 f0 = f0 – 2f–1 + f–2 ∇3 f0 = f0 – 3f–1 + 3f–2 – f–3 in (41), we get after simplification, y1 = y0 + h 24 (55f0 – 59f –1 + 37f–2 – 9f–3) which is known as Adams–Bashforth or Adams–Moulton–Predictor Formula and is denoted generally as yp n + 1 = yn + h 24 (55fn – 59fn –1 + 37fn –2 – 9fn –3) or yp n + 1 = y0 + h 24 (55yn′ – 59y′n –1 + 37y′n –2 – 9y′n –3) Having found y1, we find f1 = f (x0 + h, y1) To find a better value of y1, we derive a corrector formula by substituting Newton’s Backward Interpolation Formula at f1 in place of f (x, y) in (40) i.e., y1 = y0 + x x h f u f u u f u u u f 0 0 1 1 2 1 3 1 1 2 1 2 6 + z + ∇ + + ∇ + + + ∇ + L NM O QP ( ) ( ) ( ) ... dx = y0 + h − z + ∇ + + ∇ + + + F HG I KJ ∇ + L N MM O Q PP 1 0 1 1 2 2 1 3 2 3 1 2 3 2 6 f u f u u f u u u f ( ) ... du ∵x x hu dx h du = + ∴ = 1
  • 552. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 539 = y0 + h f f f f 1 1 2 1 3 1 1 2 1 12 1 24 − ∇ − ∇ − ∇ − F HG I KJ ... (42) Neglecting the fourth order and higher order differences and using ∇ f1 = f1 – f0, ∇2f1 = f1 – 2f0 + f–1,∇3f1 = f1 – 3f0 + 3f–1 – f–2 in (42), we get y1 = y0 + h 24 (9f1 + 19f0 – 5f–1 + f–2) which is known as Adams–Bashforth or Adams–Moulton Corrector Formula and is denoted generally as yc n + 1 = yn + h 24 (9fn + 1 – 19fn – 5fn –1 + fn –2) or yc n + 1 = yn + h 24 (9y′n + 1 – 19yn′ – 5y′n –1 + y′n –2) EXAMPLES Example 1. Using Adam’s–Moulton–Bashforth Method to find y (1.4) given: dy dx = x2 (1 + y), y(1) = 1, y(1.1) = 1.233, y(1.2) = 1.548 and y(1.3) = 1.979. Sol. Here, y′ = x2 (1 + y), h = 0.1 x0 = 1, x1 = 1.1, x2 = 1.2, x3 = 1.3 y0 = 1, y1 = 1.233, y2 = 1.548, y3 = 1.979 Now, Adams–Bashforth Predictor Formula is y4 p = y3 + h 24 (55y3′ – 59y2′ + 37y1′ – 9y0′) (43) y1′ = x1 2 (1 + y1) = 2.70193 y2′ = x2 2 (1 + y2) = 3.66912 y3′ = x3 2 (1 + y3) = 5.03451 ∴ from (43), y4 p = 1.979 + 01 24 . F HG I KJ [55(5.03451) – 59(3.66912) + 37(2.70193) – 9(2)] = 2.5722974 Now, (y4′)p = x4 2 (1 + y4 p) = (1.4)2 (1 + 2.5722974) = 7.0017029
  • 553. 540 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Now, the Corrector Formula is y4 c = y3 + h 24 (9y4′p + 19y3′ – 5y2′ + y1′) = 1.979 + 0 1 24 . F HG I KJ [9(7.0017029) + 19(5.03451) – 5(3.66912) + 2.70193] = 2.5749473 ∴ y(0.4) = 2.5749 Example 2. Find y(0.1), y(0.2), y(0.3) from dy dx = x2 – y; y(0) = 1 by using Taylor’s Series Method and hence obtain y(0.4) using Adams–Bashforth Method. Sol. We have, y′ = x2 – y, y(0) = 1 By Taylor’s Series Method, we have y(0.1) = 0.905125 y(0.2) = 0.8212352 y(0.3) = 0.7491509 Hence, x0 = 0, x1 = 0.1, x2 = 0.2, x3 = 0.3 y0 = 1, y1 = 0.905125, y2 = 0.8212352, y3 = 0.7491509 Also, y0′ = – 1, y1′ = – 0.895125, y2′ = – 0.7812352 and y3′ = – 0.6591509 Now, Adams–Bashforth Predictor Formula is y4 p = y3 + h 24 (55y3′ – 59y2′ + 37y1′ – 9y0′) = 0.7491509 + 01 24 . F HG I KJ [55(– 0.6591509) – 59(– 0.7812352) + 37(– 0.895125) – 9(– 1)] = 0.6896507 Now, y4′p = x4 2 – y4 p = (0.4)2 – 0.6896507 = – 0.5296507 The Corrector Formula is y4 c = y3 + h 24 (9y4′p + 19y3′ – 5y2′ + y1′)
  • 554. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 541 = 0.7491509 + 01 24 . F HG I KJ [9(– 0.5296507) + 19(– 0.6591509) – 5(– 0.7812352) + (– 0.895125)] = 0.6896522 ∴ y(0.4) = 0.6896522 ASSIGNMENT 6.6 1. Using Adams–Bashforth Formula, find y(0.4) and y(0.5) if y satisfies the differential equation dy dx = 3ex + 2y with y(0) = 0. Compute y at x = 0.1, 0.2, 0.3 by means of Runge-Kutta Method. 2. Determine y(0.4) given the equation dy dx = 1 2 xy using Adams–Moulton Method, given that y(0) = 1, y(0.1) = 1.0025, y(0.2) = 1.0101, y(0.3) = 1.0228. 3. Using Adams–Bashforth Predictor–Corrector Method, find y(1.4) given that x2y′ + xy = 1; y(1) = 1, y(1.1) = 0.996, y(1.2) = 0.986, y(1.3) = 0.972 4. Compute y(1) by Adam’s Method given y′ = x2 – y3 , y(0) = 1, y(0.25) = 0.821028, y(0.5) = 0.741168, y(0.75) = 0.741043. 5. Given y′ = 2y – 1, y(0) = 1. Compute y for x = 0.1, 0.2, 0.3 by the IV order Runge-Kutta Method and y(0.4) by Adam’s Method. 6.24 STABILITY A numerical method for solving a mathematical problem is considered stable if the sensitivity of the numerical answer to the data is no greater than in the original mathematical problem. Stable problems are also called well-posed problems. If a problem is not stable, it is called unstable or ill-posed. A problem f(x, y) = 0 is said to be stable if the solution y depends in a continuous way on the variable x.
  • 555. 542 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 6.25 STABILITY IN THE SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS The idea of stability may be defined as (i) A computation is stable if it does not blow up. (ii) Stability is a boundedness of the relative error. Two types of stability considerations enter in the solution of ordinary differential equations. (a) Inherent stability (b) Numerical stability Inherent stability is determined by the mathematical formulations of the problem and is dependent on the Eigen values of Jacobean Matrix of the differential equation. Numerical stability is a function of the error propagation in the numerical method. Three types of errors occur in the application of numerical integration methods: (a) Truncation error (b) Round-off error (c) Propagation error. 6.26 STABILITY OF I ORDER LINEAR DIFFERENTIAL EQUATION OF FORM dy dx = Ay WITH INITIAL CONDITION y(x0) = y0 The solution of this equation is y(x) = y(x0) e A(x– x0) Let, yn = y(xn) + εn at xn = x0 + nh εn being the total truncation error. Let E(Ah) be the polynomial approximation to e–Ah (for small Ah). Then the computed result of one step length is yn + 1 = E(Ah) yn while the correct solution is y(xn + 1) = eAh y(xn) Thus, yn + 1 – y(xn + 1) = E(Ah) yn – eAh y(xn) = E(Ah) [y(xn) + En] – eAh y(xn) = [E(Ah) – eAh] y(xn) + E(Ah) εn
  • 556. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 543 Clearly, the error εn will be amplified if E(Ah) 1 which is possible for sufficiently large Ah at xn + k = x0 + (n + k) h. It will have grown by factor Ek(Ah). Thus meaningful results can be obtained only for E(Ah) 1. If | E(Ah) | eAh then we say that the method is relatively stable for that value of Ah. EXAMPLES Example 1. How many terms are to be retained if we want to have an accuracy of 10–10 in solving y′ = x + y, y(0) = 1, x∈(0, 1) by Taylor’s series method? Sol. y′ = x + y ⇒ y′′ = 1 + y′, y′′′ = y′′, ..., and so on ⇒ y(p + 1) = y(p), p = 2, 3... ∴ y′(0) = 1, y′′(0) = 2,..., y(p)(0) = 2 Hence, y(x) = 1 + x + x2 + ... + 2 p! xp + ... In order to obtain results, which will be accurate up to 10–10 for x ≤ 1, we have 1 1 ( )! p + 5 × 10–10 ⇒ p ≈ 15 Hence about 15 terms are required to obtain the accuracy of 10–10 for solving dy dx = x + y by Taylor’s Series Method when x ≤ 1. Example 2. Discuss the stability of Euler’s Method for solving the differential equation. dy dx = λy Sol. dy dx = λy = f (x, y) True solution is y(x) = ceλx so that y(xn + 1) = y(xn)eλh, h = xn + 1 – xn Approximate solution using Euler’s Method is yn + 1 = yn + h f(xn, yn) = yn + h λ yn = (1 + hλ) yn
  • 557. 544 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Let yn = y(xn) + εn where εn is the total solution error. ⇒ yn + 1 = y(xn + 1) + εn + 1 = (1 + hλ) yn = (1 + hλ) [y(xn) + εn] Therefore, yn + 1 – y(xn + 1) = (1 + λh) y(xn) + (1 + λh) εn – y(xn) eλh ⇒ εn + 1 = (1 + λh – eλh) y(xn) + (1 + λh) εn The first term on R.H.S. is the total truncation error while the second term is the contribution to the error from the previous step (inherited error). Hence, we have E(λh) = 1 + λh where E(λh) is a polynomial approximation to eλh for small λh. Obviously, Euler’s Method is absolutely stable if | 1 + λh | 1 or – 2 λh 0; relatively stable if λh is greater than the solution of λh = – 1 – e–λh.
  • 558. P a r t 5 n Statistical Computation Frequency Charts, Curve Fitting, Principle of Least Squares, Fitting a Straight Line, Exponential Curves etc., Data Fitting with Cubic Splines, Regression Analysis, Linear Regression, Polynomial Fit: Non-linear Regression, Multiple Linear Regression, Statistical Quality Control. n Testing of Hypothesis Population or Universe, Sampling, Parameters of Statistics, Test of Significance, t-Test, F-Test, Chi-square (χ2) Test.
  • 560. 7.1 THE STATISTICAL METHODS S tatistical methods are devices by which complex and numerical data are so systematically treated as to present a comprehensible and intelligible view of them. In other words, the statistical method is a technique used to obtain, analyze and present numerical data. 7.2 LIMITATION OF STATISTICAL METHODS There are certain limitations to the Statistics and Statistical Methods. 1. Statistical laws are not exact laws like mathematical or chemical laws. They are derived by taking a majority of cases and are not true for every individual. Thus, the statistical inferences are uncertain. 2. Statistical technique applies only to data reducible to quantitative forms. 3. Statistical technique is the same for the social as for physical sciences. 4. Statistical results might lead to fallacious conclusions if they are quoted short of their context. Chapter 7 STATISTICAL COMPUTATION 547
  • 561. 548 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.3 FREQUENCY CHARTS 7.3.1 Variable A quantity which can vary from one individual to another is called a variable. It is also called a variate. Wages, barometer readings, rainfall records, heights, and weights are the common examples of variables. Quantities which can take any numerical value within a certain range are called continuous variables. For example, the height of a child at various ages is a continuous variable since, as the child grows from 120 cm to 150 cm, his height assumes all possible values within the limit. Quantities which are incapable of taking all possible values are called discontinuous or discrete variables. For example, the number of rooms in a house can take only the integral values such as 2, 3, 4, etc. 7.3.2 Frequency Distributions The scores of 50 students in mathematics are arranged below according to their roll numbers, the maximum scores being 100. 19, 70, 75, 15, 0, 23, 59, 56, 27, 89, 91, 22, 21, 22, 50, 89, 56, 73, 56, 89, 75, 65, 85, 22, 3, 12, 41, 87, 82, 72, 50, 22, 87, 50, 89, 28, 89, 50, 40, 36, 40, 30, 28, 87, 81, 90, 22, 15, 30, 35. The data given in the crude form (or raw form) is called ungrouped data. If the data is arranged in ascending or descending order of magnitude, it is said to be arranged in an array. Let us now arrange it in the intervals 0–10, 10–20, 20–30, 30–40, 40–50, 50–60, 60–70, 70–80, 80–90, 90–100. This is arranged by a method called the tally method. In this we consider every observation and put it in the suitable class by drawing a vertical line. After every 4 vertical lines, we cross it for the 5th entry and then a little space is left and the next vertical line is drawn.
  • 562. STATISTICAL COMPUTATION 549 Scores Number of Students Frequency Cumulative (Class-interval) (f ) Frequencies 0—10 | | 2 2 10—20 | | | | 4 6 20—30 | | | | | | | | 10 16 30—40 | | | | 4 20 40—50 | | | 3 23 50—60 | | | | | | | 8 31 60—70 | 1 32 70—80 | | | | 5 37 80—90 | | | | | | | | | 11 48 90—100 | | 2 50 Total Σf = 50 This type of representation is called a grouped frequency distribution or simply a frequency distribution. The groups are called the classes and the boundary ends 0, 10, 20, ...... etc. are called class limits. In the class limits 10—20, 10 is the lower limit and 20 is the upper limit. The difference between the upper and lower limits of a class is called its magnitude or class-interval. The number of observations falling within a particular class is called its frequency or class frequency. The frequency of the class 80—90 is 11. The variate value which lies mid-way between the upper and lower limits is called mid-value or mid-point of that class. The mid-points of these are respectively 5, 15, 25, 35, ...... The cumulative frequency corresponding to a class is the total of all the frequencies up to and including that class. Thus the cumulative frequency of the class 10—20 is 2 + 4, i.e., 6 the cumulative frequency of the class 20—50 is 6 + 10, i.e., 16, and so on. While preparing the frequency distribution the following points must be remembered: 1. The class-intervals should be of equal width as far as possible A comparison of different distributions is facilitated if the class interval is used for all. The class-interval should be an integer as far as possible. 2. The number of classes should never be fewer than 6 and not more than 30. With a smaller number of classes, the accuracy may be lost, and with a larger number of classes, the computations become tedious. 3. The observation corresponding to the common point of two classes should always be put in the higher class. For example, a number corresponding to the value 30 is to be put up in the class 30—40 and not in 20—30.
  • 563. 550 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The following forms of the above table may also be used: Cumulative Frequency Scores Number of Students Scores Number of Students Under 10 2 above 90 2 Under 20 6 above 80 13 Under 30 16 above 70 18 Under 40 20 above 60 19 Under 50 23 above 50 27 Under 60 31 above 40 30 Under 70 32 above 30 34 Under 80 37 above 20 44 Under 90 48 above 10 48 Under 100 50 above 0 50 7.4 GRAPHICAL REPRESENTATION OF A FREQUENCY DISTRIBU- TION Representation of frequency distribution by means of a diagram makes the unwieldy data intelligible and conveys to the eye the general run of the observations. The graphs and diagrams have a more lasting effect on the brain. It is always easier to compare data through graphs and diagrams. Forecasting also becomes easier with the help of graphs. Graphs help us in interpolation of values of the variables. However there are certain disadvantages as well. Graphs do not give measurements of the variables as accurate as those given by tables. The numerical value can be obtained to any number of decimal places in a table, but from graphs it can not be found to 2nd or 3rd places of decimals. Another disadvantage is that it is very difficult to have a proper selection of scale. The facts may be misrepresented by differences in scale. 7.5 TYPES OF GRAPHS AND DIAGRAMS Generally the following types of graphs are used in representing frequency distributions: (1) Histograms, (2) Frequency Polygon, (3) Frequency Curve, (4) Cumulative Frequency Curve or the Ogive, (5) Historigrams, (6) Bar Diagrams, (7) Area
  • 564. STATISTICAL COMPUTATION 551 Diagrams, (8) Circles or Pie Diagrams, (9) Prisms, (10) Cartograms and Map Diagrams, (11) Pictograms. 7.6 HISTOGRAMS To draw the histograms of a given grouped frequency distribution, mark off along a horizontal base line all the class-intervals on a suitable scale. With the class-intervals as bases, draw rectangles with the areas proportional to the frequencies of the respective class-intervals. For equal class-intervals, the heights of the rectangles will be proportional to the frequencies. If the class- intervals are not equal, the heights of the rectangles will be proportional to the ratios of the frequencies to the width of the corresponding classes. A diagram with all these rectangles is a Histogram. 1 2 3 4 5 6 7 8 9 10 11 0 10 20 30 40 50 60 70 80 90 100 X Y Scores Frequencies (Histogram for the previous table) Histograms are also useful when the class-intervals are not of the same width. They are appropriate to cases in which the frequency changes rapidly.
  • 565. 552 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.7 FREQUENCY POLYGON If the various points are obtained by plotting the central values of the class intervals as x co-ordinates and the respective frequencies as the y co-ordinates, and these points are joined by straight lines taken in order, they form a polygon called Frequency Polygon. 1 2 3 4 5 6 7 8 9 10 11 0 10 20 30 40 50 60 70 80 90 100 X Y Scores Frequencies (Frequency Polygon) In a frequency polygon the variables or individuals of each class are assumed to be concentrated at the mid-point of the class-interval. Here in this diagram dotted is the Histogram and a polygon with lines as sides is the Frequency Polygon. 7.8 FREQUENCY CURVE If through the vertices of a frequency polygon a smooth freehand curve is drawn, we get the Frequency Curve. This is done usually when the class-intervals are of small widths.
  • 566. STATISTICAL COMPUTATION 553 7.9 CUMULATIVE FREQUENCY CURVE OR THE OGIVE If from a cumulative frequency table, the upper limits of the class taken as x co-ordinates and the cumulative frequencies as the y co-ordinates and the points are plotted, then these points when joined by a freehand smooth curve give the Cumulative Frequency Curve or the Ogive. 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 Scores Cumulative frequencies X Y Ogive 7.10 TYPES OF FREQUENCY CURVES Following are some important types of frequency curves, generally obtained in the graphical representations of frequency distributions: 1. Symmetrical curve or bell shaped curve. 2. Moderately asymmetrical or skewed curve. 3. Extremely asymmetrical or J-shaped curve or reverse J-shaped. 4. U-shaped curve. 5. A bimodal frequency curve. 6. A multimodal frequency curve. 1. Symmetrical curve or Bell shaped curve. If a curve can be folded symmetrically along a vertical line, it is called a symmetrical curve. In this type the class frequencies decrease to zero symmetrically on either side of a central maximum, i.e., the observations equidistant from the central maximum have the same frequency.
  • 567. 554 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (Bell shaped curve) (Skewed curve) 2. Moderately asymmetrical or skewed curve. If there is no symmetry in the curve, it is called a Skew Curve. In this case the class frequencies decrease with greater rapidity on one side of the maximum than on the other. In this curve one tail is always longer than the other. If the long tail is to the to be a positive side, it is said to be a positive skew curve, if long tail is to the negative side, it is said to be a negative skew curve. 3. Extremely asymmetrical or J-shaped curve. When the class frequencies run up to a maximum at one end of the range, they form a J-shaped curve. J-shaped curve Reversed J-shaped curve U-shaped curve 4. U-shaped curve. In this curve, the maximum frequency is at the ends of the range and a maximum towards the center. 5. A Bimodal curve has two maxima. Bimodal curve Multimodal curve 6. A multimodal curve has more than two maxima.
  • 568. STATISTICAL COMPUTATION 555 7.11 DIAGRAMS 1. Bar diagrams. Bar diagrams are used to compare the simple magnitude of different items. In bar diagrams, equal bases on a horizontal or vertical line are selected and rectangles are constructed with the length proportional to the given data. The width of bars is an arbitrary factor. The distance between two bars should be taken at about one-half of the width of a bar. 2. Area diagrams. When the difference between two quantities to be compared is large, bars do not show the comparison so clearly. In such cases, squares or circle are used. 3. Circle or Pie-diagrams. When circles are drawn to represent an area equivalent to the figures, they are said to form pie-diagrams or circles- diagrams. In case of circles, the square roots of magnitudes are proportional to the radii. 4. Subdivided Pie-diagram. Subdivided Pie-diagrams are used when comparison of the component parts is done with another and the total. The total value is equated to 360° and then the angles corresponding to the component parts are calculated. 5. Prisms and Cubes. When the ratio between the two quantities to be compared is very great so that even area diagrams are not suitable, the data can be represented by spheres, prisms, or cubes. Cubes are in common use. Cubes are constructed on sides which are taken in the ratio of cube roots of the given quantities. 6. Cartograms or map diagrams. Cartograms or map diagrams are most suitable for geographical data. Rainfalls and temperature in different parts of the country are shown with dots or shades in a particular map. 7. Pictograms. When numerical data are represented by pictures, they give a more attractive representation. Such pictures are called pictograms.
  • 569. 556 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.12 CURVE FITTING Let there be two variables x and y which give us a set of n pairs of numerical values (x1, y1), (x2, y2).......(xn, yn). In order to have an approximate idea about the relationship of these two variables, we plot these n paired points on a graph, thus we get a diagram showing the simultaneous variation in values of both the variables called scatter or dot diagram. From scatter diagram, we get only an approximate non-mathematical relation between two variables. Curve fitting means an exact relationship between two variables by algebraic equations. In fact, this relationship is the equation of the curve. Therefore, curve fitting means to form an equation of the curve from the given data. Curve fitting is considered of immense importance both from the point of view of theoretical and practical statistics. Theoretically, curve fitting is useful in the study of correlation and regression. Practically, it enables us to represent the relationship between two variables by simple algebraic expressions, for example, polynomials, exponential, or logarithmic functions. Curve fitting is also used to estimate the values of one variable corresponding to the specified values of the other variable. The constants occurring in the equation of an approximate curve can be found by the following methods: (i) Graphical method (ii) Method of group averages (iii) Principle of least squares (iv) Method of moments. Out of the above four methods, we will only discuss and study here the principle of least squares. 7.13 PRINCIPLE OF LEAST SQUARES Principle of least squares provides a unique set of values to the constants and hence suggests a curve of best fit to the given data. Suppose we have m-paired observations (x1, y1), (x2, y2), ......, (xm, ym) of two variables x and y. It is required to fit a polynomial of degree n of the type y = a + bx + cx2 + ...... + kxn (1) of these values. We have to determine the constants a, b, c, ..., k such that they represent the curve of best fit of that degree. In case m = n, we get in general a unique set of values satisfying the given system of equations.
  • 570. STATISTICAL COMPUTATION 557 But if m n, then we get m equations by putting different values of x and y in equation (1) and we want to find only the values of n constants. Thus there may be no such solution to satisfy all m equations. Therefore we try to find out those values of a, b, c, ......, k which satisfy all the equations as nearly as possible. We apply the principle of least squares in such cases. Putting x1, x2, ..., xm for x in (1), we get y1′ = a + bx1 + cx1 2 + ...... + kx1 n y2′ = a + bx2 + cx2 2 + ...... + kx2 n ym′ = a + bxm + cxm 2 + ...... + kxm n where y1′, y2′, ......, ym′ are the expected values of y for x= x1, x2, ......., xm respectively. The values y1, y2, ......, ym are called observed values of y corresponding to x = x1, x2, ......, xm respectively. The expected values are different from the observed values, the difference yr – yr′ for different values of r are called residuals. Introduce a new quantity U such that U = Σ(yr – yr′)2 = Σ(yr – a – bxr – cxr 2 – ..... – kxr n)2 The constants a, b, c, ......, k are choosen in such a way that the sum of the squares of the residuals is minimum. Now the condition for U to be maximum or minimum is ∂ ∂ U a = 0 = ∂ ∂ ∂ ∂ U U b c = = ...... = ∂ ∂ U k . On simplifying these relations, we get Σy = ma + bΣx + ..... + kΣxn Σxy = aΣx + bΣx2 + ....... + k Σxn+1 Σx2y = aΣx2 + bΣx3 + ....... + k Σxn+2 Σxny = aΣxn + bΣxn+1 + ....... + k Σx2n These are known as Normal equations and can be solved as simultaneous equations to give the values of the constants a, b, c, ......., k. These equations are (n + 1) in number. If we calculate the second order partial derivatives and these values are given, they give a positive value of the function, so U is minimum.
  • 571. 558 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES This method does not help us to choose the degree of the curve to be fitted but helps us is finding the values of the constants when the form of the curve has already been chosen. 7.14 FITTING A STRAIGHT LINE Let (xi, yi), i = 1, 2, ......, n be n sets of observations of related data and y = a + bx (2) be the straight line to be fitted. The residual at x = xi is Ei = yi – f(xi) = yi – a – bxi Introduce a new quantity U such that U = i n i i n i i y a bx = = ∑ ∑ = − − 1 2 1 2 E ( ) By the principle of Least squares, U is minimum ∴ ∂ ∂ U a = 0 and ∂ ∂ U b = 0 ∴ 2 1 0 1 i n i i y a bx = ∑ − − − = ( )( ) or Σy = na + bΣx (3) and 2 0 1 i n i i i y a bx x = ∑ − − − = ( )( ) or Σxy = aΣx + bΣx2 (4) Since xi, yi are known, equations (3) and (4) result in a and b. Solving these, the best values for a and b can be known, and hence equation (2). In case of change of origin, if n is odd then, u = x (middle term) interval (h) − but if n is even then u = x (mean of two middle terms) 1 2 (interval) − . NOTE
  • 572. STATISTICAL COMPUTATION 559 7.15 ALGORITHM FOR FITTING A STRAIGHT LINE OF THE FORM y = a + bx FOR A GIVEN SET OF DATA POINTS Step 01. Start of the program. Step 02. Input no. of terms observ Step 03. Input the array ax Step 04. Input the array ay Step 05. for i=0 to observ Step 06. sum1+=x[i] Step 07. sum2+=y[i] Step 08. xy[i]=x[i]*y[i]; Step 09. sum3+=xy[i] Step 10. End Loop i Step 11. for i = 0 to observ Step 12. x2[i]=x[i]*x[i] Step 13. sum4+=x2[i] Step 14. End of Loop i Step 15. temp1=(sum2*sum4)-(sum3*sum1) Step 16. a=temp1/((observ *sum4)-(sum1*sum1)) Step 17. b=(sum2-observ*a)/sum1 Step 18. Print output a,b Step 19. Print “line is: y = a+bx” Step 20. End of Program
  • 573. 560 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.16 FLOW-CHART FOR FITTING A STRAIGHT LINE y = a + bx FOR A GIVEN SET OF DATA POINTS START Input number of observations Input array ax and ay Loop for i = 0 to observ Sum 1 + = x[i] Sum 2 + = y[i] xy[i] = x[i]*y[i] Sum 3 + = xy[i] End loop i Loop for i = 0 to observ x2[i] = x[i]*x[i] Sum 4 + = x2[i] End loop i STOP Print ‘‘output’’ a = ((Sum 2* Sum4) – (Sum 3* Sum1))/ ((observ* sum4) – (sum 1* sum1)) b = ((sum 2 – observ* a)/sum1)
  • 574. STATISTICAL COMPUTATION 561 /* ********************************************************** 7.17 PROGRAM TO IMPLEMENT CURVE FITTING TO FIT A STRAIGHT LINE ********************************************************** */ //... HEADER FILE DECLARATION # include stdio.h # include conio.h # include math.h //... Main Execution Thread void main() { //... Variable Declaration Field //... Integer Type int i=0; int observ; //... Floating Type float x[10]; float y[10]; float xy[10]; float x2[10]; float sum1=0.0; float sum2=0.0; float sum3=0.0; float sum4=0.0; //... Double Type double a; double b; //... Invoke Function Clear Screen clrscr (); //... Input Section //... Input Number of Observations printf(“nn Enter the number of observations - ”); scanf(“%d” ,observ);
  • 575. 562 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES //... Input Sequel For Array X printf(“nnn Enter the values of x – n); for (;iobserv;i++) { printf(nn Enter the Value of x%d: ,i+1); scanf(“%f” ,x[i]); sum1 +=x[i]; } //... Input Sequel For Array Y printf(“nn Enter the values of y - n”); for(i=0;iobserv;i++) { printf(nn Enter the value of y%d:,i+1); scanf(%f,y[i]); sum2+=y[i]; } //... Processing and Calculation Section for(i=0;iobserv;i++) { xy[i]=x[i]*y[i]; sum3 +=xy[i]; } for(i=0;iobserv; i++) { x2[i]=x[i]*x[i]; sum4+ =x2[i]; } a=(sum2*sum4–sum3*sum1)/(observ*sum4–sum1*sum1); b=(sum2–observ*a)/sum1; //... Output Section printf(“nnnn Equation of the STRAIGHT LINE); printf(of the form y = a + b*x is:); printf(“nnn ttt Y = %.2f + (%.2f) X, a,b); //... Invoke User Watch Halt Function
  • 576. STATISTICAL COMPUTATION 563 printf(nnn Press Enter to Exit); getch(); } //... Termination of Main Execution Thread EXAMPLES Example 1. By the method of least squares, find the straight line that best fits the following data: x: 1 2 3 4 5 y: 14 27 40 55 68. Sol. Let the straight line of best fit be y = a + bx (5) Normal equations are Σy = ma + bΣx (6) and Σxy = aΣx + bΣx2 (7) Here m = 5 The table is as below: x y xy x2 1 14 14 1 2 27 54 4 3 40 120 9 4 55 220 16 5 68 340 25 Σx = 15 Σy = 204 Σxy = 748 Σx2 = 55 Substituting in (6) and (7), we get 204 = 5a + 15b 748 = 15a + 55b Solving, we get a = 0, b = 13.6 Hence required straight line is y = 13.6x Example 2. Fit a straight line to the following data: x: 0 1 2 3 4 y: 1 1.8 3.3 4.5 6.3.
  • 577. 564 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Let the straight line obtained from the given data be y = a + bx then the normal equations are Σy = ma + b Σx (8) Σxy = aΣx + bΣx2 (9) Here m = 5 x y xy x2 0 1 0 0 1 1.8 1.8 1 2 3.3 6.6 4 3 4.5 13.5 9 4 6.3 25.2 16 Σx = 10 Σy = 16.9 Σxy = 47.1 Σx2 = 30 From (8) and (9), 16.9 = 5a + 10b and 47.1 = 10a + 30b Solving, we get a = 0.72, b = 1.33 ∴ Required line is y = 0.72 + 1.33 x. Example 3. Fit a straight line to the following data regarding x as the indepen- dent variable: x: 1 2 3 4 5 6 y: 1200 900 600 200 110 50. Sol. Let the equation of the straight line to be fitted be y = a + bx Here m = 6 x y x2 xy 1 1200 1 1200 2 900 4 1800 3 600 9 1800 4 200 16 800 5 110 25 550 6 50 36 300 Σx = 21 Σy = 3060 Σx2 = 91 Σxy = 6450
  • 578. STATISTICAL COMPUTATION 565 From normal equations, we get 3060 = 6a + 21b, 6450 = 21a + 91b Solving, we get a = 1361.97, b = – 243.42 ∴ Required line is y = 1361.97 – 243.42 x. Example 4. Show that the line of fit to the following data is given by y = 0.7x + 11.285: x: 0 5 10 15 20 25 y: 12 15 17 22 24 30. Sol. Since m is even, Let x0 = 12.5 h = 5 y0 = 20 (say) Then let, u = x − 12.5 2.5 and v = y – 20 x y u v uv u2 0 12 – 5 – 8 40 25 5 15 – 3 – 5 15 9 10 17 – 1 – 3 3 1 15 22 1 2 2 1 20 24 3 4 12 9 25 30 5 10 50 25 Total Σu = 0 Σv = 0 Σuv = 122 Σu2 = 70 Normal equations are 0 = 6a and 122 = 70b ⇒ a = 0, b = 1.743 Line of fit is v = 1.743u Put u = x − 12.5 2.5 and v = y – 20, we get y = 0.7x + 11.285. Example 5. Fit a straight line to the following data: x: 71 68 73 69 67 65 66 67 y: 69 72 70 70 68 67 68 64.
  • 579. 566 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Let the equation of the straight line to be fitted be y = a + bx (10) Normal equations are Σy = ma + bΣx (11) and Σxy = aΣx + bΣx2 (12) Here m = 8. Table is as below: x y xy x2 71 69 4899 5041 68 72 4896 4624 73 70 5110 5329 69 70 4830 4761 67 68 4556 4489 65 67 4355 4225 66 68 4488 4356 67 64 4288 4489 Σx = 546 Σy = 548 Σxy = 37422 Σx2 = 37314 Substituting these values in equations (11) and (12), we get 548 = 8a + 546b 37422 = 546a + 37314b Solving, we get a = 39.5454, b = 0.4242 Hence the required line of best fit is y = 39.5454 + 0.4242 x. Example 6. Show that the best fitting linear function for the points (x1, y1), (x2, y2), ....., (xn, yn) may be expressed in the form x y 1 x y n x x y x i i i 2 i i i Σ Σ Σ Σ Σ = 0 (i = 1, 2, ......, n) Show that the line passes through the mean point ( , ) x y . Sol. Let the best fitting linear function be y = a + bx (13) Then the normal equations are Σyi = na + bΣxi (14) and Σxiyi = aΣxi + bΣxi 2 (15)
  • 580. STATISTICAL COMPUTATION 567 Equations (13), (14), (15) may be rewritten as bx – y + a = 0 bΣxi – Σyi + na = 0 and bΣxi 2 – Σxiyi + aΣxi = 0 Eliminating a and b between these equations x y x y n x x y x i i i i i i 1 2 Σ Σ Σ Σ Σ = 0 (16) which is the required best fitting linear function for the mean point ( , ) x y , x = 1 n Σxi y = 1 n Σyi . Clearly, the line (16) passes through point ( , ) x y as two rows of determinants being equal make it zero. ASSIGNMENT 7.1 1. Fit a straight line to the given data regarding x as the independent variable: x 1 2 3 4 6 8 y 2.4 3.1 3.5 4.2 5.0 6.0 2. Find the best values of a and b so that y = a + bx fits the given data: x 0 1 2 3 4 y 1.0 2.9 4.8 6.7 8.6 3. Fit a straight line approximate to the data: x 1 2 3 4 y 3 7 13 21 4. A simply supported beam carries a concentrated load P(lb) at its mid-point. Corresponding to various values of P, the maximum deflection Y (in) is measured. The data are given below. Find a law of the type Y = a + bP
  • 581. 568 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES P 100 120 140 160 180 200 Y 0.45 0.55 0.60 0.70 0.80 0.85 5. In the following table y in the weight of potassium bromide which will dissolve in 100 grams of water at temperature x0. Find a linear law between x and y x0(c) 0 10 20 30 40 50 60 70 y gm 53.5 59.5 65.2 70.6 75.5 80.2 85.5 90 6. The weight of a calf taken at weekly intervals is given below. Fit a straight line using the method of least squares and calculate the average rate of growth per week. Age 1 2 3 4 5 6 7 8 9 10 Weight 52.5 58.7 65 70.2 75.4 81.1 87.2 95.5 102.2 108.4 7. Find the least square line for the data points (– 1, 10), (0, 9), (1, 7), (2, 5), (3, 4), (4, 3), (5, 0) and (6, – 1). 8. Find the least square line y = a + bx for the data: xi – 2 – 1 0 1 2 yi 1 2 3 3 4 9. If P is the pull required to lift a load W by means of a pulley block, find a linear law of the form P = mW + c connecting P and W, using the data: P 12 15 21 25 W 50 70 100 120 where P and W are taken in kg-wt. 10. Using the method of least squares, fit a straight line to the following data: x 1 2 3 4 5 y 2 4 6 8 10 11. Differentiate between interpolating polynomial and least squares polynomial obtained for a set of data.
  • 582. STATISTICAL COMPUTATION 569 7.18 FITTING OF AN EXPONENTIAL CURVE y = aebx Taking logarithms on both sides, we get log10 y = log10 a + bx log10 e i.e., Y = A + Bx (17) where Y = log10 y, A = log10 a and B = b log10 e The normal equations for (17) are ΣY = nA + BΣx and ΣxY = AΣx + BΣx2 Solving these, we get A and B. Then a = antilog A and b = B log10 e . 7.19 FITTING OF THE CURVE y = axb Taking the logarithm on both sides, we get log10 y = log10 a + b log10 x i.e., Y = A + bX (18) where Y = log10 y, A = log10 a and X = log10 x. The normal equations to (18) are ΣY = nA + bΣX and ΣXY = AΣX + bΣX2 which results A and b on solving and a = antilog A. 7.20 FITTING OF THE CURVE y = abx Take the logarithm on both sides, log y = log a + x log b ⇒ Y = A + Bx where Y = log y, A = log a, B = log b. This is a linear equation in Y and x.
  • 583. 570 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES For estimating A and B, normal equations are ΣY = nA + B Σx and ΣxY = A Σx + B Σx2 where n is the number of pairs of values of x and y. Ultimately, a = antilog (A) and b = antilog (B). 7.21 FITTING OF THE CURVE pvr = k pvr = k ⇒ v = k1/r p–1/r Taking logarithm on both sides, log v = 1 1 r k r log − log p ⇒ Y = A + BX where Y = log v, A = 1 r log k, B = – 1 r and X = log p r and k are determined by the above equations. Normal equations are obtained as per that of the straight line. 7.22 FITTING OF THE CURVE OF TYPE xy = b + ax xy = b + ax ⇒ y = b x + a ⇒ Y = bX + a, where X = 1 x . Normal equations are ΣY = na + bΣX ΣXY = aΣX + bΣX2. 7.23 FITTING OF THE CURVE y = ax2 + b x Let the n points be (x1, y1), (x2, y2), ..... , (xn, yn) Error of estimate for ith point (xi, yi) is Ei = y ax b x i i i − − F HG I KJ 2
  • 584. STATISTICAL COMPUTATION 571 By principle of Least squares, the values of a and b are such that U = i n i = ∑1 2 E = i n i i i y ax b x = ∑ − − F HG I KJ 1 2 2 is minimum. Normal equations are given by ∂ ∂ U a = 0 ⇒ i n i i i n i i n i x y a x b x = = = ∑ ∑ ∑ = + 1 2 1 4 1 and ∂ ∂ U b = 0 ⇒ i n i i i n i i n i y x a x b x = = = ∑ ∑ ∑ = + 1 1 1 2 1 or Dropping the suffix i, normal equations are Σx2y = a Σx4 + bΣx and ∑ y x = a Σx + b ∑ 1 2 x . 7.24 FITTING OF THE CURVE y = ax + bx2 Error of estimate for ith point (xi, yi) is Ei = (yi – axi– bxi 2) By the principle of Least Squares, the values of a and b are such that U = i n i i n i i i y ax bx = = ∑ ∑ = − − 1 2 1 2 2 E ( ) is minimum. Normal equations are given by ∂ ∂ U a = 0 ⇒ i n i i i n i i n i x y a x b x = = = ∑ ∑ ∑ = + 1 1 2 1 3 and ∂ ∂ U b = 0
  • 585. 572 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ⇒ i n i i i n i i n i x y a x b x = = = ∑ ∑ ∑ = + 1 2 1 3 1 4 or Dropping the suffix i, normal equations are Σxy = a Σx2 + bΣx3 Σx2y = a Σx3 + bΣx4. 7.25 FITTING OF THE CURVE y = ax + b x Error of estimate for ith point (xi, yi) is Ei = yi – axi – b xi By the principle of Least Squares the values of a and b are such that U = i n i i n i i i y ax b x = = ∑ ∑ = − − F HG I KJ 1 2 1 2 E is minimum. Normal equations are given by ∂ ∂ U a = 0 ⇒ 2 0 1 i n i i i i y ax b x x = ∑ − − F HG I KJ − = ( ) ⇒ i n i i i n i x y a x nb = = ∑ ∑ = + 1 1 2 and ∂ ∂ U b = 0 ⇒ 2 1 0 1 i n i i i i y ax b x x = ∑ − − F HG I KJ − F HG I KJ = ⇒ i n i i i n i y x na b x = = ∑ ∑ = + 1 1 2 1
  • 586. STATISTICAL COMPUTATION 573 Dropping the suffix i, normal equations are Σxy = aΣx2 + nb and ∑ ∑ = + y x na b x 1 2 where n is the number of pairs of values of x and y. 7.26 FITTING OF THE CURVE y = a + b x + c x2 Normal equations are Σy = ma + b ∑ ∑ + 1 1 2 x c x ∑ ∑ ∑ ∑ = + + y x a x b x c x 1 1 1 2 3 ∑ ∑ ∑ ∑ = + + y x a x b x c x 2 2 3 4 1 1 1 where m is the number of pairs of values of x and y. 7.27 FITTING OF THE CURVE y = c x 0 + c x 1 Error of estimate for ith point (xi, yi) is Ei = yi – c x c x i i 0 1 − By the principle of Least Squares, the values of a and b are such that U = i n i i n i i i i y c x c x = = ∑ ∑ = − − 1 2 1 0 2 E ( ) is minimum. Normal equations are given by ∂ ∂ U c0 0 = and ∂ ∂ U c1 = 0 Now, ∂ ∂ U c0 0 =
  • 587. 574 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ⇒ 2 1 0 1 0 1 i n i i i i y c x c x x = ∑ − − F HG I KJ − F HG I KJ = ⇒ i n i i i n i i n i y x c x c x = = = ∑ ∑ ∑ = + 1 0 1 2 1 1 1 1 (19) Also, ∂ ∂ U c1 0 = ⇒ 2 0 1 0 1 i n i i i i y c x c x x = ∑ − − F HG I KJ − = ( ) ⇒ i n i i i n i i n i y x c x c x = = = ∑ ∑ ∑ = + 1 0 1 1 1 1 (20) Dropping the suffix i, normal equations (19) and (20) become ∑ ∑ ∑ = + y x c x c x 0 2 1 1 1 and ∑ ∑ = y x c x 0 1 + c1 Σx. 7.28 FITTING OF THE CURVE 2x = ax2 + bx + c Normal equations are Σ 2xx2 = aΣx4+ bΣx3 + cΣx2 Σ 2x . x = aΣx3 + bΣx2 + cΣx and Σ 2x = aΣx2 + bΣx + mc where m is number of points (xi, yi) EXAMPLES Example 1. Find the curve of best fit of the type y = aebx to the following data by the method of Least Squares: x: 1 5 7 9 12 y: 10 15 12 15 21.
  • 588. STATISTICAL COMPUTATION 575 Sol. The curve to be fitted is y = aebx or Y = A + Bx, where Y = log10 y, A = log10 a, and B = b log10 e ∴ The normal equations are ΣY = 5A + BΣx and ΣxY = AΣx + BΣx2 x y Y = log10 y x2 xY 1 10 1.0000 1 1 5 15 1.1761 25 5.8805 7 12 1.0792 49 7.5544 9 15 1.1761 81 10.5849 12 21 1.3222 144 15.8664 Σx = 34 ΣY = 5.7536 Σx2 = 300 ΣxY = 40.8862 Substituting the values of Σx, etc. calculated by means of above table in the normal equations. We get 5.7536 = 5A + 34B and 40.8862 = 34A + 300B On solving A = 0.9766; B = 0.02561 ∴ a = antilog10 A = 9.4754; b = B log10 e = 0.059 Hence the required curve is y = 9.4754e0.059x. Example 2. For the data given below, find the equation to the best fitting exponential curve of the form y = aebx x: 1 2 3 4 5 6 y: 1.6 4.5 13.8 40.2 125 300. Sol. y = aebx Take log, log y = log a + bx log e which is of the form Y = A + Bx where Y = log y, A = log a, B = b log e
  • 589. 576 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES x y Y = log y x2 xY 1 1.6 .2041 1 .2041 2 4.5 .6532 4 1.3064 3 13.8 1.1399 9 3.4197 4 40.2 1.6042 16 6.4168 5 125 2.0969 25 10.4845 6 300 2.4771 36 14.8626 Σx = 21 ΣY = 8.1754 Σx2 = 91 ΣxY = 36.6941 Normal equations are and Σ Σ Σ Σ Σ Y A B Y A B = + = + U V W m x x x x2 (21) Here m = 6 ∴ From (21), 8.1754 = 6A + 21B, 36.6941 = 21A + 91B ⇒ A = – 0.2534, B = 0.4617 ∴ a = antilog A = antilog (– .2534) = antilog ( . ) 17466 = 0.5580 and b = B .4617 .4343 log e = = 1.0631 Hence required equation is y = 0.5580 e1.0631 x. Example 3. Determine the constants a and b by the Method of Least Squares such that y = aebx fits the following data: x 2 4 6 8 10 y 4.077 11.084 30.128 81.897 222.62 Sol. y = aebx Taking log on both sides log y = log a + bx log e or Y = A + BX, where Y = log y A = log a
  • 590. STATISTICAL COMPUTATION 577 B = b log10 e X = x. Normal equations are ΣY = mA + BΣX (22) and ΣXY = AΣX + BΣX2. (23) Here m = 5. Table is as follows: x y X Y XY X2 2 4.077 2 .61034 1.22068 4 4 11.084 4 1.04469 4.17876 16 6 30.128 6 1.47897 8.87382 36 8 81.897 8 1.91326 15.30608 64 10 222.62 10 2.347564 23.47564 100 ΣX = 30 ΣY = 7.394824 ΣXY = 53.05498 ΣX2 = 220 Substituting these values in equations (22) and (23), we get 7.394824 = 5A + 30B and 53.05498 = 30A + 220B. Solving, we get A = 0.1760594 and B = 0.2171509 ∴ a = antilog (A) = antilog (0.1760594) = 1.49989 and b = B log10 e = 0 2171509 4342945 . . = 0.50001 Hence the required equation is y = 1.49989 e0.50001x. Example 4. Obtain a relation of the form y = abx for the following data by the Method of Least Squares: x 2 3 4 5 6 y 8.3 15.4 33.1 65.2 126.4
  • 591. 578 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. The curve to be fitted is y = abx or Y = A + Bx, where A = log10 a, B = log10 b and Y = log10 y. ∴ The normal equations are ΣY = 5A + BΣx and ΣXY = AΣx + BΣx2. x y Y = log10 y x2 xY 2 8.3 0.9191 4 1.8382 3 15.4 1.1872 9 3.5616 4 33.1 1.5198 16 6.0792 5 65.2 1.8142 25 9.0710 6 127.4 2.1052 36 12.6312 Σx = 20 ΣY = 7.5455 Σx2 = 90 ΣxY = 33.1812 Substituting the values of Σx, etc. from the above table in normal equations, we get 7.5455 = 5A + 20B and 33.1812 = 20A + 90B. On solving A = 0.31 and B = 0.3 ∴ a = antilog A = 2.04 and b = antilog B = 1.995. Hence the required curve is y = 2.04(1.995)x. Example 5. By the method of least squares, find the curve y = ax + bx2 that best fits the following data: x 1 2 3 4 5 y 1.8 5.1 8.9 14.1 19.8 Sol. Error of estimate for ith point (xi, yi) is Ei = (yi – axi – bxi 2) By the principle of least squares, the values of a and b are such that U = i i i i i i y ax bx = = ∑ ∑ = − − 1 5 2 1 5 2 2 E ( ) is minimum.
  • 592. STATISTICAL COMPUTATION 579 Normal equations are given by ∂ ∂ U a = 0 ⇒ i i i i i i i x y a x b x = = = ∑ ∑ ∑ = + 1 5 1 5 2 1 5 3 and ∂ ∂ U b = 0 ⇒ i i i i i i i x y a x b x = = = ∑ ∑ ∑ = + 1 5 2 1 5 3 1 5 4 Dropping the suffix i, Normal equations are Σxy = aΣx2 + bΣx3 (24) and Σx2y = aΣx3 + bΣx4 (25) Let us form a table as below: x y x2 x3 x4 xy x2y 1 1.8 1 1 1 1.8 1.8 2 5.1 4 8 16 10.2 20.4 3 8.9 9 27 81 26.7 80.1 4 14.1 16 64 256 56.4 225.6 5 19.8 25 125 625 99 495 Total Σx2 = 55 Σx3 = 225 Σx4 = 979 Σxy = 194.1 Σx2y = 822.9 Substituting these values in equations (24) and (25), we get 194.1 = 55 a + 225 b and 822.9 = 225 a + 979 b ⇒ a = 83 85 55 . ~ 1.52 and b = 317.4 664 ~ .49 Hence the required parabolic curve is y = 1.52 x + 0.49 x2.
  • 593. 580 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 6. Fit the curve pvγ = k to the following data: p (kg/cm2) 0.5 1 1.5 2 2.5 3 v (liters) 1620 1000 750 620 520 460 Sol. pvγ = k v = k p F HG I KJ 1/γ = k1/γ p–1/γ Taking log, log v = 1 1 γ γ log k − log p which is of the form Y = A + BX where Y = log v, X = log p, A = 1 γ log k and B = – 1 γ p v X Y XY X2 .5 1620 – .30103 3.20952 – .96616 0.09062 1 1000 0 3 0 0 1.5 750 .17609 2.87506 .50627 .03101 2 620 .30103 2.79239 .84059 .09062 2.5 520 .39794 2.716 1.08080 .15836 3 460 .47712 2.66276 1.27046 .22764 Total ΣX = 1.05115 ΣY = 17.25573 ΣXY = 2.73196 ΣX2 = .59825 Here m = 6 Normal equations are 17.25573 = 6A + 1.05115 B and 2.73196 = 1.05115 A + 0.59825 B Solving these, we get A = 2.99911 and B = – 0.70298 ∴ γ = – 1 B 1 .70298 = = 1.42252 Again, log k = γA = 4.26629 ∴ k = antilog (4.26629) = 18462.48
  • 594. STATISTICAL COMPUTATION 581 Hence the required curve is pv1.42252 = 18462.48. Example 7. Given the following experimental values: x: 0 1 2 3 y: 2 4 10 15 Fit by the method of least squares a parabola of the type y = a + bx2. Sol. Error of estimate for ith point (xi, yi) is Ei = (yi – a – bxi 2) By the principle of Least Squares, the values of a, b are such that U = i i i i i y a bx = = ∑ ∑ = − − 1 4 2 1 4 2 2 E ( ) is minimum. Normal equations are given by ∂ ∂ U a = 0 ⇒ Σy = ma + bΣx2 (26) and ∂ ∂ U b = 0 Σx2y = aΣx2 + bΣx4 (27) x y x2 x2y x4 0 2 0 0 0 1 4 1 4 1 2 10 4 40 16 3 15 9 135 81 Total Σy = 31 Σx2 = 14 Σx2y = 179 Σx4 = 98 Here m = 4 From (26) and (27), 31 = 4a + 14b and 179 = 14a + 98b Solving for a and b, we get a = 2.71, b = 1.44 Hence the required curve is y = 2.71 + 1.44 x2. Example 8. The pressure of the gas corresponding to various volumes V is measured, given by the following data: V (cm3): 50 60 70 90 100 P (kg cm–2): 64.7 51.3 40.5 25.9 78 Fit the data to the equation PVγ = C.
  • 595. 582 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. PVγ = C ⇒ P = CV–γ Take log on both sides, log P = log C – γ log V ⇒ Y = A + BX where Y = log P, A = log C, B = – γ, X = log V Normal equations are ΣY = mA + BΣX and ΣXY = AΣX + BΣX2 Here m = 5 Table is as below: V P X = log V Y = log P XY X2 50 64.7 1.69897 1.81090 3.07666 2.88650 60 51.3 1.77815 1.71012 3.04085 3.16182 70 40.5 1.84510 1.60746 2.96592 3.40439 90 25.9 1.95424 1.41330 2.76193 3.81905 100 78 2 1.89209 3.78418 4 ΣX = 9.27646 ΣY = 8.43387 ΣXY = 15.62954 ΣX2 = 17.27176 From Normal equations, we have 8.43387 = 5A + 9.27646 B and 15.62954 = 9.27646 A + 17.27176 B Solving these, we get A = 2.22476, B = – 0.28997 ∴ γ = – B = 0.28997 C = antilog (A) = antilog (2.22476) = 167.78765 Hence the required equation of curve is PV0.28997 = 167.78765.
  • 596. STATISTICAL COMPUTATION 583 Example 9. Use the Method of Least Squares to fit the curve: y = c x c x 0 1 + to the following table of values: x: 0.1 0.2 0.4 0.5 1 2 y: 21 11 7 6 5 6. Sol. As derived in article 5.16, normal equations to the curve y = c x c x 0 1 + are ∑ ∑ ∑ = + y x c x c x 0 2 1 1 1 (28) and ∑ ∑ ∑ = + y x c x c x 0 1 1 (29) The table is as below: x y y/x y x 1 x 1 x2 0.1 21 210 6.64078 3.16228 100 0.2 11 55 4.91935 2.23607 25 0.4 7 17.5 4.42719 1.58114 6.25 0.5 6 12 4.24264 1.41421 4 1 5 5 5 1 1 2 6 3 8.48528 .70711 0.25 Σx = 4.2 Σ(y/x) = 302.5 Σy x = 33.71524 1 x ∑ = 10.10081 1 2 x ∑ = 136.5 From equations (28) and (29), we have 302.5 = 136.5 c0 + 10.10081 c1 and 33.71524 = 10.10081 c0 + 4.2 c1 Solving these, we get c0 = 1.97327 and c1 = 3.28182 Hence the required equation of curve is y = 197327 3 28182 . . x x + .
  • 597. 584 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 7.2 1. Fit an equation of the form y = aebx to the following data by the method of least squares: x 1 2 3 4 y 1.65 2.7 4.5 7.35 2. The voltage V across a capacitor at time t seconds is given by the following table. Use the principle of least squares to fit a curve of the form V = aekt to the data: t 0 2 4 6 8 V 150 63 28 12 5.6 3. Using the method of least squares, fit the non-linear curve of the form y = aebx to the following data: x 0 2 4 y 5.012 10 31.62 4. Fit a curve of the form y = axb to the data given below: x 1 2 3 4 5 y 7.1 27.8 62.1 110 161 5. Fit a curve of the form y = abx in least square sense to the data given below: x 2 3 4 5 6 y 144 172.8 207.4 248.8 298.5 6. Fit an exponential curve of the form y = abx to the following data: x 1 2 3 4 5 6 7 8 y 1 1.2 1.8 2.5 3.6 4.7 6.6 9.1 7. Fit a curve y = axb to the following data: x 1 2 3 4 5 6 y 2.98 4.26 5.21 6.1 6.8 7.5
  • 598. STATISTICAL COMPUTATION 585 8. Fit a least square geometric curve y = axb to the following data: x 1 2 3 4 5 y 0.5 2 4.5 8 12.5 9. Derive the least square equations for fitting a curve of the type y = ax2 + b x to a set of n points. Hence fit a curve of this type to the data: x 1 2 3 4 y – 1.51 0.99 3.88 7.66 10. Derive the least squares approximations of the type ax2 + bx + c to the function 2x at the points xi = 0, 1, 2, 3, 4. 11. A person runs the same race track for 5 consecutive days and is timed as follows: Day (x) 1 2 3 4 5 Time (y) 15.3 15.1 15 14.5 14 Make a least square fit to the above data using a function a + b x c x + 2 . 12. It is known that the variables x and y hold the relation of the form y = ax + b x . Fit the curve to the given data: x 1 2 3 4 5 6 7 8 y 5.43 6.28 8.23 10.32 12.63 14.86 17.27 19.51 13. Fit a curve of the type xy = ax + b to the following data: x 1 3 5 7 9 10 y 36 29 28 26 24 15 14. Determine the constants of the curve y = ax + bx2 for the following data: x 0 1 2 3 4 y 2.1 2.4 2.6 2.7 3.4
  • 599. 586 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 15. The presssure and volume of a gas are related by the equation pva = b where a and b are constants. Fit this equation to the following set of data: p (kg/cm3) 0.5 1 1.5 2 2.5 3 v (liters) 1.62 1 0.75 0.62 0.52 0.46 7.29 MOST PLAUSIBLE SOLUTION OF A SYSTEM OF LINEAR EQUATIONS Consider a set of m equations in n variables x, y, z,......, t; a1x + b1y + c1z + ...... + k1t = l1 a2x + b2y + c2z + ...... + k2t = l2 U V | | W | | (30) amx + bmy + cmz + ...... + kmt = lm where ai, bi, ci, ....., ki, li; i = 1, 2, ......, m are constants. In case m = n, the system of equation (30) can be solved uniquely by using algebra. In case m n, we find the values of x, y, z, ......, t which will satisfy the system (30) as nearly as possible using normal equations. On solving normal equations simultaneously, they give the values of x, y, z, ......, t; known as the best or most plausible values. On calculating the second order partial derivatives and substituting values of x, y, z,......, t so obtained, we will observe that the expression will be positive. EXAMPLES Example 1. Find the most plausible values of x and y from the following equations: 3x + y = 4.95, x + y = 3.00, 2x – y = 0.5, x + 3y = 7.25. Sol. Let S = (3x + y – 4.95)2 + (x + y – 3)2 + (2x – y – 0.5)2 + (x + 3y – 7.25)2 (31) Differentiating S partially with respect to x and y separately and equating to zero, we have ∂ ∂ S x = 0 = 2(3x + y – 4.95) (3) + 2(x + y – 3) + 2(2x – y – 0.5) (2) + 2(x + 3y – 7.25)
  • 600. STATISTICAL COMPUTATION 587 ⇒ 30x + 10y = 52.2 or 3x + y = 5.22 (32) and ∂ ∂ S y = 0 = 2(3x + y – 4.95) + 2(x + y – 3) + 2(2x – y – 0.5) (– 1) + 2(x + 3y – 7.25) (3) ⇒ 10x + 24y = 58.4 or x + 2.4y = 5.84 (33) Solving equations (32) and (33), we get x = 1.07871 and y = 1.98387. Example 2. Three independent measurements on each of the angles A, B, and C of a triangle are as follows: A B C 39.5° 60.3° 80.1° 39.3° 63.2° 80.3° 39.6° 69.1° 80.4° Obtain the best estimate of the three angles when the sum of the angles is taken to be 180°. Sol. Let the three measurements of angles A, B, C be x1, x2, x3; y1, y2, y3 and z1, z2, z3 respectively. Further suppose the best estimates of the angle A, B, and C to be α, β, γ respectively where γ = 180° – (α + β) According to Least squares method, S = i i i i i i x y z = = = ∑ ∑ ∑ − + − + − + + 1 3 2 1 3 2 1 3 2 180 ( ) ( ) ( ) α β α β (34) and ∂ ∂α α α β S = = − − + − + + = = ∑ ∑ 0 2 2 180 1 3 1 3 i i i i x z ( ) ( ) ∂ ∂β β α β S = = − − + − + + = = ∑ ∑ 0 2 2 180 1 3 1 3 i i i i y z ( ) ( ) or − + + − + + = + + − + + = R S T Σ Σ Σ Σ x z y z 3 540 3 3 0 3 540 3 3 0 α α β β α β – or R S T 6α + 3β = 540 + Σx – Σz = 417.6 (35) 3α + 6β = 540 + Σy – Σz = 481.8 (36)
  • 601. 588 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Solving equations (35) and (36), we get α = 39.2667, β = 60.6667, γ = 80.0666 ASSIGNMENT 7.3 1. Find the most plausible values of x and y from the following equations: x + y = 3, x – y = 2, x + 2y = 4, x – 2y = 1 2. Find the most plausible values of x and y from the equations: x + y = 3.31, 2x – y = .03, x + 3y = 7.73, 3x + y = 5.47 3. Find the most plausible values of x, y, and z from the follwoing equations: x – y + 2z = 3, 3x + 2y – 5z = 5, 4x + y + 4z = 21, – x + 3y + 3z = 14 4. Find the most plausible values of x, y, and z from the following equations: (i) x + y = 3.01, 2x – y = 0.03, x + 3y = 7.02 and 3x + y = 4.97 (ii) x + 2y = 4, x = y + 2, x + y – 3 = 0, x – 2y = 1 (iii) x + 2.5y = 21, 4x + 1.2y = 42.04, 3.2x – y = 28 and 1.5x + 6.3y = 40 (iv) x – 5y + 4 = 0, 2x – 3y + 5 = 0 x + 2y – 3 = 0, 4x + 3y + 1 = 0 5. Find the most plausible values of x, y, and z from the following equations: (i) 3x + 2y – 5z = 13 (ii) x + 2y + z = 1 x – y + 2z = – 2 2x + y + z = 4 4x + y + 4z = 3 – x + y + 2z = 3 – x + 3y + 3z = 0 4x + 2y – 5z = – 7 (iii) x – y + 2z = 3, 3x + 2y – 5z = 5 4x + y + 4z = 21, – x + 3y + 3z = 14. 7.30 CURVE-FITTING BY SUM OF EXPONENTIALS We are to fit a sum of exponentials of the form y = f(x) = A A A 1 2 1 2 e e e x x n x n λ λ λ + + + ...... (37) to a set of data points say (x1, y1), (x2, y2), ......, (xn, yn) In equation (37), we assume that n is known and A1, A2, ......, An, λ1, λ2, ......, λn are to be determined. Since equation (37) involves n arbitrary constants,
  • 602. STATISTICAL COMPUTATION 589 It can be seen that f(x) satisfies a differential equation of the type d y dx a d y dx a d y dx n n n n n n + + − − − − 1 1 1 2 2 2 + ...... + any = 0 (38) where coefficients a1, a2, ......, an are unknown. According to the Froberg Method, we numerically evaluate the derivatives at the n data points and substitute them in (38) thus obtaining a system of n linear equations for n unknowns a1, ......., an which can be solved thereafter. Again, since λ1, λ2, ......, λn are the roots of algebraic equation λn + a1λn–1 + a2λn–2 + ...... + an = 0 (39) which, when solved, enables us to compute A1, A2, ....., An from equation (37) by the method of least squares. An obvious disadvantage of the method is the numerical evaluation of the derivatives whose accuracy deteriorates with their increasing order, leading to unreliable results. In 1974, Moore described a computational technique which leads to more reliable results. We demonstrate the method for the case n = 2. Let the function to be fitted to a given data be of the form y = A A 1 2 1 2 e e x x λ λ + (40) which satisfies a differential equation of the form d y dx a dy dx 2 2 1 = + a2y (41) where the constants a1 and a2 have to be determined. Assuming that a is the initial value of x, we obtain by integrating (41) from a to x, the following equation y′(x) – y′(a) = a1y(x) – a1y(a) + a2 a x y x dx z ( ) (42) where y′(x) denotes dy dx . Integrating (42) again from a to x, we get y(x) – y(a) – y′(a) (x – a) = a1 a x y x dx z ( ) – a1(x – a) y(a) + a2 a x a x y x dx z z ( ) dx (43)
  • 603. 590 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES using the formula, a x a x a x n f x dx dx n x t f t dt z z z = − − − ...... ( ) ...... ( ) ! ( ) ( ) 1 1 1 (44) equation (43) simplifies to, y(x) – y(a) – (x – a) y′(a) = a1 a x y x dx z ( ) – a1(x – a) y(a) + a2 a x x t y t dt z − ( ) ( ) (45) In order to use equation (45) to set up a linear system for a1 and a2, y′(a) should be eliminated. To do this, we choose two data points x1 and x2 such that a – x1 = x2 – a then from (45), y(x1) – y(a) – (x1– a) y′(a) = a1 a x a x y x dx a x a y a a x t y t dt 1 1 1 1 2 1 z z − − + − ( ) ( ) ( ) ( ) ( ) y(x2) – y(a) – (x2 – a) y′(a) = a1 a x a x y x dx a x a y a a x t y t dt 2 2 1 2 2 2 z z − − + − ( ) ( ) ( ) ( ) ( ) Adding the above equations and simplifying, we get y(x1) + y(x2) – 2y(a) = a1 a x a x y x dx y x dx 1 2 z z + L NM O QP ( ) ( ) + − + − L NM O QP z z a x t y t dt x t y t dt a x a x 2 1 2 1 2 ( ) ( ) ( ) ( ) (46) we find integrals using Simpson’s rule and equation (46) can be used to set up a linear system of equations for a1 and a2, then we obtain λ1 and λ2 from the characteristic equation λ2 = a1λ + a2 (47) Finally, A1 and A2 can be obtained by the Method of Least Squares. Example. Fit a function of the form y = A e A e 1 x 2 x 1 2 λ λ + to the data given by x: 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 y: 1.54 1.67 1.81 1.97 2.15 2.35 2.58 2.83 3.11.
  • 604. STATISTICAL COMPUTATION 591 Sol. Choose x1 = 1, x2 = 1.4, a = 1.2 so that, a – x1 = x2 – a then, y(x1) + y(x2) – 2y(a) = a1 a x a x y x dx y x dx 1 2 z z + L NM O QP ( ) ( ) + − + − L NM O QP z z a x t y t dt x t y t dt a x a x 2 1 2 1 2 ( ) ( ) ( ) ( ) ⇒ 1.54 + 2.15 – 3.62 = a1 − + L NM O QP z z 1 1 2 1 2 1 4 . . . ( ) ( ) y x dx y x dx + − − + − L NM O QP z z a t y t dt t y t dt 2 1 1 2 1 2 1 4 1 14 . . . ( ) ( ) ( . ) ( ) (48) Evaluation of 1 1.2 y(x) dx z The table of values is x: 1 1.1 1.2 y(x): 1.54 1.67 1.81 By Simpson’s 1 3 rd rule, 1 1.2 (1.54 1.81) 4(1.67 z = + + y x dx ( ) . [ )] 0 1 3 = 0.33433 Evaluation of 1.2 1.4 y(x) dx z The table of values is x: 1.2 1.3 1.4 y(x): 1.81 1.97 2.15 By Simpson’s 1 3 rd rule, 1 1 4 0 1 3 .2 . ( ) . z = y x dx [(1.81 + 2.15) + 4(1.97)] = 0.39466
  • 605. 592 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Evaluation of 1 1.2 (1 t) y(t) dt z − The table of values is t: 1 1.1 1.2 y(t): 1.54 1.67 1.81 (1 – t) y(t): 0 – 0.167 – 0.362 By Simpson’s 1 3 rd rule, 1 1.2 z − = ( ) ( ) . 1 0 1 3 t y t dt [0 – .362 + 4 (– .167)] = – .03433 Evaluation of 1.2 1.4 (1.4 t) y(t) dt z − The table of values is t: 1.2 1.3 1.4 (1.4 – t): .2 .1 0 y(t): 1.81 1.97 2.15 (1.4 – t) y(t): .362 .197 0 By Simpson’s 1 3 rd rule, 1.2 1.4 z − = ( . ) ( ) . 14 0 1 3 t y t dt [(0.362 + 0) + 4(.197)] = 0.03833 Substituting values of above obtained integrals in equation (48), we get 0.07 = a1[– 0.33433 + 0.39466] + a2[0.03433 + 0.03833] 0.07 = 0.06033 a1 + 0.07266 a2 ⇒ 1.8099 a1 + 2.1798 a2 = 2.10 or 1.81 a1 + 2.18 a2 = 2.10 (49) Again, letting x1 = 1.4, a = 1.6 and x2 = 1.8 so that a – x1 = x2 – a then, y(x1) + y(x2) – 2y(a) = a y x dx y x dx a x a x 1 1 2 z z + L NM O QP ( ) ( ) + a x t y t dt x t y t dt a x a x 2 1 2 1 2 z z − + − L NM O QP ( ) ( ) ( ) ( )
  • 606. STATISTICAL COMPUTATION 593 ⇒ 2.15 + 3.11 – 5.16 = a y x dx y x dx 1 1 4 1 6 1 6 1 8 − + L NM O QP z z . . . . ( ) ( ) + a t y t dt t y t dt 2 1 4 1 6 1 6 1 8 14 18 − − + − L NM O QP z z . . . . ( . ) ( ) ( . ) ( ) Evaluating all of the above integrals by Simpson’s 1 3 rd rule and substituting, we obtain 2.88 a1 + 3.104 a2 = 3.00 (50) Solving (49) and (50), we get a1 = 0.03204, a2 = 0.9364 Characteristic equation is λ2 = a1λ + a2 ⇒ λ2 – 0.03204λ – 0.9364 = 0 ⇒ λ1 = 0.988 ≈ 0.99 and λ2 = – 0.96 Now the curve to be fitted is y = A1e0.99x + A2e–0.96x (51) Residual Ei = yi – A1e e x x i i 0.99 2 0.96 − − A Consider U = i n i i n i x x y e e i i = = − ∑ ∑ = − − 1 2 1 1 0.99 2 0.96 2 E A A ( ) By the Method of Least Squares, values of A1 and A2 are chosen such that U is the minimum. For U to be minimum, ∂ ∂ U A1 0 = and ∂ ∂ U A2 0 = Now, ∂ ∂ U A1 0 = ⇒ 2 0 1 99 2 96 99 ∑ − − − = − ( ) ( ) . . . y e e e x x x A A ⇒ ∑ ∑ = + ye e e x x x . . . 99 1 1 98 2 03 A A (52)
  • 607. 594 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES and ∂ ∂ U A2 0 = ⇒ 2 0 1 99 2 96 96 ∑ − − − = − − ( ) ( ) . . . y e e e x x x A A ⇒ ∑ ∑ ∑ − − = + ye e e x x x . . . 96 1 03 2 1 92 A A (53) Solving normal equations (52) and (53) using values of x and y given in the table, we get A1 = 0.499 and A2 = 0.491 Hence the required function is y = 0.499 e0.99x + 0.491 e–0.96x. 7.31 SPLINE INTERPOLATION When computers were not available, the draftsman used a device to draw a smooth curve through a given set of points such that the slope and curvature were also continuous along the curve, i.e., f(x), f ′(x), and f ″(x) were continuous on the curve. Such a device was called a spline and plotting of the curve was called spline fitting. The given interval [a, b] is subdivided into n subintervals [x0, x1], [x1, x2],......, [xn–1 , xn] where a = x0 x1 x2 ..... xn = b. The nodes (knots) x1, x2,....., xn–1 are called internal nodes. 7.32 SPLINE FUNCTION A spline function of degree n with knots (nodes) xi, i = 0, 1,......, n is a function F(x) satisfying the properties (i) F(xi) = f(xi); i = 0, 1,......, n. (ii) on each subinterval [xi–1, xi], 1 ≤ i ≤ n, F(x) is a polynomial in x of degree at most n. (iii) F(x) and its first (n – 1) derivatives are continuous on [a, b] (iv) F(x) is a polynomial of degree one for x a and x b. 7.33 CUBIC SPLINE INTERPOLATION A cubic spline satisfies the following properties: (i) F(xi) = fi, i = 0, 1,......, n
  • 608. STATISTICAL COMPUTATION 595 (ii) On each subinterval [xi–1, xi], 1 ≤ i ≤ n, F(x) is a third degree polynomial. (iii) F(x), F′(x) and F″(x) are continuous on [a, b]. Since F(x) is piecewise cubic, polynomial F″(x) is a linear function of x in the interval xi–1 ≤ x ≤ xi and hence can be written as F″(x) = x x x x i i i − − −1 F″(xi–1) + x x x x i i i − − − − 1 1 F″(xi) (54) For equally spaced intervals, xi – xi–1 = h; 1 ≤ i ≤ n From (54), F″(x) = 1 h [(xi – x) F″(xi–1) + (x – xi–1) F″(xi)] (55) Integrating equation (55) twice, we get F(x) = 1 6 6 3 1 1 3 h x x x x x x i i i i ( ) ( ) ( ) ( ) − ″ + − ″ L NMM O QPP − − F F + c1(xi – x) + c2(x – xi–1) (56) where c1 and c2 are arbitrary constants which are to be determined by conditions F(xi) = fi; i = 0, 1, 2,......, n Then, fi = 1 6 3 2 h h x c h i F″ L NM O QP+ ( ) ⇒ c2 = f h h x i i − ″ 6 F ( ) (57) and fi–1 = 1 6 3 1 1 h h x c h i F″ L NM O QP+ − ( ) ⇒ c1 = f h h x i i − − − ″ 1 1 6 F ( ) (58) Putting the values of c1 and c2 in equation (56), we get F(x) = 1 6 6 3 1 1 3 h x x x x x x i i i i ( ) ( ) ( ) ( ) − ″ + − ″ L NMM − − F F + (xi – x) f h x i i − − − ″ R S T U V W 1 2 1 6 F ( ) + (x – xi–1) f h x i i − ″ R S T U V W O Q PP 2 6 F ( ) (59)
  • 609. 596 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Denoting F″(xi) = Mi, we have F(x) = 1 6 3 1 1 3 h x x x x i i i i [( ) ( ) − + − − − M M + (xi – x) {6fi–1 – h2 Mi–1} + (x – xi–1) {6fi – h2 Mi}] (60) Now, F′(x) = 1 6h [– 3(xi – x)2 Mi–1 + 3(x – xi–1)2 Mi + 6(fi – fi–1) + h2Mi–1 – h2Mi] (61) Now, we require that the derivative F′(x) be continuous at x = xi ± ε as ε → 0 Therefore, (i) F′(xi–1 + 0) = 1 6h [– 3h2Mi–1 + h2Mi–1 – h2Mi + 6(fi – fi–1)] = 1 6h [– h2Mi – 2h2Mi–1 + 6(fi – fi–1)] (62) Again in the interval [xi–2, xi–1], F′(x) = 1 6h [– 3(xi–1 – x)2 Mi–2 + 3(x – xi–2)2 Mi–1 + 6(fi–1 – fi–2) + h2Mi–2 – h2Mi–1] (63) (ii) From (63), F′(xi–1 – 0) = 1 6h [3h2Mi–1 + 6fi–1 – 6fi–2 + h2Mi–2 – h2Mi–1] = 1 6h [2h2Mi–1 + h2Mi–2 + 6fi–1 – 6fi–2] (64) As F′(x) is continuous at xi–1, ∴ F′(xi–1 – 0) = F′(xi–1 + 0) ∴ 2h2Mi–1 + h2Mi–2 + 6fi–1 – 6fi–2 = – h2Mi – 2h2Mi–1 + 6fi – 6fi–1 or h2 (Mi + 4Mi–1 + Mi–2) = 6(fi – 2fi–1 + fi–2) For the interval [xi–1, xi], we have h2 [Mi+1 + 4Mi + Mi–1] = 6(fi+1 – 2fi + fi–1) (65) where i = 1, 2,......, n
  • 610. STATISTICAL COMPUTATION 597 This gives a system of (n – 1) linear equations with (n + 1) unknowns M0, M1,......, Mn. Two additional conditions may be taken in one of the following forms: (i) M0 = Mn = 0 (Natural spline) (ii) M0 = Mn, M1 = Mn+1, f0 = fn, f1 = fn+1, h1 = hn+1 A spline satisfying the above conditions is called a periodic spline. (iii) For a non-periodic spline, we use the conditions F′(a) = f ′(a) = f0′ and F′(b) = f ′(b) = fn′ Splines usually provide a better approximation of the behavior of functions that have abrupt local changes. Further, splines perform better than higher order polynomial approximations. 7.34 STEPS TO OBTAIN CUBIC SPLINE FOR GIVEN DATA Step 1. For interval (xi–1, xi), write cubic spline as F(x) = 1 6h [(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1} + (x – xi–1){6fi – h2Mi}] Step 2. If not given, choose M0 = 0 = M3 (for the interval 0 ≤ x ≤ 3) Step 3. For i = 1, 2,......, n, choose values of M1 and M2 such that h2[Mi+1 + 4Mi + Mi–1] = 6[fi+1 – 2fi + fi–1] exists for two sub intervals 0 ≤ x ≤ 1 and 1 ≤ x ≤ 2 respectively, where h is the interval of differencing. Step 4. Find F(x) for different sub-intervals and tabulate at last. EXAMPLES Example 1. Obtain the cubic spline for the following data: x: 0 1 2 3 y: 2 – 6 – 8 2. Sol. For the interval (xi–1, xi), the cubic spline is F(x) = 1 6h [(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1} + (x – xi–1) {6fi – h2Mi}]
  • 611. 598 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES With M0 = M3 = 0 and for i = 1, 2,......, n; we also have h2[Mi–1 + 4 Mi + Mi+1] = 6 [fi+1 – 2fi + fi–1] Here h = 1 ∴ M0 + 4M1 + M2 = 6(f2 – 2f1 + f0) | For 0 ≤ x ≤ 1 and M1 + 4M2 + M3 = 6(f3 – 2f2 + f1) | For 1 ≤ x ≤ 2 Here, M2 + 4M1 + M0 = 6[– 8 – 2(– 6) + 2] = 36 and M3 + 4M2 + M1 = 6 [2 – 2 (– 8) + (– 6) = 72 Putting M0 = M3 = 0, we get M2 + 4M1 = 36 4M2 + M1 = 72 Solving, we get M1 = 4.8, M2 = 16.8 Hence for 0 ≤ x ≤ 1, F(x) = 1 6 [(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) (6f0 – M0) + (x – 0) (6f1 – M1)] = 1 6 [x3(4.8) + (1 – x) (12) + x (– 36 – 4.8)] = 0.8x3 – 8.8x + 2 For 1 ≤ x ≤ 2, F(x) = 1 6 [(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1} + (x – 1) {6f2 – M2}] = 1 6 [(2 – x)3 (4.8) + (x – 1)3 (16.8) + (2 – x) {– 36 – 4.8} + (x – 1) {– 48 – 16.8}] = 2x3 – 3.6x2 – 5.2x + 0.8 For 2 ≤ x ≤ 3, F(x) = 1 6 [(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) {6f2 – h2M2} + (x – 2) {6f3 – h2M3}] = 1 6 [(3 – x)3 (16.8) + (3 – x) {– 48 – 16.8} + (x – 2) (12)] | using M3 = 0
  • 612. STATISTICAL COMPUTATION 599 ⇒ F(x) = 1 6 [(27 – x3 – 27x + 9x2) (16.8) – 64.8 (3 – x) + 12x – 24] = 1 6 [– 16.8x3 + 151.2x2 – 376.8x + 235.2] = – 2.8x3 + 25.2x2 – 62.8x + 39.2 Therefore, cubic splines in different intervals are tabulated as below: Interval Cubic spline [0, 1] 0.8x3 – 8.8x + 2 [1, 2] 2x3 – 3.6x2 – 5.2x + 0.8 [2, 3] – 2.8x3 + 25.2x2 – 62.8x + 39.2. Example 2. Obtain the cubic spline for every subinterval from the given data: x: 0 1 2 3 f(x): 1 2 33 244 with the end conditions M0 = M3 = 0. Hence find an estimate of f(2.5). Sol. For the interval (xi–1, xi), the cubic spline is F(x) = 1 6h [(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1} + (x – xi–1) {6fi – h2Mi}] (66) For i = 1, 2,......., n, we have h2 [Mi–1 + 4Mi + Mi+1] = 6[fi+1 – 2fi + fi–1] (67) and M0 = M3 = 0 (68) Here h = 1 ∴ From (67), For 0 ≤ x ≤ 1, M0 + 4M1 + M2 = 6(f2 – 2f1 + f0) (69) and for 1 ≤ x ≤ 2, M1 + 4M2 + M3 = 6(f3 – 2f2 + f1) (70) From (69), we get M0 + 4M1 + M2 = 6[33 – 4 + 1] = 180 (71) and M1 + 4M2 + M3 = 6[244 – 66 + 2] = 1080 (72) Using (68), equations (71) and (72) reduce to 4M1 + M2 = 180 and M1 + 4M2 = 1080
  • 613. 600 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Solving, we get M1 = – 24 and M2 = 276 (73) Hence for 0 ≤ ≤ ≤ ≤ ≤ x ≤ ≤ ≤ ≤ ≤ 1, F(x) = 1 6 [(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) {6f0 – M0} + (x – 0) {6f1 – M1}] | ∵ h = 1 = 1 6 [x3 (– 24) + (1 – x) {6} + x(12 + 24)] = 1 6 [– 24x3 + 6 – 6x + 36x] = – 4x3 + 5x + 1 For 1 ≤ x ≤ 2, F(x) = 1 6 [(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1} + (x – 1) {6f2 – M2}] = 1 6 [(2 – x)3 (– 24) + (x – 1)3 (276) + (2 – x) (12 + 24) + (x – 1) {198 – 276}] = 1 6 [(2 – x)3 (– 24) + 276 (x – 1)3 + 36(2 – x) – 78(x – 1)] = 50x3 – 162 x2 + 167 x – 53 For 2 ≤ x ≤ 3, F(x) = 1 6 [(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) (6f2 – M2) + (x – 2) (6f3 – M3)] = 1 6 [(3 – x)3 (276) + (x – 2)3 (0) + (3 – x) (198 – 276) + (x – 2) {(6 × 244) – 0}] = 1 6 [(27 – x3 – 27x + 9x2) (276) + (3 – x) (– 78) + 1464 (x – 2)] = – 46x3 + 414x2 – 985x + 715 Therefore, the cubic splines in different intervals are tabulated as below: Interval Cubic Spline [0, 1] – 4x3 + 5x + 1 [1, 2] 50x3 – 162x2 + 167x – 53 [2, 3] – 46x3 + 414x2 – 985x + 715
  • 614. STATISTICAL COMPUTATION 601 An estimate at x = 2.5 is f(2.5) = – 46 (2.5)3 + 414(2.5)2 – 985 (2.5) + 715 = 121.25. 7.35 APPROXIMATIONS The problem of approximating a function is an important problem in numerical analysis due to its wide application in the development of software for digital computers. The functions commonly used for approximating given functions are polynomials, trigonometric functions, exponential functions, and rational functions. However, from an application point of view, the polynomial functions are mostly used. 7.36 LEGENDRE AND CHEBYSHEV POLYNOMIALS In the theory of approximation of functions, we often use the well known orthogonal polynomials, Legendre and Chebyshev polynomials, as the coordinate functions while applying the method of least squares. Chebyshev polynomials are also used in the economization of power series. 7.37 LEGENDRE POLYNOMIALS Pn(x) is a Legendre polynomial in x of degree n and satisfies the Legendre differential equation (1 – x2) d y dx x dy dx n n y 2 2 2 1 0 − + + = ( ) we have Pn(– x) = (– 1)n Pn(x). From this, we conclude that Pn(x) is an even function of x if n is even and an odd function of x if n is odd. Legendre polynomials satisfy the recurrence relation (n + 1) Pn+1 (x) = (2n + 1) xPn(x) – nPn–1(x) P0(x) = 1, P1(x) = x we have Pn(x) = 13 5 2 1 1 2 2 1 1 2 3 2 4 2 1 2 3 2 4 . . ...... ( ) ! ( ) ( ) ( )( )( ) . .( ) ( ) ...... n n x n n n x n n n n n n x n n n − − − − + − − − − − − L NM O QP − −
  • 615. 602 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES In particular, P2(x) = 3 1 2 2 x − , P3(x) = 5 3 2 3 x x − P4(x) = 35 30 3 8 4 2 x x − + , P5(x) = 63 70 15 8 5 3 x x x − + Legendre polynomials Pn(x) are orthogonal on the interval [– 1, 1] with respect to the weight function W(x) = 1 We have –1 ( ) ( ) 1 z P P m n x x dx = 0 2 2 1 , , if if m n n m n ≠ + ≠ R S | T | U V | W | 7.38 CHEBYSHEV POLYNOMIALS The Chebyshev polynomial of first kind of degree n over the interval [– 1, 1] is denoted by Tn(x) and is defined by the relation Tn(x) = cos (n cos–1 x) = cos nθ where θ = cos–1 x or x = cos θ we have, T0(x) = 1 and T1(x) = x The Chebyshev polynomial of second kind of degree n over the interval [– 1, 1] is denoted by Un(x) and is defined by the relation Un(x) = sin (n cos–1 x) = sin nθ where θ = cos–1 x or x = cos θ 1. Chebyshev’s polynomials are also known as Tchebichef or Tchebicheff or Tchebysheff. 2. Sometimes the Chebyshev polynomial of the second kind is defined by Un(x) = sin {(n 1) cos x} 1 x U (x) 1 x 1 2 n 1 2 + − = − − + . NOTE
  • 616. STATISTICAL COMPUTATION 603 7.39 SPECIAL VALUES OF CHEBYSHEV POLYNOMIALS T0 (x) = cos 0 = 1 T1 (x) = cos (cos–1 x) = x T2 (x) = cos (2 cos–1 x) = 2 cos2 (cos–1 x) – 1 = 2x2 – 1 T3 (x) = cos (3 cos–1 x) = 4 cos3 (cos–1 x) – 3 cos (cos–1 x) = 4x3 – 3x T4 (x) = cos (4 cos–1 x) = 2 cos2 (2 cos–1 x) – 1 = 2 (2x2 – 1)2 – 1 = 8x4 – 8x2 + 1 T5(x) = cos (5 cos–1 x) = cos (3 cos–1 x) cos (2 cos–1 x) – sin (3 cos–1 x) sin (2 cos–1 x) = 16x5 – 20x3 + 5x Similarly, T6 (x) = 32x6 – 48x4 + 18x2 – 1 and so on. 7.40 ORTHOGONAL PROPERTIES To prove: (1) − z − = ≠ = ≠ = = R S | T | U V | W | 1 1 2 1 0 2 0 0 T T if / if if n m x x x dx m n m n m n ( ) ( ) ; ; ; π π (2) − z − = ≠ = ≠ = = R S | T | U V | W | 1 1 2 1 0 2 0 0 0 U U if / if if n m x x x dx m n m n m n ( ) ( ) ; ; ; π . 7.41 RECURRENCE RELATIONS 1. Tn+1 (x) – 2x Tn(x) + Tn–1(x) = 0. 2. (1 – x2) Tn′(x) = – nxTn(x) + n Tn–1(x). 3. Un+1(x) – 2x Un(x) + Un–1(x) = 0. 4. (1 – x2) Un′(x) = – nx Un(x) + nUn–1(x).
  • 617. 604 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.42 ALITER TO FIND CHEBYSHEV POLYNOMIALS The recurrence relation Tn + 1(x) = 2x Tn (x) – Tn–1(x) (74) Can also be used to compute all Tn(x) successively since we know T0(x) and T1(x). T0(x) = 1, T1(x) = x Given n = 1 in (74), we have T2(x) = 2xT1(x) – T0(x) = 2x2 – 1 Given n = 2 in (74), we get T3 (x) = 2x T2(x) – T1(x) = 2x (2x2– 1) – x = 4x3 – 3x Given n = 3 in (74), we get T4 (x) = 2x T3(x) – T2(x) = 2x (4x3 – 3x) – (2x2 – 1) = 8x4 – 6x2 – 2x2 + 1 = 8x4 – 8x2 + 1 Given n = 4 in (74), we get T5 (x) = 2x T4(x) – T3(x) = 2x (8x4 – 8x2 + 1) – (4x3 – 3x) = 16x5 – 20x3 + 5x Similarly, T6 (x) = 2x T5(x) – T4(x) = 2x (16x5 – 20x3 + 5x) – (8x4 – 8x2 + 1) = 32x6 – 48x4 + 18x2 – 1. 7.43 EXPRESSION OF POWERS OF X INTERMS OF CHEBYSHEV POLYNOMIALS 1 = T0(x) x = T1(x) x2 = 1 2 [T0(x) + T2(x)] x3 = 1 4 [3 T1(x) + T3(x)] x4 = 1 8 [3 T0(x) + 4T2(x) + T4(x)]
  • 618. STATISTICAL COMPUTATION 605 x5 = 1 16 [10 T1(x) + 5T3(x) + T5(x)] x6 = 1 32 [10 T0(x) + 15T2(x) + 6T4(x) + T6(x)] and so on. The above expressions will be useful in the economization of power series. 7.44 PROPERTIES OF CHEBYSHEV POLYNOMIALS (i) Tn(x) is a polynomial of degree n. We have Tn(– x) = (– 1)n Tn(x) so that Tn(x) is an even function of x if n is even and it is an odd function of x if n is odd. (ii) Tn(x) has n simple zeros. xk = cos 2 1 2 k n − F HG I KJ π , k = 1, 2, ......, n on the interval [– 1, 1] (iii) Tn(x) assumes extreme values at (n + 1) points xk = cos k n π , k = 0, 1, 2, ......, n and the extreme value at xk is (– 1)k. (iv) | Tn(x) | ≤ 1, x ∈ [– 1, 1] (v) Tn(x) are orthogonal on the interval [– 1, 1] with respect to the weight function W(x) = 1 1 2 − x (vi) If pn(x) is any monic polynomial of degree n and ~ ( ) ( ) T T n n n x x = − 2 1 is the monic Chebyshev polynomial, then max | ~ ( )| max | ( )| − ≤ ≤ − ≤ ≤ ≤ 1 1 1 1 x n x n x p x T . 7.45 CHEBYSHEV POLYNOMIAL APPROXIMATION Let f(x) be a continuous function defined on the interval [– 1, 1] and let c0 + c1x + c2x2 + ...... + cnxn be the required minimax (or uniform) polynomial approximation for f(x).
  • 619. 606 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Suppose f(x) = a a x i i i 0 1 2 + = ∞ ∑ T ( ) is the Chebyshev series expansion for f(x). Then the truncated series or the partial sum Pn(x) = a a x i n i i 0 1 2 + = ∑ T ( ) (75) is very nearly the solution to the problem max ( ) min ( ) − ≤ ≤ = − ≤ ≤ = − = − ∑ ∑ 1 1 0 1 1 0 x i n i i x i n i i f x c x f x c x i.e., the partial sum (75) is nearly the best uniform approximation to f(x). Reason. Suppose we write f(x) = a0 2 + a1T1(x) + a2T2(x) + ...... + anTn(x) + an + 1Tn + 1(x) + remainder (76) Neglecting the remainder, we obtain from (76), f(x) – a a x i n i i 0 1 2 + L N MM O Q PP = ∑ T ( ) = an+1Tn+1(x) (77) Since Tn + 1 (x) has n + 2 equal maxima and minima which alternate in sign, therefore by Chebyshev equioscillation theorem, the polynomial (75) of degree n is the best uniform approximation to f(x). 7.46 LANCZOS ECONOMIZATION OF POWER SERIES FOR A GENERAL FUNCTION First we express the given function f(x) as a power series in x in the form f(x) = i i i a x = ∞ ∑ 0 , – 1 ≤ x ≤ 1 (78) Then we change each power of x in (78) in terms of Chebyshev polynomials and we obtain f(x) = i i i c x = ∞ ∑ 0 T ( ) (79)
  • 620. STATISTICAL COMPUTATION 607 as the Chebyshev series expansion for f(x) on [– 1, 1]. It has been found that for a large number of functions f(x), the series (79) converges more rapidly than the power series given by eqn. (78). If we truncate series (79) at Tn(x), then the partial sum Pn(x) = i n i i c x = ∑ 0 T ( ) (80) is a good uniform approximation to f(x) in the sense max − ≤ ≤ 1 1 x | f(x) – Pn(x) | ≤ | cn + 1 | + | cn + 2 | + ...... ≤ ε (say) For a given ε, it is possible to find the number of terms that should be retained in eqn. (80). This process is known as Lanczos Economization. Replacing each Ti(x) in eqn. (80) by its polynomial form and rearranging the terms, we get the required economized polynomial approximation for f(x). EXAMPLES Example 1. Prove that 1 x2 − Tn(x) = Un + 1 (x) – x Un(x). Sol. If x = cos θ, we get Tn (cos θ) = cos nθ and Un (cos θ) = sin nθ Then we are to prove, sin θ cos nθ = sin (n + 1)θ – cos θ sin nθ Now, R.H.S. = sin nθ cos θ + cos nθ sin θ – cos θ sin nθ = sin θ cos nθ = L.H.S. Example 2. Find the best lower order approximation to the cubic 2x3 + 3x2. Sol. We know that x3 = 1 4 [3T1(x) + T3(x)] 2x3 + 3x2 = 2 1 4 {3 ( ) ( )} T T 1 3 x x + L NM O QP + 3x2 = 3 2 1 2 3 2 T T 1 3 ( ) ( ) x x x + + = 3x2 + 3 2 1 2 x x + T3 ( ) [∵ T1(x) = x]
  • 621. 608 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since | T3(x) | ≤ 1, – 1 ≤ x ≤ 1 therefore, the polynomial 3x2 + 3 2 x is the required lower order approximation to the given cubic with a max. error ± 1 2 in range [– 1, 1]. Example 3. Express 2 T0 (x) – 1 4 T2 (x) + 1 8 T4 (x) as polynomials in x. Sol. 2T0 (x) – 1 4 T2 (x) + 1 8 T4 (x) = 2 (1) 1 4 − − + − + ( ) ( ) 2 1 1 8 8 8 1 2 4 2 x x x = − + + − + 2 1 2 1 4 1 8 2 4 2 x x x = x x 4 2 3 4 19 8 − + . Example 4. Express 1 – x2 + 2x4 as sum of Chebyshev polynomials. Sol. 1 – x2 + 2x4 = 1 – x2 + 2 1 8 4 {3 ( ) ( ) ( )} T T T 0 2 4 x x x + + L NM O QP = 1 – x2 + 3 4 1 4 T T T 0 2 4 ( ) ( ) ( ) x x x + + = 1 1 2 3 4 1 4 − + + + + [ ( ) ( )] ( ) ( ) ( ) T T T T T 0 2 0 2 4 x x x x x = T T T T T T 0 0 2 0 2 4 ( ) ( ) ( ) ( ) ( ) ( ) x x x x x x − − + + + 1 2 1 2 3 4 1 4 = 5 4 T T T 0 2 4 ( ) ( ) ( ) x x x + + 1 2 1 4 . Example 5. Economize the power series: sin x ≈ x x 6 x 120 x 5040 3 5 7 − + − + ...... to three significant digit accuracy. Sol. The truncated series is sin x ≈ x x x − + 3 5 6 120 (81)
  • 622. STATISTICAL COMPUTATION 609 which is obtained by truncating the last term since 1 5040 = 0.000198 will produce a change in the fourth decimal place only. Converting the powers of x in (81) into Chebyshev polynomials, we get sin x ≈ T 1 6 T T T T T 1 1 3 1 3 5 ( ) {3 ( ) ( )} { ( ) ( ) ( )} x x x x x x − + L NM O QP+ + + L NM O QP 1 4 1 120 1 16 10 5 ≈ T 1 24 T T T T T 1 1 3 1 3 5 ( ) [3 ( ) ( )] [ ( ) ( ) ( )] x x x x x x − + + × + + 1 120 16 10 5 ≈ 169 192 5 128 1 1920 T T T 1 3 5 ( ) ( ) ( ) x x x − + Truncated series is sin x ≈ 169 192 5 128 T T 1 3 ( ) ( ) x x − which is obtained by truncating the last term since 1 1920 = 0.00052 will pro- duce a change in the fourth decimal place only. Economized series is sin x ≈ 169 192 5 128 x − (4x3 – 3x) = 383 384 5 32 3 x x − = 0.9974x – 0.1526x3 which gives sin x to three significant digit accuracy. Example 6. Using the Chebyshev polynomials, obtain the least squares approximation of second degree for f(x) = x4 on [– 1, 1]. Sol. Let f(x) ≈ P(x) = C0T0(x) + C1T1(x) + C2T2(x) We have U(C0, C1, C2) = − z − 1 1 2 1 1 x (x4 – C0T0 – C1T1 – C2T2)2 dx which is to be minimum. Normal equations are given by ∂ ∂ U C0 = 0 ⇒ − z − − − − 1 1 4 2 1 ( ) x x dx C T C T C T T 0 0 1 1 2 2 0 = 0
  • 623. 610 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∂ ∂ U C1 = 0 ⇒ − z − − − − 1 1 4 2 1 ( ) x x dx C T C T C T T 0 0 1 1 2 2 1 = 0 and ∂ ∂ U C2 = 0 ⇒ − z − − − − 1 1 4 2 1 ( ) x x dx C T C T C T T 0 0 1 1 2 2 2 = 0 We find that C0 = 1 1 3 8 1 1 2 π − z − = x x dx 4 0 T C1 = 2 1 0 1 1 2 π − z − = x x dx 4 1 T C2 = 2 1 1 2 1 1 2 π − z − = x x dx 4 2 T Hence the required approximation is f(x) = 3 8 1 2 T T 0 2 + . Example 7. Find a uniform polynomial approximation of degree four or less to ex on [– 1, 1] using Lanczos economization with a tolerance of ε = 0.02. Sol. We have f(x) = ex = 1 + x + x x x x 2 3 4 5 2 6 24 120 + + + + ...... Since 1 120 0 008 = . ......, therefore ex = 1 + x + x x x 2 3 4 2 6 24 + + (82) with a tolerance of ε = 0.02. Changing each power of x in (82) in terms of Chebyshev polynomials, we get ex = T0 + T1 + 1 4 (T0 + T2) + 1 24 (3T1 + T3) + 1 192 (3T0 + 4T2 + T4) = 81 64 9 8 13 48 1 24 1 192 T T T T T 0 1 2 3 4 + + + + (83)
  • 624. STATISTICAL COMPUTATION 611 We have 1 192 = 0.005 ...... ∴ The magnitude of last term on R.H.S. of (83) is less than 0.02. Hence the required economized polynomial approximation for ex is given by ex = 81 64 9 8 13 48 1 24 T T T T 0 1 2 3 + + + or ex = x x x 3 2 6 13 24 191 192 + + + . Example 8. The function f is defined by f(x) = 1 x 1 e t dt 0 x t 2 2 z − − Approximate f by a polynomial P(x) = a + bx + cx2 such that max. x 1 | | ≤ | f(x) – P(x) | ≤ 5 × 10–3. Sol. The given function f(x) = 1 1 2 6 24 120 720 0 2 4 6 8 10 x t t t t t dt x z − + − + − + F HG I KJ ...... = 1 6 30 168 1080 7920 2 4 6 8 10 − + − + − + x x x x x ...... (84) The tolerable error is 5 × 10–3 ≈ 0.005. Truncating the series (84) at x8, we get P(x) = 1 6 30 168 1080 2 4 6 8 − + − + x x x x = T0 – 1 12 (T2 + T0) + 1 240 (T4 + 4T2 + 3T0) – 1 5376 (T6 + 6T4 + 15T2 + 10T0) + 1 138240 (T8 + 8T6 + 28T4 + 56T2 + 35T0)
  • 625. 612 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES = 0.92755973 T0 – 0.06905175 T2 + 0.003253 T4 – 0.000128 T6 + 0.000007 T8 (85) Truncating R.H.S. of (85) at T2, we obtain the required polynomial P(x) = 0.92755973 T0 – 0.06905175 T2 = 0.99661148 – 0.13810350x2 = 0.9966 – 0.1381x2 The maximum absolute error in the neglected terms is obviously less than the tolerable error. ASSIGNMENT 7.4 1. Express 1 + x – x2 + x3 as sum of Chebyshev polynomials. 2. Prove that x2 = 1 2 [T0(x) + T2(x)] 3. Express T0(x) + 2T1(x) + T2(x) as polynomials in x. 4. Obtain the best lower degree approximation to the cubic x3 + 2x2. 5. Explain how to fit a function of the form y = A A 1 2 e e x x λ λ 1 2 + to the given data. 6. Obtain y(1.5) from the following data using cubic spline. x: 1 2 3 y: – 8 – 1 18 7. Economize the series f(x) = 1 2 8 16 2 3 − − − x x x 8. Economize the series sinh x = x x x x + + + 3 5 7 6 120 5040 on the interval [– 1, 1] allowing for a tolerance of 0.0005. 9. Economize the series cos x = 1 2 24 720 2 4 6 − + − x x x . 10. Obtain the cubic spline approximation valid in [3, 4], for the function given in the tabu- lar form x: 1 2 3 4 f(x): 3 10 29 65 under the natural spline conditions: M(1) = 0 = M(4)
  • 626. STATISTICAL COMPUTATION 613 11. Obtain the cubic spline fit for the data x: 0 1 2 3 f(x): 1 4 10 8 under the end conditions f″(0) = 0 = f ″(3) and valid in the interval [1, 2]. Hence obtain the estimate of f(1.5). 12. Fit the following four points by the cubic splines: x: 1 2 3 4 y: 1 5 11 8 Use the end conditions y″(1) = 0 = y″(4). Hence compute y(1.5). 13. Find the natural cubic spline that fits the data x: 1 2 3 4 f(x): 0 1 0 0 14. Find whether the following functions are splines or not? (i) f(x) = − − − ≤ ≤ − + ≤ ≤ U V | W | x x x x x x 2 3 2 3 2 1 0 2 0 1 , , (ii) f(x) = − − − ≤ ≤ + ≤ ≤ U V | W | x x x x x x 2 3 2 3 2 1 0 2 0 1 , , [Hint: Check the continuity of f(x), f ′(x) and f″(x) at x = 0] 15. Find the values of α and β such that the function f(x) = x x x x x 2 1 1 2 3 2 3 − + ≤ ≤ − ≤ ≤ R S T U V W α β , , is a quadratic spline. [Hint: For f(x) to be continuous at x = 2, 5 – 2α = 6 – β and For f′(x) to be continuous at x = 2, 4 – α = 3] 16. We are given the following values of a function of the variable t: t: 0.1 0.2 0.3 0.4 f: 0.76 0.58 0.44 0.35 Obtain a least squares fit of the form f = ae–3t + be–2t. 17. Evaluate I = 1 1 0 1 + z x dx using the cubic spline method. 18. Explain approximation of function by Taylor series by taking suitable example.
  • 627. 614 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.47 REGRESSION ANALYSIS The term ‘regression’ was first used by Sir Francis Galton (1822–1911), a British biometrician in connection with the height of parents and their offspring. He found that the offspring of tall or short parents tend to regress to the average height. In other words, though tall fathers do tend to have tall sons, the average height of tall fathers is more than the average height of their sons and the average height of short fathers is less than the average height of their sons. The term ‘regression’ stands for some sort of functional relationship between two or more related variables. The only fundamental difference, if any, between problems of curve-fitting and regression is that in regression, any of the variables may be considered as independent or dependent while in curve-fitting, one variable cannot be dependent. Regression measures the nature and extent of correlation. Regression is the estimation or prediction of unknown values of one variable from known values of another variable. 7.48 CURVE OF REGRESSION AND REGRESSION EQUATION If two variates x and y are correlated, i.e., there exists an association or relationship between them, then the scatter diagram will be more or less concentrated round a curve. This curve is called the curve of regression and the relationship is said to be expressed by means of curvilinear regression. The mathematical equation of the regression curve is called regression equation. 7.49 LINEAR REGRESSION When the points of the scatter diagram concentrate round a straight line, the regression is called linear and this straight line is known as the line of regression. The regression will be called non-linear if there exists a relationship other than a straight line between the variables under consideration. 7.50 LINES OF REGRESSION A line of regression is the straight line which gives the best fit in the least square sense to the given frequency. In case of n pairs (xi, yi); i = 1, 2, ..., n from a bivariate data, we have no reason or justification to assume y as a dependent variable and x as an
  • 628. STATISTICAL COMPUTATION 615 independent variable. Either of the two may be estimated for the given values of the other. Thus, if we wish to estimate y for given values of x, we shall have the regression equation of the form y = a + bx, called the regression line of y on x. If we wish to estimate x for given values of y, we shall have the regression line of the form x = A + By, called the regression line of x on y. Thus it implies, in general, we always have two lines of regression. If the line of regression is so chosen that the sum of the squares of deviation parallel to the axis of y is minimized [See Figure (a)], it is called the line of regression of y on x and it gives the best estimate of y for any given value of x. If the line of regression is so chosen that the sum of the squares of deviations parallel to the axis of x is minimized [See Figure (b)], it is called the line of regression of x on y and it gives the best estimate of x for any given value of y. A B Y O X H(x , y ) i i P (x , y ) i i i A B Y O X H(x , y ) i i P (x , y ) i i i FIGURE (a) FIGURE (b) The independent variable is called the predictor or Regresser or Explanator and the dependent variable is called the predictant or Regressed or Explained variable. 7.51 DERIVATION OF LINES OF REGRESSION 7.51.1 Line of Regression of y on x To obtain the line of regression of y on x, we shall assume y as dependent variable and x as independent variable. Let y = a + bx be the equation of regression line of y on x. The residual for ith point is Ei = yi – a – bxi. Introduce a new quantity U such that U = Ei i n 2 1 = ∑ = ( ) y a bx i i i n − − = ∑ 2 1 (86)
  • 629. 616 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES According to the principle of Least squares, the constants a and b are chosen in such a way that the sum of the squares of residuals is minimum. Now, the condition for U to be maximum or minimum is ∂ ∂ U a = 0 and ∂ ∂ U b = 0 From (86), ∂ ∂ U a i n = = ∑ 2 1 (yi – a – bxi)(– 1) ∂ ∂ U a = 0 gives 2 i n = ∑ 1 (yi – a – bxi)(– 1) = 0 ⇒ Σy = na + b Σx (87) Also, ∂ ∂ U b y a bx x i n i i i = − − − = ∑ 2 1 ( )( ) ∂ ∂ U b = 0 gives 2 i n = ∑ 1 (yi – a – bxi)(– xi) = 0 ⇒ Σxy = a Σx + b Σx2 (88) Equations (87) and (88) are called normal equations. Solving (87) and (88) for ‘a’ and ‘b’, we get b = Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ xy n x y x n x n xy x y n x x − − = − − 1 1 2 2 2 2 ( ) ( ) (89) and a = Σ Σ y n b x n y bx − = − (90) Eqn. (90) gives y a bx = + Hence y = a + bx line passes through point ( , ) x y . Putting a = y bx − in equation of line y = a + bx, we get y – y b x x = − ( ) (91) Equation (91) is called regression line of y on x. ‘b’ is called the regression coefficient of y on x and is usually denoted by byx.
  • 630. STATISTICAL COMPUTATION 617 Hence eqn. (91) can be rewritten as y – y b x x yx = − ( ) where x y and are mean values while byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) In equation (88), shifting the origin to ( , ) x y , we get Σ(x – x )(y – y) = a Σ(x – x ) + b(x – x )2 ⇒ nr σxσy = a(0) + bnσx 2 ∵ Σ Σ Σ ( ) ( ) ( )( ) x x n x x x x y y n r x x y − = − = − − = 0 1 2 2 σ σ σ and ⇒ b = r σ σ y x Hence regression coefficient byx can also be defined as byx = r σ σ y x where r is the coefficient of correlation, σx and σy are the standard deviations of x and y series respectively. 7.51.2 Line of Regression of x on y Proceeding in the same way as 7.16.1, we can derive the regression line of x on y as x – x = bxy(y – y) where bxy is the regression coefficient of x on y and is given by bxy = n xy x y n y y Σ Σ Σ Σ Σ − − 2 2 ( ) or bxy = r σ σ x y where the terms have their usual meanings.
  • 631. 618 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES If r = 0, the two lines of regression become y = y and x = x which are two straight lines parallel to x and y axes respectively and passing through their means y and x . They are mutually perpendicular. If r = ± 1, the two lines of regression will coincide. 7.52 USE OF REGRESSION ANALYSIS (i) In the field of Business, this tool of statistical analysis is widely used. Businessmen are interested in predicting future production, consumption, investment, prices, profits and sales etc. (ii) In the field of economic planning and sociological studies, projections of population, birth rates, death rates and other similar variables are of great use. 7.53 COMPARISON OF CORRELATION AND REGRESSION ANALYSIS Both the correlation and regression analysis helps us in studying the relation- ship between two variables yet they differ in their approach and objectives. (i) Correlation studies are meant for studying the covariation of the two variables. They tell us whether the variables under study move in the same direction or in reverse directions. The degree of their covariation is also reflected in the correlation co-efficient but the correlation study does not provide the nature of relationship. It does not tell us about the relative movement in the variables and we cannot predict the value of one variable corresponding to the value of other variable. This is possible through regression analysis. (ii) Regression presumes one variable as a cause and the other as its effect. The independent variable is supposed to be affecting the dependent variable and as such we can estimate the values of the dependent variable by projecting the relationship between them. However, correlation between two series is not necessarily a cause-effect relationship. (iii) Coefficient of correlation cannot exceed unity but one of the regression coefficients can have a value higher than unity but the product of two regression coefficients can never exceed unity. NOTE
  • 632. STATISTICAL COMPUTATION 619 7.54 PROPERTIES OF REGRESSION CO-EFFICIENTS Property I. Correlation co-efficient is the geometric mean between the regression co-efficients. Proof. The co-efficients of regression are r r y x x y σ σ σ σ and . Geometric mean between them = r r r y x x y σ σ σ σ × = 2 = r = co-efficient of correlation. Property II. If one of the regression co-efficients is greater than unity, the other must be less than unity. Proof. The two regression co-efficients are byx = r b r y x xy x y σ σ σ σ and = . Let byx 1, then 1 1 byx (92) Since byx. bxy = r2 ≤ 1 (∵ – 1 ≤ r ≤ 1) ∴ bxy ≤ 1 1 byx . | using (92) Similarly, if bxy 1, then byx 1. Property III. Arithmetic mean of regression co-efficients is greater than the correlation co-efficient. Proof. We have to prove that b b yx xy + 2 r or r r y x x y σ σ σ σ + 2r or σx 2 + σy 2 2σxσy or (σx – σy)2 0 which is true. Property IV. Regression co-efficients are independent of the origin but not of scale. Proof. Let u = x a h v y b k – , = − , where a, b, h and k are constants byx = r r k h k h r k h b y x v u v u vu σ σ σ σ σ σ = = F HG I KJ = .
  • 633. 620 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Similarly, bxy = h k buv. Thus, byx and bxy are both independent of a and b but not of h and k. Property V. The correlation co-efficient and the two regression co- efficients have same sign. Proof. Regression co-efficient of y on x = byx = r σ σ y x Regression co-efficient of x on y = bxy = r σ σ x y Since σx and σy are both positive; byx, bxy and r have same sign. 7.55 ANGLE BETWEEN TWO LINES OF REGRESSION If θ is the acute angle between the two regression lines in the case of two variables x and y, show that tan θ = 1 r r 2 x y x 2 y 2 − + . σ σ σ σ , where r, σx, σy have their usual meanings. Explain the significance of the formula when r = 0 and r = ± 1. Proof. Equations to the lines of regression of y on x and x on y are y y r x x y x − = − σ σ ( ) and x x r y y x y − = − σ σ ( ) Their slopes are m1 = r y x σ σ and m2 = σ σ y x r . ∴ tan θ = ± m m m m r r y x y x y x 2 1 2 1 2 2 1 1 − + = ± − + σ σ σ σ σ σ = ± 1 1 2 2 2 2 2 2 2 − + = ± − + r r r r y x x x y x y x y . . . σ σ σ σ σ σ σ σ σ Since r2 ≤ 1 and σx, σy are positive. ∴ +ve sign gives the acute angle between the lines.
  • 634. STATISTICAL COMPUTATION 621 Hence tan θ = 1 2 2 2 − + r r x y x y . σ σ σ σ when r = 0, θ = π 2 ∴ The two lines of regression are perpendicular to each other. Hence the estimated value of y is the same for all values of x and vice- versa. When r = ± 1, tan θ = 0 so that θ = 0 or π Hence the lines of regression coincide and there is perfect correlation between the two variates x and y. 7.56 ALGORITHM FOR LINEAR REGRESSION 1. Read n 2. sum x ← 0 3. sum xsq ← 0 4. sum y ← 0 5. sum xy ← 0 6. for i = 1 to n do 7. Read x,y 8. sum x ← sum x + x 9. sum xsq ← sum xsq + x2 10. sum y ← sum y + y 11. sum xy ← sum xy + x × y end for 12. denom ← n × sum x sq - sum x × sum x 13. a ← (sum y × sum x sq - sum x × sum xy)/denom 14. b ← (n × sum xy - sum x × sum y)/denom 15. Write b,a 16. Stop
  • 635. 622 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.57 PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A REGRESSION LINE OF Y ON X #includestdio.h #includeconio.h #includemath.h void main() { int data,i; float x[10],y[10],xy[10],x2[10],z; float sum1=0.0,sum2=0.0,sum3=0.0,sum4=0.0; clrscr(); printf(Enter the number of data points:); scanf(%d,data); printf(Enter the value of x: n); for(i=0;idata;i++) { printf(Value of x%d:,i+1); scanf(%f,x[i]); } printf{nEnter the value of f(x):n}; for(i=0;idata;i++) { printf(Value of f(x%d):,i+1); scanf(%f,y[i]); } for(i=0;idata;i++) } xy[i]=x[i]*y[i]; x2[i]=x[i]*x[i]; sum1 +=xy[i]; sum2 +=x2[i]; sum3 +=x[i]; sum4 +=y[i]; }
  • 636. STATISTICAL COMPUTATION 623 sum3 =sum3/2; sum4 =sum4/2; //printf(%.2f %.2f %.2f, %.2f sum1,sum2,sum3,sum4); sum1=(sum1/sum2); z=(sum1*sum3)-sum4; printf(nnThe REGRESSION LINE OF Y on X is:n); printf(ttt y=%.2f *x - (%.2f),sum1,z); getch(1); } 7.58 PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A REGRESSION LINE OF X ON Y #includestdio.h #includeconio.h #includemath.h void main() { int data,i; float x[10],y[10],xy[10],y2[10],z; float sumx=0.0,sumy=0.0,sumxy=0.0,sumy2=0.0; clrscr(); printf(Enter the number of data points: ); scanf(%d,data); printf(Enter the value of x: n); for(i=0;idata;i++) { printf(Value of x%d: ,i+1); scanf(%f,x[i]); } printf(nEnter the value of f(x): n); for(i=0;idata; i++) { printf(Value of f(x%d):, i+1); scanf(%f,y[i]); }
  • 637. 624 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES for(i=0;idata;i++) { xy[i]=x[i]*y[i]; y2[i]=y[i]*y[i]; sumxy +=xy[i]; sumy2 +=y2[i]; sumx +=x[i]; sumy +=y[i]; } sumx =sumx/2; sumy =sumy/2; sumxy=(sumxy/sumy2); z=(sumxy*sumy)-sumx; printf(nnThe REGRESSION LINE OF X on Y is:n); printf(ttt x = %.2f *y - (%.2f),sumxy, z); getch(); } EXAMPLES Example 1. If the regression coefficients are 0.8 and 0.2, what would be the value of coefficient of correlation? Sol. We know that, r2 = byx . bxy = 0.8 × 0.2 = 0.16 Since r has the same sign as both the regression coefficients byx and bxy Hence r = 0.16 = 0.4. Example 2. Calculate linear regression coefficients from the following: x → 1 2 3 4 5 6 7 8 y → 3 7 10 12 14 17 20 24 Sol. Linear regression coefficients are given by byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) and bxy = n xy x y n y y Σ Σ Σ Σ Σ − − 2 2 ( )
  • 638. STATISTICAL COMPUTATION 625 Let us prepare the following table: x y x2 y2 xy 1 3 1 9 3 2 7 4 49 14 3 10 9 100 30 4 12 16 144 48 5 14 25 196 70 6 17 36 289 102 7 20 49 400 140 8 24 64 576 192 Σx = 36 Σy = 107 Σx2 = 204 Σy2 = 1763 Σxy = 599 Here n = 8 ∴ byx = ( ) ( ) ( ) ( ) 8 599 36 107 8 204 36 2 × − × × − = 4792 3852 1632 1296 940 336 − − = = 2.7976 and bxy = ( ) ( ) ( ) ( ) 8 599 36 107 8 1763 107 940 2655 2 × − × × − = = 0.3540 Example 3. The following table gives age (x) in years of cars and annual maintenance cost (y) in hundred rupees: x: 1 3 5 7 9 y: 15 18 21 23 22 Estimate the maintenance cost for a 4 year old car after finding the regression equation. Sol. x y xy x2 1 15 15 1 3 18 54 9 5 21 105 25 7 23 161 49 9 22 198 81 Σx = 25 Σy = 99 Σxy = 533 Σx2 = 165
  • 639. 626 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Here, n = 5 x x n = = Σ 25 5 = 5 y y n = = Σ 99 5 = 19.8 ∴ byx = n xy x y n x x Σ Σ Σ Σ Σ − − = × − × × − 2 2 2 5 533 25 99 5 165 25 ( ) ( ) ( ) ( ) ( ) = 0.95 Regression line of y on x is given by y y b x x yx − = − ( ) ⇒ y – 19.8 = 0.95 (x – 5) ⇒ y = 0.95x + 15.05 When x = 4 years, y = (0.95 × 4) + 15.05 = 18.85 hundred rupees = Rs. 1885. Example 4. In a partially destroyed laboratory record of an analysis of a correlation data, the following results only are eligible: Variance of x = 9 Regression equations: 8x – 10y + 66 = 0, 40x – 18y = 214. What were (a) the mean values of x and y (b) the standard deviation of y and the co-efficient of correlation between x and y. Sol. (a) Since both lines of regression pass through the point ( , ) x y therefore, we have 8 10 66 0 x y − + = (93) 40 18 214 0 x y − − = (94) Multiplying (93) by 5, 40 50 330 0 x y − + = (95) Subtracting (95) from (94), 32 544 0 y − = ∴ y = 17 ∴ From (93), 8x – 170 + 66 = 0 or 8x = 104 ∴ x = 13 Hence x = 13, y = 17 (b) Variance of x = σx 2 = 9 (given) ∴ σx = 3
  • 640. STATISTICAL COMPUTATION 627 The equations of lines of regression can be written as y = .8x + 6.6 and x = .45y + 5.35 ∴ The regression co-efficient of y on x is r y x σ σ = .8 (96) The regression co-efficient of x on y is r x y σ σ = .45 (97) Multiplying (96) and (97), r2 = .8 × .45 = .36 ∴ r = 0.6 (+ve sign with square root is taken because regression co-efficients are +ve). From (96), σy = .8 .8 3 0.6 σx r = × = 4. Example 5. The regression lines of y on x and x on y are respectively y = ax + b, x = cy + d. Show that σ σ y x a c = , x bc d 1 ac and y ad b 1 ac = + − = + − . Sol. The regression line of y on x is y = ax + b (98) ∴ byx = a The regression line of x on y is x = cy + d (99) ∴ bxy = c We know that, byx = r σ σ y x (100) and bxy = r σ σ x y (101) Dividing eqn. (100) by (101), we get b b yx xy y x = σ σ 2 2 ⇒ a c a c y x y x = ⇒ = σ σ σ σ 2 2 Since both the regression lines pass through the point ( , ) x y therefore, y ax b = + and x cy d = + ⇒ ax y b − = − (102) x cy d − = (103)
  • 641. 628 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Multiplying equation (103) by a and then subtracting from (102), we get (ac – 1) y ad b = − − ⇒ y ad b ac = + − 1 Similarly, we get x bc d ac = + − 1 . Example 6. For two random variables, x and y with the same mean, the two regression equations are y = ax + b and x = αy + β Show that b 1 a 1 β α = − − . Find also the common mean. Sol. Here, byx = a, bxy = α Let the common mean be m, then regression lines are y – m = a (x – m) ⇒ y = ax + m (1 – a) (104) and x – m = α(y – m) ⇒ x = αy + m (1 – α) (105) Comparing (104) and (105) with the given equations. b = m (1 – a), β = m (1 – α) ∴ b a β α = − − 1 1 Again m = b a 1 1 − = − β α Since regression lines pass through ( , ) x y ∴ x y = + α β and y ax b = + will hold. ⇒ m = am + b m = αm + β ⇒ am + b = αm + β ⇒ m = β α − − b a .
  • 642. STATISTICAL COMPUTATION 629 Example 7. Obtain the line of regression of y on x for the data given below: x: 1.53 1.78 2.60 2.95 3.42 y: 33.50 36.30 40.00 45.80 53.50. Sol. The line of regression of y on x is given by y – y b x x yx = − ( ) (106) where byx is the coefficient of regression given by byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) Now we form the table as, x y x2 xy 1.53 33.50 2.3409 51.255 1.78 36.30 2.1684 64.614 2.60 40.00 6.76 104 2.95 45.80 8.7025 135.11 3.42 53.50 11.6964 182.97 Σx = 12.28 Σy = 209.1 Σx2 = 32.6682 Σxy = 537.949 Here, n = 5 byx = ( ) ( ) ( ) ( ) 5 537.949 12.28 209.1 5 32.6682 12.28 121.997 12.543 2 × − × × − = = 9.726 Also, mean x x n = = Σ 12.28 5 = 2.456 and y y n = = Σ 2091 . 5 = 41.82 ∴ From (106), we get y – 41.82 = 9.726(x – 2.456) = 9.726x – 23.887 y = 17.932 + 9.726x which is the required line of regression of y on x. Example 8. For 10 observations on price (x) and supply (y), the following data were obtained (in appropriate units): Σx = 130, Σy = 220, Σx2 = 2288, Σy2 = 5506 and Σxy = 3467 Obtain the two lines of regression and estimate the supply when the price is 16 units.
  • 643. 630 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. Here, n = 10, x x n = Σ = 13 and y y n = Σ = 22 Regression coefficient of y on x is byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) = ( ) ( ) ( ) ( ) 10 3467 130 220 10 2288 130 2 × − × × − = 34670 28600 22880 16900 6070 5980 − − = = 1.015 ∴ Regression line of y on x is y – y b x x yx = − ( ) y – 22 = 1.015(x – 13) ⇒ y = 1.015x + 8.805 Regression coefficient of x on y is bxy = n xy x y n y y Σ Σ Σ Σ Σ − − 2 2 ( ) = ( ) ( ) ( ) ( ) 10 3467 130 220 10 5506 220 6070 6660 2 × − × × − = = 0.9114 Regression line of x on y is x – x b y y xy = − ( ) x – 13 = 0.9114(y – 22) x = 0.9114y – 7.0508 Since we are to estimate supply (y) when price (x) is given therefore we are to use regression line of y on x here. When x = 16 units, y = 1.015(16) + 8.805 = 25.045 units. Example 9. The following results were obtained from records of age (x) and systolic blood pressure (y) of a group of 10 men: x y Mean 53 142 Variance 130 165 and Σ(x – x )(y – y) = 1220 Find the approximate regression equation and use it to estimate the blood pressure of a man whose age is 45.
  • 644. STATISTICAL COMPUTATION 631 Sol. Given: Mean x = 53 Mean y = 142 Variance σx 2 = 130 Variance σy 2 = 165 Number of men, n = 10 Σ(x – x )(y – y) = 1220 ∴ Coefficient of correlation, r = Σ( )( ) x x y y n x y − − σ σ = 1220 10 130 165 × = 122 146 458 . = 0.83. Since we are to estimate blood pressure (y) of a 45 years old man, we will find regression line of y on x. Regression coefficient byx = r σ σ y x = × 0 83 165 130 . = 0.935. Regression line of y on x is given by y – y b x x yx = − ( ) ⇒ y – 142 = 0.935(x – 53) = 0.935x – 49.555 ⇒ y = 0.935x + 92.445 when x = 45, y = (0.935 × 45) + 92.445 = 134.52. Hence the required blood pressure = 134.52. Example 10. The following results were obtained from scores in Applied Mechanics and Engineering Mathematics in an examination: Applied Mechanics (x) Engineering Mathematics (y) Mean 47.5 39.5 Standard Deviation 16.8 10.8 r = 0.95. Find both the regression equations. Also estimate the value of y for x = 30. Sol. x = 47.5, y = 39.5 σx = 16.8, σy = 10.8 and r = 0.95.
  • 645. 632 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Regression coefficients are byx = r σ σ y x = × 0 95 10 8 16 8 . . . = 0.6107 and bxy = r σ σ x y = × 0 95 16 8 10 8 . . . = 1.477. Regression line of y on x is y – y b x x yx = − ( ) ⇒ y – 39.5 = 0.6107 (x – 47.5) = 0.6107x – 29.008 y = 0.6107x + 10.49 (107) Regression line of x on y is x – x b y y xy = − ( ) ⇒ x – 47.5 = 1.477 (y – 39.5) ⇒ x – 47.5 = 1.477y – 58.3415 x = 1.477y – 10.8415 Putting x = 30 in equation (107), we get y = (0.6107)(30) + 10.49 = 18.321 + 10.49 = 28.81. Example 11. From the following data. Find the most likely value of y when x = 24: y x Mean 985.8 18.1 S.D. 36.4 2.0 r = 0.58. Sol. Given: y = 985.8, x = 18.1, σy = 36.4, σx = 2, r = 0.58 Regression coefficient, byx = r σ σ y x = (0.58) 36 4 2 . = 10.556. Regression line of y on x is y – y = byx(x – x ) ⇒ y – 985.8 = 10.556(x – 18.1) y – 985.8 = 10.556x – 191.06
  • 646. STATISTICAL COMPUTATION 633 ⇒ y = 10.556x + 794.73 when x = 24, y = (10.556 × 24) + 794.73 y = 1048 (approximately). Example 12. The equations of two regression lines, obtained in a correlation analysis of 60 observations are: 5x = 6y + 24 and 1000y = 768x – 3608. What is the correlation coefficient? Show that the ratio of coefficient of variability of x to that of y is 5 24 . What is the ratio of variances of x and y? Sol. Regression line of x on y is 5x = 6y + 24 x = 6 5 24 5 y + ∴ bxy = 6 5 (108) Regression line of y on x is 1000y = 768x – 3608 y = 0.768x – 3.608 ∴ byx = 0.768 (109) From (108), r σ σ x y = 6 5 (110) From (109), r σ σ y x = 0.768 (111) Multiplying equations (110) and (111), we get r2 = 0.9216 ⇒ r = 0.96 (112) Dividing (111) by (110), we get σ σ x y 2 2 6 5 0 768 = × . = 1.5625. Taking the square root, we get σ σ x y = = 125 5 4 . (113)
  • 647. 634 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since the regression lines pass through the point (x y , ), we have 5 6 x y = + 24 1000 y x = 768 – 3608. Solving the above equations for x and y, we get x = 6, y = 1. Coefficient of variability of x = σx x , Coefficient of variability of y = σy y . ∴ Required ratio = σ σ x y x y × = y x x y σ σ F HG I KJ = 1 6 5 4 × = 5 24 . | using (113) Example 13. The following data regarding the heights (y) and weights (x) of 100 college students are given: Σx = 15000, Σx2 = 2272500, Σy = 6800, Σy2 = 463025 and Σxy = 1022250. Find the equation of the regression line of height on weight. Sol. x x n = = Σ 15000 100 = 150 y y n = = Σ 6800 100 = 68 Regression coefficient of y on x, byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) = ( ) ( ) ( ) ( ) 100 1022250 15000 6800 100 2272500 15000 2 × − × × − = 102225000 102000000 227250000 225000000 − − = 225000 2250000 = 0.1 Regression line of height (y) on weight (x) is given by y – y b x x yx = − ( ) ⇒ y – 68 = 0.1(x – 150) ⇒ y = 0.1x – 15 + 68 ⇒ y = 0.1x + 53.
  • 648. STATISTICAL COMPUTATION 635 Example 14. Find the coefficient of correlation when the two regression equations are X = – 0.2Y + 4.2 Y = – 0.8X + 8.4. Sol. We have the regression lines X = – 0.2Y + 4.2 (114) Y = – 0.8X + 8.4. (115) Let us assume that eqn. (114) is the regression line of X on Y and eqn. (115) is the regression line of Y on X then, Regression coefficient of X on Y is bXY = – 0.2 Regression coefficient of Y on X is bYX = – 0.8 Since bXY and bYX are of the same sign and bXYbYX = 0.16 ( 1) hence our assumption is correct. We know that bXY bYX = r2 | where r is the correlation coefficient ⇒ (– 0.2)(– 0.8) = r2 ⇒ r2 = 0.16 ⇒ r = – 0.4. | Since r, σx and σy have the same sign Example 15. A panel of two judges, A and B, graded seven TV serial performances by awarding scores independently as shown in the following table: Performance 1 2 3 4 5 6 7 Scores by A 46 42 44 40 43 41 45 Scores by B 40 38 36 35 39 37 41 The eighth TV performance, which judge B could not attend, was awarded 37 scores by judge A. If judge B had also been present, how many scores would be expected to have been awarded by him to the eighth TV performance? Use regression analysis to answer this question. Sol. Let the scores awarded by judge A be denoted by x and the scores awarded by judge B be denoted by y.
  • 649. 636 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Here, n = 7; x x n = = + + + + + + Σ 46 42 44 40 43 41 45 7 = 43 y y n = = + + + + + + Σ 40 38 36 35 39 37 41 7 = 38 Let us form the table as x y xy x2 46 40 1840 2116 42 38 1596 1764 44 36 1584 1936 40 35 1400 1600 43 39 1677 1849 41 37 1517 1681 45 41 1845 2025 Σx = 301 Σy = 266 Σxy = 11459 Σx2 = 12971 Regression coefficient, byx = n xy x y n x x Σ Σ Σ Σ Σ − − 2 2 ( ) = ( ) ( ) ( ) ( ) 7 11459 301 266 7 12971 301 2 × − × × − = 80213 80066 90797 90601 147 196 − − = = 0.75 Regression line of y on x is given by y – y b x x yx = − ( ) y – 38 = 0.75(x – 43) ⇒ y = 0.75x + 5.75 when x = 37, y = 0.75(37) + 5.75 = 33.5 marks Hence, if judge B had also been present, 33.5 scores would be expected to have been awarded to the eighth T.V. performance. ASSIGNMENT 7.5 1. Find the regression line of y on x from the following data: x: 1 2 3 4 5 y: 2 5 3 8 7
  • 650. STATISTICAL COMPUTATION 637 2. In a study between the amount of rainfall and the quantity of air pollution removed the following data were collected: Daily rainfall: 4.3 4.5 5.9 5.6 6.1 5.2 3.8 2.1 (in .01 cm) Pollution removed: 12.6 12.1 11.6 11.8 11.4 11.8 13.2 14.1 (mg/m3) Find the regression line of y on x. 3. If F is the pull required to lift a load W by means of a pulley block, fit a linear law of the form F = mW + c connecting F and W, using the data W: 50 70 100 120 F: 12 15 21 25 where F and W are in kg wt. Compute F when W = 150 kg wt. 4. The two regression equations of the variables x and y are x = 19.13 – 0.87 y and y = 11.64 – 0.50 x. Find (i) mean of x’s (ii) mean of y’s and (iii) correlation coefficient between x and y. 5. Two random variables have the regression lines with equations 3x + 2y = 26 and 6x + y = 31. Find the mean values and the correlation coefficient between x and y. 6. In a partially destroyed laboratory data, only the equations giving the two lines of re- gression of y on x and x on y are available and are respectively 7x – 16y + 9 = 0 5y – 4x – 3 = 0 Calculate the coefficient of correlation, x and y . 7. A simply supported beam carries a concentrated load P (kg) at its mid-point. The follow- ing table gives maximum deflection y (cm) corresponding to various values of P: P: 100 120 140 160 180 200 y: 0.45 0.55 0.60 0.70 0.80 0.85 Find a law of the form y = a + bP. Also find the value of maximum deflection when P = 150 kg. 8. If a1x + b1y + c1 = 0 and a2x + b2y + c2 = 0 are the equations of the regression lines of y on x and x on y respectively, prove that a1b2 ≤ a2b1 given that the constants a1, a2, b1, b2 are either all positive or all negative. 9. The regression equations calculated from a given set of observations for two random variables are x = – 0.4y + 6.4 and y = – 0.6x + 4.6 Calculate (i) x (ii) y (iii) r.
  • 651. 638 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 10. The following regression equations were obtained from a correlation table: y = 0.516x + 33.73 x = 0.512y + 32.52 Find the value of (i) r (ii) x (iii) y . 11. Find the regression line of y on x for the following data: x: 1 3 4 6 8 9 11 14 y: 1 2 4 4 5 7 8 9. 12. Given N = 50, Mean of y = 44 Variance of x is 9 16 of the variance of y. Regression equation of x on y is 3y – 5x = – 180 Find (i) Mean of x (ii) Coefficient of correlation between x and y. 13. For an army personnel of strength 25, the regression of weight of kidneys (y) on weight of heart (x), both measured in ounces is y – 0.399x – 6.934 = 0 and the regression of weight of heart on weight of kidney is x – 1.212y + 2.461 = 0. Find the correlation coefficient between x and y and their mean values. Can you find out the standard deviation of x and y as well? 14. A panel of judges A and B graded 7 debators and independently awarded the following scores: Debator: 1 2 3 4 5 6 7 Scores by A: 40 34 28 30 44 38 31 Scores by B: 32 39 26 30 38 34 28 An eighth debator was awarded 36 scores by judge A while judge B was not present. If judge B were also present, how many scores would you expect him to award to the eighth debator assuming that the same degree of relationship exists in their judgement. 15. The following results were obtained in the analysis of data on yield of dry bark in ounces (y) and age in years (x) of 200 cinchona plants: x y Average: 9.2 16.5 Standard deviation: 2.1 4.2 Correlation coefficient = 0.84 Construct the two lines of regression and estimate the yield of dry bark of a plant of age 8 years. 16. Given that x = 4y + 5 and y = kx + 4 are the lines of regression of x on y and y on x respectively. Show that 0 ≤ 4k ≤ 1. If k = 1 16 , find x , y and coefficient of correlation between x and y.
  • 652. STATISTICAL COMPUTATION 639 17. The means of a bivariate frequency distribution are at (3, 4) and r = 0.4. The line of regression of y on x is parallel to the line y = x. Find the two lines of regression and estimate value of x when y = 1. 18. Assuming that we conduct an experiment with 8 fields planted with corn, four fields having no nitrogen fertilizer and four fields having 80 kgs of nitrogen fertilizer. The resulting corn yields are shown in table in bushels per acre: Field: 1 2 3 4 5 6 7 8 Nitrogen (kgs) x: 0 0 0 0 80 80 80 80 Corn yield y: 120 360 60 180 1280 1120 1120 760 (acre) (a) Compute a linear regression equation of y on x. (b) Predict corn yield for a field treated with 60 kgs of fertilizer. 19. Find both the lines of regression of following data: x: 5.60 5.65 5.70 5.81 5.85 y: 5.80 5.70 5.80 5.79 6.01 20. Obtain regression line of x on y for the given data: x: 1 2 3 4 5 6 y: 5.0 8.1 10.6 13.1 16.2 20.0 7.59 POLYNOMIAL FIT: NON-LINEAR REGRESSION Let y = a + bx + cx2 be a second degree parabolic curve of regression of y on x to be fitted for the data (xi, yi), i = 1, 2, ......, n. Residual at x = xi is Ei = yi – f(xi) = yi – a – bxi – cxi 2 Now, let U = i n i i n = = ∑ ∑ = 1 2 1 E (yi – a – bxi – cxi 2)2 By principle of Least squares, U should be minimum for the best values of a, b and c. For this, ∂ ∂ U a = 0, ∂ ∂ U b = 0 and ∂ ∂ U c = 0 ∂ ∂ U a = 0 ⇒ 2 1 i n = ∑ (yi – a – bxi – cxi 2) (– 1) = 0 ⇒ Σy = na + bΣx + cΣx2 (116)
  • 653. 640 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∂ ∂ U b = 0 ⇒ 2 1 i n = ∑ (yi – a – bxi – cxi 2) (– xi) = 0 ⇒ Σxy = aΣx + bΣx2 + cΣx3 (117) ∂ ∂ U c = 0 ⇒ 2 1 i n = ∑ (yi – a – bxi – cxi 2) (– xi 2) = 0 ⇒ Σx2y = aΣx2 + bΣx3 + cΣx4 (118) Equations (116), (117) and (118) are the normal equations for fitting a second degree parabolic curve of regression of y on x. Here n is the number of pairs of values of x and y. EXAMPLES Example 1. (a) Fit a second degree parabola to the following data: x: 0.0 1.0 2.0 y: 1.0 6.0 17.0 (b) Fit a second degree curve of regression of y on x to the following data: x: 1.0 2.0 3.0 4.0 y: 6.0 11.0 18.0 27 (c) Fit a second degree parabola in the following data: x: 0.0 1.0 2.0 3.0 4.0 y: 1.0 4.0 10.0 17.0 30.0 Sol. The equation of second degree parabola is given by y = a + bx + cx2 (119) Normal equations are Σy = ma + bΣx + cΣx2 (120) Σxy = aΣx + bΣx2 + cΣx3 (121) and Σx2y = aΣx2 + bΣx3 + cΣx4 (122)
  • 654. STATISTICAL COMPUTATION 641 (a) Here m = 3 The table is as follows: x y x2 x3 x4 xy x2y 0 1 0 0 0 0 0 1 6 1 1 1 6 6 2 17 4 8 16 34 68 Total 24 5 9 17 40 74 Substituting in eqns. (120), (121) and (122), we get 24 = 3a + 3b + 5c (123) 40 = 3a + 5b + 9c (124) 74 = 5a + 9b + 17c (125) Solving eqns. (123), (124) and (125), we get a = 1, b = 2, c = 3 Hence the required second degree parabola is y = 1 + 2x + 3x2 (b) Here m = 4 The table is as follows: x y x2 x3 x4 xy x2y 1 6 1 1 1 6 6 2 11 4 8 16 22 44 3 18 9 27 81 54 162 4 27 16 64 256 108 432 Σx = 10 Σy = 62 Σx2 = 30 Σx3 = 100 Σx4 = 354 Σxy = 190 Σx2y = 644 Substituting values in eqns. (120), (121) and (122), we get 62 = 4a + 10b + 30c (126) 190 = 10a + 30b + 100c (127) 644 = 30a + 100b + 354c (128) Solving equations (126), (127) and (128), we get a = 3, b = 2, c = 1
  • 655. 642 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Hence the required second degree parabola is y = 3 + 2x + x2 (c) Here m = 5 The table is as follows: x y x2 x3 x4 xy x2y 0.0 1.0 0 0 0 0 0 1.0 4.0 1 1 1 4 4 2.0 10.0 4 8 16 20 40 3.0 17.0 9 27 81 51 153 4.0 30.0 16 64 256 120 480 Σx = 10 Σy = 62 Σx2 = 30 Σx3 = 100 Σx4 = 354 Σxy = 195 Σx2y = 677 Substituting values in eqns. (120), (121) and (122), we get 62 = 5a + 10b + 30c (129) 195 = 10a + 30b + 100c (130) 677 = 30a + 100b + 354c (131) Solving eqns. (129), (130) and (131), we get a = 1.2, b = 1.1 and c = 1.5 Hence the required second degree parabola is y = 1.2 + 1.1x + 1.5x2 Example 2. Fit a parabola y = ax2 + bx + c in least square sense to the data x: 10 12 15 23 20 y: 14 17 23 25 21. Sol. The normal equations to the curve are and Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ y a x b x c xy a x b x c x x y a x b x c x = + + = + + = + + U V | W | 2 3 2 2 4 3 2 5 (132)
  • 656. STATISTICAL COMPUTATION 643 The values of Σx, Σx2,...... etc., are calculated by means of the following table: x y x2 x3 x4 xy x2y 10 14 100 1000 10000 140 1400 12 17 144 1728 20736 204 2448 15 23 225 3375 50625 345 5175 23 25 529 12167 279841 575 13225 20 21 400 8000 160000 420 8400 Σx = 80 Σy = 100 Σx2 = 1398 Σx3 = 26270 Σx4 = 521202 Σxy = 1684 Σx2y = 30648 Substituting the obtained values from the table in normal equation (132), we have 100 = 1398a + 80b + 5c 1684 = 26270a + 1398b + 80c 30648 = 521202a + 26270b + 1398c On solving, a = – 0.07, b = 3.03, c = – 8.89 ∴ The required equation is y = – 0.07x2 + 3.03x – 8.89. Example 3. Fit a parabolic curve of regression of y on x to the following data: x: 1.0 1.5 2.0 2.5 3.0 3.5 4.0 y: 1.1 1.3 1.6 2.0 2.7 3.4 4.1 Sol. Here m = 7 (odd) Let u = x − 2.5 0.5 = 2x – 5 and v = y The results in tabular form are: x y u v u2 uv u2v u3 u4 1.0 1.1 – 3 1.1 9 – 3.3 9.9 – 27 81 1.5 1.3 – 2 1.3 4 – 2.6 5.2 – 8 16 2.0 1.6 – 1 1.6 1 – 1.6 1.6 – 1 1 2.5 2.0 0 2.0 0 0 0 0 0 3.0 2.7 1 2.7 1 2.7 2.7 1 1 3.5 3.4 2 3.4 4 6.8 13.6 8 16 4.0 4.1 3 4.1 9 12.3 36.9 27 81 Total 0 16.2 28 14.3 69.9 0 196
  • 657. 644 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Let the curve to be fitted be v = a + bu + cu2 so that the normal equations are Σv = 7a + bΣu + cΣu2 Σuv = aΣu + bΣu2 + cΣu3 and Σu2v = aΣu2 + bΣu3 + cΣu4 ⇒ 16.2 = 7a + 28c, 14.3 = 28b, 69.9 = 28a + 196c Solving, we get a = 2.07, b = 0.511, c = 0.061 Hence the curve of fit is v = 2.07 + 0.511u + 0.061u2 ⇒ y = 2.07 + 0.511 (2x – 5) + 0.061 (2x – 5)2 = 1.04 – 0.193x + 0.243x2. Example 4. Fit a second degree parabola to the following data by the Least Squares Method: x: 1929 1930 1931 1932 1933 1934 1935 1936 1937 y: 352 356 357 358 360 361 361 360 359. Sol. Here m = g (odd) ∴ Let x0 = 1933, h = 1, y0 = 357 then u = x − 1933 1 = x – 1933 v = y – 357 and the equation y = a + bx + cx2 is transformed to v = a′ + b′u + c′u2 x u y v uv u2 u2v u3 u4 1929 – 4 352 – 5 20 16 – 80 – 64 256 1930 – 3 356 – 1 3 9 – 9 – 27 81 1931 – 2 357 0 0 4 0 – 8 16 1932 – 1 358 1 – 1 1 1 – 1 1 1933 0 360 3 0 0 0 0 0 1934 1 361 4 4 1 4 1 1 1935 2 361 4 8 4 16 8 16 1936 3 360 3 9 9 27 27 81 1937 4 359 2 8 16 32 64 256 Total Σu = 0 Σv = 11 Σuv = 51 Σu2 = 60 Σu2v = – 9 Σu3 = 0 Σu4 = 708
  • 658. STATISTICAL COMPUTATION 645 Putting the above values in normal equations, we get 11 = 9a′ + 60c′, 51 = 60b′, – 9 = 60a′ + 708c′ ⇒ a′ = 3, b′ = 0.85, c′ = – 0.27. Fitted parabola in u and v is given by v = 3 + 0.85 u – 0.27 u2 Putting u = x – 1933 and v = y – 357 y – 357 = 3 + 0.85 (x – 1933) – .27 (x – 1933)2 ⇒ y = – 0.27x2 + 1044.67x – 1010135.08 which is the required equation. Example 5. Fit a second degree parabola to the following data by Least Squares Method: x: 1 2 3 4 5 y: 1090 1220 1390 1625 1915 Sol. Here m = 5 (odd) Let u = x – 3, v = y – 1220 x y u v u2 u2v uv u3 u4 1 1090 – 2 – 130 4 – 520 260 – 8 16 2 1220 – 1 0 1 0 0 – 1 1 3 1390 0 170 0 0 0 0 0 4 1625 1 405 1 405 405 1 1 5 1915 2 695 4 2780 1390 8 16 Total Σu = 0 Σv = 1140 Σu2 = 10 Σu2v = 2665 Σuv = 2055 Σu3 = 0 Σu4 = 34 Putting these values in normal equations, we get 1140 = 5a′ + 10c′, 2055 = 10b′, 2655 = 10a′ + 34c′ ⇒ a′ = 173, b′ = 205.5, c′ = 27.5 ∴ v = 173 + 205.5u + 27.5u2 (133) Put u = x – 3 and v = y – 1220 From (133), y – 1220 = 173 + 205.5 (x – 3) + 27.5 (x – 3)2 ⇒ y = 27.5x2 + 40.5x + 1024.
  • 659. 646 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Example 6. Fit a second degree parabola to the following data taking y as dependent variable: x 1 2 3 4 5 6 7 8 9 y 2 6 7 8 10 11 11 10 9 Sol. Normal equations to fit a second degree parabola of the form y = a + bx + cx2 are and Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ Σ y ma b x c x xy a x b x c x x y a x b x c x = + + = + + = + + U V | W | 2 2 3 2 2 3 4 (134) Here, m = 9 x y x2 x3 x4 xy x2y 1 2 1 1 1 2 2 2 6 4 8 16 12 24 3 7 9 27 81 21 63 4 8 16 64 256 32 128 5 10 25 125 625 50 250 6 11 36 216 1296 66 396 7 11 49 343 2401 77 539 8 10 64 512 4096 80 640 9 9 81 729 6561 81 729 Σx = 45 Σy = 74 Σx2 = 285 Σx3 = 2025 Σx4 = 15333 Σxy = 421 Σx2y = 2771 Putting in (134), we get 74 = 9a + 45b + 285c 421 = 45a + 285b + 2025c 2771 = 285a + 2025b + 15333c Solving the above equations, we get a = – 1, b = 3.55, c = – 0.27 Hence the required equation of second degree parabola is y = – 1 + 3.55x – 0.27x2. Example 7. Employ the method of least squares to fit a parabola y = a + bx + cx2 in the following data: (x, y): (– 1, 2), (0, 0), (0, 1), (1, 2)
  • 660. STATISTICAL COMPUTATION 647 Sol. Normal equations to the parabola y = a + bx + cx2 are Σy = ma + bΣx + cΣx2 (135) Σxy = aΣx + bΣx2 + cΣx3 (136) and Σx2y = aΣx2 + bΣx3 + cΣx4 (137) Here m = 4 The table is as follows: x y x2 x3 x4 xy x2y – 1 2 1 – 1 1 – 2 2 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 2 1 1 1 2 2 Σx = 0 Σy = 5 Σx2 = 2 Σx3 = 0 Σx4 = 2 Σxy = 0 Σx2y = 4 Substituting these values in equations (135), (136) and (137); we get 5 = 4a + 2c (138) 0 = 2b (139) and 4 = 2a + 2c (140) Solving (138), (139) and (140), we get a = 0.5, b = 0 and c = 1.5 Hence the required second degree parabola is y = 0.5 + 1.5x2 7.59.1 Algorithm of Second Degree Parabolic Curve Fitting 1. Input n 2. For i=0,3 3. For j=0,4 4. u(i,j)=0 5. Next j 6. Next i 7. u(0,0)=n 8. For i=0,n 9. Input x,y
  • 661. 648 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 10. x2=x*x 11. u(0,1)+=x 12. u(0,2)+=x2 13. u(1,2)+=x*x2 14. u(2,2)+=x2*x2 15. u(0,3)+=y 16. u(1,3)+=x*y 17. u(2,3)+=x2*y 18. Next i 19. u(1,1)=u(0,2) 20. u(2,1)=u(1,2) 21. u(1,0)=u(0,1) 22. u(2,0)=u(1,1) 23. For j=0,3 24. For i=0,3 25. If i!=j then goto step 26 ELSE goto step 24 26. y=u(i,j)/u(j,j) 27. For k=0,4 28. u(i,k)-=u(j,k)*p 29. Next k 30. Next i 31. Next j 32. a=u(0,3)/u(0,0) 33. b=u(1,3)/u(1,1) 34. c=u(2,3)/u(2,2) 35. Print a,b,c 36. Stop
  • 662. STATISTICAL COMPUTATION 649 7.59.2 Flow-Chart of Second Degree Parabolic Curve Fitting START Input n For i = 0, 3 For j = 0, 4 u(i, j) = 0 u(0, 0) = n For i = 0, n Input x, y x2 = x*x u(0, 1) + = x u(0, 2) + = x2 u(1, 2) + = x*x2 u(2, 2) + = x2*x2 u(0, 3) + = y u(1, 3) + = x*y u(2, 3) + = x2*y u(1, 1) = u(0, 2) u(2, 1) = u(1, 2) u(1, 0) = u(0, 1) u(2, 0) = u(1, 1) A
  • 663. 650 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A For j = 0, 3 For i = 0, 3 For k = 0, 4 u(i, k) – = u(j, k)*p a = u(0, 3)/u(0, 0) b = u(1, 3)/u(1, 1) c = u(2, 3)/u(2, 2) STOP If i ! = j y = u(i, j)/u(j, j) Print a, b, c Yes No 7.59.3 Program in ‘C’ for Second Degree Parabolic Curve Fitting Notations used in the Program (i) n is the number of data points. (ii) x is the data point value of x. (iii) y is the data point of y. (iv) u is the two dimensional array of augmented matrix. #includestdio.h main() { int i,j,k,n;
  • 664. STATISTICAL COMPUTATION 651 float u[3][4], x,y,x2,p,a,b,c; printf(nEnter the value of data set n:); scanf(%d,n); for(i=0; i3; i++) for(j=0; j4; j++) u[i][j]=0; u[0][0]=n; printf(nEnter the value of x y:n); for(i=0; in; i++) { scanf(%f%f, x, y); x2=x*x; u[0][1]+=x; u[0][2]+=x2; u[1][2]+=x*x2; u[2][2]+=x2*x2; u[0][3]+=y; u[1][3]+=x*y; u[2][3]+=x2*y; } u[1][1]=u[0][2]; u[2][1]=u[1][2]; u[1][0]=u[0][1]; u[2][0]=u[1][1]; /* Finding the value of a,b,c */ for (j=0;j3;j++) for (i=0;i3;i++) if(i!=j) { p=u[i][j]/u[j][j]; for(k=0;k;k++) u[i][k]-=u[j][k]*p; } a=u[0][3]/u[0][0]; b=u[1][3]/u[1][1];
  • 665. 652 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES c=u[2][3]/u[2][2]; printf(na=%f b=%f c=%f , a,b,c); printf(nnEquation of parabola is: y=a+bx+cx^2 n); printf(ny=%f+(%f)x+(%f)x^2,a,b,c); return; } 7.59.4 Output Enter the value of data set n: 5 Enter the value of x y: 1 10.9 2 12.2 3 13.9 4 16.3 5 19.2 a=10.239998 b=0.398574 c=0.278571 Equation of parabola is: y = a+bx+cx^2 y=10.239998+(0.398574)x+(0.278571)x^2 7.60 MULTIPLE LINEAR REGRESSION Now we proceed to discuss the case where the dependent variable is a function of two or more linear or non-linear independent variables. Consider such a linear function as y = a + bx + cz The sum of the squares of residual is U = ( ) y a bx cz i i i i n − − − = ∑ 2 1 Differentiating U partially with respect to a, b, c; we get ∂ ∂ U a = 0 ⇒ 2 1 ( ) y a bx cz i i i i n − − − = ∑ (– 1) = 0 ∂ ∂ U b = 0 ⇒ 2 1 ( ) y a bx cz i i i i n − − − = ∑ (– xi) = 0
  • 666. STATISTICAL COMPUTATION 653 and ∂ ∂ U c = 0 ⇒ 2 1 ( ) y a bx cz i i i i n − − − = ∑ (– zi) = 0 which on simplification and omitting the suffix i, yields. ∑y = ma + b∑x + c∑z ∑xy = a∑x + b∑x2 + c∑xz ∑yz = a∑z + b∑xz + c∑z2 Solving the above three equations, we get values of a, b and c. Consequently, we get the linear function y = a + bx + cz called regression plane. Example. Obtain a regression plane by using multiple linear regression to fit the data given below: x: 1 2 3 4 z: 0 1 2 3 y: 12 18 24 30 Sol. Let y = a + bx + cz be the required regression plane where a, b, c are the constants to be determined by following equations: Σy = ma + bΣx + cΣz Σyx = aΣx + bΣx2 + cΣzx and Σyz = aΣz + bΣzx + cΣz2 Here m = 4 x z y x2 z2 yx zx yz 1 0 12 1 0 12 0 0 2 1 18 4 1 36 2 18 3 2 24 9 4 72 6 48 4 3 30 16 9 120 12 90 Σx = 10 Σz = 6 Σy = 84 Σx2 = 30 Σz2 = 14 Σyx = 240 Σzx = 20 Σyz = 156 Substitution yields, 84 = 4a + 10b + 6c 240 = 10a + 30b + 20c and 156 = 6a + 20b + 14c Solving, we get a = 10, b = 2, c = 4 Hence the required regression plane is y = 10 + 2x + 4z.
  • 667. 654 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 7.6 1. Fit a second degree parabola to the following data taking x as the independent variable: x: 0 1 2 3 4 y: 1 5 10 22 38 2. Fit a second degree parabola to the following data by Least Squares Method: x: 0 1 2 3 4 y: 1 1.8 1.3 2.5 6.3 3. The profit of a certain company in Xth year of its life are given by: x: 1 2 3 4 5 y: 1250 1400 1650 1950 2300 Taking u = x – 3 and v = y − 1650 50 , show that the parabola of second degree of v on u is v + 0.086 = 5.3 u + 0.643u2 and deduce that the parabola of second degree of y on x is y = 1144 + 72x + 32.15x2. 4. The following table gives the results of the measurements of train resistances, V is the velocity in miles per hour, R is the resistance in pounds per ton: V: 20 40 60 80 100 120 R: 5.5 9.1 14.9 22.8 33.3 46 If R is related to V by the relation R = a + bV + cV2; find a, b and c by using the Method of Least Squares. 5. Determine the constants a, b, and c by the Method of Least Squares such that y = ax2 + bx + c fits the following data: x: 2 4 6 8 10 y: 4.01 11.08 30.12 81.89 222.62 7.61 STATISTICAL QUALITY CONTROL A quality control system performs inspection, testing and analysis to ensure that the quality of the products produced is as per the laid down quality standards. It is called “Statistical Quality Control” when statistical techniques are employed to control, improve and maintain quality or to solve quality problems. Building an information system to satisfy the concept of prevention and control and improving upon product quality requires statistical thinking.
  • 668. STATISTICAL COMPUTATION 655 Statistical quality control (S.Q.C.) is systematic as compared to guess-work of haphazard process inspection and the mathematical statistical approach neutralizes personal bias and uncovers poor judgement. S.Q.C. consists of three general activities: (1) Systematic collection and graphic recording of accurate data (2) Analyzing the data (3) Practical engineering or management action if the information obtained indicates significant deviations from the specified limits. Modern techniques of statistical quality control and acceptance sampling have an important part to play in the improvement of quality, enhancement of productivity, creation of consumer confidence, and development of industrial economy of the country. The following statistical tools are generally used for the above purposes: (i) Frequency distribution. Frequency distribution is a tabulation of the number of times a given quality characteristic occurs within the samples. Graphic representation of frequency distribution will show: (a) Average quality (b) Spread of quality (c) Comparison with specific requirements (d) Process capability. (ii) Control chart. Control chart is a graphical representation of quality characteristics, which indicates whether the process is under control or not. (iii) Acceptance sampling. Acceptance sampling is the process of evaluating a portion of the product/material in a lot for the purpose of accepting or rejecting the lot on the basis of conforming to a quality specification. It reduces the time and cost of inspection and exerts more effective pressure on quality improvement than it is possible by 100% inspection. It is used when assurance is desired for the quality of materials/products either produced or received. (iv) Analysis of data. Analysis of data includes analysis of tolerances, correlation, analysis of variance, analysis for engineering design, problem solving technique to eliminate cause to troubles. Statistical methods can be used in arriving at proper specification limits of product, in designing the product, in purchase of raw-material, semi-finished and finished products, manufacturing processes, inspection, packaging, sales, and also after sales service.
  • 669. 656 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 7.62 ADVANTAGES OF STATISTICAL QUALITY CONTROL 1. Efficiency. The use of statistical quality control ensures rapid and efficient inspection at a minimum cost. It eliminates the need of 100% inspection of finished products because the acceptance sampling in statistial quality control exerts more effective pressure for quality improvement. 2. Reduction of scrap. Statistial quality control uncovers the cause of excessive variability in manufactured products forecasting trouble before rejections occur and reducing the amount of spoiled work. 3. Easy detection of faults. In statistical quality control, after plotting the control charts (X, R, P, C, U) etc., when the points fall above the upper control limits or below the lower control limit, an indication of deterioration in quality is given. Necessary corrective action may then be taken immediately. 4. Adherence to specifications. So long as a statistical quality control continues, specifications can be accurately predicted for the future by which it is possible to assess whether the production processes are capable of producing the products with the given set of specifications. 5. Increases output and reduces wasted machine and man hours. 6. Efficient utilization of personnel, machines and materials results in higher productivity. 7. Creates quality awareness in employees. However, it should be noted that statistical quality control is not a panacea for assuring product quality. 8. Provides a common language that may be used by designers, production personnel, and inspectors in arriving at a rational solution of mutual problems. 9. Points out when and where 100% inspection, sorting or screening is required. 10. Eliminates bottlenecks in the process of manufacturing. It simply furnishes ‘perspective facts’ upon which intelligent management and engineering action can be based. Without such action, the method is ineffective. Even the application of standard procedures is very dangerous without adequate study of the process.
  • 670. STATISTICAL COMPUTATION 657 7.63 REASONS FOR VARIATIONS IN THE QUALITY OF A PRODUCT Two extremely similar things are rarely obtained in nature. This fact holds good for production processes as well. No production process is good enough to produce all items or products exactly alike. The variations are due to two main reasons: (i) Chance or random causes. Variations due to chance causes are inevitable in any process or product. They are difficult to trace and to control even under the best conditions of production. These variations may be due to some inherent characteristic of the process or machine which functions at random. If the variations are due to chance factors alone, the observations will follow a “normal curve.” The knowledge of the behaviour of chance variation is the foundation on which control chart analysis rests. The conditions which produce these variations are accordingly said to be “under control.” On the other hand, if the variations in the data do not conform to a pattern that might reasonably be produced by chance causes, then in this case, conditions producing the variations are said to be “out of control” as it may be concluded that one or more assignable causes are at work. (ii) Assignable causes. The variations due to assignable causes possess greater magnitude as compared to those due to chance causes and can be easily traced or detected. The power of the shewhart control chart lies in its ability to separate out these assignable causes of quality variations, for example, in length thickness, weight, or diameter of a component. The variations due to assignable causes may be because of following factors: (i) Differences among machines (ii) Differences among workers (iii) Differences among materials (iv) Differences in each of these factors over time (v) Differences in their relationship to one another. These variations may also be caused due to change in working conditions, mistake on the part of the operator, etc. 7.64 TECHNIQUES OF STATISTICAL QUALITY CONTROL To control the quality characteristics of the product, there are two main techniques: 1. Process Control. Process control is a process of monitoring and measuring variability in the performance of a process or a machine through the
  • 671. 658 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES interpretation of statistical techniques and it is employed to manage in- process quality. This technique ensures the production of requisite standard product and makes use of control charts. 2. Product control. This technique is concerned with the inspection of already produced goods to ascertain whether they are fit to be dispatched or not. To achieve the objectives, product control makes use of sampling inspection plans. 7.65 CONTROL CHART A control chart is a graphical representation of the collected information. It detects the variation in processing and warns if there is any departure from the specified tolerance limits. In other words, control charts is a device which specifies the state of statistical control or is a device for attaining quality control or is a device to judge whether the statistical control has been attained. The control limits on the chart are so placed as to disclose the presence or absence of the assignable causes of quality variation which makes the diagnosis possible and brings substantial improvements in product quality and reduction of spoilage and rework. Moreover, by identifying chance variations, the control chart tells when to leave the process alone and thus prevents unnecessarily frequent adjustments that tend to increase the variability of the process rather than to decrease it. There are many types of control charts designed for different control situations. Most commonly used control charts are: (i) Control charts for variables. These are useful to measure quality characteristics and to control fully automatic process. It includes X and R-charts and charts for X and σ. (ii) Control charts for attributes. These include P-chart for fraction defective. A fraction defective control chart discloses erratic fluctuations in the quality of inspection which may result in improvement in inspection practice and inspection standards. It also includes C-chart for number of defects per unit. 7.66 OBJECTIVES OF CONTROL CHARTS Control charts are based on statistical techniques. 1. X and R or X and σ charts are used in combination for control process. X -chart shows the variation in the averages of samples. It is the most
  • 672. STATISTICAL COMPUTATION 659 commonly used variables chart. R-chart shows the uniformity or consistency of the process, i.e., it shows the variations in the ranges of samples. It is a chart for measure of spread. σ-chart shows the variation of process. 2. To determine whether a given process can meet the existing specifications without a fundamental change in the production line or to tell whether the process is in control and if so, at what dispersion. 3. To secure information to be used in establishing or changing production procedures. 4. To secure information when it is necessary to widen the tolerances. 5. To provide a basis for current decisions or acceptance or rejection of manufactured or purchased product. 6. To secure information to be used in establishing or changing inspection procedure or acceptance procedure or both. 7.67 CONSTRUCTION OF CONTROL CHARTS FOR VARIABLES First of all, a random sample of size n is taken during a manufacturing process over a period of time and quality measurements x1, x2, ......, xn are noted Sample mean x = x x x n n x n i i n 1 2 1 1 + + + = = ∑ ...... Sample range R = xmax. – xmin. If the process is found stable, k consecutive samples are selected and for each sample, x and R are calculated. Then we find x and R as x x x x k k x k i i k = + + + = = ∑ 1 2 1 1 ...... and R = R R R R 1 2 1 1 + + + = = ∑ ...... k i i k k k For X -chart Central line = x , when tolerance limits are not given , when tolerance limits are given μ U V W where μ = 1 2 [LCL + UCL] LCL is lower control limit and UCL is upper control limit Now, LCL (for X -chart) = x − A R 2 and UCL (for X -chart) = x + A R 2 are set.
  • 673. 660 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES A2 depends on sample size n and can be found from the following table: Sample 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 size (n) A2 1.88 1.02 0.73 0.58 0.48 0.42 0.37 0.34 0.31 0.29 0.27 0.25 0.24 0.22 0.21 0.20 0.19 0.19 0.18 For R-chart Central line (CL) = R Now, LCL (for R-chart) = D3R UCL (for R-chart) = D4R are set. where D3 and D4 depend on sample size and are found from the following table: Sample size (n) D3 D4 d2 2 0 3.27 1.13 3 0 2.57 1.69 4 0 2.28 2.06 5 0 2.11 2.33 6 0 2.00 2.53 7 0.08 1.92 2.70 8 0.14 1.86 2.85 9 0.18 1.82 2.97 10 0.22 1.78 3.08 11 0.26 1.74 3.17 12 0.28 1.72 3.26 13 0.31 1.69 3.34 14 0.33 1.67 3.41 15 0.35 1.65 3.47 16 0.36 1.64 3.53 17 0.38 1.62 3.59 18 0.39 1.61 3.64 19 0.40 1.60 3.69 20 0.41 1.59 3.74 To compute upper and lower process tolerance limits for the values of x, we have LTL = x d − 3 2 R UTL = x d + 3 2 R where d2 is found from the above table. Moreover, The process capability is given by 6σ = 6 2 R d where σ is standard deviation.
  • 674. STATISTICAL COMPUTATION 661 While plotting the X -chart the central line on the X chart should be drawn as a solid horizontal line at X . The upper and lower control limits for X chart should be drawn as dotted horizontal lines at the computed values. Similarly, for R-chart, the central line should be drawn as a solid horizontal line at R . The upper control limit should be drawn as dotted horizontal line at the computed value of UCLR. If the subgroup size is 7 or more, the lower control limit should be drawn as dotted horizontal line at LCLR. However, if the subgroup size is ≤ 6, the lower control limit for R is zero. Plot the averages of subgroups in X -chart, in the order collected and ranges in R-chart which should be below the X -chart so that the subgroups correspond to one-another in both the charts. Points outside the control limits are indicated with cross (×) on X -chart and the points outside the limits on R chart by a circle ( • ). 7.68 CONTROL CHARTS FOR ATTRIBUTES The following control charts will be discussed here (i) P chart (ii) np chart (iii) C chart (iv) u chart. As an alternative to X and R chart and as a substitute when characteristic is measured only by attribute, a control chart based on fraction defective p is used, called P-chart. p = Number of defective articles found in any inspection Total number of articles actually inspected . (i) Control limits (3σ limits) on P-chart. We know that for binomial distribution, the mean value of total number of defectives in a sample n is np and standard deviation is npq or np p ( ) 1 − . ∴ Mean value of fraction defective is p and standard deviation σp = 1 1 1 n np p p p n ( ) ( ) − = − ∴ CL = p The upper and lower limits for P-chart are, UCLP = p + 3σp = p + 3 p p n ( ) 1 −
  • 675. 662 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES and LCLP = p – 3σp = p – 3 p p n ( ) 1 − . Due to the lower inspection and maintenance costs of P-charts, they usually have a greater area of economical applications. (ii) Control limits for np chart. Whenever subgroup size is variable, P-chart is used but if it is constant, the chart for actual number of defectives called np chart is used. CL = n p where p = ∑ ∑ np n UCLnp = n p + 3σnp = n p + 3 np p ( ) 1 − (where σnp = nσp) and LCLnp = n p – 3 np p ( ) 1 − . In case of X and R chart, it may not be necessary to draw lines connecting the points which represent the successive subgroups. But incase of P-chart, a line connecting the points is usually helpful in interpretation of the chart. Such a line assists in the interpretation of trends. (iii) Control limits for C chart (a) Difference between a defect and defective An item is called defective if it fails to conform to the specifications in any of the characteristics. Each characteristic that does not meet the specifications is a defect. An item is defective if it contains atleast one defect. The np chart applies to the number of defectives in subgroups of constant size while C chart applies to the number of defects in a subgroup of constant size. (b) Basis for control limits on C chart Control limits on C chart are based on Poisson distribution. Hence two conditions must be satisfied. The first condition specifies that the area of opportunity for occurrence of defects should be fairly constant from period to period. Second condition specifies that opportunities for defects are large while the chances of a defect occurring in any one spot are small. (c) Calculation of control limits on C chart Standard deviation σc = C Thus 3σ limits on a C chart are UCLc = C + 3 C and LCLc = C 3 C − NOTE
  • 676. STATISTICAL COMPUTATION 663 and central line CL = C where C = Number of defects in all samples Total number of samples . (iv) u chart. When the subgroup size varies from sample to sample, it is necessary to use u charts. The control limits on u chart will however vary. If c is total number of defects found in any sample and n is number of inspection units in a sample, u n = = C Number of defects in a sample Number of units in a sample The larger the number of units in a sample, the narrower the limits. Formulae for control limits on u chart are: UCLu = u u n + 3 ; LCLu = u u n − 3 and central line CL = u . EXAMPLES Example 1. The following are the mean lengths and ranges of lengths of a finished product from 10 samples each of size 5. The specification limits for length are 200 ± 5 cm. Construct X and R-chart and examine whether the process is under control and state your recommendations. Sample number 1 2 3 4 5 6 7 8 9 10 Mean (X ) 201 198 202 200 203 204 199 196 199 201 Range (R) 5 0 7 3 3 7 2 8 5 6 Assume for n = 5, A2 = 0.58, D4 = 2.11 and D3 = 0. Sol. (i) Control limits for X chart: Central limit CL = 200 ∵ Tolerance / specification limits are given = 200 ∴ μ UCL A R = + A R 2 2 x x = + μ LCL A R = A R 2 2 x x = − − μ where R R R R 1 2 10 = + + + = ...... 10 46 10 = 4.6 Then, UCLX = 200 + (0.58 × 4.6) = 202.668
  • 677. 664 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES LCLX = 200 – (0.58 × 4.6) = 197.332. (ii) Control limits for R chart. Central limit CL = R = 4.6 UCLR = D4R = 2.11 × 4.6 = 9.706 LCLR = D3 R = 0 × 4.6 = 0 The X and R-charts are drawn below: × × × 1 2 3 4 5 6 7 8 9 10 190 195 200 205 LCL = 197.332 UCL = 202.668 CL = 200 Sample number Sample mean X – X-Chart 1 2 3 4 5 6 7 8 9 10 0 4 8 12 UCL = 9.706 CL = 4.6 LCL = 0 Sample number Sample Range (R) R-Chart
  • 678. STATISTICAL COMPUTATION 665 It is noted that all points lie within the control limits on the R chart. Hence the process variability is under control. But in X-chart, points corresponding to sample number 5, 6, and 8 lie outside the control limits. Therefore the process is not in statistical control. The process should be halted and it is recommended to check for any assignable causes. Fluctuation will remain until these causes, if found, are removed. Example 2. A drilling machine bores holes with a mean diameter of 0.5230 cm and a standard deviation of 0.0032 cm. Calculate the 2-sigma and 3-sigma upper and lower control limits for means of sample of 4. Sol. Mean diameter x = 0.5230 cm S.D. σ = 0.0032 cm n = 4 (i) 2-sigma limits are as follows: CL = x = 0.5230 cm UCL = x n + = + × 2 0 5230 2 0 0032 4 σ . . = 0.5262 cm LCL = x n − = − × 2 0 5230 2 0 0032 4 σ . . = 0.5198 cm. (ii) 3-sigma limits are as follows: CL = x = 0.5230 cm UCL = x n + = + × 3 0 5230 3 0 0032 4 σ . . = 0.5278 cm LCL = x n − = − × 3 0 5230 3 0 0032 4 σ . . = 0.5182 cm. Example 3. In a blade manufacturing factory, 1000 blades are examined daily. Draw the np chart for the following table and examine whether the process is under control? Date: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Number of defective blades: 9 10 12 8 7 15 10 12 10 8 7 13 14 15 16 Sol. Here, n = 1000 ∑np = total number of defectives = 166 ∑n = total number inspected = 1000 × 15 ∴ p np n = ∑ ∑ = × 166 1000 15 = 0.011
  • 679. 666 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ n p = 1000 × 0.011 = 11 Control limits are CL = n p = 11 UCLnp = np np p + − 3 1 ( ) = 11 + 3 11 1 0 011 ( . ) − = 20.894 LCLnp = np np p − − = − − 3 1 11 3 11 1 0 011 ( ) ( . ) = 1.106 The np chart is drawn in the figure. Since all the points lie within the control limits, the process is under control. 1 3 5 7 9 11 13 15 0 5 10 15 20 25 UCL = 20.894 LCL = 1.106 Sample number ( -chart) np Number of defective blades Example 4. In a manufacturing process, the number of defectives found in the inspection of 20 lots of 100 samples is given below: Lot number Number of defectives Lot number Number of defectives 1 5 11 7 2 4 12 6 3 3 13 3 4 5 14 5 5 4 15 4 6 6 16 2 7 9 17 8 8 15 18 7 9 11 19 6 10 6 20 4
  • 680. STATISTICAL COMPUTATION 667 (i) Determine the control limits of p-chart and state whether the process is in control. (ii) Determine the new value of mean fraction defective if some points are out of control. Compute the corresponding control limits and state whether the process is still in control or not. (iii) Determine the sample size when a quality limit not worse than 9% is desirable and a 10% bad product will not be permitted more than three times in thousand. Sol. (i) p = = × Total number of defectives Total number of items inspected 120 20 100 = 0.06 UCLP = p p p n + − = + − 3 1 0 06 3 0 06 1 0 06 100 ( ) . . ( . ) = 0.13095 LCLP = p p p n − − = − − 3 1 0 06 3 0 06 1 0 06 100 ( ) . . ( . ) = – 0.01095 Since the fraction defective cannot be (–) ve ∴ LCLP = 0 After observing the values of defectives in the given example, it is clear that only 8th lot having fraction defective 15 100 = 0.15 will go above UCLP. (ii) After eliminating the 8th lot, Revised value of p = − × 120 15 100 19 = 0.056 Revised control limits will be UCLP = 0.056 + 3 0 056 1 0 056 100 . ( . ) − = 0.125 LCLP = 0.056 – 3 0 056 1 0 056 100 . ( . ) − = – 0.013 i.e., zero. It is clear that all the points are within control limits. ∴ Revised quality level p = 0.056 (iii) Since a probability that a defective more than a 9% defective quality will not be permitted, is more than 3 times in a thousand (0.3%) in corresponding 3σ limits: ∴ p + 3p = 0.09
  • 681. 668 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 0.056 + 3 0 056 1 0 056 . ( . ) − n = 0.09 ⇒ 0 056 0 034 3 . . × = 0.944 n Squaring, 0 056 0 034 3 2 . . × = F HG I KJ 0.944 n = (0.01133)2 n = 0 056 0 944 0 01133 0 01133 . . . . × × = 333. Example 5. A control chart for defects per unit u uses probability limits corresponding to probabilities of 0.975 and 0.025. The central line on the control chart is at u = 2.0. The limits vary with the value of n. Determine the correct position of these upper and lower control limits when n = 5. (Assume σ = 1.96) Sol. UCLu = u u n + = + σ 2 2 5 1.96 = 3.239 LCLu = 2 – 1.96 2 5 = 0.761. Example 6. Determine the control limits for X and R charts if ∑ X = 357.50, ∑R = 9.90, number of subgroups = 20. It is given that A2 = 0.18, D3 = 0.41, D4 = 1.59 and d2 = 3.736. Also find the process capability. Sol. X = X N ∑ = 357 50 20 . = 17.875 R = R N ∑ = 9 90 20 . = 0.495 UCL X A R X 2 = + = 17.875 + (0.18 × 0.495) = 17.9641 LCL X A R X 2 = − = 17.875 – (0.18 × 0.495) = 17.7859 UCLR = D4R = 1.59 × 0.495 = 0.78705 LCLR = D3 R = 0.41 × 0.495 = 0.20295 σ = R d2 0 495 3 735 = . . = 0.13253 ∴ Process capability = 6σ = 6 × 0.13253 = 0.79518. Example 7. If the average fraction defective of a large sample of a product is 0.1537, Calculate the control limits given that sub-group size is 2000. Sol. Average fraction defective p = 0.1537
  • 682. STATISTICAL COMPUTATION 669 Sub-group size is 2000 ∴ n = 2000 Central line CL = n p = 2000 × 0.1537 = 307.4 UCLnp = n p + 3σnp = np np p + − 3 1 ( ) = 307.4 + 3 307 4 1 0 1537 . ( . ) − = 307.4 + 48.38774204 = 355.787742 and LCLnp = np np p − − 3 1 ( ) = 307.4 – 48.38774204 = 259.012258 ASSIGNMENT 7.7 1. A company manufactures screws to a nominal diameter 0.500 ± 0.030 cm. Five samples were taken randomly from the manufactured lots and 3 measurements were taken on each sample at different lengths. Following are the readings: Sample number Measurement per sample x(in cm) 1 2 3 1 0.488 0.489 0.505 2 0.494 0.495 0.499 3 0.498 0.515 0.487 4 0.492 0.509 0.514 5 0.490 0.508 0.499 Calculate the control limits of X and R charts. Draw X and R charts and examine whether the process is in statistical control? [Take A2 = 1.02, D4 = 2.57, D3 = 0 for n = 3] 2. The average percentage of defectives in 27 samples of size 1500 each was found to be 13.7%. Construct P-chart for this situation. Explain how the control chart can be used to control quality. [Hint: p = 0.137] 3. The number of customer complaints received daily by an organization is given below: Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Complaints: 2 3 0 1 9 2 0 0 4 2 0 7 0 2 4 Does it mean that the number of complaints is under statistical control? Establish a control scheme for the future.
  • 683. 670 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 4. It was found that when a manufacturing process is under control, the average number of defectives per sample batch of 10 is 1.2. What limits would you set in a quality control chart based on the examination of defectives in sample batches of 10? [Hint: p = 0.12, n p = 1.2] 5. The following data shows the value of sample mean X and range R for 10 samples of size 5 each. Calculate the values for central line and control limits for X -chart and R chart and determine whether the process is under control. Sample number:1 2 3 4 5 6 7 8 9 10 Mean X : 11.2 11.8 10.8 11.6 11 9.6 10.4 9.6 10.6 10 Range R: 7 4 8 5 7 4 8 4 7 9 Assume for n = 5, A2 = 0.577, D3 = 0 and D4 = 2.115. 6. What are statistical quality control techniques? Discuss the objectives and advantages of statistical quality control. 7. The following table shows the number of missing rivets observed at the time of inspection of 12 aircrafts. Find the control limits for the number of defects chart and comment on the state of control. Air craft number: 1 2 3 4 5 6 7 8 9 10 11 12 Number of missing rivets: 7 15 13 18 10 14 13 10 20 11 22 15
  • 684. Chapter 8 TESTING OF HYPOTHESIS 671 8.1 POPULATION OR UNIVERSE A n aggregate of objects (animate or inanimate) under study is called population or universe. It is thus a collection of individuals or of their attributes (qualities) or of results of operations which can be numerically specified. A universe containing a finite number of individuals or members is called a finite inverse. For example, the universe of the weights of students in a particular class. A universe with infinite number of members is known as an infinite universe. For example, the universe of pressures at various points in the atmosphere. In some cases, we may be even ignorant whether or not a particular universe is infinite, for example, the universe of stars. The universe of concrete objects is an existent universe. The collection of all possible ways in which a specified event can happen is called a hypothetical universe. The universe of heads and tails obtained by tossing a coin an infinite number of times (provided that it does not wear out) is a hypothetical one.
  • 685. 672 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 8.2 SAMPLING The statistician is often confronted with the problem of discussing a universe of which he cannot examine every member, i.e., of which complete enumeration is impracticable. For example, if we want to have an idea of the average per capita income of the people of a country, enumeration of every earning individual in the country is a very difficult task. Naturally, the question arises: What can be said about a universe of which we can examine only a limited number of members? This question is the origin of the Theory of Sampling. A finite subset of a universe is called a sample. A sample is thus a small portion of the universe. The number of individuals in a sample is called the sample size. The process of selecting a sample from a universe is called sampling. The theory of sampling is a study of relationship existing between a population and samples drawn from the population. The fundamental object of sampling is to get as much information as possible of the whole universe by examining only a part of it. An attempt is thus made through sampling to give the maximum information about the parent universe with the minimum effort. Sampling is quite often used in our day-to-day practical life. For example, in a shop we assess the quality of sugar, rice, or any other commodity by taking only a handful of it from the bag and then decide whether to purchase it or not. A housewife normally tests the cooked products to find if they are properly cooked and contain the proper quantity of salt or sugar, by taking a spoonful of it. 8.3 PARAMETERS OF STATISTICS The statistical constants of the population such as mean, the variance, etc. are known as the parameters. The statistical concepts of the sample from the members of the sample to estimate the parameters of the population from which the sample has been drawn is known as statistic. Population mean and variance are denoted by μ and σ2, while those of the samples are given by x , s2. 8.4 STANDARD ERROR The standard deviation of the sampling distribution of a statistic is known as the standard error (S.E.). It plays an important role in the theory of large samples and it forms a basis of the testing of hypothesis. If t is any statistic, for large sample.
  • 686. TESTING OF HYPOTHESIS 673 z = t t t − E S E ( ) . ( ) is normally distributed with mean 0 and variance unity. For large sample, the standard errors of some of the well known statistic are listed below: n—sample size; σ2—population variance; s2—sample variance; p—population proportion ; Q = 1 – p; n1, n2—are sizes of two independent random samples. Number Statistic Standard error 1. x σ/ n 2. s σ2 2 / n 3. Difference of two sample means x x 1 2 − σ σ 1 2 1 2 2 2 n n + 4. Difference of two sample standard deviation s1 – s2 σ σ 1 2 1 2 2 2 2 2 n n + 5. Difference of two sample proportions p1 – p2 P Q P Q 1 1 1 2 2 2 n n + 6. Observed sample proportion p PQ/n 8.5 TEST OF SIGNIFICANCE An important aspect of the sampling theory is to study the test of significance which will enable us to decide, on the basis of the results of the sample, whether (i) the deviation between the observed sample statistic and the hypothetical parameter value or (ii) the deviation between two sample statistics is significant or might be attributed due to chance or the fluctuations of the sampling. For applying the tests of significance, we first set up a hypothesis which is a definite statement about the population parameter called Null hypothesis denoted by H0. Any hypothesis which is complementary to the null hypothesis (H0) is called an Alternative hypothesis denoted by H1.
  • 687. 674 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES For example, if we want to test the null hypothesis that the population has a specified mean μ0, then we have H0: μ = μ0 Alternative hypothesis will be (i) H1: μ ≠ μ0 (μ μ0 or μ μ0) (two tailed alternative hypothesis). (ii) H1: μ μ0 (right tailed alternative hypothesis (or) single tailed). (iii) H1: μ μ0 (left tailed alternative hypothesis (or) single tailed). Hence alternative hypothesis helps to know whether the test is two tailed test or one tailed test. 8.6 CRITICAL REGION A region corresponding to a statistic t, in the sample space S which amounts to rejection of the null hypothesis H0 is called as critical region or region of rejection. The region of the sample space S which amounts to the acceptance of H0 is called acceptance region. 8.7 LEVEL OF SIGNIFICANCE The probability of the value of the variate falling in the critical region is known as level of significance. The probability α that a random value of the statistic t belongs to the critical region is known as the level of significance. P(t ∈ ω| H0) = α i.e., the level of significance is the size of the type I error or the maximum producer’s risk. 8.8 ERRORS IN SAMPLING The main aim of the sampling theory is to draw a valid conclusion about the population parameters on the basis of the sample results. In doing this we may commit the following two types of errors: Type I Error. When H0 is true, we may reject it. P(Reject H0 when it is true) = P(Reject H0/H0) = α α is called the size of the type I error also referred to as producer’s risk.
  • 688. TESTING OF HYPOTHESIS 675 Type II Error. When H0 is wrong we may accept it P(Accept H0 when it is wrong) = P(Accept H0/H1) = β . β is called the size of the type II error, also referred to as consumer’s risk. The values of the test statistic which separates the critical region and acceptance region are called the critical values or significant values. This value is dependent on (i) the level of significance used and (ii) the alternative hypothesis, whether it is one-tailed or two-tailed. For larger samples corresponding to the statistic t, the variable z = t t t − E S.E ( ) ( ) is normally distributed with mean 0 and variance 1. The value of z given above under the null hypothesis is known as test statistic. The critical value of zα of the test statistic at level of significance α for a two-tailed test is given by p(| z | zα) = α (1) i.e., zα is the value of z so that the total area of the critical region on both tails is α. Since the normal curve is symmetrical, from equation (1), we get p(z zα) + p(z – zα) = α; i.e., 2p(z zα) = α; p(z zα) = α/2 i.e., the area of each tail is α/2. Lower critical value z = – za Level of significance (Two tailed test) a Rejection region ( /2) a Upper critical value Rejection region ( /2) a z = 0 z = za z = 0 Right tailed test Acceptance region Rejection region ( ) a z = za Left tailed test Acceptance region z = – za z = 0 Rejection region ( ) a The critical value zα is that value such that the area to the right of zα is α/2 and the area to the left of – zα is α/2. In the case of the one-tailed test, p(z zα) = α if it is right-tailed; p(z – zα) = α if it is left-tailed. NOTE
  • 689. 676 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES The critical value of z for a single-tailed test (right or left) at level of significance α is same as the critical value of z for two-tailed test at level of significance 2α. Using the equation, also using the normal tables, the critical value of z at different levels of significance (α) for both single tailed and two tailed test are calculated and listed below. The equations are p(| z | zα) = α; p(z zα) = α; p(z – zα) = α Level of significance 1% (0.01) 5% (0.05) 10% (0.1) Two tailed test | zα | = 2.58 | z | = 1.966 | z | = 0.645 Right tailed zα = 2.33 zα = 1.645 zα = 1.28 Left tailed zα = – 2.33 zα = – 1.645 zα = – 1.28 8.9 STEPS IN TESTING OF STATISTICAL HYPOTHESIS Step 1. Null hypothesis. Set up H0 in clear terms. Step 2. Alternative hypothesis. Set up H1, so that we could decide whether we should use one tailed test or two tailed test. Step 3. Level of significance. Select the appropriate level of significance in advance depending on the reliability of the estimates. Step 4. Test statistic. Compute the test statistic z = t t t − E S.E ( ) ( ) under the null hypothesis. Step 5. Conclusion. Compare the computed value of z with the critical value zα at level of significance (α). If | z | zα, we reject H0 and conclude that there is significant difference. If | z | zα, we accept H0 and conclude that there is no significant difference. 8.10 TEST OF SIGNIFICANCE FOR LARGE SAMPLES If the sample size n 30, the sample is taken as large sample. For such sample we apply normal test, as Binomial, Poisson, chi square, etc. are closely approximated by normal distributions assuming the population as normal. Under large sample test, the following are the important tests to test the significance: 1. Testing of significance for single proportion. 2. Testing of significance for difference of proportions.
  • 690. TESTING OF HYPOTHESIS 677 3. Testing of significance for single mean. 4. Testing of significance for difference of means. 5. Testing of significance for difference of standard deviations. 8.10.1 Testing of Significance for Single Proportion This test is used to find the significant difference between proportion of the sample and the population. Let X be the number of successes in n independent trials with constant probability P of success for each trial. E(X) = nP; V(X) = nPQ; Q = 1 – P = Probability of failure. Let p = X/n called the observed proportion of success. E(p) = E(X/n) = 1 n x E( ) = np n = p; E(p) = p V(p) = V(X/n) = 1 2 n V(X) = 1( ) PQ n = PQ/n S.E.(p) = PQ n ; z = p p p p p n − = − E S.E. PQ ( ) ( ) / ~ N(0, 1) This z is called test statistic which is used to test the significant difference of sample and population proportion. 1. The probable limit for the observed proportion of successes are p± zα PQ/n , where zα is the significant value at level of significance α.. 2. If p is not known, the limits for the proportion in the population are p± zα pq n / , q = 1 – p. 3. If α is not given, we can take safely 3σ limits. Hence, the confidence limits for observed proportion p are p ± 3 PQ n . The confidence limits for the population proportion p are p ± pq n . EXAMPLES Example 1. A coin was tossed 400 times and the head turned up 216 times. Test the hypothesis that the coin is unbiased. Sol.H0: The coin is unbiased i.e., P = 0.5. H1: The coin is not unbiased (biased); P ≠ 0.5 NOTE
  • 691. 678 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Here n = 400; X = Number of success = 216 p = proportion of success in the sample X n = 216 400 = 0.54. Population proportion = 0.5 = P; Q = 1 – P = 1 – 0.5 = 0.5. Under H0, test statistic z = p n − P PQ/ | z | = 0 54 0 5 0 5 0 5 400 . . . . − × = 1.6 we use a two-tailed test. Conclusion. Since | z | = 1.6 1.96 i.e., | z | zα, zα is the significant value of z at 5% level of significance. i.e., the coin is unbiased is P = 0.5. Example 2. A manufacturer claims that only 4% of his products supplied by him are defective. A random sample of 600 products contained 36 defectives. Test the claim of the manufacturer. Sol. (i) P = observed proportion of success. i.e., P = proportion of defective in the sample = 36 600 = 0.06 p = proportion of defectives in the population = 0.04 H0: p = 0.04 is true. i.e., the claim of the manufacturer is accepted. H1: (i) P ≠ 0.04 (two tailed test) (ii) If we want to reject, only if p 0.04 then (right tailed). Under H0, z = p n − = − × P PQ/ 0 06 0 04 0 04 0 96 600 . . . . = 2.5. Conclusion. Since | z | = 2.5 1.96, we reject the hypothesis H0 at 5% level of significance two tailed. If H1 is taken as p 0.04 we apply right tailed test. | z | = 2.5 1.645 (zα) we reject the null hypothesis here also. In both cases, manufacturer’s claim is not acceptable.
  • 692. TESTING OF HYPOTHESIS 679 Example 3. A machine is producing bolts a certain fraction of which are defective. A random sample of 400 is taken from a large batch and is found to contain 30 defective bolts. Does this indicate that the proportion of defectives is larger than that claimed by the manufacturer if the manufacturer claims that only 5% of his product are defective? Find 95% confidence limits of the proportion of defective bolts in batch. Sol. Null hypothesis H0: The manufacturer claim is accepted i.e., P = 5 100 = 0.05 Q = 1 – P = 1 – 0.05 = 0.95 Alternative hypothesis. p 0.05 (Right tailed test). p = observed proportion of sample = 30 400 = 0.075 Under H0, the test statistic z = p n − P PQ/ ∴ z = 0 075 0 05 0 05 0 95 400 . . . . − × = 2.2941. Conclusion. The tabulated value of z at 5% level of significance for the right-tailed test is zα = 1.645. Since | z | = 2.2941 1.645, H0 is rejected at 5% level of significance. i.e., the proportion of defective is larger than the manufacturer claim. To find 95% confidence limits of the proportion. It is given by p ± zα PQ/n 0.05 ± 1.96 0 05 0 95 400 . . × = 0.05 ± 0.02135 = 0.07136, 0.02865 Hence 95% confidence limits for the proportion of defective bolts are (0.07136, 0.02865). Example 4. A bag contains defective articles, the exact number of which is not known. A sample of 100 from the bag gives 10 defective articles. Find the limits for the proportion of defective articles in the bag. Sol. Here p = proportion of defective articles = 10 100 = 0.1; q = 1 – p = 1 – 0.1 = 0.9 Since the confidence limit is not given, we assume it is 95%. ∴ level of significance is 5% zα = 1.96.
  • 693. 680 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Also the proportion of population P is not given. To get the confidence limit, we use P and it is given by P ± zα pq n / = 0.1 ± 1.96 0 1 0 9 100 . . × = 0.1 ± 0.0588 = 0.1588, 0.0412. Hence 95% confidence limits for defective articles in the bag are (0.1588, 0.0412). ASSIGNMENT 8.1 1. A sample of 600 persons selected at random from a large city shows that the percentage of males in the sample is 53. It is believed that the ratio of males to the total population in the city is 0.5. Test whether the belief is confirmed by the observation. 2. In a city a sample of 1000 people was taken and 540 of them are vegetarian and the rest are non-vegetarian. Can we say that both habits of eating (vegetarian or non-vegetarian) are equally popular in the city at (i) 1% level of significance (ii) 5% level of significance? 3. 325 men out of 600 men chosen from a big city were found to be smokers. Does this information support the conclusion that the majority of men in the city are smokers? 4. A random sample of 500 bolts was taken from a large consignment and 65 were found to be defective. Find the percentage of defective bolts in the consignment. 5. In a hospital 475 female and 525 male babies were born in a week. Do these figures confirm the hypothesis that males and females are born in equal number? 6. 400 apples are taken at random from a large basket and 40 are found to be bad. Estimate the proportion of bad apples in the basket and assign limits within which the percentage most probably lies. 8.10.2 Testing of Significance for Difference of Proportions Consider two samples X1 and X2 of sizes n1 and n2, respectively, taken from two different populations. Test the significance of the difference between the sample proportion p1 and p2. The test statistic under the null hypothesis H0, that there is no significant difference between the two sample proportion, we have z = p p n n 1 2 1 2 1 1 − + F HG I KJ PQ , where P = n p n p n n 1 1 2 2 1 2 + + and Q = 1 – P.
  • 694. TESTING OF HYPOTHESIS 681 EXAMPLES Example 1. Before an increase in excise duty on tea, 800 people out of a sample of 1000 persons were found to be tea drinkers. After an increase in the duty, 800 persons were known to be tea drinkers in a sample of 1200 people. Do you think that there has been a significant decrease in the consumption of tea after the increase in the excise duty? Sol. Here n1 = 800, n2 = 1200 p1 = X1 1 800 1000 4 5 n = = ; p2 = X2 2 800 1200 2 3 n = = P = p n p n n n 1 1 2 2 1 2 + + = X X 1 2 1 2 + + n n = 800 800 1000 1200 8 11 + + = ; Q = 3 11 Null hypothesis H0: p1 = p2, i.e., there is no significant difference in the consumption of tea before and after increase of excise duty. H1: p1 p2 (right-tailed test) The test statistic z = p p n n 1 2 1 2 1 1 − + F HG I KJ PQ = 0 8 0 6666 8 11 3 11 1 1000 1 1200 . . − × + F HG I KJ = 6.842. Conclusion. Since the calculated value of | z | 1.645 also | z | 2.33, both the significant values of z at 5% and 1% level of significance. Hence H0 is rejected, i.e., there is a significant decrease in the consumption of tea due to increase in excise duty. Example 2. A machine produced 16 defective articles in a batch of 500. After overhauling it produced 3 defectives in a batch of 100. Has the machine improved? Sol. p1 = 16 500 = 0.032; n1 = 500 p2 = 3 100 = 0.03; n2 = 100 Null hypothesis H0: The machine has not improved due to overhauling, p1 = p2. H1: p1 p2 (right-tailed) ∴ P = p n p n n n 1 1 2 2 1 2 19 600 + + = ~ = 0.032
  • 695. 682 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Under H0, the test statistic z = p p n n 1 2 1 2 1 1 0 032 0 03 0 032 0 968 1 500 1 100 − + F HG I KJ = − + F HG I KJ PQ . . ( . )( . ) = 0.104. Conclusion. The calculated value of | z | 1.645, the significant value of z at 5% level of significance, H0 is accepted, i.e., the machine has not improved due to overhauling. Example 3. In two large populations, there are 30% and 25%, respectively, of fair haired people. Is this difference likely to be hidden in samples of 1200 and 900, respectively, from the two populations. Sol. p1 = proportion of fair haired people in the first population = 30% = 0.3; p2 = 25% = 0.25; Q1 = 0.7; Q2 = 0.75. H0: Sample proportions are equal, i.e., the difference in population proportions is likely to be hidden in sampling. H1: p1 ≠ p2 z = P P P Q P Q 2 2 1 2 1 1 1 2 03 0 25 03 07 1200 0 25 075 900 − + = − × + × n n . . . . . . = 2.5376. Conclusion. Since | z | 1.96, the significant value of z at 5% level of significance, H0 is rejected. However | z | 2.58, the significant value of z at 1% level of significance, H0 is accepted. At 5% level, these samples will reveal the difference in the population proportions. Example 4. 500 articles from a factory are examined and found to be 2% defective. 800 similar articles from a second factory are found to have only 1.5% defective. Can it reasonably be concluded that the product of the first factory are inferior to those of second? Sol.n1 = 500, n2 = 800 p1 = proportion of defective from first factory = 2% = 0.02 p2 = proportion of defective from second factory = 1.5% = 0.015 H0: There is no significant difference between the two products, i.e., the products do not differ in quality. H1: p1 p2 (one tailed test) Under H0, z = p p n n 1 2 2 1 − + F HG I KJ PQ 1 1
  • 696. TESTING OF HYPOTHESIS 683 P = n p n p n n 1 1 2 2 1 2 0 02 500 0 015 800 500 800 + + = + + . ( ) ( . )( ) = 0.01692; Q = 1 – P = 0.9830 z = 0 02 0 015 0 01692 0 983 1 500 1 800 . . . . − × + F HG I KJ = 0.68 Conclusion. As | z | 1.645, the significant value of z at 5% level of significance, H0 is accepted i.e., the products do not differ in quality. ASSIGNMENT 8.2 1. A random sample of 400 men and 600 women were asked whether they would like to have a school near their residence. 200 men and 325 women were in favor of the proposal. Test the hypothesis that the proportion of men and women in favor of the proposal are the same at 5% level of significance. 2. In a town A, there were 956 births, of which 52.5% were males while in towns A and B combined, this proportion in total of 1406 births was 0.496. Is there any significant difference in the proportion of male births in the two towns? 3. In a referendum submitted to the student body at a university, 850 men and 560 women voted. 500 men and 320 women voted yes. Does this indicate a significant difference of opinion between men and women on this matter at 1% level? 4. A manufacturing firm claims that its brand A product outsells its brand B product by 8%. If it is found that 42 out of a sample of 200 persons prefer brand A and 18 out of another sample of 100 persons prefer brand B. Test whether the 8% difference is a valid claim. 8.10.3 Testing of Significance for Single Mean To test whether the difference between sample mean and population mean is significant or not. Let X1, X2, ......, Xn be a random sample of size n from a large population X1, X2, ......, XN of size N with mean μ and variance σ2. ∴ the standard error of mean of a random sample of size n from a population with variance σ2 is σ/ n . To test whether the given sample of size n has been drawn from a population with mean μ, i.e. to test whether the difference between the sample mean and the population mean is significant. Under the null hypothesis, there is no difference between the sample mean and population mean. The test statistic is z = x n − μ σ/ , where σ is the standard deviation of the population.
  • 697. 684 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES If σ is not known, we use the test statistic z = X − μ s n / , where s is the standard deviation of the sample. If the level of significance is a and zα is the critical value – zα | z | = x n − μ σ/ zα. The limits of the population mean μ are given by x z n x z n − + α α σ μ σ . At 5% level of significance, 95% confidence limits are x 1.96 n x 1.96 n − + σ μ σ At 1% level of significance, 99% confidence limits are x n x n − + 2 58 2 58 . . σ μ σ . These limits are called confidence limits or fiducial limits. EXAMPLES Example 1. A normal population has a mean of 6.8 and standard deviation of 1.5. A sample of 400 members gave a mean of 6.75. Is the difference significant? Sol.H0: There is no significant difference between x and μ. H1: There is significant difference between x and μ. Given μ = 6.8, σ = 1.5, x = 6.75 and n = 400 | z | = x n − = − μ σ/ . . / 6 75 6 8 900 1.5 = | – 0.67 | = 0.67 Conclusion. As the calculated value of | z | zα = 1.96 at 5% level of significance, H0 is accepted, i.e., there is no significant difference between x and μ. Example 2. A random sample of 900 members has a mean 3.4 cms. Can it be reasonably regarded as a sample from a large population of mean 3.2 cms and standard deviation 2.3 cms? Sol. Here n = 900, x = 3.4, μ = 3.2, σ = 2.3 NOTE
  • 698. TESTING OF HYPOTHESIS 685 H0: Assume that the sample is drawn from a large population with mean 3.2 and standard deviation = 2.3 H1: μ ≠ 3.25 (Apply two-tailed test) Under H0; z = x n − = − μ σ/ . . . / 3 4 3 2 2 3 900 = 0.261. Conclusion. As the calculated value of | z | = 0.261 1.96, the significant value of z at 5% level of significance, H0 is accepted, i.e., the sample is drawn from the population with mean 3.2 and standard deviation = 2.3. Example 3. The mean weight obtained from a random sample of size 100 is 64 gms. The standard deviation of the weight distribution of the population is 3 gms. Test the statement that the mean weight of the population is 67 gms at 5% level of significance. Also set up 99% confidence limits of the mean weight of the population. Sol. Here n = 100, μ = 67, x = 64, σ = 3 H0: There is no significant difference between sample and population mean. i.e., μ = 67, the sample is drawn from the population with μ = 67. H1: μ ≠ 67 (Two-tailed test). Under H0, z = x n − = − μ σ/ / 64 67 3 100 = – 10 ∴ | z | = 10. Conclusion. Since the calculated value of | z | 1.96, the significant value of z at 5% level of significance, H0 is rejected, i.e., the sample is not drawn from the population with mean 67. To find 99% confidence limits, given by x ± 2.58 σ/ n = 64 ± 2.58(3/ 100 ) = 64.774, 63.226. Example 4. The average score in mathematics of a sample of 100 students was 51 with a standard deviation of 6 points. Could this have been a random sample from a population with average scores 50? Sol. Here n = 100, x = 51, s = 6, μ = 50; σ is unknown. H0: The sample is drawn from a population with mean 50, μ = 50 H1: μ ≠ 50 Under H0, z = x s n − = − = μ / / 51 50 6 100 10 6 = 1.6666. Conclusion. Since | z | = 1.666 1.96, zα the significant value of z at 5% level of significance, H0 is accepted, i.e., the sample is drawn from the population with mean 50.
  • 699. 686 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 8.3 1. A sample of 1000 students from a university was taken and their average weight was found to be 112 pounds with a standard deviation of 20 pounds. Could the mean weight of students in the population be 120 pounds? 2. A sample of 400 male students is found to have a mean height of 160 cms. Can it be reasonably regarded as a sample from a large population with mean height 162.5 cms and standard deviation 4.5 cms? 3. A random sample of 200 measurements from a large population gave a mean value of 50 and a standard deviation of 9. Determine 95% confidence interval for the mean of popu- lation. 4. The guaranteed average life of certain type of bulbs is 1000 hours with a standard de- viation of 125 hours. It is decided to sample the output so as to ensure that 90% of the bulbs do not fall short of the guaranteed average by more than 2.5%. What must be the minimum size of the sample? 5. The heights of college students in a city are normally distributed with standard devia- tion 6 cms. A sample of 1000 students has mean height 158 cms. Test the hypothesis that the mean height of college students in the city is 160 cms. 8.10.4 Test of Significance for Difference of Means of Two Large Samples Let x1 be the mean of a sample of size n1 from a population with mean μ1, and variance σ1 2. Let x2 be the mean of an independent sample of size n2 from another population with mean μ2 and variance σ2 2. The test statistic is given by z = x x n n 1 2 1 2 1 2 2 2 − + σ σ . Under the null hypothesis that the samples are drawn from the same population where σ1 = σ2 = σ, i.e., μ1 = μ2 the test statistic is given by z = x x n n 1 2 1 2 1 1 − + σ . 1. If σ1, σ2 are not known and σ1 ≠ σ2 the test statistic in this case is z = x x s s n n 1 2 1 2 2 2 1 2 − + + . NOTE
  • 700. TESTING OF HYPOTHESIS 687 2. If σ is not known and σ1 = σ2. We use σ2 = n s n s n n 1 1 2 2 2 2 1 2 + + to calculate σ; z = x x n s n s n n 1 n 1 n 1 2 1 1 2 2 2 2 1 2 1 2 − + + + F HG I KJ . EXAMPLES Example 1. The average income of persons was 210 with a standard deviation of 10 in a sample of 100 people. For another sample of 150 people, the average income was 220 with a standard deviation of 12. The standard deviation of incomes of the people of the city was 11. Test whether there is any significant difference between the average incomes of the localities. Sol. Here n1 = 100, n2 = 150, x1 = 210, x2 = 220, s1 = 10, s2 = 12. Null hypothesis. The difference is not significant, i.e., there is no difference between the incomes of the localities. H0: x x 1 2 = , H1: x1 ≠ x2 Under H0, z = x x s n s n 1 2 1 2 1 2 2 2 2 2 210 220 10 100 12 150 − + = − + = – 7.1428 ∴ | z | = 7.1428. Conclusion. As the calculated value of | z | 1.96, the significant value of z at 5% level of significance, H0 is rejected i.e., there is significant difference between the average incomes of the localities. Example 2. Intelligence tests were given to two groups of boys and girls. Mean Standard deviation Size Girls 75 8 60 Boys 73 10 100 Examine if the difference between mean scores is significant. Sol. Null hypothesis H0: There is no significant difference between mean scores, i.e., x1 = x2. H1: x1 ≠ x2 Under the null hypothesis z = x x s n s n 1 2 1 2 1 2 2 2 2 2 75 73 8 60 10 100 − + = − + = 1.3912.
  • 701. 688 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Conclusion. As the calculated value of | z | 1.96, the significant value of z at 5% level of significance, H0 is accepted i.e., there is no significant difference between mean scores. ASSIGNMENT 8.4 1. Intelligence tests on two groups of boys and girls gave the following results. Examine if the difference is significant. Mean Standard Deviation Size Girls 70 10 70 Boys 75 11 100 2. Two random samples of 1000 and 2000 farms gave an average yield of 2000 kg and 2050 kg, respectively. The variance of wheat farms in the country may be taken as 100 kg. Examine whether the two samples differ significantly in yield. 3. A sample of heights of 6400 soldiers has a mean of 67.85 inches and a standard devia- tion of 2.56 inches. While another sample of heights of 1600 sailors has a mean of 68.55 inches with standard deviation of 2.52 inches. Do the data indicate that sailors are, on the average, taller than soldiers? 4. In a survey of buying habits, 400 women shoppers are chosen at random in supermarket A. Their average weekly food expenditure is 250 with a standard deviation of 40. For 500 women shoppers chosen at supermarket B, the average weekly food expenditure is 220 with a standard deviation of 45. Test at 1% level of significance whether the aver- age food expenditures of the two groups are equal. 5. A random sample of 200 measurements from a large population gave a mean value of 50 and standard deviation of 9. Determine the 95% confidence interval for the mean of the population. 6. The means of two large samples of 1000 and 2000 members are 168.75 cms and 170 cms, respectively. Can the samples be regarded as drawn from the same population of stand- ard deviation 6.25 cms? 8.10.5 Test of Significance for the Difference of Standard Deviations If s1 and s2 are the standard deviations of two independent samples, then under the null hypothesis H0: σ1 = σ2, i.e., the sample standard deviations don’t differ significantly, the statistic
  • 702. TESTING OF HYPOTHESIS 689 z = s s n n 1 2 1 2 1 2 2 2 2 2 − + σ σ , where σ1 and σ2 are population standard deviations. When population standard deviations are not known, then z = s s s n s n 1 2 1 2 1 2 2 2 2 2 − + . EXAMPLE Example. Random samples drawn from two countries gave the following data relating to the heights of adult males: Country A Country B Mean height (in inches) 67.42 67.25 Standard deviation 2.58 2.50 Number in samples 1000 1200 (i) Is the difference between the means significant? (ii) Is the difference between the standard deviations significant? Sol. Given: n1 = 1000, n2 = 1200, x1 = 67.42; x2 = 67.25, s1 = 2.58, s2 = 2.50 Since the samples size are large we can take σ1 = s1 = 2.58; σ2 = s2 = 2.50. (i) Null hypothesis: H0 = μ1 = μ2 i.e., sample means do not differ significantly. Alternative hypothesis: H1: μ1 ≠ μ2 (two tailed test) z = x x s n s n 1 2 1 2 1 2 2 2 2 2 67 42 67 25 2 58 1000 2 50 1200 − + = − + . . ( . ) ( . ) = 1.56. Since | z | 1.96 we accept the null hypothesis at 5% level of significance. (ii) We set up the null hypothesis. H0: σ1 = σ2 i.e., the sample standard deviations do not differ significantly. Alternative hypothesis: H1 = σ1 ≠ σ2 (two tailed)
  • 703. 690 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ∴ The test statistic is given by z = s s n n s s s n s n 1 2 1 2 1 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 − + = − + σ σ (∵ σ1 = s1, σ2 = s2 for large samples) = 2 58 2 50 2 58 2 1000 2 50 2 1200 0 08 6 6564 2000 6 25 2400 2 2 . . ( . ) ( . ) . . . − × × × = + = 1.0387. Since | z | 1.96 we accept the null hypothesis at 5% level of significance. ASSIGNMENT 8.5 1. The mean yield of two sets of plots and their variability are as given. Examine (i) whether the difference in the mean yield of the two sets of plots is significant. (ii) whether the difference in the variability in yields is significant. Set of 40 plots Set of 60 plots Mean yield per plot 1258 lb 1243 lb Standard deviation per plot 34 28 2. The yield of wheat in a random sample of 1000 farms in a certain area has a standard deviation of 192 kg. Another random sample of 1000 farms gives a standard deviation of 224 kg. Are the standard deviation significantly different ? 8.11 TEST OF SIGNIFICANCE OF SMALL SAMPLES When the size of the sample is less than 30, then the sample is called small sample. For such sample it will not be possible for us to assume that the random sampling distribution of a statistic is approximately normal and the values given by the sample data are sufficiently close to the population values and can be used in their place for the calculation of the standard error of the estimate.
  • 704. TESTING OF HYPOTHESIS 691 t-TEST 8.12 STUDENT’S t-DISTRIBUTION This t-distribution is used when sample size is ≤ 30 and the population standard deviation is unknown. t-statistic is defined as t = x s n − μ / ~ t(n – 1 d. f) d.f–degrees of freedom where s = Σ( ) X X − − 2 1 n . 8.12.1 The t-Table The t-table given at the end is the probability integral of t-distribution. The t-distribution has different values for each degrees of freedom and when the degrees of freedom are infinitely large, the t-distribution is equivalent to normal distribution and the probabilities shown in the normal distribution tables are applicable. 8.12.2 Applications of t-Distribution Some of the applications of t-distribution are given below: 1. To test if the sample mean ( ) X differs significantly from the hypothetical value μ of the population mean. 2. To test the significance between two sample means. 3. To test the significance of observed partial and multiple correlation coeffi- cients. 8.12.3 Critical Value of t The critical value or significant value of t at level of significance α degrees of freedom γ for two tailed test is given by P[| t | tγ (α)] = α P[| t | ≤ tγ (α)] = 1 – α The significant value of t at level of significance α for a single tailed test can be determined from those of two-tailed test by referring to the values at 2α.
  • 705. 692 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 8.13 TEST I: t-TEST OF SIGNIFICANCE OF THE MEAN OF A RANDOM SAMPLE To test whether the mean of a sample drawn from a normal population deviates significantly from a stated value when variance of the population is unknown. H0: There is no significant difference between the sample mean x and the population mean μ, i.e., we use the statistic t = X − μ s n / where X is mean of the sample. s2 = 1 1 1 2 n i n i − − = ∑ ( ) X X with degrees of freedom (n – 1). At a given level of significance α1 and degrees of freedom (n – 1). We refer to t-table tα (two-tailed or one-tailed). If calculated t value is such that | t | tα the null hypothesis is accepted. | t | tα, H0 is rejected. 8.13.1 Fiducial Limits of Population Mean If tα is the table of t at level of significance α at (n – 1) degrees of freedom. X − μ s n / tα for acceptance of H0. x – tα s/ n μ x + tα s/ n 95% confidence limits (level of significance 5%) are X ± t0.05 s n / . 99% confidence limits (level of significance 1%) are X ± t0.01 s n / . Instead of calculating s, we calculate S for the sample. Since s2 = 1 1 1 2 n i n i − − = ∑ ( ) X X ∴ S2 = 1 1 2 n i n i = ∑ − ( ) X X . | ∵ (n – 1)s2 = nS2 NOTE
  • 706. TESTING OF HYPOTHESIS 693 EXAMPLES Example 1. A random sample of size 16 has 53 as mean. The sum of squares of the derivation from mean is 135. Can this sample be regarded as taken from the population having 56 as mean? Obtain 95% and 99% confidence limits of the mean of the population. Sol. H0: There is no significant difference between the sample mean and hypothetical population mean. H0: μ = 56; H1: μ ≠ 56 (Two-tailed test) t: X − μ s n / ~ t(n – 1 difference) Given: X = 53, μ = 56, n = 16, Σ(X X) − 2 = 135 s = Σ( ) X X − − = 2 1 135 15 n = 3; t = 53 56 3 16 − / = – 4 | t | = 4 . d.fv. = 16 – 1 = 15. Conclusion. t0.05 = 1.753. Since | t | = 4 t0.05 = 1.753, the calculated value of t is more than the table value. The hypothesis is rejected. Hence, the sample mean has not come from a population having 56 as mean. 95% confidence limits of the population mean = X ± = ± s n t0.05 53 3 16 (1.725) = 51.706; 54.293 99% confidence limits of the population mean = X ± = ± s n t0 01 53 3 16 . , (2.602) = 51.048; 54.951. Example 2. The lifetime of electric bulbs for a random sample of 10 from a large consignment gave the following data: Item 1 2 3 4 5 6 7 8 9 10 Life in ‘000’ hrs. 4.2 4.6 3.9 4.1 5.2 3.8 3.9 4.3 4.4 5.6 Can we accept the hypothesis that the average lifetime of a bulb is 4000 hrs? Sol. H0: There is no significant difference in the sample mean and population mean. i.e., μ = 4000 hrs.
  • 707. 694 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Applying the t-test: t = X − μ s n / ~ t(10 – 1 difference) X 4.2 4.6 3.9 4.1 5.2 3.8 3.9 4.3 4.4 5.6 X – X – 0.2 0.2 – 0.5 – 0.3 0.8 – 0.6 – 0.5 – 0.1 0 1.2 ( ) X X − 2 0.04 0.04 0.25 0.09 0.64 0.36 0.25 0.01 0 1.44 X = ΣX n = 44 10 = 4.4 Σ(X X)2 − = 3.12 s = Σ(X X)2 − − = n 1 3 12 9 . = 0.589; t = 4 4 4 0 589 10 . . − = 2.123 For γ = 9, t0.05 = 2.26. Conclusion. Since the calculated value of t is less than table t0.05. ∴ The hypothesis μ = 4000 hrs is accepted, i.e., the average lifetime of bulbs could be 4000 hrs. Example 3. A sample of 20 items has mean 42 units and standard deviation 5 units. Test the hypothesis that it is a random sample from a normal population with mean 45 units. Sol. H0: There is no significant difference between the sample mean and the population mean. i.e., μ = 45 units H1: μ ≠ 45 (Two tailed test) Given: n = 20, X = 42, S = 5; γ = 19 difference s2 = n n − = − L NM O QP 1 20 20 1 2 S (5)2 = 26.31 ∴ s = 5.129 Applying t-test t = X − = − μ s n / . / 42 45 5 129 20 = – 2.615; | t | = 2.615 The tabulated value of t at 5% level for 19 d.f. is t0.05 = 2.09. Conclusion. Since | t | t0.05, the hypothesis H0 is rejected, i.e., there is significant difference between the sample mean and population mean. i.e., the sample could not have come from this population. Example 4. The 9 items of a sample have the following values 45, 47, 50, 52, 48, 47, 49, 53, 51. Does the mean of these values differ significantly from the assumed mean 47.5?
  • 708. TESTING OF HYPOTHESIS 695 Sol. H0: μ = 47.5 i.e., there is no significant difference between the sample and population mean. H1: μ ≠ 47.5 (two tailed test); Given: n = 9, μ = 47.5 X 45 47 50 52 48 47 49 53 51 X – X – 4.1 – 2.1 0.9 2.9 – 1.1 – 2.1 – 0.1 3.9 1.9 ( ) X X − 2 16.81 4.41 0.81 8.41 1.21 4.41 0.01 15.21 3.61 X = Σx n = 442 9 = 49.11; Σ(X X)2 − = 54.89; s2 = Σ( ) ( ) X X − − 2 1 n = 6.86 ∴ s = 2.619 Applying t-test t = X − = − μ s n / . . . / 49 1 47 5 2 619 8 = ( ) . 1.6 8 2 619 = 1.7279 t0.05 = 2.31 for γ = 8. Conclusion. Since | t | t0.05, the hypothesis is accepted i.e., there is no significant difference between their mean. ASSIGNMENT 8.6 1. Ten individuals are chosen at random from a normal population of students and their scores found to be 63, 63, 66, 67, 68, 69, 70, 70, 71, 71. In the light of these data discuss the suggestion that mean score of the population of students is 66. 2. The following values gives the lengths of 12 samples of Egyptian cotton taken from a consignment: 48, 46, 49, 46, 52, 45, 43, 47, 47, 46, 45, 50. Test if the mean length of the consignment can be taken as 46. 3. A sample of 18 items has a mean 24 units and standard deviation 3 units. Test the hypothesis that it is a random sample from a normal population with mean 27 units. 4. A filling machine is expected to fill 5 kg of powder into bags. A sample of 10 bags gave the following weights: 4.7, 4.9, 5.0, 5.1, 5.4, 5.2, 4.6, 5.1, 4.6, and 4.7. Test whether the machine is working properly. 8.14 TEST II: t-TEST FOR DIFFERENCE OF MEANS OF TWO SMALL SAMPLES (FROM A NORMAL POPULATION) This test is used to test whether the two samples x1, x2, ......, xn1 , y1, y2, ......, yn2 of sizes n1, n2 have been drawn from two normal populations with mean μ1
  • 709. 696 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES and μ2 respectively, under the assumption that the population variance are equal. (σ1 = σ2 = σ). H0: The samples have been drawn from the normal population with means μ1 and μ2, i.e., H0: μ1 ≠ μ2. Let X , Y be their means of the two samples. Under this H0 the test of statistic t is given by t = (X Y) − + s n n 1 1 1 2 ~ t(n1 + n2 – 2 difference) 1. If the two sample’s standard deviations s1, s2 are given, then we have s2 = n s n s n n 2 1 1 2 2 2 2 1 2 + + − . 2. If n1 = n2 = n, t = X Y s s n 1 1 2 2 2 − + − can be used as a test statistic. 3. If the pairs of values are in some way associated (correlated) we can’t use the test statistic as given in Note 2. In this case, we find the differences of the associated pairs of values and apply for single mean i.e., t = X s/ n − μ with degrees of freedom n – 1. The test statistic is t = d s n / or t = d s n / − 1 , where d is the mean of paired difference. i.e., di = xi – yi di = X Y − , where (xi, yi) are the paired data i = 1, 2, ......, n. NOTE
  • 710. TESTING OF HYPOTHESIS 697 EXAMPLES Example 1. Two samples of sodium vapor bulbs were tested for length of life and the following results were obtained: Size Sample mean Sample S.D. Type I 8 1234 hrs 36 hrs Type II 7 1036 hrs 40 hrs Is the difference in the means significant to generalize that Type I is superior to Type II regarding length of life? Sol. H0: μ1 = μ2 i.e., two types of bulbs have same lifetime. H1: μ1 μ2 i.e., type I is superior to Type II. s2 = n s n s n n 1 1 2 2 2 2 1 2 2 2 2 8 36 7 40 8 7 2 + + − = + + − ( ) ( ) = 1659.076 ∴ s = 40.7317 The t-statistic t = X X 1 2 1 2 1 1 − + s n n = 1234 1036 40 7317 1 8 1 7 − + . = 18.1480 ~ t(n1 + n2 – 2 difference) t0.05 at difference 13 is 1.77 (one tailed test). Conclusion. Since calculated | t | t0.05, H0 is rejected, i.e. H1 is accepted. ∴ Type I is definitely superior to Type II. where X = i n i i n = ∑1 1 X , Y = j n j n = ∑1 2 2 Y ; s2 = 1 2 1 2 2 2 n n i j + − − + − [ ( ) ( ) ] Σ X X Y Y is an unbiased estimate of the population variance σ2. t follows t-distribution with n1 + n2 – 2 degrees of freedom. Example 2. Samples of sizes 10 and 14 were taken from two normal populations with standard deviation 3.5 and 5.2. The sample means were found to be 20.3 and 18.6. Test whether the means of the two populations are the same at 5% level. Sol. H0: μ1 = μ2 i.e., the means of the two populations are the same. H1 : μ1 ≠ μ2.
  • 711. 698 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Given X = 20.3, X2 = 18.6; n1 = 10, n2 = 14, s1 = 3.5, s2 = 5.2 s2 = n s n s n n 1 1 2 2 2 2 1 2 2 2 2 10 3 5 14 5 2 10 14 2 + + − = + + − ( . ) ( . ) = 22.775 ∴ s = 4.772 t = X X 1 1 1 − + = − + F HG I KJ 2 2 1 20 3 18 6 1 10 1 14 4 772 s n n . . . = 0.8604 The value of t at 5% level for 22 difference is t0.05 = 2.0739. Conclusion. Since | t | = 0.8604 t0.05 the hypothesis is accepted, i.e., there is no significant difference between their means. Example 3. The height of 6 randomly chosen sailors in inches is 63, 65, 68, 69, 71, and 72. Those of 9 randomly chosen soldiers are 61, 62, 65, 66, 69, 70, 71, 72, and 73. Test whether the sailors are, on average, taller than soldiers. Sol. Let X1 and X2 be the two samples denoting the heights of sailors and soldiers. Given the sample size n1 = 6, n2 = 9, H0: μ1 = μ2, i.e., the means of both populations are the same. H1: μ1 μ2 (one tailed test) Calculation of two sample means: X1 63 65 68 69 71 72 X1 – X1 – 5 – 3 0 1 3 4 (X X ) 1 1 2 − 25 9 0 1 9 16 X1 = ΣX1 n1 = 68; Σ(X X ) 1 1 2 − = 60 X2 61 62 65 66 69 70 71 72 73 X2 – X2 – 6.66 – 5.66 – 2.66 1.66 1.34 2.34 3.34 4.34 5.34 (X X ) 2 2 2 − 44.36 32.035 7.0756 2.7556 1.7956 5.4756 11.1556 18.8356 28.5156 X2 = ΣX2 n2 = 67.66; Σ(X X ) 2 2 2 − = 152.0002
  • 712. TESTING OF HYPOTHESIS 699 s2 = 1 2 1 2 1 1 2 2 n n + − − + − [ ( ) ( ) ] Σ Σ X X X X 2 2 = 1 6 9 2 + − [60 + 152.0002] = 16.3077 ∴ s = 4.038 Under H0, t = X X 1 2 1 2 1 1 68 67 666 4 0382 1 6 1 9 − + = − + s n n . . = 0.3031 ~ t(n1 + n2 – 2 difference) The value of t at 10% level of significance (∵ the test is one-tailed) for 13 difference is 1.77. Conclusion. Since | t | = 0.3031 t0.05 = 1.77, the hypothesis H0 is accepted. There is no significan difference between their average. The sailors are not, on average, taller than the soldiers. Example 4. A certain stimulus administered to each of 12 patients resulted in the following increase in blood pressure: 5, 2, 8, – 1, 3, 0, – 2, 1, 5, 0, 4, 6. Can it be concluded that the stimulus will in general be accompanied by an increase in blood pressure? Sol. To test whether the mean increase in blood pressure of all patients to whom the stimulus is administered will be positive, we have to assume that this population is normal with mean μ and standard deviation σ which are unknown. H0: μ = 0; H1: μ1 0 The test statistic under H0 t = d s n / − 1 ~ t(n – 1 degrees of freedom) d = 5 2 8 1 3 0 6 2 1 5 0 4 12 + + + − + + + + − + + + + ( ) ( ) = 2.583 s2 = Σd n d 2 2 1 12 − = [52 + 22 + 82 + (– 1)2 + 32 + 02 + 62 + (– 2)2 + 12 + 52 + 02 + 42] – (2.583)2 = 8.744 ∴ s = 2.9571 t = d s n / . . / . . − = − = 1 2583 2 9571 12 1 2583 11 2 9571 = 2.897 ~ t(n – 1 difference)
  • 713. 700 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Conclusion. The tabulated value of t0.05 at 11 difference is 2.2. ∵ | t | t0.05, H0 is rejected. i.e., the stimulus does not increase the blood pressure. The stimulus in general will be accompanied by an increase in blood pressure. Example 5. Memory capacity of 9 students was tested before and after a course of meditation for a month. State whether the course was effective or not from the data below (in same units): Before 10 15 9 3 7 12 16 17 4 After 12 17 8 5 6 11 18 20 3 Sol. Since the data are correlated and concerned with the same set of students we use paired t-test. H0: Training was not effective μ1 = μ2 H1: μ1 ≠ μ2 (Two-tailed test). Before training (X) After training (Y) d = X – Y d2 10 12 – 2 4 15 17 – 2 4 9 8 1 1 3 5 – 2 4 7 6 1 1 12 11 1 1 16 18 – 2 4 17 20 – 3 9 4 3 1 1 Σd = – 7 Σd2 = 29 d = Σd n = − 7 9 = – 0.7778; s2 = Σd n d 2 2 29 9 − = ( ) – (– 0.7778)2 = 2.617 t = d s n / . . / . . − = − = − × 1 07778 2 6172 8 07778 8 16177 = – 1.359 The tabulated value of t0.05 at 8 difference is 2.31. Conclusion. Since | t | = 1.359 t0.05, H0 is accepted, training was not effective in improving performance.
  • 714. TESTING OF HYPOTHESIS 701 Example 6. The following figures refer to observations in live independent samples: Sample I 25 30 28 34 24 20 13 32 22 38 Sample II 40 34 22 20 31 40 30 23 36 17 Analyse whether the samples have been drawn from the populations of equal means. Sol. H0: The two samples have been drawn from the population of equal means, i.e., there is no significant difference between their means i.e., μ1 = μ2 H1: μ1 ≠ μ2 (Two tailed test) Given n1 = Sample I size = 10 ; n2 = Sample II size = 10 To calculate the two sample mean and sum of squares of deviation from mean. Let X1 be the Sample I and X2 be the Sample II. X1 25 30 28 34 24 20 13 32 22 38 X1 – X1 – 1.6 3.4 1.4 7.4 – 2.6 – 6.6 – 13.6 5.4 4.6 11.4 (X X ) 1 1 2 − 2.56 11.56 1.96 54.76 6.76 43.56 184.96 29.16 21.16 129.96 X2 40 34 22 20 31 40 30 23 36 17 X2 – X2 10.7 4.7 – 7.3 – 9.3 1.7 10.7 0.7 – 6.3 6.7 – 12.3 (X X ) 2 2 2 − 114.49 22.09 53.29 86.49 2.89 114.49 0.49 39.67 44.89 151.29 X1 = i n = ∑1 10 1 1 X = 26.6 X2 = i n = ∑ = 1 10 2 2 293 10 X = 29.3 Σ( ) X X 1 1 2 − = 486.4 Σ( ) X X 2 2 2 − = 630.08 s2 = 1 2 1 2 1 1 2 2 2 2 n n + − − + − [ ( ) ( ) ] Σ Σ X X X X = 1 10 10 2 + − [486.4 + 630.08] = 62.026 ∴ s = 7.875
  • 715. 702 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Under H0 the test statistic is given by t = X X 1 2 − + = − + s n n 1 1 26 6 29 3 7 875 1 10 1 10 1 2 . . . = – 0.7666 ~ t(n1 + n2 – 2 difference) | t | = 0.7666. Conclusion. The tabulated value of t at 5% level of significance for 18 difference is 2.1. Since the calculated value | t | = 0.7666 t0.05, H0 is accepted. There is no significant difference between their means. The two samples have been drawn from the populations of equal means. ASSIGNMENT 8.7 1. The mean life of 10 electric motors was found to be 1450 hrs with a standard deviation of 423 hrs. A second sample of 17 motors chosen from a different batch showed a mean life of 1280 hrs with a standard deviation of 398 hrs. Is there a significant difference between means of the two samples ? 2. The scores obtained by a group of 9 regular course students and another group of 11 part time course students in a test are given below: Regular: 56 62 63 54 60 51 67 69 58 Part time: 62 70 71 62 60 56 75 64 72 68 66 Examine whether the scores obtained by regular students and part time students differ significantly at 5% and 1% level of significance. 3. A group of 10 boys fed on diet A and another group of 8 boys fed on a different diet B recorded the following increase in weight (kgs): Diet A: 5 6 8 1 12 4 3 9 6 10 Diet B: 2 3 6 8 10 1 2 8 Does it show the superiority of diet A over the diet B? 4. Two independent samples of sizes 7 and 9 have the following values: Sample A: 10 12 10 13 14 11 10 Sample B: 10 13 15 12 10 14 11 12 11 Test whether the difference between the means is significant. 5. To compare the prices of a certain product in two cities, 10 shops were visited at random in each city. The price was noted below: City 1: 61 63 56 63 56 63 59 56 44 61 City 2: 55 54 47 59 51 61 57 54 64 58 Test whether the average prices can be said to be the same in two cities.
  • 716. TESTING OF HYPOTHESIS 703 6. The average number of articles produced by two machines per day are 200 and 250 with standard deviation 20 and 25 respectively on the basis of records of 25 days production. Are both machines equally efficient at 5% level of significance? 8.15 SNEDECOR’S VARIANCE RATIO TEST OR F-TEST In testing the significance of the difference of two means of two samples, we assumed that the two samples came from the same population or populations with equal variance. The object of the F-test is to discover whether two independent estimates of population variance differ significantly or whether the two samples may be regarded as drawn from the normal populations having the same variance. Hence before applying the t-test for the significance of the difference of two means, we have to test for the equality of population variance by using the F-test. Let n1 and n2 be the sizes of two samples with variance s1 2 and s2 2. The estimate of the population variance based on these samples is s1 2 = n s n 1 1 2 1 1 − and s n s n 2 2 2 2 2 2 1 = − . The degrees of freedom of these estimates are ν1 = n1 – 1, ν2 = n2 – 1. To test whether these estimates, s1 2 and s2 2, are significantly different or if the samples may be regarded as drawn from the same population or from two populations with same variance σ2, we set-up the null hypothesis H0: σ1 2 = σ2 2 = σ2, i.e., the independent estimates of the common population do not differ significantly. To carry out the test of significance of the difference of the variances we calculate the test statistic F = s s 1 2 2 2 , the Numerator is greater than the Denominator, i.e., s1 2 s2 2. Conclusion. If the calculated value of F exceeds F0.05 for (n1 – 1), (n2 – 1) degrees of freedom given in the table, we conclude that the ratio is significant at 5% level. We conclude that the sample could have come from two normal population with same variance. The assumptions on which the F-test is based are: 1. The populations for each sample must be normally distributed. 2. The samples must be random and independent.
  • 717. 704 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 3. The ratio of σ1 2 to σ2 2 should be equal to 1 or greater than 1. That is why we take the larger variance in the Numerator of the ratio. Applications. F-test is used to test (i) whether two independent samples have been drawn from the normal populations with the same variance σ2. (ii) Whether the two independent estimates of the population variance are homogeneous or not. EXAMPLES Example 1. Two random samples drawn from 2 normal populations are as follows: A 17 27 18 25 27 29 13 17 B 16 16 20 27 26 25 21 Test whether the samples are drawn from the same normal population. Sol. To test if two independent samples have been drawn from the same population we have to test (i) equality of the means by applying the t-test and (ii) equality of population variance by applying F-test. Since the t-test assumes that the sample variances are equal, we shall first apply the F-test. F-test. 1. Null hypothesis H0: σ1 2 = σ2 2 i.e., the population variance do not differ significantly. Alternative hypothesis. H1: σ1 2 ≠ σ2 2 Test statistic: F = s s 1 2 2 2 , (if s1 2 s2 2) Computations for s1 2 and s2 2 X1 X1 – X1 (X X ) 1 1 2 − X2 X2 – X2 (X X ) 2 2 2 − 17 – 4.625 21.39 16 – 2.714 7.365 27 5.735 28.89 16 – 2.714 7.365 18 – 3.625 13.14 20 1.286 1.653 25 3.375 11.39 27 8.286 68.657 27 5.735 28.89 26 7.286 53.085 29 7.735 54.39 25 6.286 39.513 13 – 8.625 74.39 21 2.286 5.226 17 – 4.625 21.39
  • 718. TESTING OF HYPOTHESIS 705 X1 = 21.625; n1 = 8; Σ(X X ) 1 1 2 − = 253.87 X2 = 18.714; n2 = 7; Σ(X X ) 2 2 2 − = 182.859 s1 2 = Σ( ) . X X 1 1 2 1 1 253 87 7 − − = n = 36.267; s2 2 = Σ( ) . X X 2 2 2 2 1 182 859 6 − − = n = 30.47 F = s s 1 2 2 2 36 267 30 47 = . . = 1.190. Conclusion. The table value of F for ν1 = 7 and ν2 = 6 degrees of freedom at 5% level is 4.21. The calculated value of F is less than the tabulated value of F. ∴ H0 is accepted. Hence we conclude that the variability in two populations is same. t-test: Null hypothesis. H0: μ1 = μ2 i.e., the population means are equal. Alternative hypothesis. H1: μ1 ≠ μ2 Test of statistic s2 = Σ Σ ( ) ( ) . . X X X X 1 1 2 2 2 2 1 2 2 253 87 182 859 8 7 2 − + − + − = + + − n n = 33.594 ∴ s = 5.796 t = X X 21.625 1 2 1 2 1 1 18 714 5 796 1 8 1 7 − + = − + s n n . . = 0.9704 ~ t(n1 + n2 – 2) difference Conclusion. The tabulated value of t at 5% level of significance for 13 difference is 2.16. The calculated value of t is less than the tabulated value. H0 is accepted, i.e., there is no significant difference between the population mean. i.e., μ1 = μ2. ∴ We conclude that the two samples have been drawn from the same normal population. Example 2. Two independent sample of sizes 7 and 6 had the following values: Sample A 28 30 32 33 31 29 34 Sample B 29 30 30 24 27 28 Examine whether the samples have been drawn from normal populations having the same variance.
  • 719. 706 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. H0: The variance are equal. i.e., σ1 2 = σ2 2 i.e., the samples have been drawn from normal populations with same variance. H1: σ1 2 ≠ σ2 2 Under null hypothesis, the test statistic F = s s 1 2 2 2 (s1 2 s2 2) Computations for s1 2 and s2 2 X1 X1 – X1 (X X ) 1 1 2 − X2 X2 – X2 (X X ) 2 2 2 − 28 – 3 9 29 1 1 30 – 1 1 30 2 4 32 1 1 30 2 4 33 2 4 24 – 4 16 31 0 0 27 – 1 1 29 – 2 4 28 0 0 34 3 9 28 26 X1 = 31, n1 = 7; Σ(X X ) 1 1 2 − = 28 X2 = 28, n2 = 6; Σ(X X ) 2 2 2 − = 26 s1 2 = Σ( ) X X 1 1 2 1 1 28 6 − − = n = 4.666; s2 2 = Σ( ) X X 2 2 2 2 1 26 5 − − = n = 5.2 F = s s 2 2 1 2 5 2 4 666 = . . = 1.1158. (∵ s2 2 s1 2) Conclusion. The tabulated value of F at ν1 = 6 – 1 and ν2 = 7 – 1 difference for 5% level of significance is 4.39. Since the tabulated value of F is less than the calculated value, H0 is accepted, i.e., there is no significant difference between the variance. The samples have been drawn from the normal population with same variance. Example 3. The two random samples reveal the following data: Sample number Size Mean Variance I 16 440 40 II 25 460 42 Test whether the samples come from the same normal population.
  • 720. TESTING OF HYPOTHESIS 707 Sol. A normal population has two parameters namely the mean μ and the variance σ2. To test whether the two independent samples have been drawn from the same normal population, we have to test (i) the equality of means (ii) the equality of variance. Since the t-test assumes that the sample variance are equal, we first apply F-test. F-test: Null hypothesis. σ1 2 = σ2 2 The population variance do not differ significantly. Alternative hypothesis. σ1 2 ≠ σ2 2 Under the null hypothesis the test statistic is given by F = s s 1 2 2 2 , (s1 2 s2 2) Given: n1 = 16, n2 = 25; s1 2 = 40, s2 2 = 42 ∴ F = s s n s n n s n 1 2 2 2 1 1 2 1 2 2 2 2 1 1 = − − = 16 40 15 24 25 42 × × × = 0.9752. Conclusion. The calculated value of F is 0.9752. The tabulated value of F at 16 – 1, 25 – 1 difference for 5% level of significance is 2.11. Since the calculated value is less than that of the tabulated value, H0 is accepted, the population variance are equal. t-test: Null hypothesis. H0: μ1 = μ2 i.e., the population means are equal. Alternative hypothesis. H1: μ1 ≠ μ2 Given: n1 = 16, n2 = 25, X1 = 440, X2 = 460 s2 = n s n s n n 1 1 2 2 2 2 1 2 2 16 40 25 42 16 25 2 + + − = × + × + − = 43.333 ∴ s = 6.582 t = X X 1 2 − + = − + s n n 1 1 440 460 6 582 1 16 1 25 1 2 . = – 9.490 for (n1 + n2 – 2) difference Conclusion. The calculated value of | t | is 9.490. The tabulated value of t at 39 difference for 5% level of significance is 1.96.
  • 721. 708 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Since the calculated value is greater than the tabulated value, H0 is rejected, i.e., there is significant difference between means. i.e., μ1 ≠ μ2. Since there is significant difference between means, and no significant difference between variance, we conclude that the samples do not come from the same normal population. ASSIGNMENT 8.8 1. From the following two sample values, find out whether they have come from the same population: Sample 1 17 27 18 25 27 29 27 23 17 Sample 2 16 16 20 16 20 17 15 21 2. The daily wages in Rupees of skilled workers in two cities are as follows: Size of sample of workers Standard deviation of wages in the sample City A 16 25 City B 13 32 3. The standard deviation calculated from two random samples of sizes 9 and 13 are 2.1 and 1.8 respectively. Can the samples be regarded as drawn from normal populations with the same standard deviation? 4. Two independent samples of size 8 and 9 had the following values of the variables: Sample I 20 30 23 25 21 22 23 24 Sample II 30 31 32 34 35 29 28 27 26 Do the estimates of the population variance differ significantly? 8.16 CHI-SQUARE (χ2) TEST When a coin is tossed 200 times, the theoretical considerations lead us to expect 100 heads and 100 tails. But in practice, these results are rarely achieved. The quantity χ2 (a Greek letter, pronounced as chi-square) describes the magnitude of discrepancy between theory and observation. If χ = 0, the observed and expected frequencies completely coincide. The greater the discrepancy between the observed and expected frequencies, the greater is the value of χ2. Thus χ2 affords a measure of the correspondence between theory and observation.
  • 722. TESTING OF HYPOTHESIS 709 If Oi (i = 1, 2, ......, n) is a set of observed (experimental) frequencies and Ei (i = 1, 2, ......, n) is the corresponding set of expected (theoretical or hypothetical) frequencies, then, χ2 is defined as χ2 = i n i i i = ∑ − L NMM O QPP 1 2 ( ) O E E where ΣOi = ΣEi = N (total frequency) and degrees of freedom (difference) = (n – 1). (i) If χ2 = 0, the observed and theoretical frequencies agree exactly. (ii) If χ2 0 they do not agree exactly. 8.16.1 Degrees of Freedom While comparing the calculated value of χ2 with the table value, we have to determine the degrees of freedom. If we have to choose any four numbers whose sum is 50, we can exercise our independent choice for any three numbers only, the fourth being 50 minus the total of the three numbers selected. Thus, though we were to choose any four numbers, our choice was reduced to three because of one condition imposed. There was only one restraint on our freedom and our degrees of freedom were 4 – 1 = 3. If two restrictions are imposed, our freedom to choose will be further curtailed and degrees of freedom will be 4 – 2 = 2. In general, the number of degrees of freedom is the total number of observations less the number of independent constraints imposed on the observations. Degrees of freedom (difference) are usually denoted by ν (the letter ‘nu’ of the Greek alphabet). Thus, ν = n – k, where k is the number of independent constraints in a set of data of n observations. (i) For a p × q contingency table (p columns and q rows), ν = (p – 1) (q – 1) (ii) In the case of a contingency table, the expected frequency of any class = Total of rows in which it occurs Total of columns in which it occurs Total number of observations × 8.16.2 Applications χ2 test is one of the simplest and the most general test known. It is applicable to a very large number of problems in practice which can be summed up under the following heads: NOTE NOTE
  • 723. 710 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (i) as a test of goodness of fit. (ii) as a test of independence of attributes. (iii) as a test of homogeneity of independent estimates of the population variance. (iv) as a test of the hypothetical value of the population variance s2. (v) as a list to the homogeneity of independent estimates of the population correlation coefficient. 8.16.3 Conditions for Applying χ χ χ χ χ2 Test Following are the conditions which should be satisfied before χ2 test can be applied: (a) N, the total number of frequencies should be large. It is difficult to say what constitutes largeness, but as an arbitrary figure, we may say that N should be atleast 50, however small the number of cells. (b) No theoretical cell-frequency should be small. Here again, it is difficult to say what constitutes smallness, but 5 should be regarded as the very minimum and 10 is better. If small theoretical frequencies occur (i.e., 10), the difficulty is overcome by grouping two or more classes together before calculating (O – E). It is important to remember that the number of degrees of freedom is determined with the number of classes after regrouping. (c) The constraints on the cell frequencies, if any, should be linear. If any one of the theoretical frequency is less than 5, then we apply a corrected given by F Yates, which is usually known as ‘Yates correction for continuity’, we add 0.5 to the cell frequency which is less than 5 and adjust the remaining cell frequency suitably so that the marginal total is not changed. 8.17 THE χ2 DISTRIBUTION For large sample sizes, the sampling distribution of χ2 can be closely approximated by a continuous curve known as the chi-square distribution. The probability function of χ2 distribution is given by f(χ2) = c(χ2)(ν/2–1) e x − 2 2 / where e = 2.71828, ν = number of degrees of freedom; c = a constant depending only on ν. Symbolically, the degrees of freedom are denoted by the symbol ν or by difference and are obtained by the rule ν = n – k, where k refers to the number of independent constraints. NOTE
  • 724. TESTING OF HYPOTHESIS 711 In general, when we fit a binomial distribution the number of degrees of freedom is one less than the number of classes; when we fit a Poisson distribution the degrees of freedom are 2 less than the number of classes, because we use the total frequency and the arithmetic mean to get the parameter of the Poisson distribution. When we fit a normal curve the number of degrees of freedom are 3 less than the number of classes, because in this fitting we use the total frequency, mean and standard deviation. If the data is given in a series of “n” numbers then degrees of freedom = n – 1. In the case of Binomial distribution difference = n – 1 In the case of Poisson distribution difference = n – 2 In the case of Normal distribution difference = n – 3. 8.18 χ2 TEST AS A TEST OF GOODNESS OF FIT χ2 test enables us to ascertain how well the theoretical distributions such as Binomial, Poisson or Normal etc. fit empirical distributions, i.e., distributions obtained from sample data. If the calculated value of χ2 is less than the table value at a specified level (generally 5%) of significance, the fit is considered to be good, i.e., the divergence between actual and expected frequencies is attributed to fluctuations of simple sampling. If the calculated value of χ2 is greater than the table value, the fit is considered to be poor. EXAMPLES Example 1. The following table gives the number of accidents that took place in an industry during various days of the week. Test if accidents are uniformly distributed over the week. Day Mon Tue Wed Thu Fri Sat Number of accidents 14 18 12 11 15 14 Sol. Null hypothesis H0: The accidents are uniformly distributed over the week. Under this H0, the expected frequencies of the accidents on each of these days = 84 6 = 14
  • 725. 712 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Observed frequency Oi 14 18 12 11 15 14 Expected frequency Ei 14 14 14 14 14 14 (Oi – Ei)2 0 16 4 9 1 0 χ2 = Σ( ) O E E i i i − = 2 30 14 = 2.1428. Conclusion. Table value of χ2 at 5% level for (6 – 1 = 5 d.f.) is 11.09. Since the calculated value of χ2 is less than the tabulated value, H0 is accepted, the accidents are uniformly distributed over the week. Example 2. A die is thrown 270 times and the results of these throws are given below: Number appeared on the die 1 2 3 4 5 6 Frequency 40 32 29 59 57 59 Test whether the die is biased or not. Sol. Null hypothesis H0: Die is unbiased. Under this H0, the expected frequencies for each digit is 276 6 = 46. To find the value of χ2 Oi 40 32 29 59 57 59 Ei 46 46 46 46 46 46 (Oi – Ei)2 36 196 289 169 121 169 χ2 = Σ( ) O E E i i i − = 2 980 46 = 21.30. Conclusion. Tabulated value of χ2 at 5% level of significance for (6 – 1 = 5) d.f. is 11.09. Since the calculated value of χ2 = 21.30 11.07 the tabulated value, H0 is rejected. i.e., die is not unbiased or die is biased.
  • 726. TESTING OF HYPOTHESIS 713 Example 3. The following table shows the distribution of digits in numbers chosen at random from a telephone directory: Digits 0 1 2 3 4 5 6 7 8 9 Frequency 1026 1107 997 966 1075 933 1107 972 964 853 Test whether the digits may be taken to occur equally frequently in the directory. Sol. Null hypothesis H0: The digits taken in the directory occur equally frequently. i.e., there is no significant difference between the observed and expected frequency. Under H0, the expected frequency is given by = 10 000 10 , = 1000 To find the value of χ2 Oi 1026 1107 997 996 1075 1107 933 972 964 853 Ei 1000 1000 1000 1000 1000 1000 1107 1000 1000 1000 (Oi – Ei)2 676 11449 9 1156 5625 11449 4489 784 1296 21609 χ2 = Σ( ) O E E i i i − = 2 58542 1000 = 58.542. Conclusion. The tabulated value of χ2 at 5% level of significance for 9 difference is 16.919. Since the calculated value of χ2 is greater than the tabulated value, H0 is rejected. There is significant difference between the observed and theoretical frequency. The digits taken in the directory do not occur equally frequently. Example 4. Records taken of the number of male and female births in 800 families having four children are as follows: Number of male births 0 1 2 3 4 Number of female births 4 3 2 1 0 Number of families 32 178 290 236 94 Test whether the data are consistent with the hypothesis that the Binomial law holds and the chance of male birth is equal to that of female birth, namely p = q = 1/2.
  • 727. 714 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Sol. H0: The data are consistent with the hypothesis of equal probability for male and female births, i.e., p = q = 1/2. We use Binomial distribution to calculate theoretical frequency given by: N(r) = N × P(X = r) where N is the total frequency. N(r) is the number of families with r male children: P(X = r) = nCrprqn–r where p and q are probability of male and female births, n is the number of children. N(0) = Number of families with 0 male children = 800 × 4C0 1 2 4 F HG I KJ = 800 × 1 × 1 24 = 50 N(1) = 800 × 4C1 1 2 1 2 1 3 F HG I KJ F HG I KJ = 200; N(2) = 800 × 4C2 1 2 1 2 2 2 F HG I KJ F HG I KJ = 300 N(3) = 800 × 4C3 1 2 1 2 1 3 F HG I KJ F HG I KJ = 200; N(4) = 800 × 4C4 1 2 1 2 0 4 F HG I KJ F HG I KJ = 50 Observed frequency Oi 32 178 290 236 94 Expected frequency Ei 50 200 300 200 50 (Oi – Ei)2 324 484 100 1296 1936 (O E ) E i i 2 i − 6.48 2.42 0.333 6.48 38.72 χ2 = Σ( ) O E E i i i − 2 = 54.433. Conclusion. Table value of χ2 at 5% level of significance for 5 – 1 = 4 difference is 9.49. Since the calculated value of χ2 is greater than the tabulated value, H0 is rejected.
  • 728. TESTING OF HYPOTHESIS 715 The data are not consistent with the hypothesis that the Binomial law holds and that the chance of a male birth is not equal to that of a female birth. Since the fitting is Binomial, the degrees of freedom ν = n – 1 i.e., ν = 5 – 1 = 4. Example 5. Verify whether Poisson distribution can be assumed from the data given below: Number of defects 0 1 2 3 4 5 Frequency 6 13 13 8 4 3 Sol. H0: Poisson fit is a good fit to the data. Mean of the given distribution = Σ Σ f x f i i i = 94 47 = 2 To fit a Poisson distribution we require m. Parameter m = x = 2. By Poisson distribution the frequency of r success is N(r) = N × e–m . m r r ! , N is the total frequency. N(0) = 47 × e–2 . ( ) ! 2 0 0 = 6.36 ≈ 6; N(1) = 47 × e–2 . ( ) ! 2 1 1 = 12.72 ≈ 13 N(2) = 47 × e–2 . ( ) ! 2 2 2 = 12.72 ≈ 13; N(3) = 47 × e–2 . ( ) ! 2 3 3 = 8.48 ≈ 9 N(4) = 47 × e–2 . ( ) ! 2 4 4 = 4.24 ≈ 4; N(5) = 47 × e–2 . ( ) ! 2 5 5 = 1.696 ≈ 2. X 0 1 2 3 4 5 Oi 6 13 13 8 4 3 Ei 6.36 12.72 12.72 8.48 4.24 1.696 (O E ) E i i 2 i − 0.2037 0.00616 0.00616 0.02716 0.0135 1.0026 χ2 = Σ( ) O E E i i i − 2 = 1.2864. NOTE
  • 729. 716 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Conclusion. The calculated value of χ2 is 1.2864. Tabulated value of χ2 at 5% level of significance for γ = 6 – 2 = 4 d.f. is 9.49. Since the calculated value of χ2 is less than that of tabulated value. H0 is accepted i.e., Poisson distribution provides a good fit to the data. Example 6. The theory predicts the proportion of beans in the four groups, G1, G2, G3, G4 should be in the ratio 9: 3: 3: 1. In an experiment with 1600 beans the numbers in the four groups were 882, 313, 287 and 118. Does the experimental result support the theory. Sol. H0: The experimental result support the theory. i.e., there is no significant difference between the observed and theoretical frequency under H0, the theoretical frequency can be calculated as follows: E(G1) = 1600 9 16 × = 900; E(G2) = 1600 3 16 × = 300; E(G3) = 1600 3 16 × = 300; E(G4) = 1600 1 16 × = 100 To calculate the value of χ2. Observed frequency Oi 882 313 287 118 Expected frequency Ei 900 300 300 100 (O E ) E i i 2 i − 0.36 0.5633 0.5633 3.24 χ2 = Σ( ) O E E i i i − 2 = 4.7266. Conclusion. The table value of χ2 at 5% level of significance for 3 difference is 7.815. Since the calculated value of χ2 is less than that of the tabulated value. Hence H0 is accepted and the experimental results support the theory. ASSIGNMENT 8.9 1. The following table gives the frequency of occupance of the digits 0, 1, ......, 9 in the last place in four logarithm of numbers 10–99. Examine if there is any peculiarity. Digits: 0 1 2 3 4 5 6 7 8 9 Frequency: 6 16 15 10 12 12 3 2 9 5 2. The sales in a supermarket during a week are given below. Test the hypothesis that the sales do not depend on the day of the week, using a significant level of 0.05. Days: Mon Tues Wed Thurs Fri Sat Sales: 65 54 60 56 71 84
  • 730. TESTING OF HYPOTHESIS 717 3. A survey of 320 families with 5 children each revealed the following information: Number of boys: 5 4 3 2 1 0 Number of girls: 0 1 2 3 4 5 Number of families: 14 56 110 88 40 12 Is this result consistent with the hypothesis that male and female births are equally probable? 4. 4 coins were tossed at a time and this operation is repeated 160 times. It is found that 4 heads occur 6 times, 3 heads occur 43 times, 2 heads occur 69 times, one head occurs 34 times. Discuss whether the coin may be regarded as unbiased? 5. Fit a Poisson distribution to the following data and best the goodness of fit: x: 0 1 2 3 4 f : 109 65 22 3 1 6. In the accounting department of bank, 100 accounts are selected at random and esti- mated for errors. The following results were obtained: Number of errors: 0 1 2 3 4 5 6 Number of accounts: 35 40 19 2 0 2 2 Does this information verify that the errors are distributed according to the Poisson probability law? 7. In a sample analysis of examination results of 500 students, it was found that 180 students failed, 170 secured a third class, 90 secured a second class and the rest, a first class. Do these figures support the general belief that the above categories are in the ratio 4:3:2:1, respectively? 8. What is χ2–test? A die is thrown 90 times with the following results: Face: 1 2 3 4 5 6 Total Frequency: 10 12 16 14 18 20 90 Use χ2-test to test whether these data are consistent with the hypothesis that die is unbiased. Given χ2 0.05 = 11.07 for 5 degrees of freedom. 9. A survey of 320 families with 5 children shows the following distribution: Number of boys 5 boys 4 boys 3 boys 2 boys 1 boy 0 boy Total girls: 0 girl 1 girl 2 girls 3 girls 4 girls 5 girls Number of families: 18 56 110 88 40 8 320 Given that values of χ2 for 5 degrees of freedom are 11.1 and 15.1 at 0.05 and 0.01 significance level respectively, test the hypothesis that male and female births are equally probable.
  • 731. 718 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 8.19 χ2 TEST AS A TEST OF INDEPENDENCE With the help of χ2 test, we can find whether or not two attributes are associated. We take the null hypothesis that there is no association between the attributes under study, i.e., we assume that the two attributes are independent. If the calculated value of χ2 is less than the table value at a specified level (generally 5%) of significance, the hypothesis holds good, i.e., the attributes are independent and do not bear any association. On the other hand, if the calculated value of χ2 is greater than the table value at a specified level of significance, we say that the results of the experiment do not support the hypothesis. In other words, the attributes are associated. Thus a very useful application of χ2 test is to investigate the relationship between trials or attributes which can be classified into two or more categories. The sample data set out into two-way table, called contingency table. Let us consider two attributes A and B divided into r classes A1, A2, A3, ......, Ar , and B divided into s classes B1, B2, B3, ......, Bs. If (Ai), (Bj) represents the number of persons possessing the attributes Ai, Bj respectively, (i = 1, 2, ......, r, j = 1, 2, ......, s) and (Ai Bj) represent the number of persons possessing attributes Ai and Bj. Also we have i r i j s j = = ∑ ∑ = 1 1 A B = N where N is the total frequency. The contingency table for r × s is given below: A A1 A2 A3 ...Ar Total B B1 (A1B1) (A2B1) (A3B1) ......(ArB1) B1 B2 (A1B2) (A2B2) (A3B2) ......(ArB2) B2 B3 (A1B3) (A2B3) (A3B3) ......(ArB3) B3 ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... Bs (A1Bs) (A2Bs) (A3Bs) ......(ArBs) (Bs) Total (A1) (A2) (A3) ......(Ar) N H0: Both the attributes are independent. i.e., A and B are independent under the null hypothesis, we calculate the expected frequency as follows: P(Ai) = Probability that a person possesses the attribute Ai = ( ) A N i i = 1, 2, ......, r P(Bj) = Probability that a person possesses the attribute Bj = ( ) B N j
  • 732. TESTING OF HYPOTHESIS 719 P(AiBj) = Probability that a person possesses both attributes Ai and Bj = ( ) A B N i j If (AiBj)0 is the expected number of persons possessing both the attributes Ai and Bj (AiBj)0 = NP(AiBj) = NP(Ai)(Bj) = N ( ) ( ) ( )( ) A N B N A B N i j i j = (∵ A and B are independent) Hence χ2 = i r j s i j i j i j = = ∑ ∑ − L N MM O Q PP 1 1 0 2 0 [( ) ( ) ] ( ) A B A B A B which is distributed as a χ2 variate with (r – 1)(s – 1) degrees of freedom. 1. For a 2 × 2 contingency table where the frequencies are a b c d / / , χ2 can be calculated from independent frequencies as χ2 = (a b c d)(ad bc) (a b)(c d)(b d)(a c) 2 + + + − + + + + . 2. If the contingency table is not 2 × 2, then the formula for calculating χ2 as given in Note 1, can’t be used. Hence, we have another formula for calculating the expected frequency (AiBj)0 = (A )(B ) N i j i.e., expected frequency in each cell is = Product of column total and row total whole total . 3. If a b c d | | is the 2 × 2 contingency table with two attributes, Q = ad bc ad bc − + is called the coefficient of association. If the attributes are independent then a b c d = . 4. Yates’s Correction. In a 2 × 2 table, if the frequencies of a cell is small, we make Yates’s correction to make χ2 continuous. Decrease by 1 2 those cell frequencies which are greater than expected frequencies, and increase by 1 2 those which are less than expectation. This will not affect the marginal columns. This correction is known as Yates’s correction to continuity. NOTE
  • 733. 720 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES After Yates’s correction χ2 = N bc ad 1 2 N (a c)(b d)(c d)(a b) 2 − − F HG I KJ + + + + when ad – bc 0 χ2 = N ad bc 1 2 N (a c)(b d)(c d)(a b) 2 − − F HG I KJ + + + + when ad – bc 0. EXAMPLES Example 1. What are the expected frequencies of 2 × 2 contingency tables given below: a b 2 10 (i) (ii) c d 6 6 Sol. Observed frequencies Expected frequencies (i) a b a + b ( )( ) a c a b a b c d + + + + + ( )( ) b d a b a b c d + + + + + c d c + d a + c b + d a + b + c + d = N ( )( ) a c c d a b c d + + + + + ( )( ) b d c d a b c d + + + + + Observed frequencies Expected frequencies (ii) 2 10 12 8 12 24 × = 4 16 12 24 × = 8 6 6 12 8 16 24 8 12 24 × = 4 16 12 24 × = 8 Example 2. From the following table regarding the color of eyes of father and son test if the color of son’s eye is associated with that of the father. Eye color of son Light Not light Eye color of father Light 471 51 Not light 148 230 →
  • 734. TESTING OF HYPOTHESIS 721 Sol. Null hypothesis H0: The color of son’s eye is not associated with that of the father, i.e., they are independent. Under H0, we calculate the expected frequency in each cell as = Product of column total and row total Whole total Expected frequencies are: Eye color of son Light Not light Total Eye color of father Light 619 522 900 × = 359.02 289 522 900 × = 167.62 522 Not light 619 378 900 × = 259.98 289 378 900 × = 121.38 378 Total 619 289 900 χ2 = (471 359.02) 359.02 (51 167.62) 167.62 (148 259.98) 259.98 (230 121.38) 121.38 2 2 2 2 − + − + − + − = 261.498. Conclusion. Tabulated value of χ2 at 5% level for 1 difference is 3.841. Since the calculated value of χ2 tabulated value of χ2, H0 is rejected. They are dependent, i.e., the color of son’s eye is associated with that of the father. Example 3. The following table gives the number of good and bad parts produced by each of the three shifts in a factory: Good parts Bad parts Total Day shift 960 40 1000 Evening shift 940 50 990 Night shift 950 45 995 Total 2850 135 2985 Test whether or not the production of bad parts is independent of the shift on which they were produced. Sol. Null hypothesis H0: The production of bad parts is independent of the shift on which they were produced. The two attributes, production and shifts are independent.
  • 735. 722 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Under H0, χ2 = i j i j i j i j = = ∑ ∑ − L N MM O Q PP 1 2 1 3 0 2 0 [( ) ( )] ( ) A B A B A B Calculation of expected frequencies Let A and B be the two attributes namely production and shifts. A is divided into two classes A1, A2 and B is divided into three classes B1, B2, B3. (A1B1)0 = ( )( ) ( ) ( ) A B N 1 2 2850 1000 2985 = × = 954.77; (A1B2)0 = ( )( ) ( ) ( ) A B N 1 2 2850 990 2985 = × = 945.226 (A1B3)0 = ( )( ) ( ) ( ) A B N 1 3 2850 995 2985 = × = 950; (A2B1)0 = ( )( ) ( ) ( ) A B N 2 1 135 1000 2985 = × = 45.27 (A2B2)0 = ( )( ) ( ) ( ) A B N 2 2 135 990 2985 = × = 44.773; (A2B3)0 = ( )( ) ( ) ( ) A B N 2 3 135 995 2985 = × = 45. To calculate the value of χ2 Class Oi Ei (Oi – Ei)2 (Oi – Ei)2/Ei (A1B1) 960 954.77 27.3529 0.02864 (A1B2) 940 945.226 27.3110 0.02889 (A1B3) 950 950 0 0 (A2B1) 40 45.27 27.7729 0.61349 (A2B2) 50 44.773 27.3215 0.61022 (A2B3) 45 45 0 0 1.28126 Conclusion. The tabulated value of χ2 at 5% level of significance for 2 degrees of freedom (r – 1)(s – 1) is 5.991. Since the calculated value of χ2 is less than the tabulated value, we accept H0, i.e., the production of bad parts is independent of the shift on which they were produced.
  • 736. TESTING OF HYPOTHESIS 723 ASSIGNMENT 8.10 1. In a locality 100 persons were randomly selected and asked about their educational achievements. The results are given below: Education Middle High school College Sex Male 10 15 25 Female 25 10 15 Based on this information can you say the education depends on sex. 2. The following data is collected on two characters: Smokers Non smokers Literate 83 57 Illiterate 45 68 Based on this information can you say that there is no relation between habit of smok- ing and literacy. 3. In an experiment on the immunisation of goats from anthrax, the following results were obtained. Derive your inferences on the efficiency of the vaccine. Died anthrax Survived Inoculated with vaccine 2 10 Not inoculated 6 6
  • 737. 724 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES TABLE 1: Significant values tv (α α α α α) of t-distribution (Two Tail Areas) [| t | tv(α)] = α difference Probability (Level of significance) (ν) 0.50 0.10 0.05 0.02 0.01 0.001 1 1.00 6.31 12.71 31.82 63.66 636.62 2 0.82 0.92 4.30 6.97 6.93 31.60 3 0.77 2.32 3.18 4.54 5.84 12.94 4 0.74 2.13 2.78 3.75 4.60 8.61 5 0.73 2.02 2.57 3.37 4.03 6.86 6 0.72 1.94 2.45 3.14 3.71 5.96 7 0.71 1.90 2.37 3.00 3.50 5.41 8 0.71 1.80 2.31 2.90 3.36 5.04 9 0.70 1.83 2.26 2.82 3.25 4.78 10 0.70 1.81 2.23 2.76 3.17 4.59 11 0.70 1.80 2.20 2.72 3.11 4.44 12 0.70 1.78 2.18 2.68 3.06 4.32 13 0.69 1.77 2.16 2.65 3.01 4.22 14 0.69 1.76 2.15 2.62 2.98 4.14 15 0.69 1.75 2.13 2.60 2.95 4.07 16 0.69 1.75 2.12 2.58 2.92 4.02 17 0.69 1.74 2.11 2.57 2.90 3.97 18 0.69 1.73 2.10 2.55 2.88 3.92 19 0.69 1.73 2.09 2.54 2.86 3.88 20 0.69 1.73 2.09 2.53 2.85 3.85 21 0.69 1.72 2.08 2.52 2.83 3.83 22 0.69 1.72 2.07 2.51 2.82 3.79 23 0.69 1.71 2.07 2.50 2.81 3.77 24 0.69 1.71 2.06 2.49 2.80 3.75 25 0.68 1.71 2.06 2.49 2.79 3.73 26 0.68 1.71 2.06 2.48 2.78 3.71 27 0.68 1.70 2.05 2.47 2.77 3.69 28 0.68 1.70 2.05 2.47 2.76 3.67 29 0.68 1.70 2.05 2.46 2.76 3.66 30 0.68 1.70 2.04 2.46 2.75 3.65 ∞ 0.67 1.65 1.96 2.33 2.58 3.29
  • 738. TESTING OF HYPOTHESIS 725 Degrees of freedom for numerator 1 2 3 4 5 6 7 8 9 10 12 15 20 24 20 40 60 120 ∞ 1 161 200 216 225 230 234 237 239 241 242 244 246 248 249 250 251 252 253 254 2 18.5 19.0 19.2 19.2 19.3 19.3 19.4 19.4 19.4 19.4 19.4 19.4 19.4 19.5 19.5 19.5 19.5 19.5 19.5 3 10.1 9.55 9.28 9.12 9.01 9.94 8.89 8.85 8.81 8.79 8.74 8.70 8.66 8.64 8.62 8.59 8.57 8.55 8.53 4 7.71 6.94 6.59 6.39 6.26 6.16 6.09 6.04 6.00 5.96 5.91 5.86 5.80 5.77 5.75 5.72 5.69 6.66 5.63 5 6.61 5.79 5.41 5.19 5.05 4.95 4.88 4.82 4.77 4.74 4.68 4.62 4.56 4.53 4.50 4.46 4.43 4.40 4.37 6 5.99 5.14 4.76 4.53 4.39 4.28 4.21 4.15 4.10 4.06 4.00 3.94 3.87 3.84 3.81 3.77 3.74 3.70 3.67 7 5.59 4.74 4.35 4.12 3.97 3.87 3.79 3.73 3.68 3.64 3.57 3.51 3.44 3.41 3.38 3.34 3.30 3.27 3.23 8 5.32 4.46 4.07 3.84 3.69 3.58 3.50 3.44 3.39 3.35 3.28 3.22 3.15 3.12 3.08 3.04 3.01 2.97 2.93 9 5.12 4.26 3.86 3.63 3.48 3.37 3.29 3.23 3.18 3.14 3.07 3.01 2.94 2.90 2.86 2.83 2.79 2.75 2.71 10 4.96 4.10 3.71 3.48 3.33 3.22 3.14 3.07 3.02 2.98 2.91 2.85 2.77 2.74 2.70 2.66 2.62 2.58 2.54 11 4.84 3.98 3.59 3.36 3.20 3.09 3.01 2.95 2.90 2.85 2.79 2.72 2.65 2.61 2.57 2.53 2.49 2.45 2.40 12 4.75 3.89 3.49 3.26 3.11 3.00 2.91 2.85 2.80 2.75 2.69 2.62 2.54 2.51 2.47 2.43 2.38 2.34 2.30 13 4.67 3.81 3.41 3.18 3.03 2.92 2.83 2.77 2.71 2.67 2.60 2.53 2.46 2.42 2.38 2.34 2.30 2.25 2.21 14 4.60 3.74 3.34 3.11 3.96 2.85 2.76 2.70 2.65 2.60 2.53 2.46 2.39 2.35 2.31 2.27 2.22 2.18 2.13 15 4.54 3.68 3.29 3.06 3.90 2.79 2.71 2.64 2.59 2.54 2.48 2.40 2.33 2.29 2.25 2.20 2.16 2.11 2.07 16 4.49 3.63 3.24 3.01 2.85 2.74 2.66 2.59 2.54 2.49 2.42 2.35 2.28 2.24 2.19 2.15 2.11 2.06 2.01 17 4.45 3.59 3.20 2.96 2.81 2.70 2.61 2.55 2.49 2.45 2.38 2.31 2.23 2.19 2.15 2.10 2.06 2.01 1.96 18 4.41 3.55 3.16 2.93 2.77 2.66 2.58 2.51 2.46 2.41 2.34 2.27 2.19 2.15 2.11 2.06 2.02 1.97 1.92 TABLE 2: F-Distribution Values of F for F-Distributions with 0.05 of the Area in The Right Tall
  • 739. 726 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 19 4.38 3.52 3.13 2.90 2.74 2.63 2.54 2.48 2.42 2.38 2.31 2.23 2.16 2.11 2.07 2.03 1.98 1.93 1.88 20 4.35 3.49 3.10 2.87 2.17 2.60 2.51 2.45 2.39 2.35 2.28 2.20 2.12 2.08 2.04 1.99 1.95 1.90 1.84 21 4.32 3.47 3.07 2.84 2.68 2.57 2.49 2.42 2.37 2.32 2.25 2.18 2.10 2.05 2.01 1.96 1.92 1.87 1.81 22 4.30 3.44 3.05 2.82 2.66 2.55 2.46 2.40 2.34 2.30 2.23 2.15 2.07 2.03 1.98 1.94 1.89 1.84 1.78 23 4.28 3.42 3.03 2.80 2.64 2.53 2.44 2.37 2.32 2.27 2.20 2.13 2.05 2.01 1.96 1.91 1.86 1.81 1.76 24 4.26 3.40 3.01 2.78 2.62 2.51 2.42 2.36 2.30 2.25 2.18 2.11 2.03 1.98 1.94 1.98 1.84 1.79 1.73 25 4.24 3.39 2.99 2.76 2.60 2.94 2.40 2.34 2.28 2.24 2.16 2.29 2.01 1.96 1.92 1.87 1.82 1.77 1.71 30 4.17 3.32 2.92 2.69 2.53 2.42 2.33 2.27 2.21 2.16 2.09 2.01 1.93 1.89 1.84 1.79 1.74 1.64 1.62 40 4.08 3.23 2.84 2.61 2.45 2.34 2.25 2.18 2.12 2.08 2.00 1.92 1.84 1.79 1.74 1.69 1.64 1.58 1.51 60 4.00 3.15 2.76 2.53 2.37 2.25 2.17 2.10 2.04 1.99 1.92 1.84 1.75 1.70 1.65 1.59 1.53 1.47 1.39 120 3.92 3.07 2.68 2.45 2.29 2.18 2.09 2.02 1.96 1.91 1.83 1.75 1.66 1.61 1.55 1.50 1.43 1.35 1.25 ∞ 3.84 3.00 2.60 2.37 2.21 2.10 2.01 1.94 1.88 1.83 1.75 1.67 1.57 1.52 1.46 1.39 1.32 1.22 1.00
  • 740. TESTING OF HYPOTHESIS 727 TABLE 3: CHI-SQUARE DISTRIBUTION Significant Values χ2 (α) of Chi-Square Distribution Right Tail Areas for Given Probability α, P = Pr (χ2 χ2 (α)) = α And ν Degrees of Freedom (difference) Degrees Probability (Level of significance) of freedom (ν) 0 = .99 0.95 0.50 0.10 0.05 0.02 0.01 1 .000157 .00393 .455 2.706 3.841 5.214 6.635 2 .0201 .103 1.386 4.605 5.991 7.824 9.210 3 .115 .352 2.366 6.251 7.815 9.837 11.341 4 .297 .711 3.357 7.779 9.488 11.668 13.277 5 .554 1.145 4.351 9.236 11.070 13.388 15.086 6 .872 2.635 5.348 10.645 12.592 15.033 16.812 7 .1.239 2.167 6.346 12.017 14.067 16.622 18.475 8 3.646 2.733 7.344 13.362 15.507 18.168 20.090 9 2.088 3.325 8.343 14.684 16.919 19.679 21.669 10 2.558 3.940 9.340 15.987 18.307 21.161 23.209 11 3.053 4.575 10.341 17.275 19.675 22.618 24.725 12 3.571 5.226 11.340 18.549 21.026 24.054 26.217 13 4.107 5.892 12.340 19.812 22.362 25.472 27.688 14 4.660 6.571 13.339 21.064 23.685 26.873 29.141 15 4.229 7.261 14.339 22.307 24.996 28.259 30.578 16 5.812 7.962 15.338 23.542 26.296 29.633 32.000 17 6.408 8.672 15.338 24.769 27.587 30.995 33.409 18 7.015 9.390 17.338 25.989 28.869 32.346 34.805 19 7.633 10.117 18.338 27.204 30.144 33.687 36.191 20 8.260 10.851 19.337 28.412 31.410 35.020 37.566 21 8.897 11.591 20.337 29.615 32.671 36.343 38.932 22 9.542 12.338 21.337 30.813 33.924 37.659 40.289 23 10.196 13.091 22.337 32.007 35.172 38.968 41.638 24 10.856 13.848 23.337 32.196 36.415 40.270 42.980 25 11.524 14.611 24.337 34.382 37.65 41.566 44.314 26 12.198 15.379 25.336 35.363 38.885 41.856 45.642 27 12.879 16.151 26.336 36.741 40.113 41.140 46.963 28 13.565 16.928 27.336 37.916 41.337 45.419 48.278 29 14.256 17.708 28.336 39.087 42.557 46.693 49.588 30 14.933 18.493 29.336 40.256 43.773 47.962 50.892 For degrees of freedom (ν) greater than 30, the quantity 2 2 1 2 χ ν − − may be used as a normal variate with unit variance. NOTE
  • 744. APPENDIX A ANSWERS TO SELECTED EXERCISES 731 ASSIGNMENT 1.1 5. printf (“the given value is %f”, 22.23); 7. x = 10.0 Sum = 1 + 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 + + + + + + + . 19. 3 ASSIGNMENT 2.1 1. 3.264, 35.47, 4986000, 0.7004, 0.0003222, 1.658, 30.06, 0.8594, 3.142. 3. 0.0005 5. 48.21, 2.37, 52.28, 2.38, 2.38, 81.26 7. (i) 0.004, 0.0015772 (ii) 0.006, 0.0023659 9. (34.5588, 35.9694)
  • 745. 732 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 2.2 3. 0.00355, 0.0089 5. 12 7. q = 3.43636, er = 0.020857 ASSIGNMENT 2.3 1. .4485 E 8 7. .1010 E 1, .1012 E 1; correct value = .1012034 E 1 9. (i) x = – .3217 E 2, y = .1666 E 2; yes (ii) x = – .2352 E 2, y = .1250 E 2. 11. .168 × 103. ASSIGNMENT 3.1 1. (i) x: – 4 – 3 – 2 – 1 0 1 2 3 4 f(x): 1.0625 .125 – .75 – 1.5 – 2 – 2 – 1 2 9 Roots lie in (– 3, – 2) and (2, 3). (ii) 1.7281 in interval (1, 2). 3. 0.111 5. 2.02875625 7. 4.712389 9. 2.374 11. .56714333 13. (i) – 2.1048 (ii) 2.621 (iii) .682 (iv) .657, 1.834 15. .322 17. 0.39188 19. 2.94282 21. (i) (– 3, – 2) (ii) Root lies in the interval (– 2.5, – 2.25) ASSIGNMENT 3.2 1. 0.0912 3. (i) 2.9353 (ii) – .420365 (iii) 1.83928 (iv) – .682327803 (v) 2.690647448 (vi) 2.594313016 5. 5.4772 7. 0.10260
  • 746. ANSWERS TO SELECTED EXERCISES 733 ASSIGNMENT 3.3 1. 2.942821 3. 1.875 7. (i) 1.860, .2541 (ii) 1.69562 (iii) 1.2134 (iv) 2.7473 13. – 1.25115 and 0.55000 ASSIGNMENT 3.4 3. 0.5177573637 ASSIGNMENT 3.5 1. x2 – 2.40402 + 3.0927 3. x2 + 1.94184x + 1.95685 ASSIGNMENT 3.6 1. (i) 1.324 (ii) 1.839286755 3. (i) 2.279 (ii) 3.20056 (iii) .76759 ASSIGNMENT 3.7 1. 5.12487, 1.63668, 0.23845 ASSIGNMENT 3.8 1. (i) 2.7698 (ii) 2.231 (iii) 3.107 ASSIGNMENT 3.9 1. 1.856 3. (i) 2.094568 (ii) 2.279 5. (i) 0.511 (ii) 0.657 (iii) 2.908 (iv) – 2.533 (v) 1.171 (vi) .739 (vii) 1.896 (viii) 1.756 (ix) 4.4934
  • 747. 734 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 9. 4.9324 11. 1.442 13. (a) 5.099 (b) 5.384 (c) 5.916 15. p = 5 9 , q = 5 9 , r = – 1 9 ; Third order 17. Roots lie in (0, 1) and (1, 2); 0.100336, 1.679631 19. 0.298 21. – 0.5081 ASSIGNMENT 3.10 1. (iii) Newton-Raphson method since it deals with multiple roots as well. ASSIGNMENT 3.11 1. (i) 2, 1, 1 (ii) 2.556, 2.861, 0.8203 (iii) 1.3247, – .6624 ± .5622i ASSIGNMENT 3.12 1. .56704980 3. 1, 0, 1.0, 0.5, .66666, .75000, .666666, .666666, .69230769 ASSIGNMENT 4.1 1. 239, 371 9. (i) 3x2 – 3x + 1 (ii) 6x ASSIGNMENT 4.2 1. 16.1, 2x is not a polynomial 3. 0.4147 5. 27, 125 ASSIGNMENT 4.3 1. 244
  • 748. ANSWERS TO SELECTED EXERCISES 735 ASSIGNMENT 4.4 1. 15.6993 nautical miles 3. 43.704 5. 0.23589625 7. 51 9. (a) 27 (b) 27 11. 0.1205 ASSIGNMENT 4.5 1. 0.3057 3. 15.47996 5. 421.875 7. 0.783172 9. 219 11. 6.36, 11.02 ASSIGNMENT 4.6 1. 19.407426 3. 2290.0017 5. .046 ASSIGNMENT 4.7 1. 22898 3. 1.2662 5. 0.70696 ASSIGNMENT 4.8 1. 0.9391002 3. 0.19573 5. 0.32495 ASSIGNMENT 4.9 1. 0.496798 3. 7957.1407 5. 1.904082 7. 3250.875
  • 749. 736 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 4.10 1. 3.3756 3. 4913, 5052, 5185, 5315 5. 3250.875 7. 14.620947 9. 19523.5, 215914 11. 3.7084096, 3.7325079, 3.7563005, 3.7797956 13. 1.904082 15. 6.7531 ASSIGNMENT 4.11 1. 37.8, 73; 2x is not a polynomial 3. (i) 100.99999 (ii) 25 5. 0.64942084 7. 1294.8437 9. x4 – 3x3 + 5x2 – 6 11. 12.45 13. 53 17. 2.4786 19. x5 – 9x4 + 18x3 – x2 + 9x – 18 ASSIGNMENT 4.12 1. 810 3. 521 5. 328 7. (x – 1)3 + 2(x – 1)2 + 4(x – 1) + 11 9. 1 2 1 1 2 1 2 1 ( ) ( ) x x x − + − − + 11. 2.49136 13. 10. ASSIGNMENT 4.13 1. f(x) = 2x4 – x2 + x + 1, 11 8 , 3 8 . 3. 1 2 (5x3 – 3x5). 5. 0.86742375. 7. (1 + 3x) (1 – x)2 + (2 – x)ex2; 1.644; 1.859. 9. 1.02470. 11. 0.993252. 13. (i) 29.556 x3 – 85.793 x2 + 97.696 x – 34.07; 19.19125. (ii) Same polynomial as in (i). 15. (i) 0.0068 x5 + 0.002 x4 – 0.1671 x3 – 0.0002 x2 + x; 0.6816. (ii) x3 – 6x2 – 5x + 4; 0.125, – 13.625.
  • 750. ANSWERS TO SELECTED EXERCISES 737 ASSIGNMENT 5.1 1. 3.946, – 3.545, 2.727, – 1.703 3. – 27.9, 117.67 5. (i) 0.5005, – 0.2732 (ii) 0.4473, – 0.1583 (iii) 0.4662, – 0.2043 7. 0.9848 9. 18, 18 11. 232.869 13. 0.10848 17. 0.0018 19. (a) – 52.4 (b) – 0.01908. ASSIGNMENT 5.2 1. 0.69325; 0.0001 3. 1.8278 5. (i) 1.82765512 (ii) 1.82784789 7. 177.483 9. 0.83865 11. 1.61 13. 1.1615 15. 30.87 m/sec 17. (i) 591.85333 (ii) 591.855 19. 0.693255; 0.0001078 21. 1.0101996 23. (i) 0.6827 (ii) 0.658596 25. 1.14 27. 0.52359895 29. 1.019286497. ASSIGNMENT 5.3 1. (i) 0.01138 (ii) 0.00083 3. 3.1428 5. 0.0490291. ASSIGNMENT 6.1 1. .019984, .0200 3. 0.0214 5. 0.7432, 0.7439 9. y(0.1) = 3.005, y(0.2) = 3.020. ASSIGNMENT 6.2 1. y(0.2) = 1.0199, y(0.5) = 1.1223 3. y(.02) = 1.0202, y(.04) = 1.0408, y(.06) = 1.0619 5. y(.1) = 1.222, y(.2) = 1.375, y(.3) = 1.573 7. 1.0526, 1.1104 9. 1.76393 11. y(.01) = 1.01, y(.02) = 1.0201.
  • 751. 738 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 6.3 1. 2.2052, 2.4214 3. y(x) = 1 2 2 5 8 10954 2 3 4 + − + − x x x x ; . 5. y(0.1) = 2.0845, z(0.1) = 0.5867 y(0.2) = 2.1366338, z(0.2) = 0.1549693. ASSIGNMENT 6.4 1. 1.11034 3. y(1.2) = 2.4921, y(1.4) = 3.2320 5. y(0.5) = 1.375, y(1.0) = 1.6030 7. y(1.1) = 1.8955, y(1.2) = 2.5041. 9. y(0.1) = 1.1168873, y(0.2) = 1.2773914, y(0.3) = 1.50412 11. (i) 1.1749, (ii) y(0.6) = 0.61035, y (0.8) = 0.84899 13. y(1.2) = 0.246326, y(1.4) = 0.622751489 15. y(0.1) = 1.118057, y(0.2) = 1.291457, y(0.3) = 1.584057 17. y(0.2) = 1.195999, y(0.4) = 1.375269. ASSIGNMENT 6.5 1. y4 (3) = y(0.8) = 1.218 3. 2.0444 5. y(0.3) = 1.0150 7. y(0.5) = 1.3571, y(1) = 1.5837, y(1.5) = 1.7555, y(2) = 1.8957 9. y(0.4) = 1.538, y(0.5) = 1.751 11. y(0.8) = 2.3164, y(1.0) = 2.3780 13. y(0.1) = 0.60475. ASSIGNMENT 6.6 1. y(0.4) = 2.2089, y(0.5) = 3.20798 3. y(1.4) = 0.9996 5. 1.1107, 1.2459, 1.4111, 1.61287.
  • 752. ANSWERS TO SELECTED EXERCISES 739 ASSIGNMENT 7.1 1. y = 2.4333 + 0.4x 3. y = – 4 + 6x 5. y = 54.35 + 0.5184x° 7. y = – 1.6071429x + 8.6428571 9. P = 2.2759 + 0.1879 W. ASSIGNMENT 7.2 1. y = e0.5x 3. y = 4.642 e0.46x 5. y = 99.86 (1.2)x 7. y = 2.978 x0.5143 9. y = 0.509x2 – 2 04 . x 11. y = 13.0065 + 6.7512 4.4738 x x − 2 13. xy = 16.18x + 40.78 15. pv1.42 = 0.99. ASSIGNMENT 7.3 1. x = 2.5, y = 0.7 3. x = 2.47, y = 3.55, z = 1.92 5. (i) x = 1.54, y = 1.27, z = – 1.08 (ii) x = 1.16, y = – .76, z = 2.8 (iii) x = 6.9, y = 3.6, z = 4.14. ASSIGNMENT 7.4 1. 1 2 7 4 1 2 1 4 T T T T 0 1 2 3 ( ) ( ) ( ) ( ) x x x x + − + 3. 2x + 2x2 7. 15 16 1 2 − x 9. 191 192 1 2 2 − x 11. M1 = 8, M2 = – 14 F(x) = − + − + 11 45 40 18 3 3 2 x x x ; F(1.5) = 7.375
  • 753. 740 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES 13. M1 = − 18 5 , M2 = 12 5 For 1 ≤ x ≤ 2, F(x) = − + − − 3 9 5 5 3 2 x x x For 2 ≤ x ≤ 3, F(x) = 5 39 95 69 5 3 2 x x x − + − For 3 ≤ x ≤ 4, F(x) = − + − + 2 24 94 120 5 3 2 x x x 15. α = 1, β = 3 17. For 0 ≤ x ≤ 1 3 , F(x) = 0.63x3 – 0.82x + 1 For 1 3 2 3 ≤ ≤ x , F(x) = – 0.45x3 + 1.08x2 – 1.18x + 1.0 For 2 3 ≤ x ≤ 1, F(x) = – 0.18x3 + 0.54x2 – 0.8x + 0.96 I = 0.695 ASSIGNMENT 7.5 1. y = 1.3x + 1.1 3. F = 0.18793W + 2.27595; F = 30.4654 kg wt. 5. x = 4, y = 7, r = – 0.5 7. y = 0.04765 + 0.004071 P; y = 0.6583 cm 9. x = 6, y = 1, r = – 0.48989 11. 7x – 11y + 6 = 0 13. r = 0.70, x = 11.5086, y = 11.5261, no 15. y = 1.68x + 1.044, x = 0.42y + 2.27; y = 14.484 17. y = x + 1; x = 0.16y + 2.36; x = 2.52 19. Regression line of y on x: y = 0.74306 x + 1.56821 Regression line of x on y: x = 0.63602 y + 2.0204.
  • 754. ANSWERS TO SELECTED EXERCISES 741 ASSIGNMENT 7.6 1. y = 1.43 + 0.24x + 2.21x2 5. a = 5.358035714, b = – 38.89492857, c = 67.56. ASSIGNMENT 7.7 1. CLX = 0.4988, UCLX = 0.5172, LCLX = 0.4804, CLR = 0.018, UCLR = 0.0463, LCLR = 0. The process is in control. 3. CLC = 2.4, UCLC = 7.05, LCLC = 0, the process is not under control 5. CLX = 10.66, UCLX = 14.295, LCLX = 7.025, CLR = 0.3, UCLR = 13.32, LCLR = 0 ; The process is under control 7. UCLC = 25.23, LCLC = 2.77. The process is in control. ASSIGNMENT 8.1 1. H0 rejected at 5% level 3. H0 rejected at 5% level 5. H0 accepted at 5% level. ASSIGNMENT 8.2 1. H0: Accepted 3. H0: Accepted. ASSIGNMENT 8.3 1. H0 is rejected 3. 48.8 and 51.2 5. H0 rejected both at 1% to 5% level of significance. ASSIGNMENT 8.4 1. Significant difference 3. Highly significant 5. 48.75, 51.25.
  • 755. 742 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES ASSIGNMENT 8.5 1. z = 2.315, Difference significant at 5% level; z = 1.31, Difference not significant at 5% level. ASSIGNMENT 8.6 1. accepted 3. rejected. ASSIGNMENT 8.7 1. accepted 3. accepted 5. accepted. ASSIGNMENT 8.8 1. rejected 3. accepted. ASSIGNMENT 8.9 1. no 3. accepted 5. Poisson law fits the data 7. yes. 9. Accepted at 1% level of significance and rejected at 5% level of significance. ASSIGNMENT 8.10 1. No 3. Not effective.
  • 756. 1. Attempt any FOUR parts of the following: (a) Define the term ‘absolute error’. Given that a = 10.00 ± 0.05, b = 0.0356 ± 0.0002 c = 15300 ± 100, d = 62000 ± 500 Find the maximum value of the absolute error in (i) a + b + c + d (ii) a + 5c – d (iii) d3 (b) Use the series loge 1 1 + F HG I KJ x x – = 2 x x x + + + F HG I KJ 3 5 3 5 ...... to compute the value of loge (1.2) correct to seven decimal places and find the number of terms retained. (c) Explain underflow and overflow conditions of error with suitable examples in floating point’s addition and subtraction. (d) Explain the Bisection method to calculate the roots of an equation. Write an algorithm and implement it in ‘C’. (e) Using the method of false position, find the root of equation x6 – x4 – x3 – 1 = 0 up to four decimal places. 743 APPENDIX B SAMPLE EXAMINATION
  • 757. 744 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES (f) Determine p, q, and r so that the order of the iterative method xn+1 = pxn + qa x ra x n n 2 2 5 + for a1/3 becomes as high as possible. 2. Attempt any FOUR parts of the following: (a) Prove that the nth differences of a polynomial of nth degree are constant and all higher order differences are zero when the values of the independent variable are at equal interval. (b) Find the missing terms in the following table: x 1 2 3 4 5 6 7 8 f (x) 1 8 ? 64 ? 216 343 512 (c) Find the number of students from the following data who secured scores not more than 45: Scores range 30–40 40–50 50–60 60–70 70–80 Number of students 35 48 70 40 22 (d) State and prove Stirling’s formula. (e) By means of Lagrange’s formula, prove that y1 = y3 – 0.3 (y5 – y–3) + 0.2 (y–3 – y–5) (f) Prove that the nth divided differences of a polynomial of nth degree are constant. 3. Attempt any TWO parts of the following: (a) y is a function of x satisfying the equation xy″ + ay′ + (x – b) y = 0 where a and b are integers. Find the values of constants a and b if y is given by the following table: x 0.8 1 1.2 1.4 1.6 1.8 2 2.2 y 1.73036 1.95532 2.19756 2.45693 2.73309 3.02549 2.3333 3.65563 (b) Find, from the following table, the area bounded by the curve and the x-axis from x = 7.47 to x = 7.52. x 7.47 7.48 7.49 7.50 7.51 7.52 f(x) 1.93 1.95 1.98 2.01 2.03 2.06
  • 758. SAMPLE EXAMINATION 745 (c) Derive Simpson’s 1 3 F HG I KJ rd rule from Newton-Cote’s quadrature formula. Give its algorithm and write a program in ‘C’ to implement. 4. Attempt any TWO parts of the following: (a) Obtain y for x = 0.25, 0.5 and 1.0 correct to three decimal places using Picard’s method, given the differential equation dy dx x y = + 2 2 1 with the initial condition y = 0 when x = 0. (b) Use Runge-Kutta method to approximate y when x = 1.4 given that y = 2 at x = 1 and dy dx = xy taking h = 0.2. (c) Explain Predictor-Corrector methods. Write the algorithm of Milne’s Predictor-corrector method and also give a code in ‘C’ to implement. 5. Attempt any FOUR parts of the following: (a) Write a short note on Frequency charts. (b) Find the least square line for the data points: (– 1, 10), (0, 9), (1, 7), (2, 5), (3, 4), (4, 3), (5, 0) and (6, – 1). (c) Find the most plausible values of x and y from the following equations: 3x + y = 4.95, x + y = 3.00, 2x – y = 0.5, x + 3y = 7.25. (d) Prove that the regression coefficients are independent of the origin but not of scale. (e) The average percentage of defectives in 27 samples of size 1500 each was found to be 13.7%. Construct p-chart for this situation. Explain how the control chart can be used to control quality. (f) Fit a curve of the type xy = ax + b to the following data: x 1 3 5 7 9 10 y 36 29 28 26 24 15
  • 760. n Included on the CD-ROM are simulations, figures from the text, third party software, and other files related to topics in numerical methods and statistics. n See the “README” files for any specific information/system requirements related to each file folder, but most files will run on Windows 2000 or higher and Linux. 747 APPENDIX C ABOUT THE CD-ROM
  • 762. 749 A Absolute error, 37 Acceptance sampling, 655 Adams-Moulton (or Adams-Bashforth) formula, 537 Adams-Moulton corrector formula, 539 Adams-Moulton predictor formula, 538 Advantages of statistical quality control, 656 Advantages/Features of ‘C’ language, 7 Algebraic and transcendental equations, 77 Algorithm for linear regression, 621 Algorithm of Euler’s method, 493 Algorithm of Milne’s predictor-corrector method, 528 Algorithm of modified Euler’s method, 497 Algorithm of Runge-Kutta method, 516 Algorithm of second degree parabolic curve fitting, 647 Algorithm of Simpson’s 1/3rd rule, 437 Algorithm of Simpson’s 3/8th rule, 433 Algorithm of trapezoidal rule, 429 Algorithmic errors, 31 Alternative hypothesis, 673 Analysis of data, 655 Angle between two lines of regression, 620 Applications of t-distribution, 691 Approximations, 601 Area diagrams, 555 Argument, 202 Arrays, 18 Assembler, 6 Assumptions for interpolation, 200 Asymptotic error constant, 80 Averaging operator μ, 205 B Backward difference operator, 203 Backward differences, 203 INDEX
  • 763. 750 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Curve of regression, 614 Curve-Fitting by sum of exponentials, 588 D Debugging, 80 Decision making instructions in “C”, 14 Degrees of freedom, 709 Detection of errors by use of difference tables, 234 Differences of a polynomial, 207 Discrete variables, 548 Divided differences, 361 E Error formula, 42 Error in a series approximation, 56 Error in Lagrange’s interpolation formula, 357 Errors in numerical computations, 43 Errors in numerical differentiation, 422 Errors in polynomial interpolation, 200 Errors in sampling, 674 Escape sequences, 12 Euler-Maclaurin’s Formula, 461 Euler’s formula, 493 Euler’s method, 492 Euler’s modified method, 493 Evaluation of principal value integrals, 466 Expression of rational function as a sum of partial fractions, 359 Extrapolation, 199 F Factorial notation, 225 Fibonacci numbers, 27 Bell shaped curve, 553 Bessel’s interpolation formula, 312 Bisection (or Bolzano) method, 77 Boole’s rule, 426 C ‘C’ constants, 8 “C instructions”, 10 “C” variables, 9 χ2 test as a test of goodness of fit, 711 χ2 test as a test of independence, 718 Carl Runge, 513 Cartograms, 555 Central difference operator, 204 Central differences, 204 Chebyshev formula of third order, 175 Chebyshev polynomial approximation, 605 Chi-square (χ2) test, 708 Class frequency, 549 Comparison of correlation and regression analysis, 618 Comparison of iterative methods, 189 Computational errors, 31 Conditions for applying χ2 test, 710 Confidence limits or fiducial limits, 684 Continuous variables, 548 Control chart, 655, 658 Control charts for attributes, 661 Convergence of a sequence, 81 Convergence of iteration method, 96 Convergence of regula-falsi method, 130 Critical region, 674 Critical value of t, 691 Cubic spline interpolation, 594 Cumulative frequency, 549 Cumulative frequency curve or the ogive, 553 Curve fitting, 556
  • 764. INDEX 751 Finite differences, 202 Finite inverse, 671 First order Runge-Kutta method, 514 Floating point representation of numbers, 61 Flow-chart for trapezoidal rule, 430 Flow-chart of Euler’s method, 494 Flow-chart of Milne’s predictor-corrector method, 529 Flow-chart of modified Euler’s method, 498 Flow-chart of Runge-Kutta method, 517 Flow-chart of second degree parabolic curve fitting, 649 Flow-chart of Simpson’s 1/3rd rule, 438 Flow-chart of Simpson’s 3/8th rule, 434 Forward difference operator, 202 Forward differences, 202 Fourth order Runge-Kutta method, 515 Frequency charts, 548 Frequency curve, 552 Frequency distributions, 548, 655 Frequency polygon, 552 Fundamental operator, 205 G Gauss’s backward difference formula, 289 Gauss’s forward difference formula, 278 Gaussian quadrature formula, 463 Graeffe’s root-squaring method, 190 Grouped frequency distribution, 549 H Hermite’s interpolating polynomial, 381 Hermite’s interpolation formula, 381, 382 Horner’s method, 156 Hypothetical universe, 671 I Initial-value and boundary-value problems, 480 Interpolating polynomial, 200 Interpolation by unevenly spaced points, 338 Inverse interpolation, 360 Inverse problems, 46 Iteration method, 94 J J-shaped curve, 554 L Lagrange’s interpolation formula, 339 Lanczos economization of power series, 606 Laplace-Everett’s formula, 327 Legendre and chebyshev polynomials, 601 Lin-bairstow’s method, 135 Linear regression, 614 Lines of regression, 614 Loop control structure, 17 Lower limit, 549 M Machine computation, 71 Machine epsilon, 34 Maclaurin’s expansion, 61 Marching methods, 481 Mathematical preliminaries, 60 Maxima and minima of a tabulated function, 402
  • 765. 752 COMPUTER-BASED NUMERICAL AND STATISTICAL TECHNIQUES Mean value theorem for derivatives, 61 Merits and demerits of Lagrange’s formula, 365 Method for complex root, 135 Method of false position, 113 Method of linear interpolation, 113 Method of separation of symbols, 234 Methods for multiple roots, 182 Milne’s corrector formula, 527 Milne’s method, 525 Milne’s predictor (extrapolation) formula, 526 Modified Euler’s method, 496 Muller’s method, 141 N Natural spline, 597 Newton-Cote’s quadrature formula, 423 Newton-Raphson method, 158 Newton-Raphson’s extended formula, 175 Newton’s divided difference interpolation formula, 363 Newton’s Gregory backward interpolation formula, 262 Newton’s Gregory forward interpolation formula, 243 Newton’s iterative formulae, 163 Non-periodic spline, 597 Normalized floating point, 62 np chart, 662 Numerical evaluation of singular integrals, 465 Numerical solution of ordinary differential equations, 479 O One-step predictor-corrector method, 497 Order of convergence, 80 Orthogonal properties, 603 Osculating interpolation formula, 381 P P chart, 661 Periodic spline, 597 Picard, 481 Picard’s method of successive approximations, 481 Predictor-corrector methods, 525 Principle of least squares, 556 Prisms and cubes, 555 Procedual errors or numerical errors, 35 Program to implement trapezoidal method, 431 Program to implement simpson’s 3/8th method, 435 Program in ‘C’ for second degree parabolic curve fitting, 650 Program of Euler’s method, 495 Program of Milne’s method, 530 Program of modified Euler’s method, 499 Program of Runge-Kutta method, 517 Program to implement least square fit of a regression, 622, 623 Program to implement Simpson’s 1/3rd method, 439 Program writing, 80 Properties of chebyshev polynomials, 605 Properties of divided differences, 362 Properties of regression co-efficients, 619 Q Quotient-difference method, 152
  • 766. INDEX 753 R Ramanujan’s method, 195 Region of rejection, 674 Regression analysis, 614 Regression equation, 614 Regression plane, 653 Regula-Falsi method, 113 Residuals, 557 Rolle’s theorem, 60 Runge-Kutta methods, 513 S Scatter or dot diagram, 556 Secant method, 132 Second order formula, 161 Second order Runge-Kutta method, 514 Significant values χ2 (α) of Chi-square distribution, 727 Significant values tv (α) of t-distribution, 724 Simpson’s one-third rule, 425 Simplson’s three-eighth rule, 426 Snedecor’s variance ratio test or F-test, 703 Special values of Chebyshev polynomials, 603 Spline function, 594 Spline interpolation, 594 Stability in the solution of ordinary differential equations, 542 Statistical quality control, 654 Stirling’s formula, 301 Student’s t-distribution, 691 Successive approximation method, 94 T t-statistic, 691 Taylor’s method, 506 Taylor’s series for a function of one variable, 61 Taylor’s series for a function of two variables, 61 Test of significance, 673 Test of significance for large samples, 676 Test of significance of small samples, 690 Test statistic, 675 Testing of hypothesis, 671 The χ2 distribution, 710 The t-table, 691 Third order Runge-Kutta method, 515 Trapezoidal rule, 424 Two point rule, 466 Type I error, 674 Type II error, 675 Types of frequency curves, 553 U u-chart, 661 U-shaped curve, 554 Use of regression analysis, 618 V Values of F for F-distributions, 725 W Weddle’s rule, 427 Wilhelm Kutta, 513 Y Yates’s correction, 719