Uploaded by Prince Raturi

cbnst-notes

advertisement
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
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
1.12
1.13
1.14
1.15
1.16
1.17
1.18
Chapter 2
Introduction to Computers
Definitions
Introduction to “C” Language
Advantages/Features of ‘C’ language
‘C’ Character Set
‘C’ Constants
“C” Variables
‘C’ Key Words
“C Instructions”
Hierarchy of Operations
Escape Sequences
Basic Structure of ‘‘C’’ Program
Decision Making Instructions in “C”
Loop Control Structure
Arrays and String
Pointers
Structure and Unions
Storage Classes in ‘C’
Errors
2.1
2.2
2.3
2.4
2.5
2.6
3—30
4
4
6
7
7
8
9
10
10
11
12
12
14
17
18
19
20
21
31—76
Errors and Their Analysis
Accuracy of Numbers
Errors
A General Error Formula
Errors in Numerical Computations
Inverse Problems
31
32
34
42
43
46
v
vi
CONTENTS
2.7
2.8
2.9
2.10
2.11
2.12
Chapter 3
Error in a Series Approximation
Mathematical Preliminaries
Floating Point Representation of Numbers
Arithmetic Operations with Normalized Floating Point Numbers
Machine Computation
Computer Software
Algebraic and Transcendental Equations
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.16
3.17
3.18
3.19
3.20
3.21
3.22
3.23
3.24
3.25
3.26
3.27
3.28
3.29
3.30
Bisection (or Bolzano) Method
Algorithm
Flow-Chart
Program Writing
Order of Convergence of Iterative Methods
Order of Convergence of Bisection Method
Convergence of a Sequence
Prove that Bisection Method Always Converges
Program to Implement Bisection Method
Iteration Method—(Successive Approximation Method)
Sufficient Condition for Convergence of Iterations
Theorem
Convergence of Iteration Method
Algorithm for Iteration Method
Flow-Chart for Iteration Method
Computer Program
The Method of Iteration for System of Non-Linear Equations
Method of False Position or Regula-Falsi Method
Algorithm
Flow-Chart
Convergence of Regula-Falsi Method
Secant Method
Lin-Bairstow’s Method or Method for Complex Root
Muller’s Method
Algorithm of Muller’s Method
Flow-Chart for Muller’s Method
The Quotient-Difference Method
Horner’s Method
Newton-Raphson Method
Convergence
56
60
61
63
71
72
77—196
77
78
79
80
80
80
81
81
84
94
95
95
96
96
98
99
111
113
114
116
130
132
135
141
142
144
152
156
158
159
CONTENTS
3.31
3.32
3.33
3.34
3.35
3.36
3.37
3.38
3.39
3.40
3.41
3.42
3.43
3.44
Order of Convergence
Geometrical Interpretation
Algorithm of Newton-Raphson Method
Flow-Chart of Newton–Raphson Method
Newton’s Iterative Formulae for Finding Inverse, Square Root
Rate of Convergence of Newton’s Square Root Formula
Rate of Convergence of Newton’s Inverse Formula
Definitions
Methods for Multiple Roots
Nearly Equal Roots
Comparison of Newton’s Method with Regula-Falsi Method
Comparison of Iterative Methods
Graeffe’s Root-Squaring Method
Ramanujan’s Method
vii
159
161
161
162
163
164
164
182
182
187
189
189
190
195
PART 2
Chapter 4
Interpolation
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
4.14
4.15
4.16
4.17
4.18
4.19
4.20
Introduction
Assumptions for Interpolation
Errors in Polynomial Interpolation
Finite Differences
Other Difference Operators
Relation Between Operators
Differences of a Polynomial
Factorial Notation
To Show that (i) Δn[x]n = n ! (ii) Δn+1 [x]n = 0
Reciprocal Factorial
Missing Term Technique
Method of Separation of Symbols
Detection of Errors by Use of Difference Tables
Newton’s Formulae for Interpolation
Newton’s Gregory Forward Interpolation Formula
Newton’s Gregory Backward Interpolation Formula
Central Difference Interpolation Formulae
Gauss’ Forward Difference Formula
Gauss’ Backward Difference Formula
Stirling’s Formula
199—390
199
200
200
202
205
205
207
225
225
226
227
234
234
243
243
262
278
278
289
301
viii
CONTENTS
4.21
4.22
4.23
4.24
4.25
4.26
4.27
4.28
4.29
4.30
Bessel’s Interpolation Formula
Laplace-Everett’s Formula
Interpolation by Unevenly Spaced Points
Lagrange’s Interpolation Formula
Error in Lagrange’s Interpolation Formula
Expression of Rational Function as a Sum of Partial Fractions
Inverse Interpolation
Divided Differences
Properties of Divided Differences
Newton’s General Interpolation Formula or Newton’s Divided
Difference Interpolation Formula
4.31 Relation Between Divided Differences and Ordinary
Differences
4.32 Merits and Demerits of Lagrange’s Formula
4.33 Hermite’s Interpolation Formula
312
327
338
339
357
359
360
361
362
363
364
365
381
PART 3
Chapter 5
Numerical Integration and Differentiation
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.14
5.15
Introduction
Numerical Differentiation
Formulae for Derivatives
Maxima and Minima of a Tabulated Function
Errors in Numerical Differentiation
Numerical Integration
Newton-cote’s Quadrature Formula
Trapezoidal Rule (n = 1)
Simpson’s One-third Rule (n = 2)
Simpson’s Three-Eighth Rule (n = 3)
Boole’s Rule
Weddle’s Rule (n = 6)
Algorithm of Trapezoidal Rule
Flow-Chart for Trapezoidal Rule
Program to Implement Trapezoidal Method of
Numerical Integration
5.16 Output
5.17 Algorithm of Simpson’s 3/8th Rule
5.18 Flow-Chart of Simpson’s 3/8th Rule
393—476
393
394
394
402
422
423
423
424
425
426
426
427
429
430
431
433
433
434
CONTENTS
5.19 Program to Implement Simpson’s 3/8th Method of
Numerical Integration
5.20 Output
5.21 Algorithm of Simpson’s 1/3rd Rule
5.22 Flow-Chart of Simpson’s 1/3rd Rule
5.23 Program to Implement Simpson’s 1/3rd Method
of Numerical Integration
5.24 Output
5.25 Euler-Maclaurin’s Formula
5.26 Gaussian Quadrature Formula
5.27 Numerical Evaluation of Singular Integrals
5.28 Evaluation of Principal Value Integrals
ix
435
437
437
438
439
441
461
463
465
466
PART 4
Chapter 6
Numerical Solution of Ordinary Differential Equations
6.1
6.2
6.3
6.4
6.5
6.6
6.7
6.8
6.9
6.10
6.11
6.12
6.13
6.14
6.15
6.16
6.17
6.18
6.19
6.20
479—544
Introduction
Initial-Value and Boundary-Value Problems
Single Step and Multi-Step Methods
Comparison of Single-Step and Multi-Step Methods
Numerical Methods of Solution of O.D.E.
Picard’s Method of Successive Approximations
Picard’s Method for Simultaneous First Order Differential
Equations
Euler’s Method
Algorithm of Euler’s Method
Flow-Chart of Euler’s Method
Program of Euler’s Method
Modified Euler’s Method
Algorithm of Modified Euler’s Method
Flow-Chart of Modified Euler’s Method
Program of Modified Euler’s Method
Taylor’s Method
Taylor’s Method for Simultaneous I Order Differential
Equations
Runge-Kutta Methods
Fourth Order Runge-Kutta Method
Runge-Kutta Method for Simultaneous First Order Equations
479
480
480
480
480
481
488
492
493
494
495
496
497
498
499
506
508
513
515
519
x
CONTENTS
6.21
6.22
6.23
6.24
6.25
6.26
Predictor-Corrector Methods
Milne’s Method
Adams-Moulton (or Adams–Bashforth) Formula
Stability
Stability in the Solution of Ordinary Differential Equations
Stability of I Order Linear Differential Equation of Form
dy/dx = Ay with Initial Condition y(x0) = y0
525
525
537
541
542
542
PART 5
Chapter 7
Statistical Computation
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
7.17
7.18
7.19
7.20
7.21
7.22
7.23
7.24
7.25
The Statistical Methods
Limitation of Statistical Methods
Frequency Charts
Graphical Representation of a Frequency Distribution
Types of Graphs and Diagrams
Histograms
Frequency Polygon
Frequency Curve
Cumulative Frequency Curve or the Ogive
Types of Frequency Curves
Diagrams
Curve Fitting
Principle of Least Squares
Fitting a Straight Line
Algorithm for Fitting a Straight Line of the Form y = a + bx
for a Given Set of Data Points
Flow-Chart for Fitting a Straight Line y = a + bx for a Given
Set of Data Points
Program to Implement Curve Fitting to Fit a Straight Line
Fitting of an Exponential Curve y = aebx
Fitting of the Curve y = axb
Fitting of the Curve y = abx
Fitting of the Curve pvr = k
Fitting of the Curve of Type xy = b + ax
Fitting of the Curve y = ax2 + b/x
Fitting of the Curve y = ax + bx2
Fitting of the Curve y = ax + b/x
547—670
547
547
548
550
550
551
552
552
553
553
555
556
556
558
559
560
561
569
569
569
570
570
570
571
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
7.28 Fitting of the Curve 2x = ax2 + bx + c
7.29 Most Plausible Solution of a System of Linear Equations
7.30 Curve-Fitting by Sum of Exponentials
7.31 Spline Interpolation
7.32 Spline Function
7.33 Cubic Spline Interpolation
7.34 Steps to Obtain Cubic Spline for Given Data
7.35 Approximations
7.36 Legendre and Chebyshev Polynomials
7.37 Legendre Polynomials
7.38 Chebyshev Polynomials
7.39 Special Values of Chebyshev Polynomials
7.40 Orthogonal Properties
7.41 Recurrence Relations
7.42 Aliter to Find Chebyshev Polynomials
7.43 Expression of Powers of x in terms of Chebyshev Polynomials
7.44 Properties of Chebyshev Polynomials
7.45 Chebyshev Polynomial Approximation
7.46 Lanczos Economization of Power Series for a General Function
7.47 Regression Analysis
7.48 Curve of Regression and Regression Equation
7.49 Linear Regression
7.50 Lines of Regression
7.51 Derivation of Lines of Regression
7.52 Use of Regression Analysis
7.53 Comparison of Correlation and Regression Analysis
7.54 Properties of Regression Co-efficients
7.55 Angle between Two Lines of Regression
7.56 Algorithm for Linear Regression
7.57 Program to Implement Least Square Fit of a Regression Line
of y on x
7.58 Program to Implement Least Square Fit of a Regression Line
of x on y
7.59 Polynomial Fit: Non-linear Regression
7.60 Multiple Linear Regression
7.61 Statistical Quality Control
573
574
586
588
594
594
594
597
601
601
601
602
603
603
603
604
604
605
605
606
614
614
614
614
615
618
618
619
620
621
622
623
639
652
654
xii
CONTENTS
7.62
7.63
7.64
7.65
7.66
7.67
7.68
Chapter 8
Testing of Hypothesis
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
8.10
8.11
8.12
8.13
8.14
8.15
8.16
8.17
8.18
8.19
PART 6
Advantages of Statistical Quality Control
Reasons for Variations in the Quality of a Product
Techniques of Statistical Quality Control
Control Chart
Objectives of Control Charts
Construction of Control Charts for Variables
Control Charts for Attributes
656
657
657
658
658
659
661
671—728
Population or Universe
Sampling
Parameters of Statistics
Standard Error
Test of Significance
Critical Region
Level of Significance
Errors in Sampling
Steps in Testing of Statistical Hypothesis
Test of Significance for Large Samples
Test of Significance of Small Samples
Student’s t-Distribution
Test I: t-test of Significance of the Mean of a Random Sample
Test II: t-test for Difference of Means of Two Small Samples
(From a Normal Population)
Snedecor’s Variance Ratio Test or F-test
Chi-square (χ2) Test
The χ2 Distribution
χ2 Test as a Test of Goodness of Fit
χ2 Test as a Test of Independence
671
672
672
672
673
674
674
674
676
676
690
691
692
695
703
708
710
711
718
APPENDICES
Appendix A (Answers to Selected Exercises)
731
Appendix B (Sample Examination)
743
Appendix C (About the CD-ROM)
747
Index
749
1
P a r t
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.
1
Chapter
INTRODUCTION
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.
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
(Terminal point)
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 decisionmaking 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.
(Input/output)
(Processing
operation box)
(Decision logic)
(Connector point)
G
(Subprocess symbol)
(Subroutine)
(Connector arrows)
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.
¾®
Integer
constant
¾® Short signed
¾®¾® Shor t unsigned
¾® Long signed
¾® Primary
constants
or
Primary data
types
¾®¾®
Real
constant
Character
¾®
constant
‘C’ constants ¾¾®
Secondar y
constants
or
¾®
Secondar y
data types
¾¾®
Array
¾¾®
Pointer
¾¾® ¾¾®
¾® Float
¾®
¾®
Structure
¾¾®
Union
¾¾®
Enum
¾® Double
¾® Signed
¾® Unsigned
INTRODUCTION
1.6.1
Primary Data Types
Data types
Byte
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
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
(v) Long signed integer
1.7
9
Range
Format
“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
C Variables
Real variables
Integer variables
String variable
Floating
point
Long
integer
Short
integer
Unsigned
integer
Double
Character
variable
Integer
Signed
character
Unsigned
character
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
1.11
ESCAPE SEQUENCES
AND
STATISTICAL TECHNIQUES
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.
No.
Functions
Meaning
Argument
Value
x
float
float
1.
sqrt (x)
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
integer value
float
float
8.
f mod (x, y)
returns the remainder
of x/y
float
float
9.
rand ( )
generates a (+) ve
random integer
—
integer
to initialize the random
number generator
Unsigned
—
10.
srand (v)
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
particular character
character integer
integer
15.
tolower (x)
To convert character
to lower case
’’
character
16.
toupper (x)
To convert character
to upper case
character
’’
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)
(ii)
(iii)
(i)
The if statement;
The if-else statement; and
The switch statement.
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;
statement
2;
else
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.
NOTE
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.
INTRODUCTION
1.14
17
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;
}
OP
PP
Q
NOTE
(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.
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’’;
NOTE
(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
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 + b2 − 4 ac
2a
and
x2 =
− b − b2 − 4 ac
2a
or
x1 =
−b+ d
,
2a
x2 =
−b− d
, where d = b 2 – 4ac.
2a
22
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
START
Read
a, b, c
Yes
Is
a=0?
No
Is
b=0?
2
d = b – 4 ac
No
x1 = –
Yes
Is
d<0?
No
x1 = (– b +
d)/2a
x2 = (– b –
d)/2a
Print roots
are complex
Print
x1, x2
c
b
Print x1
STOP
STOP
Flow-chart
Yes
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
1
Is
count = 100 ?
Yes
Print
Max
No
STOP
Read n
Is
n > Max ?
Yes
Max = n
No
Count = Count + 1
1
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
are
STATISTICAL TECHNIQUES
x1 =
−b− e
−b+ e
, x2 =
2a
2a
b2 − 4 ac = d
Algorithm is
Step 1. Input a, b, c.
where e =
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.
−b+ e
.
2a
−b−e
Step 6. Calculate x2 =
.
2a
Step 7. Print x1 and x2.
Step 5. Calculate x1 =
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 =
Sol. The algorithm is
1. read a, b, c
a+b+c
2
3. area = sqrt (s * (s – a) * (s – b) * (s – c))
2. s =
4. print area
5. end.
The program is given below
# include<stdio.h>
# include<math.h>
main( )
a+b+c
.
2
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=0
i=i+1
i
Sum = Sum + x
True
False
i<n
Print Sum
STOP
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 (‘‘% d\t’’ , 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 (“%d\t”, i);
}
The output will be
1
3
5
7
9
ASSIGNMENT 1.1
1.
2.
3.
Write a C-program to find the magnitude of a vector a = a1i + a2j + a3k.
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);
Write a C program to solve a set of linear equations with two variables
a1x + b1y = c1
a2x + b2y = c2
LM Hint: Solution is x = b c
ab
N
2 1
1 2
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
PNR
100
Write a printf statement to print “The given value is 22.23.”
Give an algorithm and write a program in C to check whether a given number is prime
or not.
Simple interest =
5.
6.
OP
Q
a c − a2 c1
− b1c2
,y= 1 2
.
− a2b1
a1b2 − a2b1
INTRODUCTION
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
29
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
}
Write a program in C to determine whether a number is odd or even. Also, draw its flowchart.
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.
Draw a flow-chart for adding marks of 5 subjects for a student and print the total.
Write a C-program to print the message CRICKET WORLD CUP-2007 six times.
Give any five library functions in “C”.
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
Write an algorithm for addition of two matrices of same order.
Write a C-program to find the multiplication of two square matrices each of order 2.
Write a C-program to find factorial of a given number.
Give a flow-chart for finding the determinant of a square non-singular matrix.
Write an algorithm for finding the inverse of a square non-singular matrix.
What is the maximum length allowed in defining a variable in “C”?
Write a C-program to find whether a year is leap year.
Develop a flow-chart to select the largest number of a given set of 500 numbers.
Chapter
2
ERRORS
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
31
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
Programming
Computation
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
7
approximate. Exact numbers are 2, 4, 9, , 6.45, ...... etc. but there are
2
numbers such that
4
(= 1.333 ......), 2 (= 1.414213 ...) and π (= 3.141592......) which cannot
3
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 nonzero digit on the left.
NOTE
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
02
3, 9, 0, 9
04
6
01
3.9 ×
106
3.909 ×
6 × 10–2
105
34
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
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.
(3) Rounding-off. There are numbers with many digits, e.g.,
(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
2.3
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
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 roundingoff 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.
n
∞
e.g., If S =
∑ ax
i i
∑ a x , then the
is replaced by or truncated to S =
i i
i=1
1
error developed is a truncation error.
A truncation error is a type of algorithm error. Also,
if ex = 1 + x +
1+x+
x2 x3 x 4
+
+
+ ...... ∞ = X (say) is truncated to
2! 3! 4!
x2 x3
+
= X′ (say), then truncation error = X – X′
2! 3!
1
if
5
(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
Example. Find the truncation error for ex at x =
F
GH
= 1+ x +
I F
JK GH
x2 x 3
x2
+
+ ...... − 1 + x +
2! 3!
2!
I = x + x + x + ......
JK 3 ! 4 ! 5 !
3
4
5
ERRORS
Put x =
37
1
5
error =
.008 .0016 .00032
+
+
+ ......
6
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 |
X – X′
=
True value
X
where X is true value and X – X′ is error.
(6) Percentage error. Percentage error ep is defined as
ep = 100 er = 100
NOTE
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
(10–n).
2
e.g., if the number 3.1416 is correct to 4 decimal places, then the
error
=
=
1
(10–4) = .00005.
2
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
and relative errors.
Sol. True value
=
2 . Find the absolute
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
=
0.21356 × 10 −3
ea
=
True value
2
= 0.151 × 10–3.
Example 2. If 0.333 is the approximate value of
and percentage errors.
Sol. True value
Approximate value
∴ Absolute error
(X) =
1
, find the absolute, relative,
3
1
3
(X′) = 0.333
ea = | X – X′ |
=
1
− 0.333 =|0.333333 − 0.333| = .000333
3
ea
.000333
=
= .000999
X
.333333
Relative error
er =
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
0.0012645
=
3.1415926
True value
= 0.000402502.
1
are given as 0.30, 0.33,
3
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.
Example 4. Three approximate values of the number
1
= 0.33333.
3
Case I. Approximate value = 0.30
Absolute error = | True value – Approximate value |
True 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,
∴
FG∵
H
ea = .05
er =
.05
= .0058.
8.6
Example 6. Find the relative error if
Sol. True value
Approximate value
=
2
is approximated to 0.667.
3
2
= 0.666666
3
= 0.667
ea =
1
× 10 −1
2
IJ
K
40
COMPUTER-BASED NUMERICAL
Absolute error
AND
STATISTICAL TECHNIQUES
ea = | True value – approximate value |
= | .666666 – .667 | = .000334
Relative error
er =
.000334
= .0005 .
.666666
Example 7. Find the percentage error if 625.483 is approximated to three
significant figures.
Sol.
ea = | 625.483 – 625 | = 0.483
er =
∴
ea
.483
=
= .000772
625.483 625.483
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 =
Percentage error
ep = er × 100 = 5.77 × 10–3
ea
50
=
= 5.77 × 10–5
X 865250
(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
0.00235
=
X 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 =
Percentage error
ep = er × 100 = .00265.
ea
2
=
= .0000265
75462 75462
Example 10. Find the absolute, relative, and percentage errors if x is roundedoff 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
.000002
=
= .0033344
.005998 .005998
ep = er × 100 = .33344.
Percentage error
Example 11. Evaluate the sum S =
find its absolute and relative errors.
Sol.
3 = 1.732,
Hence,
3 + 5 + 7 to 4 significant digits and
5 = 2.236,
7 = 2.646
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,
then,
S = 6.61
er =
.0015
= 0.0002.
6.61
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=
∴
or
| ΔX | =
2 ± 4 − 4 log 10 2
2
= 1 ± 1 − log 10 2
1 Δ(log 2)
< 0.5 × 10–4
2 1 − log 2
Δ(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.
5.
10
, approximate value = 3.33, find the absolute and relative errors.
3
Round-off the following numbers to two decimal places.
If true value =
48.21416, 2.3742, 52.275, 2.375, 2.385, 81.255.
6.
Calculate the value of
7.
If X = 2.536, find the absolute error and relative error when
102 − 101 correct to four significant digits.
(i) X is rounded-off
(ii) X is truncated to two decimal digits.
8.
9.
22
is approximated as 3.14, find the absolute error, relative error, and percentage
7
of relative error.
If π =
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
FG ∂f
H ∂x
y + δy = f(x1, x2) +
1
δx1 +
∂f
δx2
∂x2
IJ
K
+ 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
Hence,
δy =
∂f
∂f
δ x1 +
δx2 approximately
∂x2
∂x1
δy =
∂y
∂y
δ x1 +
δx2
∂x1
∂x2
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
∂y
∂y
δx1 +
δx2 + ...... +
δxn
∂x n
∂x2
∂ x1
and the relative error in y is
er =
δy
∂y δx1
∂y δx2
∂y δxn
=
.
.
.
+
+ ...... +
y ∂ x1 y
y
∂x2 y
∂ xn
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
⇒
Δxn
ΔX Δx1 Δx2
=
+
+ ...... +
X
X
X
X
which is the relative error.
The maximum relative error is
Δx1
Δx2
Δxn
ΔX
.
≤
+
+ ...... +
X
X
X
X
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.
NOTE
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 Δx1 Δx2
=
−
is the relative error.
X
X
X
The maximum relative error
=
Δx1
Δx2
ΔX
≤
+
X
X
X
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
∂X
∂X
∂X
Δx1 +
Δx2 + ...... +
Δx n
∂xn
∂x2
∂ x1
then,
ΔX =
Now,
1 ∂X
1 ∂X
ΔX 1 ∂X
=
Δx1 +
Δx2 + ...... +
Δx n
X
X ∂ x1
X ∂x2
X ∂xn
ERRORS
Now,
x . x ...... xn
1 ∂X
1
= 2 3
=
X ∂x1 x1 x2 x3 ...... xn x1
x x ...... xn
1 ∂X
1
= 1 3
=
X ∂x2 x1 x2 x3 ...... xn x2
1 ∂X
1
=
X ∂xn xn
∴
Δxn
ΔX Δx1 Δx2
=
+
+ ...... +
.
X
x1
x2
xn
∴ The relative and absolute errors are given by,
Maximum relative error =
Δx1
Δx2
Δxn
ΔX
≤
+
+ ...... +
X
x1
x2
xn
Maximum absolute error =
ΔX
ΔX
X=
. ( x1 x2 x3 ...... xn )
X
X
(4) Error in division of numbers
Let,
∴
X=
x1
x2
1 ∂X
ΔX 1 ∂X
. Δ x2
=
Δ x1 + .
X
X ∂x1
X ∂ x2
=
Δx1
FG x IJ
Hx K
1
2
∴
.
F − x I = Δx
FG IJ GH x JK x
H K
1
Δx2
+
x2
x1
x2
Δx1
Δx2
ΔX
≤
+
X
x1
x2
Absolute error = | ΔX | ≤
ΔX
X
. X.
2
1
2
1
1
−
Δx2
x2
which is relative error.
45
46
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
(5) Error in evaluating xk
X = xk ,
ΔX =
where k is an integer or fraction
dX
Δx = kxk – 1 . Δx
dx
ΔX
Δx
= k.
X
x
∴
ΔX
Δx
≤ k.
X
x
The relative error in evaluating xk = k .
2.6
Δx
.
x
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
Δx1 +
Δx2 + ...... +
Δxn
∂xn
∂x2
∂x1
According to the principle of equal effects,
∂X
∂X
∂X
Δx1 =
Δx2 = ...... =
Δxn
∂ xn
∂x2
∂ x1
∴
ΔX = n
∴
Δx1 =
∂X
Δx1
∂x1
ΔX
n
FG ∂X IJ
H ∂x K
1
Similarly,
NOTE
Δx2 =
ΔX
and so on.
∂X
n
∂ x2
The above article is needed when we are to find errors in both independent
variables involved and error in dependent variable is given.
ERRORS
47
EXAMPLES
Example 1. If u =
4x 2 y 3
z4
maximum error in u when
Sol.
δu =
=
and errors in x, y, z be 0.001, compute the relative
x = y = z = 1.
∂u
∂u
∂u
δx +
δy +
δz
∂x
∂y
∂z
8 x y3
z4
δx +
12 x 2 y 2
z4
δy −
16 x 2 y 3
z5
δ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 xy 3
12 x 2 y 2
16 x 2 y3
δx +
δy +
δz
4
4
z
z
z5
= 8(.001) + 12(.001) + 16(.001) = 0.036
∴ Maximum relative error =
.036
= .009.
4
Example 2. Find the relative error in the function
y = ax1 m1 x 2 m2 ...... xn mn .
Sol. We have
∴
∴
log y = log a + m1 log x1 + m2 log x2 + ...... + mn log xn
FG IJ
H K
m
m
1 ∂y
1 ∂y
= 1 =
= 2 , ...... etc.
y ∂x1
x1
y ∂ x2
x2
er =
∂ y δ xn
∂y δx2
∂y δx1
+ ...... +
+
.
.
.
∂xn
∂x2
∂ x1 y
y
y
= m1
δx1 m2
δx
+
δx2 + ...... + mn . n
x1
x2
xn
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
δx1
δx2
δ xn
+ m2
+ ...... + mn
.
x2
xn
x1
48
COMPUTER-BASED NUMERICAL
Corollary. If
AND
STATISTICAL TECHNIQUES
y = x1 x2 ......, xn
er ≈
δx1 δx2
δx
+
+ ...... + n
x1
x2
xn
∴ 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 = 1 m if the error in the measurement of l is 0.01.
Sol.
T = 2π
l
for
g
l
g
Taking log
log T = log 2π +
⇒
1
1
log l − log g
2
2
1
1 δl
δT =
T
2 l
δT
δl
.01
× 100 =
× 100 =
× 100 = 0.5% .
T
2l
2×1
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 = (12 V5 – 5) δV
∂V
F
GH
I
JK
12V 5 − 5
δu
. δV × 100
× 100 =
u
2V 6 − 5V
=
7
(12 − 5)
× (.05) × 100 = − × 5 = – 11.667%
3
(2 − 5)
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 = (21h6 – 6) δh
∂h
ERRORS
49
F
I
GH
JK
F 21 − 6 IJ FG δh × 100IJ = 15 . 5% = – 25%
=G
H 3 − 6 K H h K (− 3)
21h6 − 6
δr
× 100 =
δh × 100
r
3 h7 − 6 h
Percentage error
δr
× 100 = 25% .
r
=
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 +
Differentiating,
5
log H
2
δQ 5 δH
= .
Q
2 H
δQ
5 0.15
1
× 100 = ×
× 100 = = 0.5 .
Q
2
75
2
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
2
× 100 = (δd × 100)
d
A
δd
0.1
× 100 =
= .05 .
d
2
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
FG IJ
H K
Δx 1 Δx
.
<
x 2 x
50
COMPUTER-BASED NUMERICAL
(ii) From (i),
AND
STATISTICAL TECHNIQUES
x ΔN
= 2.3026 x(ΔN).
0.43429
Δx =
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) 2 − 4
2
32 + (32) 2 − 4
2
and
32 − 1020
= 16 − 255
2
I Algorithm. Smaller root = 16 − 255 = 16 – 15.97 = 0.03
The smaller root is
II Algorithm. Smaller root
= (16 − 255 ) .
16 + 255
1
1
=
= 0.0313
16 + 15.97 31.97
=
16 + 255
The second algorithm is evidently a better one, as gives the result correct
to 4 figures.
Example 10. If X = x + e, prove that
Sol.
FG
H
X − x = X − X − e = X − X 1−
=
X– X +
e
2 X
≈
e
X − x≈
e
e
X
2 X
IJ
K
1/2
=
.
FG
H
X − X 1−
e
2X
IJ
K
.
2 X
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 =
=
FG aIJ
H cK
∂A
∂A
δa +
δc
∂a
∂c
c
2
a +c
2
δa −
a
2
a + c2
δc
ERRORS
or
|δA|≤
=
c
a2 + c2
. δa +
a
a2 + c 2
51
. δc
15
6
. (0.1) +
. (0.2) = .0103 radians
261
261
δA ≤ .0103 radians.
∴
Example 12. In a ΔABC, a = 30 cm, b = 80 cm, ∠B = 90°, find the maximum
1
1
error in the computed value of A if possible errors in a and b are % and % ,
3
4
respectively.
Sol.
Here,
∴
sin A =
a
b
|δA|<
∂A
∂A
δa +
δb
∂a
∂b
A = sin–1
⇒
FG aIJ
H bK
(2)
δa
1
× 100 =
a
3
∴
δa = 0.1
δb
1
× 100 =
b
4
∴
δb = 0.2
∂A
=
∂a
1
2
b −a
2
,
∂A
−a
=
∂b b b 2 − a 2
Substituting in (2), we get δA < .00135 + .00100 < .00235.
1
1
and
correct to 4 decimal places
7
11
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
Example 13. The approximate values of
maximum error in each case is
1
× .0001 = 0.00005.
2
(i) Relative error
|ΔX| |Δx1 | |Δx 2 | 0.00005 0.00005
<
+
<
+
|X|
|X|
|X|
0.2338
0.2338
0.0001
ΔX
<
= .00043 .
X
0.2338
(∵ X = x1 + x2)
52
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
(ii) Absolute error
ΔX = Δx1 + Δx2 = 0.00005 + 0.00005 = 0.0001.
1
1
and
, correct to four decimal
7
15
places, are 0.1429 and 0.0667 respectively. Find the relative error for the sum of
0.1429 and 0.0667.
Example 14. The approximate values of
ΔX
0.0001
<
= 0.000477 .
X
0.2096
Sol.
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
1
× 10–3 = 0.0005
2
Δx1 = Δx2 = 0.0005
∴ The maximum error in each case is
∴
The relative error in their sum is
Δx1
Δx2
ΔX
≤
+
X
X
X
≤
|∵
X = x1 + x2 = 8.702
0.0005
0.0005
+
< 1.149 × 10 −4
8.702
8.702
The relative error in their difference is
Δx1
Δx2
ΔX
≤
+
, where X = x1 – x2 = 2.068
X
X
X
≤
0.0005
0.0005
+
< 4.835 × 10 −4 .
2.068
2.068
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 =
∴ The relative error <
1
× 0.001 = 0.0005
2
Δx1
Δx2
+
X
X
=2
FG
H
IJ
K
Δx1
0.0005
=2
= 0.008 .
X
0.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×
∴ Percentage error
=
0.0005
0.001
=
(3.162 − 2.718) .444
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) ≤
=
Δx1
Δx2
+
x1
x2
0.05
0.05
+
346.1
865.2
= 0.000144 + 0.000058 = 0.000202
∴ Absolute error = er . X = 0.000202 × 299446 ~
– 60
54
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL 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
= 299446
2
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.
7.342
. Numbers are correct
0.241
to three decimal places. Determine the smallest interval in which true result
lies.
Sol.
Δx1 = Δx2 = 0.0005
Example 21. Find the relative error in calculation of
Relative error
≤
0.0005
0.0005
+
7.342
0.241
≤ 0.0005
Absolute error
Now,
FG 1 + 1 IJ = 0.0021
H 7.342 .241K
= 0.0021 ×
7.342
x1
= 0.0021 ×
= 0.0639
0.241
x2
x1 7.342
=
= 30.4647
x2 0.241
∴ 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
=3.
Δx
x
0.0005
= 0.003054989
0.491
ERRORS
Absolute error
55
< 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 =
F
GH
I
JK
1 r2
+ h and the error in R is at the most 0.4%, find the
2 h
percentage error allowable in r and h when r = 5.1 cm and h = 5.8 cm.
Sol. Percentage error in R =
ΔR
× 100 = 0.4
R
(i) Percentage error in r =
=
=
=
1
.
r
OP
Q
LM
N
0.4 1 (5.1) 2
0.4
×
+ 5.8 = 0.0206
×R =
100 2 5.8
100
ΔR =
∴
Δr
× 100
r
F ΔR I × 100
GG 2 ∂R JJ
H ∂r K
∵ 2
100 ΔR
50 h
.
= 2 ΔR
r
r
r
2
h
FG IJ
H K
50 × 5.8
(5.1) 2
Δh
× 100
h
(ii) Percentage error in h =
=
100
×
h
=
100
.
h
=
× 0.0206 = 0.22968%
FG
H
ΔR
100
ΔR
=
.
∂R
h
1
r2
2
2 −
+
2
∂h
2
2h
LM
N
IJ
K
ΔR
F− r
GH h
2
2
I
JK
+1
=
OP
Q
100
0.0206
×
5.8 (− 0.773186 + 1)
2.06
= 1.5659% .
5.8 × 0.2268
∂R 2 r
=
∂r
h
56
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL 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° =
LM
N
5π
11
radian
=
180 126
1 – cos θ = 1 – 1 −
=
∴
OP
Q
θ2 θ4
+
– ......
2! 4!
FG IJ
H K
θ2 θ4
1 11
−
+ ...... =
2! 4!
2 126
2
−
FG IJ
H K
1 11
24 126
4
+ ......
= 0.0038107 – 0.0000024
_ 0.0038083
~
X = x(1 – cos θ)
= 10.2 (0.0038083)
= 0.0388446 ~ 0.0388
Further,
Δx =
Δθ =
where
∴
0.0005
ΔX
~
=
– 0.0656
∂X
2 × 0.0038083
2
∂x
FG IJ
H K
0.0005
0.0005
ΔX
=
=
∂X
2 x sin θ 2 × 10.2 × 0.0871907
2
∂θ
FG IJ
H K
sin θ = θ −
Δθ =
FG IJ
H K
θ3
11
1 11
+ ...... =
−
3!
126 6 126
3
+ ...... = 0.0871907
0.0005
~
– 0.0002809 ~
– 0.00028 .
20.4 × 0.0871907
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) +
where
Rn(x) =
( x − a) 2
( x − a) n − 1 (n − 1)
f ″(a) + ...... +
f
(a) + R n ( x)
2!
(n − 1) !
( x − a) n (n)
f (ξ) ; a < ξ < x.
n!
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.
ex = 1 + x +
Sol.
where
Rn(x) =
x2 x3
xn − 1
+
+ ...... +
+ R n ( x)
2! 3!
(n − 1) !
(3)
xn θ
e ,0<θ<x
n!
xn x
e
n!
Maximum absolute error (at θ = x) =
and Maximum relative error
=
xn
n!
1
n!
For a six decimal accuracy at x = 1, we have
Hence,
(er)max. at x = 1 is =
1 1
< × 10 −6
n! 2
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 e
FG 1 + x IJ = 2 F x + x
H 1 − x K GH 3
3
+
I
JK
x5
+ ......
5
to compute the value of log (1.2) correct to seven decimal places and find the
number of terms retained.
Sol.
loge
FG 1 + x IJ = 2 FG x + x
H 1 − xK H 3
3
+
I
JK
x5
x 2n −1
+ ... +
+ Rn(x)
5
2n − 1
58
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL TECHNIQUES
If we retain n terms, then
Rn(x) =
FG
H
IJ
K
2 x 2n +1
1+ ξ
log e
;0<ξ<x
2n + 1
1− ξ
Maximum absolute error (at ξ = x) =
and maximum relative error =
FG
H
2 x 2 n+ 1
1+ x
log e
2n + 1
1− x
IJ
K
2
x2n+1
2n + 1
1+ x
1
= 1.2 ⇒ x =
1− x
11
Let
FG IJ
H K
2
1
1
is
2n + 1 11
11
Hence (er)max. at x =
2 n+ 1
.
For seven decimal accuracy,
FG IJ
H K
2
1
.
2n + 1 11
2n + 1
<
1
× 10 −7
2
(2n + 1) (11)2n + 1 > 4 × 107
which gives n ≥ 3.
Hence, retaining the first three terms of the given series, we get
F
GH
loge (1.2) = 2 x +
x3 x5
+
3
5
I at FG x = 1 IJ = 0.1823215 .
JK H 11K
Example 3. The function f(x) = tan–1x can be expanded as
tan–1x = x −
x3 x 5
x 2n − 1
+
− ...... + ( − 1) n − 1 .
+ ......
3
5
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 .
For x = 1,
(n + 1)th term =
(− 1) n
2n + 1
x 2n + 1
2n + 1
ERRORS
59
For the determination of tan–1 (1) correct up to eight significant digit
accuracy,
(− 1) n
1
< × 10 −8
2n + 1
2
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 x6
+
−
+ ...
2! 4! 6!
Compute the number of terms required to estimate cos
is correct to at least two significant digits.
x2 x4 x6
+
−
+ ... + Rn(x)
2! 4! 6!
Sol.
cos x = 1 –
where
Rn(x) = (– 1)n
x 2n
cos ξ; 0 < ξ < x
2n !
Maximum absolute error (at ξ = x) = ( − 1)n
Maximum relative error =
At x =
π
,
4
x 2n
( 2n ) !
(er)max. =
( π / 4 )2n
( 2n ) !
For two significant digit accuracy,
( π / 4 )2n 1
≤ × 10–2
( 2n ) !
2
i.e.,
FG π IJ so that the result
H 4K
( 2n ) !
( π / 4 )2n
≥ 200
n = 3 satisfies it.
2n
x
x 2n
cos x =
cos x
(
2n ) !
( 2n ) !
60
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL 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 xy2
z3
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
, where x = 4.536 and y = 1.32; both x and y being correct to the
y
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)
, a < c < b.
b− a
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
( x − a) n − 1 (n − 1)
f
(a) + R n ( x)
f ″(a) + ...... +
2!
(n − 1) !
where Rn(x) is remainder term, can be expressed in the form
Rn(x) =
( x − a) n n
f (c) , a < c < x.
n!
Theorem 5. Maclaurin’s expansion.
f(x) = f(0) + x f ′(0) +
x2
x n ( n)
f ″ (0) + ...... +
f (0) + ......
2!
n!
Theorem 6. Taylor’s series for a function of two variables.
f(x1 + Δx1, x2 + Δx2) = f(x1, x2) +
+
2.9
∂f
∂f
Δx1 +
Δx2
∂x2
∂ x1
LM
MN
OP
PQ
1 ∂2 f
∂2 f
∂2 f
2
(
Δ
x
)
+
2
Δ
x
.
Δ
x
+
(Δx2 ) 2 + ......
1
1
2
2
2
2 ∂x1
∂x1∂x2
∂x2
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-B ASED NUMERICAL
AND
S TATISTICAL 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
One memory
location or word
6
5
2
3
1
sign
assumed
decimal point
position
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:
sign of mantissa
sign of exponent
+
.
4
+
3
7
mantissa
6
0
8
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
(iv) .6434 E 3 and
.5433 E 7
.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
.5433 E 7
| ∵ .4546 E 3 = .0000 E 7
64
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL 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.
NOTE
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.
ERRORS
65
Example 3. In normalized floating point mode, carry out the following
mathematical operations:
(i) (.4546 E 3) + (.5454 E 8)
Sol. (i)
(ii) (.9432 E – 4) – (.6353 E – 5).
.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
(iii) .1111 E 51 and .4444 E 50
(ii) .1111 E 10 and .1234 E 15
(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-B ASED NUMERICAL
AND
S TATISTICAL 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
x
2
sin .0698 = .6974 E – 1.
Compare it when evaluated 2 sin2
Assume
Sol.
1 – cos (.1396) = .1000 E 1 – .9903 E 0
= .1000 E 1 – .0990 E 1 = .1000 E – 1
Now,
x
= sin (.0698) = .6974 E – 1
2
x
2 sin2 = (.2000 E 1) × (.6974 E – 1) × (.6974 E – 1)
2
= .9727 E – 2
sin
The value obtained by the alternate formula is closer to the true value
.9728 E – 2.
ERRORS
67
x 2 − y2
x+ y
using normalized floating point arithmetic. Compare with the value of (x – y).
Indicate the error in the former.
Example 3. For x = .4845 and y = .4800, calculate the value of
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,
Also,
x 2 − y2
= .0043 E 0 ÷ .9645 E 0 = .4458 E – 2
x+ y
x – y = .4845 E 0 – .4800 E 0 = .0045 E 0 = .4500 E – 2
Relative error
=
.4500 − 0.4458
= .93% .
.4500
Example 4. For e = 2.7183, calculate the value of ex when x = .5250 E 1. The
expression for ex is
ex = 1 + x +
Sol.
Also,
x 2 x3
+
.
2! 3!
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
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 ± 106 − 10 2
2
68
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL TECHNIQUES
106 = .1000 E 7 and
Now,
102 = .1000 E 3
106 – 102 = .1000 E 7
∴
106 − 10 2 = .1000 E 4
∴
∴ Roots are
FG .1000 E 4 + .1000 E 4 IJ
H
K
2
and
FG .1000 E 4 – .1000 E 4 IJ
H
K
2
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
the larger root.
So, First root
c
, so the smaller root may be obtained by dividing (c/a) by
a
and Second root
= .1000 E 4
=
25
.2500 E 2
=
= .2500 E − 1
.1000 E 4 .1000 E 4
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.
b2 > > | 4ac |
Sol. Here
The roots of the equation
ax2
| See Example 5
– bx + c = 0 are
b + b2 − 4 ac
b − b2 − 4 ac
and
2a
2a
The product of the roots is
∴ The smaller root is
c
.
a
Fb+
GG
H
c/ a
i. e.,
b+
b − 4 ac I
J
JK
2a
2
Here a = 1 = .1000 E 1, b = 400 = .4000 E 3,
b2
∴
2c
b2 − 4 ac
c = 1 = .1000 E 1
– 4ac = .1600 E 6 – .4000 E 1 = .1600 E 6 (to four digit accuracy)
b 2 − 4 ac = .4000 E 3
∴ Smaller root
=
2 × (.1000 E 1)
.2000 E 1
=
= .25 E – 2 = .0025.
.4000 E 3 + .4000 E 3 .8000 E 3
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 +
Sol.
FG b − a IJ .
H 2 K
a = .4568 E 1, b = .6762 E 1
Let c be the middle value of numbers, then
c=
a + b .4568 E 1 + .6762 E 1 .1133 E 2
=
=
= .5665 E 1
2
.2000 E 1
.2000 E 1
However, if we use the formula
c=a+
FG b − a IJ = .4568 E 1 + FG .6762 E 1 − .4568 E 1IJ
H 2 K
H .2000 E 1 K
= .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 ′(x) =
1
(1 + x)–1/2,
2
f ″(x) = –
f ″′(x) =
f(0) = 1
1
(1 + x)–3/2,
4
f ′(0) =
1
2
f ″(0) = –
1
4
3
(1 + x)–5/2
8
Taylor’s series expansion with remainder term may be written as
(1 + x)1/2 = 1 +
x x2
1
x3
−
+
; 0 < ξ < 0.1
2
8
16 [(1 + ξ) 1/2 ]5
The truncation term is given by
F
GH
T = (1 + x)1/2 – 1 +
We have
f(0.05) = 1 +
I
JK
x x2
1
x3
−
=
.
2
8
16 [(1 + ξ) 1/2 ]5
0.05 (0.05) 2
= 0.10246875 × 101
−
2
8
70
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL TECHNIQUES
Bound of the truncation error, for x ∈ [0, 0.1] is
|T|≤
(0.1) 3
16 [(1 + ξ) 1/2 ]5
≤
(0.1) 3
= 0.625 × 10–4.
16
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 inaccuracies 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
∴
Thus,
ab – ac = .0005 E 2 = .5000 E – 1
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-B ASED NUMERICAL
AND
S TATISTICAL 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 piecewise 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-B ASED NUMERICAL
AND
S TATISTICAL 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
5.
Discuss the consequences of normalized floating point representation of numbers.
6.
Calculate the value of x2 + 2x – 2
75
and (2x – 2) + x2
where x = .7320 E 0
7.
8.
using normalized floating point arithmetic and prove that they are not the same. Compare
with value of (x2 – 2) + 2x.
Find the value of (1 + x)2 and (x2 + 2x) + 1
when x = .5999 E – 2.
Find the value of
3
5
3!
5!
x
x
sin x ~
−x−
+
9.
10.
with an absolute error smaller than .005 for x = .2000 E 0 using normalized floating
point arithmetic with a 4 digit mantissa.
Write a short note on machine computation.
Prove the following consequence of the normalized floating point representation of
numbers by taking x = .6667
6x ≠ x + x + x + x + x + x.
11.
12.
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.
(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?
Chapter
3
ALGEBRAIC AND
TRANSCENDENTAL
EQUATIONS
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
1
x1 = (a + b).
2
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.
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.
1
The second approximation to the root is x2 = (a + x1). If f (x2) is (–)ve the
2
1
root lies between x1 and x2. The third approximation to the root is x3 = (x1 +
2
x2), and so on.
y=
f(x
)
Y
f(b)
a x2
O
f(a)
x3
x1 b
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
3.3
AND
TRANSCENDENTAL EQUATIONS
FLOW-CHART
START
Define F(x)
Get the value of
interval (a, b),
error, iter
Initialize i = 1
Call subroutine
bisect mid
Y
B=X
Yes
is
F(mid)
<0
A=X
B
is
Abs (XI-X)
< Aerr
Yes
X
No
i < iter
Subroutine
bisect
X = (A + B)/2
Yes
Y
Iter + +
No
X
Print solution does
not converge
Print ITER, Xl
Print iter, Xl
RETURN
STOP
79
80
COMPUTER-BASED NUMERICAL
3.4
PROGRAM WRITING
AND
STATISTICAL TECHNIQUES
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→∞
ei + 1
ei k
≤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
ei + 1
ei
= 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→∞
we get
ei + 1
≤A
ei k
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 =
⇒
p1 < x1 < q1
FG p
H
1
+ q1
2
IJ
K
Now either the root lies in [a, x1] or in [x1, b].
∴ either
[p2, q2] = [p1, x1]
⇒ either
p2 = p1, q2 = x1
⇒
p1 ≤ p2, q2 ≤ q1
Also,
x2 =
or
[p2, q2] = [x1, q1]
or
p2 = x1, q2 = q1
p2 + q2
so that p2 < x2 < q2
2
82
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Continuing this way, we obtain that at nth step,
xn =
and
pn + qn
, pn < xn < qn
2
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.
lim pn = p
Let,
n→∞
and
lim qn = q.
n→∞
Now, since the length of the interval is decreasing at every step, we get
that
lim (qn – pn) = 0
n→∞
Also,
⇒
pn < xn < qn
lim pn ≤ lim xn ≤ lim qn
p ≤ lim xn ≤ q
⇒
⇒
⇒ q=p
lim xn = p = q
(2)
Further, since a root lies in [pn, qn], we shall have
f(pn) . f(qn) < 0
⇒
0 ≥ lim [ f ( pn ) . f ( qn )]
⇒
0 ≥ f(p) . f(q)
⇒
0 ≥ [f(p)]2
n→∞
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.
Since
and
f(x) = x log10 x – 1.2
f(2.74) = – .000563 i.e., (–)ve
f(2.75) = .0081649
i.e., (+)ve
Hence, the root lies between 2.74 and 2.75.
∴ First approximation to the root is
x1 =
Now
2.74 + 2.75
= 2.745
2
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 =
Now
2.74 + 2.745
= 2.7425
2
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 =
Now
2.74 + 2.7425
= 2.74125
2
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 =
Now
2.74 + 2.74125
= 2.740625
2
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.7409375
2
84
COMPUTER-BASED NUMERICAL
Now
AND
STATISTICAL TECHNIQUES
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 =
Now
2.740625 + 2.7409375
= 2.74078125
2
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 =
Now
2.740625 + 2.74078125
= 2.740703125
2
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 =
Now
2.740625 + 2.740703125
= 2.740664063
2
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.740644532
2
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
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<process.h>
#include<string.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("\n\t\t\t x*log(x) – 1.2 = 0\n\n");
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 (f2>0)
{
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(f1<0)
{
break;
}
}
//...Printing Result
printf("\t\t-----------------------------------------");
printf("\n\t\t ITERATIONS\t\t
ROOTS\n");
printf("\t\t-----------------------------------------");
for(;count<=n;count++)
{
x0=(x1+x2)/2.0;
f0=F(x0);
if(f0==0)
{
root=x0;
}
if(f0*f1<0)
{
x2=x0;
}
else
{
x1=x0;
f1=f0;
}
printf("\n\t\t ITERATION %d", count);
printf("\t
:\t
%f",x0);
if(fabs((x1-x2)/x1) < EPS)
{
printf("\n\t\t---------------------------------");
printf("\n\t\t
Root = %f",x0);
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
87
printf("\n\t\t Iterations = %d\n", count);
printf("\t\t------------------------------------");
getch();
exit(0);
}
}
printf("\n\t\t----------------------------------------");
printf("\n\t\t\t Root = %7.4f",x0);
printf("\n\t\t\t Iterations = %d\n", count-1);
printf("\t\t------------------------------------------");
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:\tc\exe>
Example 2. Find a root of the equation
x3 – 4x – 9 = 0
using Bisection method in four stages.
f(x) ≡ x3 – 4x – 9
Sol. Let
Since
and
f(2.706) = – .009488
i.e., (–)ve
f(2.707) = .008487 i.e., (+)ve
Hence, the root lies between 2.706 and 2.707.
∴ First approximation to the root is
x1 =
Now
2.706 + 2.707
= 2.7065
2
f(x1) = – .0005025 i.e., (–)ve
Hence, the root lies between 2.7065 and 2.707.
∴ Second approximation to the root is
x2 =
Now
2.7065 + 2.707
= 2.70675
2
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
2.7065 + 2.70675
= 2.706625
2
x3 =
Now
f(x3) = .001744
i.e., (+)ve
Hence, the root lies between 2.7065 and 2.706625.
∴ Fourth approximation to the root is
2.7065 + 2.706625
= 2.7065625
2
Hence, the root is 2.7065625, correct to three decimal places.
x4 =
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 =
Now
0.73 + 0.74
= 0.735
2
f(0.735) = (–)ve
Hence, the root lies between 0.735 and 0.74. Second approximation to the
root is
x2 =
Now
0.73 + 0.74
= 0.7375
2
f(0.7375) = (–)ve
Hence, the root lies between 0.7375 and 0.74. Third approximation to the
root is
0.7375 + 0.74
= 0.73875
2
x3 =
Now
f(0.73875) = (–)ve
Hence, the root lies between 0.73875 and 0.74.
Fourth approximation to the root is
x4 =
Now
1
(0.73875 + 0.74) = 0.739375
2
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 =
Now
1
(0.73875 + 0.739375) = 0.7390625
2
f(0.7390625) = (–)ve
Hence, the root lies between 0.7390625 and 0.739375
Sixth approximation to the root is
x6 =
Now
1
(0.7390625 + 0.739375) = 0.73921875
2
f(0.73921875) = (+)ve
Hence, the root lies between 0.7390625 and 0.73921875
Seventh approximation to the root is
x7 =
Now
1
(0.7390625 + 0.73921875) = 0.73914
2
f(0.73914) = (+)ve
Hence, the root lies between 0.7390625 and 0.73914
Eighth approximate to the root is
x8 =
1
(0.7390625 + 0.73914) = 0.73910
2
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.
Since
and
f(x) = x3 – 5x + 1
f(.2016) = .0001935
f(.2017) = – .0002943
i.e., (+)ve
i.e., (–)ve
Hence, the root lies between .2016 and .2017.
First approximation to the root is
x1 =
Now
.2016 + .2017
= .20165
2
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
.2016 + .20165
= .201625
2
Now
f(x2) = .00007159 i.e., (+)ve
Hence, the root lies between .201625 and .20165.
Third approximation to the root is
x2 =
.201625 + .20165
= .2016375
2
Now
f(x3) = .00001061 i.e., (+)ve
Hence, the root lies between .2016375 and .20165.
Fourth approximation to the root is
x3 =
.2016375 + .20165
= .20164375
2
Now
f(x4) = – .00001987 i.e., (–)ve
Hence, the root lies between .2016375 and .20164375.
x4 =
∴ Fifth approximation to the root is
.2016375 + .20164375
= .201640625
2
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.
x5 =
Sol. Here,
Since
and
f(x) = x3 – x – 1
f(1.324) = – .00306
i.e., (–)ve
f(1.325) = .00120 i.e.,
(+)ve
Hence, the root lies between 1.324 and 1.325.
∴ First approximation to the root is
x1 =
Now
1.324 + 1.325
= 1.3245
2
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
= 1.32475
2
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 =
Now
1.3245 + 1.32475
= 1.324625
2
f(x3) = – .000396 i.e., (–)ve
Hence, the root lies between 1.324625 and 1.32475.
∴ Fourth approximation to the root is
x4 =
Now
1.324625 + 1.32475
= 1.3246875
2
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
= 1.32471875
2
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
Since
and
f(x) = x2 – 30
f(5.477) = – .00247 i.e.,
f(5.478) = .00848
(–)ve
i.e., (+)ve
Hence, the root lies between 5.477 and 5.478
∴ First approximation to the root is
x1 =
Now
5.477 + 5.478
= 5.4775
2
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
= 5.47725
2
ALGEBRAIC
Now
AND
TRANSCENDENTAL EQUATIONS
93
f(x2) = .00026 i.e., (+)ve
Hence, the root lies between 5.477 and 5.47725
∴ Third approximation to the root is
x3 =
Now
5.477 + 5.47725
= 5.477125
2
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
= 5.4771875
2
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.
2.
3.
4.
(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.
Find a real root of ex = 3x by Bisection method.
Find the smallest positive root of x3 – 9x + 1 = 0, using Bisection method correct to three
decimal places.
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:
9.
(i) x3 – x – 4 = 0
(ii) x3 – x2 – 1 = 0
(iii) x3 + x2 – 1 = 0
(iv) x3 – 3x – 5 = 0.
x3
– x – 11 = 0 using Bisection method correct to 3 decimal places which
Find a root of
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 algorithm 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
Y
y=
x0 x2
TRANSCENDENTAL EQUATIONS
95
x
y=
O
AND
φ(x)
x3 x1
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
NOTE
3.13
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.
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,
φ( xn − 1 ) − φ (α)
xn − 1 − α
Hence (4) becomes
= φ′(ξ), where xn – 1 < ξ < α
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.
NOTE
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
NOTE
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)
NOTE
Steps 4 to 6 are repeated until the procedure converges to a root or iterations
reach n.
ALGEBRAIC
3. For i = 1 to n in steps of 1 do
4. x0 ← x1
5. x1 ← g(x0)
6. If
x1 − x0
x1
≤ 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.
AND
TRANSCENDENTAL EQUATIONS
97
98
COMPUTER-BASED NUMERICAL
3.15
FLOW-CHART FOR ITERATION METHOD
AND
STATISTICAL TECHNIQUES
START
Define F(x)
Get the value of x 0 and max_error
Set n = 0.
xn+1 = f(xn)
n=n+1
Is
| xn+1 – xn | >
max. error
No
Print the root is x n.
STOP
Yes
ALGEBRAIC
3.16
AND
TRANSCENDENTAL EQUATIONS
COMPUTER PROGRAM
//Program for Solution by ITERATION method
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define EPS 0.00005
#define F(x)
#define f(x)
(x*x*x + 1)/2
x*x*x - 2*x + 1
void ITER();
void main ()
{
clrscr();
printf("\n\t Solution by ITERATION method \n");
printf("\n\t Equation is ");
printf("\n\t\t\t\t X*X*X - 2*X + 1 = 0\n\n");
ITER();
getch();
}
void ITER()
{
float x1,x2,x0,f0,f1,f2,error;
int i=0,n;
for(x1=1;;x1++)
{
f1=F(x1);
if (f1>0)
break;
}
for(x0=x1-1;;x0--)
{
f0=f(x0);
if(f0<0)
break;
}
99
100
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
x2=(x0+x1)/2;
printf("Enter the number of iterations:");
scanf("%d",&n);
printf("\n\n\t\t The 1 approximation to the root is: %f",x2);
for(;i<n-1;i++)
{
f2=F(x2);
printf("\n\n\t\t The %d approximation to the root is:
%f",i+2,f2);
x2=F(x2);
error=fabs(f2-f1);
if(error<EPS)
break;
f1=f2;
}
if(error>EPS)
printf("\n\n\t NOTE:- The number of iterations
are not sufficient.");
printf("\n\n\n\t\t\t------------------------------");
printf("\n\t\t\t The root is %.4f",f2);
printf("\n\t\t\t-----------------------------");
}
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
NOTE
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,
Hence,
φ(x) = e–x so φ′(x) = – e –x
| φ′(x) | < 1 for x < 1, which assures that iteration is convergent.
102
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Starting with x0 = 1, we find that successive iterates are given by
x1 =
1
= 0.3678794
e
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π
+ 1 = (–)ve
2
∴ A root lies between 0 and π/2.
Rewriting the given equation as
x=
We have
and
1
(cos x + 1) = φ(x)
3
φ′(x) = –
| φ′(x) | =
sin x
3
1
| sin x | < 1 in (0, π/2)
3
Hence the iteration method can be applied and we start with x0 = 0. Then
the successive approximations are
x1 = φ(x0) =
1
(cos 0 + 1) = 0.6667
3
x2 = φ(x1) =
1
[cos 0.6667 + 1] = 0.5953
3
x3 = φ(x2) =
1
[cos (0.5953) + 1] = 0.6093
3
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
TRANSCENDENTAL EQUATIONS
AND
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=
we have
∴
1
(log10 x + 7) = φ(x),
2
φ′(x) =
IJ
K
FG
H
1 1
log 10 e
2 x
| φ′(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
(log10 3.6 + 7) = 3.77815
2
x2 = φ(x1) =
1
(log10 3.77815 + 7) = 3.78863
2
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+
x2
(2 !) 2
−
x3
(3 !) 2
+
x4
(4 !) 2
−
x5
(5 !) 2
+ ...... = 0 .
Sol. Writing the given equation as
x=1+
x2
(2 !) 2
−
x3
(3 !) 2
+
x4
(4 !) 2
−
x5
(5 !) 2
+ ...... = φ( x)
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 +
x2 = φ(x1) = 1 +
1
(2 !)
2
−
1
(3 !)
(1.2239) 2
(2 !) 2
−
2
+
1
(4 !)
2
−
(1.2239) 3
(3 !) 2
1
(5 !) 2
+ ...... = 1.2239
(1.2239) 4
+
(4 !) 2
−
(1.2239) 5
(5 !) 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 = –
xn + 1 =
F ax + bI
GH x JK
n
will converge near x = α if | α | > | β | and the iteration
n
−b
will converge near x = α if | α | < | β |.
xn + a
Sol. Since α, β are the roots of x2 + ax + b = 0,
we have
α + β = – a and αβ = b
The formula xn + 1 = –
converge to x = α if
RS
T
F ax + bI , which is of the form x
GH x JK
n
n
d − (ax + b)
dx
x
x = xn
= f(xn), will
Using condition
of iteration method
<1
b
<1
xn 2
⇒
⇒
UV
W
n + 1
| xn2 | > | b |
or xn2 > | b |
or
| α |2 > | b | as
or
| α |2 > | α | | β |
or
|α|>|β|
xn → α
(∵
αβ = b)
ALGEBRAIC
Similarly,
xn + 1 =
TRANSCENDENTAL EQUATIONS
105
−b
will converge to x = α if
xn + a
LM d F − b I OP
N dx GH x + a JK Q
<1
x = xn
b
or
AND
( xn + a) 2
<1
or
(xn + a)2 > | b |
or
β2 > | b |
or
(α + a)2 > | b | as xn → α
(∵
α + a = – β)
| β |2 > | α | | β |
or
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 x 2 − x 3
= f(x)
10
− 12 x − 3 x 2
10
Clearly, f ′(x) < – 1 in neighborhood of x = 1. Hence | f ′(x) | > 1, and
neither the method nor the sequence <xn> converge.
Hence,
f ′(x) =
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
i.e., if
or
– 1 < f ′(x) < 1
– 1 < 1 + 2kx < 1
Moreover, the convergence will be rapid if f ′(a) ~
– 0
i.e., if
i.e.,
1 + 2ka ~
– 0
1 + 2k 3 ~
– 0
⇒ k=–
1
2 3
106
COMPUTER-BASED NUMERICAL
AND
We may take k = –
STATISTICAL TECHNIQUES
1
to insure a rapid convergence by this formula.
4
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,
Let, for some p(positive integer)
a = F(a)
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) + ...... +
( xn − a) p ( p)
( xn − a) p − 1 ( p − 1)
(a) +
F
F (ξ)
( p − 1) !
p!
where ξ is some point between x = xn and x = a.
⇒
⇒
xn + 1 = a +
( xn − a) p
p!
xn + 1 – a = (xn – a) p .
F ( 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)
1
(sin x + 2), suggesting two iterating procedures for its solution.
5
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)
and also as x =
∴
φ′(x) =
5
1 − (5 x − 2) 2
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) =
φ′(x) =
1
(sin x + 2)
5
1
cos x
5
ALGEBRAIC
Hence | φ′(x) | ≤
AND
TRANSCENDENTAL EQUATIONS
107
1
for all x because | cos x | ≤ 1
5
∴ φ(x) will succeed.
Hence, taking x = φ(x) =
1
(sin x + 2) and the initial value x0 = 0.5, we have
5
the first approximation x1 given by
x1 =
1
(sin 0.5 + 2) = 0.4017
5
x2 =
1
[sin (0.4017) + 2] = 0.4014
5
x3 =
1
[sin (0.4014) + 2] = 0.4014
5
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 =
so that,
φ(x) =
∴
φ′(x) = –
1
1+ x
1
2(1 + x) 3 / 2
1
1+ x
108
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
We have, | φ′(x) | < 1 for x < 1
Hence the iterative method can be applied.
x0 = 0.5, we get
Take
1
x1 = φ(x0) =
= 0.81649
1.5
1
x2 = φ(x1) =
1.81649
= 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)
Putting
Let
(5)
i = 0, x1 = x0(2 – 41 x0)
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
F
GH
1F
= Gx
2H
xi + 1 =
Sol. Put i = 0,
Let
∴
x1
x0 = 4.5
0
0
FG
IJ
H
K
1F
20 I
J = 4.472
= GH 4.47 +
2
4.47 K
x1 =
Put i = 1, x1 = 4.47, x2
I
JK
20 I
+
x JK
1
20
xi +
.
2
xi
1
20
4.5 +
= 4.47
2
4.5
ALGEBRAIC
Put i = 2, x2 = 4.472,
AND
TRANSCENDENTAL EQUATIONS
109
x3 = 4.4721
– 4.472 correct to three decimal places.
20 ~
∴
Example 14. Find the cube root of 15 correct to four significant figures by
iterative method.
x = (15)1/3 ∴ x3 – 15 = 0
Sol. Let
The real root of the above equation lies in (2, 3). The equation may be
written as
x=
Now,
15 + 20 x − x 3
= φ(x)
20
3x 2
20
φ′(x) = 1 –
Iterative formula is xi + 1 =
15 + 20 xi − xi 3
20
Put
i = 0, x0 = 2.5, we get x1 = 2.47
Put
i = 1 in (6),
x2 = 2.466
3
(6)
(where x1 = 2.47)
x3 = 2.4661
Similarly,
∴
∴ | φ′(x) | < 1 (for x ≈ 2.5)
15 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 =
Starting with x0 = 0, we get
x1 = e
e
x n3 + 1
110
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
x2 =
e
1 + e3
= e(1 + e3)–1
= e(1 – e3 + e6 – ...)
= e – e4 + e7
x3 =
(neglecting higher powers of e)
e
1 + ( e − e 4 + e7 ) 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.
2.
3.
Apply iteration method to solve e–x = 10x.
LM
N
OP
Q
1 1
< 1 if x ≥ 0.
10 e x
Find by iterative method, the real root of the equation 3x – log10 x = 6 correct to four
significant figures.
Solve by iteration method:
Hint: | φ′(x) | =
x
x+1
(ii) sin x =
2
x−1
(iii) x3 = x2 + x + 1 near 2 (use 5 iterations)
(v) x3 – 2x2 – 5 = 0
(vi) x3 – 2x2 – 4 = 0.
(iv) x3 + x + 1 = 0
Use the iterative method to find, correct to four significant figures, a real root of each of
the following equations:
(i) 1 + log x =
4.
(i) x =
1
(ii) x = (5 – x)1/3
( x + 1)2
(v) ex = cot x
(viii) 5x3 – 20x + 3 = 0.
(iv) x sin x = 1
(vii) x2 – 1 = sin2 x
5.
By iteration method, find
6.
The root of the equation x =
xn+1 =
(iii) sin x = 10(x – 1)
(vi) 1 + x2 – x3 = 0
30 .
1
+ sin x by using the iteration method
2
1
+ sin xn, x0 = 1
2
ALGEBRAIC
7.
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.
The equation f(x) = 0, where
f(x) = 0.1 – x +
x2
(2 !)
2
−
x3
(3 !)
2
+
x4
(4 !) 2
– ...
has one root in the interval (0, 1). Calculate this root correct to 5 decimal places.
8.
FG x − a IJ passing through the points (1, 1) and (2, 3).
H c K
F 1 − a IJ = 1 and c cosh FG 2 − a IJ = 3 to get
[Hint: Eliminate a from c cosh G
H c K
H c K
F 1I
1 + c cosh G J
H c K = φ(c)]
c=
3I
F
cosh G J
H cK
Find a catenary y = c cosh
−1
−1
9.
The equation x2 + ax + b = 0 has two real roots, α and β. Show that the iteration method
xn+1 = –
Fx
GH
n
2
+b
a
I
JK
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
3 + (k − 4) xn + 5 xn 2 − xn3
, k integer; x0 = 4
k
(i) Determine which value of k will give the fastest convergence.
xn+1 =
(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
< 1 and
+
∂y
∂x
∂G
∂G
< 1 in neighborhood of root.
+
∂y
∂x
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
= 0.4x
∂x
∂G
= 0.3y2
∂x
∂F
=0
∂y
∂G
= 0.6xy
∂y
It is easy to see that x = 1 and y = 1 are the roots of the system.
Choosing
x0 =
∂F
∂x
and
∂G
∂x
1
,
2
y0 =
+
( x0 , y0 )
( x0 , y0 )
+
1
, we find that
2
∂F
∂y
( x0 , y0 )
∂G
∂y
( x0 , y0 )
= 0.2 < 1
= 0.225 < 1
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
113
∴ Conditions are satisfied. Hence,
x1 = F(x0, y0) =
and
0.2
+ 0.8 = 0.85
4
y1 = G(x0, y0) =
0.3
+ 0.7 = 0.74*
8
For approximation II, we obtain
and
x2 = F(x1, y1) = 0.2(0.85)2 + 0.8 = 0.9445
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
A {x0, f(x0)}
x3
O
x0
x2
x1
P(x)
X
B
{x1, f(x1)}
*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 ( x1 ) − f ( x0 )
( x − x0 )
x1 − x0
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 –
x1 − x0
f ( x0 )
f ( x1 ) − f ( x0 )
(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.
NOTE
3.19
The order of convergence of the Regula Falsi method is 1.618.
ALGORITHM
Step 01.
Step 02.
Start of the program.
Input the variables x0, x1, e, n for the task.
Step 03.
Step 04.
f0 = f(x0)
f1 = f(x1)
Step 05.
Step 06.
for i = 1 and repeat if i < = n
x2 = (x0 f1-x1 f0)/(f1-f0)
Step 07.
Step 08.
f2 = x2
if | f2 | < = e
Step 09.
Step 10.
Print “convergent”, x2, f2
If sign (f2) ! = sign (f0)
Step 11.
Step 12.
x1 = x2 & f1 = f2
else
Step 13.
Step 14.
x0 = x2 & f0 = f2
End loop
Step 15.
Step 16.
Print output
End of program.
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
115
3.19.1 Aliter Algorithm: Method of False Position
1. Read x0, x1, e, n
NOTE
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.
116
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
3.20 FLOW-CHART
START
Define function f(x)
Define function regula
Get the value of
x0, x1, aerr, mitr
initialize itr
Call function regula with x2, x0, x1
f(x0), f(x1), itr
A
B
x1 = x2
Yes
Is
f(x0)*f(x2)
<0
No
Call function regula with x3, x0, x1
f(x0), f(x1), itr
Is
fabs (x3 – x2)
< aerr
Yes
x0 = x2
A
C
No
x2 = x3
Is itr
< maxitr
Yes
No
Print "Not convergent
STOP
B
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
117
A
x = x0 – (x1 – x0)/(f(x1) – f(x0))*f(x0)
Print itr, x
Return
C
Print ‘‘solution’’
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
and
i.e., (–)ve
f(0.4) = 0.0975 i.e., (+)ve
∴ The root lies between 0.3 and 0.4.
Using Regula Falsi method,
x2 = x0 –
x1 − x0
f ( x0 )
f ( x1 ) − f ( x0 )
= (0.3) −
(0.4) − (0.3)
(− 0.154)
(0.0975) − (− 0.154)
|∵
= (0.3) +
Now
x0 = 0.3 and x1 = 0.4 (let)
FG 0.1 × 0.154 IJ = 0.3612
H 0.2515 K
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.
x3 = x0 –
Now again,
( x2 − x0 )
f ( x0 )
f ( x2 ) − f ( x0 )
Replacing x1 by x2
RS (0.3612) − (0.3) UV (− 0.154)
T (0.0019) − (− 0.154) W
F 0.0612 IJ (0.154) = 0.3604
= (0.3) + G
H 0.1559 K
= (0.3) −
Now
f(x3) = f(0.3604) = – 0.00005 = (–)ve
∴ The root lies between 0.3604 and 0.3612.
Now again,
RS x − x UV f (x )
Replacing x
T f (x ) − f (x ) W
L (0.3612 − 0.3604) OP (− 0.00005)
= (0.3604) − M
N (0.0019) − (− 0.00005) Q
F 0.0008 IJ (0.00005) = 0.36042
= 0.3604 + G
H 0.00195 K
x4 = x3 −
2
3
2
3
3
0
by x3
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
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<string.h>
#include<process.h>
//...Formulae declaration
#define EPS
#define f(x)
0.00005
3*x+sin(x)-exp(x)
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
//...Function Declaration Prototype
void FAL_POS();
//...Main Execution Thread
void main()
{
clrscr();
printf("\n Solution by FALSE POSITION method\n");
printf("\n Equation is ");
printf("\n\t\t\t 3*x + sin(x)-exp(x)=0\n\n");
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(f1>0)
{
break;
{
else
{
x1=x1+0.1;
}
}
x0=x1-0.1;
f0=f(x0);
119
120
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
printf("\n\t\t-----------------------------------------");
printf("\n\t\t
ITERATION\t x2\t\t F(x)\n");
printf("\t\t--------------------------------------------");
for(i=0;i<itr;i++)
{
x2=x0-((x1-x0)/(f1-f0))*f0;
f2=f(x2);
if(f0*f2>0)
{
x1=x2;
f1=f2;
}
else
{
x0=x2;
f0=f2;
}
if(fabs(f(2))>EPS)
{
printf("\n\t\t%d\t%f\t%f\n",i+1,x2,f2);
}
}
printf("\t\t--------------------------------------------");
printf("\n\t\t\t\tRoot=%f\n",x2);
printf("\t\t-------------------------------------------");
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
3
0.360409
0.360422
-0.000031
0.000000
4
5
0.360422
0.360422
-0.000000
0.000000
6
7
0.360422
0.360422
0.000000
0.000000
8
9
0.360422
0.360422
0.000000
0.000000
10
11
0.360422
0.360422
0.000000
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 –
=0−
Now
( x1 − x0 )
f ( x0 )
f ( x1 ) − f ( x0 )
1− 0
(1) = 0.31467
− 3.17798
f(x2) = f(0.31467) = 0.51987
i.e., the root lies between 0.31487 and 1.
Again
x3 = 0.31487 –
= 0.44673
(1 − 0.31487)
(0.51987)
(− 2.17798 − 0.51987)
122
COMPUTER-BASED NUMERICAL
Now
AND
STATISTICAL TECHNIQUES
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
#include<stdio.h>
#include<conio.h>
#include<math.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.5f\n",*itr,*x);
}
main()
{
int itr=0,maxitr;
float x0,x1,x2,x3,aerr;
printf("Enter the values for x0,x1, allowed error,
max.iteration\n");
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.4f\n",itr,x3);
getch();
return (0);
}
x2=x3;
}while (itr<maxitr);
printf("Solution does not converge, iterations not
sufficient\n");
getch();
return(1);
OUTPUT
Enter the values for x0,x1, allowed error, max.iteration
0
1
.00005
20
Iteration number
Iteration number
1 x = 0.31467
2 x = 0.44673
Iteration number
Iteration number
3 x = 0.49402
4 x = 0.50995
Iteration number
Iteration number
5 x = 0.51520
6 x = 0.51692
Iteration number
Iteration number
7 x = 0.51748
8 x = 0.51767
Iteration number
Iteration number
9 x = 0.51773
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 –
( x1 − x0 )
f ( x0 )
f ( x1 ) − f ( x0 )
124
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
=2–
Now
(3 − 2)
(– 1) = 2.0588
(16 + 1)
f(x2) = f(2.0588) = – 0.3908
i.e., The root lies between 2.0588 and 3.
Now again,
x3 = 2.0588 –
FG 3 − 2.0588 IJ (– 0.3908) = 2.0813
H 16 + 0.3908 K
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
and
f(2.35) = – 0.03
f(2.37) = 0.009
Hence, the root lies between 2.35 and 2.37.
Using Regula-Falsi method,
RS x − x UV f (x )
T f (x ) − f (x ) W
F 2.37 − 2.35 IJ (− 0.03)
= 2.35 − G
H 0.009 + 0.03 K
F 0.02 IJ (0.03) = 2.365
= 2.35 + G
H 0.039 K
x2 = x0 −
Now
1
0
1
0
0
Let x0 = 2.35
and x1 = 2.37
f(x2) = – 0.00004 (–)ve
Hence, the root lies between 2.365 and 2.37.
Using Regula-Falsi method,
RS x − x UV f (x )
T f ( x ) − f (x ) W
F 2.37 − 2.365 IJ (− 0.00004)
= 2.365 − G
H 0.009 + 0.00004 K
x3 = x2 –
1
1
2
2
2
Replacing
x0 by x2
ALGEBRAIC
= 2.365 +
AND
TRANSCENDENTAL EQUATIONS
125
FG 0.005 IJ (0.00004) = 2.365
H 0.00904 K
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,
RS x − x UV f (x )
T f ( x ) − f (x ) W
F 1.41 − 1.4 IJ (− 0.056)
= 1.4 − G
H 0.102 + 0.056 K
F 0.01 IJ (0.056) = 1.4035
= 1.4 + G
H 0.158 K
1
x2 = x0 –
0
1
0
0
Let, x0 = 1.4
and x1 = 1.41
Now
f(x2) = – 0.0016 (–)ve
Hence, the root lies between 1.4035 and 1.41.
Using the method of false position,
RS x − x UV f (x )
T f (x ) − f (x ) W
F 1.41 − 1.4035 IJ (− 0.0016)
= 1.4035 − G
H 0.102 + 0.0016 K
F 0.0065 IJ (0.0016) = 1.4036
= 1.4035 + G
H 0.1036 K
x3 = x2 −
1
2
1
2
2
Now
f(x3) = – 0.00003 (–)ve
Hence, the root lies between 1.4036 and 1.41.
Using the method of false position,
x4 = x3 –
RS x − x UV f (x )
T f ( x ) − f (x ) W
1
1
3
3
3
Replacing x0 by x2
126
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
FG 1.41 − 1.4036 IJ (0.00003)
H 0.102 + 0.00003 K
F 0.0064 IJ (0.00003) = 1.4036
= 1.4036 + G
H 0.10203 K
= 1.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
Since
and
f(x) = x log10 x – 1.2
f(2.74) = – .0005634
f(2.741) = .0003087
Hence, the root lies between 2.74 and 2.741.
Using the method of False position,
Let x = 2.74
RS x − x UV f (x )
and x = 2.741
T f (x ) − f (x ) W
R 2.741 − 2.74 UV (− .0005634)
= 2.74 − S
T.0003087 − (− .0005634) W
F .001 IJ (.0005634)
= 2.74 + GH
.0008721K
1
x2 = x0 −
1
0
0
0
0
1
= 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,
RS x − x UV f (x )
| Replacing x by x
T f (x ) − f (x ) W
F 2.741 − 2.740646027 IJ (− .00000006016)
= 2.740646027 – G
H .0003087 + .00000006016 K
x3 = x 2 −
1
1
2
2
2
0
2
= 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
127
TRANSCENDENTAL EQUATIONS
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,
RS x − x UV f (x )
T f (x ) − f (x ) W
F .58 − .56 IJ (− .01121)
= .56 − G
H .0201 + .01121K
x2 = x0 −
1
0
1
0
0
= .56716
Now
f(x2) = .00002619 i.e., (+)ve
Hence, the root lies between .56 and .56716.
Using the method of false position,
RS x − x UV f (x )
| Replacing x
T f (x ) − f (x ) W
F .56716 − .56 IJ (− .01121)
= .56 − G
H .00002619 + .01121K
2
x3 = x0 −
0
2
0
0
1
by x2
= .567143
Since x2 and x3 agree up to four decimal places, the required root correct to
three decimal places is 0.567.
(ii) Let
Since
and
f(x) = xex – 2
f(.852) = – .00263
f(.853) = .001715
The root lies between .852 and .853.
Let
x0 = .852 and x1 = .853
Using the method of false position,
x2 = x0 −
RS x − x UV f (x )
T f (x ) − f (x ) W
1
1
0
0
0
128
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
= .852 −
RS .853 − .852 UV (− .00263)
T.001715 − (− .00263) W
= .852605293
Now
f(x2) = – .00000090833
Hence, the root lies between .852605293 and .853
Using the method of false position,
RS x − x UV f (x )
| Replacing x by x
T f (x ) − f (x ) W
R .853 − 852605293 UV (− .00000090833)
= (.852605293) – S
T.001715 − (−.00000090833) W
x3 = x2 −
1
1
2
2
2
0
2
= 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
Since
and
f(x) = x3 – 5x + 3
f(.65) = .024625
f(.66) = – .012504
The root lies between .65 and .66.
Let
x0 = .65 and
x1 = .66
Using the method of false position,
RS x − x UV f (x )
T f ( x ) − f (x ) W
F .66 − .65 IJ (.024625)
= .65 – G
H − .012504 − .024625 K
x2 = x0 –
1
0
1
0
0
= .656632282
Now
f(x2) = – .00004392
Hence, the root lies between .65 and .656632282.
Using the method of false position,
x3 = x0 –
RS x − x UV f (x )
T f (x ) − f (x ) W
2
2
0
0
0
Replacing
x1 by x2
ALGEBRAIC
= .65 −
AND
TRANSCENDENTAL EQUATIONS
129
FG .656632282 − .65 IJ (.024625)
H − .00004392 − .024625 K
= .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,
RS x − x UV f (x )
T f (x ) − f (x ) W
R 1.80 − 1.79 UV (− .054661)
= 1.79 − S
T.032 − (− .054661) W
1
x2 = x0 −
1
0
0
0
= 1.796307
Now,
f(x2) = – .00012936
Hence, the root lies between 1.796307 and 1.80.
Using the method of false position,
RS x − x UV f (x )
T f (x ) − f (x ) W
R 1.8 − 1.796307 UV (− .00012936)
= 1.796307 – S
T.032 − (− .00012936) W
x3 = x2 −
1
1
2
2
2
= 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
STATISTICAL TECHNIQUES
AND
3.21 CONVERGENCE OF REGULA-FALSI METHOD
If < xn > is the sequence of approximations obtained from
xn + 1 = xn –
( xn − x n − 1 )
f ( xn ) − f ( xn − 1 )
(8)
f ( xn )
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 − en − 1 )
α + en + 1 = α + en –
or
en + 1 =
f (α + en ) − f (α + en − 1 )
. f (α + en )
en − 1 f (α + en ) − en f (α + en − 1 )
f (α + en ) − f (α + en − 1 )
LM
MN
en − 1 f (α) + en f ′ (α) +
LM
MN
OP
PQ
en 2
f ″ (α) + ......
2!
− en f (α) + en − 1 f ′ (α) +
=
LM f (α) + e
MN
n
f ′ (α) +
OP
PQ
en2 − 1
2!
OP
PQ
f ″ (α) + ......
en 2
f ″ (α) + ......
2!
LM
MN
− f (α) + en − 1 f ′ (α) +
(en − 1 − en ) f (α) +
en2 − 1
2!
OP
PQ
f ″ (α) + ......
en − 1 en
(en − en − 1 ) f ″ (α) + ......
2!
=
(en − en − 1 ) ( en + en − 1 )
(en − en − 1 ) f ′ (α) +
f ″ (α) + ......
2!
en − 1 en
=
f ″ (α) + ......
2
en + en − 1
f ′ (α) +
f ″ (α) + ......
2
FG
H
IJ
K
|∵
f(α) = 0
ALGEBRAIC
or
en + 1 ≈
AND
TRANSCENDENTAL EQUATIONS
en en − 1 f ″ (α)
f ′ (α)
2!
131
(9)
(neglecting high powers of en, en – 1)
Let
en + 1 = c enk , where c is a constant and k > 0.
en = c ekn – 1
∴
en – 1 = c–1/k en1/k
or
∴ From (9),
−1/ k
c −1/ k 1 + 1/ k f ″ (α)
f ″ (α)
c enk ≈ en c
en
.
=
en 1/ k .
f ′ (α)
2!
2!
f ′ (α)
Comparing the two sides, we get
k=1+
and c =
1
k
Now,
k=1+
Also,
c = c–1/k .
c
or
1
k
1+
1
k
c −1/ k f ″ (α)
2 ! f ′ (α)
⇒ k2 – k – 1 = 0
⇒ k = 1.618
1 f ″ (α)
2 ! f ′ (α)
= c 1.618 =
1 f ″ (α)
2 f ′ (α)
L f ″ (α) OP
c= M
N 2f ′ (α) Q
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
(iii)
x3
(ii) x3 – x2 – 2 = 0
(iv) x3 – 5x – 7 = 0
+x–3=0
by using the method of false-position.
8.
Find the real root of the equations
(i) x4 – x3 – 2x2 – 6x – 4 = 0
(iii) xex = 3
(ii) x6 – x4 – x3 – 3 = 0
(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
(v)
x3
– 3x + 4 = 0 b/w – 2 and – 3
(iv) x3 + x2 – 3x – 3 = 0 lying b/w 1 and 2
(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(x 1) . 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 –
LM x − x OP f(x )
N f (x ) − f (x ) Q
1
0
1
1
0
Again, the formula for successive approximation in general form is
xn+1 = xn –
LM x − x OP f(x )
N f (x ) − f (x ) Q
n
n− 1
n
n
n− 1
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.
Y
o
x0
x1
x2
X
x3
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 –
LM x − x OP f(x ) = 0.25
N f (x ) − f (x ) Q
1
1
f(x2) = – 0.234375.
0
0
1
134
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The second approximation is
x3 = x2 –
LM x − x OP f(x ) = 0.186441
N f (x ) − f (x ) Q
2
1
2
1
2
f(x3) = 0.074276
The third approximation is
x4 = x3 –
LM x − x OP f(x ) = 0.201736
N f (x ) − f (x ) Q
3
2
3
2
3
f(x4) = – 0.000470
The fourth approximation is
x5 = x4 –
LM x − x OP f(x ) = 0.201640.
N f (x ) − f (x ) Q
4
3
4
3
4
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
LM x − x OP f(x )
N f (x ) − f (x ) Q
F 1.43 − 1.42 IJ (.00034) = 1.4296
= 1.43 – G
H .00034 + .0086 K
x2 = x1 –
1
0
1
0
1
f(x2) = – .000011
The second approximation is
LM x − x OP f(x )
N f (x ) − f (x ) Q
F 1.4296 − 1.42 IJ (– .000011) = 1.4292
= 1.4296 – G
H − .000011 − .00034 K
x3 = x2 –
2
2
1
1
2
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.
f(x) = xn + a1 xn – 1 + ...... + an – 1 x + an
Let
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
Thus,
Rn = Rx + S
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.
NOTE
1. Synthetic division scheme is as follows
a0 (= 1)
b0 (= 1)
c0 (= 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
b1
b2
b3 ...... bn – 2
bn – 1
bn
– pc0
– pc1
– pc2 ...... – pcn – 3
– pcn – 2
–p
– qc0
– qc1 ...... – qcn – 4
– qcn – 3
–q
c2
c3 ...... cn – 2
cn – 1
c1
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.
and
| ∈p | =
Δpi
pi +1
× 100%
| ∈q | =
Δqi
qi + 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.
ALGEBRAIC
AND
137
TRANSCENDENTAL EQUATIONS
Sol. Starting with the values p0 = – 4, q0 = 8, we have
1
–5
20
– 40
60
–
4
–4
–8
32
8
0
– 64
1
–1
8
4
12
48
4
–8
– 24
–8
12(= cn – 2)
24(= cn – 1)
1
3(= cn – 3)
0(= bn – 1)
– 4(= bn)
cn – 1 – bn – 1 = 24 – 0 = 24
∴
4
–8
(12)
Corrections Δp0 and Δq0 are given by
cn – 2 Δp0 + cn – 3 Δq0 = bn – 1
and
⇒ 12 Δp0 + 3 Δq0 = 0
(cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn
24 Δp0 + 12 Δq0 = – 4
⇒
Solving (13) and (14), we get
Δp0 = 0.1667, Δq0 = – 0.6667
∴
p1 = p0 + Δp0 = – 3.8333
q1 = q0 + Δq0 = 7.3333
Also,
| ∈p | =
=
and
(13)
| ∈q | =
=
Δp0
p1
× 100%
0.1667
× 100% = 4.3487%
− 3.8333
Δq0
q1
× 100%
− .6667
× 100% = 9.0914%
7.3333
(14)
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
1
–5
20
– 40
3.8333
– 4.4723
31.4116
– 0.125
3.8333
– 7.3333
8.5558
– 60.092
– 7.3333
– 1.1667
8.1944
– 0.0326
– 0.217
3.8333
10.2219
42.4845
– 7.3333
– 19.555
2.6666
11.083
22.8969
(= cn – 3)
(= cn – 2)
(= cn – 1)
F || I
GH b JK
n−1
1
60
FG ||IJ
Hb K
n
3.8333
– 7.3333
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 | =
=
and
| ∈q | =
=
Δp1
p2
× 100%
0.0033
× 100% = .08616%
− 3.83
Δq1
q2
× 100%
− 0.0269
× 100% = .3682%
7.3064
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
1
–5
3.83
– 1.17
20
– 4.4811
– 7.3064
– 40
31.4539
8.5485
60
– 60.0038
8.2125
0.0024
≈0
– .0038
≈0
3.83
– 7.3064
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
1
1
5
–3
3
–6
5
2
–3
2
3
5
–1
↓
10
↓
cn – 3
∴
cn – 2
–5
–6
10
– 1(= bn – 1)
– 30
–5
–9
3
10
4(= bn)
–3
5
–3
5
– 36
↓
cn – 1
cn – 1 – bn – 1 = – 36 + 1 = – 35
Corrections Δp0 and Δq0 are given by
cn – 2 Δp0 + cn – 3 Δq0 = bn – 1
and (cn – 1 – bn – 1) Δp0 + cn – 2 Δq0 = bn
⇒
10 Δp0 – Δq0 = – 1
⇒ – 35 Δp0 + 10 Δq0 = 4
(16)
(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 | =
=
| ∈q | =
=
Δp0
p1
× 100%
− 0.09
× 100% = 3.0927%
2.91
Δq0
q1
× 100%
0.08
× 100% = 1.6260%.
− 4.92
Repeating the same process, i.e., dividing f(x) by x2 + 2.91x – 4.92, we get
1
1
1
5
– 2.91
3
– 6.08
4.92
–5
– 5.35
10.28
–9
0.20
9.05
2.09
– 2.91
1.84
2.37
4.92
– 0.07
– 26.57
– 4.03
0.25
– 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
– 2.91
4.92
– 2.91
4.92
ALGEBRAIC
| ∈p | =
=
| ∈q | =
=
Δp1
p2
AND
TRANSCENDENTAL EQUATIONS
141
× 100%
− 0.00745
× 100% = .2566%
2.90255
Δq1
q2
× 100%
0.00241
× 100% = .04901%.
− 4.91759
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.
2.
3.
Find the quadratic factor of x3 – 3.7x2 + 6.25x – 4.069 after two iterations. Use p0 = – 2.5,
q0 = 0.
Solve the equation x4 – 8x3 + 39x2 – 62x + 50 = 0 starting with p = q = 0.
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
– xi)2 + B(xi – 1 – xi) + yi
(18)
yi – 2 = A(xi – 2 – xi)2 + B(xi – 2 – xi) + yi
(19)
yi – 1 = A(xi
and
–1
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)
yi – 2 – yi = A(xi – 2 – xi)2 + B(xi – 2 – xi)
and
(20)
(21)
Solution of equations (20) and (21) gives,
A=
and
B=
( xi − 2 − xi ) ( yi − 1 − yi ) − ( xi − 1 − xi ) ( yi − 2 − yi )
( xi − 1 − xi − 2 ) ( xi − 1 − xi ) ( xi − 2 − xi )
( xi − 2 − xi ) 2 ( yi − 1 − yi ) − ( xi − 1 − xi ) 2 ( yi − 2 − yi )
( xi − 2 − xi − 1 ) ( xi − 1 − xi ) ( xi − 2 − xi )
(22)
(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 2 − 4 Ayi
2A
(24)
A direct solution from (24) leads to inaccurate results and therefore it is
usually written in the form,
xi + 1 – xi = −
2 yi
B ± B 2 − 4 Ayi
(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.
Step 03.
Input the variables xi, xi1, xi2
Input absolute error-aerr
Step 04.
Step 05.
Repeat Steps 5-12 until |Xn-Xi| < aerr
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
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
143
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
li = (2*y(x[0])*di)/(– mu + s)
No
li = (2*yx[I]*di)/(– mu + s)
x[I + 1] = x[I] + 1 * (x[I] – x[I – 1])
A
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
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)
Print ‘‘solution’’
End loop (itr)
Print 'solution does
not converge
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
145
146
COMPUTER-BASED NUMERICAL
AND
A=
=
B=
STATISTICAL TECHNIQUES
( xi − 2 − xi ) ( yi − 1 − yi ) − ( xi − 1 − xi ) ( yi − 2 − yi )
( xi − 1 − xi − 2 ) ( xi − 1 − xi ) ( xi − 2 − xi )
(− .2) (− 1.061) − (− .1) (− 2.002) .2122 − .2002
=
=6
(.1) (− .1) (− .2)
.002
( xi − 2 − xi ) 2 ( yi − 1 − yi ) − ( xi − 1 − xi ) 2 ( yi − 2 − yi )
( xi − 2 − xi − 1 ) ( xi − 1 − xi ) ( xi − 2 − xi )
=
(− .2) 2 (− 1.061) − (− .1) 2 (− 2.002)
(− .1) (− .1) (− .2)
=
− .04244 + 0.02002
= 11.21
− .002
The next approximation to the desired root is
xi + 1 = xi –
2 yi
B ± B 2 − 4 Ayi
= 2.1 −
= 2.1 –
2 (.061)
11.21 ± (11.21) 2 − (24 × .061)
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,
then
xi–1 = 2.1
yi–2 = – 1, yi–1 = .061
A=
and xi = 2.094542
and yi = – .0001058
( xi − 2 − xi )( yi − 1 − yi ) − ( xi − 1 − xi )( yi −2 − yi )
( xi −1 − xi −2 )( xi −1 − xi )( xi − 2 − xi )
=
(2 − 2.094542)(.061 + .0001058) − (2.1 − 2.094542)(− 1 + .0001058)
(2.1 − 2)(2.1 − 2.094542)(2 − 2.094542)
=
(− .094542)(.0611058) − (.005458)(− .9998942)
(.1)(.005458)(− .094542)
ALGEBRAIC
=
− .005777064 + .005457422
− .000051601
=
− .000319642
= 6.194492
− .000051601
B=
AND
TRANSCENDENTAL EQUATIONS
147
( xi − 2 − xi ) 2 ( yi − 1 − yi ) − ( xi −1 − xi ) 2 ( yi − 2 − yi )
( xi − 2 − xi − 1 )( xi − 1 − xi )( xi − 2 − xi )
=
( − .094542) 2 (.0611058) − (.005458) 2 ( − .9998942)
( − .1)(.005458)( − .094542)
=
(.008938189)(.0611058 ) + (.000029789 )(.9998942 )
.000051601
=
.000546175 + .000029785
= 11.161799
.000051601
The next approximation to the desired root is
xi+1 = xi –
2yi
B ± B 2 − 4 Ayi
= 2.094542 –
= 2.094542 +
2(− .0001058)
11.161799 ± (11.161799) 2 − 4(6.194492)(− .0001058)
.0002116
= 2.094551
11.161799 + 11.161916
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("\n\n ");
printf("Enter the values of X(i),X(i-1),X(i-2), absolute
error\n");
printf("\n\n Enter the value of X(i)
scanf("%f",&Xi);
- ");
printf("\n\n Enter the value of X(i-1)
scanf("%f",&Xi1);
- ");
printf("\n\n Enter the value of X(i-2)
scanf("%f",&Xi2);
- ");
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
149
printf("\n\n Enter the value of Absolute Error – ");
scanf("%f",&aerr);
printf("\n\n Processing ");
for(loop=0; loop<10;loop++)
{
delay(200);
printf("...");
}
printf("\n\n\n");
//...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("\n\n After Iteration %d value of x-%f",i,Xn);
if(fabs(Xn-Xi)<aerr)
{
goto jmp;
}
Xi=Xn;
i++;
}
jmp:
//...Output Section
printf("\n\n After %d iterations root is-%6.6f\n",i+1,Xn);
//...Invoke User Watch Halt Function
printf("\n\n\n 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)
Enter the value of X(i-1)
- 3
- 2
Enter the value of X(i-2)
Enter the value of Absolute Error
- 1
- 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.
2.
3.
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.
Apply Muller’s method to find the root of the equation cos x = xex which lies between
0 and 1.
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
(iii) x3 –
4.
AND
STATISTICAL TECHNIQUES
1
1
= 0 take x0 = 0, x1 = 1 and x2 = .
2
2
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
so that,
∞
1
a3 x 3 + a2 x 2 + a1 x + a0
=
∑α
i
xi
i=0
(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 =
Hence,
and so,
In general,
1
,
a0
α1 = −
a1
a0 2
q1(1) =
a
α1
=− 1
a0
α0
q1(2) =
α 2 a2 a0 − a12
=
α1
a0 a1
Δ1(1) = q1(2) – q1(1) =
Δm(m) =
am + 1
am
, α2 =
− a2
a0 2
+
a2
a3
, Δ2(0) =
a1
a2
, m = 1, 2, 3, ......, (n – 1)
a12
a0 3
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)
Δ0(k) = Δn(k) = 0, for all k
We also set
[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)
Δ0(1)
Δ1(0)
q1(1)
q3(– 2)
Δ2(– 1)
q2(0)
Δ0(2)
Δ1(1)
q1(2)
q3(– 1)
Δ2(0)
q2(1)
Δ0(3)
Δ3(– 2)
Δ3(– 1)
q3(0)
Δ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.
a0 = 1,
Sol. Here,
a1 = – 6, a2 = 11,
q1(1) = –
Now,
q1(2) =
a1
=6
a0
a2 a0 − a12 11 − 36
=
= 4.167
a0 a1
−6
Δ1(1) = q1(2) – q1(1) =
q2(0) = 0,
Also,
Δ2(0) =
a3 = – 6
a2
= – 1.833
a1
q3(– 1) = 0
a3
6
=−
= – 0.5454.
a2
11
The first two rows containing starting values of
q1(1)
Δ0(2)
q2(0)
Δ1(1)
i.e.,
6
0
q3(– 1)
Δ2(0)
0
– 1.833
Δ3(– 1)
0
– 0.5454
0
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
155
The succeeding rows can be constructed as below:
Δ0
q1
Δ1
6
0
q2
0
– 1.833
4.167
0
– 0.5666
3.344
0
– 0.1105
– .0073
0
.9919
– .0037
1.976
– .0125
3.0213
0
0.9846
1.961
3.0338
0
0.9703
– .0143
– .0192
0
0.9422
1.9384
3.053
0
– 0.0281
– .0299
0
0.8869
1.9051
– .0476
0
0
– 0.0553
– 0.0782
3.083
0
0.7764
1.8550
3.131
0
0.5454
1.770
3.209
0
– 0.2310
– 0.1353
Δ3
0
1.624
– 0.2556
0
q3
– 0.5454
1.288
3.600
0
Δ2
0
.9956
– .0019
1.987
0
.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.
f(x) = x3 + 9x2 – 18
f(1) = 1 + 9 – 18 = – ve
Sol. Let
Then
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
0
9
1
0
10
– 18
10
1
1
0
10
1
10
11
–8
1
1
0
11
1
21
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
0
120
3
2100 – 8000
369
7407
3
1
0
123
3
2469
378
3
1
0
126
3
2847
3
129
– 593
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
0
1290
6
284700
2592
– 593000
574584
2
3
0
1296
6
287292
2604
– 18416
2
3
0
1302
6
289896
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
3
(iii) x – 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
f″(x0) + ...... = 0
2!
Since h is small, neglecting h2 and higher powers of h, we get
f(x0) + hf ′(x0) = 0 or h = –
f ( x0 )
f ′ ( x0 )
(29)
A better approximation than x0 is therefore given by x1, where
x1 = x0 –
f ( x0 )
f ′ ( x0 )
Successive approximations are given by x2, x3, ....... , xn + 1, where
x n + 1 = xn –
f ( xn )
f ′ ( xn )
which is the Newton-Raphson formula.
(30) (n = 0, 1, .......)
ALGEBRAIC
NOTE
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 –
In general,
which gives
φ(x) = x –
φ′(x) =
f ( xn )
f ′ ( xn )
f ( x)
f ′ ( xn )
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
160
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Then (30) becomes, en + 1 = en –
= en –
= en –
en 2
f ″ (α) + ......
2!
f ′ (α) + en f ″ (α) + ......
f (α) + en f ′ (α) +
en 2
f ″ (α) + .......
2
f ′ (α) + en f ″ (α) + ......
en f ′ (α) +
=
en 2 f ″ (α)
2[ f ′ (α) + en f ″ (α)]
=
en 2
2
=
en 2
2
=
en 2
2
f (α + en )
f ′ (α + en )
or
en 2
|∵
f(α) = 0
| Neglect high powers of en
f ″ (α)
RS f ″ (α) UV
f ′ (α) W
T
f ″ (α) R
.
S1 + e ff ″′ ((αα)) UVW
f ′ (α) T
U
f ″ (α) R
f ″ (α)
1− e
+ .......V
S
f ′ (α) T
f ′ (α)
W
f ′ (α) 1 + en
−1
n
n
RS f ″ (α) UV + .......
T f ′ (α ) W
1 f ″ (α) e R f ″ (α) U
−
=
S V + .......
2 f ′ (α)
2 T f ′ (α) W
2
e 2 f ″ (α) en 3
−
= n
2 f ′ (α)
2
en +1
(By Taylor’s expansion)
2
n
≈
f ″ (α)
2 f ′ (α)
(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)
A {x0, f(x0)}
y=
f(x
)
Y
A1
A2
x2 x1
O
x0
X
a
It cuts the x-axis at
x1 = x0 –
f ( x0 )
f ′ ( x0 )
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.
Step 03.
Input the variables x0, n for the task
Input Epsilon & delta
Step 04.
Step 05.
for i = 1 and repeat if i <= n
f0 = f(x0)
162
COMPUTER-BASED NUMERICAL
Step 06.
Step 07.
AND
STATISTICAL TECHNIQUES
df0 = df(x1)
if |df0| <= delta
a. Print Slope too small
b. Print x0, f0, df0, i
Step 08.
Step 09.
c. End of Program
x1 = x0-(f0/df0)
if |(x1-x0)/x1| <epsilon
a. Print convergent
b. Print x1, f(x1), i
c. End of Program
Step 10.
Step 11.
x0 = x1
End Loop
3.34 FLOW-CHART OF NEWTON–RAPHSON METHOD
START
Define function f(x)
Define function d f(x)
Get the values of x0, aerr, maxitr
Loop for itr = 1 to maxitr
h = f (x0)/ d f(x0)
x1 = x0 – h
Print itr, x1
Is fabs (h)
< aerr
Yes
Print solution
No
x0 = x 1
End loop (itr)
Print ‘‘solution does
not converge”
STOP
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
Since
1
– a = 0, which can be solved by Newton’s method.
x
f(x) =
1
1
– a, f ′(x) = – 2
x
x
∴ Newton’s formula gives
x n + 1 = xn
FG 1 − aIJ
Hx K
+
F 1I
GH x JK
n
n
2
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.
f(x) = x2 – a, f ′(x) = 2x
Since
xn + 1 = xn –
xn + 1 =
xn 2 − a
2 xn
F
GH
1
a
xn +
2
xn
3. Inverse square root. Equation is
I
JK
1
x2
–a=0
Iterative formula is
xn + 1 =
1
x (3 – a xn2)
2 n
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 p − a)
xn + 1 = xn –
pxn p − 1
( p − 1) xn p + a
pxn p − 1
Also, the general formula for the reciprocal of pth root of a is
x n + 1 = xn
F p + 1 − ax I .
GH p JK
n
p
3.36 RATE OF CONVERGENCE OF NEWTON’S SQUARE ROOT FORMULA
a = α so that a = α2 . If we write
Let
F1+ e I
GH 1 − e JK
F1+ e I
=αG
H 1 − e JK
1F
aI
= Gx +
J , we get
2H
x K
1 L F 1+ e I a F 1− e
= Mα G
J+ G
2 MN H 1 − e K α H 1 + e
F1+ e I
= αG
H 1 − e JK
n
xn = α
then,
n
n+1
xn + 1
Also, by formula,
xn + 1
xn + 1
(31)
n+1
n
n
n
n
n
n
n
n
I OP
JK PQ
2
2
(32)
(∵
a = α2)
Comparing (31) and (32), we get en + 1 = en2
confirming quadratic convergence of Newton’s method.
3.37 RATE OF CONVERGENCE OF NEWTON’S INVERSE FORMULA
Let
then,
1
1
i.e., a = . If we write xn = α(1– en)
α
a
= α (1 – en + 1)
α=
xn + 1
ALGEBRAIC
By formula,
AND
TRANSCENDENTAL EQUATIONS
165
xn + 1 = xn (2 – axn), we get
xn + 1 = α(1– en) [2 – aα (1– en)] = α(1– en2)
|∵
aα = 1
Comparing, we get en+1 = en2, 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
Since
f(x) = 3x – cos x – 1
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 –
= xn –
f ( xn )
f ′ ( xn )
3 xn − cos xn − 1 xn sin x n + cos x n + 1
=
3 + sin x n
3 + sin xn
If n = 0, the first approximation x1 is given by,
x1 =
=
x0 sin x0 + cos x0 + 1
3 + sin x0
0.6 sin 6 + cos 0.6 + 1
= .6071
3 + sin 0.6
If n = 1,
the second approximation is
x2 =
=
x1 sin x1 + cos x1 + 1
3 + sin x1
.6071sin (.6071) + cos(.6071) + 1
= 0.6071
3 + sin (.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 ("\n\t\t\t 3*X - COS X - 1=0 \n\n ");
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("\n\t\t The root is near to %.4f\n",x1);
}
If (f1 > fabs(f(x0)))
{
printf("\n\t\t The root is near to %.4f\n",x0);
}
x0=(x0+x1)/2;
for(;i<=itr;i++)
{
f0=f(x0);
df0=df(x0);
x1=x0 - (f0/df0);
printf("\n\t\t The %d approximation to the root is:
%f",i,x1);
168
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
error=fabs(x1-x0);
if(error<EPS)
{
break;
}
x0 = x1;
}
if(error>EPS)
{
prinf("\n\n\t NOTE:- ");
printf("The number of iterations are not sufficient.");
}
printf("\n\n\n\t\t\t ------------------------------");
printf("\n\t\t\t
The root is %.4f ",x1);
printf("\n\t\t\t ------------------------------");
}
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
TRANSCENDENTAL EQUATIONS
AND
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 –
= xn –
f ( xn )
f ′ ( xn )
.43429 xn + 1.2
x n log 10 xn − 1.2
=
log
log 10 xn + .43429
10 xn + .43429
(33)
Given n = 0, the first approximation is
x1 =
.43429 x0 + 1.2
= 2.81
log 10 2 + .43429
(∵
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
Sol. Let
x=
12 to four decimal places by Newton’s iterative method.
so that x2 – 12 = 0
12
(34)
Take f(x) = x2 – 12, Newton’s iteration formula gives,
F
GH
f ( xn )
1
12
xn 2 − 12
xn +
xn + 1 = xn –
= xn –
=
2
xn
f ′ ( xn )
2 xn
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,
F
GH
1F
= Gx
2H
x1 =
x2
I FG
JK H
12 I
+
J = 3.4641
x K
IJ
K
1
12
12
1
x0 +
3.5 +
=
= 3.4643
x0
2
3.5
2
1
x3 = 3.4641
1
I
JK
(35)
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 –
with x0 = π,
x1 = x0 –
xn sin xn + cos xn
x n cos xn
x0 sin x0 + cos x0
π sin π + cos π
=π–
= 2.8233
x0 cos x0
π cos π
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
then,
Let
then,
Now,
so that,
f(x) = xex – 1
f ′(x) = (1+ x) ex
x0 = 1
x1 = 1–
FG e − 1IJ = 1 FG 1 + 1IJ = 0.6839397
H 2e K 2 H e K
f(x1) = 0.3553424 and f ′(x1) = 3.337012
x2 = 0.6839397 –
0.3553424
= 0.5774545
3.337012
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
so that,
xn + 1 = xn +
Take x0 = .6 then,
e
− xn
AND
TRANSCENDENTAL EQUATIONS
171
− sin xn
e − xn + cos x n
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 =
Here
a = 17
Take
x0 = 2.5
F
GH
a
1
2 xn + 2
3
xn
I
JK
(36)
∵
Putting n = 0 in (36), we get
x1 =
F
GH
1
17
2 x0 + 2
3
x0
Putting n = 1 in (36), we get
x2 =
F
GH
1
17
2 x1 + 2
3
x1
3
8 = 2 and 3 27 = 3
I = 1 FG 5 + 17 IJ = 2.5733
JK 3 H 6.25 K
I = 1 FG 5.1466 + 17 IJ = 2.5713
JK 3 H
6.6220 K
Again putting n = 2 in (36), we get
x3 =
F
GH
Putting n = 3 in (36), we get
x4 =
I
JK
FG
H
I
JK
FG
H
IJ
K
1
17
1
17
2 x2 + 2 =
5.1426 +
= 2.57128
3
3
6.61158
x2
F
GH
1
17
1
17
2 x3 + 2 =
5.14256 +
3
3
6.61148
x3
IJ = 2.57128
K
Since x3 and x4 agree to four decimal places, the required root is 2.5713,
correct to four decimal places.
(ii)
xn + 1 =
2 xn 3 + a
3 xn
2
=
F
GH
1
a
2 xn + 2
3
xn
I
JK
172
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
3
3
27 = 3)
x0 = 2.5
∴
x1 = 2.2
(n = 0)
x2 = 2.155
(n = 1)
x3 = 2.15466
(n = 2)
3
∴
(∵
8 = 2 and
Take
10 ≈ 2.15466.
Example 8. Show that the following two sequences both have convergence of
the second order with the same limit
I and, x = 1 x F 3 − x I .
F
GH
JK
a JK
2 GH
F a I , we have
1
=
x G1 +
2
H x JK
F a I – = 1 F x + a − 2 aI
1
a = x G1 +
JK
2
H x JK a 2 GH x
1F
1
a I
= G x −
=
(x – a )
J
2H
2x
x K
xn + 1 =
Sol. Since,
a.
a
1
x 1+ 2
2 n
xn
xn + 1
xn + 1 –
n
n
n
n+1
n
n
2
2
n
n
2
n
2
n
n
n
Thus,
en + 1 =
n
2
1
e 2
2x n n
(37)
which shows the quadratic convergence. Similarly for the second,
xn + 1 –
a =
F
GH
I– a
JK
F 1 − x I + (x –
GH a JK
1
x 2
xn 3 − n
2
a
2
=
1
x
2 n
=
xn
(a – xn2) + (xn –
2a
en + 1 =
=
n
n
a)
a ) = (xn –
xn − a
[2a – xn2 – xn a ]
2a
xn − a
[(a – xn2) + (a – xn a )]
2a
LM
N
a) 1−
e
xn
xn + a
2a
jOPQ
ALGEBRAIC
=–
en + 1 = –
F x − a I (x
GH 2a JK
n
n
–
AND
TRANSCENDENTAL EQUATIONS
173
a ) (xn + 2 a )
( xn + 2 a )
( xn − a ) 2
(xn + 2 a ) = –
. en2
2a
2a
(38)
which shows the quadratic convergence.
Example 9. If xn is a suitably close approximation to
in the formula
F
I
GH
JK is about 13 rd that in the formula,
F x I
1
=
x G3 −
2
H a JK , and deduce that the formula
F 6 + 3a − x I
x
G x a JK gives a sequence with third order convergence.
=
8 H
xn + 1 =
xn + 1
xn + 1
a , show that the error
a
1
xn 1 + 2
xn
2
n
2
n
n
n
n
2
2
Sol. Since xn is very close to
en + 1 ~
− –
=3.
a
F x + 2x I e
GH 2x JK
n
n
n
2
2
n
| From (38)
1
e 2
2xn n
(39)
A simple observation shows that from (37) (see Ex. 8) and (39), the error
1
rd of that in the second formula.
3
To find the rate of convergence of the given formula, we have
in the first formula for en + 1 is about
xn + 1 –
a =
=
∴
en
+1
xn
8
F 6 + 3a − x I –
GH x a JK
n
n
2
2
a =
xn (6 xn 2 a + 3a 2 − xn 4 )
8 axn 2
–
a
6 xn 2 a + 3 a 2 − xn 4 − 8 xn a a
− ( x n + 3 a ) ( xn − a ) 3
=
8 xn a
8 xn a
=–
F x + 3 aI e
GH 8 x a JK
n
n
n
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 − 1) xn p + a
p xn p − 1
Here, a = 30, p = 5, the first approximation is
x1 =
4 x0 5 + 30
5 x0 4
Take
x0 = 1.9,
Again,
x2 = 1.973
we get x1 = 1.98
∴ 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 –
= xn –
=
f ( xn )
f ′ ( xn )
xn 4 − 5 xn 3 + 20 xn 2 − 40 xn + 60
4 xn 3 − 15 x n 2 + 40 x n − 40
3 xn 4 − 10 xn 3 + 20 xn 2 − 60
4 xn 3 − 15 xn 2 + 40 x n − 40
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
⇒
F α + iβ + α − iβ I
Sum = G + 1.915 + 1.908 iJ = 2α + 3.83 = 5
GH + 1.915 − 1.908 iJK
α = 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(x0 )
1 {f(x0 )} 2 . f ″ (x0 )
– .
f ′ (x0 )
2
{f ′ (x0 )}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 ( x0 )
f ′ ( x0 )
This is I approximation to the root.
∴
x1 = x0 –
f ( x0 )
f ′ ( x0 )
Again By Taylor’s series, we have
f(x) = f(x0) + (x – x0) f ′(x0) +
( x − x0 ) 2
f ″(x0)
2
( x1 − x0 ) 2
f ″(x0)
2
But f(x1) = 0 as x1 is an approximation to the root.
∴
∴
or
f(x1) = f(x0) + (x1 – x0) f ′(x0) +
f(x0) + (x1– x0) f ′(x0) +
f(x0) + (x1 – x0) f ′(x0) +
⇒
x1 = x0 –
1
(x – x0)2 f ″(x0) = 0
2 1
1 { f ( x0 )} 2 f ″ ( x0 )
=0
2
f ′ ( x0 ) 2
1 { f ( x0 )} 2 f ″ ( x0 )
f ( x0 )
–
2
{ f ′ ( x0 )}3
f ′ ( x0 )
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
= 2 cos x
dx
For
y = log x + c
1
dy
=
x
dx
∴
Let
∴
1
x
2 cos x =
⇒ x cos x – .5 = 0
f(x) = x cos x – .5
f ′(x) = cos x – x sin x
∴ Newton’s iterative formula is
xn + 1 = xn –
xn cos xn − 0.5
cos xn − xn sin xn
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 –
Now,
f (i)
3i
=i–
= .486 + .919 i
f ′ (i)
1 + 6i
x2 = .486 + .919 i –
= .486 + .919 i –
The actual root is x =
f (.486 + .919i)
f ′ (.486 + .919i)
FG − .292 + .174 i IJ = – .499 + 0.866i
. + 6.005 i K
H 178
− 1+ i 3
.
2
Example 15. Show that the square root of N = AB is given by
S N
N ~
− 4 + S , where S = A + B.
ALGEBRAIC
Sol. Let
⇒
Let
∴
x=
AND
TRANSCENDENTAL EQUATIONS
177
N
x2 – N = 0
f(x) = x2 – N
f ′(x) = 2x
By Newton-Raphson formula,
xn + 1 = xn –
Let
then,
xn =
xn + 1 =
xn2 − N xn
N
f ( xn )
=
+
= xn −
x
xn
2
2
2
f ′ ( xn )
n
A+B
2
A+B
N
S N
~
+
− +
4
A+B
4 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
α + en + 1 = p(α + en) + q
= p (α + en ) + q
α3
(α + en ) 2
FG
H
α3
α2 1 +
en
α
IJ
K
2
FG e IJ
H αK
R| e + 3 F e I
= p (α + e ) + qα S1 − 2
|T α GH α JK
= p(α + en) + qα 1 +
n
n
−2
n
n
2
U|
V|
W
− .........
N
xn2
, we get
178
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
= p (α + en ) + qα − 2qen + 3q
en2
– ........
α
en + 1 = (p + q – 1)α + (p – 2q)en + 0(en2) + .......
⇒
Now for the method to become of the highest order as possible, i.e., of order
2, we must have
p+q=1
so that,
p=
2
3
and p – 2q = 0
and q =
1
.
3
Example 17. How should the constant α be chosen to ensure the fastest possible
convergence with the iteration formula?
xn+1 =
αxn + xn −2 + 1
.
α+1
Sol. Since lim x n = lim x n + 1 = ξ, we have
n→ ∞
n→ ∞
F αξ + 1 + 1I
G ξ J
ξ = GH α + 1 JK
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 ( x0 )
= x0 –
f ′ ( x0 )
F x − x − 1I = 1.465601.
GH 3x − 2 x JK
f ( x1 )
= x1 –
f ′ ( x1 )
F x − x − 1I = 1.46557
GH 3x − 2x JK
Second approximation is
x2 = x1 –
0
3
0
3
1
2
2
1
0
2
0
2
1
1
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
179
Hence ξ = 1.465 correct to three decimal places.
Now, we have
xn+1 =
αxn + xn −2 + 1
α+1
(40)
Putting xn = ξ + en and xn+1 = ξ + en+1 in (40), we get
(α + 1)(ξ + en + 1) = α(ξ + en) +
1
(ξ + en ) 2
1
= α(ξ + en) +
ξ2
+1
FG 1 + e IJ
H ξK
n
−2
+1
which gives,
F
GH
(1 + α)en+1 = α −
2
ξ
3
Ie
JK
n
+ O(en2)
For fastest convergence, we must have α =
∴
α=
2
2
ξ3
= 0.636.
(1.465) 3
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) =
RS cos x,
Tcos x + (x − 1)
2
2
UV
W
when|x|≤ 1
, when|x|≥ 1
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 –
LM f (x ) − c OP
N f ′ (x ) Q
n
n
For n = 0, we have
x1 = x0 –
LM f (x ) − c OP
N f ′ (x ) Q
0
0
180
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
LM cos 1 − c OP
N − sin 1 Q
L cos 1 − c OP
–1=1+ M
N sin 1 Q
=1–
Hence
| ∵ x0 = 1
| ∵ x1 = (– 1)1 = – 1
– 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.
4.
(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.
Find the real root of the equations
(ii) x2 + 4 sin x = 0
(i) log x = cos x
5.
by Newton-Raphson method, correct to three decimal places.
Use Newton-Raphson method to obtain a root correct to three decimal places of the
following equations:
(i) sin x = 1 – x
(iv) x3 + 3x2 – 3 = 0
(ii) x3 – 5x + 3 = 0
(v) 4(x – sin x) = 1
(iii) x4 + x2 – 80 = 0
(vi) x – cos x = 0
x
(viii) x + log x = 2
(ix) tan x = x.
2
Explain the method of Newton-Raphson for computing roots. Apply it for finding x from
x2 – 25 = 0. Write a program using ‘C’.
Write a computer program in ‘C’ for finding out a real root of eqn. f(x) = 0 by the NewtonRaphson method.
(vii) sin x =
6.
7.
8.
9.
10.
Using the Newton-Raphson method, obtain the formula for N and find 20 correct to
2 decimal places.
Obtain the cube root of 120 using the Newton-Raphson method, starting with x0 = 4.5.
Develop an algorithm using the Newton-Raphson method to find the fourth root of a
positive number N, and find 4 32 .
ALGEBRAIC
11.
12.
TRANSCENDENTAL EQUATIONS
181
Find the cube root of 3 correct to three decimal places by Newton’s iterative method.
Prove the recurrence formula
xi + 1 =
13.
AND
F
GH
1
N
2 xi + 2
3
xi
I
JK
for finding the cube root of N. Find the cube root of 63.
Use Newton’s formula to prove that the square root of N can be obtained by the recursion
formula,
F
GH
xi + 1 = xi 1 −
xi 2 – N
2N
I
JK
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
15.
1
.
31
Determine p, q, and r so that the order of the iterative method
xn + 1 = pxn +
qa
xn
2
+
ra2
xn5
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
18. The equation
z
x
0
2
e− x dt – 1 = 0 with six correct decimals.
2e–x =
1
1
+
x+2 x+1
has two roots greater than – 1.
Calculate these roots correct to five decimal places.
19. The equation x = 0.2 + 0.4 sin
FG x IJ where b is a parameter, has one solution near x = 0.3.
H bK
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 +
correct to 6 decimal places.
x2
x3 0.3x
+
e
2
6
182
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
21. Show that the equation
RS π(x + 1) UV + 0.148x – 0.9062 = 0
T 8 W
f(x) = cos
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) =
em + 1
ekm (m)
f
f (m + 1) (α)
(α) + k
m!
(m + 1) !
+
f ′(xk) = f ′ (α + ek ) =
ekm + 2
f (m + 2) (α) + .......
(m + 2) !
ekm −1
em
f (m) (α) + k f (m + 1) (α) + .......
(m − 1) !
m!
ALGEBRAIC
AND
TRANSCENDENTAL EQUATIONS
183
The error equation for the Newton-Raphson method becomes,
FG
H
ek + 1 = 1 −
IJ
K
f ( m + 1) ( α ) 2
1
1
3
ek + 2
ek + O ( ek )
(m )
m
m (m + 1) f
(α)
If m ≠ 1, we obtain,
FG
H
ek + 1 = 1 −
IJ
K
1
2
ek + O ( ek )
m
(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 k − β
fk
fk ′
(43)
where β is an arbitrary parameter to be determined.
If α is a multiple root of multiplicity m, we obtain from (43), the error
equation
FG
H
ek + 1 = 1 −
IJ
K
f (m + 1) (α) 2
β
β
ek + 2
ek + 0 (ek 3 )
m
m (m + 1) f (m) (α)
If the method (43) is to have the quadratic rate of convergence, then the
coefficient of ek must vanish, which gives
1−
β
=0
m
or β = m
Thus the method
xk + 1 = x k − m
fk
fk′
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
Hence, g(x) =
AND
STATISTICAL TECHNIQUES
f ( x)
has a simple root α and we can now use the Newtonf ′ ( x)
Raphson method
x k + 1 = xk −
g ( xk )
g ′ ( xk )
to find the approximate value of the multiple root α.
Simplifying, we have
x k + 1 = xk –
fk fk ′
fk′ 2 − fk fk″
which has a quadratic rate of convergence for multiple roots.
NOTE
If initial approximation x0 is sufficiently close to the root, then the expressions
x0 − m
f ( x0 )
f ′ ( x0 )
f ″ ( x0 )
, x0 − (m − 1)
, x0 − (m − 2)
will have same value.
f ′ ( x0 )
f ″ ( x0 )
f ″′ ( x0 )
EXAMPLES
Example 1. Show that the modified Newton-Raphson’s method
2f(x n )
f ′ (x n )
gives a quadratic convergence when f(x) = 0 has a pair of double roots in the
neighborhood of x = xn.
xn + 1 = xn –
2f (a + en )
, where a, en, and en + 1 have their usual meanings.
f ′ (a + en )
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
Sol. en
+1
= en –
2
e n + 1 = en –
LMe
MN
n
n
2
f ″ (a) +
2 en 2
= en –
LM e
MN 2 !
en
OP
PQ
f ″ (a) + .......
OP
PQ
en 2
f ″′ (a) + .......
2!
LM 1 f ″ (a) + 1 f ″′ (a) + .......OP
3!
N2!
Q
LM f ″ (a) + e f ″′ (a) + ......OP
2!
N
Q
n
ALGEBRAIC
2en
~
− en –
∴
AND
TRANSCENDENTAL EQUATIONS
185
LM 1 f ″ (a) + 1 f ″′ (a)OP
3!
N2 !
Q
f ″ (a) +
en + 1 ~
−
1 2
e .
6 n
en + 1 ≈
1 2 f ″ ′ (a)
e
6 n f ″ (a)
en
f ″′ (a)
2!
f ″ ′ (a)
LM f ″ (a) + e f ″ ′ (a)OP
2!
N
Q
n
en + 1 ∝ en2
⇒
and hence the convergence is quadratic.
Example 2. Find the double root of the equation
x3 – x2 – x + 1 = 0.
Sol. Let
so that
f(x) = x3 – x2 – x + 1
f ′(x) = 3x2 – 2x – 1
f ″(x) = 6x – 2
Starting with x0 = 0.9, we have
x0 – 2
and
f ( x0 )
2 × .019
= .9 –
= 1.003
f ′ ( x0 )
(− .37)
x0 – (2 – 1)
f ′ ( x0 )
(−.37)
= .9 –
= 1.009
f ″ ( x0 )
3.4
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
and
x1 – (2 – 1)
0.0002
f ( x1 )
= 1.01 – 2 ×
= 1.0001
0.0403
f ′ ( x1 )
f ′ ( x1 )
.0403
= 1.01 –
= 1.0001
4.06
f ″ ( x1 )
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
LM x − 7 x + 16 x − 12 OP , n = 0, 1, .......
MN 3x − 14 x + 16 PQ
3
n
2
n
2
n
n
n
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 NewtonRaphson 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
LM 1 − x e
MN ( x − 1) e
n
n
Starting with x0 = 0, we get
1 − xn
1 − xn
OP ; n = 0, 1, .......
PQ
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 ′ ( xi )
f ″ ( xi )
(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) +
But
1
(x – c)2 f ″(c) + .......
2
f ′(c) = 0
f(x) = f(c) +
1
(x – c)2 f ″(c) + R
2
Assuming R to be small, we conclude that the zero’s of f(x) near x = c are
approximately given by
f(c) +
⇒
1
(x – c)2 f ″(c) = 0
2
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
–1.0001
0
0.9999
– 1.0001
1
0
1
– 1.0001
1
– 0.0002 = f (1)
1
1
1
– .0001 = f ′(1)
1
2=
1
1
f ″(1)
2
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 ′ ( xi )
to modify the root. For this, we require f ″(1).
f ″ ( xi )
From the above synthetic division, we have
1
f ″ (1) = 2 ⇒ f ″ (1) = 4
2
∴ First approximation x1 = 1 –
f ′ (1)
(− .0001)
=1–
= 1.000025
f ″ (1)
4
Now we again calculate f(x1) and f ″(x1) by synthetic division.
1
–1
1.000025
– 1.000100
0.000025
0.999900
– 1.000095
1
. 000025
1.000025
– 1.00075
1.000075
– 0.000 195 = f (x1)
1
1.000050
1.000025
0 = f ′(x1)
1
∴
2.000075 =
1.000025
1
f ″(x1)
2
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)
, where c = 1.000025
f ″ (c)
= 1.000025 ±
− 2 (− .000195)
= 1.009899, 0.990151.
4.000150
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
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
1.
f(x) ≡ sin x –
5.
6.
x+1
= 0 near x = – .4
x−1
Give a comparative study of iterative methods.
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 = a12 + 2a2; b2 = a22 – 2a1a3 + 2a4 ...... bn = (– 1)n an2
(48)
ALGEBRAIC
TRANSCENDENTAL EQUATIONS
AND
191
If p1, p2, ......... , pn are the roots of (46), then the roots of (47) are
p12, p22, ......... , pn2.
Let us suppose that after m squarings, the new transformed equation is
zn + λ1zn–1 + ...... + λn–1z + λn = 0
whose roots are q1, q2, ......., qn such that qi = pi
2m
(49)
, 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’.
| q2 | q2
|qn |
q
, ......,
=
= n
|q1 | q1
| qn −1 | qn − 1
Thus
(50)
Also qi being an even power of pi, is always positive.
Now, from (49), we have
FG q + q + ......IJ
H q q
K
F q + ......IJ
= q q G1 +
H q
K
F q + ......IJ
= q q q G1 +
H q
K
⇒ λ1 = – q1 1 +
2
3
1
1
Σq1q2 = λ2
⇒ λ2
3
Σq1q2q3 = – λ3
⇒ λ3
Σq1 = – λ1
1 2
1
4
1 2 3
1
............................................................................
⇒ λn = (– 1)n q1q2q3 ...... qn.
q1q2q3 ...... qn = (– 1)n λn
Hence by (50), we find q1 ≈ – λ1; q2 ≈ –
qi = pi2m
But
pi = (qi
∴
)1/2m
λ2
λ
λ
, q3 ≈ − 3 , ......, qn ≈ − n
λ1
λ2
λ n −1
F λ I
= G−
H λ JK
1/2 m
i
(51)
i −1
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+1
λi
192
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
qiqi+1 ≈ qi2 ≈
∴
λ i+1
λ i−1
i.e., pi2m = qi2 =
λ i+1
λ i−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 e ± iφ r , then
the co-efficient of xn–r in successive squarings would vary both in magnitude and
sign by an amount 2Prm cos mφr. For sufficiently large Pr and φr can be determined
by
Pr 2(2
m
)
≈
λ r +1
λr
2m
m
; 2Pr cos 2 φ r = −
λ r−1
λ r−1
(53)
If there is only one pair of complex roots, say
Pr e ± iφ r = ξ r + iηr then ξr is given by
p1 + p2 + ...... + pr–1 + 2ξr + pr+2 + ...... + pn = – a1
(54)
ηr = Pr 2 – ξ r 2
(55)
and
If there are two pairs of complex roots, say
Pr e ± iφ r = ξ r ± iηr
and
Ps e
± iφ s
= ξ s ± iη s
where p1 + p2 + ...... + pr–1 + 2ξr + Pr+2 + ...... + ps–1 + 2ξs + ps+2 + ...... + pn = – a1
(56)
2
and
Fξ
GH P
r
2
r
+
ξs
Ps
2
I = − La
JK MN n
n− 1
ηr =
+
1
1
+ ...... +
a1
an
OP
Q
Pr 2 − ξ r 2 ; η s = Ps 2 − ξ s 2
(57)
(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
TRANSCENDENTAL EQUATIONS
AND
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)
Squaring again and putting
z(z +
129)2
y2
(61)
= z, we get
= (30z + 100)2
or
z3 + 258z2 + 16641z = 900z2 + 6000z + 10000
or
z(z2 + 10641) = (642z2 + 10000)
Squaring again and putting
u(u +
10641)2
z2
(62)
= u, we get
= (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
LM 100390881OP = 2.000811036 ≅ 2
N 378882 Q
L 10 OP = 0.99951247 ≅ 1
= M
N 100390881Q
1/8
p2 = (q2)1/8 = (– λ2/λ1)1/8 =
8
p3 = (q3)1/8 = (– λ3/λ2)1/8
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.
(64)
Sol. Here
f(x) = x4 – 3x + 1 = 0
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
z4 + 4z3 + 6z2 – 77z + 1 = 0
i.e.,
z4
or
+
6z2
+1=–
(65)
z(4z2
– 77)
Squaring once again and putting z2 = u, we get
(u2 + 6u + 1)2 = u(4u – 77)2
u4 – 4u3 + 654u2 – 5917u + 1 = 0
or
(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
p3 = (q3)1/8
p4 = (q4
)1/8
L λ
= M−
N λ
L λ
= M−
N λ
L λ
= M−
N λ
2
1
3
1
4
3
OP
Q
OP
Q
OP
Q
1/8
LM 654 OP
N4Q
L 5917 OP
=M
N 654 Q
L 1 OP
=M
N 5917 Q
1/8
=
1/8
1/8
= 1.8909921
1/8
= 1.3169384
1/8
= 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 e ± iφ 2 = ξ 2 ± iη2 . From (66), its magnitude is given by
3
ρ 2 2( 2 ) ≈
λ 3 5917
=
λ1
4
∴ ρ2 = 1.5780749
also from (64) the sum of the roots = 0, i.e., p1 + 2ξ2 + p4 = 0
∴
and
ξ2 = –
η2 =
1
(p + p4) = – 0.7634365
2 1
ρ 2 2 − ξ 2 2 = 1.9074851 = 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 = a12 + a2 = a1b2 + a2b1
bn = a1bn – 1 + a2bn – 2 + ....... + an – 1b1
n = 2, 3, .....
U|
||
V|
||
W
Ramanujan stated that the successive convergents viz.
root of the equation f(x) = 0.
bn
approach a
bn + 1
EXAMPLE
Example. Find the smallest root of the equation
x3 – 6x2 + 11x – 6 = 0 using Ramanujan’s method.
Sol. We have
LM1 − F 11x − 6 x
6
MN GH
Here,
a1 =
2
+ x3
I OP
JK PQ
−1
= b1 + b2x + b3x2 + .....
11
1
, a2 = – 1, a3 = , a4 = a5 = a6 = ..... = 0
6
6
196
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Hence
b1 = 1
b2 = a1 =
11
6
∴
b1
6
=
= .54545
b2 11
b3 = a1b2 + a2b1
=
121
85
− 1=
;
36
36
b2 66
=
= .7764705
b3 85
b4 = a1b3 + a2b2 + a3b1
=
575
;
216
b3 102
=
= .8869565
b4 115
b5 = a1b4 + a2b3 + a3b2 + a4b1
=
b4 3450
=
= .9423654
b5 3661
3661
;
1296
b6 = a1b5 + a2b4 + a3b3 + a4b2 + a5b1
=
22631
;
7776
b5 3138
=
= .9706155
b6 3233
The smallest root of the given equation is 1 and the successive convergents
approach this root.
ASSIGNMENT 3.12
1.
2.
3.
Find a root of the equation xex = 1
using Ramanujan’s method.
Find a root of the equation sin x = 1 – x
using Ramanujan’s method.
Using Ramanujan’s method, obtain the first eight convergents of the equation x + x3 = 1.
2
P a r t
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.
Chapter
4.1
4
INTERPOLATION
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.
199
200
COMPUTER-BASED NUMERICAL
4.2
ASSUMPTIONS FOR INTERPOLATION
AND
STATISTICAL TECHNIQUES
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)
where
Πn+1(x) = (x – x0) (x – x1) ...... (x – xn)
(2)
(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,
Construct a function,
where L is given by (4).
L=
y( x ′) − φ n ( x ′)
Π n + 1 ( x ′)
F(x) = y(x) – φn(x) – L Πn+1(x)
(4)
(5)
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) !
so that,
L=
y(n+ 1) (ξ)
(n + 1) !
d n +1
( x n+ 1 ) = (n + 1) !
dx n+ 1
(6)
Comparison of (4) and (6) give
y(x′) – φn(x′) =
y(n+ 1) (ξ)
Πn+1(x′)
(n + 1) !
Hence, the required expression of error is
y(x) – φn(x) =
Π n+ 1 ( x) n+1
y (ξ), x0 < ξ < xn
(n + 1) !
(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
4.4
FINITE DIFFERENCES
AND
STATISTICAL TECHNIQUES
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
x0
y0
x1
y1
Δ 2y
Δy
Δ3 y
Δ 4y
Δ5 y
Δy0
(= x0 + h)
x2
Δ2 y 0
Δ2 y
y2
(= x0 + 2h)
x3
= (x0 + 4h)
Δ5 y 0
Δ4 y
2
1
Δ3 y 2
Δy3
Δ2 y 3
y4
x5
Δ3 y 1
Δ2 y
y3
Δ4 y 0
1
Δy2
= (x0 + 3h)
x4
Δ3 y 0
Δy1
Δy4
y5
= (x0 + 5h)
Here the first entry, y0, is called the leading term and Δy0, Δ2y0, ...... are
called leading differences.
NOTE
Δ 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.
204
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Backward difference table
x
y
x0
y0
x1
(= x0 + h)
x2
(= x0 + 2h)
x3
(= x0 + 3h)
x4
(= x0 + 4h)
x5
y1
y2
y3
y4
y5
∇y
∇y1
∇y2
∇y3
∇y4
∇y5
∇2 y
∇2 y2
∇2 y
3
∇2 y4
∇2 y5
∇3 y
∇3y 3
∇3y
4
∇3y 5
∇4 y
∇5 y
∇4 y4
∇4 y5
∇5y 5
(= 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
x0
y0
x1
y1
x2
y2
x3
y3
x4
y4
x5
y5
δy
δy1/2
δy3/2
δy5/2
δy7/2
δy9/2
δ 2y
δ 2 y1
δ2y
δ2y
2
3
δ 2 y4
δ3y
δ3y3/2
δ3y
5/2
δ3y7/2
δ4y
δ4y 2
δ4y
3
δ 5y
δ5y5/2
INTERPOLATION
NOTE
4.5
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.
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
LM y
N
x+
1
h
2
+y
x−
1
h
2
OP
Q
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+Δ
∇ = 1 – E–1
2.
Proof.
∴
3.
∇yx = yx – yx–h = yx – E–1yx
∇ = 1 – E–1
δ = E1/2 – E–1/2
206
COMPUTER-BASED NUMERICAL
Proof.
AND
STATISTICAL TECHNIQUES
δyx = y
x+
h
2
– yx − h
2
= E1/2 yx – E–1/2 yx
= (E1/2 – E–1/2) yx
∴
4.
δ = E1/2 – E–1/2
μ=
Proof.
μyx =
1 1/2
(E + E–1/2)
2
1
1
( y h + yx − h ) = (E1/2 + E–1/2) yx
x+
2
2
2
2
⇒
1
μ = (E1/2 + E–1/2)
2
Δ = E∇ = ∇E = δE1/2
5.
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 = Δ
E = ehD
6.
Proof.
Ef(x) = f(x + h)
= f(x) + h f ′(x) +
h2
f ″(x) + .....
2!
= f(x) + hDf(x) +
h2 2
D f(x) + ......
2!
LM
N
= 1 + hD +
∴
OP
Q
(By Taylor series)
(h D) 2
+ ...... f(x) = ehD f(x)
2!
E = ehD or Δ = ehD – 1.
INTERPOLATION
4.7
207
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
y:
9962
9848
and point out the values of
Δ2y
15
20
25
30
9659
9397
9063
8660
10 ,
Δ4y
5.
208
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Sol. Forward difference table is as follows:
x
y
5
9962
10
9848
15
9659
20
9397
25
9063
30
8660
Δ 2y
Δy
– 114
Δ3 y
– 75
– 189
2
– 73
– 262
1
– 72
– 334
–1
2
3
– 69
– 403
Δ 4y
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
0
1
1
1
2
9
3
31
4
73
5
141
6
241
Δy
0
8
22
42
68
100
Δ 2y
8
14
20
26
32
Δ3 y
6
6
6
6
INTERPOLATION
209
Third differences are constant.
∵
∴
Δ3y3 = 6
⇒
⇒
Δ2y4 – 26 = 6
⇒
Δ2y4 = 32
Δ2y4 = 42
⇒
Δy5 – Δy4 = 32
Δy5 – 68 = 32
⇒
Now,
⇒
Further,
Δ2y4 – Δ2y3 = 6
Δy5 = 100
Δ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
10
1
20
1.3010
∇y
∇2 y
∇3 y
∇4 y
0.3010
– 0.1249
0.1761
30
1.4771
0.0738
– 0.0511
0.1250
40
1.6021
– 0.0508
0.0230
– 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
25
.4225
30
0.5000
∇2 y
∇y
∇3 y
.0775
– .0039
0.0736
35
0.5736
40
0.6428
45
0.7071
– .0005
– .0044
0.0692
– .0005
– .0049
0.0643
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
RS x + h − x UV = tan FG h IJ
H 1 + hx + x K
T 1 + x (x + h) W
–1
2
(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:
F 5x + 12 I ; the interval of differencing being unity.
GH x + 5x + 6 JK
RS 5x + 12 UV
T( x + 2)( x + 3) W
F 2 + 3 IJ = Δ LMΔ FG 2 IJ + Δ FG 3 IJ OP
=Δ G
H x + 2 x + 3K N H x + 2 K H x + 3 K Q
L F 1 − 1 IJ + 3 FG 1 − 1 IJ OP
= Δ M2 G
N H x + 3 x + 2K H x + 4 x + 3K Q
R 1 UV − 3Δ RS 1 UV
= – 2Δ S
T (x + 2)(x + 3) W T (x + 3)(x + 4) W
L 1 − 1 OP
=–2 M
N ( x + 3)( x + 4) ( x + 2)(x + 3) Q
L 1 − 1 OP
–3 M
N ( x + 4)(x + 5) (x + 3)( x + 4) Q
Δ2
Sol. Δ2
2
2
=
4
6
+
( x + 2)( x + 3)( x + 4) ( x + 3)( x + 4)( x + 5)
=
2(5 x + 16)
.
( x + 2)( x + 3)( x + 4)( x + 5)
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
STATISTICAL TECHNIQUES
AND
Example 8. With usual notations, prove that
Δn
Δn
Sol.
n! h
FG 1IJ = (– 1) .
.
H xK
x (x + h) ...... (x + nh)
FG 1IJ = Δ Δ FG 1IJ = Δ LM 1 − 1 OP
H xK
H xK
Nx + h xQ
RS − h UV
=Δ
T x(x + h) W
R 1 UV
= (– h) Δ Δ S
T x(x + h) W
LMΔ FG 1 − 1 IJ OP
= (– 1) Δ
N H x x + hK Q
LMFG 1 − 1IJ − FG 1 − 1 IJ OP
= (– 1) Δ
NH x + h x K H x + 2h x + h K Q
LM 2 − 1 − 1 OP
= (– 1) Δ
N x + h x x + 2h Q
LM − 2h OP
= (– 1) Δ
N x( x + h)(x + 2h) Q
LM 2 ! h OP
= (– 1) Δ
N x( x + h)(x + 2h) Q
OP
LM
3! h
= (– 1) Δ
N x(x + h)(x + 2h)(x + 3h) Q
n
n
n–1
n–1
n–1
n–2
n–2
n–2
n–2
2
n–2
2
n–2
3
n–3
2
3
= (– 1)n
n ! hn
.
x( x + h) ...... ( x + nh)
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
0
1
1
–1
Δ 2y
Δy
Δ3 y
Δ 4y
–2
4
2
2
1
3
–1
–8
–4
–2
8
4
2
4
Δ2 y 3
1
5
y5
6
y6
7
16
Δy4
Δ2 y 4
Δy5
Δ2 y 5
Δy6
16
Δ3 y 2
Δ3 y 3
Δ3 y
16
16
4
y7
Since values of y belong to a polynomial of degree 4, the fourth differences
must be constant.
Δ4y0 = 16
But
∴ Other fourth order differences will be 16.
Δ4y1 = 16
Thus,
∴
Δ3y2 – Δ3y1 = 16
⇒
Δ3y2 = 24
∴
Δ2y3 – Δ2y2 = 24
⇒
Δ2y3 = 28
Δy4 – Δy3 = 28
Δ y4 = 30
⇒
y5 – y4 = 30
y5 = 31
⇒
Again,
and
Δ4y
2
= 16 and solving, we get y6 = 129
Δ4y3 = 16 gives y7 = 351.
214
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
Example 10. Prove that
LM
N
OP
Q
Δf(x)
.
f(x)
Δ log f(x) = log 1 +
Sol.
L.H.S. = log f(x + h) – log f(x)
= log [f(x) + Δf(x)] – log f(x)
= log
| ∵ Δf(x) = f(x + h) – f(x)
LM f (x) + Δf ( x) OP = log LM1 + Δf (x) OP = R.H.S.
N f (x) Q
N f (x) Q
Example 11. Prove that
FΔ I e
GH E JK
2
ex =
FΔ I e
GH E JK
2
Sol.
x
x
.
Ee x
.
Δ2 e x
= Δ2 E–1 ex = Δ2 ex–h = e–h Δ2 ex
R.H.S. = e–h . Δ2 ex .
E ex
Δ2 e x
= e–h . E ex = e–h ex+h = ex.
hD = – log (1 – ∇) = sin h–1 (μδ).
Example 12. Prove that
hD = log E = – log (E–1) = – log (1 – ∇)
Sol.
Also,
μ=
| ∵ E–1 = 1 – ∇
1 1/2
(E + E–1/2)
2
δ = E1/2 – E–1/2
∴
μδ =
1
1
(E – E–1) = (ehD – e–hD) = sin h (hD)
2
2
hD = sin h–1 (μδ).
or
Example 13. Prove that
(i) (E1/2 + E–1/2) (1 + Δ)1/2 = 2 + Δ
(iii) Δ3y2 = ∇3y5.
(ii) Δ =
1 2
δ + δ 1 + δ 2/4
2
Sol. (i) (E1/2 + E–1/2) E1/2 = E + 1 = 1 + Δ + 1 = Δ + 2
(ii)
1 1/ 2
1 2
1
δ2
−1/ 2 2
)
δ + δ 1+
= (E1/2 – E–1/2)2 + (E1/2 – E–1/2) 1 + (E − E
4
2
2
4
F
GH
=
1
E1/2 + E −1/2
(E + E–1 – 2) + (E1/2 – E–1/2)
2
2
=
1
(2E – 2) = E – 1 = Δ
2
I
JK
INTERPOLATION
215
Δ3y2 = (E – 1)3 y2
(iii)
= (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
Δ ∇
−
∇ Δ
where Δ and ∇ are forward difference and backward difference operators
respectively.
(i) Δ + ∇ =
n−1
(ii)
∑Δ y
2
r=0
Sol. (i)
r
(iii) Δryk = ∇ryk+r.
= Δyn – Δy0
FG Δ − ∇ IJ y = FG E − 1 − 1 − E IJ y
H ∇ ΔK H 1− E E − 1 K
R|
FG E − 1IJ U|
| E − 1 − H E K |V y = FG E − 1 IJ y
=S
|| FGH EE− 1IJK E − 1 || H E K
W
T
−1
x
x
−1
x
x
= (E – E–1)yx
= {(1 + Δ) – (1 – ∇)}yx = (Δ + ∇)yx
Hence,
(ii)
Δ ∇
−
=Δ+∇
∇ Δ
n−1
∑
Δ2 yr =
r=0
n−1
∑ (Δ y
r+1
− Δyr )
r=0
= Δy1 – Δy0 + Δy2 – Δy1 + ...... + Δyn – Δyn–1
= Δyn – Δy0.
(iii)
∇ryk+r = (1 – E–1)ryk+r =
FG E − 1IJ
H E K
= (E – 1)r E–ryk+r = Δryk.
yk+r
FG xIJ = x(x − 1) ...... (x − n + 1) , prove that for any polynon!
H nK
F xI
φ(x) = ∑ G J Δ φ(0).
H iK
Example 15. Denoting
mial φ(x) of degree k
r
k
i
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.
∴
FI
∑ GH i JK Δ φ(0).
k
φ(x) = φ(0) + xC1 Δ φ(0) + ...... + xCk Δk φ(0) =
∴
x
i
i=1
Example 16. Obtain the first term of the series whose second and subsequent
terms are 8, 3, 0, – 1, 0.
f(1) = E–1 f(2) = (1 + Δ)–1 f(2)
Sol.
= (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)
2
8
3
3
4
0
5
–1
6
0
Hence,
Δf(x)
–5
–3
–1
1
Δ2f(x)
2
2
2
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
2
1
2
=
1
25 (c − b) + 3(a − c)
c+
2
256
where a = u0 + u5, b = u1 + u4, c = u2 + u3.
Sol.
u
2
1
2
= E5/2 u0 = (1 + Δ)5/2 u0
INTERPOLATION
LM
5 F5
G − 1IJK
5
2 H2
= M1 + Δ +
Δ
2!
MM 2
N
2
+ ...... +
217
IJ FG 5 − 2IJ FG 5 − 3IJ FG 5 − 4IJ OP
K H2 K H2 K H2 K Δ P u
5!
PP
Q
FG
H
5 5
−1
2 2
5
= u0 +
5
15 2
5 3
3
5
Δu0 +
Δ u0 +
Δ u0 –
Δ4u0 +
Δ5u0
2
8
16
256
128
= u0 +
5
15
5
(u1 – u0) +
(u2 – 2u1 + u0) +
(u – 3u2 + 3u1 – u0) + ......
2
8
16 3
+
3
(u – 5u4 + 10u3 – 10u2 + 5u1 – u0)
256 5
=
3
75
75
25
3a
25
(u0 + u5) –
(u1 + u4) +
(u2 + u3) =
b+
c
−
256
128
128
256
256 256
=
1
11
3a
25b
c 3(a − c) + 25(c − b)
+
−
+
c= +
.
2 128
256 256
2
256
FG
H
0
IJ
K
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
x+
2
=
1
1
(ux + ux+1) –
(Δ2ux + Δ2ux+1).
16
2
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.
Δ ex = ex+h – ex = (eh – 1) ex
(ii)
ex =
⇒
Hence,
(iii)
eh − 1
F e I =e
GH e − 1JK
x
Δ
Δe x
x
h
u
x+
1
2
or f(x) =
ex
eh − 1
.
= E1/2 ux = (1 + Δ)1/2 ux
FG
H
= 1+
IJ
K
1
1
Δ − Δ2 ux
2
8
(10) | ∵ Δ3 ux = 0
218
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Δ3 ux = 0
Now,
⇒ Δ2ux+1 – Δ2 ux = 0
Δ2ux+1 = Δ2ux and Δux = ux+1 – ux
⇒
∴ From (10),
u
1
x+
2
= ux +
=
1
1
(u – ux) –
2 x+1
8
FΔ u
GH 2
2
x
+
Δ2 ux + 1
2
I
JK
1
1
(ux + ux+1) –
(Δ2ux + Δ2ux+1).
2
16
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)
0
–3
1
6
Δf(x)
Δ2f(x)
Δ3f(x)
9
–7
2
2
8
3
12
9
2
4
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 (m)
x (m−1)
(x + 1)(m)
+
=
m!
(m − 1) !
m!
INTERPOLATION
219
(ii) Given u0 + u8 = 1.9243, u1 + u7 = 1.9590
u2 + u6 = 1.9823,
Sol. (i)
R.H.S. =
u3 + u5 = 1.9956. Find u4.
x( x − 1) ...... ( x − m + 1) x( x − 1) ...... ( x − m + 2)
+
m!
(m − 1) !
=
x( x − 1) ( x − 2) ...... ( x − m + 2)
[(x – m + 1) + m]
m!
=
( x + 1) x( x − 1)( x − 2) ...... ( x − m + 2) ( x + 1) (m)
=
= L.H.S.
m!
m!
(ii) Taking
Δ8 u0 = 0
8
⇒ (E – 1) 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)
LM f(x) OP = μg(x) δf(x) − μf(x) δg(x)
N g(x) Q g(x − ) g(x + )
L f(x) OP = μf(x) μg(x) − δf(x) δg(x)
(iii) μ M
N g(x) Q g(x − ) g(x + )
(ii) δ
1
2
1
2
1
2
1
4
1
2
The interval of difference is said to be unity.
Sol. (i) R.H.S. = μf(x) δg(x) + μg(x) δf(x)
=
E 1/ 2 + E −1/2
E1/ 2 + E −1/ 2
f(x) . (E1/2 – E–1/2) g(x) +
g(x) (E1/2 – E–1/2) f(x)
2
2
=
1
2
=
1
2
[{f(x +
1
2
) + f(x –
[{f(x + 21 )g (x +
1
2
1
2
)}{g(x +
) – f(x +
+ f(x +
1
2
1
2
1
2
) – g(x –
1
2
)}
+ {g(x +
1
2
) + g(x –
) g(x –
) g(x –
1
2
1
2
) + f(x –
1
2
1
2
)} {f(x +
) g(x +
1
2
1
2
) – f(x –
1
2
)}]
)
– f(x –
1
2
) g(x –
1
2
)} + {f(x +
) – f(x –
1
2
) g(x +
1
2
) – f(x –
1
2
1
2
) g(x +
) g(x –
1
2
1
2
)
)}]
220
COMPUTER-BASED NUMERICAL
=
1
4
f(x +
1
2
) g(x +
1
2
STATISTICAL TECHNIQUES
AND
) – 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 − 21 ) g( x + 21 )
Numerator of R.H.S.
=
E 1/ 2 + E −1/2
g(x) (E1/2 – E–1/2) f(x)
2
–
=
1
2
1
2
[{g(x +
1
2
) + g(x –
1
2
[f(x +
1
2
– f(x –
) g(x +
1
2
) g(x –
1
2
) + f(x +
1
2
1
2
)}{f(x +
– {f(x +
=
E1/ 2 + E −1/ 2
f(x) (E1/2 – E–1/2) g(x)
2
)] –
1
2
1
2
) + f(x –
1
2
) g(x –
[f(x +
+ f(x –
= f(x +
∴
R.H.S. =
=
1
2
) g(x –
) – f(x –
1
2
1
2
) g(x +
1
2
1
2
1
2
)}{g(x +
1
2
) – g(x –
) – f(x –
1
2
) g(x +
) g(x +
) g(x +
1
2
)}
1
2
1
)
2
) – f(x +
– f(x –
1
2
1
)
2
1
)}]
2
1
2
)
)g(x –
1
2
g(x –
1
)]
2
)
)
f ( x + 21 ) g ( x − 21 ) − f ( x − 21 ) g ( x + 21 )
g ( x − 21 ) g( x + 21 )
f ( x + 21 )
g( x + 21 )
LM f (x) OP − E LM f (x) OP
N g ( x) Q
N g( x) Q
F f (x) IJ = δ LM f (x) OP .
)G
H g(x) K N g(x) Q
−
= (E1/2 – E–1/2
(iii) R.H.S. =
1
2
1
2
) – f(x –
f ( x − 21 )
g( x − 21 )
μf ( x) μg ( x) −
g(x −
1)
2
1
4
= E 1/ 2
1/ 2
δf ( x) δg ( x)
g ( x + 21 )
Numerator of R.H.S.
=
=
1
2
1
4
[E1/2 + E–1/2] f(x) .
[f(x +
1
2
) + f(x –
–
1
2
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)
)][g(x +
1
2
) + g(x –
1
4
[f(x +
1
2
) – f(x –
1
2
)]
1
)][g(x
2
+
1
2
) – g(x –
1
)]
2
221
INTERPOLATION
=
1
4
[f(x +
1
2
1
2
+ f(x –
=
R.H.S. =
∴
=
1
2
[f(x +
1
2 [ f (x
1
2
1
2
) g(x +
1
2
) g(x –
) g(x –
) + f(x +
1
2
)–
1
2
1
[f(x
4
) 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
) g(x +
1
2
)
– f(x +
1
)
2
g(x –
1
)
2
) + f(x –
1
)
2
g(x –
1
)
2
)]
+ 21 ) g( x − 21 ) + f ( x − 21 ) g( x + 21 )]
g( x − 21 ) g ( x + 21 )
LM
MN
OP
PQ
1 f ( x + 21 ) f ( x − 21 )
E 1/2 + E −1/2
+
=
1
1
2 g( x + 2 ) g( x − 2 )
2
Example 22. Evaluate:
LM f (x) OP = μ LM f (x) OP .
N g( x) Q N g(x) Q
F 2 I ; h = 1.
GH (x + 1) ! JK
x
(i) Δ(eax log bx)
Sol. (i) Let
(ii) Δ
f(x) = eax, g(x) = log bx
Δ f(x) = ea(x+h) – eax = eax (eah – 1)
FG
H
Δg(x) = log b(x + h) – log bx = log 1 +
Also,
We know that,
h
x
IJ
K
Δ f(x) g(x) = f(x + h) Δ g(x) + g(x) Δf(x)
FG
H
∴ Δ (eax log bx) = ea(x+h) log 1 +
LM
N
FG
H
ah
= eax e log 1 +
(ii) Let
IJ
K
h
+ (log bx) eax(eah – 1)
x
IJ
K
OP
Q
h
+ (e ah − 1) log bx .
x
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,
Δ
LM f (x) OP = g(x) Δf (x) − f (x) Δg( x)
g( x + h) g( x)
N g(x) Q
=
( x + 1) ! . 2 x − 2 x . ( x + 1) ( x + 1) !
( x + 1 + 1) ! ( x + 1 )!
=
2 x ( x + 1) ! (1 − x − 1)
x
=−
2 x.
( x + 2) ! ( x + 1) !
( x + 2) !
(∵
h = 1)
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)
LM FG IJ OP
N H K Q
ah
ah + π I
F
= 2 sin
sin G ax + b +
J
H
2
2 K
= 2 sin
ah
h
+b
cos a x +
2
2
∴ Δ2 sin (ax + b)
LM
N
= Δ 2 sin
FG
H
ah
ah + π
sin ax + b +
2
2
IJ OP
KQ
FG ah IJ FG 2 sin ahIJ sin LMax + b + ah + π + ah + π OP
H 2KH 2K N
2
2 Q
F ah IJ sin LMax + b + 2 FG ah + π IJ OP
= G 2 sin
H 2 KQ
H 2K N
= 2 sin
2
Proceeding in the same manner, we get
FG
H
Δ3 sin (ax + b) = 2 sin
FG
H
Δn sin (ax + b) = 2 sin
Similarly,
ah
2
ah
2
FG
H
(ii) Δn cos (ax + b) = 2 sin
IJ
K
IJ
K
3
n
ah
2
Example 24. Prove that
(i) μδ =
1
(Δ + ∇)
2
3(ah + π)
2
LM
N
n(ah + π)
2
sin ax + b +
IJ
K
LM
N
n
cos ax + b + n
(ii) 1 +
(iii) ∇2 = h2D2 – h3D3 +
Sol. (i)
LM
N
sin ax + b +
Fδ I =
GH 2 JK
2
7 4 4
h D . ...... (iv) ∇ – Δ = – ∇Δ
12
x+
h
2
−y
x−
h)
2
= μ( y
x+
h)
2
− μ( y
OP
Q
FG ah + π IJ OP .
H 2 KQ
μδyx = μ(E1/2 – E–1/2)yx
= μ( y
OP
Q
x−
h)
2
1 + δ 2μ 2
INTERPOLATION
=
1 1/2
1
(E + E–1/2) ( y h ) − (E1/2 + E–1/2) ( y h )
x−
x+
2
2
2
2
1
1
1
1
(yx+h + yx) – (yx + yx–h) = (yx+h – yx) + (yx – yx–h)
2
2
2
2
1
1
1
= (Δyx) + (∇yx) = (Δ + ∇)yx
2
2
2
1
μδ =
(Δ + ∇)
2
=
Hence,
R| F δ I U| R (E − E ) U
L.H.S. = S1 + G J V y = S1 +
VW| y
2
T| H 2 K W| T|
R| F E + E − 2 I U| y = 1 (E + E )y
= S1 + G
|T H 2 JK V|W 2
2
(ii)
223
1/2
−1/2 2
x
–1
–1
x
x
x
2 2
R.H.S. = ( 1 + δ μ ) y x
1
LM RS
UO
(E + E
) VP
4
WQ
N T
R| F (E − E ) I U| y
= S1 + G
|T H 4 JK V|W
F E + E + 2I y = F E + E I y
=G
GH 2 JK
H 4 JK
= 1 + (E 1/2 − E −1/2 ) 2 .
−1 2
1/2
−1/2 2
1/2
yx
1/2
x
2
1/ 2
−2
−1
x
x
Hence L.H.S. = R.H.S.
(iii)
E = ehD and ∇ = 1 – E–1
∴
∇2 = (1 – E–hD)2
L R
(hD)
(hD)
(hD)
−
+
= M1 − S1 − hD +
2
!
3
!
4!
MN T
R (hD) + (hD) − (hD) + ...UV
= S hD −
2!
3!
4!
T
W
2
2
=
h2D2
3
3
LM1 − R hD − (hD)
MN ST 2 6
4
2
UVOP
WPQ
+ ...
2
2
4
UO
− ...VP
WPQ
2
224
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
LM R hD (hD) U R hD (hD) UOP
=
MN1 + ST 2 − 6 + ...VW − 2 ST 2 − 6 + ...VWPQ
L
O
F 1 1I
= h D M1 − hD + G + J (hD) − ...P
H 4 3K
N
Q
7
I
F
7
h D − ...J = h D – h D +
= h D GH 1 − hD +
h D – ...
K
12
12
F E − 1IJ – (E – 1) = (E – 1)(E – 1)
∇ – Δ = (1 – E ) – (E – 1) = GH
E K
2
2
2
h2D2
2
2
2
2
2
2
2
2
2
3
3
–1
(iv)
4
4
–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
2.
Continue the table to obtain f(6) and f(7).
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.
4.
Write the forward difference table for
x:
10
20
30
40
y:
1.1
2.0
4.4
7.9.
Construct the table of differences for the data below:
x:
f(x):
Evaluate
5.
Δ3
0
1
2
3
4
1.0
1.5
2.2
3.1
4.6
f(2).
Prove that:
(i) ∇ = ΔE–1 = E–1Δ = 1 – E–1
(iii) δ = ΔE–1/2 = ∇E1/2
(v) Δ∇ = ∇Δ = δ2
(vii) E = (1 – Δ)–1.
(ii) E1/2 = μ +
1
δ
2
(iv) δ(E1/2 + E–1/2) = ΔE–1 + Δ
(vi) δ = Δ(1 + Δ)–1/2 = ∇(1 – ∇)–1/2
INTERPOLATION
6.
ux is a function of x for which fifth differences are constant and
u1 + u7 = –786,
7.
u2 + u6 = 686,
1 − x2 – x
Evaluate:
(i) (E–1 Δ) x3
10.
(ii) u4 = u0 + 4Δu0 + 6 Δ2u–1 + 10 Δ3u–1.
Prove that:
Δ sin–1 x = sin–1 [(x + 1)
9.
u3 + u5 = 1088. Find u4.
Prove that:
(i) u4 = u3 + Δu2 + Δ2u1 + Δ3u1
8.
225
Evaluate:
(i) Δ
F
GH e
ex
x
+e
−x
(ii)
I
JK
1 − ( x + 1) 2 ].
F Δ I x ; h = 1.
GH E JK
2
3
(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
Δ2[x]n = Δ[nh [x]n–1] = nh Δ[x]n–1 = n(n – 1) h2 [x]n–2
Similarly,
Δn[x]n
= n(n – 1) ..... 2 . 1 . hn–1 (x + h – x) = n ! hn
Δn + 1[x]n = n ! hn – n ! hn = 0
Also,
Δ[x]n = n[x]n–1 and Δn[x]n = n !
when h = 1,
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
Since,
Δx(n)
=
x(0) = (x + h) x(– 1)
(12)
nhx(n–1)
(13)
when n = 1, Δx(1) = hx(0).
⇒
Δx = h x(0)
From (12),
⇒ h = hx(0) ⇒ x(0) = 1
x(–1) =
1
( x + h)
(14)
when n = – 1, from (11),
x(–1) = (x + 2h) x(–2)
⇒
1
= (x + 2h) x(–2)
x+h
In general, x(–n) =
x(–n) =
⇒
x(–2) =
1
( x + h)( x + 2h)
1
( x + h)( x + 2h) ...... ( x + nh)
(15)
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
4.11
227
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
2
3
–1
2
2
–1
4
2=C
3
2
3=B
– 10 = D
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
1
24
– 11
– 30
13
2
1
– 11
2
13
– 18
– 17 = D
3
1
–9
9=E
–5=C
3
4
1
–6=B
1=A
f(x) = [x]4 – 6[x]3 – 5[x]2 – 17[x] + 9
Hence,
∴
Δ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
Δ5f(x) = 0.
and
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
[ x] 3
[ x] 2
+ 20
+ 5[x] + c
3
2
= 3x(x – 1) (x – 2) + 10x(x – 1) + 5x + c = 3x3 + x2 + x + c
f(x) = 9
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
45
3
50
y1
55
y1 – 3
2 – y1
2
60
y3 – 2
y3
65
Δ2 y
Δy
– 2.4 – y3
5 – 2y1
y1 + y3 – 4
– 0.4 – 2y3
Δ3 y
3 y1 + y3 – 9
3.6 – y1 – 3y3
– 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
in terms of negative factorial
(x + 1)(x + 3)
polynomials.
Sol.
f(x) =
=
x−1
( x − 1)( x + 2)
=
( x + 1)( x + 3) ( x + 1)( x + 2)( x + 3)
1
4
4
−
+
x + 1 ( x + 1)( x + 2) ( x + 1)( x + 2)( x + 3)
= 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
STATISTICAL TECHNIQUES
AND
Comparing the coefficients of various powers of x, we get
α = a2 – ab, β = 2ab – b2, γ = b2
Eliminating a and b from the above equations,
γ2 + 4αγ = β2
we get
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
100
2
Δ 2y
Δy
Δ3 y
Δ 4y
.0043
101
2.0043
102
y2 – 2.0043
y2
103
2.0128
104
2.0170
2.0128 – y2
y2 – 2.0086
4.0171 – 2y2
y2 – 2.0086
.0042
6.0257 – 3y2
6y2 – 12.0514
3y2 – 6.0257
Δ4y = 0
Since
∴ 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
81 – 4f(3) + 54 – 12 + 1 = 0
⇒
231
(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.
f(x) = Ax2 + Bx + C
Sol. Let
The difference table is:
x
f(x)
0
1
1
3
Δ2f(x)
Δf(x)
2
2
4
2
7
3
13
2
6
Δ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
Also,
Δ2f(x) = 2A
Also,
⇒ A+B=2
⇒ Δ2f(0) = 2 = 2A
⇒ A=1
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
and
Δ5y0 = 0
and Δ5y1 = 0
⇒
(E – 1)5y0 = 0 and (E – 1)5y1 = 0
⇒
y5 – 5y4 + 10y3 – 10y2 + 5y1 – y0 = 0
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
⇒
and
y5 + 10y3 = 3450
(16)
– 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.
Δ5
∴ It is assumed that fifth differences are zero and hence both Δ5 y2.0 and
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
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
(18)
INTERPOLATION
233
= .074 – .41 + 10y2.4 – 1 + .555 – y2.1
= 10y2.4 – y2.1 – .781
Since
Δ5 y
∴
10y2.4 – y2.1 – .781 = 0
2.1
=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
Δ4y1 = 0
we assume
⇒
(E – 1)4 y1 = 0
⇒
(E4 – 4E3 + 6E2 – 4E + 1)y1 = 0
⇒
y5 – 4y4 + 6y3 – 4y2 + y1 = 0
⇒
37 – 4(21) + 6(13) – 4y2 + 7 = 0
⇒
38 – 4y2 = 0
|∵ h=1
y2 = 9.5
⇒
Hence the required missing value is 9.5.
ASSIGNMENT 4.2
1.
2.
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?
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):
(in millions)
17.1
13
14
9.6
—
12.4
18.2
234
3.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
From the following data, find the value of U47:
U46 = 0.2884, U48 = 0.5356, U49 = 0.6513, U50 = 0.7620.
[Hint:
4.
Δ4
Ux = 0
⇒ (E – 1)4 Ux = 0.]
Find by constructing the difference table, the tenth term of the series
3, 14, 39, 84, 155, 258, ......
[Hint: f(10) =
5.
6.
E9
f(1) = (1 + Δ)9 f(1)]
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
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
x
f(x)
x1
f(x1)
x2
f(x2)
x3
x4
x5
x6
f(x3)
f(x4)
Δf(x1)
f(x6)
x7
f(x7)
x8
f(x8)
x9
f(x9)
Δ2f(x1)
Δf(x2)
Δf(x3)
R|Δ f(x ) + e
S|⎯⎯⎯⎯→
T Δ f(x ) – e
4
f (x5 )
Δ2f(x)
Δf(x)
5
Δ f(x6)
Δ2f(x2)
R| Δ f(x ) + e
||
S|Δ f(x ) – 2e
|| Δ f(x ) + e
T
Δ f(x7)
Δ f(x8)
2
2
3
4
2
5
Δ2f(x6)
Δ2f(x7)
235
Δ3f(x)
Δ4f(x)
Δ3f(x1)
R| Δ f(x ) + e
||
|| Δ f(x ) – 4e
|S Δ f(x ) + 6e
||
|| Δ f(x ) – 4e
|| Δ f(x ) + e
T
R| Δ f(x ) + e
||
Δ f(x ) – 3e
|S⎯⎯⎯⎯→
||Δ f(x ) + 3e
||
T Δ f(x ) – e
3
3
2
3
3
4
3
5
Δ3f(x
6)
4
4
4
4
4
1
2
3
4
5
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.
236
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Sol.
x
y
1
2
2
5
3
10
Δ 2y
Δy
3
2
5
8
18 ←⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
8
26
11
37
13
50
4
5
6
7
3
Δ3 y
1
–3
0 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
3
3
–1
2
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:
103 y
103Δy
103Δ2y
103Δ3y
103Δ4y
1203
221
1424
36
257
1681
311
1992
18
54
4
22
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 + ... =
Sol. R.H.S. =
=
1
1
1
u0 − Δu0 + Δ2u0 – ...... .
8
2
4
LM
MN
FG IJ − FG 1 ΔIJ
H K H2 K
1
.
2
1
1
1
1+ Δ
u0 =
1
2
2
1+ Δ
2
2
1
1
1
1− Δ +
Δ
2
2
2
FG
H
FG
H
IJ
K
OP
PQ
3
+ ...... u0
IJ
K
−1
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(n − 1)
ux–2 + ...... + (– 1)n ux–n.
2
Δn ux–n = ux – nux–1 +
Sol.
R.H.S. = ux – nE–1 ux +
LM
N
−1
= 1 − nE +
n(n − 1) –2
E ux + ...... + (– 1)n E–n ux
2
OP
Q
n(n − 1) −2
E + ...... + (− 1) n E − n ux
2
= (1 – E–1)n ux
FG 1 IJ
H EK
E − 1I
= FG
H E JK
n
= 1−
ux
n
= Δn E–n ux
= Δn ux–n
= L.H.S.
ux =
Δn
ux
En
238
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Example 5. Show that:
F
GH
ex u0 + x Δ u0 +
F
GH
Sol. L.H.S. = ex 1 + xΔ +
F
GH
= 1 + xE +
I
JK
x2 2
x2
Δ u0 + ....... = u0 + u1x + u2
+ ...... .
2!
2!
I
JK
x 2 Δ2
+ ...... u0 = ex . exΔ u0 = ex(1+Δ) u0 = exE u0
2!
I
JK
F
GH
I
JK
x2
x 2 E2
u2 + ....... = R.H.S.
+ ...... u0 = u0 + xu1 +
2!
2!
Example 6. Prove the following identity:
u1x + u2x2 + u3x3 + ...... =
Sol.
x2
x
u1 +
Δu1 + .....
1− x
(1 − x) 2
L.H.S. = xu1 + x2 E u1 + x3 E2u1 + ...... = x (1 + xE + x2E2 + ......) u1
=x.
1
1
u =x.
u
[1 − x(1 + Δ)] 1
(1 − xE) 1
LM 1 OP u
N1 − x − x Δ Q
LM 1 OP u
MN 1 − 1x−Δx PQ
x L
xΔ
x Δ
x L
xΔ O
1+
+
=
(u ) =
1−
M
M
P
1− x N
1 − x (1 − x)
1− x N
1 − xQ
=x
=
1
x
1− x
1
−1
2 2
1
=
2
OP
Q
+ ...... u1
x
x2
x3
u1 +
Δu
+
Δ2u1 + ...... = R.H.S.
1
1− x
(1 − x) 2
(1 − x) 3
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
LM FG Δ IJ OP u
MN H E K PQ
n
= 1−
=
1
En
x =
1
En
(En – Δn) ux =
1
En
FE −Δ I u
GH E − Δ JK
n
[En–1 + ΔEn–2 + Δ2En–3 + ...... + Δn–1] ux
= (E–1 + ΔE–2 + Δ2E–3 + ...... + Δn–1 E–n) ux
n
x
|∵ 1+Δ=E
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 n 1.3 3 n 1 . 3 . 5 4 n
Δx +
Δx –
Δ x + ...... n terms
2
2.4
2 . 4 .6
F 1I F 1I
= Gx + J – Gx − J
H 2 K H 2K
LM
FG − 1IJ FG − 3 IJ
H 2K H 2 K . Δ
1
L.H.S. = Δ M1 − Δ +
1. 2
MM 2
N
n
Sol.
n
OP
+ ...... ∞ P x
PP
Q
F 1I
= Δ (1 + Δ)
x =ΔE
x = Δ Gx − J
H 2K
1I
F
F 1 I F 1 I F 1I
= Gx + 1− J – Gx − J = Gx + J – Gx − J
H
H 2 K H 2K H 2K
2K
2
n
n
–1/2
n
–1/2
n
n
n
n
n
= R.H.S.
Example 9. Prove that:
ux –
1.3 .5
1 2
1.3 4
Δ ux–1 +
Δ ux–2 –
Δ6 ux–3 + ......
8 . 16 . 24
8
8.16
=u
Sol.
x+
1
2
–
1
1 2
1 3
Δu 1 +
Δ u 1 –
Δ u 1 + ....
x+
x+
x+
8
2
4
2
2
2
1. 3 . 5
1
1.3 4 –2
Δ E ux –
Δ6 E–3 ux + ......
L.H.S. = ux – Δ2 E–1 ux +
8 . 16 . 24
8
8.16
FG − 1IJ FG − 1 − 1IJ
H 2K H 2 K F Δ I u
GH 4E JK
1. 2
FG − 1IJ FG − 1 − 1IJ FG − 1 − 2IJ
H 2K H 2 K H 2 K F Δ I
+
GH 4EJK
1. 2 . 3
LM
OP
FG − 1IJ FG − 1 − 1IJ
F
K
Δ I
1I F Δ I H 2 K H 2
F
= M1 + G − J G
GH 4E JK + ......PP u
2!
MM H 2 K H 4E JK +
PQ
N
F I
GH JK
1 Δ2
ux +
= ux –
2 4E
2
2
x
2
2
2
3
2
x
ux + ......
240
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
F Δ I u = F 4E + Δ I u
= G1 +
GH 4E JK
H 4E JK
L 4(1 + Δ) + Δ OP u = LM (2 + Δ) OP
=M
N 4E Q
N 4E Q
L 4E OP u = 2 E FG 1 IJ u
=M
H 2 + ΔK
N (2 + Δ) Q
F Δ Δ − ......I u
= E G1 − +
JK
H 2 2
−1/ 2
2
2
−1/ 2
x
x
2 − 1/ 2
2
−1/ 2
ux
x
FG
H
1/ 2
1/2
x
2
1/2 1 +
x = E
Δ
2
IJ
K
−1
ux
2
1/2
=u
2
1
x+
2
–
x
1
1
Δ u 1 + Δ2 u 1 – ...... = R.H.S.
x+
x+
2
4
2
2
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+1C
2
Δ2un–2 +
x+2C
3
Δ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 +
=
1
Ex
Δ2E–1)x
FE+ Δ I
=G
H E JK
2
ux
x
ux
FE
=G
H
2
I
JK
−E+1
E
x
ux
[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
FG Δ IJ
H EK
F 1I
=G J u
H EK
−x
= 1−
−x
n
un =
FG E − Δ IJ
H E K
−x
un
= Exun = un+x = L.H.S.
INTERPOLATION
241
(iii) L.H.S. = u0 + Eu0 + E2 u0 + ..... + Enu0 = (1 + E + E2 + ....... + En) u0
=
=
F E − 1I u = LM (1 + Δ)
GH E − 1 JK N Δ
n+ 1
n+ 1
−1
0
OP u
Q
0
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
F E − 1I u = LM (1 + Δ)
GH E − 1 JK N Δ
n(n − 1)
1L
Δ
= M1 + n Δ +
2!
ΔN
=
n
n
0
2
=n+
−1
+
OP u
Q
0
OP
Q
n (n − 1)(n − 2) 3
Δ + ...... + Δn − 1 u0
3!
n(n − 1)
n (n − 1) (n − 2) 2
Δ u0 +
Δ u0 + ......
2!
3!
Δ u0 = u1 – u0 = 23 – 13 = 7
Now,
Δ2 u0 = u2 – 2u1 + u0 = 33 – 2(2)3 + (1)3 = 12
and
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)
n (n − 1) (n − 2)
n (n − 1) (n − 2) (n − 3)
(7) +
(12) +
(6)
2!
6
24
LM
N
n2
n (n + 1)
(n2 + 2n + 1) =
4
2
Example 12. Sum to n terms, the series
OP .
Q
2
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
(Δ + 1)S = 1.2Δxn – 2.2Δ2xn + 2.3Δ3xn – 2.4Δ4xn + ...
Hence,
= 2Δ(1 – 2Δ + 3Δ2 – ...)xn = 2Δ(1 + Δ)–2 xn
S = 2Δ(1 + Δ)–3 xn = 2ΔE–3 xn = 2Δ(x – 3)n
or
= 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.
2.
3.
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.
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.
Prove the identities:
(i) ux – Δ2ux + Δ3ux – Δ5ux + Δ6ux – Δ8ux + ......
= ux – Δ2ux – 1 + Δ4 ux – 2 – Δ6 ux – 3 + Δ8 ux – 4 – ......
∞
(ii)
∑
u2 x =
x=0
4.
1
2
∞
∑
x=0
ux +
F
GH
I
JK
1
Δ Δ2
− ...... u0.
1− +
4
2
4
Prove that:
1
1
1
(1 + x)2 + 2 (2 + x)2 + 3 (3 + x)2 + ...... = 2 (x2 + 2x + 3)
2
2
2
using the calculus of finite differences and taking the interval of difference unity.
x2 +
[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 interpolation. 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 technique 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
4.14
243
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) = A 0 + A 1 (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,
For
x = a + h,
f(a) = A0
(21)
f(a + h) = A0 + A1h
f(a + h) = f(a) + A1h
⇒
A1 =
⇒
| By (21)
Δf (a)
h
(22)
For x = a + 2h,
f(a + 2h) = A0 + A1 (2h) + A2 (2h) h
= f(a) + 2h
⇒
RS Δf (a) UV + 2h
T h W
2
A2
2h2A2 = f(a + 2h) – 2f(a + h) + f(a) = Δ2f(a)
⇒
A2 =
Similarly,
A3 =
Thus,
An =
Δ2 f (a)
2 ! h2
Δ3 f (a)
and so on.
3 ! h3
Δn f (a)
n ! hn
.
244
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
Δ2 f (a)
Δ f (a)
+ (x – a) (x – a – h)
+ .......
h
2 ! h2
Δn f (a)
+ (x – a) ...... (x – a – n − 1 h)
n ! hn
x−a
x = a + hu ⇒ u =
, we have
h
(hu) (hu − h) 2
Δ f (a)
f(a + hu) = f(a) + hu
+
Δ f (a) +......
2 ! h2
h
From (20),
Put
AND
f(x) = f(a) + (x – a)
+
⇒
(hu) (hu − h) (hu − 2h) ....... (hu − n − 1 h)
f(a + hu) = f(a) + uΔ f(a) +
n ! hn
Δn f(a)
u(u − 1) 2
Δ f(a) + ...
2!
+
u(u − 1)(u − 2) ... (u − n + 1) n
Δ f(a)
n!
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
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
Start of the program
Input number of terms n
Input the array ax
Input the array ay
h=ax[1] – ax[0]
for i=0; i<n-1; i++
diff[i] [1]=ay[i + 1] – ay[i]
End Loop i
for j=2; j<=4; j++
for i = 0; i <n – j; i++
diff[i][j]=diff [i + 1] [j – 1]-diff [i][j – 1]
End Loop i
End Loop j
i=0
Repeat Step 16 until ax[i]<x
i=i + 1
i=i – 1;
INTERPOLATION
Step
Step
Step
Step
Step
Step
Step
Step
18.
19.
20.
21.
22.
23.
24.
25.
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
y=ay[i]+y1+y2+y3+y4
Print output x, y
End of program.
4.15.2 Flow-chart
245
246
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
A
i=0
Is
ax[i] > x
B
No
i=i+1
Yes
i=i–1
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
y = ay[i] + y1 + y2 + y3 + y4
Print output x, y
STOP
NOTE
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
B
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;
int i,j;
//... Number of terms
//... Loop Variables
//...Floating Type
float ax[10];
float ay[10];
//... array limit 9
//... array limit 9
float x;
float y = 0;
//... User Querry
//... Initial value 0
float h;
float p;
//... Calc. section
//... Calc. section
float diff[20][20];
float y1,y2,y3,y4;
//... array limit 19,19
//... 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 ("\n\n Enter the value in the form of x - ");
//... Input Loop for X
for (i=0;i<n;i++)
{
printf("\n\n Enter the value of x%d - ",i+1);
scanf("%f",&ax[i]);
}
//... Input Sequel for array Y
printf("\n\n Enter the value in the form of y – ");
//... Input Loop for Y
for (i=0;i<n;i++)
{
printf ("\n\n 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;i<n-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
INTERPOLATION
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("\n\n\n 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
249
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 7
= = 1.4
h
5
Difference table is:
Differences
x°
104y
45°
7071
50°
7660
55°
8192
60°
8660
104Δy
104 Δ2y
104 Δ3y
589
– 57
532
–7
– 64
468
By forward difference formula,
f(a + hu) = f(a) + u Δ f(a) +
⇒
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ f (a) +
Δ f(a)
2!
3!
104 f(x) = 104 f(a) + 104 u Δ f(a) + 104
u(u − 1)
Δ2 f(a)
2!
+ 104
u(u − 1)(u − 2) 3
Δ f(a)
3!
INTERPOLATION
⇒
104 f(52) = 104 f(45) + (1.4) 104 Δ f(45) +
+
= 7071 + (1.4)(589) +
251
(1.4)(1.4 − 1)
104 Δ2 f(45)
2!
(1.4)(1.4 − 1)(1.4 − 2)
104 Δ3 f(45)
3!
(1.4)(.4)
(1.4)(.4)(− .6)
(− 57) +
(– 7)
2
6
= 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:
Population y:
(in thousands)
Sol. Here
⇒
1891
1901
1911
1921
1931
46
66
81
93
101
a = 1891, h = 10,
1891 + 10 u = 1895
⇒
a + hu = 1895
u = 0.4
The difference table is as under:
x
y
1891
46
1901
66
Δy
Δ2 y
Δ3 y
Δ4 y
20
–5
15
1911
81
2
–3
–3
12
1921
93
–1
–4
8
1931
101
Applying Newton’s forward difference formula,
y(1895) = y(1891) + u Δy(1891) +
u(u − 1) 2
Δ y(1891)
2!
+
+
u(u − 1)(u − 2) 3
Δ y(1891)
3!
u(u − 1)(u − 2)(u − 3) 4
Δ y(1891)
4!
252
COMPUTER-BASED NUMERICAL
⇒
AND
STATISTICAL TECHNIQUES
y(1895) = 46 + (.4)(20) +
+
⇒
(.4)(.4 − 1)
(– 5)
2
(.4)(.4 − 1)(.4 − 2)
(.4)(.4 − 1)(.4 – 2)(.4 − 3)
(2) +
(– 3)
6
24
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,
i.e.,
h = 1, x = 3.2 ∴ a + h u = 3.2
3 + 1 × u = 3.2
or
u = 0.2
The difference table is:
x
f(x)
3
16
4
20
5
24
6
38
Δf(x)
4
4
14
Δ2f(x)
Δ3f(x)
0
10
10
Applying Newton’s forward difference formula,
f(3.2) = f(3) + u Δ f(3) +
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ f (3) +
Δ f (3)
3!
2!
(.2)(.2 − 1)
(.2)(.2 − 1)(.2 − 2)
(0) +
(10) = 17.28.
2
6
Example 4. From the following table, find the value of e0.24
= 16 + (.2)(4) +
x:
0.1
0.2
0.3
INTERPOLATION
253
Sol. The difference table is:
x
105y
0.1
110517
0.2
122140
0.3
134986
0.4
149182
0.5
164872
Here
10 5Δy
11623
12846
14196
15690
h = 0.1.
105Δ2y
105 Δ3y
1223
127
1350
0.24 = 0.1 + 0.1 × u
∴
17
144
1494
or
104Δ4y
u = 1.4
Newton-Gregory forward formula is
y(.24) = y(.1) + u Δ y(.1) +
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y(.1) +
Δ y(.1)
2!
3!
+
⇒ 105 y(.24) = 105 y(.1) + u 105 Δy(.1) +
+
u(u − 1)
105 Δ2y(.1)
2!
u(u − 1)(u − 2)(u − 3)
u(u − 1)(u − 2)
105 Δ3y(.1) +
105 Δ4y(.1)
4!
3!
⇒ 105 y(.24) = 110517 + (1.4)(11623) +
+
u(u − 1)(u − 2)(u − 3) 4
Δ y(.1)
4!
(1.4)(1.4 − 1)
(1223)
2
(1.4)(1.4 − 1)(1.4 − 2)
(1.4)(1.4 − 1)(1.4 − 2)(1.4 − 3)
(127) +
(17)
3!
4!
= 127124.9088
∴
Hence,
y(.24) = 1.271249088
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
(in dollars)
114.84
96.16
83.32
74.48
68.48
254
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Sol. The difference table is:
Age
(x)
Premium
(in dollars)
(y)
45
114.84
50
96.16
Δy
Δ2 y
Δ 3y
Δ4 y
– 18.68
5.84
– 12.84
55
83.32
– 1.84
4
.68
– 8.84
60
74.48
– 1.16
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 − 1) 2
u(u − 1)(u − 2) 3
Δ y45 +
Δ y45
2!
3!
+
= 114.84 + (.2)(– 18.68) +
u(u − 1)(u − 2)(u − 3) 4
Δ y45
4!
(.2)(.2 − 1)
(5.84)
2!
(.2)(.2 − 1)(.2 − 2)
(.2)(.2 − 1)(.2 − 2)(.2 − 3)
(– 1.84) +
(.68)
3!
4!
= 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:
Number of students:
30—40
40—50
50—60
60—70
70—80
31
42
51
35
31.
INTERPOLATION
255
Sol. The difference table is:
Scores less than
(x)
y
40
31
50
73
Δ 2y
Δy
Δ3 y
Δ4 y
42
9
51
60
124
70
159
– 25
– 16
37
35
12
–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
Δ y(40)
2!
u(u − 1)(u − 2) 3
u(u − 1)(u − 2)(u − 3) 4
Δ y(40) +
Δ y(40)
3!
4!
= 31 + (.5)(42) +
(.5)(.5 − 1)
(.5)(.5 − 1)(.5 − 2)
(9) +
(– 25)
2
6
+
(.5)(.5 − 1)(.5 − 2)(.5 − 3)
(37)
24
= 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
0
1
1
2
2
1
3
10
Δ2 y
Δy
1
Δ3 y
–2
–1
12
10
9
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 +
= 1 + x(1) +
x( x − 1) 2
x ( x − 1) ( x − 2) 3
Δ y0 +
Δ y0
2!
3!
x( x − 1)
x( x − 1) ( x − 2)
(– 2) +
(12)
2!
3!
= 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:
Number of students:
30—40
40—50
50—60
60—70
70—80
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
Less than 40
Number of students
25
Less than 50
Less than 60
60
82
Less than 70
Less than 80
93
100
INTERPOLATION
(i) Here, a = 40,
∴ 40 + 10u = 55
h = 10,
⇒ u = 1.5
257
a + hu = 55
First, we find the number of students who got scores less than 55.
The difference table follows:
Scores obtained
less than
Number of
students = y
40
25
50
60
60
82
70
93
80
100
Δ2 y
Δy
35
– 13
22
– 11
11
–4
7
Δ3 y
2
7
Δ4 y
5
Applying Newton’s forward difference formula,
y55 = y40 + u Δ y40 +
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y40
Δ y40 +
2!
3!
+
= 25 + (1.5)(35) +
u(u − 1)(u − 2)(u − 3) 4
Δ y40
4!
(1.5)(.5)
(1.5)(.5)(− .5)
(− 13) +
(2)
2!
3!
+
(1.5)(.5)(− .5)(− 1.5)
(5)
4!
= 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.
Also,
u=
x − a 36 − 40
= – .4
=
h
10
u=
45 − 40
= .5
10
258
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Newton’s forward difference formula:
y36 = y40 + u Δ y40 +
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y40
Δ y40 +
2!
3!
+
= 25 + (– .4)(35) +
(− .4)(− 1.4)
(− .4)(− 1.4)(− 2.4)
(− 13) +
(2)
2!
3!
+
Also, y45 = y40 + u Δ y40 +
(− .4)(− 1.4)(− 2.4)(− 3.4)
(5) = 7.864 ≈ 8
4!
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y40 +
Δ y40
2!
3!
+
= 25 + (.5)(35) +
u(u − 1)(u − 2)(u − 3) 4
Δ y40
4!
u(u − 1) (u − 2) (u − 3) 4
Δ y40
4!
(.5)(− .5)
(.5)(− .5)(− 1.5)
(2)
(− 13) +
2
6
(.5)(− .5)(− 1.5)(− 2.5)
(5)
+
24
= 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
x
Number of deaths
f(x)
35
13229
45
31368
55
55593
65
87089
Δf(x)
18139
24225
31496
Δ2f(x)
6086
7271
Δ3f(x)
1185
INTERPOLATION
Here,
∴
259
h = 10, a = 35, a + hu = 50
35 + 10u = 50 ⇒ u = 1.5
By Newton’s forward difference formula,
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y35
y50 = y35 + u Δ y35 +
Δ y35 +
2!
3!
= 13229 + (1.5)(18139) +
∴
(1.5)(.5)
(1.5)(.5)(– .5)
(6086) +
(1185)
2
6
= 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 +
FG B IJ , where A is the arithmetic mean of q and r and B is arithmetic
H 24 K
mean of 3q – 2p – s and 3r – 2s – p.
Sol.
A=
q+r
2
B=
(3q − 2 p − s) + (3r − 2 s − p) 3q + 3r − 3 p − 3s
=
2
2
⇒ q + r = 2A
3(q + r) 3( p + s)
−
2
2
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 +
FG h IJ
H 2K
i.e., a +
3h
.
2
3
3
h ⇒ m=
2
2
Let us now construct the difference table:
Hence
a + mh = a +
x
f(x)
a
p
a+h
q
a + 2h
r
a + 3h
s
Δf(x)
q–p
r–q
s–r
Δ2f(x)
r – 2q + p
s – 2r + q
Δ3f(x)
s – 3r + 3q – p
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
FG
H
FG
H
IJ
K
IJ FG
KH
IJ
K
3 3
3
3 3
−1
−1
−2
3
3
2 2
2
2 2
Δ2 f (a) +
Δ3 f (a)
f a + h = f(a) + Δ f (a) +
2
6
2
2
FG
H
IJ
K
=p+
3
3
1
(q – p) + (r – 2q + p) –
(s – 3r + 3q – p)
2
8
16
=
(16 p − 24 q − 24 p + 6 r − 12q + 6 p − s + 3r − 3q + p)
16
=
1
9
(– p + 9q + 9r – s) =
(q + r) –
16
16
=
2 3A − B
9
(2A) –
16
3
16
=
9
1
B
B
A– A+
=A+
.
8
8
24
24
FG
H
IJ
K
FG p + s IJ
H 16 K
ASSIGNMENT 4.4
1.
2.
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.
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.
4.
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.
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
5.
Ordinates f(x) of a normal curve in terms of standard deviation x are given as
x:
f(x):
6.
7.
1.00
1.02
1.04
1.06
1.08
0.2420
0.2371
0.2323
0.2275
0.2227
Find the ordinate for standard deviation x = 1.025.
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
Find the number of students from the following data who secured scores not more than 45
Scores range:
Number of students:
8.
30—40
40—50
50—60
60—70
70—80
35
48
70
40
22
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
9
30
35
42
Frequency:
9.
261
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 polynomial 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:
tan x:
.10
.15
.20
.25
.30
.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
FORMULA
GREGORY
BACKWARD
INTERPOL ATION
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.
Put
x = a + nh, a + n − 1 h, ......, a in (23) respectively.
Put
x = a + nh, then
Put
x = a + (n – 1) h, then
f (a + nh) = A0
f(a + n − 1 h) = A0 – h A1 = f(a + nh) – h A1
A1 =
⇒
Put
∇ f (a + nh)
h
x = a + (n – 2)h, then
f (a + n − 2 h) = A0 – 2hA1 + (– 2h) (– h) A2
(23)
(24)
| By (24)
(25)
INTERPOLATION
⇒
263
2 ! h2 A2 = f(a + n − 2 h) – f(a + nh) + 2 ∇ f(a + nh)
= ∇ 2 f(a + nh)
A2 =
∇ 2 f (a + nh)
(26)
2 ! h2
Proceeding, we get
An =
∇ n f (a + nh)
(27)
n ! hn
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 f (a + nh)
n ! hn
(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
∇ f(a + nh)
2!
+ ...... + uh . (u + 1)h ..... (u + n − 1)(h)
or
f(a + nh + uh) = f(a + nh) + u ∇ f(a + nh) +
+ ...... +
∇ n f (a + nh)
n ! hn
u(u + 1) 2
∇ f(a + nh)
2!
u(u + 1) ...... (u + n − 1) n
∇ f(a + nh)
n!
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; 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. 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
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
Is
! ax[i] < x
Yes
i=i+1
A
265
266
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
A
x0 = mx[i]
Sum = 0
y0 = my[i]
Fun = 1
p = (x – x0)/n
Sum = y0
Start loop k = 1 to 4
fun = (fun * (p – (k – 1)))/k
Sum = sum + fun * diff[i][k]
End loop k
Print ‘‘Output’’, x, sum
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];
float x;
//... array limit 9
//... User Querry
float x0 = 0;
float y0;
//... Initial value 0
//... Calc. Section
float sum;
float h;
//... Calc. Section
//... Calc. Section
float fun;
float p;
//... Calc. Section
//... Calc. Section
float diff[20][20];
float y1, y2, y3, y4;
//... array limit 19,19
//... 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("\n\n Enter the value in the form of x - ");
//...Input Loop for X
for (i=0;i<n;i++)
{
printf("\n\n Enter the value of x%d - ",i+1);
scanf (“%f”,&mx[i]);
}
//...Input Sequel for array Y
printf ("\n\n Enter the value in the form of y -");
//...Input Loop for Y
for (i=0;i<n;i++)
{
printf ("\n\n 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;i<n-1;i++)
{
diff[i][1]=my[i+1]-my[i];
}
for (j=2;j<=4;j++)
{
for (i=0;i<n-j;i++)
{
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
}
}
INTERPOLATION
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("\n\n\n 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 xEnter 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
269
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
46
66
81
93
101
Population (y):
(in thousands)
Sol. Here,
a + nh = 1931, h = 10,
a + nh + uh = 1925
1925 − 1931
= – 0.6
10
The difference table is:
u=
∴
x
y
1891
46
1901
66
∇y
∇2 y
∇3 y
∇4 y
20
–5
15
1911
81
2
–3
12
1921
93
–4
8
1931
101
–3
–1
INTERPOLATION
271
Applying Newton’s Backward difference formula, we get
y1925 = y1931 + u ∇ y1931 +
+
u(u + 1) 2
∇ y1931
2!
u(u + 1)(u + 2) 3
u(u + 1)(u + 2)(u + 3) 4
∇ y1931 +
∇ y1931
3!
4!
= 101 + (– .6)(8) +
(− .6)(.4)
(− .6)(.4)(1.4)
(− 4) +
(– 1)
2!
3!
+
(− .6)(.4)(1.4)(2.4)
(– 3)
4!
= 96.8368 thousands.
Hence the population for the year 1925 = 96836.8 ≈ 96837.
Example 2. The population of a town is as follows:
Year:
Population:
(in Lakhs)
1921
1931
1941
1951
1961
1971
20
24
29
36
46
51
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
1921
20
1931
24
1941
29
∇y
∇2 y
∇3y
∇4 y
∇5 y
4
1
5
1
2
7
1951
36
1961
46
1971
51
0
1
3
10
–8
–5
5
–9
–9
272
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Applying Newton’s backward difference formula, we get
y1955 = y1971 + u ∇ y1971 +
+
u(u + 1) 2
u(u + 1)(u + 2) 3
∇ y1971
∇ y1971 +
2!
3!
u(u + 1)(u + 2)(u + 3) 4
u(u + 1)(u + 2)(u + 3)(u + 4) 5
∇ y1971 +
∇ y1971
4!
5!
(− 1.6)(− 0.6)(0.4)
(− 1.6)(− 0.6)
(– 5) +
(– 8)
6
2!
= 51 + (– 1.6)(5) +
+
(− 1.6)(− 0.6)(.4)(1.4)
(− 1.6)(− 0.6)(0.4)(1.4)(2.4)
(– 9) +
(– 9)
24
120
= 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
3
4.8
4
8.4
5
14.5
Δy
Δ 2y
Δ3 y
Δ4 y
3.6
2.5
6.1
0.5
3
9.1
6
23.6
3.5
12.6
7
36.2
0
0.5
4
16.6
8
0
0.5
52.8
0
0.5
4.5
21.1
9
73.9
To find the first term, we use Newton’s forward interpolation formula.
INTERPOLATION
Here,
a = 3,
h = 1, x = 1
We have y1 = y3 + uΔy3 +
273
x−a
=–2
h
∴ u=
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y3 +
Δ y3
2!
3!
= 4.8 + (– 2) × 3.6 +
(− 2)(− 3)
(− 2)(− 3)(− 4)
(2.5) +
(0.5)
2
6
= 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
u(u + 1)(u + 2) 3
∇ y9 +
∇ y9
2!
3!
= 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:
log x:
40
45
50
55
60
65
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
40
160206
45
165321
50
169897
105 ∇yx
105 ∇2 yx
105 ∇3yx
105∇4 yx
105∇5yx
5115
– 539
4576
102
– 437
4139
55
174036
– 360
3779
60
177815
181291
5
– 20
57
– 303
3476
65
– 25
77
274
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Newton’s Backward difference formula is
u(u + 1) 2
∇ f(a + nh)
2!
f(a + nh + uh) = f(a + nh) + u∇f(a + nh) +
+
u(u + 1)(u + 2) 3
u(u + 1)(u + 2)(u + 3) 4
∇ f(a + nh) +
∇ f(a + nh)
3!
4!
+
u(u + 1)(u + 2)(u + 3)(u + 4) 5
∇ f(a + nh)
5!
(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)
(– 303)
2!
(− 1.25)(− .25)(.75)
(− 1.25)(− .25)(.75)(1.75)
(57) +
(– 20)
3!
4!
+
(− 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°:
tan x°:
45
46
47
48
49
50
1.00000
1.03053
1.07237
1.11061
1.15037
1.19175
Sol. Here a + nh = 50, h = 1,
∴
50 + u(1) = 48.25
⇒
a + nh + uh = 48° 15′ = 48.25°
u = – 1.75
INTERPOLATION
275
The difference table is:
x°
105y
45
100000
105∇y
105∇2y
105∇3y
105∇4y
105∇5y
3553
46
103553
47
107237
131
3648
9
140
3
3824
48
12
111061
152
–2
3976
49
–5
10
115037
162
4138
50
119175
ya+nh+uh = ya+nh + u∇ya+nh +
+
u(u + 1)(u + 2) 3
u(u + 1) 2
∇ ya+nh +
∇ ya+nh
3!
2
u(u + 1)(u + 2)(u + 3) 4
u(u + 1)(u + 2)(u + 3)(u + 4) 5
∇ ya+nh +
∇ ya+nh
4!
5!
∴ 105y48.25 = 119175 + (– 1.75) × 4138 +
+
(− 1.75)(− 0.75)(0.25)
(− 1.75)(− .75)(.25)(1.25)
× 10 +
(– 2)
3!
4!
+
⇒
(− 1.75) × (− 0.75)
× 162
2
(− 1.75)(− .75)(.25)(1.25)(2.25)
(– 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:
Premium:
(in dollars)
45
50
55
60
65
114.84
96.16
83.32
74.48
68.48
276
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Sol. The difference table is:
Age
(x)
Premium
(in dollars)
(y)
45
114.84
∇2 y
∇y
∇3 y
∇4 y
– 18.68
50
96.16
5.84
– 12.84
55
– 1.84
83.32
4
.68
– 8.84
60
74.48
65
68.48
– 1.16
2.84
–6
Here
a + nh = 65,
h = 5, a + nh + uh = 63
65 + 5u = 63 ⇒ u = – .4
∴
By Newton’s backward difference formula,
u(u + 1) 2
u(u + 1)(u + 2) 3
∇ y(65) +
∇ y(65)
2!
3!
y(63) = y(65) + u∇y(65) +
+
u(u + 1)(u + 2)(u + 3) 4
∇ y(65)
4!
= 68.48 + (– .4)(– 6)
(− .4)(.6)
(− .4)(.6)(1.6)
(− .4)(.6)(16
. )(2.6)
(2.84) +
(− 1.16) +
(.68)
2
6
24
= 70.585152
+
ASSIGNMENT 4.5
1.
2.
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
Find the value of an annuity at 5
Rate:
Annuity value:
4
172.2903
3
% , given the following table:
8
4
1
2
162.8889
5
153.7245
5
1
2
145.3375
6
137.6483
INTERPOLATION
3.
The values of annuities are given for the following ages. Find the value of annuity at the
age of 27
1
.
2
Age:
Annuity:
4.
25
26
27
28
29
16.195
15.919
15.630
15.326
15.006
The table below gives the value of tan x for 0.10 ≤ x ≤ 0.30.
x:
y = tan x:
0.10
0.15
0.20
0.25
0.30
0.1003
0.1511
0.2027
0.2553
0.3093
Find: (i) tan 0.50
5.
277
(ii) tan 0.26
(iii) tan 0.40.
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)
x:
f(x):
7.
(ii) f(0.29)
0.20
0.22
0.24
0.26
0.28
0.30
1.6596
1.6698
1.6804
1.6912
1.7024
1.7139
The probability integral
P=
x:
1.00
P:
0.682689
2
π
z
x
0
e
−
1 2
t
2
dt has following values:
1.05
1.10
1.15
1.20
1.25
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 limits 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
9.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
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 formula:
x:
y = ex:
1.7
1.8
1.9
2.0
2.1
5.474
6.050
6.686
7.389
8.166
12. Using Newton’s backward difference formula, find the value of
table of values of e–x:
x:
e–x:
4.17
e–1.9
1
1.25
1.50
1.75
2.00
0.3679
0.2865
0.2231
0.1738
0.1353
2.2
2.3
9.025
9.974
from the following
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 − 1) 2
u (u − 1)(u − 2) 3
Δ f (a) +
Δ f (a)
2!
3!
+
Given
a = 0,
u (u − 1)(u − 2)(u − 3) 4
Δ f (a) + ......
4!
(30)
h = 1, we get
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
u (u − 1)(u − 2) 3
Δ f (0) +
Δ f (0)
2!
3!
+
u (u − 1)(u − 2)(u − 3) 4
Δ f (0) + ......
4!
(31)
INTERPOLATION
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)
279
Δ5f(– 1) = Δ4f(0) – Δ4f(– 1) ⇒ Δ4f(0) = Δ5f(– 1) + Δ4f(– 1) and so on.
and
∴ From (31),
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
{Δ f (− 1) + Δ3 f (− 1)}
2!
+
+
= f(0) + uΔf(0) +
+
RS
T
u (u − 1)(u − 2) 3
{ Δ f (− 1) + Δ4 f (− 1)}
3!
u (u − 1)(u − 2)(u − 3) 4
{ Δ f (− 1) + Δ5 f (− 1)} + ......
4!
RS
T
UV
W
u (u − 1) 2
u (u − 1)
u−2 3
Δ f (− 1) +
Δ f (− 1)
1+
2!
2
3
UV
W
u(u − 1)(u − 2)
u−3 4
u(u − 1)(u − 2)(u − 3) 5
Δ f (− 1) +
1+
Δ f (− 1) + ......
6
4
4!
= f(0) + uΔf(0) +
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
But,
(u + 1) u (u − 1)(u − 2) 4
u (u − 1)(u − 2)(u − 3) 5
Δ f (− 1) +
Δ f (− 1) + ......
4!
4!
(32)
Δ5f(– 2) = Δ4f(– 1) – Δ4f(– 2)
∴
Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2)
+
then (32) becomes,
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
+
(u + 1) u (u − 1)(u − 2)
{Δ4 f (− 2) + Δ5 f (− 2)}
4!
+
u (u − 1)(u − 2)(u − 3) 5
Δ f (− 1) + ......
4!
280
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
+
(u + 1) u (u − 1)(u − 2) 4
Δ f (− 2) + ......
4!
This is called Gauss’ forward difference formula.
NOTE
This formula is applicable when u lies between 0 and
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;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]
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
1
.
2
INTERPOLATION
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
If
ax[i] < x
X
Y
281
282
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
X
i=i+1
y
i=i–1
p = (x – ax[i])/n
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
y = ay[i] + y 1 + y2 + y3
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];
float ax[10];
//...array limit 9
//...array limit 9
float x;
float nr,dr;
float y=0;
float h;
float p;
float diff[20][20];
//...Initial value 0
//...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("\n\n Enter the value in the form of x – ");
//...Input loop for Array X
for (i=0;i<n;i++)
{
printf("\n\n Enter the value of x%d – ",i+i);
scanf("%f”,&ax[i]);
}
printf("\n\n Enter the value in the form of y – ");
//...Input Loop for Array Y
for(i=0;i<n;i++)
{
printf("\n\n 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;i<n–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n–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("\n\n\n Press Enter to Exit");
getch();
}
//...Termination of Main Execution Thread
INTERPOLATION
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:
Sol. Here
f(25) = 0.2707
f(35) = 0.3386
f(30) = 0.3027
f(40) = 0.3794.
a + hu = 32
Take origin at 30
and h = 5
∴ a = 30
then u = 0.4
285
286
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
The forward difference table is:
u
x
f(x)
–1
25
.2707
0
30
.3027
Δ2f(x)
Δf(x)
Δ3f(x)
.032
.0039
.0359
1
35
.0010
.3386
.0049
.0408
2
40
.3794
Applying Gauss’ forward difference formula, we have
f(u) = f(0) + uΔf(0) +
∴
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
f(.4) = .3027 + (.4)(.0359) +
(.4)(.4 − 1)
(1.4)(.4)(.4 − 1)
(.0039) +
(.0010)
2!
3!
= 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)
–2
1
1
–1
2
–1
Δf(x)
Δ2f(x)
Δ3f(x)
Δ4f(x)
–2
4
2
0
3
1
–8
–4
–2
1
4
–1
4
2
2
5
1
16
8
INTERPOLATION
287
Gauss’ forward difference formula is
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
f(u) = f(0) + uΔf(0) +
2!
3!
(u + 1) u (u − 1)(u − 2) 4
+
Δ f (− 2)
4!
( x − 3)( x − 4)
( x − 2)( x − 3)( x − 4)
= 1 + (x – 3)(– 2) +
(− 4) +
(8)
2
6
( x − 2)( x − 3)( x − 4)( x − 5)
+
(16)
24
4
= 1 – 2x + 6 – 2x2 + 14x – 24 + (x3 – 9x2 + 26x – 24)
3
2
+ (x4 – 14x3 + 71x2 – 154x + 120)
3
∴
F(x) =
100 2
2 4
x – 56x + 31
x – 8x3 +
3
3
Example 3. The values of e–x at x = 1.72 to x = 1.76 are given in the following
table:
x:
e–x:
1.72
1.73
1.74
1.75
1.76
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 1.7425 − 1.7400
=
= 0.25
h
0.01
The difference table is as follows:
u
x
105f(x)
–2
1.72
17907
–1
1.73
17728
105Δf(x)
10 5Δ2f(x)
105Δ3f(x)
105Δ4f(x)
– 179
3
– 176
0
1.74
17552
–2
1
3
– 175
1
1.75
17377
2
– 173
2
1.76
17204
1
288
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
(u + 1) u (u − 1)(u − 2) 4
Δ f (− 2)
4!
+
∴ 105f(.25) = 17552 + (.25)(– 175) +
= 17508.16846
∴
(.25)(− .75)
(1.25)(.25)(− .75)
(1) +
(1)
2
6
(1.25)(.25)(− .75)(− 175
. )
+
(3)
24
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)
–2
0
14
–1
4
24
Δf(x)
Δ2f(x)
Δ3f(u)
Δ4f(x)
10
–2
8
0
8
32
–3
–5
10
3
1
12
35
7
2
5
2
16
Here
∴
40
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 − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
+
= 32 + (.25)(3) +
(u + 1) u (u − 1)(u − 2) 4
Δ f (− 2)
4!
(.25)(− .75)
(1.25)(.25)(− .75)
(− 5) +
(7)
2
6
+
(1.25)(.25)(− .75)(− 175
. )
(10)
24
289
INTERPOLATION
= 33.11621094
u9 = 33.11621094.
Hence
ASSIGNMENT 4.6
1.
Apply Gauss’s forward formula to find the value of f(x) at x = 3.75 from the table:
x:
f(x):
2.
2.5
3.0
3.5
4.0
4.5
5.0
24.145
22.043
20.225
18.644
17.262
16.047.
Given that
x:
log x:
25
30
35
40
45
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:
f(x):
4.
5.
4.19
30
35
40
45
50
3678.2
2995.1
2400.1
1876.2
1416.3
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
ex :
2.7183
2.8577
3.0042
3.1582
3.3201
3.4903
1.30
3.6693
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
GAUSS’S BACKWARD DIFFERENCE FORMULA
Newton’s Gregory forward difference formula is
u (u − 1) 2
u (u − 1)(u − 2) 3
Δ f (a) +
Δ f (a) + ......
2!
3!
(33)
a = 0, h = 1, we get
f(a + hu) = f(a) + uΔf(a) +
Put
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
u (u − 1)(u − 2) 3
Δ f (0) +
Δ f (0)
2!
3!
+
u (u − 1)(u − 2)(u − 3) 4
Δ f (0) + ......
4!
(34)
290
COMPUTER-BASED NUMERICAL
Now,
AND
STATISTICAL TECHNIQUES
Δ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),
u (u − 1) 2
[Δ f(–1) + Δ3f(– 1)]
2!
f(u) = f(0) + u [Δf(– 1) + Δ2f(– 1)] +
+
+
u (u − 1)(u − 2) 3
[Δ f (− 1) + Δ4 f (− 1)]
3!
u (u − 1)(u − 2)(u − 3)
[Δ4f(–1) + Δ5f(– 1)] + ......
4!
FG
H
= f(0) + uΔf(– 1) + u 1 +
IJ
K
u−1
Δ2f(– 1)
2
+
+
UV
W
RS
T
IJ
K
u (u − 1)
u−2 3
1+
Δ f (− 1)
3
2
u (u − 1)(u − 2)
u−3 4
u (u − 1)(u − 2)(u − 3) 5
Δ f (− 1) +
Δ f (− 1) + ......
1+
6
4
4!
= f(0) + uΔf(– 1) +
(u + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
+
Again,
and
FG
H
(35)
(u + 1) u (u − 1)(u − 2) 4
Δ f (− 1) + ......
4!
(36)
Δ3f(– 1) = Δ3f(– 2) + Δ4f(– 2)
Δ4f(– 1) = Δ4f(– 2) + Δ5f(– 2) and
so on
∴ (36) gives
f(u) = f(0) + uΔf(– 1) +
(u + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
{Δ f(– 2)
2!
3!
+ Δ4f(– 2)}
+
(u + 1) u (u − 1)(u − 2) 4
{Δ f(– 2) + Δ5f(– 2)} + ......
4!
INTERPOLATION
f(u) = f(0) + uΔf(– 1) +
291
(u + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 2)
2!
3!
+
(u + 2) (u + 1) u (u − 1) 4
Δ f (− 2) + ......
4!
(37)
This is known as Gauss’ backward difference formula.
1
This formula is useful when u lies between − and 0.
2
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;i<n-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;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][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
Is
ax[i] < x
Yes
X
No
Y
INTERPOLATION
293
X
i=i+1
Y
i=i–1
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
y = ay[i] + y 1 + y2 + y3 + y4
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];
float x;
//... array limit 9
//... User Querry
float y=0;
float h;
//... Initial value 0
//... Calc. section
float p;
float diff[20][20];
//... Calc. section
//... 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("\n\n Enter the value in the form of x – ");
//... Input loop for X
for (i=0;i<n;i++)
{
printf("\n\n Enter the value of x%d–",i+1);
scanf("%f”,&ax[i]);
}
//...Input Sequel for array Y
printf("\n\n Enter the value in the form of y–");
//...Input Loop for Y
for(i=0;i<n;i++)
{
printf("\n\n Enter the value of y%d–",i+1);
INTERPOLATION
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;i<n–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n–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("\n\n\n Press Enter to Exit");
295
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
12516 − 12520
4
=
=–
= – 0.4
h
10
10
INTERPOLATION
297
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
(u + 1) u 2
Δ f(– 1)
2!
+
(u + 1) u(u − 1) 3
Δ f(– 2) + ......
3!
(38)
The difference table is:
u
x
106 f(x)
–2
12500
111803399
–1
12510
111848111
106Δ f(x)
106 Δ2 f(x)
106 Δ3 f(x)
44712
– 17
44695
0
12520
–1
111892806
– 18
44677
1
12530
111937483
From (38),
106f(– .4) = 111892806 + (– .4)(44695)
+
(.6)(− .4)
(.6)(− .4)(− 1.4)
(− 18) +
(− 1)
2!
3!
= 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:
cos x:
50°
51°
52°
53°
54°
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 + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 2)
2!
3!
+
(u + 2)(u + 1) u (u − 1) 4
Δ f (− 2)
4!
(39)
298
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The difference table is as below:
x
104 f(x)
–2
50°
6428
–1
51°
6293
u
104 Δ f(x)
104 Δ2 f(x)
104 Δ3 f(x)
104 Δ4 f(x)
– 135
–1
– 136
0
52°
6157
1
53°
6018
2
54°
5878
–2
–3
4
– 139
2
–1
– 140
From (39),
104f(– .3) = 6157 + (– .3)(– 136) +
(.7)(− .3)
(.7)(− .3)(− 1.3)
(− 3) +
(− 2)
2!
3!
+
(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:
Population:
(in thousands)
1901
1911
1921
1931
1941
1951
12
15
20
27
39
52
Sol. Taking the origin at 1941 and h = 10,
x = a + uh ∴ u =
x−a
1936 − 1941
=
= – 0.5
h
10
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
+
(u + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 2)
2!
3!
(u + 2)(u + 1) u (u − 1) 4
(u + 2)(u + 1) u (u − 1)(u − 2) 5
Δ f (− 2) +
Δ f (− 3)
4!
5!
(40)
INTERPOLATION
299
The difference table is:
u
f(u)
–4
12
–3
15
Δ2f(u)
Δf(u)
Δ3f(u)
Δ4f(u)
Δ5f(u)
3
2
5
–2
0
20
2
3
7
–1
27
0
39
1
52
3
– 10
5
–7
12
–4
1
13
From (40),
(.5)(− .5)
(.5)(− .5)(− 1.5)
(1) +
(− 4)
2
6
= 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(– .5) = 39 + (– .5)(12) +
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)
–2
4
270
–1
5
648
0
6
1330
1
7
2448
Δ f(x)
378
682
1118
Δ2 f(x)
304
436
Δ3 f(x)
132
300
COMPUTER-BASED NUMERICAL
Here,
AND
STATISTICAL TECHNIQUES
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 + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 2)
2!
3!
+
= 1330 + (– .2)(682)
(.8)(− .2)
(.8)(− .2)(− 1.2)
(436) +
(132)
2
6
+
= 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:
Population:
(in thousands)
1931
1941
1951
1961
1971
15
20
27
39
52
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:
tan x:
4.
50
51
52
53
54
1.1918
1.2349
1.2799
1.3270
1.3764
Using Gauss’s backward formula, find the value of tan 51° 42′.
Interpolate by means of Gauss’s backward formula, the population of a town for the
year 1974 given that:
Year:
1939
Population:
12
(in thousands)
5.
1949
1959
1969
1979
1989
15
20
27
39
52
Apply Gauss’s backward formula to find sin 45° from the following table:
θ°:
sin θ:
20
30
40
50
60
70
80
0.34202
0.502
0.64279
0.76604
0.86603
0.93969
0.98481
INTERPOLATION
6.
301
Using Gauss’s backward formula, estimate the number of persons earning wages between $ 60 and $ 70 from the following data:
Wages ($):
Below 40
40—60
60—80
80—100
100—120
250
120
100
70
50
Number of people:
(in thousands)
4.20 STIRLING’S FORMULA
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 1)
2!
3!
+
(u + 1) u (u − 1)(u − 2) 4
Δ f (− 2) + ......
4!
(41)
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
(u + 1) u 2
(u + 1) u (u − 1) 3
Δ f (− 1) +
Δ f (− 2)
2!
3!
+
(u + 2)(u + 1) u (u − 1) 4
Δ f (− 2) + ......
4!
(42)
Take the mean of (41) and (42),
f(u) = f(0) + u
RS Δf (0) + Δf (− 1) UV + u Δ f (− 1)
2
T
W 2!
2
2
RS Δ f (− 1) + Δ f (− 2) UV
2
T
W
+
(u + 1) u (u − 1)
3!
+
u 2 (u2 − 1) 4
Δ f (− 2) + ......
4!
3
This is called Stirling’s formula. It is useful when | u | <
gives the best estimate when −
1
1
<u< .
4
4
3
(43)
1
1
1
or − < u < . It
2
2
2
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
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
If
ax[i] < x
Yes
X
No
Y
303
304
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
X
i=i+1
Y
i=i–1
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
Print ‘‘output’’, y
STOP
*/ ********************************************************************
4.20.3 Program to Implement Stirling Method of Interpolation
******************************************************************** /*
//... HEADER FILES DECLARATION
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<process.h>
//...MAIN EXECUTION THREAD
void main()
INTERPOLATION
305
{
//...Variable declaration Field
//...Integer Type
int n;
int i,j;
//...Floating Type
float ax[10];
float ax[10];
//... array-limit 9
//... array-limit 9
float h;
float p;
float diff[20][20];
float x,y;
float y1,y2,y3,y4;
clrscr();
//...array 2d-limit 19,19
//... 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;i<n;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;i<n;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;i<n-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n-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("\n\n 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
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
307
308
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The difference table is:
u
θ
10 4f(θ)
–3
0
0
104Δf(θ)
104Δ2f(θ) 10 4Δ3f(θ) 104Δ4f(θ)
104Δ5f(θ) 10 4Δ6f(θ)
875
–2
5
875
13
888
–1
10
15
1763
28
2
916
0
15
2679
1
20
3640
2
25
4663
3
30
5774
17
–2
45
0
961
11
17
9
62
9
1023
26
88
1111
Using Stirling’s formula,
FG 961 + 916 IJ + (.2) (45) + (1.2)(.2)(− .8) FG 17 + 17 IJ
H 2 K 2!
H 2 K
3!
(.2) o(.2) − 1t
(2.2)(1.2)(.2)(− .8)(− 1.8) R 9 + (− 2) U
+
(0) +
ST 2 VW
4!
5!
2
104f(.2) = 2679 + (.2)
2
2
+
(.2) 2 {(.2) 2 − 1}{(.2) 2 − 4}
(11)
6!
= 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) =
x = 0.5 from x = 0 to 2.
1
2π
z
x
0
e
−
x2
2
dx, at intervals of
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 1.22 − 1.00
=
= 0.44
h
0.5
Applying Stirling’s formula
f(u) = f(0) + u .
+
1
u2 2
Δf (0) + Δf (− 1) +
Δ f (− 1)
2
2!
u(u 2 − 1) 1 3
u 2 (u2 − 1) 4
. [ Δ f (− 1) + Δ3 f (− 2)] +
. Δ f (− 2) + ......
3!
2
4!
f(0.44) = f(0) + (0.44)
∴
+
(0.44) 2 2
1
[ Δ f (0) + Δ f (− 1)] +
Δ f (− 1)
2
2
(0.44)[(0.44) 2 − 1] 1 3
(0.44) 2 [(0.44) 2 − 1] 4
. [Δ f (− 1) + Δ3 f (− 2)] +
Δ f (− 2)
6
2
24
2
~
− f(0) + (0.22)[Δf(0) + Δf(– 1)] + 0.0968 Δ f(– 1)
– 0.029568 [Δ3f(– 1) + Δ3f(– 2)] – 0.06505 Δ4f(– 2) + ......
The difference table is as follows:
u
x
–2
0
103f(x)
103 Δf(x)
103Δ2f(x)
103Δ3f(x)
103Δ4f(x)
0
191
–1
.5
191
– 41
150
0
1
341
…
1
1.5
433
92
2
2
477
44
– 17
– 58
27
10
– 48
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
–2
20
49225
Δy
Δ 2y
Δ3 y
Δ4 y
– 909
–1
25
48316
– 171
– 1080
0
30
47236
– 59
– 230
– 1310
1
35
45926
– 21
– 80
– 310
– 1620
2
40
44306
By Stirling’s formula,
FG − 1080 − 1310 IJ + (− .4) (– 230)
H
K 2!
2
(.6)(− .4)(− 1.4) F − 59 − 80 I (− .4) {(− .4)
+
GH 2 JK +
3!
4!
f(– .4) = 47236 + (– .4)
2
2
2
− 1}
(− 21)
= 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
The difference table is as follows:
u
x
y
–1
20
512
0
30
439
1
40
346
2
50
243
Δ2 y
Δy
Δ3 y
– 73
– 20
– 93
10
– 10
– 103
By Stirling’s formula,
f(.5) = 439 + (.5)
Hence,
FG − 93 − 73 IJ + (.5)
H 2 K 2!
2
(− 20) +
= 394.6875
y35 = 394.6875.
ASSIGNMENT 4.8
1.
2.
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
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.
FG IJ
H K
(1.5)(.5)(− .5) 10
3!
2
311
312
3.
COMPUTER-BASED NUMERICAL
sin x:
5.
0.15
0.17
0.19
0.21
0.23
0.14944
0.16918
0.18886
0.20846
0.22798
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.
Employ Stirling’s formula to evaluate y12.2 from the following table (yx = 1 + log10 sin x):
x°:
105 yx:
6.
STATISTICAL TECHNIQUES
Evaluate sin (0.197) from the data given below:
x:
4.
AND
10
11
23967
28060
12
13
14
31788
35209
38368.
ex
The following table gives the values of
for certain equidistant values of x. Find the
value of ex when x = 0.644 using Stirling’s method.
x:
y = ex:
0.61
0.62
0.63
0.64
0.65
1.840431
1.858928
1.877610
1.896481
1.915541
0.66
0.67
1.934792 1.954237
4.21 BESSEL’S INTERPOLATION FORMULA
Gauss’s forward formula is
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
Δ f (− 1)
2!
+
(u + 1) u (u − 1) 3
Δ f (− 1)
3!
+
(u + 1) u (u − 1) (u − 2) 4
Δ f (− 2) .....
4!
(44)
Gauss’s backward formula is
f(u) = f(0) + uΔf(– 1) +
(u + 1) u 2
Δ f (− 1)
2!
+
(u + 1) u (u − 1) 3
Δ f (− 2)
3!
+
(u + 2) (u + 1) u (u − 1) 4
Δ f (− 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 − 1) 2
Δ f (0)
2!
+
u (u − 1) (u − 2) 3
Δ f (− 1)
3!
+
(u + 1) u (u − 1) (u − 2) 4
Δ f (− 1) + .....
4!
(46)
Taking mean of (44) and (46), we get
f(u) =
RS f (0) + f (1) UV + RS u + (u − 1) UV Δf (0)
T 2 W T 2 W
u (u − 1) R Δ f (− 1) + Δ
+
ST
2!
2
2
+
2
f (0)
UV
W
u (u − 1)
Δ3 f (− 1)
(u + 1 + u − 2)
3!
2
RS
T
UV
W
(u + 1) u (u − 1) (u − 2) Δ4 f (− 2) + Δ4 f (− 1)
+
+ .....
4!
2
Finally, we get
f(u) =
RS f (0) + f (1) UV + FG u − 1IJ Δf (0)
T 2 W H 2K
u (u − 1) R Δ f (− 1) + Δ
+
ST|
2!
2
F 1I
(u − 1) G u − J u
H 2K
2
+
+
3!
2
f (0)
UV
W|
Δ3 f (− 1)
RS
T
(u + 1) u (u − 1) (u − 2) Δ4 f (− 2) + Δ4 f (− 1)
4!
2
UV + ......
W
(47)
314
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
This is called Bessel’s formula.
1
1
3
. It gives a better estimate when < u < .
2
4
4
It is used mainly to compute entry against any argument between 0 and 1.
It is very useful when u =
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;i<n-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;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])
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
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
Is
ax[i] < x
Yes
X
No
Y
315
316
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
X
i=i+1
Y
i=i–1
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
y = ay[i] + y1 + y2 + y3 + y4
Print ‘‘output’’x, y
STOP
/* ***********************************************************************
4.21.3 Program to Implement Bessel’s Method of Interpolation
*********************************************************************** */
//...HEADER FILES DECLARATION
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<process.h>
//... MAIN EXECUTION THREAD
void main()
{
//...Variable declaration Field
INTERPOLATION
317
//...Integer Type
int n;
int i,j;
//...Floating Type
float ax[10];
float ay[10];
//...array – limit 9
//...array – limit 9
float h;
float p;
float diff[20][20];
19, 19
float x,y;
//... array 2d – limit
float y1,y2,y3,y4,
//...Invoke Clear Screen Function
clrscr();
//... Input Section
//... Clear Screen
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;i<n;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 y\n");
//...Input Section Loop for Y
for(i=0;i<n;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;i<n–1;i++)
{
diff[i][1]=ay[i+1]–ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n–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("\n\n 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
–1
20
24
0
24
32
Δ2 y
Δy
Δ 3y
8
–5
3
1
28
35
2
32
40
7
2
5
Using Bessel’s formula,
f(u) =
RS f (0) + f (1) UV + FG u − 1IJ Δf (0)
T 2 W H 2K
u (u − 1) R Δ f (− 1) + Δ
+
S|T
2
2
F 1I
(u − 1) G u − J u
H 2K
2
+
f(.25) =
⇒
2
f (0)
UV
|W
Δ3 f (− 1)
3!
FG 32 + 35 IJ + (.25 – .5) (3) + (.25) (.25 − 1) RS − 5 + 2 UV
H 2 K
2
T 2 W
+
(.25 − 1) (.25 − .5) (.25)
(7)
3!
= 32.9453125
Hence
y25 = 32.9453125.
Example 2. Apply Bessel’s formula to find the value of f(27.4) from the table:
x:
f(x):
25
26
27
28
29
30
4.000
3.846
3.704
3.571
3.448
3.333.
Sol. Taking origin at 27 and h = 1
x = a + uh
∴
u = 0.4
⇒
27.4 = 27 + u × 1
INTERPOLATION
321
The difference table is as follows:
u
103f(u)
–2
4000
–1
3847
103 Δf(u)
103 Δ2f(u)
103 Δ3f(u)
103 Δ4f(u)
103 Δ5f(u)
– 154
12
– 142
0
–3
3704
9
4
– 133
1
3571
2
3448
3
3333
1
–7
10
–3
– 123
–2
8
– 115
Bessel’s formula is
RS f (0) + f (1) UV + FG u − 1IJ Δf (0) + u (u − 1) RS Δ f (0) + Δ f (− 1) UV
2!
2
T 2 W H 2K
T
W
F 1I
(u − 1) G u − J u
H 2 K Δ f (− 1)
+
2
f(u) =
2
3
3!
+
RS
T
(u + 1) u (u − 1) (u − 2) Δ4 f (− 1) + Δ4 f (− 2)
4!
2
FG
H
(u − 2) (u − 1) u −
+
∴
5!
IJ
K
1
u (u + 1)
2
UV
W
Δ5 f (− 2)
RS 3704 + 3571UV + (.4 – .5) (– 133) + (.4) (.4 − 1) FG 10 + 9 IJ
H 2 K
2!
T 2 W
(.4 + 1) (.4) (.4 − 1) (.4 − 2) F − 3 + 4 I
(.4 − 1) (.4 − .5) (.4)
(1) +
GH 2 JK
+
4!
3!
103f(0.4) =
+
= 3649.678336
⇒
Hence
f(.4) = 3.649678336
f(27.4) = 3.649678336.
(.4 − 2) (.4 − 1) (.4 − .5) (.4) (.4 + 1)
(− 7)
5!
322
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Example 3. Probability distribution function values of a normal distribution
are given as follows:
x:
p(x):
0.2
0.6
1.0
1.4
1.8
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
u=
∴
⇒ 1.2 = 1.0 + u × 0.4
1.2 − 1.0 1
=
0.4
2
The difference table is:
u
105f(u)
–2
39104
–1
33332
0
24197
1
14973
2
7895
105 Δf(u)
105 Δ2f(u)
105 Δ3f(u)
105 Δ4f(u)
– 5782
– 3343
– 9125
3244
– 99
– 999
– 9224
2245
2146
– 7078
Bessel’s formula is
f(u) =
RS f (0) + f (1) UV + FG u − 1IJ Δ f (0)
T 2 W H 2K
+
RS
T
u (u − 1) Δ2 f (0) + Δ2 f (− 1)
2!
2
FG
H
(u − 1) u −
+
105
3!
IJ
K
1
(u)
2
UV
W
Δ3 f (− 1)
FG 1IJ FG 1 − 1IJ
H 2 K H 2 K FG 2146 − 99 IJ + 0
+
24197
14973
F
I
f (.5) = G
+0+
J
H
K
H 2 K
2
2!
= 19457.0625
INTERPOLATION
323
f(.5) = 0.194570625
∴
Hence
p(1.2) = 0.194570625.
Example 4. Given that
x:
f(x):
4
6
8
10
12
14
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
–2
35460
–1
50753
0
64632
1
77217
2
88633
3
98986
104 Δ2yu
15293
– 1414
13879
– 1294
1258
– 1169
11416
– 1063
10353
Bessel’s formula is
yu =
104 Δ2yu
FG
H
IJ
K
104 Δ3yu
104 Δ4yu
120
105 Δ5yu
5
125
– 19
106
– 24
1
1
u(u − 1) 1 2
( y1 + y0 ) + u −
Δy0 +
(Δ y0 + Δ2 y−1 )
2
2
2!
2
FG u − 1IJ u(u − 1)
H 2K
Δ y
+
3
3!
+
(u + 1) u(u − 1)(u − 2) 1 4
× (Δ y−3 + Δ4 y−2 )
4!
2
FG
H
(u − 2) (u − 1) u −
+
−1
5!
IJ
K
1
u (u + 1)
2
Δ5 y−2
324
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
FG IJ
H K
1
1
−
1
1
2
2
. (− 1169 − 1294)
104y1/2 = (77217 + 64632) + 0 +
2
2
2
FG IJ FG − 3 IJ
H K H 2 K . 1 (− 19 + 5) + 0
3 1
1
. . −
2 2
2
+0+
24
⇒
104y1/2 = 71078.27344
∴
y1/2 = 7.107827344
Hence,
f(9) = 7.107827344.
2
Example 5. Given y0, y1, y2, y3, y4, y5 (fifth differences constant), prove that
y
where
1
2
2
=
1
25(c − b) + 3(a − c)
c+
2
256
a = y0 + y5, b = y1 + y4, c = y2 + y3 .
Sol. Put
u=
1
in Bessel’s formula, we get
2
1
1 2
3
( y0 + y1 ) −
(Δ y0 + Δ2 y−1 ) +
(Δ4 y−1 + Δ4 y−2 )
2
16
256
Shifting the origin to 2, we have
y1/2 =
y
1
2
2
=
1
1 2
3
( y2 + y3 ) −
(Δ y2 + Δ2 y1 ) +
(Δ4 y1 + Δ4 y0 )
2
16
256
=
c
1
−
(y – 2y2 + y1 + y4 – 2y3 + y2)
2 16 3
+
y
1
2
2
y
1
2
2
3
(y – 3y4 + 2y3 + 2y2 – 3y1 + y0)
256 5
=
c
1
3
−
( y4 − y3 − y2 + y1 ) +
(a − 3b + 2c)
2 16
256
=
c
1
3
−
(b − c) +
(a − 3b + 2 c)
2 16
256
=
c
1
+
[25(c − b) + 3(a − c)] .
2 256
325
INTERPOLATION
Example 6. If third differences are constant, prove that
y
1
x+
2
Sol. Putting u =
=
1
1
(yx + yx + 1 ) −
( Δ2 yx − 1 + Δ2 yx ) .
2
16
1
in Bessel’s formula, we get
2
1
1 2
( y0 + y1 ) −
(Δ y0 + Δ2 y−1 )
2
16
Shifting the origin to x,
y1/2 =
y
1
x+
2
=
1
1 2
( yx + yx + 1 ) −
(Δ yx + Δ2 yx − 1 ) .
2
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)
–1
10
2854
Δ2 f(x)
Δ f(x)
Δ3 f(x)
308
0
14
3162
1
18
3544
74
382
–8
66
448
2
22
3992
Bessel’s formula is
RS f (0) + f (1) UV + FG u − 1IJ Δ f (0) + u (u − 1) RS Δ
2!
T 2 W H 2K
T
2
f(u) =
f (− 1) + Δ2 f (0)
2
FG
H
(u − 1) u −
+
3!
IJ
K
1
u
2
UV
W
Δ3 f (−1)
326
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
FG 3162 + 3544 IJ + (.25 – .5) (382) + (.25) (.25 − 1) FG 74 + 66 IJ
H 2 K
H 2 K
2
f (.25) =
∴
AND
+
(.25 − 1) (.25 − .5) (.25)
(– 8)
6
= 3250.875
Hence
y15 = 3250.875.
ASSIGNMENT 4.9
1.
2.
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.
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.
4.
5.
6.
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.
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
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
Find y(0.543) from the following values of x and y:
x:
y(x):
0.1
0.2
0.3
0.4
0.5
0.6
0.7
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
p:
1.1
20
2
30
4.4
40
7.9
INTERPOLATION
327
4.22 LAPLACE-EVERETT’S FORMULA
Gauss’ forward formula is
f(u) = f(0) + uΔf(0) +
u (u − 1) 2
Δ f (− 1) + (u + 1) u (u − 1) Δ3 f (− 1)
2!
3!
+
(u + 1) u (u − 1) (u − 2) 4
Δ f (− 2)
4!
+
(u + 2) (u + 1) u (u − 1) (u − 2) 5
Δ f (− 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)
Δ2f(– 1)
2!
+
(u + 1) u (u − 1)
{Δ2f(0) – Δ2f(– 1)}
3!
+
(u + 1) u (u − 1) (u − 2) 4
Δ f (− 2)
4!
+
(u + 2) (u + 1) u (u − 1) (u − 2)
{Δ4f(– 1) – Δ4f(– 2)} + ......
5!
= (1 – u) f(0) + uf(1) +
(u + 1) u (u − 1) 2
Δ f (0)
3!
–
u (u − 1) (u − 2) 2
Δ f ( − 1)
3!
+
(u + 2) (u + 1) u (u − 1) (u − 2) 4
Δ f (− 1)
5!
–
(u + 1) u(u − 1) (u − 2) (u − 3) 4
Δ f (− 2) + .....
5!
328
COMPUTER-BASED NUMERICAL
RS
T
AND
= u f (1) +
STATISTICAL TECHNIQUES
(u + 1) u (u − 1) 2
Δ f (0)
3!
+
UV
W
(u + 2) (u + 1) u (u − 1) (u − 2) 4
Δ f (− 1) + .....
5!
RS
T
+ (1 − u ) f (0) +
+
(1 − u + 1) (1 − u) (1 − u − 1) 2
Δ f (− 1)
3!
UV
W
(1 − u + 2) (1 − u + 1) (1 − u) (1 − u − 1) (1 − u − 2) 4
Δ f (− 2) + .....
5!
RS
T
f(u) = uf (1) +
+
(u + 1) u (u − 1) 2
Δ f (0)
3!
RS
T
+ wf (0) +
+
UV
W
(u + 2) (u + 1) u (u − 1) (u − 2) 4
Δ f (− 1) + .....
5!
(w + 1) w (w − 1) 2
Δ f (− 1)
3!
UV
W
(w + 2) (w + 1) w (w − 1) (w − 2) 4
Δ f (− 2) + .....
5!
(49)
where
w=1–u
This is called Laplace–Everett’s formula.
1
. It is used to compute any entry
2
against any argument between 0 and 1. It is useful when intervening values in
successive intervals are required.
It gives the best estimate when u >
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
Step 04. Input the array ay
Step 05. h=ax[1]-ax[0]
Step 06. for i=0; i<n-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; 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. 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
329
330
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
4.22.2 Flow-chart
Start
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
Is
ax[i] < x
No
i=i–1
A
Yes
i=i+1
INTERPOLATION
331
A
p = (x – ax[i])/h
q=1–p
y1 = q * (ay[i])
y2 = q * (q * q – 1) * diff[i – 1]
y3 = q * (q * q – 1) * (q * (q – 4)) * diff[i – 2][4])/120
py1 = p * ay[i + 1]
py2 = p * (p * p – 1) * diff[i][2]/6
py3 = p * (p * p – 1) * (p * p – 4) * (diff[i – 1][4])/120
y = y1 + y2 + y3 + py1 + py2 + py3
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];
float ay[10];
float x;
float nr,dr;
float y=0;
//... array limit 9
//... array limit 9
//... Initial value 0
float h;
float p,q;
float diff[20][20];
float y1,y2,y3,y4;
//... array limit 19,19
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("\n\n Enter the value in the form of x - ");
//... Input Loop for Array X
for (i=0;i<n;i++)
{
Printf("\n\n Enter the value of x%d - ",i+1);
scanf("%f",&ax[i]);
}
//... Input Sequel for Array X
printf ("\n\n Enter the value in the form of y - ");
INTERPOLATION
//... Input Loop Array Y
for (i=0;i<n;i++)
{
printf ("\n\n 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;i<n-1;i++)
{
diff[i][1]=ay[i+1]-ay[i];
}
for(j=2;j<=4;j++)
{
for(i=0;i<n-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];
333
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("\n\n\n 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:
Δ2f(u)
Δ3f(u)
308
3162 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→ 3618
3926
7088 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯→ – 3030
896
– 6648
u
f(u)
–1
Δf(u)
2854
0
1
2
7984
By Everett’s formula,
∴
RS
T
f(.25) = (.25) (7088) +
UV
W
(1.25) (.25) (− .75)
(− 3030) + .....
3!
RS
T
+ (.75) (3162) +
= 4064
UV
W
(175
. ) (.75) (− .25)
(3618) + .....
3!
Hence f(30) = 4064.
Example 2. Find the value of f(27.4) from the following table:
x:
f(x):
25
26
27
28
29
30
4.000
3.846
3.704
3.571
3.448
3.333.
Sol. Here u =
27.4 − 27.0
= 0.4 ∵ origin is at 27.0, h = 1
1
Also, w = 1 – u = 0.6
336
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The difference table is:
u
103 f(u)
–2
4000
103 Δf(u)
103Δ2f(u)
103Δ3f(u)
103Δ4f(u)
– 154
–1
3846
12
– 142
–3
3704 ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ 9 ⎯⎯⎯⎯⎯⎯⎯⎯⎯→
0
– 133
4
1
3571 ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ 10 ⎯⎯⎯⎯⎯⎯⎯⎯⎯→ – 3
1
– 123
2
–2
3448
8
– 115
3
3333
By Laplace Everett’s formula,
RS
T
f(.4) = (.4) (3571) +
+
(1.4) (.4) (− .6)
(10)
3!
UV
W
(2.4) (1.4) (.4) (− .6) (− 1.6)
(− 3) + .....
5!
RS
T
+ (.6) (3704) +
(16
. ) (.6) (− .4)
(9)
3!
+
(2.6) (16
. ) (.6) (− .4) (− 1.4)
(4)
5!
= 3649.678336.
Hence f(27.4) = 3649.678336.
ASSIGNMENT 4.10
1.
Given the table
x:
log x:
21
22
23
24
25
26
1.3222
1.3424
1.3617
1.3802
1.3979
1.4150
Apply Laplace-Everett’s formula to find the value of log 2375.
UV
W
INTERPOLATION
2.
3.
337
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.
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:
e–x:
7.
8.
1.72
1.73
1.74
1.75
1.76
1.77
0.1790
0.1773
0.1755
0.1738
0.1720
0.1703
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.
Apply Everett’s formula to find the value of f(26) and f(27) from the table:
x:
f(x):
9.
15
20
25
30
35
40
12.849
16.351
19.524
22.396
24.999
27.356.
Find the compound interest on the sum of Rs. 10,000 at 7% for the period 16 and 17
years if:
x:
(1.07)n:
5
10
15
1.40255
1.96715
2.75903
10. Apply Everett’s formula to find the values of
x:
e–x:
e–x
20
25
30
3.86968
5.42743
7.61236.
for x = 3.2, 3.4, 3.6, 3.8, if
1
2
3
4
5
6
0.36788
0.13534
0.04979
0.01832
0.00674
0.00248.
11. Given that
x:
x1/3:
40
45
50
55
60
65
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) 2
u(u2 − 1) 2
Δ y0 + uy0 +
Δ y–1
3!
3!
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
y=
ex:
0.62
0.63
0.64
0.65
0.66
0.67
1.840431 1.858928 1.877610 1.896481 1.915541 1.934792 1.954237.
14. The values of the elliptic integral,
k(m) =
z
π/2
0
(1 − m sin 2 θ)
−
1
2
dθ
for certain equidistant values of m are given below. Use Everett’s or Bessel’s formula to
determine k(0.25).
m:
k(m):
0.20
0.22
0.24
0.26
0.28
0.30
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:
y=
ex:
1.7
1.8
1.9
2.0
2.1
2.2
5.4739
6.0496
6.6859
7.3891
8.1662
9.0250.
310
320
330
340
350
360
2.49136
2.50515
2.51851
2.53148
2.54407
2.55630.
16. Given the table:
x:
log x:
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 ( x0 )
( x0 − x1) ( x0 − x2 ) ...... ( x0 − xn )
(51)
f(x1) = A1 (x1 – x0) (x1 – x2) ...... (x1 – xn)
A1 =
∴
f ( x1)
( x1 − x0 ) ( x1 − x2 ) ...... ( x1 − xn )
Similarly, An =
(52)
f ( xn )
( xn − x0 ) ( xn − x1) ...... ( xn − xn − 1)
(53)
Substituting the values of A0, A1, ......, An in equation (50), we get
f(x) =
( x − x1) ( x − x2 ) ...... ( x − xn )
f(x0)
( x0 − x1) ( x0 − x2 ) ...... ( x0 − xn )
+
( x − x0 ) ( x − x2 ) ...... ( x − xn )
f(x1)
( x1 − x0 ) ( x1 − x2 ) ...... ( x1 − xn )
+ ...... +
( x − x0 ) ( x − x1) ...... ( x − xn − 1)
( xn − x0 ) ( xn − x1) ...... ( xn − xn − 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)
f ( x0 )
1
.
=
( x − x0 ) ( x − x1) ...... ( x − xn )
( x0 − x1) ( x0 − x2 ) ...... ( x0 − xn ) ( x − x0 )
+
f ( x1)
1
.
+ ......
( x1 − x0 ) ( x1 − x2 ) ...... ( x1 − xn ) ( x − x1)
+
f ( xn )
1
.
.
( xn − x0 ) ( xn − x1) ...... ( xn − xn − 1) ( x − xn )
(55)
4.24.1 Another form of Lagrange’s Formula
§ Prove that the Lagrange’s formula can be put in the form
n
Pn(x) =
φ ( x) f ( xr )
∑ ( x − x ) φ′ ( x )
r=0
r
r
n
φ(x) =
∏ (x − x )
φ′(xr) =
LM d {φ (x)}OP
N dx Q
where
and
r
r=0
x = xr
We have the Lagrange’s formula,
n
Pn(x) =
∑
r=0
( x − x0 ) ( x − x1 ) ... ( x − xr − 1 ) ( x − x r + 1 ) ... ( x − xn )
( xr − x0 ) ( xr − x1 ) ... ( xr − x r − 1 ) ( xr − xr + 1 ) ... ( x r − xn )
R
R φ ( x) U |
∑ ST x − x VW S|T ( x
n
=
r
r=0
r
f ( xr )
f ( xr )
− x0 ) ( xr − x1 ) ... ( xr − xr − 1 ) ( xr − xr + 1 ) ... ( xr − x n )
U|
V|
W
(56)
Now,
n
φ(x) =
∏ (x − x )
r
r=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),
n
Pn(x) =
∑
r=0
φ ( x) f ( x r )
( x − x r ) φ′ ( x r )
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; i<n; i++
Step 06. nr=1
Step 07. dr=1
Step 08. for j=0; j<n; 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
|using (57)
342
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
4.24.3 Flow-chart
START
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
No
Is
J!=i
B
Yes
nr∗ = x – ax[j]
dr∗ = ax[i] – ax[j]
B
End loop[j]
Print x, y as solution
STOP
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;
//... Floating Type
//... Loop Variables
float ax[100];
float ay[100];
//... array limit 99
//... array limit 99
float x=0;
float y=0;
//... User Querry
//... Initial value 0
float nr;
float dr;
//... Calc. section
//... 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("\n\n Enter the value in the form of
//... Input Loop for X
x - ");
for (i=0;i<n;i++)
{
printf ("\n\n Enter the value of
scanf("%f",&ax[i]);
x%d - ", i+1);
}
//... Input Sequel for array Y
printf("\n\n Enter the value in the form of y - ");
//... Input Loop for Y
for (i=0;i<n;i++)
{
printf("\n\n 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;i<n;i++)
{
nr=1;
dr=1;
for(j=0;j<n;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("\n\n When x=%5.2f,y=%5.2f ",x,y);
//... Invoke User Watch Halt Function
printf("\n\n\n 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,
f(x0) = 12,
x1 = 6,
x2 = 9,
f(x1) = 13,
f(x2) = 14,
x3 = 11
f(x3) = 16
346
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Lagrange’s formula is
f(x) =
f(x) =
( x − x1 ) ( x − x2 ) ( x − x3 )
f ( x0 )
( x0 − x1 ) ( x0 − x2 ) ( x0 − x 3 )
+
( x − x0 ) ( x − x 2 ) ( x − x3 )
f ( x1 )
( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x3 )
f ( x2 )
( x2 − x0 ) ( x 2 − x1 ) ( x 2 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x2 )
f ( x3 )
( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )
( x − 6) ( x − 9) ( x − 11)
(12)
(5 − 6) (5 − 9) (5 − 11)
=–
+
( x − 5) ( x − 9) ( x − 11)
(13)
(6 − 5) (6 − 9) (6 − 11)
+
( x − 5) ( x − 6) ( x − 11)
(14)
(9 − 5) (9 − 6) (9 − 11)
+
( x − 5) ( x − 6) ( x − 9)
(16)
(11 − 5) (11 − 6) (11 − 9)
1
13
( x − 6) ( x − 9) ( x − 11) +
( x − 5) ( x − 9) ( x − 11)
2
15
–
7
( x − 5) ( x − 6) ( x − 11)
12
+
4
( x − 5) ( x − 6) ( x − 9)
15
Putting x = 10, we get
f(10) = –
1
13
(10 − 6) (10 − 9) (10 − 11) +
(10 − 5) (10 − 9) (10 − 11)
2
15
–
7
4
(10 − 5) (10 − 6) (10 − 11) +
(10 − 5) (10 − 6) (10 − 9)
12
15
= 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,
f(x0) = 1,
f(x1) = 8,
x2 = 3,
x3 = 4
f(x2) = 27,
f(x3) = 64
Lagrange’s formula is
( x − x1 ) ( x − x2 ) ( x − x3 )
f ( x0 )
( x0 − x1 ) ( x0 − x2 ) ( x0 − x 3 )
f(x) =
=
( x − x0 ) ( x − x 2 ) ( x − x3 )
f ( x1 )
( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x3 )
f ( x2 )
( x2 − x0 ) ( x 2 − x1 ) ( x 2 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x2 )
f ( x3 )
( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )
( x − 2) ( x − 3) ( x − 4)
( x − 1) ( x − 3) ( x − 4)
(1) +
(8)
(1 − 2) (1 − 3) (1 − 4)
(2 − 1) (2 − 3) (2 − 4)
=−
Given
+
+
( x − 1) ( x − 2) ( x − 4)
(27)
(3 − 1) (3 − 2) (3 − 4)
+
( x − 1) ( x − 2) ( x − 3)
(64)
(4 − 1) (4 − 2) (4 − 3)
1
( x − 2) ( x − 3) ( x − 4) + 4 ( x − 1) ( x − 3) ( x − 4)
6
–
27
( x − 1) ( x − 2) ( x − 4)
2
+
32
( x − 1) ( x − 2) ( x − 3)
3
x = 2.5, we get
f(2.5) = −
1
(2.5 – 2) (2.5 – 3) (2.5 – 4)
6
+ 4(2.5 – 1) (2.5 – 3) (2.5 – 4)
348
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
–
27
(2.5 – 1) (2.5 – 2) (2.5 – 4)
2
+
32
(2.5 – 1) (2.5 – 2) (2.5 – 3)
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,
f(x0) = 2,
x1 = 1,
x2 = 2,
f(x1) = 3, f(x2) = 12,
x3 = 5
f(x3) = 147
Lagrange’s formula is
f(x) =
=
( x − x1 ) ( x − x2 ) ( x − x3 )
f ( x0 )
( x0 − x1 ) ( x0 − x2 ) ( x0 − x 3 )
+
( x − x0 ) ( x − x 2 ) ( x − x3 )
f ( x1 )
( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x3 )
f ( x2 )
( x2 − x0 ) ( x 2 − x1 ) ( x 2 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x2 )
f ( x3 )
( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )
( x − 1) ( x − 2) ( x − 5)
( x − 0) ( x − 2) ( x − 5)
(2) +
(3)
(0 − 1) (0 − 2) (0 − 5)
(1 − 0) (1 − 2) (1 − 5)
=−
+
( x − 0) ( x − 1) ( x − 5)
(12)
(2 − 0) (2 − 1) (2 − 5)
+
( x − 0) ( x − 1) ( x − 2)
(147)
(5 − 0) (5 − 1) (5 − 2)
1
3
( x − 1) ( x − 2) + x ( x − 2) ( x − 5) – 2x(x – 1) (x – 5)
5
4
+
49
x ( x − 1) ( x − 2)
20
INTERPOLATION
=−
349
1 3
3
( x − 8 x 2 + 17 x − 10) + ( x 3 − 7 x 2 + 10 x) – 2(x3 – 6x2 + 5x)
5
4
49 3
(x – 3x2 + 2x)
20
+
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 − x0 ) ( x − x2 )
( x − x1 ) ( x − x 2 )
f ( x1 )
f ( x0 ) +
(
x
( x0 − x1 ) ( x 0 − x2 )
1 − x0 ) ( x1 − x2 )
+
=
( x − x0 ) ( x − x1 )
f ( x2 )
( x 2 − x0 ) ( x 2 − x 1 )
( x − 3) ( x − 4)
( x − 1) ( x − 4)
( x − 1) ( x − 3)
(1) +
(27) +
(64)
(1 − 3) (1 − 4)
(3 − 1) (3 − 4)
(4 − 1) (4 − 3)
1 2
27 2
64 2
( x − 7 x + 12) −
( x − 5 x + 4) +
( x − 4 x + 3)
6
2
3
= 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,
f(x0) = 3,
x1 = 8,
x2 = 9,
x3 = 10
f(x1) = 1, f(x2) = 1, f(x3) = 9
350
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Lagrange’s interpolation formula is
f(x) =
=
( x − x1 ) ( x − x2 ) ( x − x3 )
f ( x0 )
( x0 − x1 ) ( x0 − x2 ) ( x0 − x 3 )
+
( x − x0 ) ( x − x 2 ) ( x − x3 )
f ( x1 )
( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x3 )
f ( x2 )
( x2 − x0 ) ( x2 − x1 ) ( x2 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x2 )
f ( x3 )
( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )
( x − 8) ( x − 9) ( x − 10)
( x − 7) ( x − 9) ( x − 10)
(3) +
(1)
(7 − 8) (7 − 9) (7 − 10)
(8 − 7) (8 − 9) (8 − 10)
=−
+
( x − 7) ( x − 8) ( x − 10)
(1)
(9 − 7) (9 − 8) (9 − 10)
+
( x − 7) ( x − 8) ( x − 9)
(9)
(10 − 7) (10 − 8) (10 − 9)
1
1
( x − 8) ( x − 9) ( x − 10) + ( x − 7) ( x − 9) ( x − 10)
2
2
–
1
( x − 7) ( x − 8) ( x − 10)
2
3
( x − 7) ( x − 8) ( x − 9)
2
Given x = 9.5 in eqn. (58), we get
+
f(9.5) = −
(58)
1
1
(9.5 − 8) (9.5 − 9) (9.5 − 10) + (9.5 − 7) (9.5 − 9) (9.5 − 10)
2
2
1
3
(9.5 − 7) (9.5 − 8) (9.5 − 10) + (9.5 − 7) (9.5 − 8) (9.5 − 9)
2
2
= 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,
f(x0) = – 8,
f(x1) = 3,
f(x2) = 1,
x3 = 3
f(x3) = 12
Lagrange’s interpolation formula is
f(x) =
=
=
( x − x1 ) ( x − x2 ) ( x − x3 )
f ( x0 )
( x0 − x1 ) ( x0 − x2 ) ( x0 − x 3 )
+
( x − x0 ) ( x − x 2 ) ( x − x3 )
f ( x1 )
( x1 − x0 ) ( x1 − x2 ) ( x1 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x3 )
f ( x2 )
( x2 − x0 ) ( x 2 − x1 ) ( x 2 − x3 )
+
( x − x0 ) ( x − x1 ) ( x − x2 )
f ( x3 )
( x3 − x0 ) ( x3 − x1 ) ( x3 − x2 )
( x − 0) ( x − 2) ( x − 3)
( x + 1) ( x − 2) ( x − 3)
(− 8) +
(3)
(− 1 − 0) (− 1 − 2) (− 1 − 3)
(0 + 1) (0 − 2) (0 − 3)
+
( x + 1) ( x − 0) ( x − 3)
(1)
(2 + 1) (2 − 0) (2 − 3)
+
( x + 1) ( x − 0) ( x − 2)
(12)
(3 + 1) (3 − 0) (3 − 2)
2
1
x ( x − 2) ( x − 3) + ( x + 1) ( x − 2) ( x − 3)
3
2
–
=
2 3
1
( x − 5 x 2 + 6 x) + ( x 3 − 4 x 2 + x + 6)
3
2
–
⇒
Hence,
Given
1
( x + 1) x ( x − 3) + ( x + 1) x ( x − 2)
6
1 3
( x − 2 x 2 − 3 x) + ( x 3 − x 2 − 2 x)
6
f(x) = 2x3 – 6x2 + 3x + 3
ux = 2x3 – 6x2 + 3x + 3
x = 1 in (59), we get
u1 = 2(1)3 – 6(1)2 + 3(1) + 3 = 2.
(59)
352
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Example 7. By means of Lagrange’s formula, prove that
(i) y0 =
LM
N
OP
Q
1
1 1
1
(y3 − y1 ) − (y− 1 − y− 3 )
(y1 + y− 1 ) −
2
8 2
2
(ii) y3 = 0.05 (y0 + y6 ) − 0.3 (y1 + y5 ) + 0.75 (y 2 + y4 )
(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 + 1) ( x − 1) ( x − 3)
( x + 3) ( x − 1) ( x − 3)
y− 3 +
y−1
(− 3 + 1) (− 3 − 1) (− 3 − 3)
(− 1 + 3) (− 1 − 1) (− 1 − 3)
+
( x + 3) ( x + 1) ( x − 3)
y
(1 + 3) (1 + 1) (1 − 3) 1
+
( x + 3) ( x + 1) ( x − 1)
y3
(3 + 3) (3 + 1) (3 − 1)
( x + 1) ( x − 1) ( x − 3)
( x + 3) ( x − 1) ( x − 3)
y−3 +
y−1
(− 48)
16
+
( x + 3) ( x + 1) ( x − 3)
y1
(− 16)
+
( x + 3) ( x + 1) ( x − 1)
y3
48
Given x = 0 in (60), we get
y0 = −
=
1
9
9
1
y− 3 +
y−1 +
y1 −
y3
16
16
16
16
LM
N
1
1 1
1
( y1 + y− 1 ) −
( y3 − y1 ) − ( y− 1 − y− 3 )
2
8 2
2
OP
Q
(ii) For the arguments 0, 1, 2, 4, 5, 6, the Lagrange’s formula is
yx =
( x − 1) ( x − 2) ( x − 4) ( x − 5) ( x − 6)
y0
(0 − 1) (0 − 2) (0 − 4) (0 − 5) (0 − 6)
+
( x − 0) ( x − 2) ( x − 4) ( x − 5) ( x − 6)
y1
(1 − 0) (1 − 2) (1 − 4) (1 − 5) (1 − 6)
+
( x − 0) ( x − 1) ( x − 4) ( x − 5) ( x − 6)
y2
(2 − 0) (2 − 1) (2 − 4) (2 − 5) (2 − 6)
(60)
INTERPOLATION
+
( x − 0) ( x − 1) ( x − 2) ( x − 5) ( x − 6)
y4
(4 − 0) (4 − 1) (4 − 2) (4 − 5) (4 − 6)
+
( x − 0) ( x − 1) ( x − 2) ( x − 4) ( x − 6)
y5
(5 − 0) (5 − 1) (5 − 2) (5 − 4) (5 − 6)
+
( x − 0) ( x − 1) ( x − 2) ( x − 4) ( x − 5)
y6
(6 − 0) (6 − 1) (6 − 2) (6 − 4) (6 − 5)
353
(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 + 3) ( x − 3) ( x − 5)
( x + 5) ( x − 3) ( x − 5)
y−5 +
y−3
(− 5 + 3) (− 5 − 3) (− 5 − 5)
(− 3 + 5) (− 3 − 3) (− 3 − 5)
+
( x + 5) ( x + 3) ( x − 5)
( x + 5) ( x + 3) ( x − 3)
y3 +
y5
(3 + 5) (3 + 3) (3 − 5)
(5 + 5) (5 + 3) (5 − 3)
(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 2 − 1) 2
x (x 2 − 1) 2
Δ u–1 +
Δ u0 where x + y = 1.
3!
3!
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 − x) {(1 − x) 2 − 1}
(u1 – 2u0 + u–1)
3!
x ( x 2 − 1)
(u2 − 2u1 + u0 )
3!
|where y = 1 – x
x ( x − 1) ( x − 2)
( x − 2) ( x − 1) ( x + 1)
( x + 1) x ( x − 2)
u− 1 +
u0 −
u1
6
2
2
+
( x + 1) x ( x − 1)
u2
6
(63)
354
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Applying Lagrange’s formula for the arguments – 1, 0 , 1 and 2.
ux =
x ( x − 1) ( x − 2)
( x + 1) ( x − 1) ( x − 2)
u−1 +
u0
(− 1) (− 2) (− 3)
(1) (− 1) (− 2)
+
( x + 1) x ( x − 2)
( x + 1) x ( x − 1)
u1 +
u2
(2) (1) (− 1)
(3) (2) (1)
x ( x − 1) ( x − 2)
( x − 2) ( x − 1) ( x + 1)
( x + 1) x ( x − 2)
u−1 +
u0 −
u1
6
2
2
=−
( x + 1) x ( x − 1)
u2
6
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
Sol. Let
Given
Pn (x)
1
x
f(x0 )
f(x1 )
...
1
1
...
x0
x1
...
f(xn )
1
xn
x2
...
...
xn
2
x0
x12
...
...
...
...
...
...
...
x0 n
x1n
...
xn 2
...
...
xn n
= 0 where Pn(x) = f(x).
Pn(x) = a0 + a1x + a2x2 + ... + anxn
x = x0, x1, ..., xn, and Pn(xi) = f(xi), i = 0, 1, 2, ..., n
f(x0) = a0 + a1x0 + a2x02 + ... + anx0n
f(x1) = a0 + a1x1 + a2x12 + ... + anx1n
...
...
...
...
...
...
2
f(xn) = a0 + a1xn + a2xn + ... + anxnn ... (n + 2)
Eliminating a0, a1, a2, ......, an from these equations, we get
− Pn ( x) 1 x
− f ( x0 ) 1 x0
− f ( x1 ) 1 x1
...
... ...
− f ( x n ) 1 xn
x2
x0 2
x12
...
xn 2
...
...
...
...
...
... x n
... x0 n
... x1n = 0
... ...
... xn n
(64)
INTERPOLATION
or
x
x2
...
...
xn
1
1
...
x0
x1
...
2
x0
x12
...
...
...
...
...
...
...
x0 n
x1n
...
1
xn
xn 2
...
...
xnn
Pn ( x)
1
f ( x0 )
f ( x1)
...
f ( xn )
355
=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.
7.
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.
Apply Lagrange’s formula to find f(15), if
x:
f(x):
8.
10
12
14
16
18
20
2420
1942
1497
1109
790
540.
If y0, y1, ..., y9 are consecutive terms of a series, prove that
y5 =
1
[56(y4 + y6) – 28(y3 + y7) + 8(y2 + y8) – (y1 + y9)]
70
356
9.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Using the following table, find f(x) as a polynomial in x:
x:
f(x):
–1
0
3
6
3
–6
39
822
7
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:
y=
x:
Evaluate
150
152
154
156
12.247
12.329
12.410
12.490
155 using Lagrange’s interpolation formula.
12. Applying Lagrange’s formula, find a cubic polynomial which approximates the following data:
x:
–2
–1
2
3
y(x):
– 12
–8
3
5.
13. Given the table of values
x:
3
x:
50
52
54
56
3.684
3.732
3.779
3.825
Use Lagrange’s formula to find x when 3 x = 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) (b2 − c2 ) + f (b) (c2 − a2 ) + f (c) (a2 − b2 )
.
f (a) (b − c) + f (b) (c − a) + f (c) ( a − b)
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:
log10 x:
300
304
305
307
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,
f(x0) = 4,
x1 = 2.5,
x2 = 4
and
f(x1) = 7.5, f(x2) = 13
x3 = 5.5
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 +1 ( x) (n+1)
y
(ξ) , a < ξ < b
(n + 1) !
where Lagrange’s formula is for the class of functions having continuous
derivatives of order upto (n + 1) on [a, b].
Quantity EL = max. | Rn(x) | may be taken as an estimate of error.
[a, b]
Let us assume
| y(n+1) (ξ) | ≤ Mn+1, a ≤ ξ ≤ b
then,
EL ≤
M n +1
max. | Πn+1(x) |.
(n + 1) ! [ a, b]
EXAMPLES
Example 1. Show that the truncation error of quadratic interpolation in an
equidistant table is bounded by
f is the tabulated function.
h3
9 3
max | f ″′(ξ) | where h is the step size and
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
max | (x – xi–1)(x – xi)(x – xi+1) |
6
where xi–1 ≤ x ≤ xi+1 and
Substitute t =
M3 = max | f ″′(x) |
a≤ x≤b
x − xi
then,
h
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
1
3t2 – 1 = 0 ⇒ t = ±
3
.
For both these values of t, we obtain
max | (x – xi–1)(x – xi)(x – xi+1) | = h3 max | t(t2 – 1) | =
− 1≤ t ≤ 1
2 h3
3 3
Hence, the truncation error of the quadratic interpolation is bounded by
| E2(f; x) | ≤
or,
| E2(f; x) | ≤
h3
9 3
h3
9 3
M3
max | f ″′(ξ) |.
Example 2. Determine the step size that can be used in the tabulation of
LM π OP at equally spaced nodal points so that the
N 4Q
f(x) = sin x in the interval 0,
truncation error of the quadratic interpolation is less than 5 × 10–8.
Sol. From Example 1, we have
| E2(f; x) | ≤
For
and
f(x) = sin x, we get
h3
9 3
M3
f ″′(x) = – cos x
M3 = max |cos x | = 1
0 ≤ x ≤ π/4
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
from the following data:
x:
0
π/4
π/2
y = sin x:
0
0.70711
1.0
FG π IJ
H 6K
Also estimate the error in the solution.
FG π − 0IJ FG π − π IJ
FG π − 0IJ FG π − π IJ
F π I H 6 K H 6 2 K (0.70711) + H 6 K H 6 4 K (1)
sin G J =
H 6 K FG π − 0IJ FG π − π IJ
FG π − 0IJ FG π − π IJ
H 4 KH 4 2K
H 2 KH 2 4K
Sol.
=
Now,
8
1 4.65688
(0.70711) – =
= 0.51743
9
9
9
y(x) = sin x, y′(x) = cos x,
Hence,
y″(x) = – sin x, y′″(x) = – cos x
| y′″ (ξ) | < 1
when x = π/6.
| Rn(x) | ≤
FG π − 0IJ FG π − π IJ FG π − π IJ
H 6 K H 6 4K H 6 2K
3!
= 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 x2 + x + 1
( x − 1)( x − 2)( x − 3)
Consider φ(x) = 3x2 + x + 1 and tabulate its values for x = 1, 2, 3, we get
x:
3x2
+ x + 1:
1
2
3
5
15
31
360
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Using Lagrange’s interpolation formula, we get
f(x) =
( x − 2)( x − 3)
( x − 1)( x − 2)
( x − 1)( x − 3)
(5) +
(15) +
(31)
(1 − 2)(1 − 3)
2
−1
=
5
31
(x – 2)(x – 3) – 15 (x – 1)(x – 3) +
(x – 1)(x – 2)
2
2
=
5
31
15
–
+
.
2( x − 1)
2
(
x
− 3)
x−2
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
z
θ:
21°
23°
25°
F(θ):
0.3706
0.4068
0.4433
θ
0
dθ
1 + cos 2 θ
are given below:
Find θ for which F(θ) = 0.3887.
Sol. By inverse interpolation formula
θ=
=
(F − F1 )(F − F2 )
(F − F0 )(F − F2 )
(F − F0 )(F − F1 )
θ0 +
θ1 +
θ
(F0 − F1 )(F0 − F2 )
(F1 − F0 )(F1 − F2 )
(F2 − F0 )(F2 − F1 ) 2
(0.3887 − 0.4068) (0.3887 − 0.4433)
(.3706) + ... + ...
(0.3706 − 0.4068)(0.3706 − 0.4433)
= 7.884 + 17.20 – 3.087 = 22°.
Example 2. From the given table:
x:
y(x):
20
25
30
35
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 − y1 ) ( y − y2 ) ( y − y3 )
( y − y0 ) ( y − y2 ) ( y − y3 )
x0 +
x1
( y0 − y1 ) ( y0 − y2 ) ( y0 − y3 )
( y1 − y0 ) ( y1 − y2 ) ( y1 − y3 )
+
=
( y − y0 ) ( y − y1 ) ( y − y3 )
( y − y0 ) ( y − y1 ) ( y − y2 )
x2 +
x3
( y2 − y0 ) ( y2 − y1 ) ( y2 − y3 )
( y3 − y0 ) ( y3 − y1 ) ( y3 − y2 )
(.39 − .423) (.39 − .5) (.39 − .65)
(20)
(.342 − .423) (.342 − .5) (.342 − .65)
+
(.39 − .342) (.39 − .5) (.39 − .65)
(25)
(.423 − .342) )(.423 − .5) (.423 − .65)
+
(.39 − .342) (.39 − .423) (.39 − .65)
(30)
(.5 − .342) (.5 − .423) (.5 − .65)
+
(.39 − .342) (.39 − .423) (.39 − .5)
(35)
(.65 − .342) (.65 − .423) (.65 − .5)
= 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
Δ| y0 = [x0, x1] =
x1
Similarly,
[x1, x2] =
y1 − y0
x1 − x0
y2 − y1
and so on.
x2 − x1
The second divided difference for x0, x1, x2 is defined as
| 2 y = [x , x , x ] =
Δ
0
0
1
2
x1 , x2
[ x1 , x2 ] − [ x0 , x1 ]
x2 − x0
362
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Third divided difference for x0, x1, x2, x3 is defined as
[x0, x1, x2, x3] =
[ x1 , x2 , x3 ] − [ x0 , x1 , x2 ]
and so on.
x3 − x0
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] =
Also, [x0, x1, x2] =
y1
y0
+
= [x1, x0]
x1 − x0
x0 − x1
y2
y1
y0
+
+
( x0 − x1 )( x0 − x2 ) ( x1 − x0 )( x1 − x2 ) ( x2 − x0 )( x2 − x1 )
= [x2, x0, x1] or [x1, x2, x0]
2. The nth divided differences of a polynomial of n th degree are
constant.
Let the arguments be equally spaced so that
x1 – x0 = x2 – x1 = ..... = xn – xn–1 = h
then,
[x0, x1] =
[x0, x1, x2] =
=
In general,
[x0, x1, x2, ......, xn] =
Δy0
y1 − y0
=
h
x1 − x0
[ x1 , x2 ] − [ x0 , x1 ]
( x2 − x0 )
1
2h
FG Δy
Hh
1
−
Δy0
h
IJ = 1 . 1
K 2! h
2
(Δ2 y0)
1
1 n
.
Δ y0
n ! hn
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
OR
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] =
so that,
y − y0
x − x0
y = y0 + (x – x0) [x, x0]
Again,
[x, x0, x1] =
which gives,
(65)
[ x, x0 ] − [ x0 , x1 ]
x − x1
[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]
Also
which gives
[x, x0, x1, x2] =
(67)
[ x, x0 , x1 ] − [ x0 , x1 , x2 ]
x − x2
[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
Δ| f(x0) =
x1
f ( x0 + h) − f ( x0 )
Δ f ( x0 )
f ( x1 ) − f ( x0 )
=
=
h
h
x1 − x0
(69)
1
Δ| 2 f(x0) = x − x [f(x1, x2) – f(x0, x1)]
x1 x2
2
0
=
=
=
=
1
x2 − x0
LM
N
LM f (x ) − f (x ) − f (x ) − f ( x ) OP
x −x
N x −x
Q
2
2
1
1
1
1
0
0
1 f ( x0 + 2h) − f ( x0 + h) f ( x0 + h) − f ( x0 )
−
h
h
2h
1
2h2
OP
Q
[ f ( x 0 + 2h ) − 2f ( x 0 + h ) + f ( x 0 )]
Δ2 f ( x0 )
2 ! . h2
(70)
INTERPOLATION
Δ| 3
x1 , x2 , x3
f(x0) =
=
=
365
1
[f(x1, x2, x3) – f(x0, x1, x2)]
x2 − x0
1
3h
LM Δ f (x ) − Δ f (x ) OP = Δ
2h
MN 2h
PQ
2
2
2
1
2
2
0
f ( x1 ) − Δ2 f ( x0 )
6h3
[From (69)]
Δ3 f ( x0 )
3 ! h3
...
...
...
n
Δ f (x )
0
Δ| n f(x0) = n ! h n .
x1,....., xn
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)
1
22
Δ| f(x)
Δ| 2f(x)
30 − 22
=8
2−1
2
26 − 8
=6
4−1
30
82 − 30
= 26
4−2
4
82
106 − 82
=8
7−4
7
106
12
216
216 − 106
= 22
5
8 − 26
= – 3.6
7−2
22 − 8
= 1.75
12 − 4
Δ| 3f(x)
− 3.6 − 6
= – 1.6
7−1
1.75 + 3.6
= 0.535
12 − 2
Δ| 4f(x)
0.535 + 1.6
= 0.194
12 − 1
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)
2
4
Δ| f(x)
56 − 4
= 26
4−2
4
56
711 − 56
= 131
9−4
9
10
711
980
980 − 711
= 269
10 − 9
Δ| 2f(x)
131 − 26
= 15
9−2
269 − 131
= 23
10 − 4
Hence, the third divided difference is 1.
Δ| 3f(x)
23 − 15
=1
10 − 2
INTERPOLATION
367
(ii)
x
f(x) =
a
1
a2
1
Δ| f(x)
x2
FG 1 − 1 IJ
Hb a K
2
2
b− a
b
1
c
2
−
d
FG a + b IJ
Ha b K
–
1
Δ| 3f(x)
2 2
1
b2
−
c
=
Δ| 2f(x)
ab + bc + ca
a2b2 c2
FG b + c IJ
Hb c K
–
2 2
bc + cd + db
FG abc + acd + abd
H
a b c d
2 2 2 2
+ bcd
IJ
K
b2 c 2 d 2
FG c + d IJ
Hc d K
2 2
d2
From the above divided difference table, we observe that the first divided
differences,
f(a, b) = –
f(a, b, c) =
and
2 2
ab + bc + ca
a2 b2 c 2
f(a, b, c, d) = –
(iii)
FG a + b IJ
Ha b K
FG abc + acd + abd + bcd IJ
H
K
a b c d
R.H.S. = g(x1)
=
=
2 2 2
2
h( x2 ) − h( x1 ) g( x2 ) − g ( x1 )
h( x2 )
+
x2 − x1
x2 − x1
1
[{g(x1) h(x2) – g(x1)h(x1)}
x2 − x1
+ {g(x2) h(x2) – g(x1) h(x2)}]
g ( x2 ) h ( x2 ) − g ( x1 ) h ( x1 )
x2 − x1
= Δ| g(x1) h(x1) = Δ| f(x1) = f(x1, x2) = L.H.S.
x2
Hence the result.
x2
368
COMPUTER-BASED NUMERICAL
AND
Example 3. (i) Prove that
Δ|
3
bcd
STATISTICAL TECHNIQUES
FG 1 IJ = − 1
H a K abcd
(ii) Show that the nth divided differences
[x0, x1, ....., xn] for ux =
LM
N
Sol. (i)
x
f(x)
a
1
a
b
OP
Q
1
( − 1) n
is
.
x
x0 x1 ..... xn
Δ| 2f(x)
Δ| f(x)
1 1
−
b a =– 1
ba
b−a
1
b
(– 1)2
Δ| 3f(x)
1
abc
1 1
−
c b =– 1
bc
c−b
c
d
1
c
1
abcd
(– 1)3
(– 1)2
1 1
−
d c =– 1
dc
d−c
1
bdc
1
d
From the table, we observe that
|3
Δ
bcd
FG 1IJ = – 1 .
H aK abcd
(71)
(ii) From (71), we see that
|3
Δ
bcd
FG 1 IJ = – 1 = (– 1)
H a K abcd
3
f(a, b, c, d)
∴ In general,
|n
x0 , x1 , ....., xn
Δ
F 1 I = (– 1)
GH x JK
0
n
f (x0, x1, x2, ....., xn) =
LM
Nx
0
OP
Q
(− 1) n
.
x1 x2 ..... xn
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)
–4
Δ| 2f(x)
Δ| 3f(x)
Δ| 4f(x)
1245
– 404
–1
33
94
– 28
0
5
2
9
– 14
10
3
2
13
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(4)
| f(4) + (x – 4)(x – 5) Δ
f(x) = f(4) + (x – 4) Δ
5, 7
5
| 3 f(4)
+ (x – 4)(x – 5)(x – 7) Δ
5, 7, 10
+ (x – 4)(x – 5)(x – 7)(x – 10)
|4
Δ
f(4)
5, 7, 10 , 11
+ (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)
4
48
Δ|
Δ| 2 f(x)
f(x)
100 − 48
= 52
5−4
5
97 − 52
= 15
7−4
100
294 − 100
= 97
7−5
7
1210 − 900
= 310
11 − 10
11
13
27 − 21
=1
11 − 5
0
33 − 27
=1
13 − 7
409 − 310
= 33
13 − 10
1210
2028 − 1210
= 409
13 − 11
2028
0
310 − 202
= 27
11 − 7
900
Δ| 4f(x)
21 − 15
= 1
10 − 4
202 − 97
= 21
10 − 5
294
900 − 294
= 202
10 − 7
10
Δ| 3f(x)
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)
0
4
2
26
3
58
4
112
7
466
9
922
Δ| f(x)
Δ| 2f(x)
11
Δ| 3f(x)
7
32
1
11
54
1
16
118
1
22
228
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
5
3
35
4
190
5
1
7
5
38
60
194
5
1
12
5
98
1
17
2x2 + x3 + 3x + 4 = (x – 5)3 + 17(x – 5)2 + 98 (x – 5) + 194.
Example 7. Given
log 10 654 = 2.8156, log 10 658 = 2.8182, log 10 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) Δ| f(654)
658
+ (x – 655) (x – 658)
Δ| 2
658, 659
f(654)
+ (x – 654) (x – 658) (x – 659)
Δ| 3
658, 659, 661
f(654)
(73)
372
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The divided difference table is as follows:
x
105 f(x)
654
281560
| f(x)
105 Δ
| 3 f(x)
105 Δ
| 2f(x)
105 Δ
260
= 65
4
658
70 − 65
= 1
5
281820
70
= 70
1
659
− 1.66 − 1
= – 0.38
7
65 − 70
= – 1.66
3
281890
130
= 65
2
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:
Δ| f(x)
x
f(x)
3
– 13
5
23
11
899
27
17315
34
35606
Δ| 2f(x)
18
Δ| 3f(x)
16
146
1
40
1026
0
1
69
2613
Δ| 4f(x)
By Newton’s divided difference formula,
f(x) = – 13 + (x – 3) 18 + (x – 3)(x – 5)16 + (x – 3)(x – 5)(x – 11)1
∴
Put
f ′(x) = 3x2 – 6x – 7
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
= log 70 – log 2 = 1.8451 – 0.3010 = 1.5441.
2
The divided difference table is as follows:
x
30
104 log10 x
104
Δ|
log10 x
| 2 log x
104 Δ
10
14771
279
= 139.5
2
32
15050
–
391
= 130.3
3
35
36
| 3log x
104 Δ
10
15441
15562
–
–
121
= 121
1
9.2
= − 1.84
5
9.3
= − 2.32
7
0.48
= − 0.08
6
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
– 1.941
1.9
– 1.000
2.0
0.061
2.1
1.248
2.2
Δ|
ux
0.1062699
0.0942507
0.0842459
Δ| 2 ux
– 0.0060035
– 0.0044505
Δ| 3 ux
0.0004869
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)
8.9
30
| f(x)
100 Δ
| 2f(x)
100 Δ
5
50
=
0.9
9
9.0
–
35
–
9.3
350
3500
=−
9 × 0.4
36
10
100
=−
0.3
3
25
Applying Newton’s divided difference formula
100 f(x) = 30 + (x – 8.9) ×
FG
H
3500
50
+ (x – 8.9)(x – 9) −
36
9
IJ
K
= – 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
= 8.9788
1.9444
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)
0
58.8
1
63.4
2
62.5
∴
Δ| f(x)
4.6
– 0.9
Δ| 2f(x)
– 2.75
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
⇒
Again,
– 5.5 x + 7.35 = 0
⇒ x = 1.342
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)
0
40.7
1
38.1
2
39.3
Δ| f(x)
– 2.6
1.2
Δ| 2f(x)
1.9
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 midnight 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)
1
1
Δ| f(x)
Δ| 2f(x)
Δ| 3f(x)
4
2
−
5
2
3
1
14
0
7
5
8
4
−
–1
Applying Newton’s divided difference formula,
1
6
FG 2 IJ
H 3K
f(x) = 1 + (x – 1) (4) + (x – 1) (x – 2) −
+ (x – 1) (x – 2) (x – 7)
FG 1 IJ
H 14 K
378
COMPUTER-BASED NUMERICAL
∴
AND
STATISTICAL TECHNIQUES
FG 2 IJ + (5) (4) (– 1) FG 1 IJ
H 3K
H 14 K
f(6) = 1 + 20 + (5) (4) −
= 6.2381.
Example 14. Referring to the following table, find the value of f(x) at point
x = 4:
x:
f(x):
1.5
3
6
– 0.25
2
20.
Sol. The divided difference table is:
x
f(x)
1.5
– 0.25
3
2
6
20
Δ| f(x)
Δ| 2f(x)
1.5
1
6
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
Δ f(– 1)
2!
(x + 1)x(x − 1) 3
Δ f(– 2) + ......
3!
Sol. Taking the arguments, 0, – 1, 1, – 2, ...... the divided Newton’s difference
formula is
f(x) = f(0) + x Δ
| f(0) + x(x + 1) Δ
|
−1
2
− 1, 1
+ x(x + 1)(x – 1)
f(0)
|3
Δ
− 1, 1, − 2
f(0) + ...
| 2 f(– 1)
= f(0) + x Δ
| f(– 1) + x(x + 1) Δ
0
0, 1
| 3 f(– 2) + ....
+ (x + 1)x(x – 1) Δ
− 1, 0, 1
(74)
INTERPOLATION
Now
| f(– 1) =
Δ
f (0) − f (− 1)
= Δ f(– 1)
0 − (− 1)
| 2 f(– 1) =
Δ
1
| f(– 1)]
[Δ
| f(0) – Δ
1 − (− 1) 1
0
0
0, 1
=
| 3 f(– 2) =
Δ
− 1, 0, 1
1
2
1
2
[Δ f(0) – Δ f(– 1)] =
379
Δ2 f(– 1)
1
| 2 f(– 1) – Δ
| 2 f(– 2)]
[Δ
1 − (− 2) 0, 1
− 1, 0
=
1 Δ2 f (− 1) Δ2 f (− 2)
−
3
2
2
OP
Q
=
Δ3 f (− 2) Δ3 f (− 2)
=
3.2
3!
and so on.
LM
N
Substituting these values in (74)
( x + 1) x 2
Δ f(– 1)
2!
f(x) = f(0) + xΔ f(– 1) +
+
( x + 1) x( x − 1) 3
Δ f(– 2) + ......
3!
ASSIGNMENT 4.12
1.
Given the values:
x:
f(x):
2.
3.
5
7
11
13
17
150
392
1452
2366
5202
Evaluate f(9) using Newton’s divided difference formula.
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?
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
yx :
1
27
Find y5. Why does it differ from
5.
4
6
7
81
729
2187
35?
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
6.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
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
x2 + x − 3
3
x − 2 x2 − x + 2
as sums of portial fractions
10. Express the function
x2 + 6 x − 1
2
( x − 1)( x − 4)( x − 6)
as a sum of partial fractions.
11. Certain corresponding values of x and log10 x are given below:
x:
log10 x:
300
304
305
307
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 interpolation.
(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:
f(x):
0.5
1.5
3.0
5.0
6.5
8.0
1.625
5.875
31.0
131.0
282.125
521.0
381
INTERPOLATION
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
n
H(x) =
∑
n
ui ( x) yi +
i=0
∑ v ( x) y ′
i
(76)
i
i=0
where ui(x) and vi(x) are polynomials in x of degree ≤ (2n + 1) and satisfy
RS
T
0, i ≠ j
(i) ui(xj) = 1, i = j
(ii) vi(xj) = 0
UV
W
∀ i, j
(iii) ui′(xj) = 0 ∀ i, j
RS
T
(77 (i))
0, i ≠ j
(iv) vi′(xj) = 1, i = j
(77 (ii))
(77 (iii))
UV
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
UV
W
where Li(x) is defined as
Li(x) =
( x − x0 )( x − x1 ) ... ( x − xi −1 )( x − xi + 1 ) ... ( x − xn )
( xi − x0 )( xi − x1 ) ... ( xi − xi −1 )( xi − xi + 1 ) ... ( xi − xn )
(78)
382
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Since Li2(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
UV
W
(79)
using conditions (77(i)) and (77(ii)) in (79), we get
and
aix + bi = 1
(80 (i))
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
and
(80 (iii))
ci = 1
(80 (iv))
From equations (80(i)), (80(ii)), (80(iii)) and (80(iv)), we deduce
U|
b = 1 + 2x L ′(x ) |
V|
c =1
|W
d =–x
ai = – 2Li′(xi)
i
i i
(81)
i
i
and
i
i
Hence, from (79),
ui(x) = [– 2x Li′(xi) + 1 + 2xiLi′(xi)] [Li(x)]2
= [1 – 2(x – xi) Li′(xi)] [Li(x)]2
vi(x) = (x – xi) [Li(x)]2
and
Therefore from (76),
n
n
H(x) =
∑ [1 – 2(x – x ) L ′(x )] [L (x)]
i =0
i
i
i
i
2
yi +
∑ ( x − x ) [L ( x)]
i
i
2
yi′
i=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.
383
INTERPOLATION
xi
yi
y i′
0
0
0
1
1
1
Sol. Hermite interpolation formula is
1
∑
H(x) =
1
[1 − 2( x − xi ) L ′i ( xi )] [L i ( x)]2 yi +
i=0
∑ ( x − x ) [L ( x)]
i
i
2
yi′
i=0
= [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′
Now,
L0(x) =
L1 (x) =
(82)
x − x1
x−1
=
=1–x
x0 − x1 0 − 1
x − x0
x−0
=x
=
x1 − x0 1 − 0
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
2
H(x) =
∑
[1 − 2( x − x i ) L ′i ( x i )][ L i ( x )]2 y i +
i=0
2
∑ ( x − x ) [L ( x )]
i
2
i
y i′
i=0
= [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′
Now,
∴
Hence,
( x − x1 ) ( x − x2 )
( x − 1) ( x − 2) 1 2
= (x – 3x + 2)
=
( x0 − x1 ) ( x0 − x2 ) (0 − 1) (0 − 2) 2
L0(x) =
L1 (x) =
( x − x0 ) (x − x2 )
( x − 0) ( x − 2)
=
= 2x – x2
( x1 − x 0 ) ( x1 − x 2 ) (1 − 0) (1 − 2)
L2(x) =
( x − x 0 ) ( x − x1 )
( x − 0) ( x − 1) 1 2
=
= (x – x)
( x 2 − x 0 ) ( x 2 − x1 ) ( 2 − 0) ( 2 − 1) 2
L0′(x) =
2x − 3
,
2
L0′(x0) = –
∴ From (83),
(83)
LM
N
3
,
2
L1′(x) = 2 – 2x,
L2′(x) =
2x − 1
2
L1′(x1) = 0,
L2′(x2) =
3
2
FG 3 IJ OP 1 (x
H 2K Q 4
H(x) = 1 − 2( x − 0) −
2
– 3x + 2)2 (0)
+ [1 – 2(x – 1) (0)] (2x – x2)2 (1)
LM
N
+ 1 − 2( x − 2)
FG 3 IJ OP 1 (x
H 2K Q 4
2
– x)2 (0)
1 2
(x – 3x + 2)2 (0)
4
1
+ (x – 1) (2x – x2)2 (0) + (x – 2) (x2 – x)2 (0)
4
+ (x – 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
Y
385
(4, 2)
X
(0, 0)
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
1
H(x) =
∑
[1 − 2( x − x i ) L ′i ( x i )][ L i ( x )]2 y i +
i=0
Now,
1
∑ ( x − x ) [L ( x )]
i
2
i
y i′
(84)
i=0
L0(x) =
x − x1
x−4
x
= 1−
=
4
x0 − x1 0 − 4
L1(x) =
x − x0
x−0 x
=
=
x1 − x0 4 − 0 4
∴
L0′( x) = –
1
4
and L1′(x) =
Hence,
L0′(x0) = –
1
4
and L1′(x1) =
LM
N
1
4
1
4
FG 1IJ OP FG 1 − x IJ (0)
H 4K Q H 4K
L
F 1I O F x I
+ M1 − 2( x − 4) G J P G J (2)
H 4KQ H 4K
N
x
+ (x – 0) FG 1 − IJ (0) + (x – 4) FG x IJ
H 4K
H 4K
2
∴ From (84), H(x) = 1 − 2( x − 0) −
2
2
LM FG x − 4 IJ OP x
N H 2 KQ 8
= 1−
2
=
(6 − x) x 2
1
=
(6x2 – x3).
16
16
2
(0)
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
2.
3.
f ′(xi)
–1
1
–5
0
1
1
1
3
7
Also find f(– 0.5).
Apply Hermite’s interpolating formula to obtain a polynomial of degree 4 for the following data:
xi
yi
yi′
0
1
0
1
0
0
2
9
24
Apply Hermite’s formula to find a polynomial which meets the following specifications:
xi
4.
f(xi)
yi
yi′
–1
–1
0
0
0
0
1
1
0
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
5.
6.
387
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
Find y = f(x) by Hermite’s interpolation from the table:
yi
xi
yi′
–1
1
–5
0
1
1
1
3
7
Compute y2 and y2′.
7.
8.
Compute e by Hermite’s formula for the function f(x) = ex at the points 0 and 1. Compare the value with the value obtained by using Lagrange’s interpolation.
Show that
f
9.
FG a + b IJ = f (a) + f (b) + (b − a) [ f ′(a) − f ′(b)]
H 2 K
2
8
by Hermite’s interpolation.
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.
y′ =
1
x
x
y = logex
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
0.33333
0.28571
0.25000
y′ =
1
x
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.
3
P a r t
n
Numerical Integration and Differentiation
Introduction, Numerical Differentiation,
Numerical Integration,
Trapezoidal Rule, Simpson’s
Weddle’s Rule.
FG 1IJ
H 3K
rd
and
FG 3IJ
H 8K
th
Rule, Boole’s Rule,
Chapter
5.1
5
NUMERICAL INTEGRATION
AND DIFFERENTIATION
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
z
b
a
f ( x) dx 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.
393
394
COMPUTER-BASED NUMERICAL
5.2
NUMERICAL DIFFERENTIATION
AND
STATISTICAL TECHNIQUES
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 +
where
u=
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y0 +
Δ y0 + ....
2!
3!
(1)
x−a
h
(2)
Differentiating eqn. (1) with respect to u, we get
dy
2u − 1 2
3u 2 − 6u + 2 3
Δ y0 + ...
= Δy0 +
Δ y0 +
du
2
6
(3)
Differentiating eqn. (2) with respect to x, we get
du 1
=
dx h
(4)
We know that
LM
MN
FG
H
IJ
K
F
GH
I
JK
OP
PQ
dy dy du 1
2u − 1 2
3u 2 − 6u + 2 3
.
Δy0 +
Δ y0 +
Δ y0 + ...
=
=
dx du dx h
2
6
(5)
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
395
dy
at any x which is not tabulated.
dx
Formula (5) becomes simple for tabulated values of x, in particular when
x = a and u = 0
Putting u = 0 in (5), we get
Expression (5) provides the value of
FG dy IJ
H dx K
=
x= a
LM
N
OP
Q
1
1
1
1
1
Δy0 − Δ2 y0 + Δ3 y0 − Δ4 y0 + Δ5 y0 − ...
h
2
3
4
5
(6)
Differentiating eqn. (5) with respect to x, we get
FG IJ = d FG dy IJ du
H K du H dx K dx
F 6u − 18u + 11I Δ y + ...OP 1
1L
= MΔ y + (u − 1) Δ y + G
h MN
H 12 JK
PQ h
F 6u − 18u + 11I Δ y + ...OP
1 L
Δ y + (u − 1) Δ y + G
M
=
h MN
H 12 JK
PQ
d2 y
d dy
=
2
dx dx
dx
2
2
2
2
3
0
3
0
4
0
2
0
0
4
0
(7)
Putting u = 0 in (7), we get
F d yI
GH dx JK
2
=
2
x =a
1
h
FG Δ y
H
2
2
0
− Δ3 y 0 +
IJ
K
11 4
Δ y0 + ...
12
(8)
Similarly, we get
F d yI
GH dx JK
3
=
3
x= a
1
h
3
FG Δ y
H
3
0
−
IJ
K
3 4
Δ y0 + ...
2
(9)
and so on.
Formulae for computing higher derivatives may be obtained by
successive differentiation.
Aliter: We know that
E = ehD ⇒ 1 + Δ = e hD
∴
hD = log (1 + Δ) = Δ −
Δ2 Δ3 Δ4
+
−
+ ...
2
3
4
396
COMPUTER-BASED NUMERICAL
AND
LM
N
OP
Q
1
1
1
1
Δ − Δ2 + Δ3 − Δ4 + ...
2
3
4
h
D=
⇒
STATISTICAL TECHNIQUES
Similarly,
FG
H
1 F
GΔ
=
h H
D2 =
and D3
IJ
K
1
1
1
1
Δ − Δ2 + Δ3 − Δ4 + ...
2
2
3
4
h
3
3
−
IJ
K
2
=
FG
H
IJ
K
1
11 4 5 5
Δ2 − Δ3 +
Δ − Δ + ...
2
12
6
h
3 4
Δ + ...
2
(2) Newton’s backward difference interpolation formula is
y = yn + u ∇yn +
u(u + 1) 2
u(u + 1)(u + 2) 3
∇ yn +
∇ yn + ...
2!
3!
x − xn
h
Differentiating (10) with respect to, u, we get
(11)
where u =
FG
H
F
GH
IJ
K
I
JK
dy
2u + 1 2
3u2 + 6u + 2
= ∇ yn +
∇ yn +
∇3yn + ...
du
2
6
Differentiating (11) with respect to x, we get
(10)
(12)
du 1
=
dx h
(13)
Now,
dy dy du
=
.
dx du dx
=
LM
MN
FG
H
IJ
K
F
GH
I
JK
OP
PQ
1
2u + 1 2
3u 2 + 6u + 2
∇yn +
∇ yn +
∇ 3 yn + ...
h
2
6
Expression (14) provides us the value of
(14)
dy
at any x which is not tabulated.
dx
At x = xn, we have u = 0
∴ Putting u = 0 in (14), we get
FG dy IJ
H dx K
x = xn
=
FG
H
IJ
K
1
1
1
1
∇yn + ∇ 2 yn + ∇ 3 yn + ∇ 4 yn + ...
h
2
3
4
(15)
DIFFERENTIATION
397
+ 18u + 11 4
∇ yn + ...
12
OP
PQ
(16)
IJ
K
(17)
NUMERICAL INTEGRATION
AND
Differentiating (14) with respect to x, we get
FG IJ
H K
LM∇ y
MN
d2 y
d dy du
=
dx 2 du dx dx
=
1
h2
2
n
+ (u + 1) ∇ 3 yn +
F 6u
GH
I
JK
2
Putting u = 0 in (16), we get
F d yI
GH dx JK
2
=
2
x = xn
FG
H
1
11 4
∇ 2 yn + ∇ 3 yn +
∇ yn + ...
2
12
h
Similarly, we get
F d yI
GH dx JK
3
=
3
x = xn
FG
H
IJ
K
1
3
∇ 3 yn + ∇ 4 yn + ...
3
2
h
(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 – ∇
∴
⇒
Also,
D=
D2
FG
H
IJ
K
1
1
1
1
∇ + ∇ 2 + ∇ 3 + ∇ 4 + ...
h
2
3
4
FG
H
FG ∇
H
D3 =
1
h2
1
h
3
FG ∇
H
2
3
+ ∇3 +
+
11 4
∇
12
IJ
K
IJ
K
1 2 1 3 1 4
∇ + ∇ + ∇ + ...
2
3
4
IJ
K
I
+ ...J
K
1
1 2 1 3
= 2 ∇ + ∇ + ∇ + ...
2
3
h
=
Similarly,
FG
H
– hD = log (1 – ∇) = – ∇ +
2
3 4
∇ + ... and so on.
2
398
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
(3) Stirling’s central difference interpolation formula is
F
GH
IJ
K
FG
H
u Δy0 + Δy−1
u2 2
u(u 2 − 12 ) Δ3 y−1 + Δ3 y−2
+
Δ y−1 +
1!
2
2!
3!
2
y = y0 +
+
I
JK
F
GH
u2 (u 2 − 12 ) 4
u(u 2 − 12 )(u2 − 2 2 ) Δ5 y−2 + Δ5 y−3
Δ y−2 +
4!
5!
2
where
u=
I + ...
JK
(19)
x−a
h
(20)
Differentiating eqn. (19) with respect to u, we get
F
GH
I FΔ y +Δ y I
JK GH 2 JK
− 15u + 4 I F Δ y + Δ y I
JK GH 2 JK + ...
5!
3
3u 2 − 1
dy Δy0 + Δy−1
=
+ u Δ2 y−1 +
2
6
du
F 4u − 2uI Δ y + F 5u
GH 4 ! JK
GH
3
+
4
4
−2
3
−1
5
2
−2
5
−2
−3
(21)
Differentiating (20) with respect to x, we get
du 1
=
dx h
(22)
Now,
dy dy du
=
.
dx du dx
=
LM
F
IFΔ y +Δ y I
G
JK GH 2 JK
H
MN
F 4u − 2u I Δ y + F 5u − 15u + 4 I F Δ y + Δ y I + ...OP
+G
GH 5 ! JK GH 2 JK PQ
H 4 ! JK
1 Δy0 + Δy−1
3u 2 − 1
+ u Δ2 y−1 +
h
2
6
3
4
4
−2
2
3
3
−1
5
−2
−2
5
−3
(23)
Expression (23) provides the value of
Given x = a, we have u = 0
dy
at any x which is not tabulated.
dx
NUMERICAL INTEGRATION
399
DIFFERENTIATION
AND
∴ Given u = 0 in (23), we get
FG dy IJ
H dx K
1
h
=
x= a
LMF Δy
MNGH
0
F
GH
IJ
K
+ Δy−1
1 Δ3 y−1 + Δ3 y−2
−
2
6
2
I + 1 FΔ y
JK 30 GH
5
−2
I OP
JK PQ
+ Δ5 y−3
− ...
2
(24)
Differentiating (23) with respect to x, we get
FG IJ
H K
LMΔ y
MN
d2 y
d dy du
=
2
du dx dx
dx
=
1
h
2
2
−1
+u
FΔ y
GH
3
I F
I
JK GH
JK
F 2u − 3uI F Δ y + Δ y I + ...OP
+G
H 12 JK GH 2 JK PQ
−1
+ Δ3 y−2
6u2 − 1
+
Δ4y–2
2
12
5
3
Given u = 0 in (25), we get
F d yI
GH dx JK
2
=
2
x=a
5
−2
FG
H
−3
IJ
K
1
1 4
1 6
Δ2 y−1 −
Δ y −2 +
Δ y−3 − ...
2
12
90
h
(25)
(26)
and so on.
Formulae for computing higher derivatives may be obtained by
successive differentiation.
(4) Bessel’s central difference interpolation formula is
y=
FG y
H
F
GH
IJ FG IJ
K H K
F 1I
u(u − 1) G u − J
H 2K Δ y
+
0
+ y1
u(u − 1) Δ2 y−1 + Δ2 y0
1
+ u−
Δy0 +
2
2
2!
2
3
3!
−1
FG
H
+
+
5!
F
GH
(u + 1) u(u − 1)(u − 2) Δ4 y−2 + Δ4 y−1
4!
2
(u + 1) u(u − 1)(u − 2) u −
+
I
JK
1
2
IJ
KΔy
5
−2
F
GH
(u + 2)(u + 1) u(u − 1)(u − 2)(u − 3) Δ6 y−3 + Δ6 y−2
6!
2
where u =
x−a
h
I
JK
I + ...
JK
(27)
(28)
400
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Differentiating eqn. (27) with respect to u, we get
IJ F Δ y
K GH
− 6u − 2u + 2 I F Δ y
JK GH
4!
FG
H
2
dy
2u − 1
= Δy0 +
du
2!
F 4u
GH
F 6u
+G
H
3
+
5
2
1I
F
I + GG 3u − 3u + 2 JJ Δ y
JK H 3 ! K
+ Δ y I F 5u − 10u + 5u − 1I
JK Δ y
JK + GH
2
5!
+ 8u − 12 I F Δ y + Δ y I
JK GH 2 JK + ... (29)
2
2
−1 + Δ y0
2
4
4
−2
− 15u 4 − 20u 3 + 45u 2
6!
3
4
−1
–1
3
5
6
−3
6
–2
−2
Differentiating (28) with respect to x, we get
du 1
=
dx h
dy dy du
=
.
dx du dx
Now,
LM
MM
MN
IJ F Δ y
K GH
FG
H
2
1 Δy + 2u − 1
0
=
2!
h
F 4u − 6u − 2u + 2 I F Δ y
GH
JK GH
4!
F
+ 6u − 15u − 20u + 45u
GH
6!
3
4
2
+
5
4
3
−2
2
−1
I
JK
I F
JK GH
+ 8u − 12 I F Δ y
JK GH
I
JJ
K
Δ3y–1
I
JK
+ Δ4 y−1
5u 4 − 10u 3 + 5u − 1 5
+
Δ y–2
2
5!
Expression (30) provides us the value of
lated.
F
GG
H
1
3u 2 − 3u +
+ Δ2 y0
2
+
3!
2
6
−3
I OP
JK PQ
+ Δ6 y−2
+ ...
2
(30)
dy
at any x which is not tabudx
Given x = a, we have u = 0
∴ Given u = 0 in (30), we get
FG dy IJ
H dx K
x= a
=
LM
MN
F
GH
I
JK
F
GH
I
JK
I + ...OP
JK PQ
1
1 Δ2 y−1 + Δ2 y0
1 3
1 Δ4 y−2 + Δ4 y−1
Δy0 −
+
Δ y−1 +
h
2
2
12
12
2
–
F
GH
1 Δ6 y−3 + Δ6 y−2
1 5
Δ y−2 −
120
60
2
(31)
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
401
Differentiating (30) with respect to x, we get
FG IJ = d FG dy IJ du
H K du H dx K dx
LMF Δ y + Δ y I + F 2u − 1I Δ y + F 6u
GH
MNGH 2 JK GH 2 JK
d2 y
d dy
=
2
dx
dx
dx
=
2
1
h
2
2
−1
3
0
2
−1
− 6u − 1
12
+
+
F 15u
GH
4
− 30u3 − 30u 2 + 45u + 4
360
I FΔ y
JK GH
6
I FΔ y
JK GH
4
F 4u
GH
−3
3
2
=
2
x=a
1
h2
LMF Δ y
MNGH
2
−1
I
JK
I
JK
I + ...OP
JK PQ
+ Δ6 y−2
2
F
GH
+ Δ2 y0
1
1 Δ4 y−2 + Δ4 y−1
− Δ3 y−1 −
2
2
12
2
+
F
GH
+ Δ4 y−1
2
I
JK
− 6u 2 + 1 5
Δ y–2
24
Given u = 0 in (32), we get
F d yI
GH dx JK
–2
I
JK
I
JK
OP
PQ
1 5
1 Δ6 y−3 + Δ6 y−2
Δ y−2 +
+ ...
24
90
2
(32)
(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)
3f(x
(x – x2)
0)
f(x0) + (x – x0)(x – x1)
2f(x
0)
+ (x – x0)(x – x1) (x – x2)(x – x3)
+ (x – x0)(x – x1)
4f(x
0)
+ ...
(34)
f ′(x) is given by
f ′(x) =
f(x0) + {2x – (x0 + x1)}
2f(x )
0
+ {3x2 – 2x(x0 + x1 + x2)
+ (x0x1 + x1x2 + x2x0)}
3f(x
0)
+ ... (35)
(ii) Lagrange’s interpolation formula is
f(x) =
( x − x1 )( x − x2 ) ... ( x − x n )
f(x0)
( x0 − x1 )( x0 − x2 ) ... ( x0 − x n )
+
( x − x0 )( x − x2 ) ... ( x − xn )
f(x1) + ...
( x1 − x0 )( x1 − x2 ) ... ( x1 − xn )
f ′(x) can be obtained by differentiating f(x) in eqn. (36).
(36)
402
NOTE
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
1. Formula (8) can be extended as
F d yI
GH dx JK
2
2
=
x =a
1
h2
FΔ
GG
GH
2
− Δ3 +
I
JJ
JK
11 4 5 5
Δ − Δ
12
6
y0
137 6
7 7 363 8
Δ −
Δ +
Δ + ...
+
180
10
560
2. Formula (17) can be extended as
F d yI
GH dx JK
2
2
5.4
=
x = xn
1
h2
F∇
GG
GH
2
+ ∇3 +
I
JJ
JK
11 4 5 5 137 6
∇ + ∇ +
∇
12
6
180
yn.
7 7 363 8
+
∇ +
∇ + ...
10
560
MAXIMA AND MINIMA OF A TABULATED FUNCTION
dy
to zero and
dx
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
Since maxima and minima of y = f(x) can be found by equating
y = y0 + u Δy0 +
u(u − 1) 2
u(u − 1)(u − 2) 3
Δ y0 +
Δ y0 + ...
2!
3!
(37)
Differentiating (37) with respect to u, we get
dy
2u − 1 2
3u2 − 6u + 2 3
= Δ y0 +
Δ y0 +
Δ y0 + ...
du
2!
3!
For maxima or minima,
dy
=0
du
⇒
Δy0 +
2u − 1 2
3u 2 − 6u + 2 3
Δ y0 +
Δ y0 + ... = 0
2!
3!
(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.
NUMERICAL INTEGRATION
For maximum,
For minimum,
AND
DIFFERENTIATION
403
d2 y
= (–)ve
du 2
d2 y
= (+)ve.
du 2
EXAMPLES
dy
at x = 0.1 from the following table:
dx
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:
Example 1. Find
x
y
0.1
0.9975
0.2
0.9900
Δ2 y
Δy
Δ3 y
– 0.0075
– 0.0049
– 0.0124
0.3
0.9776
0.4
0.9604
0.0001
– 0.0048
– 0.0172
Here
LM dy OP
N dx Q
h = 0.1 and y0 = 0.9975
x = 0.1
LM
N
OP
Q
=
1
1
1
Δy0 − Δ2 y0 + Δ3 y0
h
2
3
=
1
1
1
− 0.0075 − (− 0.0049) + (0.0001)
0.1
2
3
LM
N
OP
Q
= – 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
1.0
43.1
1.1
47.7
Δ2 v
Δv
Δ3 v
Δ4 v
4.6
– 0.2
4.4
1.2
0.1
52.1
– 0.1
0.1
4.3
1.3
0.2
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
LM dv OP
N dt Q
t = 1.1
=
LM
N
OP
Q
LM
N
1
1
1
1
1
1
4.4 − (− 0.1) + (0.2)
Δv0 − Δ2 v0 + Δ3 v0 =
2
3
3
2
h
0.1
OP
Q
= 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 − 1) 2
u(u − 1)(u − 2) 3
Δ y0 +
Δ y0
2!
3!
+
where
u=
x−a
h
u(u − 1)(u − 2)(u − 3) 4
Δ y0 + ...
4!
(39)
(40)
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
405
I
JK
(41)
Differentiating eqn. (39) with respect to u, we get
FG
H
F
GH
F 2u
+G
H
IJ
K
I
JK
dy
2u − 1 2
3u 2 − 6u + 2
Δ3y0
Δ y0 +
= Δy0 +
du
2
6
3
− 9u2 + 11u − 3
Δ4y0 + ...
12
Differentiating eqn. (40) with respect to x
du 1
=
dx h
(42)
dy dy du
=
.
dx du dx
∴
=
LM
MN
FG
H
F
GH
IJ
K
I
JK
1
2u − 1 2
3u 2 − 6u + 2 3
Δy0 +
Δ y0 +
Δ y0
h
2
6
+
Also, at x = 1.1, u =
F 2u
GH
3
I
JK
OP
PQ
− 9u 2 + 11u − 3 4
Δ y0 + ...
12
Here a = 1.0
and h = 0.2
1.1 − 1.0 1
=
0.2
2
The forward difference table is as follows:
x
f(x) = y
1.0
0.0
Δy
Δ 2y
Δ 3y
Δ 4y
Δ5 y
0.1280
1.2
0.1280
0.298
0.4260
1.4
0.5540
1.6
1.2960
0.018
0.316
0.7420
1.8
2.4320
2.0
4.000
0.06
0.078
0.394
1.1360
1.5680
– 0.1
– 0.04
0.038
0.432
(43)
406
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
From eqn. (43),
LM
MN
I
JK
F
GH
IJ
K
FG
H
2u − 1 2
3u 2 − 6u + 2 3
dy 1
Δy 0 +
Δ y0 +
Δ y0
=
2
6
dx h
F 2u
GH
F 5u
+G
H
+
I
JK
3
− 9u 2 + 11u − 3
Δ4y0
12
4
− 40u3 + 105u 2 − 100u + 24 5
Δ y0 + ...
120
OP
PQ
I
JK
(44)
At x = 1.1, we get
f ′(1.1) =
FG dy IJ
H dx K
x =1.1
R|3 FG 1IJ
S H 2K
+|
T
2
LM
R|2 FG 1IJ − 1U|
1 M
S H 2 K V| (0.298)
=
0.1280 + |
M
0.2
T 2 W
N
R F 1 I F 1I F 1 I U
FG 1IJ + 2U|
H 2 K V (0.018) + |S2 GH 2 JK − 9 GH 2 JK + 11 GH 2 JK − 3|V (.06)
|W
|W
|T
6
12
OP
R|5 FG 1IJ − 40 FG 1IJ + 105 FG 1IJ − 100 FG 1IJ + 24U|
H 2K
H 2K
H 2 K V (– 0.1) PP
S H 2K
+|
|W
120
T
Q
3
−6
4
3
2
2
= 0.66724.
Differentiating eqn. (44), with respect to x, we get
FG IJ
H K
LM
MN
F
GH
I
JK
d2 y
d dy du
1
6u 2 − 18u + 11 4
2
3
1
=
(
)
Δ
y
+
u
−
Δ
y
+
Δ y0
=
0
0
12
h2
dx 2 du du dx
+
F 2u
GH
3
I
JK
OP
PQ
− 12u 2 + 21u − 10 5
Δ y0 + ...
12
NUMERICAL INTEGRATION
AND
407
DIFFERENTIATION
At x = 1.1, we get
F d yI
GH dx JK
2
f ″(1.1) =
=
2
1
( 0.2) 2
x =1.1
LM
R|6 FG 1IJ
MM0.298 + FG 1 − 1IJ (0.018) + S| H 2 K
H2 K
T
N
R|2 FG 1IJ
S H 2K
+|
T
3
− 12
FG 1IJ + 11U|
H 2 K V (0.06)
|W
12
2
− 18
FG 1IJ
H 2K
2
+ 21
12
= 8.13125.
OP
FG 1IJ − 10U|
H 2 K V (– 0.1) PP
|W
Q
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
0
0
∇s
∇2 s
∇3s
∇4s
∇5s
∇6 s
2.5
1
2.5
3.5
6
2
8.5
– 2.5
1
7
3
15.5
2
9
4
24.5
5
36.5
6
50
3.5
1
0
1
3
12
1
– 2.5
– 2.5
– 1.5
1.5
13.5
– 3.5
408
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
The speed of the athlete at t = 5 sec is given by
FG ds IJ
H dt K
LM
N
1
1
1
1
1L
O
= M12 + (3) + (1) + (0) + (− 3.5)P
5
4
3
2
1N
Q
=
t =5
1
1
1
1
1
∇s5 + ∇ 2 s5 + ∇ 3 s5 + ∇ 4 s5 + ∇ 5 s5
h
2
3
4
5
OP
Q
= 13.1333 ≈ 13.13 metre/sec.
dy
d2y
and
at x = 6, given that
dx
dx 2
Example 5. Find
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
4.5
9.69
5.0
12.9
Δy
Δ 2y
Δ3 y
Δ4 y
3.21
0.60
3.81
5.5
16.71
0.06
0.66
0
4.47
6.0
21.18
0.06
0.72
0
5.19
6.5
26.37
0.06
0.78
0
5.97
7.0
32.34
0.06
0.84
6.81
7.5
39.15
We know that
LM dy OP
N dx Q
x=6
FG
H
IJ
K
=
1
1
1
Δy0 − Δ2 y0 + Δ3 y0
h
2
3
=
1
1
1
5.19 − (0.78) + (0.06) = 9.64
0.5
2
3
LM
N
OP
Q
NUMERICAL INTEGRATION
LM d y OP
N dx Q
2
and
=
2
x=6
=
1
h
2
LMΔ y
N
2
0
− Δ3 y0 +
11 4
Δ y0
12
AND
DIFFERENTIATION
409
OP
Q
1
[0.78 – 0.06] = 4(0.72) = 2.88.
0.25
Example 6. From the following table of values of x and y, obtain
dy
d2 y
and
dx
dx 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
1.0
2.7183
1.2
3.3201
Δ 2y
Δy
Δ3 y
Δ 4y
Δ5 y
Δ6 y
0.6018
0.1333
0.7351
1.4
4.0552
1.6
4.9530
0.0294
0.1627
0.8978
0.0361
0.1988
1.0966
1.8
0.0013
0.0080
0.0441
6.0496
0.2429
1.3395
2.0
0.0067
0.0001
0.0014
0.0094
0.0535
7.3891
0.2964
1.6359
2.2
9.0250
(i) Here
∴
LM dy OP
N dx Q
a = 1.2
y0 = 3.3201; h = 0.2
x = 1.2
=
LM
N
1
1
1
1
1
0.7351 − (0.1627) + (0.0361) − (0.008) + (0.0014)
5
4
3
2
0.2
= 3.3205
LM d y OP
N dx Q
2
=
2
x = 1.2
1
(0.2)
2
= 3.318
LM0.1627 − 0.0361 + 11 (0.0080) − 5 (0.0014)OP
12
6
N
Q
OP
Q
410
COMPUTER-BASED NUMERICAL
(ii) Here
∴
LM dy OP
N dx Q
AND
STATISTICAL TECHNIQUES
a = 2.2,
yn = 9.02 and h = 0.2
=
x = 2.2
LM
N
1
1
1
1
1
1.6359 + (0.2964) + (0.0535) + (0.0094) + (0.0014)
5
4
0.2
2
3
= 9.0228
LM d y OP
N dx Q
2
=
2
x = 2.2
LM
N
11
5
1
0.2964 + 0.0535 +
(0.0094) + (0.0014)
0.04
12
6
OP
Q
= 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
LM dy OP
N dx Q
x = 1.6
=
1
0.2
LMFG 1.0966 + 0.8978 IJ − 1 FG 0.0441 + 0.0361IJ
K 6H
K
2
2
NH
1 F 0.0014 + 0.0013 I O
+
G
JK PQ
30 H
2
= 4.9530
and
LM d y OP
N dx Q
2
=
2
x = 1.6
LM
N
1
1
1
0.1988 −
(.0080) +
(.0001)
0.04
12
90
OP
Q
= 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.
OP
Q
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
411
Sol. The difference table is:
x
y
7.47
0.193
7.48
0.195
7.49
0.198
Δ 2y
Δy
Δ3 y
Δ4 y
Δ5 y
Δ 6y
0.002
0.001
0.003
– 0.001
0.000
0.000
0.003
7.50
– 0.001
0.201
– 0.001
0.002
7.51
0.002
0.203
0.001
– 0.01
– 0.007
– 0.004
0.003
7.52
0.003
0.003
– 0.002
0.206
– 0.001
0.002
7.53
0.208
Let
a = 7.5, h = 0.01
LM
MN
F
I
GH
JK
O
1 FΔ y +Δ y I
1
1 FΔ y +Δ y I
−
+ ...P
Δ y −
+
G
J
G
J
12 H
2
60 H
2
K 120
K PQ
1 L
1 R − .001 + .001 U 1
1
(.002) − S
(0.002) +
+
=
V
M
0.01 N
2T
2
12
W 12
RS.003 + (− .004) UV − 1 (− 0.007) − 1 FG − .01IJ OP
60 H 2 K Q
T 2 W 120
f ′(7.5) =
FG dy IJ
H dx K
x =7.5
=
1
1 Δ2 y−1 + Δ2 y0
1 3
Δy0 −
+
Δ y−1
0.01
2
2
12
4
−2
4
−1
5
6
−2
−3
6
−2
= 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
θ
0
0
Δ2 θ
Δθ
Δ3 θ
Δ4 θ
0.12
0.2
0.12
0.25
0.37
0.4
0.01
0.49
0.26
0
0.63
0.6
1.12
0.8
2.02
0.01
0.27
0
0.9
0.01
0.28
0
1.18
1.0
0.01
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
FG dθ IJ
H dt K
t = 0.6
OP
I
JK
PQ
1 L
1 F 0.27 + 0.28 I
0.9 − G
=
JK + 121 (0.01)OPQ
0.2 MN
2H
2
=
LM
MN
F
GH
1
1 Δ2 θ −1 + Δ2 θ0
1 3
Δθ 0 −
+
Δ θ −1
h
2
2
12
= 3.81667 rad./sec.
Angular acceleration at t = 0.6 sec is given by
F d θI
GH dt JK
2
LMF Δ θ + Δ θ I − 1 Δ θ OP
MNGH 2 JK 2 PQ
1 LF 0.27 + 0.28 I 1
=
MG 2 JK − 2 (0.01)OPQ
(0.2) NH
=
2
t = 0.6
2
1
h2
−1
2
= 6.75 rad./sec2.
2
0
3
−1
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
413
In case we choose the formula obtained from Stirling’s formula,
at t = 0.6 sec.,
NOTE
angular velocity
FG dθ IJ = 1 LMFG Δθ
H dt K h MNH
F
GH
IJ
K
+ Δθ −1
1 Δ3 θ −1 + Δ3 θ −2
−
2
6
2
0
=
1
0.2
I OP
JK PQ
LMFG .9 + .63 IJ − 1 FG .01 + .01IJ OP
NH 2 K 6 H 2 K Q
= 3.81667 rad./sec.
and angular acceleration
F d θI = 1
GH dt JK h
2
2
( Δ2 θ −1 ) =
2
1
(0.2) 2
(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
θ
1
85.3
3
74.5
Δθ
Δ2θ
Δ3θ
Δ4θ
– 10.8
3.3
– 7.5
5
67.0
– 2.3
1.0
– 6.5
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
1.6
– 0.7
414
COMPUTER-BASED NUMERICAL
∴
FG dθ IJ
H dt K
AND
STATISTICAL TECHNIQUES
LM
N
1
1
1L
O
= M− 7.5 − (1) + (− 0.7)P
3
2
2N
Q
=
t =3
1
1
1
1
Δθ 0 − Δ2θ 0 + Δ3θ 0 − Δ4 θ 0
h
2
3
4
OP
Q
= – 4.11667°C/min.
(ii) t = 3.5 is the non-tabular value of t so, we have from Newton’s forward
difference formula,
LM
MN
F
GH
IJ
K
FG
H
I
JK
dy 1
2u − 1 2
3u 2 − 6u + 2 3
=
Δy0 +
Δ y0 +
Δ y0
dx h
2
6
+
LM
MN
3
OP
PQ
I
JK
− 9u 2 + 11u − 3 4
Δ y0 + ...
12
F
GH
IJ
K
FG
H
F 2u
GH
I
JK
dθ 1
2u − 1 2
3u2 − 6u + 2 3
=
Δθ 0 +
Δ θ0 +
Δ θ0
dt h
2
6
Here,
+
At t = 3.5, u =
F 2u
GH
3
OP
PQ
I
JK
− 9u 2 + 11u − 3 4
Δ θ 0 + ...
12
3.5 − 3.0 0.5
=
= 0.25
2
2
| Here a = 3.0 and h = 2
From (45),
FG dθ IJ
H dt K
t =3.5
=
LM
MN
RS
T
UV
W
(45)
RS
T
UV
W
1
2(.25) − 1
3(.25) 2 − 6(.25) + 2
− 7.5 +
(1) +
(− .7)
2
2
6
= – 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.
OP
PQ
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
415
Sol. The difference table is as follows:
x
y
1.2
0.9320
Δ2
Δ
Δ3
Δ4
0.0316
1.3
0.9636
– 0.0097
0.0219
1.4
– 0.0002
0.9855
– 0.0099
0.0002
0.0120
1.5
0.9975
1.6
0.9996
0
– 0.0099
0.0021
Let
y0 = 0.9320 and a = 1.2
By Newton’s forward difference formula,
y = y0 + u Δy0 +
u(u − 1) 2
Δ y0 + ...
2
= 0.9320 + 0.0316 u +
differences
u(u − 1)
(– 0.0097) | Neglecting higher
2
IJ
K
FG
H
2u − 1
dy
(− 0.0097)
= 0.0316 +
2
du
At a maximum,
⇒
∴
FG
H
dy
=0
du
0.0316 = u −
IJ
K
1
(0.0097)
2
⇒
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 + 1) 2
u(u + 1)(u + 2) 3
∇ yn +
∇ yn
2!
3!
416
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
= 0.9996 – (0.24 × 0.0021) +
(− 0.24)(1 − 0.24)
(– 0.0099)
2
= 0.9999988 = 0.9999 nearly
∴ Maximum y = 0.9999 approximately.
Example 11. Assuming Bessel’s interpolation formula, prove that
d
1 3
(yx ) = Δyx −1/2 −
Δ yx − 3/2 + ...
dx
24
Sol. Bessel’s formula is
yx =
FG y
H
IJ FG
K H
F
GH
IJ
K
+ y1
x( x − 1) Δ2 y−1 + Δ2 y0
1
+ x−
Δy0 +
2
2
2!
2
0
FG
H
x( x − 1) x −
+
1
, we get
2
Replacing x by x +
yx+1/2
Fy
=G
H
0
IJ
K
+ y1
+ x Δy0 +
2
1
2
IJ
K Δy
3
I
JK
+ ...
(46)
FG x + 1IJ FG x − 1IJ F
H 2 K H 2 K G Δ y + Δ y IJ
H 2 K
2!
FG x + 1IJ FG x − 1IJ x
H 2 K H 2 K Δ y + ...
+
(47)
3!
2
2
−1
3
3!
–1
0
−1
Differentiating (47) with respect to x, we get
F
GH
d
2 x Δ2 y−1 + Δ2 y0
( yx + 1/2 ) = Δy0 +
dx
2!
2
1
I + FGG 3x − 4 IJJ Δ y
JK H 3 ! K
Given x = 0, we get
d
1 3
Δ y–1 + ...
( yx + 1/2 ) = Δy0 −
dx
24
Shifting the origin from x = 0 to x –
1
, we get
2
d
1 3
( yx ) = Δyx − 1/2 −
Δ yx − 3 / 2 + ...
dx
24
2
3
–1
+ ...
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(x0) + (x – x0)(x – x1)
2f(x
+ (x – x0)(x – x1)(x – x2)
3f(x
f(x) = f(x0) + (x – x0)
0)
0)
4f(x
+ (x – x0) (x – x1)(x – x2)(x – x3)
0)
+ ...
(48)
Newton’s divided difference table is as follows:
x
f(x)
2
57
4
1345
f(x)
2
f(x)
3
f(x)
4
f(x)
5
f(x)
6
f(x)
644
1765
12999
9
66340
556
7881
83928
13
402052
22113
238719
16
1118209
4287844
29
21242820
1
64
2274
49401
633927
21
45
1186
0
1
89
4054
114265
2119372
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 − 2)( x − 5)( x − 1)
( x − 0)( x − 5)( x − 1)
(0) +
(8)
(0 − 2)(0 − 5)(0 − 1)
(2 − 0)(2 − 5)(2 − 1)
+
=–
( x − 0)( x − 2)( x − 1)
( x − 0)( x − 2)( x − 5)
(125) +
(1)
(5 − 0)(5 − 2)(5 − 1)
(1 − 0)(1 − 2)(1 − 5)
4 3
25 3
1 3
(x – 6x2 + 5x) +
(x – 3x2 + 2x) +
(x – 7x2 + 10x)
3
12
4
= 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 +
where
u=
x − x0
h
and E =
u(u − 1) 2
Δ f0
2
1
u(u – 1) (u – 2) h3 f ′″(ξ)
6
NUMERICAL INTEGRATION
We have,
f ′(x) =
=
and
df du
.
du dx
LM
N
1
1
Δf0 + (2u − 1) Δ2 f0
h
2
| E′(x0) | = | E′(u = 0) | ≤
AND
DIFFERENTIATION
OP
Q
h2
M3
3
M3 = max|f ′′′( x)|
x0 ≤ x ≤ x2
where
(ii) Newton’s backward difference approximation is given by
f(x) = f2 + u ∇f2 +
where u =
x − x2
h
We have,
and E =
f ′(x) =
LM
N
1
u(u + 1) ∇2 f2
2
1
u (u + 1) (u + 2) h3 f ′″(ξ)
6
1
1
∇f2 + (2u + 1) ∇ 2 f2
h
2
h2
M3
3
(iii) Central difference approximation is given by
and
| E′(x2) | = | E′ (u = 0) | ≤
f(x) = f0 +
where
We have
and
u=
f ′(x) =
u
(δf1/2 + δf–1/2)
2
x − x0
.
h
1
(δf + δf–1/2)
2h 1/2
=
1
[(f – f ) + (f0 – f–1)]
2h 1 0
=
1
(f – f )
2h 1 –1
| E′(x) | ≤
h2
M3.
6
OP
Q
419
420
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
ASSIGNMENT 5.1
1.
Given that
x:
1.0
y: 7.989
Find
1.1
8.403
1.2
8.781
1.3
9.129
1.4
9.451
1.5
9.750
1.6
10.031
dy
d2 y
and
at
dx
dx2
(i) x = 1.1
(ii) x = 1.6.
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
2.
Find
dy
d2 y
and
at
dx
dx2
(i) x = 1
(ii) x = 1.25
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.
(iii) x = 1.15.
6.
d
( J0 ) at x = 0.1 from the following table:
dx
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.
8.
Find
NUMERICAL INTEGRATION
AND
421
DIFFERENTIATION
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
dx
at t = .1 and at t = .5.
dt
Using Newton’s divided difference formula, find f ′(10) from the following data:
Evaluate
11.
x:
f(x):
12.
13.
14.
15.
3
– 13
5
11
27
34
23
899
17315
35606
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.
Given the following table of values, find f ′(8):
x:
6
7
9
12
f(x):
1.556
1.690
1.908
2.158.
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
Prove that
1
1
d
1
(yx+h – yx–h) –
(y
– yx–2h) +
(y
– yx–3h) – ...
( yx ) =
2h x+2h
3h x+3h
dx
h
LMHint: R.H.S. = 1 log F 1 + E I y = F 1 log EI y
GH 1 + E JK GH h JK
h
MN
x
−1
16.
x
= D( yx )
OP
PQ
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:
f(x) = x :
1
1.05
1.1
1.15
1.2
1.25
1.3
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
y: 1.73036 1.95532 2.19756 2.45693 2.73309 3.02549
5.5
2
2.2
2.3333
3.65563.
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 Δ3 y−2 + Δ3 y−1
.
6h
2
The truncation error in the second derivative =
The rounding error is proportional to
while it is proportional to
1
h2
1
12h 2
|Δ4 y−2 |.
1
in the case of the first derivatives,
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ε
h2
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
at x = 1.6.
dx
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
423
Sol. Since the values are correct to four decimals, it follows that
ε = 0.5 × 10–4
Truncation error =
IJ
K
FG
H
1 Δ3 y−1 + Δ3 y0
1 0.0361 + 0.0441
=
1.2
6h
2
2
| See difference table in Example 6
= 0.03342
Rounding error
5.6
=
3ε 3 × 0.5 × 10 −4
=
= 0.00038.
2h
2 × 0.2
NUMERICAL INTEGRATION
Given a set of tabulated values of the integrand f(x), determining the value of
z
xn
x0
f ( x) dx 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
y = f(x)
y0
O
5.7
y1
y2
x0 x0 + h x0 + 2h
yn
X
x0 + nh
NEWTON-COTE’S QUADRATURE FORMULA
Let I =
z
b
a
y dx , 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,
b−a
so that
n
each of width h =
x0 = a, x1 = x0 + h, x2 = x0 + 2h, ......., xn = x0 + nh = b.
I=
∴
z
x0 + nh
x0
f ( x) dx
Since any x is given by x = x0 + rh and dx = hdr
I=h
∴
=h
z
z LMN
n
0
f ( x0 + rh) dr
n
0
y0 + rΔy0 +
OP
Q
r (r − 1) 2
r (r − 1)(r − 2) 3
Δ y0 +
Δ y0 + ....... dr
2!
3!
[by Newton’s forward interpolation formula]
L
= h Mry
MN
0
+
F
I
GH
JK
I
1 Fr
+ G
−r +r J Δ y
6H 4
K
1 r3 r2 2
r2
−
Δy 0 +
Δ y0
2
2 3
2
4
LM
N
= nh y0 +
3
2
3
0
O
+ .......P
PQ
n
0
OP
Q
n
n(2n − 3) 2
n(n − 2) 2 3
Δy0 +
Δ y0 +
Δ y0 + ........
2
12
24
(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
z
x0 + h
x0
FG
H
f ( x) dx = h y0 +
IJ
K
1
h
h
Δy0 = [2 y0 + ( y1 − y0 )] = ( y0 + y1 )
2
2
2
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
425
Similarly, for the next sub-interval (x0 + h, x0 + 2h), we get
z
x0 + 2 h
f ( x) dx =
x0 + h
h
( y1 + y2 ) , ......,
2
z
x0 + nh
x0 + ( n − 1) h
f ( x) dx =
h
( yn − 1 + yn )
2
Adding the above integrals, we get
z
x0 + nh
f ( x) dx =
x0
h
[( y0 + yn ) + 2( y1 + y2 + ...... + yn − 1 )]
2
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
z
x0 + 2 h
x0
LM
N
f ( x) dx = 2h y0 + Δy0 +
Similarly,
z
z
1 2
Δ y0
6
OP
Q
=
2h
[6 y0 + 6( y1 − y0 ) + ( y2 − 2 y1 + y0 )]
6
=
h
( y0 + 4 y1 + y2 )
3
x0 + 4 h
x0 + 2 h
f ( x) dx =
h
(y + 4y3 + y4), ...... ,
3 2
h
( yn− 2 + 4 yn− 1 + yn )
3
Adding the above integrals, we get
x0 + nh
x0 + ( n − 2 ) h
z
x0 + nh
x0
f ( x) dx =
f ( x) dx =
h
[(y0 + yn) + 4(y1 + y3 + ... + yn–1)
3
+ 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
z
x0 + 3 h
x0
FG
H
f ( x) dx = 3h y0 +
Similarly,
z
3
3
1
Δy0 + Δ2 y0 + Δ3 y0
2
4
8
IJ
K
=
3h
[8y0 + 12(y1 – y0) + 6(y2 – 2y1 + y0) + (y3 – 3y2 + 3y1 – y0)]
8
=
3h
[y0 + 3y1 + 3y2 + y3]
8
z
x0 + 6 h
x0 + 3 h
x0 + 6 h
x0 + ( n − 3) h
f ( x) dx =
3h
[y3 + 3y4 + 3y5 + y6], ...
8
f ( x) dx =
3h
[yn–3 + 3yn–2 + 3yn–1 + yn]
8
Adding the above integrals, we get
z
x0 + nh
x0
f ( x) dx =
3h
[(y0 + yn) + 3(y1 + y2 + y4 + y5
8
+ ..... + 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
z
x0 + 4 h
x0
f ( x) dx = h
z LMN
4
0
y 0 + rΔy 0 +
+
LM
MN
OP
Q
r(r − 1)(r − 2)(r − 3) 4
Δ y 0 dr
4!
n( 2n − 3) 2
n( n − 2 ) 2 3
n
Δy 0 +
Δ y0 +
Δ y0
2
12
24
Fn
+G
H5
LM
N
= 4 h y0 + 2 Δy0 +
get
z
427
r(r − 1) 2
r(r − 1)(r − 2) 3
Δ y0 +
Δ y0
2!
3!
4
Similarly,
DIFFERENTIATION
| By Newton’s forward interpolation formula
= 4h y 0 +
=
AND
I
JK
Δ4 y 0
3n 3 11n 2
−
+
− 3n
2
3
4!
5 2
3
7 4
Δ y0 + Δ3 y0 +
Δ y0
3
2
90
OP
Q
OP
PQ
4
0
2h
(7y0 + 32y1 + 12y2 + 32y3 + 7y4)
45
x0 + 8 h
x0 + 4 h
f ( x) dx =
2h
(7y4 + 32y5 + 12y6 + 32y7 + 7y8) and so on.
45
Adding all these integrals from x0 to x0 + nh, where n is a multiple of 4, we
z
x0 + nh
x0
f ( x) dx =
2h
[7y0 + 32y1 + 12y2 + 32y3 + 14y4 + 32 y5
45
+ 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
z
x0 + 6 h
x0
f ( x) dx = h
AND
z LMN
6
0
STATISTICAL TECHNIQUES
y0 + rΔy0 +
r(r − 1) 2
r (r − 1)(r − 2) 3
Δ y0 +
Δ y0
2!
3!
+
r(r − 1)(r − 2)(r − 3) 4
r (r − 1)(r − 2)(r − 3)(r − 4) 5
Δ y0 +
Δ y0
4!
5!
+
r(r − 1)(r − 2)(r − 3)(r − 4)(r − 5) 6
Δ y0 dr
6!
LM
MN
= h ry0 +
+
F
GH
F
GH
1 r 5 3r 4 11r 3
−
+
− 3r 2
24 5
2
3
F
GH
1 Fr
5r
+
−
+ 17r
G
720 H 7
2
9
L
= 6h M y + 3Δy + Δ y
2
N
+
I
JK
IΔ y
JK
1 r3 r2 2
r2
−
Δy 0 +
Δ y0
2
2 3
2
4
4
0
6
0
2
5
0
I
JK
0
I
JK
225r 4 274 r 3
−
+
− 60 r 2 Δ6 y 0
4
3
+ 4 Δ3 y 0 +
+
LM
MN
41 4
Δ y0
20
11 5
41 6
Δ y0 +
Δ y0
20
840
6h
20 y 0 + 60Δy 0 + 90Δ2 y 0 + 80Δ3 y 0 + 41Δ4 y 0
20
+ 11Δ5 y 0 +
=
I
JK
− r 3 + r 2 Δ 3 y0
1 r6
35r 4 50r 3
− 2r 5 +
−
+ 12r 2 Δ5 y 0
120 6
4
3
7
=
OP
Q
1Fr
+ G
6H 4
41 6
Δ y0
42
3h
[20y0 + 60(y1 – y0) + 90(y2 – 2y1 + y0)
10
+ 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)]
OP
PQ
6
0
OP
Q
OP
Q
LM∵
N
OP
Q
41 ~
−1
42
NUMERICAL INTEGRATION
=
AND
DIFFERENTIATION
429
3h
[y + 5y1 + y2 + 6y3 + y4 + 5y5 + y6]
10 0
Similarly,
z
z
3h
[y + 5y7 + y8 + 6y9 + y10 + 5y11 + y12]
x0 + 6 h
10 6
...................................................................................................
...................................................................................................
x0 + 12 h
x0 + nh
x0 + ( n − 6 ) h
f ( x) dx =
f ( x) dx =
3h
[y + 5yn–5 + yn–4 + 6yn–3 + yn–2 + 5yn–1 + yn]
10 n–6
Adding the above integrals, we get
z
x0 + nh
x0
f ( x) dx =
3h
[y + 5y1 + y2 + 6y3 + y4 + 5y5 + 2y6
10 0
+ 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
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
Step
01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
Start of the program.
Input Lower limit a
Input Upper Limit b
Input number of sub intervals n
h=(b-a)/n
sum=0
sum=fun(a)+fun(b)
for i=1; i<n; i++
sum +=2*fun(a+i)
End Loop i
result =sum*h/2;
Print Output result
End of Program
Start of Section fun
temp = 1/(1+(x*x))
Return temp
End of Section fun.
430
COMPUTER-BASED NUMERICAL
5.14
FLOW-CHART FOR TRAPEZOIDAL RULE
AND
STATISTICAL TECHNIQUES
START
Define function y(x)
Get values x0, xn, n
h = (xn – x0)/n
s = y(x0) + y(xn)
Loop for i = 1 to n – 1
s + = 2 * y * (x0 + i * h)
End loop(i)
t = (h/2) * s
Print ‘‘soln.’’, t
STOP
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(“\n\n Enter the range - ”);
printf(“\n\n Lower Limit a - ”);
scanf(“%f” ,&a);
432
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
printf(“\n\n Upper Limit b - ");
scanf(“%f” ,&b);
//... Input Number of subintervals
printf(“\n\n 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;i<n;i++)
{
sum+=2*fun(a+i);
}
result=sum*h/2;
//... Output Section
printf(“n\n\n\n Value of the integral is %6.4f\t”,result);
//...Invoke User Watch Halt Function
printf(“\n\n\n 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
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
AND
DIFFERENTIATION
433
434
COMPUTER-BASED NUMERICAL
5.18
FLOW-CHART OF SIMPSON’S 3/8th RULE
AND
STATISTICAL TECHNIQUES
START
Define fn. f(x)
Get values x0, xn, n
h = (xn – x0)/n
Sum = 0
Sum = f(a) + f(b)
Loop for i = 1 to n
Is
i% 3 = 0
No
Sum + = 3 * f(a + i * h)
End loop i
Print sum
STOP
Yes
Sum + = 2 * f(a + i * h)
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
435
/*************************************************************
5.19 PROGRAM TO IMPLEMENT SIMPSON’S 3/8 th 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("\n\n Enter the range - ");
printf("\n\n Lower Limit a - ");
scanf("%f" ,&a);
436
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
printf("\n\n Upper Limit b - ");
scanf("%f" ,&b);
//...Input Number of Subintervals
printf("\n\n 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;i<n;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("\n\n\n\n Value of the integral is %6.4f\t",result);
//... Invoke User Watch Halt Function
printf("\n\n\n Press Enter to Exit");
getch();
}
//... Termination of Main Execution Thread
//... Function Body
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
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.
Step 02.
Start of the program.
Input Lower limit a
Step 03.
Step 04.
Input Upper limit b
Input number of subintervals n
Step 05.
Step 06.
h=(b–a)/n
sum=0
Step 07.
Step 08.
sum=fun(a)+4*fun(a+h)+fun(b)
for i=3; i<n; i + = 2
Step 09.
Step 10.
sum + = 2*fun(a+(i – 1)*h) + 4*fun(a+i*h)
End of loop i
Step 11.
Step 12.
result=sum*h/3
Print Output result
Step 13.
Step 14.
End of Program
Start of Section fun
Step 15.
temp = 1/(1+(x*x))
437
438
COMPUTER-BASED NUMERICAL
Step 16.
Step 17.
AND
STATISTICAL TECHNIQUES
Return temp
End of Section fun
5.22 FLOW-CHART OF SIMPSON’S 1/3rd RULE
START
Define fn y(x)
Get values of x0, xn, n
h = (xn – x0)/n
s = y0 + yn + 4y1
Loop for i = 3 to n – 1 step 2
s + = 4 * yi + 2 * yi + 1
End loop (i)
P = s * (h/3)
Print ''solution'', P
STOP
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
439
/* ***********************************************************
5.23 PROGRAM TO IMPLEMENT SIMPSON’S 1/3 rd 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("\n\n Enter the range - ");
440
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
printf("\n\n Lower Limit a - ");
scanf("%f" ,&a);
printf("\n\n Upper Limit b - ");
scanf("%f" ,&b);
//... Input Number of Subintervals
printf("\n\n 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;i<n;i+=2)
{
sum+=2*fun(a+(i-1)*h)+4*fun(a+i*h);
}
result=sum*h/3;
//... Output Section
printf("\n\n\n\n Value of the integral is %6.4f\t",result);
//... Invoke User Watch Halt Function
printf("\n\n\n 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
intervals.
z
1
0
x 3 dx considering five sub-
Sol. Dividing the interval (0, 1) into 5 equal parts, each of width h =
= 0.2, the values of f(x) = x3 are given below:
x:
f(x):
0
0
0.2
0.008
0.4
0.064
y0
y1
y2
By Trapezoidal rule, we have
z
1
0
x 3 dx =
=
0.6
0.216
0.8
0.512
1.0
1.000
y3
y4
y5
h
[(y0 + y5) + 2(y1 + y2 + y3 + y4)]
2
0.2
[(0 + 1) + 2(0.008 + 0.064 + 0.216 + 0.512)]
2
= 0.1 × 2.6 = 0.26.
Example 2. Evaluate
z
1
0
dx
using
1 + x2
(i) Simpson’s
1
1
rule taking h =
4
3
(ii) Simpson’s
1
3
rule taking h =
6
8
1
6
Hence compute an approximate value of π in each case.
(iii) Weddle’s rule taking h =
1− 0
5
442
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Sol. (i) The values of f(x) =
1
1+ x
2
at x = 0,
1 2 3
, , , 1 are given below:
4 4 4
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
z
z
Also
1
0
dx
1
0
1
rule,
3
1+ x
2
=
h
[(y0 + y4) + 4(y1 + y3) + 2y2]
3
=
16
1
(1 + 0.5) + 4
+ .64 + 2(0.8) = 0.785392156
17
12
dx
=
1 + x2
LM
N
RS
T
LM tan xOP
MN
PQ
1
–1
= tan –1 1 =
0
π~
– 0.785392156
4
∴
(ii) The values of f(x) =
1
1 + x2
at x = 0,
UV
W
OP
Q
π
4
⇒ π ~
– 3.1415686
1 2 3 4 5
, , , , , 1 are given below:
6 6 6 6 6
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
z
1
0
3
rule,
8
3h
dx
=
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
2
8
1+ x
NUMERICAL INTEGRATION
3
=
Also,
z
AND
DIFFERENTIATION
443
FG 1IJ
H 6 K LMFG 1 + 1IJ + 3 RS 36 + 9 + 9 + 36 UV + 2 FG 4 IJ OP
8 NH
2K
T 37 10 13 61 W H 5 K Q
= 0.785395862
1
0
dx
π
=
2
4
1+ x
π
= 0.785395862
4
∴
π = 3.141583
⇒
(iii) By Weddle’s rule, using the values as in (ii),
z
1
0
3h
dx
=
(y + 5y1 + y2 + 6y3 + y4 + 5y5 + y6)
2
10 0
1+ x
3
=
Since
z
FG 1IJ
H 6 K RS1 + 5 FG 36 IJ + 9 + 6 FG 4 IJ + 9 + 5 FG 36 IJ + 1 UV
H 37 K 10 H 5 K 13 H 61K 2 W
10 T
= 0.785399611
dx
1
0
1+ x
2
=
π
4
π
= 0.785399611
4
∴
π = 3.141598.
⇒
Example 3. Evaluate
z
6
dx
0
1 + x2
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
are given below:
1 + x2
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,
z
6
0
dx
h
=
[(y0 + y6) + 4(y1 + y3 + y5) + 2(y2 + y4)]
2
3
1+ x
=
1
3
LMFG 1 + 1 IJ + 4 FG 0.5 + 0.1 + 1 IJ + 2 FG 0.2 + 1 IJ OP
H 17 K Q
26 K
NH 37 K H
= 1.366173413.
(ii) By Simpson’s three-eighth rule,
z
6
0
3h
dx
=
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
8
1 + x2
=
3
8
LMFG 1 + 1 IJ + 3 FG .5 + .2 + 1 + 1 IJ + 2(.1)OP
17 26 K
NH 37 K H
Q
= 1.357080836.
(iii) By Trapezoidal rule,
z
6
0
dx
h
= [(y0 + y6) + 2(y1 + y2 + y3 + y4 + y5)]
1 + x2 2
=
1
2
LMFG 1 + 1 IJ + 2 FG.5 + .2 + .1 + 1 + 1 IJ OP
17 26 K Q
NH 37 K H
= 1.410798581.
(iv) By Weddle’s rule,
z
6
0
dx
1+ x
2
=
3h
[y + 5y1 + y2 + 6y3 + y4 + 5y5 + y6]
10 0
NUMERICAL INTEGRATION
LM
N
AND
DIFFERENTIATION
FG IJ
H K
1
1
1
3
+5
1 + 5(.5) + .2 + 6(.1) +
+
26
37
17
10
=
445
OP
Q
= 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
v
0
3.60
24
36
48
60
72
10.08 18.90 21.60 18.54 10.26
84
96
108
120
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
=v
dt
LMsOP
NQ
∴
t = 120
t=0
=
z
120
0
v dt
since the number of sub-intervals is 10 (even). Hence, by using Simpson’s
rule,
z
120
0
v dt =
1
rd
3
h
[(v0 + v10) + 4(v1 + v3 + v5 + v7 + v9) + 2(v2 + v4 + v6 + v8)]
3
=
12
[(0 + 9) + 4(3.6 + 18.9 + 18.54 + 5.4 + 5.4)
3
+ 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
x:
0.6
0.8
y:
1.23
1.58
z
2
0.6
y dx , where y is given by the following table:
1.0
1.2
1.4
1.6
1.8
2.0
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
z
2
0.6
y dx =
AND
STATISTICAL TECHNIQUES
h
[(y0 + y7) + 2(y1 + y2 + y3 + y4 + y5 + y6)]
2
0.2
[(1.23 + 12.45) + 2(1.58 + 2.03 + 4.32 + 6.25 + 8.36 + 10.23)]
2
| Here h = 0.2
= 7.922.
=
Example 6. Find
z
11
f(x) dx , where f(x) is given by the following table, using a
1
suitable integration formula.
x:
f(x):
1
2
3
4
5
6
7
8
9
10
11
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
rd rule.
3
z
11
1
f ( x) dx =
=
=
h
[(y0 + y10) + 4(y1 + y3 + y5 + y7 + y9) + 2(y2 + y4 + y6 + y8)]
3
1
[(543 + 95) + 4(512 + 489 + 400 + 310 + 172)
3
+ 2(501 + 453 + 352 + 250)]
1
[638 + 7532 + 3112] = 3760.67.
3
z
dx
by dividing the interval of integration into 8 equal
1+ x
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.
Example 7. Evaluate
Here,
0
y=
y0 = f(0) =
y3 = f
1
1
= f(x)
1+ x
1
= 1,
1+ 0
FG 3 IJ = 8 ,
H 8 K 11
y1 = f
FG 1IJ = 1 = 8 ,
H 8K 1 + 1 9
y2 = f
FG 2 IJ = 4
H 8K 5
FG 4 IJ = 2 ,
H 8K 3
y5 = f
FG 5 IJ = 8
H 8 K 13
8
y4 = f
NUMERICAL INTEGRATION
y6 = f
FG 6 IJ = 4 ,
H 8K 7
FG 7 IJ = 8
H 8 K 15
y7 = f
AND
447
DIFFERENTIATION
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
1
rd rule,
3
By Simpson’s
z
1
0
dx
h
= [(y0 + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)]
1+ x 3
1
24
=
LMFG 1 + 1IJ + 4 FG 8 + 8 + 8 + 8 IJ + 2 FG 4 + 2 + 4 IJ OP
NH 2 K H 9 11 13 15 K H 5 3 7 K Q
| Here h = 1/8
z
Since,
= 0.69315453
1
0
LM
MN
dx
= log e (1 + x)
1+ x
OP
PQ
1
= loge 2
0
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 =
z
7.52
7.47
f ( x) dx
with h = 0.01, the trapezoidal rule gives,
Area =
.01
[(1.93 + 2.06) + 2(1.95 + 1.98 + 2.01 + 2.03)]
2
= 0.09965.
448
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Example 9. Use Simpson’s rule for evaluating
z
0.3
−0.6
from the table given below:
x:
f(x) dx
– 0.6
– 0.5
– 0.4
– 0.3
– 0.2
– 0.1
0
.1
.2
.3
4
2
5
3
–2
1
6
4
2
8
f(x):
Sol. Since the number of subintervals is 9(a multiple of 3), we will use Simpson’s
3/8th rule here.
∴
z
0.3
−0.6
f ( x) dx =
3(.1)
[(4 + 8) + 3{2 + 5 + (– 2) + 1 + 4 + 2} + 2(3 + 6)]
8
= 2.475.
Example 10. Evaluate
z
2 −
1
e
1
x
2
dx using four intervals.
Sol. The table of values is:
x:
1
1.25
y=
e–x/2:
.60653
y0
.53526
y1
1.5
1.75
2
.47237
y2
.41686
y3
.36788
y4
Since we have four (even) subintervals here, we will use Simpson’s
rule.
∴
z
2 −
1
e
1
x
2
=
dx =
1
rd
3
h
[(y0 + y4) + 4(y1 + y3) + 2y2]
3
.25
[(.60653 + .36788) + 4(.53526) + .41686) + 2(.47237)]
3
= 0.4773025.
Example 11. Find
on integration.
z
6
0
3
ex
dx approximately using Simpson’s th rule
8
1+ x
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) =
ex
; y = f(0) = 1
1+ x 0
NUMERICAL INTEGRATION
449
DIFFERENTIATION
AND
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
z
6
0
ex
3h
dx =
[(y0 + y6) + 3(y1 + y2 + y4 + y5) + 2y3]
1+ x
8
=
=
3
8
LMF 1 + e I + 3 F e + e + e
MNGH 7 JK GH 2 3 5
6
2
4
+
I
JK
e5
e3
+2
6
4
OP
PQ
3
[(1 + 57.6327) + 3(1.3591 + 2.463 + 10.9196
8
+ 24.7355 + 2(5.0214)]
= 70.1652.
NOTE
z
ex
dx by using usual calculus method.
0 1+ x
Numerical integration comes to our rescue in such situations.
It is not possible to evaluate
6
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
=v
dt
⇒
LMsOP
NQ
t = 45
t=0
=
z
45
0
v dt
450
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Since the number of subintervals is 9 (a multiple of 3) hence by using
Simpson’s
z
FG 3 IJ
H 8K
45
0
th
rule,
v dt =
=
3h
[(v0 + v9) + 3(v1 + v2 + v4 + v5 + v7 + v8) + 2(v3 + v6)]
8
15
[(30 + 5) + 3(24 + 19 + 13 + 11 + 8 + 7) + 2(16 + 10)]
8
= 624.375 meters.
Hence the distance moved by the train in 45 seconds is 624.375 meters.
Example 13. Evaluate
z
4
0
dx
using Boole’s rule taking
1 + x2
(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,
z
4
0
y dx =
=
2h
[7y0 + 32y1 + 12y2 + 32y3 + 7y4]
45
LM
N
FG IJ
H K
= 1.289412 (approx.)
∴
z
4
0
FG IJ
H K
FG IJ FG IJ OP
H K H KQ
1
1
1
1
2(1)
7(1) + 32
+ 12
+ 32
+7
17
10
5
2
45
dx
= 1.289412.
1 + x2
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,
z
4
0
2h
[ 7 ( y 0 ) + 32 ( y1 ) + 12 ( y 2 ) + 32 ( y 3 ) + 7 ( y 4 )
45
ydx =
+ 7 ( y 4 ) + 32 ( y 5 ) + 12 ( y 6 ) + 32 ( y 7 ) + 7 ( y 8 )]
=
LM
N
= 1.326373
z
∴
4
0
FG IJ
H K
F4I
1 O
4
+ 32 G J + 12(.1) + 32 FG IJ + 7 FG IJ P
H 29 K
H 53 K H 17 K Q
1
4
+ 7(.2) + 7 (.2)
7(1) + 32(.8 ) + 12(.5) + 32
45
13
dx
= 1.326373
1 + x2
But the actual value is
z
4
dx
0
1 + x2
Error in result I
Error in result II
F
I
= G tan xJ = tan (4) = 1.325818
H
K
.
− 1.289412 I
F 1325818
=G
H 1.325818 JK × 100 = 2.746%
.
− 1.326373 I
F 1325818
=G
H 1.325818 JK × 100 = – 0.0419%.
4
−1
–1
0
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
STATISTICAL TECHNIQUES
AND
Find the approximate area of cross-section of the river using
(i) Boole’s rule.
1
rd rule.
3
Sol. The required area of the cross-section of the river
(ii) Simpson’s
z
=
80
0
y dx
Here the number of sub intervals is 8.
(i) By Boole’s rule,
z
80
0
y dx =
=
2h
[7y0 + 32y1 + 12y2 + 32y3 + 7y4 + 7y4
45
+ 32y5 + 12y6 + 32y7 + 7y8]
2 (10)
[7(0) + 32(4) + 12(7) + 32(9) + 7(12) + 7(12) + 32(15)
45
+ 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
z
80
0
y dx =
=
1
rd rule
3
h
[(y + y8) + 4(y1 + y3 + y5 + y7) + 2(y2 + y4 + y6)]
3 0
10
[(0 + 3) + 4(4 + 9 + 15 + 8) + 2(7 + 12 + 14)]
3
= 710
Hence the required area of the cross-section of the river = 710 sq. m.
Example 15. Evaluate
z
1.4
0.2
(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,
z
1.4
0.2
f ( x) dx =
=
3h
[y + 5y1 + y2 + 6y3 + y4 + 5y5 + y6 + y6
10 0
+ 5y7 + y8 + 6y9 + y10 + 5y11 + y12]
3
(0.1)[3.0295 + 14.2470 + 2.7975 + 16.9278 + 2.8976
10
+ 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
y:
1
0.9896
0.9589
0.75 1
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= π
z
1
0
y 2 dx
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)
[(1 + .7081) + 4(.9793 + .8261) + 2(.9195)]
3
= 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:
x:
1.257 1.39
1.5
1.65
1.52
1.65 1.809 1.962 2.123 2.295 2.462 2.650 2.827
1.8
1.95
2.1
Using the formula (0.018) T =
z
2.25
2.4
2.55
2.7
2.85
3
A
3.0
dx , calculate T, the time (in seconds)
x
for the level of the water to drop from 3.0 m to 1.5 m above the orifice.
1.5
Sol. Here h = 0.15
The table of values of x and the corresponding values of
x
y=
1.5
A
x
1.65
1.8
1.95
2.1
2.25
2.4
2.55
A
is
x
2.7
2.85
3
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
z
A
3
1.5
x
1
rd rule, we get
3
dx =
.15
[(1.025+1.632) + 4(1.081 + 1.182 + 1.308 + 1.438
3
+ 1.571) + 2(1.132 + 1.249 + 1.375 + 1.498)]
= 1.9743
Using the formula
(0.018)T =
We get
z
3
1.5
A
x
0.018T = 1.9743
dx
⇒ T = 110 sec. (approximately).
Example 18. Using the following table of values, approximate by Simpson’s
rule, the arc length of the graph y =
x:
1 + x4
x4
:
FG IJ
H K
1
1
between the points (1, 1) and 5,
5
x
1
2
3
4
5
1.414
1.031
1.007
1.002
1.001.
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
455
Sol. The given curve is
y=
1
x
∴
dy
1
=− 2
dx
x
∴
ds
dy
= 1+
dx
dx
FG IJ
H K
2
= 1+
1
x
=
4
1 + x4
x4
FG 1IJ
H 5K
∴ The arc length of the curve between the points (1, 1) and 5,
=
z
=
h
[(1.414 + 1.001) + 4(1.031 + 1.002) + 2(1.007)]
3
=
1
(2.415 + 8.132 + 2.014) = 4.187
3
5
1 + x4
dx
x4
1
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
z
z
z
z
1
x=
0
1
0
1
and
y=
0
xy dx
y dx
y
. y dx
2
=
1
y dx
0
z
z
1
0
1
0
OP
PP
PP
y
dx P
2
PP
y dx P
Q
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,
z
z
z
1
xy dx =
0
y2
1
dx =
2
12
1
0
1
0
From (50),
25
(1/4)
[(0 + 1) + 4(1 + 3) + 2(4)] =
12
3
y dx =
LMFG 1 + 1IJ + 4(8 + 8) + 2(32)OP = 129
NH 2 2 K
Q 12
50
1
[(1 + 1) + 4(4 + 4) + 2(8)] =
12
12
x=
25/12 1
= = 0.5
50/12 2
y=
129/12 129
=
= 2.58
50/12
50
∴ Centroid is the point (0.5, 2.58).
(i) We know that
V = Volume = π
∴ Required volume = π.2
z
z
1
0
y2 dx
129
y2
= 67.5442
dx = 2π ×
12
2
1
0
(ii) We know that moment of inertia of the area about the x-axis is given by
M.I. =
1
ρ
3
z
b
a
y 3 dx
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
z
1
0
y3 dx =
Reqd. M.I. =
∴
769
1
[(1 + 1) + 4(64 + 64) + 2(512)] =
6
12
FG IJ = 769 ρ = 42.7222 ρ.
H K 18
1
769
ρ
3
6
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
48
=−
dt
A
h
Estimate the time taken for the water level to fall from 14 to 10 m above the
sluices.
dh
48
=−
dt
A
Sol. From
dt = −
Integration yields,
t= −
Here, y =
A
h
1
48
h , we have
A dh
48 h
z
10
A
14
h
dh =
1
48
z
14
A
10
h
dh
. The table of values is as follows:
h:
10
11
12
13
14
A:
950
1070
1200
1350
1530
322.6171
346.4102
374.4226
408.9097
A
h
: 300.4164
458
COMPUTER-BASED NUMERICAL
AND
Applying Simpson’s
time t =
STATISTICAL TECHNIQUES
1
rd rule, we have
3
1 1
. [(300.4164 + 408.9097)
48 3
+ 4(322.6171 + 374.4226) + 2(346.4102)]
= 29.0993 minutes.
ASSIGNMENT 5.2
1.
z
2
1
1
dx by Simpson’s rd rule with four strips and determine the error by
1 x
3
direct integration.
Evaluate
2.
Evaluate the integral
3.
Evaluate
4.
Evaluate
5.
Evaluate
z
z
z
5.2
0
cos θ dθ by dividing the interval into 6 parts.
log e x dx by Simpson’s
4
90°
30°
5.2
4
z
π/2
3
th rule. Also write its programme in ‘C’ language.
8
log 10 sin x dx by Simpson’s
1
rd rule by dividing the interval into 6 parts.
3
log e x dx using
(i) Trapezoidal rule
6.
(ii) Weddle’s rule.
Evaluate using Trapezoidal rule
(i)
z
π
0
t sin t dt
z
7
(ii)
z
2
−2
t dt
5 + 2t
x2 log x dx taking 4 strips.
7.
Evaluate
8.
The velocities of a car running on a straight road at intervals of 2 minutes are given
below:
3
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
z
1
0
cos x dx using h = 0.2.
NUMERICAL INTEGRATION
10. Evaluate
z
z
4
AND
DIFFERENTIATION
459
ex dx by Simpson’s rule, given that e = 2.72, e2 = 7.39, e3 = 20.09, e4 = 54.6
0
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
rd rule,
3
5
0
dx
dividing the range into 10 equal parts.
4x + 5
12. Use Simpson’s rule, taking five ordinates, to find an approximate value of
to 2 decimal places.
13. Evaluate
x:
z
π/2
2
x−
1
1
dx
x
sin x dx given that
0
sin x :
z
0
π/12
π/6
π/4
π/3
5π/12
π/2
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.
LMHint: Here step - size h = 2 OP
60 Q
N
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
rd rule, find the
3
velocity of the rocket at t = 80 seconds.
t(sec):
0
10
20
30
40
50
60
70
2
f(cm/sec ): 30
31.63 33.34 35.47 37.75 40.33 43.25 46.69
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,
Compute
z
26
20
G(25) = 100.41, G(26) = 101.24.
G(x) dx by Simpson’s and Weddle’s rule, respectively.
80
50.67.
460
18.
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
Using the data of the following table, compute the integral
rule:
19.
20.
0.5
xy dx by Simpson’s
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
z
x2
1.
1
rd rule by dividing the
0 1+ x
3
range of integration into four equal parts. Also find the error.
Use Simpson’s rule dividing the range into ten equal parts to show that
Find the value of loge 2 from
z
log (1 + x 2 )
1
1 + x2
0
21.
z
1.1
dx using Simpson’s
3
dx = 0.173
Find by Weddle’s rule the value of the integral
z
I=
1.6
0.4
by taking 12 sub-intervals.
z
0.7
x 1/2 e − x dx approximately by using a suitable formula.
22.
Evaluate
23.
(i) Compute the integral
0.5
x
dx
sinh x
2
π
I=
Using Simpson’s
z
1
e− ( x
0
2
/2)
dx
1
rd rule, taking h = 0.125.
3
(ii) Compute the value of I given by
I=
Using Simpson’s
24.
Using Simpson’s
(i)
(ii)
z
z
1.8
1.0
π/2
0
0.2
2
e− x dx
FG 1IJ rule with four subdivisions.
H 3K
1
rd rule, Evaluate the integrals:
3
e x + e− x
dx
2
dx
1
sin x + cos2 x
4
2
z
1.5
(taking h = 0.2)
NUMERICAL INTEGRATION
25. Evaluate
z
1
AND
DIFFERENTIATION
461
sin x + cos x dx correct to two decimal places using seven ordinates.
0
26. Use Simpson’s three-eighths rule to obtain an approximate value of
z
0.3
0
(1 − 8 x3 )1/2 dx
27. Evaluate
28. Evaluate
29. Using
z
z
1/2
dx
using Weddle’s rule.
1 − x2
0
x2 + 2
1
x2 + 1
0
dx using Weddle’s rule correct to four places of decimals.
3
th Simpson’s rule,
8
Evaluate:
z
6
dx
0
1 + x4
1
rd rule to evaluate the integral
3
30. Apply Simpson’s
I=
z
.
1
0
e x dx 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=
z
(1 + x + x2 ) dx
Using Simpson’s rule by taking interval size h as 1. Write a C program to implement.
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. Simplify 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
Also,
STATISTICAL TECHNIQUES
ΔF(x) = f(x) gives
F(x1) – F(x0) = f(x0)
Similarly,
On adding,
F( x2 ) − F( x1 ) = f ( x1 )
F( xn ) − F( xn −1 ) = f ( xn −1 )
F(xn) – F(x0) =
n− 1
∑
(52)
f ( xi )
i=0
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)
LF
I O
h D
h D
= MG 1 + hD +
+
+ ......J − 1P f ( x)
2!
3!
K PQ
MNH
L h D + h D + ......OP f ( x )
= MhD +
2!
3!
MN
PQ
L F hD + h D + ......I OP f ( x )
= (hD) M1 + G
JK PQ
MN H 2 ! 3 !
L F hD + h D + ......I
1
= D M1 − G
JK
h
MN H 2 ! 3 !
O
I
( − 1) ( − 2 ) F h D h D
+
+
+ ......J + ......P f ( x )
G
PQ
2!
H 2! 3!
K
L hD + h D − h D + ......OP f (x)
1
= D M1 −
h
Q
N 2 12 720
2
2
2
2
3
3
−1
3
2
−1
−1
2
2
−1
2
2
−1
F(x) =
1
h
z
f ( x) dx −
−1
3
2
2
2
2
4
4
1
h
h3
f ( x) +
f ′ ( x) −
f ′ ″ ( x) + ......
2
12
720
(53)
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
463
Putting x = xn and x = x0 in (53) and then subtracting, we get
F(xn) – F(x0) =
1
h
z
xn
f ( x) dx −
x0
1
h
[f(xn) – f(x0)] +
[f ′(xn) – f ′(x0)]
2
12
−
n− 1
1
∑ f (x ) = h
⇒
i
i =0
z
xn
f ( x) dx −
x0
−
⇒
1
h
z
xn
f ( x) dx =
x0
n− 1
∑
f ( xi ) +
i =0
h
1
[ f ( xn ) − f ( x0 )] +
[ f ′ ( xn ) − f ′ ( x0 )]
2
12
h3
[ f ′ ″ ( xn ) − f ′ ″ ( x0 )] + ......
720
z
xn
x0
y dx =
h3
[ f ′ ″ ( xn ) − f ′ ″ ( x0 )] − ......
720
(54)
h
[ y 0 + 2 y1 + 2 y 2 + ...... + y n ]
2
−
=
| using (52)
h
1
[ f ( xn ) − f ( x0 )] −
[ f ′ ( xn ) − f ′ ( x0 )]
2
12
+
or
h3
[f ′″(xn) – f ′″(x0)] + ......
720
h2
h4
( yn ′ − y 0 ′ ) +
( y n ′ ″ − y 0 ′ ″ ) − ......
12
720
h
[( y 0 + y n ) + 2( y1 + y 2 + ...... + y n −1 )]
2
h2
h4
( yn ′ − y 0 ′ ) +
( y n ′ ″ − y 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
z
b
a
f ( x) dx
(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
z
1
F(u) du = W1 F(u1) + W2 F(u2) + ...... + Wn F(un)
−1
n
=
∑W
i
F (ui )
(57)
i=1
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
(58)
F(u) = C0 + C1 u + C2 u2 + C3 u3 + ...... + C2n – 1 u2n – 1
Then from (57),
z
1
F(u) du =
−1
z
1
−1
(C 0 + C 1 u + C2 u 2 + C3 u3 + ...... + C2 n − 1 u 2 n − 1 ) du
= 2 C0 +
2
2
C2 + C4 + .......
3
5
(59)
Set u = ui in (58), we get
F(ui) = C0 + C1 ui + C2 ui2 + C3 ui3 + ...... + C2n – 1 ui2n – 1
From (57),
z
1
F(u) du = W1 (C0 + C1 u1 + C2 u12 + ........ + C2n – 1 u12n – 1)
−1
+ W2 (C0 + C1 u2 + C2 u22 + ...... + C2n – 1 u22n – 1)
+ W3 (C0 + C1 u3 + C2 u32 + ...... + C2n – 1 u32n – 1) + ......
+ Wn (C0 + C1 un + C2 un2 + ...... + C2n – 1 un2n – 1)
which can be written as
z
1
F(u) du = C0 (W1 + W2 + ....... + Wn) + C1(W1 u1 + W2 u2
−1
+ W3 u3 + ...... + Wn un) + C2(W1 u12 + W2 u22
+ W3 u32 + ...... + Wn un2) + ......
+ C2n – 1(W1 u12n – 1 + W2 u22n – 1
+ W3 u32n – 1 + ...... + Wn un2n – 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 u12 + W2 u22 + W3 u32 + ........ + Wn un2 =
2
3
W1 u12n – 1 + W2 u22n – 1 + W3 u32n – 1 + ........ + Wn un2n – 1 = 0
in 2n unknowns Wi and ui (i = 1, 2, ......, n).
U|
||
|V
||
||
W
(61)
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
0.53846 93101
0.47862 86705
0.90617 98459
0.23692 68851
5
In general case, the limits of integral in (56) have to be changed to those in
(57) by transformation
x=
1
1
u (b – a) + (a + b).
2
2
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.
466
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
5.28 EVALUATION OF PRINCIPAL VALUE INTEGRALS
Consider,
I(f) =
z
f ( x)
dx
x−t
b
a
(62)
which is singular at t = x.
Its Principal value,
P(I) = lim
ε→0
LM
N
z
t−ε
a
f ( x)
dx +
x−t
z
b
t+ε
= I(f) (for t < a or t > b)
Set
OP
Q
f ( x)
dx ; a < t < b
x−t
(63)
x = a + uh and t = a + kh in (1), we get
z
P(I) = P
f (a + hu)
du
u−k
p
0
(64)
Replacing f(a + hu) by Newton’s forward difference formula at x = a and
simplifying, we get
∞
I(f) =
Δ j f (a)
Cj
j!
∑
j=0
(65)
where the constants Cj are given by
Cj = P
In (66),
(u)0 = 1,
z
p
0
(u) j
u−k
du
(66)
(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
n
In(f) =
∑
j=0
Δ j f (a)
Cj
j!
(67)
We obtain rules of orders 1, 2, 3, ...... etc. by setting n = 1, 2, 3, ......
respectively.
1
(i) Two point rule (n = 1): I1(f) =
∑
j=0
Δ j f ( a)
Cj
j!
= C0 f(a) + C1 Δ f(a)
= (C0 – C1) f(a) + C1 f (a + h)
(68)
NUMERICAL INTEGRATION
AND
467
DIFFERENTIATION
(ii) Three-point rule (n = 2):
2
I2 (f) =
Δ j f (a)
Cj = C0 f(a) + C1 Δ f(a) + C2 Δ2 f(a)
j!
∑
j=0
FG
H
= C0 − C1 +
IJ
K
1
C 2 f(a) + (C1 – C2) f (a + h)
2
+
1
C f (a + 2h)
2 2
(69)
In above relations (68) and (69), values of Cj are given by,
p− k
k
C0 = log e
C1 = p + C0 k
C2 =
1 2
p + p (k – 1) + C0 k (k – 1) .
2
EXAMPLES
Example 1. Apply Euler-Maclaurin formula to evaluate
1
1
1
1
+
+
+ ....... +
.
2
2
2
51
53
55
99 2
Sol. Take
y =
1
, x0 = 51, h = 2, n = 24, we have
x2
y′ = −
2
x3
,
y′″ = −
24
x5
Then from Euler-Maclaurin’s formula,
z
99
dx
51
2
x
=
LM
N
2 1
2
2
2
1
+ 2 + 2 + ...... +
+ 2
2
2
2 51
53
55
97
99
–
∴
1
2
51
+
2
53
2
+
2
55
=
2
z
LM
N
dx
51
2
x
+
LM
N
(2) 2 (− 2) (− 2)
(2) 4 (− 24) (− 24)
−
−
+
12 (99) 3 (51) 3
720 (99) 5
(51) 5
+ ...... +
99
OP
Q
OP
Q
2
97
LM
N
2
+
OP
Q
1
99 2
OP
Q
2
1
1
8
−
–
3
3 (51)
(99) 3
15
LM 1
N (51)
5
−
OP
Q
1
+......
(99) 5
468
COMPUTER-BASED NUMERICAL
⇒
2
LM 1
N 51
2
+
STATISTICAL TECHNIQUES
AND
1
1
1
+ 2 + ...... +
2
53
55
99 2
OP
Q
99
dx
1
51
2
=
z
x
+
FG 1
H 51
2
+
99
2
IJ + 2 LM 1 − 1 OP
K 3 N (51) (99) Q
1 O
8 L 1
−
–
M
P + ......
(99) Q
15 N (51)
3
3
5
⇒
1
(51) 2
+
1
(53) 2
+
=
1
+ ...... +
(55) 2
1
2
z
99
dx
51
2
x
+
1
(99) 2
LM
N
1
1
1
+
2
(99) 2
2 (51)
OP
Q
FG − 1 IJ
H xK
99
+
51
LM
N
1
1
2 (51) 2
+
LM
N
1
1
1
−
3
3 (51)
(99)3
LM
N
OP
Q
OP + ......
Q
1 O 1L 1
+
P + M − (991) OPQ
(99) Q 3 N (51)
4 L 1
1 O
−
–
P + .......
15 MN (51)
(99) Q
–
1
=
2
5
4
1
1
−
5
15 (51)
(99) 5
2
3
5
3
5
= 0.00475 + 0.000243 + 0.0000022 + ......
= 0.00499 approximately.
Example 2. Using Euler-Maclaurin’s formula, find the value of loge 2 from
z
1
0
dx
.
1+ x
1
, x = 0, n = 10, h = 0.1,
1+ x 0
Sol. Take
y=
we have
y′ = −
1
(1 + x)
2
and
y′″ =
−6
(1 + x) 4
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
469
Then from Euler-Maclaurin’s formula, we have
z
1
0
LM
N
1
2
2
2
2
dx
0.1
+
+
+
+
=
1
+
0
1
+
01
1
+
0
2
1
+
0
3
1
+
0.4
.
.
.
1+ x
2
+
LM
N
(0.1) 2
(−1)
( − 1)
−
12
(1 + 1) 2 (1 + 0) 2
–
z
Also,
1
0
dx
= log (1 + x)
1+ x
4
4
−
π/2
sin x dx =
0
1
= log 2
0
z
π/2
0
sin x dx using the Euler-Maclaurin formula.
h
[y + 2y1 + 2y2 + ....... + 2yn – 1 + yn]
2 0
+
To evaluate the integral, let us take h =
h2
h4
h6
+ ......
+
+
12 720 30240
π
.
4
Then we obtain,
z
π/2
0
sin x dx =
π
π2
π4
(0 + 2 + 0) +
+
+ ......
8
192
184320
π
π2
π4
(approximately)
+
+
4 192 184320
=
= 0.785398 + 0.051404 + 0.000528 = 0.837330
If we take
z
π/2
0
(− 6)
(1 + 0) 4
loge 2 = 0.693149.
Example 3. Evaluate
z
OP + (0.1) LM (− 6)
Q 720 N (1 + 1)
= 0.693773 – 0.000625 + 0.000001 = 0.693149
Hence
Sol.
2
2
2
2
2
1
+
+
+
+
+
1 + 0.5 1 + 0.6 1 + 0.7 1 + 0.8 1 + 0.9 1 + 1
h=
sin x dx =
π
, we get
8
π
[0 + 2(0.382683 + 0.707117 + 0.923879) + 1]
16
= 0.987119 + 0.012851 + 0.000033 = 1.000003.
OP
Q
OP
Q
470
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Example 4. Use Euler-Maclaurin’s formula to prove that
n
∑x
2
=
1
n (n + 1) (2n + 1)
.
6
Sol. By Euler–Maclaurin’s formula,
z
xn
x0
y dx =
h
h2
[y0 + 2y1 + 2y2+ ......... + 2yn – 1 + yn] –
(yn′ – y0′)
2
12
+
⇒
h4
h6
(yn′″ – y0′″) –
(yn(v) – y0(v)) + .....
720
30240
1
1
y + y1 + y2 + ...... + yn – 1 +
y
2 0
2 n
=
z
1
h
xn
x0
3
y dx + h (y ′ – y ′) – h (y ′″ – y ′″)
n
0
n
0
12
720
+
Here
h5
(yn(v) – y0(v)) – .......
30240
y(x) = x2, y′(x) = 2x and h = 1
∴ From (70),
Sum =
z
n
x 2 dx +
1
1 2
1
(n + 1) +
(2n – 2)
2
12
∵
=
Example 5. Find
z
1
0
x dx by Gaussian formula.
x=
n2
1
1 1
y0 = , yn =
2
2 2
2
1 3
1
1
n (n + 1) (2n + 1)
(n – 1) + (n2 + 1) +
(n – 1) =
.
3
2
6
6
Sol. Let us change the limits as
1
1
1
u(1– 0) + (1 + 0) = (u + 1)
2
2
2
This gives,
1
I=
4
where
(70)
z
1
(u + 1) du =
4
−1
1
F(ui) = ui + 1
n
∑W
i
i=1
F(ui )
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
[(– 0.86114 + 1) (0.34785 ) + (– 0.33998 + 1) (0.65214)
4
+ (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
z
h
0
f(x) dx = hf
FG h IJ is exact for
H 2K
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
z
h
0
and
f ( x) dx = kh
(71)
FG h IJ = hk
H 2K
(72)
hf
∴ From (71) and (72),
z
h
0
FG h IJ
H 2K
f ( x) dx = hf
If f(x) is a polynomial of degree one then
z
f(x) = ax + b
h
0
f ( x) dx =
z
h
0
( ax + b) dx =
ah 2
+ bh
2
FG h IJ = h FG ah + bIJ = ah
H 2K H 2 K 2
hf
2
(73)
(74)
+ bh
From (73) and (74), we have the result.
Now,
z
h
0
y dx =
z
h
0
LM y
MN
0
+ ( x − x0 ) y0 ′ +
OP
PQ
( x − x0 ) 2
y0 ″ + ..... dx
2
472
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
h2
h3
y0 ′ +
y0 ″ + .....
2!
3!
= hy0 +
(75)
(where x – x0 = h)
LM
F hI
hf G J = h M y
H 2 K MM
MN
Also,
FG h IJ
H 2K
h
+ y ′+
0
0
2
2
2!
OP
y ″ + .....P
PP
PQ
(76)
0
(75) – (76) gives the truncation error
FG
H
IJ
K
1 1
= h3 6 − 8 y0″ (nearly)
h3
1 3
y0 ″ <
h
24
24
Now,
1 3
h < 10–3
24
⇒
–
⇒
3
0.024 < h <
3
or
| h3 | < 24 × 10– 3 = 0.024
0.024 .
Example 7. Find λ such that the quadrature formula
+ Cf(1) may be exact for polynomials of degree 3.
Sol.
Set
z
1
0
f ( x)
x
z
1
0
f(x)
x
dx ≈ Af(0) + Bf(λ)
dx = Af(0) + Bf(λ) + Cf(1)
f(x) = 1, x, x2 and x3 in turn,
2=A+B+C
2
= Bλ2 + C
5
(77)
2
= Bλ + C
3
(78)
(79)
2
= Bλ3 + C
7
(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
z
1
f(x) dx = W0 f(– α) + W1 f(0) + W2 f(α) + R, α ≠ 0
–1
Vanishes when f(x) is an arbitrary polynomial of degree at most 3. Show
that the precision is five when α =
Compute the error R when α =
Sol.
z
1
–1
3
and three otherwise.
5
3
.
5
f ( x) dx = W0 f(– α) + W1 f(0) + W2 f(α) is exact for f(x) = 1, x, x2, x3.
f(x) = 1
⇒
f(x) = x
⇒
f(x) = x2
⇒
f(x) = x3
⇒
W0 + W1 + W2 = 2
W0 = W2
2W0α2 =
W0 = W2
Solving, we find
W0 = W2 =
Choosing
f(x) =
x4,
1
3α
2
,
FG
H
W1 = 2 1 −
1
3α 2
we get
2
2 2
= 2W0α4 =
α
5
3
⇒
α=
3
5
With this value, f(x) = x5 gives exact value.
∴ The precision is 5.
2
3
IJ
K
474
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
If
α≠
3
the precision is 3.
5
With
α=
3
, we have
5
z
1
f ( x ) dx =
–1
LM F
MN GH
I F 3 I OP + 8 f(0) + R
JK GH 5 JK PQ 9
5
3
+f
f −
9
5
Hence the error term R is given by
R=
=
2
f
7!
(vi)
(0) + terms involving higher order derivatives
f (vi) (0)
.
2520
Example 9. Determine a, b and c such that the formula
z
h
0
RS
T
f(x) dx = h af(0) + bf
FG hIJ + cf (h)UV
H 3K
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)
FG
H
IJ
K
For f(x) = x:
bh
h2
+ ch
=h
3
2
For f(x) = x2:
bh 2
h3
+ ch 2
= h
9
3
F
GH
⇒ a+b+c=1
I
JK
⇒
b
1
+c=
3
2
⇒
b
1
+c=
9
3
Solving above eqns., we get
a = 0, b =
3
1
,c=
4
4
Truncation error of the formula =
and
c=
z
h
0
x
3
c
f ′″(ξ);
3!
F bh
dx – h G
H 27
3
0<ξ<h
I
JK
4
+ ch3 = – h
36
NUMERICAL INTEGRATION
AND
DIFFERENTIATION
475
1
1
Hence, we have
Truncation error
=−
h4
f ′″ (ξ) = 0 (h4 ).
216
ASSIGNMENT 5.3
1.
Using Euler-Maclaurin’s formula, evaluate
(i)
1
1
1
1
+
+
+ ....... +
400
402
404
500
n
2.
∑x
Prove that
3
=
1
3.
RS n (n + 1) UV
T 2 W
1
(201) 2
n
∑i
4
=
0
(205) 2
+ ...... +
(299)2
.
applying Euler-Maclaurin’s formula.
z
1
dx
0
1 + x2
.
n5 n 4 n3
n
.
+
+
+
5
2
3
30
1
1
1
1
1
+
+
+
+
.
100 101 102 103 104
Sum the series
6.
Determine α, β, γ and δ such that the relation
y′
FG a + b IJ = αy (a) + βy (b) + γ y″ (a) + δ y″ (b)
H 2 K
is exact for polynomials of as high degree as possible.
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.
Find the values a, b, c such that the truncation error in the formula
z
h
−h
f ( x) dx = h [af(– h) + bf (0) + af(h) + h2 c {f ′ (– h) – f ′ (h)}]
is minimized.
n
9.
+
2
5.
8.
1
(203)2
Find the sum of the fourth powers of first n natural numbers by means of EulerMaclaurin’s formula.
OR
Prove that,
7.
+
Use Euler-Maclaurin’s formula to find the value of π from the formula
π
=
4
4.
(ii)
i=1
∞
10. Evaluate:
n
∑ i +∑ i
Show that
7
∑
m=0
i=1
1
(10 + m) 2
5
F
= 2 G∑ i
GH
n
i=1
3
I
JJ
K
2
.
by applying Euler-Maclaurin’s formula.
4
P a r t
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, AdamsMoulton Formula, Stability in the Solution of Ordinary Differential
Equations.
Chapter
6.1
6
NUMERICAL SOLUTION
OF ORDINARY
DIFFERENTIAL EQUATIONS
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
= f (x, y)
dx
(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.
479
480
COMPUTER-BASED NUMERICAL
6.2
INITIAL-VALUE AND BOUNDARY-VALUE PROBLEMS
AND
STATISTICAL TECHNIQUES
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
= f (x, y); y(x0) = y0
(3)
dx
Integrating eqn. (3) between the limits x0 and x and the corresponding
limits y0 and y, we get
z z
z
y
y0
⇒
or,
dy =
y – y0 =
x
x0
x
x0
f ( x, y) dx
f ( x, y) dx
y = y0 +
z
x
x0
f ( x, y) dx
(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 +
z
x
x0
f ( x, y0 ) dx
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
z
z
x
y(2) = y0 +
f { x , y (1) } dx
x0
Proceeding in this way, we obtain y(3), y(4), ......., y(n–1) and y(n) where
y(n) = y0 +
x
f { x , y ( n −1) } dx with y(x0) = y0
x0
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
x2
= 2
dx y + 1
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
where y = y0 = 0
dy
x2
= f(x, y) = 2
dx
y +1
at x = x0 = 0
We have first approximation,
z
z
z
z FG
x
y(1) = y0 +
=0+
Second approximation,
x0
x
0
=0+
x2
1
dx = x3
0+1
3
x
y(2) = y0 +
x0
x
0
f ( x, y0 ) dx
f { x, y(1) } dx
x2
I
H JK
x3
3
dx
2
+1
(5)
NUMERICAL SOLUTION
L
= Mtan
N
x3
3
−1
FG
H
OP
Q
OF
x
= tan–1
0
IJ
K
3
=
1 3 1 1 3
x –
x
3
3 3
=
1 3
1 9
x –
x + .....
3
81
ORDINARY DIFFERENTIAL EQUATIONS
483
x3
3
+ ......
(6)
From (5) and (6), we see that y(1) and y(2) agree to the first term
x3
. To find
3
the range of values of x so that the series with the term 1 x3 alone will give the
3
result correct to three decimal places, we put
which gives,
Hence,
and
1 9
x ≤ .0005
81
x9 ≤ .0405 or x ≤ 0.7
1
(.25)3 = .005
3
y(.25) =
1
(0.5)3 = .042
3
To find y(1.0), we make use of eqn. (6) which gives,
y(0.5) =
1
1
–
= 0.321.
3 81
Example 2. Use Picard’s method to obtain y for x = 0.2. Given:
y(1.0) =
Sol. Here
dy
= x – y with initial condition y = 1 when x = 0.
dx
f(x, y) = x – y, x0 = 0, y0 = 1
We have first approximation,
z
z
z FGH
x
y(1) = y0 +
Second approximation,
0
x
y(2) = y0 +
=1+
0
x
0
f ( x, y0 ) dx = 1 +
z
f { x, y (1) } dx = 1 +
x − 1+ x −
I
JK
x
0
( x − 1) dx = 1 – x +
z
x
0
{ x − y (1) } dx
x3
x2
dx = 1 – x + x2 –
6
2
x2
2
484
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Third approximation,
z
z FGH
x
y(3) = y0 +
=1+
0
x
0
f { x , y ( 2 ) } dx = 1 +
x − 1 + x − x2 +
= 1 – x + x2 –
Fourth approximation,
z
F
z GH
x
y(4) = y0 +
=1+
0
x
0
Fifth approximation,
z
z FGH
x
y(5) = y0 +
=1+
0
x
0
When
0
I
JK
{ x − y( 2) } dx
x3 x 4
+
3
24
x − 1 + x − x2 +
z
x
0
{ x − y (3) } dx
I
JK
x3 x 4
−
dx
3
24
x3 x4
x5
+
−
3
12 120
f { x, y ( 4) } dx = 1 +
x − 1 + x − x2 +
= 1 – x + x2 –
x
x3
dx
6
f { x, y (3) } dx = 1 +
= 1 – x + x2 –
z
z
x
0
{ x − y (4) } dx
I
JK
x3 x 4
x5
−
+
dx
3
12 120
x3 x 4 x5
x6
+
−
+
3
12 60 720
x = 0.2, we get
y(1) = .82,
y(2) = .83867,
y(4) = .83746,
Thus, y = .837
y(3) = .83740
y(5) = .83746
when x = .2.
Example 3. Use Picard’s method to obtain y for x = 0.1. Given that:
dy
= 3x + y2; y = 1 at x = 0.
dx
Sol. Here
f(x, y) = 3x + y2, x0 = 0, y0 = 1
NUMERICAL SOLUTION
y(1) = y0 +
First approximation,
=1+
z
z
OF
x
0
485
f ( x, y0 ) dx
0
x
ORDINARY DIFFERENTIAL EQUATIONS
(3 x + 1) dx
3 2
x
2
=1+x+
Second approximation,
y(2) = 1 + x +
5 2 4 3 3 4
9 5
x + x + x +
x
2
3
4
20
Third approximation,
y(3) = 1 + x +
5 2
23 4 25 5
x + 2x3 +
x +
x
2
12
12
+
68 6 1157 7 17 8
47 9
x +
x +
x +
x
45
1260
32
240
+
27 10
81 11
x +
x
400
4400
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.
dy y − x
, find the value of y at x = 0.1 using Picard’s method.
=
dx y + x
y(0) = 1.
Example 4. If
Given that
Sol. First approximation,
z
z FGH
x
y(1) = y0 +
=1+
0
x
0
y0 − x
dx = 1 +
y0 + x
IJ
K
z FGH
x
0
IJ
K
1− x
dx
1+ x
2
− 1 dx
1+ x
= 1 – x + 2 log (1 + x)
Second approximation,
y(2) = 1 + x – 2
z
x
0
x dx
1 + 2 log (1 + x)
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
dy
= 1 + xy with x0 = 2, y0 = 0 using Picard’s method of
dx
successive approximations.
Example 5. Solve
y(1) = y0 +
Sol. Here,
y(2) = 0 +
z
z
x
2
x
z
x
2
[1 + x (0)] dx = x – 2
{1 + x( x − 2)} dx
2
F
= Gx − x
H
f ( x, y0 ) dx = 0 +
2
x3
+
3
I
JK
x
=–
2
x3
2
+ x – x2 +
3
3
And third approximation,
y(3) = 0 +
z
x
2
{1 + x y ( 2) } dx
22
x3 x4 x5
1
+ x – x2 +
−
+
15
3
3
4
15
which is the required solution.
=–
Example 6. Obtain y when x = 0.1, x = 0.2, given that
the result with exact value.
dy
= x + y; y(0) = 1. Check
dx
dy
= f(x, y) = x + y, x0 = 0, y0 = 1
dx
Now first approximation,
Sol. We have
y(1) = 1 +
Second approximation,
y(2) = 1 +
Third approximation,
z
z FGH
x
0
(1 + x) dx = 1 + x +
x
0
x + 1+ x +
y(3) = 1 + x + x2 +
When
I
JK
x3
x2
dx = 1 + x + x2 +
6
2
x3 x 4
+
3
24
x = .1, y(1) = 1.105
y(2) = 1.11016
y(3) = 1.11033
x2
2
(closer appr.)
NUMERICAL SOLUTION
When
OF
ORDINARY DIFFERENTIAL EQUATIONS
487
x = .2,
y(3) = 1.2427
We can continue further to get the better approximations. Now we shall
obtain exact value.
dy
– y = x is the given differential equation. General sol. is
dx
ye–x = – e–x (1 + x) + c
| I.F. = e–x
Putting
y = 1, x = 0
∴
y = – x – 1 + 2ex
When
x = 0.1,
y = 1.11034
x = 0.2,
y = 1.24281
and
we obtain, c = 2
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.
dy
= 1 + xy, y(0) = 1 which passes through
dx
(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
Example 7. Find the solution of
dy
= f(x, y) = 1 + xy; y(0) = 1
dx
y = y0 = 1 at x = x0 = 0
i.e.,
Here,
y(1) = 1 + x +
x2
2
y(2) = 1 + x +
x2 x3 x 4
+
+
2
3
8
y(3) = 1 + x +
x2 x3 x 4 x5 x6
+
+
+
+
2
3
8
15 48
y(4) = y(3) +
when x = 0,
y = 1.000
x = 0.1,
∴
x7
x8
+
105 384
y(1) = 1.105,
y = 1.105
x = 0.2,
y(2) = 1.1053 ....
(correct up to 3 decimals)
y(1) = 1.220,
y(2) = 1.223 = y(3)
488
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
y = 1.223
∴
x = 0.3,
(correct up to 3 decimals)
y = 1.355 as y(2) = 1.355 = y(3)
x = 0.4, y = 1.505
x = 0.5,
(similarly)
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 DIFFERENTIAL EQUATIONS
dy
dz
= φ(x, y, z) and
= f(x, y, z)
dx
dx
be the simultaneous differential eqns. with initial conditions y(x0) = y0; z(x0) = z0.
Picard’s method gives
Let
z
z
y(1) = y0 +
y(2) = y0 +
x
x0
x
x0
φ( x, y0 , z0 ) dx ;
z(1) = z0 +
φ{ x, y(1) , z (1) } dx ;
z(2) = z0 +
and so on as successive approximations.
z
z
x
x0
x
x0
f ( x, y0 , z0 ) dx
f { x, y (1) , z (1) } dx
EXAMPLES
Example 1. Approximate y and z by using Picard’s method for the particular
dy
dz
= x + z,
= x – y2 given that y = 2, z = 1 when x = 0.
solution of
dx
dx
Sol. Let
φ(x, y, z) = x + z, f(x, y, z) = x – y2
Here,
x0 = 0, y0 = 2, z0 = 1
We have,
dy
= φ(x, y, z) ⇒ y = y0 +
dx
z
x
x0
φ( x, y, z) dx
NUMERICAL SOLUTION
Also,
ORDINARY DIFFERENTIAL EQUATIONS
dz
= f(x, y, z) ⇒ z = z0 +
dx
First approximation,
z
z
z
z
z
z
z FGH
x
y(1) = y0 +
=2+
z(1) = z0 +
and
OF
=1+
Second approximation,
x0
x
=2+
=2+
x
x0
x
=1+
φ( x, y0 , z0 ) dx = 2 +
0
x
x0
x
0
z
x
0
( x + z0 ) dx
x2
2
f ( x, y0 , z0 ) dx = 1 +
( x − 4) dx = 1 – 4x +
z
x
0
( x − y0 2 ) dx
x2
2
φ{ x, y (1) , z (1) } dx
{ x + z (1) } dx
x
0
=2+x–
z(2) = z0 +
f ( x, y, z) dx
x0
( x + 1) dx = 2 + x +
0
y(2) = y0 +
z
x
489
x + 1 − 4x +
I
JK
x2
dx
2
3 2 x3
x +
2
6
z
LM
z MN
x
x0
x
0
f { x , y (1) , z (1) } dx
F
x I
x − G2 + x +
2 JK
H
2
2
OP
PQ dx
3 2
x4
x5
x – x3 –
–
.
2
4
20
Example 2. Solve by Picard’s method, the differential equations
= 1 – 4x –
dy
= z,
dx
dz
= x3 (y + z)
dx
1
at x = 0. Obtain the values of y and z from III
2
approximation when x = 0.2 and x = 0.5.
where
y = 1,
z =
490
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
φ(x, y, z) = z, f(x, y, z) = x3(y + z)
1
Here
x0 = 0, y0 = 1, z0 =
2
First approximation,
Sol. Let
y(1) = y0 +
=1+
z(1) = z0 +
z
x
0
φ( x, y0 , z0 ) dx = 1 +
z
1
+
2
z
1
x
2
z
x
0
f ( x, y0 , z0 ) dx =
1 3 x4
+
.
2 2 4
Second approximation,
x
0
x
0
z0 dx
x 3 ( y0 + z0 ) dx
=
y(2) = 1 +
=1+
z(2) =
1
+
2
=
1
+
2
z
x
0
z (1) dx = 1 +
x
3 5
+
x
2 40
z
z
x
0
x
0
z FGH
x
0
IJ
K
1 3 4
+ x dx
2 8
x 3 { y( 1) + z ( 1) } dx
x3
FG 3 + x + 3 x IJ dx
H2 2 8 K
4
1 3 4 x5
3 8
+ x +
+
x
2 8
10 64
Third approximation,
=
y(3) = 1 +
=1+
z
x
0
z( 2) dx = 1 +
z FGH
x
0
I
JK
1 3x 4 x5 3x8
+
+
+
dx
2
8
10 64
x
3 5 x6 3x9
+
+
x +
2 40
60 576
z
z
z(3) =
1
+
2
=
1
+
2
=
1 3 x4 1 x5 3 x8
7 x9
3 x 12
+ .
+ .
+ .
+
.
+
.
2 2 4
2 5
8 8
40 9
64 12
x
0
x
0
x 3 { y ( 2) + z( 2) } dx
x3
RS 3 + x + 3 x
T2 2 8
4
+
UV
W
7 5
3 8
x +
x dx
40
64
NUMERICAL SOLUTION
=
when x = 0.2
OF
ORDINARY DIFFERENTIAL EQUATIONS
491
7 9
3 12
1 3 4 x5
3 8
+ x +
x +
x +
x
+
360
768
2 8
10 64
3
(0.2)6
3
(0.2)5 +
+
(0.2)9
40
60
576
= 1.100024 (leaving higher terms)
y(3) = 1 + 0.1 +
1 3
7
3
(.2) 5
3
+ (.2)4 +
+
(.2)8 +
(.2)9 +
(.2)12
2 8
360
768
10
64
= .500632 (leaving higher terms)
z(3) =
when x = 0.5
.5
3
(.5) 6
3
+
(.5)5 +
+
(.5)9
2 40
60
576
= 1.25234375
y(3) = 1 +
1 3
7
3
(.5) 5
3
+ (.5)4 +
+
(.5)8 +
(.5)9 +
(.5)12
2 8
360
768
10
64
= .5234375.
z(3) =
ASSIGNMENT 6.1
1.
dy
= x – y2, y(0) = 0
dx
Calculate y(0.2) by Picard’s method to third approximations and round-off the value at
the 4th place of decimals.
For the differential equation
dy
= log (x + y); y(0) = 1. Use Picard’s method.
dx
2.
Find y(0.2) if
3.
Employ Picard’s method to obtain the solution of
dy
= x2 + y2 for x = 0.1 correct to four
dx
decimal places, given that y = 0 when x = 0.
4.
Find an approximate value of y when x = 0.1 if
dy
= x – y2 and y = 1 at x = 0 using
dx
Picard’s method.
5.
6.
7.
dy
= 2x – y, y(0) = 0.9 at x = 0.4 by Picard’s method with three
dx
iterations and compare the result with the exact value.
Solve numerically
dy
= 1 + y2 and y (0) = 0.
dx
Explain Picard’s method of successive approximation for numerical solution of ordinary
differential equations.
Employ Picard’s method to find y (0.2) and y (0.4) given that
492
8.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Approximate y and z by using Picard’s method for the solution of simultaneous differential
equations
dy
dz
= 2x + z,
= 3xy + x2z
dx
dx
with y = 2, z = 0 at x = 0 up to third approximation.
9.
Using Picard’s method, obtain the solution of
dy
= x(1 + x3y), y (0) = 3
dx
Tabulate the values of y(0.1), y(0.2).
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
pe
)
,y1
(f x 1
g(x
Y
slo
e
lop
,
f(x 0
s
Q2
y 0)
y2
Q1
P0
y1
y0
O
)
dy
= f ( x, y) , y(x0) = y0
(7)
dx
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=
6.8
x0
x1
x2
X
The eqn. of the tangent at P0(x0, y0) is
y – y0 =
⇒
FG dy IJ
H dx K
P0
( x – x0 ) = f(x , y ) (x – x )
0
0
0
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.
dy
changes
dx
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.
A great disadvantage of this method lies in the fact that if
NOTE
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
494
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
7. Print x0,y0
8. If x<xn then
x0=x
y0=y
ELSE
9. Next i
10. Stop
6.10
FLOW-CHART OF EULER’S METHOD
START
F(x, y) = (x – y)/(x + y)
Input x0, y0, h, xn
n = (xn – x0)/h + 1
For i = 1, n
y = y0 + h*F(x0, y0)
x=x+h
Print x0, y0
If
x < xn
Yes
x0 = x
y0 = y
STOP
No
NUMERICAL SOLUTION
6.11
OF
ORDINARY DIFFERENTIAL EQUATIONS
PROGRAM OF EULER’S METHOD
#include<stdio.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
if(x<xn)
Y=%f",x0,y0);
{
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
495
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
L
(x1, y1)
B
L2
L
(x0, y0)
A
O
x0
X
x1
LM f ( x , y ) + f ( x , y ) OP
2
MN
PQ
L f (x , y ) + f (x , y ) OP
+h M
2
MN
PQ
0
y1 = y0 + (x1 – x0)
= y0
L1
(1)
(x1, y1 )
0
0
0
1
1
(1)
1
(1)
1
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
497
A generalised form of Euler’s modified formula is
y1(n+1) = y0 +
h
[f(x0, y0) + f{x1, y1(n)}] ; n = 0, 1, 2, ......
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
6.14
FLOW-CHART OF MODIFIED EULER’S METHOD
AND
STATISTICAL TECHNIQUES
START
F(x) = (x – y)/(x + y)
Input x(1), y(1), h, xn
yp = y(1) + h*F(x(1), y(1))
itr = (xn – x(1))/h
Print x(1), y(1)
For i = 1, itr
x(i + 1) = x(i) + h
For n = 1, 50
yc(n + 1) = y(i) + (h/2*(F(x(i), y(i)) +
F(x(i + 1), yp))
Print n, yc(n + 1)
p = yc(n + 1) – yp
If
abs(p) < 0.0001
No
yp = yc(n + 1)
y(i + 1) = yc(n + 1)
Print x(i + 1), yp
STOP
Yes
NUMERICAL SOLUTION
6.15
OF
ORDINARY DIFFERENTIAL EQUATIONS
PROGRAM OF MODIFIED EULER’S METHOD
#include<stdio.h>
#include<math.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("\n\n X=%f Y=%f\n",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("\n\n X=%f Y=%f\n",x[i+1], yp);
}
return;
}
499
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
N=1
N=2
X=0.000000
Y=0.980400
Y=0.980400
X=0.020000
N=1
N=2
Y=0.961584
Y=0.961598
N=1
X=0.040000
Y=0.943572
N=2
Y=0.943593
X=0.060000
Y=1.000000
Y=0.980400
Y=0.961584
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
dy y – x
=
with y = 1 for x = 0. Find y approximately for
dx y + x
x = 0.1 by Euler’s method.
Example 1. Given
Sol. We have
y– x
dy
= f(x, y) =
; x0 = 0, y0 = 1, h = 0.1
y+ x
dx
Hence the approximate value of y at x = 0.1 is given by
y1 = y0 + hf(x0, y0)
= 1 + (.1) +
FG 1 – 0 IJ = 1.1
H 1 + 0K
| using yn+1 = yn + hf(xn, yn)
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)
At xB = 0.04,
FG 1 – 0 IJ = 1.02
H 1 + 0K
y2 = y1 + hf(x1, y1)
FG 102
. – .02 I
H 1.02 + .02 JK = 1.0392
F 1.0392 – .04 IJ = 1.0577
y = 1.0392 + (.02) G
H 1.0392 + .04 K
F 1.0577 – .06IJ = 1.0756
y = 1.0577 + (.02) G
H 1.0577 + .06 K
F 1.0756 – .08IJ = 1.0928
y = 1.0756 + (.02) G
H 1.0756 + .08 K
= 1.02 + (.02)
At xC = .06,
3
At xD = .08,
4
At xE = .1,
5
Hence y = 1.0928 when x = 0.1
E
Y
D
C
A
O
A¢
B
B¢
C¢
D¢
E¢
X
dy
= 1 – y with the initial condition x = 0, y = 0
dx
using Euler’s algorithm and tabulate the solutions at x = 0.1, 0.2, 0.3.
Example 2. Solve the equation
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
Again,
AND
STATISTICAL TECHNIQUES
y2 = y1 + hf(x1, y1)
= 0.1 + (0.1) (1 – .1)
= 0.1 + .09 = .19
y(0.2) = 0.19
∴
y3 = y2 + hf(x2, y2)
Again,
= .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
= x +| y|= f(x, y)
dx
with initial condition y = 1 at x = 0 for the range 0 ≤ x ≤ 0.6 in steps of 0.2.
Sol. Here
∴
We have
f(x, y) = x + | y | ; x0 = 0, y0 = 1,
h = .2
f(x0, y0) = x0 + | y 0 | = 0 + 1 = 1
y1(1) = y0 + hf(x0, y0)
= 1 + (.2) . 1 = 1.2
∴
f(x1, y1(1)) = x1 + | y 1(1) |
= 0.2 + | 1.2 | = 1.2954
The second approximation to y1 is
LM f (x , y ) + f { x , y } OP
2
MN
PQ
1 + 1.2954 I
= 1 + (0.2) FG
H 2 JK = 1.2295
y1(2) = y0 + h
0
0
1
( 1)
1
NUMERICAL SOLUTION
Again,
So,
f{x1, y1(2)} = x1 + | y1
We have
Then
Since,
Now,
ORDINARY DIFFERENTIAL EQUATIONS
| = 0.2 +
= 1.3088
12295
.
0.2
[1 + 1.3088] = 1.2309
2
f{x1, y1(3)} = 0.2 +
1.2309 = 1.309
.2
[1 + 1.309] = 1.2309
2
y1(4) = y1(3) hence y1 = 1.2309
y2(1) = y1 + hf(x1, y1)
y1(4) = 1 +
= 1.2309 + (0.2) [0.2 +
1.2309 ]
= 1.4927
f{x2, y2(1)} = x2 +
|∵ x1 = 0.2
y2 ( 1) = 0.4 +
1.4927
= 1.622
Then,
y2(2) = y1 +
|∵ x2 = 0.4
h
[f(x1, y1) + f{x2, y2(1)}]
2
= 1.2309 +
Now,
503
h
[f(x0, y0) + f{x1, y1(2)}]
2
y1(3) = y0 +
=1+
(2 )
OF
y2(3) = y1 +
0.2
[(.2 + 1.2309 ) + 1.622] = 1.524
2
h
[ f ( x1, y1 ) + f { x2 , y2 (2) }]
2
= 1.2309 +
0.2
[(.2 + 1.2309 ) + (.4 + 1524
.
)]
2
= 1.5253
0.2
[(.2 + 1.2309 ) + (.4 + 1.5253 )]
2
hence y2 = 1.5253
y2(4) = 1.2309 +
Since,
y2(4) = y2(3)
Now,
y3(1) = y2 + hf(x2, y2)
= 1.5253 + (0.2) [.4 +
y3(2) = y2 +
] = 1.8523
15253
.
h
[f(x2, y2) + f{x3, y3(1)}]
2
= 1.5253 +
= 1.8849
0.2
[(.4 + 1.5253 ) + (.6 + 18523
.
)]
2
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.
dy
= log10 (x + y) with the initial condition that y = 1
dx
when x = 0. Find y for x = 0.2 and x = 0.5 using Euler’s modified formula.
Example 4. Given that
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 +
=1+
Also,
y1(3) = 1 +
h
[f(x0, y0) + f{x1, y1(1)}]
2
.2
[0 + log (1.2)] = 1.0079
2
.2
[0 + log (.2 + 1.0079)] = 1.0082
2
.2
[0 + log (.2 + 1.0082)] = 1.0082
2
y1(4) = y1(3) hence y1 = 1.0082
y1(4) = 1 +
Since,
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
Now,
y2(2) = y1 +
(∵ h = .5 – .2 = .3 here)
h
[f(x1, y1) + f{x2, y2(1)}]
2
= 1.0082 +
.3
[log (.2 + 1.0082) + log (.5 + 1.0328)]
2
= 1.0082 + 0.0401 = 1.0483
Also,
.3
[log (.2 + 1.0082) + log (.5 + 1.0483)]
2
= 1.0082 + .0408 = 1.0490
y2(3) = 1.0082 +
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
Similarly,
y2(4) = 1.0490
Since,
y2(3) = y2(4) hence, y2 = 1.0490.
505
dy
= x – y2 ; y(.2) = 0.2, find y(.4) by modified Euler’s
dx
method correct to 3 decimal places, taking h = 0.2.
Example 5. Given :
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 – y02 = 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
[f(x0, y0) + f{x1, y1(1)}]
2
.2
[.1996 + .3964] = .0796 ~
− .080
2
f{x1, y1(2)} = x1 – [y1(2)]2 = .4 – (.08)2 = .3936
= .02 +
Now,
∴
y1(3) = y0 +
= .02 +
h
[f(x0, y0) + f{x1, y1(2)}]
2
.2
[.1996 + .3936] = .07932 ~
− .079
2
f{x1, y1(3)} = x1 – [y1(3)]2 = .4 – (.079)2 = .3938
∴
y1(4) = y0 +
h
[f(x0, y0) + f{x1, y1(3)}]
2
.2
[.1996 + .3938] = .0793 ~
− .079
2
hence y1 = .079.
= .02 +
Since y1(3) = y1(4)
ASSIGNMENT 6.2
1.
2.
Find y for x = 0.2 and x = 0.5 using modified Euler’s method, given that
dy
= log e ( x + y) ; y(0) = 1
dx
Taking h = .05, determine the value of y at x = 0.1 by Euler’s modified method, given
that,
dy
= x2 + y; y(0) = 1
dx
506
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
dy
= x2 + y, y(0) = 1, find y(.02), y(.04) and y(.06) using Euler’s modified method.
dx
3.
Given
4.
Apply Euler’s method to the initial value problem
dy
= x + y, y(0) = 0 at x = 0 to x = 1.0
dx
taking h = 0.2.
5.
Use Euler’s method with h = 0.1 to solve the differential equation
dy
= x2 + y2, y(0) = 1
dx
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
=2–
dx
y = 2 when x = 1. (Take h = 0.05).
7.
8.
where
dy
=x+ y
dx
with the initial condition x0 = 0, y0 = 1. Give the correct result up to 4 decimal places.
Use Euler’s modified method to compute y for x = .05 and .10. Given that
Using Euler’s method, compute y(0.04) for the differential eqn.
h = 0.01.
9.
FG y IJ
H xK
Compute y(0.5) for the differential eqn.
dy
= y2 – x2 with y(0) = 1 using Euler’s method.
dx
10. Find y(2.2) using modified Euler’s method for
11. Given
dy
= – y; y(0) = 1. Take
dx
dy
= – xy2; y(2) = 1. Take h = .1.
dx
dy
= x 3 + y , y( 0) = 1. Compute y (0.02) by Euler’s method taking h = 0.01.
dx
dy
– y
=
when y(0.3) = 2.
dx 1 + x
Convert up to four decimal places taking step length h = 0.1.
12. Find y(1) by Euler’s method from the differential equation
6.16
TAYLOR’S METHOD
Consider the differential equation
dy
= f(x, y)
dx
with the initial condition y(x0) = y0.
UV
W
(9)
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
( x − x0 ) 2
( x − x0 ) 3
y0″ +
y0′″ + ......
2!
3!
where dashes denote differentiation with respect to x.
y(x) = y0 + (x – x0) y0′ +
(10)
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
507
Differentiating (9) successively with respect to x, we get
∴
FG
H
IJ
K
y″ =
∂f ∂f dy ∂f
∂f
∂
∂
f
+
=
+f
=
+f
∂x ∂y dx ∂x
∂y
∂x
∂y
y″′ =
d
∂
∂
+f
(y″) =
dx
∂x
∂y
=
FG
H
∂2f
∂x 2
+
IJ FG ∂f + f ∂f IJ
K H ∂x ∂y K
FG IJ
H K
∂f ∂f
∂2 f
∂2 f
∂f
+f
+f
+f
∂x ∂y
∂x∂y
∂y∂x
∂y
(11)
2
+ f2
∂2f
∂y 2
(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 − x0 ) 2
y0″
2!
+
Putting
( x − x0 ) 3
y0″′ + .......
3!
(13)
x = x1 (= x0 + h) in (13), we get
y1 = y(x1) = y0 + hy0′ +
h3
h2
y0″ +
y ″′ + .......
3! 0
2!
(14)
Here y0′, y 0″, y 0″′, ...... 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
h3
y1″ +
y ″′ + .......
2!
3! 1
Proceeding, we get
yn = yn –1 + hyn–1′ +
h2
h3
yn–1″ +
y ″′ + ........
2!
3 ! n–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
and
with initial conditions
dy
= f(x, y, z)
dx
(15)
dz
= φ(x, y, z)
dx
(16)
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
and
y1 = y0 + hy0′ +
h3
h2
y0″ +
y ″′ + ......
3! 0
2!
(17)
z1 = z0 + hz0′ +
h2
h3
z0″ +
z ″′ + ......
2!
3! 0
(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′ +
h3
h2
y1″ +
y ′″ + ......
3! 1
2!
h2
h3
z1 ″ ′ + .......
z1″ +
2!
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.
and
z2 = z1 + hz1′ +
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
509
EXAMPLES
Example 1. Use Taylor’s series method to solve
dy
= x + y; y(1) = 0
dx
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 ′ = x 0 + y 0 = 1
⇒
y″ = 1 + y′
i.e.,
y0″ = 1 + y0′ = 2
⇒
y″′ = y″
i.e.,
y0″′ = y0″ = 2
i.e.,
y0(iv) = 2
i.e.,
y0(v) = 2
⇒
y(iv)
⇒
y(v) = y(iv)
= y″′
By Taylor’s series, we have
y1 = y0 + hy0′ +
h2
h3
h4
y0″ +
y0″′ +
y (iv) + ......
2!
3!
4! 0
y(1 + h) = 0 + (0.1) 1 +
⇒
(0.1)4
(0.1) 2
(0.1)3
2+
2+
2 + ......
4!
2!
3!
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
h3
y1″ +
y ″′ + ......
2!
3! 1
= 0 . 11 + (0.1) (1.21) +
⇒
y(1.2) = 0.232 (app.)
( 0 . 1) 2
(2.21) + ......
2
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.
dy
= – xy2, y (0) = 2. Calculate y(0. 2) by
dx
Taylor’s series method retaining four non-zero terms only.
Example 2. For the differential eqn.,
Sol. Here
x0 = 0, y0 = 2 Also y′ = – xy2
Taylor’s series for y(x) is given by
y(x) = y0 + xy0′ +
x2
x3
x 4 (iv)
y0″ +
y0″′ +
y
2
6
24 0
x5
y (v) + .......
(19)
120 0
The values of the derivatives y0′, y0″, ......., etc. are obtained as follows:
y′ = – xy2
y0′ = – x0y02 = 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).
∴
∴
x2
x4
x6
(– 4) +
(48) +
(– 1440) + ......
2
24
720
= 2 – 2x2 + 2x4 – 2x6 + .......
y(x) = 2 +
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
= x – y2 and y(0) = 1. Also find y(0.2).
dx
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
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) =
511
y0(iv) = 34
– 2yy′″ – 6y′y″
y0(v) = – 186
y(v) = – 2yy(iv) – 8y′y′″ – 6y″2
UV
= – 10996 W only for y(0.2)
y(vi) = – 2yy(v) – 10y′y(iv) – 20 y″y′″
y0(vi) = 1192
y(vii) = – 2yy(vi) – 12y′y(v) – 50 y″y(iv)
y0(vii)
– 20 y′″2
Using these values, Taylor’s series becomes
3 2 4 3 17 4 31 5
x – x +
x –
x + ......
2
3
12
20
x = 0.1 in (20), we get
(20)
y(x) = 1 – x +
Put
y(0.1) = 0.91379 ~
− 0.9138
To determine y(0.2), we have
(upto four decimal places)
3 2 4 3 17 4 31 5 1192 6 10996 7
x – x +
x –
x +
x –
x + ........
2
3
12
20
720
5040
= 0.8512 (correct to four decimal places).
y(x) = 1 – x +
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
Also,
x0 = 2, y0 = 2
y′ = 1 –
y
x
y0′ = 0
2 1
=
4 2
y″ = –
y′
y
+ 2
x x
y0″ = – 0 +
y″′ = −
y ′′ 2 y ′ 2 y
+ 2 − 3
x
x
x
y0″′ =
−3
4
y′′′ 3 y ′′ 6 y′ 6 y
+ 2 − 3 + 4
x
x
x
x
y0(iv) =
3
and so on.
2
y(iv) = –
Putting these values in Taylor’s series, we get
y(2 + h) = 2 +
h 2 h3 h 4
+ .......
−
+
4
8
16
512
COMPUTER-BASED NUMERICAL
Put
AND
STATISTICAL TECHNIQUES
h = 0.1, we get
y (2.1) = 2.00238 (correct to 5 decimal places).
dy
= 2y + 3ex , y(0) = 0. Also check the value.
dx
x0 = 0, y0 = 0
Example 5. Find y(1) for
Sol. Here
y′(x) = 2y + 3ex
y0′ = 3,
y0″ = 9,
y″(x) = 2y′ + 3ex
y0″′ = 21,
y0(iv) = 45
y0(v) = 93,
y0(vi) = 189
y0(vii) = 381,
y0(viii) = 765
:
:
:
:
y(viii) (x) = 2y(vii) + 3ex
Now,
y(h) = 3h +
9 2 7 3 15 4 31 5 21 6
127 7
h + h +
h +
h +
h +
h
2
2
8
40
80
1680
+
Put
17 8
h + .......
896
h = 1, y(1) = 14.01
Exact solution.
Solution is
dy
– 2y = 3ex
dx
ye–2x = – 3e–x + c
x = 0, y = 0
∴
ye–2x = – 3e–x + 3
⇒
y = 3(e2x – ex)
∴ c=3
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
Also
Hence,
OF
ORDINARY DIFFERENTIAL EQUATIONS
513
z′ = 1, z″ = 3, z″′ = 3
y(x) = x +
x3
3
and z(x) = 1 + x +
3 2 1 3
x +
x.
2
2
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 –
4.
Using Taylor series method, solve
5.
6.
2x
; y(0) = 1. Also compute y(0.1).
y
dy
= x2 – y, y(0) = 1 at x = 0.1, 0.2, 0.3 and 0.4.
dx
Compare the values with exact solution.
dy
dz
= x + z,
= x – y2 with y(0) = 2, z(0) = 1 to get y(0. 1), y(0. 2), z(0. 1) and
dx
dx
z(0. 2) approximately by Taylor’s algorithm.
Solve
1
Given the differential equation dy =
with y(4) = 4
dx x 2 + y
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
= f(x, y); y (x0) = y0
dx
Euler’s method gives
(21)
y1 = y0 + hf(x0, y0) = y0 + hy0′
(22)
Expanding by Taylor’s series, we get
y1 = y(x0 + h) = y0 + hy0′ +
h2
y ″ + .......
2! 0
(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 RungeKutta 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
= f (x, y); y(x0) = y0 as
dx
y1 = y0 + δy
where
Here,
h
δy = (k1 + 4k2 + k3)
6
k1 = f (x0, y0)
RS
T
k2 = f x0 +
k
h
, y0 + 1
2
2
UV
W
(24)
UV
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)
FG
H
= hf FG x
H
IJ
K
k I
+ J
2K
k2 = hf x0 +
k
h
, y0 + 1
2
2
k3
h
, y0
2
0
+
2
k4 = hf (x0 + h, y0 + k3)
1
(k + 2k2 + 2k3 + k4)
6 1
taken in the given order.
Δy =
Then,
x1 = x0 + h and y1 = y0 + Δy
U|
||
||
V|
||
||
W
(25)
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)
FG
H
F
= hf G x
H
IJ
K
k I
+ J
2K
k2 = hf x1 +
k
h
, y1 + 1
2
2
k3
h
, y1
2
1
+
2
k4 = hf (x1 + h, y1 + k3)
1
(k + 2k2 + 2k3 + k4)
6 1
and similarly for the next intervals.
This method is also simply termed as Runge-Kutta’s method.
Δy =
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
6.19.2 Flow-Chart of Runge-Kutta Method
START
F(x) = (x – y)/(x + y)
Input x0, y0, h, xn
n = (xn – x0)/h
x = x0
y = y0
For i = 0, n
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
#include<stdio.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");
517
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
X=0.040000
Y=0.980000
Y=0.960816
X=0.060000
X=0.080000
Y=0.942446
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
519
ORDINARY DIFFERENTIAL EQUATIONS
6.20 RUNGE-KUTTA METHOD FOR SIMULTANEOUS FIRST ORDER
EQUATIONS
Consider the simultaneous equations
dy
= f1(x, y, z)
dx
dz
= f2 (x, y, z)
dx
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)
FG
H
k2 = hf1 x0 +
IJ
K
F h k , z + l IJ
l = hf G x + , y +
H 2
2
2K
k
l I
,z + J;
+
2
2K
k
l I
h
l = hf FG x + , y +
,z + J
H 2
2
2K
k
l
h
, y0 + 1 , z0 + 1 ;
2
2
2
2
FG
H
k3 = hf1 x0 +
h
, y0
2
2
0
3
2
0
0
1
0
1
2
2
0
0
2
0
2
k4 = hf1(x0 + h, y0 + k3 , z0 + l3);
l4 = hf2(x0 + h, y0 + k3 , z0 + l3)
k=
1
(k + 2k2 + 2k3 + k4);
6 1
1
(l + 2l2 + 2l3 + l4)
6 1
z1 = z0 + l
l=
Hence
y1 = y0 + k,
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
dy
= x + y with initial condition y(0) = 1 by
dx
Runge-Kutta rule, from x= 0 to x = 0.4 with h = 0.1.
Example 1. Solve the equation
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
FG
H
F
= hf G x
H
IJ = 0.1 (0.05 + 1.05) = 0.11
K
k I
+ J = 0.1105
2K
k2 = hf x 0 +
h
k
, y0 + 1
2
2
k3
h
, y0
2
0
+
2
k4 = hf (x0 + h, y0 + k3) = 0.12105
∴
Thus,
Δy =
1
(k + 2k2 + 2k3 + k4) = 0.11034
6 1
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
FG
H
F
= hf G x
H
IJ = 0.13208
K
k I
+ J = 0.13263
2K
k2 = hf x1 +
h
k
, y1 + 1
2
2
k3
h
, y1
2
1
+
2
k4 = hf (x1 + h, y1 + k3) = 0.14429
∴
Hence
1
(k + 2k2 + 2k3 + k4) = 0.132460
6 1
x2 = 0.2 and y2 = y1 + Δy = 1.11034 + 0.13246 = 1.24280
Δy =
Similarly, for finding y3, we have
k1 = hf (x2, y2) = 0.14428
k2 = 0.15649
k3 = 0.15710
k4 = 0.16999
Repeating the above
process
NUMERICAL SOLUTION
∴
and for
OF
ORDINARY DIFFERENTIAL EQUATIONS
521
y3 = 0.13997
y4 = y(0.4), we calculate
k1 = 0.16997
k2 = 0.18347
k3 = 0.18414
k4 = 0.19838
∴
y4 = 1.5836
dy
= y – x, y(0) = 2. Find y(0.1) and y(0.2) correct to four
dx
decimal places (use both II and IV order methods).
Example 2. Given
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
∴
Thus,
1
(k + k2) = 0.205
2 1
x1 = x0 + h = 0.1 and y1 = y0 + Δy = 2.205
Δy =
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
∴
Thus,
Hence
1
(k + k2) = 0.216025
2 1
x2 = x1 + h = 0.2 and y2 = y1 + Δy = 2.4210
Δy =
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
1
(k + 2k2 + 2k3 + k4) = 0.2052
6 1
∴
Δy =
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
FG
H
F
= hf G x
H
k2 = hf x1 +
k3
and
1
IJ = 0.21605
K
k I
+ J = 0.216323
2K
k
h
, y1 + 1
2
2
+ h / 2, y1
2
k4 = hf (x1 + h, y1 + k3) = 0.221523
1
(k + 2k2 + 2k3 + k4) = 0.21613
6 1
∴
Δy =
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,
Example 3. Solve
y(0.2) = 2.4213.
dy
dz
= yz + x,
= xz + y;
dx
dx
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
FG
H
k2 = hf1 x0 +
k
l
h
, y0 + 1 , z0 + 1
2
2
2
IJ
K
= hf1(0.05, 0.95, – 0.95) = – 0.08525
FG
H
l2 = hf2 x0 +
k
l
h
, y0 + 1 , z0 + 1
2
2
2
IJ
K
= hf2 (0.05, 0.95, – 0.95) = 0.09025
NUMERICAL SOLUTION
FG
H
k3 = hf1 x0 +
OF
ORDINARY DIFFERENTIAL EQUATIONS
k
l
h
, y0 + 2 , z0 + 2
2
2
2
523
IJ
K
= hf1(0.05, 0.957375, – 0.954875) = – 0.0864173
FG
H
l3 = hf2 x 0 +
h
k
l
, y0 + 2 , z0 + 2
2
2
2
IJ
K
= hf2 (0.05, 0.957375, – 0.954875) = – 0.0864173
b
g
k4 = hf1 x 0 + h, y 0 + k3 , z 0 + l3 = – 0.073048.
l4 = hf2(x0 + h, y0 + k3, z0 + l3) = 0.0822679
k=
1
(k + 2k2 + 2k3 + k4) = – 0.0860637
6 1
l=
1
(l + 2l2 + 2l3 + l4) = 0.0907823
6 1
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
2.
dy
= x + y.
dx
Apply the Runge-Kutta Fourth Order Method to solve 10
dy
= x2 + y2; y (0) = 1 for
dx
0 < x ≤ 0. 4 and h = 0.1.
dy
= xy. Take
dx
3.
Use Runge-Kutta Fourth Order Formula to find y(1.4) if y (1) = 2 and
4.
h = 0.2.
Prove that the solution of y′ = y, y(0) = 1 by Second Order Runge-Kutta Method yields
ym
F
h I
= G1 + h +
2 JK
H
2
m
.
1
, y(0) = 1 for x = 0.5 to x = 1 by Runge-Kutta Method (h = 0.5).
x+y
5.
Solve y′ =
6.
Solve y′ = – xy 2 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
7.
8.
9.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Use Runge-Kutta Method to find y when x = 1.2 in steps of 0.1 given that
dy
= x2 + y2 and y(1) = 1.5
dx
Given y′ = x 2 – y, y (0) = 1 find y(0.1), y(0.2) using Runge-Kutta Methods of (i) Second
Order (ii) Fourth Order.
Using Runge-Kutta Method of Fourth Order, solve for y(0.1), y(0.2) and y(0.3),
given that y′ = xy + y 2, y(0) = 1.
10. Using Runge-Kutta Method, find y(0.2) for the equation
dy y − x
=
, y (0) = 1. Take h = 0.2
dx y + x
11. (i) Using Runge-Kutta Method, find y(0.2) given that
dy
1
= 3x + y, y(0) = 1 taking h = 0.1.
dx
2
(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
=x+z
dx
dz
= x – y2
dx
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
= y2 + x2, y(1) = 0. Assume step size h = 0.2.
dx
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
= x3 + y3 ,
dx
y(0) = 1 and step length h = 0.1 upto three iterations.
dy
= xy with y(1) = 5. Using the Fourth Order Runge-Kutta Method, find the
dx
solution in the interval (1, 1.5) using step size h = 0.1.
16. Given
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
525
17. Using the Runge-Kutta Method of Fourth Order, solve the following differential equation:
dy y 2 − x 2
=
dx y2 + x 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 RungeKutta 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)
y1p = y0 + hf(x0, y0)
(27)
can be stated as
y1c = y0 +
h
[f(x0, y0) + f(x1, y1p)]
2
(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
u(u − 1) (u − 2) 3
Δ y0 ′ +
Δ y0′
2
6
+
u(u − 1) (u − 2) (u − 3)
Δ4 y0′ + .......
24
(29)
x − x0
or x = x0 + uh
h
Now integrating (29) over the interval x0 to x0 + 4h (or u = 0 to 4), we get
where
u=
z
x0 + 4 h
x0
or
y ′ dx = h
y4 – y0 = h
z
z LMN
4
0
4
0
y ′ du
| ∵ dx = h du
y 0′ + uΔy0′ +
+
FG
H
= h 4 y0′ + 8 Δy0′ +
u(u − 1) 2
u(u − 1) (u − 2) 3
Δ y0′ +
Δ y0′
2
6
OP
Q
u(u − 1) (u − 2) (u − 3) 4
Δ y0′ + ...... du
24
20 2
8
28 4
Δ y0′ + Δ3 y0′ +
Δ y0′
3
3
90
IJ
K
| 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
FG
H
y4 – y0 = h 4 y0′ + 8(E − 1) y0′ +
=
or
20
8
28 4
(E − 1) 2 y0′ + (E − 1) 3 y0′ +
Δ y0′
3
3
90
IJ
K
(30)
4h
28 4
(2y1′ – y2′ + 2y3′) +
hΔ y0′
3
90
y4 = y0 +
4h
28
(2y1′ – y2′ + 2y3′) +
hΔ4 y0′
3
90
(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.
FG
H
y2 – y0 = h 2 y0′ + 2 Δy0′ +
1 2
1 4
Δ y0′ −
Δ y0′
3
90
IJ
K
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,
h
h 4
(y0′ + 4y1′ + y2′) –
Δ y0′
3
90
h
h 4
⇒
y2 = y0 + (y0′ + 4y1′ + y2′) –
Δ y0′
3
90
This is Milne’s Corrector Formula.
y2 – y0 =
(32)
The value of y4 obtained from (31) and (32) can be put as
4h
(2y′n–2 – y′n–1 + 2yn′)
(33)
3
h
y′n + 1 = yn–1 +
(y′n–1 + 4yn′ + y′n + 1)
(34)
3
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.
yn + 1 = yn–3 +
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
hΔ4y′
90
(yn + 1)exact = y(1)n + 1 –
and
h 4
Δ y′
90
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 = –
where δ = –
δ=
29 4
hΔ y′ = 29 δ
90
h 4
Δ y′ denotes the principal part of the error in (34). Thus it gives
90
1
[y
– y(1)n + 1 ]
29 n + 1
Thus we observe that the error in (34) is
predicted and corrected values.
1 th
of the difference between the
29
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
6.22.2 Flow-Chart of Milne’s Predictor Corrector Method
START
F(x, y) = x + y
Input xn
For i = 0, 3
Input x(i), y(i)
h = x(1) – x(0)
n = (xn – x(0)/h
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)
STOP
No
yp = yc
529
530
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
6.22.3 Program of Milne’s Method
#include<stdio.h>
#include<math.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("\n\nPredicated Y=%f Correctd Y=%f", yp,yc);
If(fabs (yp-yc)<0.00005)
goto next;
yp=yc;
next;
y[i+1]=yc;
printf("\n\n 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.2
0.0
0.02
0.4
0.6
0.0906
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
with initial conditions x0 = 0, y0 = 1 from x = 0.20 to x = 0.30.
dy
=x+y
dx
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 +
4h
(2y′n – 2 – y′n – 1 + 2yn′)
3
(36)
532
COMPUTER-BASED NUMERICAL
and
AND
STATISTICAL TECHNIQUES
h
(y′n – 1 + 4yn′ + y′n + 1)
3
Put n = 3, h = 0.05 in (36), we get
yn + 1(1) = yn – 1 +
y4 = y0 +
(37)
4h
(2y1′ – y2′ + 2y3′)
3
4( 0.05)
[2.205 – 1.2103 + 2.6472]
3
= 1.2428 (predicted value)
=1+
It is corrected by
y4(1) = y2 +
h
(y ′ + 4y3′ + y4′)
3 2
0.05
[1.2103 + 5.2944 + 1.4428] = 1.2428
3
which is the same as predicted value.
= 1.1103 +
Put x = 0.20 and y = 1.2428 in
we get
dy
= x + y,
dx
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 +
4h
(2y2′ – y3′ + 2y4′)
3
= 1.0525 +
4( 0.05)
[2.4206 – 1.3236 + 2.8856]
3
= 1.3180
which is corrected by
y5(1) = y3 +
h
(y ′ + 4y4′ + y5′)
3 3
0.05
(1.3236 + 5.7712 + 1.568) = 1.3180
3
which is same as predicted value.
= 1.1736 +
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
1
= (x + y) where y(0) = 2,
dx
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 +
4h
(2y1′ – y2′ + 2y3′)
3
we have,
y′ =
1
(x + y)
2
∴
y1′ =
1
(x + y1) = 1.568
2 1
Similarly
y2′ = 2.2975, y3′ = 3.234
∴ from (38),
⇒
y4 = 2 +
y4′ =
(38)
4(0.5)
[3.136 – 2.2975 + 6.468] = 6.871
3
1
(x + y4) = 4.4355
2 4
This is corrected by
y4(1) = y2 +
h
(y ′ + 4y3′ + y4′)
3 2
= 3.595 +
Now,
(y4(1))′ =
0.5
[2.2975 + 12.936 + 4.4355] = 6.87317
3
1
1
[x + y4(1)] = (2 + 6.87317) = 4.43659
2 4
2
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
[y ′ + 4y3′ + (y4(1))′]
3 2
= 3.595 +
0.5
[2.2975 + 12.936 + 4.43659] = 6.87335
3
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, y 3, and we
require y4 = y(0.8) and y5 = y(1.0). Here h = 0.2
We have,
∴
y′ = 1 + y2
y1′ = 1 + y12 = 1 + (0.2027)2 = 1.0411
y2′ = 1 + y22 = 1 + (0.4228)2 = 1.1788
y3′ = 1 + y32 = 1 + (0.6841)2 = 1.4680
By Predictor Formula, we get
y4 = y0 +
=0+
4h
(2y1′ – y2′ + 2y3′)
3
0.8
[2.0822 – 1.1788 + 2.936] = 1.0238
3
y4′ = 1 + y42 = 1 + (1.0238)2 = 2.0482
This is corrected by
y4(1) = y2 +
h
(y ′ + 4y3′ + y4′)
3 2
0.2
[1.1788 + 5.872 + 2.0482] = 1.0294
3
[y4(1)]′ = 1 + [y4(1)]2 = 1 + (1.0294)2 = 2.0597
= 0.4228 +
Now,
The second corrected value is,
h
[y ′ + 4y3′ + y4(1) ′]
3 2
0.2
[1.1788 + 5.872 + 2.0597] = 1.0302
= 0.4228 +
3
y4(2) = y2 +
Again,
Again,
hence,
[y4(2)]′ = 1 + [y4(2)]2 = 1 + (1.0302)2 = 2.0613
y4(3) = 1.0303 = y4(4)
y4 = y(0.8) = 1.0303
NUMERICAL SOLUTION
OF
ORDINARY DIFFERENTIAL EQUATIONS
535
Now, by Predictor Formula, also
y5 = y1 +
4h
(2y2′ – y3′ + 2y4′)
3
= 0.2027 +
0.8
[2.3576 – 1.468 + 4.123] | y4′ = 1 + (1.0303)2
3
= 1.5394
y5′ = 1 + y52 = 3.3698
This is corrected by
y5′ = y3 +
h
( y3′ + 4y4′ + y5′)
3
= 0.6841 +
0.2
(1.468 + 8.246 + 3.3698) = 1.5564
3
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
= – xy2 at x = 0.8, given that
dx
y(0) = 2, y(0.2) = 1.923, y(0.4) = 1.724, y(0.6) = 1.471
2.
3.
Solve 10
dy
= x2 + y2, y(0) = 1 and compute y(0.4) and y(0.5) by Milne’s Method given
dx
x:
0.1
0.2
0.3
y:
1.0101
1.0206
1.0317
Part of a numerical solution of the differential equation
dy
= 0.2x + 0.1y
dx
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.
dy
1
=
(1 + x2) y2 and y(0) = 1, y(0.1) = 1.06, y(0.2) = 1.12, y(0.3) = 1.21, evaluate
dx
2
y(0.4) by Milne’s Predictor-Corrector Method.
4.
Given
5.
The differential equation
dy
1 2
+
y = x satisfies the following pairs of values of x
dx
10
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
= y – x2
dx
by Milne’s Method and compute y at x = 0.80 when:
7.
8.
9.
x:
0
0.2
0.4
0.6
y:
1
1.12186
1.46820
1.73790
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
dy
= 2 – xy2 and y(0) = 1. Show that by Milne’s Method, y(1) = 1.6505 taking
dx
h = 0.2. You may use Picard’s Method to obtain the values of y(0.2), y(0.4), y(0.6).
Given:
Solve the initial value problem
dy
= 1 + xy2, y(0) = 1 for x = 0.4, 0.5 by using Milne’s
dx
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.
x:
dy
= x – y2 for y(0.8) and y(1), given the starting values.
dx
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
1
dy
=
by Milne’s Method.
x+ y
dx
12. Solve numerically
dy
= 2ex – y at x = 0.4 and 0.5 by Milne’s Method given:
dx
x:
0
0.1
0.2
0.3
y:
2
2.010
2.040
2.090
dy
= – xy with y(0) = 1. Solve the equation in the interval (0, 1) using step size = 0.5
dx
using Predictor-Corrector Method. Give algorithm of Predictor-Corrector Method.
13. Given
14. Apply Predictor-Corrector Method on a differential equation
dx
= f (t, x).
dt
x = x(t)
Let
The method is of order IV with step-size h is x(t + h) = x(t) +
where,
1
(k + 2k2 + 2k3 + k4)
6 1
k1 = h f (t, x)
FG h , x + k IJ
H 2 2K
F h k IJ
= h f Gt + , x +
H 2 2K
k2 = h f t +
1
k3
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
= t – x and x(0) = 0.
dt
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
We compute
dy
= f (x, y) with y(x0) = y0
dx
y–1 = y(x0 – h), y–2 = y (x0 – 2h), y– 3 = y(x0 – 3h),......
(39)
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 +
z
x0 + h
x0
f ( x, y) dx
(40)
Replacing f (x, y) by Newton’s Backward Interpolation Formula, we get
y1 = y0 + h
z RST
1
0
f 0 + u ∇ f0 +
FG
H
= y0 + h f0 +
UV
W
u(u + 1) 2
u(u + 1) (u + 2) 3
∇ f0 +
∇ f0 + ... du
2
6
IJ
K
∵ x = x0 + hu
∴ dx = h du
Limits of u are from 0 to 1
1
5 2
3
∇ f0 +
∇ f0 + ∇ 3 f0 + ...
2
12
8
(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,
y 1 = y0 +
h
(55f0 – 59f –1 + 37f–2 – 9f–3)
24
which is known as Adams–Bashforth or Adams–Moulton–Predictor
Formula and is denoted generally as
or
y p n + 1 = yn +
h
(55fn – 59fn –1 + 37fn –2 – 9fn –3)
24
y p n + 1 = y0 +
h
(55yn′ – 59y′n –1 + 37y′n –2 – 9y′n –3)
24
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 +
z
x0 + h
x0
= y0 + h
z
0
−1
LM f
MN
LM f
N
1
1
+ u ∇ f1 +
+ u ∇ f1 +
OP
Q
O
+ ...P du
PQ
u(u + 1) 2
u(u + 1) (u + 2) 3
∇ f1 +
∇ f1 + ... dx
2
6
F
GH
I
JK
(u 2 + u) 2
u 3 + 3u 2 + 2u
∇ f1 +
∇ 3 f1
2
6
∵ x = x1 + hu
∴ dx = h du
NUMERICAL SOLUTION
FG
H
= y0 + h f1 −
OF
ORDINARY DIFFERENTIAL EQUATIONS
IJ
K
1
1 2
1 3
∇ f1 −
∇ f1 −
∇ f1 − ...
2
12
24
539
(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
y 1 = y0 +
h
(9f1 + 19f0 – 5f–1 + f–2)
24
which is known as Adams–Bashforth or Adams–Moulton Corrector
Formula and is denoted generally as
h
y cn + 1 = y n +
(9fn + 1 – 19fn – 5fn –1 + fn –2)
24
h
or
y cn + 1 = y n +
(9y′n + 1 – 19yn′ – 5y′n –1 + y′n –2)
24
EXAMPLES
Example 1. Using Adam’s–Moulton–Bashforth Method to find y (1.4) given:
dy
= x2 (1 + y), y(1) = 1, y(1.1) = 1.233, y(1.2) = 1.548 and y(1.3) = 1.979.
dx
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
h
(55y3′ – 59y2′ + 37y1′ – 9y0′)
24
y1′ = x12 (1 + y1) = 2.70193
y4p = y3 +
y2′ = x22 (1 + y2) = 3.66912
y3′ = x32 (1 + y3) = 5.03451
∴ from (43),
y4p = 1.979 +
FG 01. IJ [55(5.03451) – 59(3.66912)
H 24 K
+ 37(2.70193) – 9(2)]
= 2.5722974
Now,
(y4′)p = x42 (1 + y4p) = (1.4)2 (1 + 2.5722974)
= 7.0017029
(43)
540
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Now, the Corrector Formula is
y4c = y3 +
h
(9y4′p + 19y3′ – 5y2′ + y1′)
24
= 1.979 +
FG 0.1IJ [9(7.0017029) + 19(5.03451)
H 24 K
– 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
= x2 – y; y(0) = 1
dx
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,
and
y0′ = – 1, y1′ = – 0.895125, y2′ = – 0.7812352
y3′ = – 0.6591509
Now, Adams–Bashforth Predictor Formula is
y4p = y3 +
h
(55y3′ – 59y2′ + 37y1′ – 9y0′)
24
= 0.7491509 +
FG 01. IJ [55(– 0.6591509) – 59(– 0.7812352)
H 24 K
+ 37(– 0.895125) – 9(– 1)]
= 0.6896507
Now,
y4′p = x42 – y4p = (0.4)2 – 0.6896507 = – 0.5296507
The Corrector Formula is
y4c = y3 +
h
(9y4′p + 19y3′ – 5y2′ + y1′)
24
NUMERICAL SOLUTION
= 0.7491509 +
OF
ORDINARY DIFFERENTIAL EQUATIONS
541
FG 01. IJ [9(– 0.5296507)
H 24 K
+ 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
= 3ex + 2y with y(0) = 0.
dx
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
1
=
xy using Adams–Moulton Method, given
dx
2
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(x 0) = y0
The solution of this equation is
y(x) = y(x0) e
Let,
A(x– x0)
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.
⇒
⇒
∴
Hence,
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
y(x) = 1 + x + x2 + ... +
2
xp + ...
p!
In order to obtain results, which will be accurate up to 10–10 for x ≤ 1,
we have
1
< 5 × 10–10
( p + 1) !
⇒
p ≈ 15
Hence about 15 terms are required to obtain the accuracy of 10–10 for solving
dy
= x + y by Taylor’s Series Method when x ≤ 1.
dx
Example 2. Discuss the stability of Euler’s Method for solving the differential
equation.
dy
= λy
dx
dy
Sol.
= λy = f (x, y)
dx
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
Let
AND
STATISTICAL TECHNIQUES
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.
5
P a r t
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.
Chapter
7.1
7
STATISTICAL COMPUTATION
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.
547
548
COMPUTER-BASED NUMERICAL
7.3
FREQUENCY CHARTS
7.3.1
Variable
AND
STATISTICAL TECHNIQUES
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
Scores
(Class-interval)
Number of Students
Frequency
(f )
Cumulative
Frequencies
0—10
10—20
20—30
30—40
40—50
50—60
60—70
70—80
80—90
90—100
||
|| ||
|||| ||||
|| ||
|||
|||| |||
|
||||
|||| |||| |
||
2
4
10
4
3
8
1
5
11
2
2
6
16
20
23
31
32
37
48
50
Total
549
Σ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
Under
10
2
Scores
above 90
Number of Students
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
50
above
50
Under 100
7.4
Number of Students
0
GRAPHICAL REPRESENTATION OF A FREQUENCY DISTRIBUTION
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.
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 classintervals 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.
Y
11
10
9
8
7
6
Frequencies
7.6
5
4
3
2
1
0
10
20
30
40
50
Scores
60
70
80
90
100
X
(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
7.7
FREQUENCY POLYGON
AND
STATISTICAL TECHNIQUES
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.
Y
11
10
9
8
7
Frequencies
6
5
4
3
2
1
0
10
20
30
40
50
Scores
60
70
80
90
100
X
(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
7.9
553
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.
Y
Cumulative frequencies
50
40
Og
20
10
0
7.10
ive
30
10
20
30
40 50
Scores
60
70
80
90 100 X
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
7.11
555
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 circlesdiagrams. 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
7.12
CURVE FITTING
AND
STATISTICAL TECHNIQUES
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 + cx12 + ...... + kx1n
y2′ = a + bx2 + cx22 + ...... + kx2n
ym′ = a + bxm + cxm2 + ...... + kxmn
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 – cxr2 – ..... – kxrn)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
∂U ∂U
=
=0=
∂a
∂b
∂c
∂U
. On simplifying these relations, we get
∂k
Σ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
n
U=
∑
Ei2 =
i=1
n
∑
( yi − a − bxi ) 2
i=1
By the principle of Least squares, U is minimum
∂U
= 0 and
∂a
∴
n
∴
2
∑
∂U
=0
∂b
( yi − a − bxi )(− 1) = 0
or
Σy = na + bΣx
(3)
( yi − a − bxi )(− xi ) = 0
or
Σxy = aΣx + bΣx2
(4)
i=1
n
and
2
∑
i=1
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).
NOTE
In case of change of origin,
if n is odd then,
u=
but
u=
if n is even then
x − (middle term)
interval (h)
x − (mean of two middle terms)
.
1
(interval)
2
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
a = ((Sum 2* Sum4) – (Sum 3* Sum1))/
((observ* sum4) – (sum 1* sum1))
b = ((sum 2 – observ* a)/sum1)
Print ‘‘output’’
STOP
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(“\n\n Enter the number of observations - ”);
scanf(“%d” ,&observ);
562
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
//... Input Sequel For Array X
printf(“\n\n\n Enter the values of x – \n");
for (;i<observ;i++)
{
printf("\n\n Enter the Value of x%d: ",i+1);
scanf(“%f” ,&x[i]);
sum1 +=x[i];
}
//... Input Sequel For Array Y
printf(“\n\n Enter the values of y - \n”);
for(i=0;i<observ;i++)
{
printf("\n\n Enter the value of y%d:",i+1);
scanf("%f",&y[i]);
sum2+=y[i];
}
//... Processing and Calculation Section
for(i=0;i<observ;i++)
{
xy[i]=x[i]*y[i];
sum3 +=xy[i];
}
for(i=0;i<observ; 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(“\n\n\n\n Equation of the STRAIGHT LINE");
printf("of the form y = a + b*x is:");
printf(“\n\n\n \t\t\t Y = %.2f + (%.2f) X", a,b);
//... Invoke User Watch Halt Function
STATISTICAL COMPUTATION
563
printf("\n\n\n 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
Normal equations are
and
(5)
Σy = ma + bΣx
(6)
Σ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
Σxy = aΣx +
Here
(8)
bΣx2
(9)
m=5
x
y
xy
x2
0
1
2
3
4
1
1.8
3.3
4.5
6.3
0
1.8
6.6
13.5
25.2
0
1
4
9
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 independent 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
Here m = 6
x
y
y = a + bx
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
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
Then let,
u=
x − 12.5
2.5
y0 = 20 (say)
and v = y – 20
x
y
u
v
uv
u2
0
5
10
15
20
25
12
15
17
22
24
30
–5
–3
–1
1
3
5
–8
–5
–3
2
4
10
40
15
3
2
12
50
25
9
1
1
9
25
Σv = 0
Σuv = 122
Σu2 = 70
Total
Σu = 0
Normal equations are
0 = 6a and 122 = 70b
⇒
a = 0,
Line of fit is
v = 1.743u
Put u =
x − 12.5
2.5
b = 1.743
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.
565
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
and
Σxy = aΣx +
(11)
bΣx2
(12)
Here m = 8. Table is as below:
x
y
xy
x2
71
68
73
69
67
65
66
67
69
72
70
70
68
67
68
64
4899
4896
5110
4830
4556
4355
4488
4288
5041
4624
5329
4761
4489
4225
4356
4489
Σy = 548
Σxy = 37422
Σx2 = 37314
Σx = 546
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
Σxi
Σxi 2
y
Σyi
Σxi yi
1
n =0
Σxi
(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
Then the normal equations are
and
(13)
Σyi = na + bΣxi
(14)
Σxi yi = aΣxi + bΣxi2
(15)
567
STATISTICAL COMPUTATION
Equations (13), (14), (15) may be rewritten as
bx – y + a = 0
bΣxi – Σyi + na = 0
bΣxi2 – Σxiyi + aΣxi = 0
and
Eliminating a and b between these equations
x
Σ xi
Σxi 2
y
Σyi
Σxi yi
1
n
Σxi
=0
(16)
which is the required best fitting linear function for the mean point ( x , y ) ,
x =
1
Σxi
n
y =
1
Σy .
n i
Clearly, the line (16) passes through point ( x , y ) as two rows of determinants
being equal make it zero.
ASSIGNMENT 7.1
1.
2.
3.
4.
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
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
Fit a straight line approximate to the data:
x
1
2
3
4
y
3
7
13
21
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
5.
6.
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
P
100
120
140
160
180
200
Y
0.45
0.55
0.60
0.70
0.80
0.85
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
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
Weight
7.
AND
1
2
3
4
5
6
7
8
9
10
52.5
58.7
65
70.2
75.4
81.1
87.2
95.5
102.2
108.4
Find the least square line for the data points
(– 1, 10), (0, 9), (1, 7), (2, 5), (3, 4),
8.
9.
(4, 3), (5, 0)
and (6, – 1).
Find the least square line y = a + bx for the data:
xi
–2
–1
0
1
2
yi
1
2
3
3
4
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
7.18
569
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 =
7.19
B
.
log 10 e
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
where Y = log10 y, A = log10 a and X = log10 x.
The normal equations to (18) are ΣY = nA + bΣX
ΣXY = AΣX + bΣX2
and
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.
(18)
570
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
For estimating A and B, normal equations are
ΣY = nA + B Σx
ΣxY = A Σx + B Σx2
and
where n is the number of pairs of values of x and y.
Ultimately,
7.21
a = antilog (A) and b = antilog (B).
FITTING OF THE CURVE pvr = k
pvr = k ⇒ v = k1/r p–1/r
Taking logarithm on both sides,
log v =
⇒
1
1
log k − log p
r
r
Y = A + BX
1
1
log k, B = –
and X = log p
r
r
r and k are determined by the above equations. Normal equations are obtained
as per that of the straight line.
where Y = log v, A =
7.22
FITTING OF THE CURVE OF TYPE xy = b + ax
xy = b + ax ⇒ y =
⇒
Y = bX + a, where X =
Normal equations are
7.23
b
+a
x
ΣY = na + bΣX
ΣXY = aΣX + bΣX2.
b
x
FITTING OF THE CURVE y = ax2 +
Let the n points be (x1, y1), (x2, y2), ..... , (xn, yn)
Error of estimate for ith point (xi, yi) is
F
GH
2
Ei = yi − axi −
b
xi
I
JK
1
.
x
STATISTICAL COMPUTATION
By principle of Least squares, the values of a and b are such that
n
U=
∑
Ei 2 =
i=1
F
∑ GH y − ax
n
i
i=1
i
2
−
b
xi
I
JK
2
is minimum.
Normal equations are given by
∂U
=0
∂a
n
⇒
∑
xi 2 yi = a
i=1
∑
xi 4 + b
i=1
n
∑
xi
i=1
∂U
=0
∂b
and
n
⇒
or
n
∑
i=1
n
n
yi
1
xi + b
=a
xi
xi 2
i=1
i=1
∑
∑
Dropping the suffix i, normal equations are
Σx2y = a Σx4 + bΣx
∑
and
7.24
y
= a Σx + b
x
∑
1
x2
.
FITTING OF THE CURVE y = ax + bx2
Error of estimate for ith point (xi, yi) is Ei = (yi – axi– bxi2)
By the principle of Least Squares, the values of a and b are such that
n
U=
∑
Ei 2 =
i=1
Normal equations are given by
n
⇒
∑
n
xi yi = a
i=1
and
∑
i=1
∂U
=0
∂b
n
∑
( yi − axi − bxi 2 ) 2 is minimum.
i=1
∂U
=0
∂a
xi 2 + b
n
∑
i=1
xi 3
571
572
COMPUTER-BASED NUMERICAL
n
∑
⇒
AND
STATISTICAL TECHNIQUES
n
∑
xi 2 yi = a
i=1
or
xi 3 + b
i=1
n
∑
xi 4
i=1
Dropping the suffix i, normal equations are
Σxy = a Σx2 + bΣx3
Σx2y = a Σx3 + bΣx4.
7.25
b
x
FITTING OF THE CURVE y = ax +
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
n
U=
∑
Ei 2 =
i=1
F
bI
∑ GH y − ax − x JK
n
i
i=1
Normal equations are given by
∂U
=0
∂a
F
n
⇒
2
∑ GH y
i
− axi −
i=1
⇒
n
∑
n
xi yi = a
i=1
∑
I
JK
b
(− x i ) = 0
xi
xi 2 + nb
i=1
∂U
=0
∂b
and
n
⇒
2
i=1
n
⇒
F
∑ GH y
∑
i=1
i
− axi −
b
xi
I F− 1 I = 0
JK GH x JK
n
yi
1
= na + b
2
xi
x
i
i=1
∑
i
i
i
2
is minimum.
STATISTICAL COMPUTATION
Dropping the suffix i, normal equations are
Σxy = aΣx2 + nb
∑
and
y
= na + b
x
1
∑
x2
where n is the number of pairs of values of x and y.
7.26
b
x
FITTING OF THE CURVE y = a +
+
c
x2
Normal equations are
y
=a
x
∑
1
+b
x
y
∑
1
∑
∑
x
2
=a
x
1
+c
x
∑
Σy = ma + b
∑
+b
2
∑
1
x
1
x2
∑
+c
2
1
x
3
∑
+c
∑
1
x3
1
x4
where m is the number of pairs of values of x and y.
7.27
c0
x
FITTING OF THE CURVE y =
+ c1 x
Error of estimate for ith point (xi, yi) is
Ei = yi –
c0
− c1 xi
xi
By the principle of Least Squares, the values of a and b are such that
n
U=
∑
Ei2 =
i=1
n
∑
( yi −
i=1
Normal equations are given by
∂U
=0
∂c0
Now,
∂U
=0
∂c0
and
∂U
=0
∂c1
c0
− ci xi ) 2 is minimum.
xi
573
574
COMPUTER-BASED NUMERICAL
F
n
2
⇒
AND
∑ GH y
i
STATISTICAL TECHNIQUES
−
i=1
n
yi
= c0
xi
∑
⇒
c0
− c1 xi
xi
i=1
n
∑
i=1
I F− 1 I = 0
JK GH x JK
i
n
1
xi
2
+ c1
1
∑
(19)
xi
i=1
∂U
=0
∂c1
Also,
F
n
2
⇒
∑ GH y
i
i=1
−
n
n
∑
⇒
I
JK
c0
− c1 xi (− xi ) = 0
xi
yi
xi = c0
i=1
∑
n
1
xi
i=1
+ c1
∑
xi
(20)
i=1
Dropping the suffix i, normal equations (19) and (20) become
y
= c0
x
∑
y x = c0
∑
∑
∑
and
7.28
1
x2
+ c1
1
x
∑
1
x
+ c1 Σx.
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
Σ 2x = aΣx2 + bΣx + mc
and
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
ΣxY = AΣx + BΣx2
and
x
x2
y
Y = log10 y
1
10
1.0000
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
ΣY = 5.7536
Σx2 = 300
ΣxY = 40.8862
Σx = 34
xY
1
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
= 0.059
log 10 e
y = 9.4754e0.059x.
Hence the required curve is
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.
Take log,
which is of the form
y = aebx
log y = log a + bx log e
Y = A + Bx
where Y = log y, A = log a, B = b log e
576
COMPUTER-BASED NUMERICAL
x
y
1
1.6
AND
STATISTICAL TECHNIQUES
x2
Y = log y
xY
.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
ΣY = 8.1754
Σx2 = 91
ΣxY = 36.6941
Σx = 21
Normal equations are
ΣY = mA + BΣx
ΣxY = AΣx + BΣx 2
and
Here m = 6
∴ From (21),
⇒
∴
UV
W
(21)
8.1754 = 6A + 21B, 36.6941 = 21A + 91B
A = – 0.2534, B = 0.4617
a = antilog A = antilog (– .2534)
= antilog ( 1.7466) = 0.5580
and
b=
B
.4617
=
= 1.0631
log e .4343
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
and
ΣXY = AΣX +
(22)
BΣX2.
(23)
Here m = 5.
Table is as follows:
x
y
X
Y
X2
XY
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
0.2171509
=
= 0.50001
log 10 e
.4342945
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
ΣXY = AΣx + BΣx2.
and
x
y
x2
Y = log10 y
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
Σx2 = 90
ΣxY = 33.1812
Σx = 20
ΣY = 7.5455
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 – bxi2)
By the principle of least squares, the values of a and b are such that
5
U=
∑
i =1
Ei 2 =
5
∑
i=1
( yi − axi − bxi 2 ) 2 is minimum.
STATISTICAL COMPUTATION
579
Normal equations are given by
∂U
=0
∂a
5
∑
⇒
5
xi yi = a
i =1
∑
xi 2 + b
i=1
5
∑
xi 3
i=1
∂U
=0
∂b
and
5
∑
⇒
xi 2 yi = a
i =1
5
∑
xi 3 + b
i=1
5
∑
xi 4
i=1
Dropping the suffix i, Normal equations are
and
Σxy = aΣx2 + bΣx3
(24)
Σx2y = aΣx3 + bΣx4
(25)
Let us form a table as below:
x
y
x2
x3
x4
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
Σx2 = 55
Σx3 = 225
Σx4 = 979
Total
x2 y
xy
Σ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
⇒
and
a=
83.85
~ 1.52
55
b=
317.4
~ .49
664
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)
v (liters)
0.5
1
1.5
2
2.5
3
1620
1000
750
620
520
460
pvγ = k
Sol.
v =
Taking log,
log v =
which is of the form
FG k IJ
H pK
1/ γ
1
1
log k − log p
γ
γ
Y = A + BX
where Y = log v, X = log p, A =
1
1
1
log k and B = –
γ
γ
v
X
Y
XY
X2
1620
– .30103
3.20952
– .96616
0.09062
1000
0
3
0
0
p
.5
= k1/γ p–1/γ
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
ΣY = 17.25573
ΣXY = 2.73196
ΣX2 = .59825
Total
ΣX = 1.05115
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
∴
Again,
∴
γ =–
B = – 0.70298
1
1
=
= 1.42252
B .70298
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 – bxi2)
By the principle of Least Squares, the values of a, b are such that
4
U=
∑
Ei 2 =
i=1
4
∑
( yi − a − bxi 2 ) 2 is minimum.
i=1
Normal equations are given by
and
∂U
= 0 ⇒ Σy = ma + bΣx2
∂a
(26)
∂U
= 0 Σx2y = aΣx2 + bΣx4
∂b
(27)
x
y
x2
x2 y
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):
P (kg
cm–2):
50
60
70
90
100
64.7
51.3
40.5
25.9
78
Fit the data to the equation PVγ = C.
582
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
PVγ = C
Sol.
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
ΣXY = AΣX + BΣX2
and
Here
Table is as below:
m=5
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
78
2
1.89209
3.78418
4
ΣY = 8.43387
ΣXY = 15.62954
100
ΣX = 9.27646
Σ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
c0
+ c1 x to
x
Example 9. Use the Method of Least Squares to fit the curve: y =
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=
y
= c0
x
∑
y x = c0
∑
∑
∑
and
c0
+ c1 x are
x
1
x
2
1
+ c1
∑
+ c1
∑
1
x
(28)
x
x
(29)
The table is as below:
1
1
x
x2
6.64078
3.16228
100
4.91935
2.23607
25
17.5
4.42719
1.58114
6.25
12
4.24264
1.41421
4
5
5
5
1
1
6
3
8.48528
.70711
0.25
x
y
y/x
y x
0.1
21
210
0.2
11
55
0.4
7
0.5
6
1
2
Σx = 4.2
Σ(y/x) = 302.5 Σy x = 33.71524
∑
1
x
= 10.10081
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=
1.97327
+ 3.28182 x .
x
1
∑x
2
= 136.5
584
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
ASSIGNMENT 7.2
1.
2.
3.
4.
5.
6.
7.
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
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
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
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
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
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
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
585
STATISTICAL COMPUTATION
8.
9.
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
b
to a set of n
x
Derive the least square equations for fitting a curve of the type y = ax2 +
points.
Hence fit a curve of this type to the data:
10.
11.
x
1
2
3
4
y
– 1.51
0.99
3.88
7.66
Derive the least squares approximations of the type ax2 + bx + c to the function 2x at the
points xi = 0, 1, 2, 3, 4.
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 +
12.
b
c
+ 2.
x
x
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:
13.
14.
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
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
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
15.
7.29
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
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
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
amx + bmy + cmz + ...... + kmt = lm
U|
|V
||
W
(30)
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
= 0 = 2(3x + y – 4.95) (3) + 2(x + y – 3)
∂x
+ 2(2x – y – 0.5) (2) + 2(x + 3y – 7.25)
STATISTICAL COMPUTATION
⇒
30x + 10y = 52.2
or
3x + y = 5.22
(32)
∂S
= 0 = 2(3x + y – 4.95) + 2(x + y – 3)
∂y
+ 2(2x – y – 0.5) (– 1) + 2(x + 3y – 7.25) (3)
and
⇒
or
587
10x + 24y = 58.4
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,
3
S=
∑
( xi − α ) 2 +
i=1
3
∑
( yi − β) 2 +
i=1
( zi − 180 + α + β) 2
i=1
3
and
3
∑
(34)
3
∂S
=0=−2
( xi − α ) + 2
( zi − 180 + α + β)
∂α
i=1
i=1
∑
∑
3
3
∂S
=0=−2
( yi − β) + 2
( zi − 180 + α + β)
∂β
i=1
i=1
∑
or
or
∑
RS− Σx + 3α + Σz − 540 + 3α + 3β = 0
T– Σy + 3β + Σz − 540 + 3α + 3β = 0
RS 6α + 3β = 540 + Σx – Σz = 417.6
T 3α + 6β = 540 + Σy – Σz = 481.8
(35)
(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:
3.
Find the most plausible values of x, y, and z from the follwoing equations:
x + y = 3.31,
2x – y = .03,
x + 3y = 7.73,
3x + y = 5.47
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
λ x
λ x
y = f(x) = A 1e 1 + A 2 e 2 + ...... + A n e
λnx
(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
dn y
dx n
+ a1
d n− 1 y
dx n − 1
+ a2
d n− 2 y
dx n − 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
λ x
λ x
y = A1 e 1 + A2 e 2
(40)
which satisfies a differential equation of the form
d2 y
dx
2
= a1
dy
+ a2y
dx
(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
z
y′(x) – y′(a) = a1y(x) – a1y(a) + a2
where y′(x) denotes
x
a
dy
.
dx
y( x) dx
(42)
Integrating (42) again from a to x, we get
y(x) – y(a) – y′(a) (x – a) = a1
z
x
a
y( x) dx – a1(x – a) y(a)
+ a2
zz
x
x
a
a
y( x) dx dx
(43)
590
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
using the formula,
z z
x
a
......
x
a
f ( x) dx ...... dx =
equation (43) simplifies to,
y(x) – y(a) – (x – a) y′(a) = a1
z
x
a
1
(n − 1) !
z
x
a
( x − t) n− 1 f (t) dt
(44)
z
y( x) dx – a1(x – a) y(a) + a2
x
a
( x − t) y(t) dt
(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)
z
z
= a1
x1
y ( x) dx − a1 ( x1 − a) y(a) + a2
a
y(x2) – y(a) – (x2 – a) y′(a)
= a1
x2
y ( x) dx − a1 ( x2 − a) y( a) + a2
a
Adding the above equations and simplifying, we get
y(x1) + y(x2) – 2y(a) = a1
LM
N
z
x1
a
+ a2
LM
N
y ( x ) dx +
z
x1
a
z
x2
a
y( x ) dx
( x 1 − t) y(t) dt +
z
x1
a
x2
a
( x1 − t) y(t) dt
( x2 − t) y(t) dt
OP
Q
x2
a
z
z
( x 2 − t) y(t) dt
OP
Q
(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 = A1 e λ 1 x + A2 e λ 2 x
to the data given by
x:
1.0
1.1
y:
1.54
1.67
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.81
1.97
2.15
2.35
2.58
2.83
3.11.
591
STATISTICAL COMPUTATION
Sol. Choose
x1 = 1,
so that,
x2 = 1.4,
a = 1.2
a – x1 = x2 – a
LM
N
y(x1) + y(x2) – 2y(a) = a1
z
then,
x1
y( x ) dx +
a
LM
N
+ a2
LM
N
⇒ 1.54 + 2.15 – 3.62 = a1 −
z
1
LM
N
z
x1
a
1.2
+ a2 −
Evaluation of
z
x2
y( x ) dx
a
z
1.4
1.2
y( x ) dx
1.2
1
OP
Q
( x 1 − t) y(t) dt +
y( x ) dx +
z
z
(1 − t) y(t) dt +
z
1.4
1.2
OP
Q
z
x2
a
y(x) dx
The table of values is
x:
1
1.1
1.2
y(x):
1.54
1.67
1.81
By Simpson’s
z
1.2
1
1
rd rule,
3
y( x) dx =
Evaluation of
z
1.4
1.2
0.1
[(1.54 + 1.81) + 4(1.67)] = 0.33433
3
y(x) dx
The table of values is
x:
1.2
1.3
1.4
y(x):
1.81
1.97
2.15
By Simpson’s
z
1. 4
1.2
1
rd rule,
3
y( x) dx =
OP
Q
OP
Q
(1.4 − t) y(t) dt (48)
1.2
1
( x 2 − t) y(t) dt
0.1
[(1.81 + 2.15) + 4(1.97)] = 0.39466
3
592
COMPUTER-BASED NUMERICAL
Evaluation of
z
AND
STATISTICAL TECHNIQUES
1.2
1
(1 − t) y(t) dt
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
z
1.2
1
1
rd rule,
3
(1 − t) y(t) dt =
Evaluation of
z
0.1
[0 – .362 + 4 (– .167)] = – .03433
3
1.4
1.2
(1.4 − t) y(t) dt
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
z
1.4
1.2
1
rd rule,
3
(1.4 − t) y(t) dt =
0.1
[(0.362 + 0) + 4(.197)] = 0.03833
3
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
⇒
or
1.8099 a1 + 2.1798 a2 = 2.10
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) = a1
LM
N
z
x1
a
y( x) dx +
+ a2
LM
N
z
x1
a
z
x2
a
y( x) dx
OP
Q
( x1 − t) y(t) dt +
z
x2
a
( x2 − t) y(t) dt
OP
Q
STATISTICAL COMPUTATION
⇒
LM
N
2.15 + 3.11 – 5.16 = a1 −
z
1.6
1.4
y( x) dx +
z
LM
N
+ a2 −
1.6
1.4
z
1.8
1.6
y( x) dx
OP
Q
(1.4 − t) y(t) dt +
Evaluating all of the above integrals by Simpson’s
we obtain
z
1.8
1.6
593
(18
. − t) y(t) dt
OP
Q
1
rd rule and substituting,
3
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
⇒
and
λ1 = 0.988 ≈ 0.99
λ2 = – 0.96
Now the curve to be fitted is
y = A1e0.99x + A2e–0.96x
(51)
Residual
Ei = yi – A1 e 0.99 xi − A 2 e −0.96 xi
Consider
U=
n
∑
Ei2 =
i=1
n
∑
( yi − A 1 e
0.99 xi
− A2e
−0.96 xi 2
)
i=1
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
=0
∂A 1
Now,
∂U
=0
∂A 1
and
⇒
⇒
∂U
=0
∂A 2
2
∑
( y − A 1e.99 x − A 2 e − .96 x ) (− e.99 x ) = 0
∑
ye.99 x = A 1e 1.98 x + A 2
∑
e.03 x
(52)
594
COMPUTER-BASED NUMERICAL
and
AND
∂U
=0
∂A 2
STATISTICAL TECHNIQUES
∑
⇒
2
⇒
∑
( y − A 1e.99 x − A 2 e − .96 x ) (− e − .96 x ) = 0
ye −.96 x = A 1
∑e
.03 x
+ A2
∑e
−1.92 x
(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 − xi − 1
xi − x
F″(xi–1) +
F″(xi)
xi − xi − 1
xi − xi −1
(54)
For equally spaced intervals,
xi – xi–1 = h; 1 ≤ i ≤ n
From (54),
F″(x) =
1
[(xi – x) F″(xi–1) + (x – xi–1) F″(xi)]
h
Integrating equation (55) twice, we get
F(x) =
LM
MN
1 ( xi − x) 3
( x − xi − 1 ) 3
F ″ ( xi − 1 ) +
F ″ ( xi )
h
6
6
(55)
OP
PQ
+ 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
LM
N
OP
Q
Then,
fi =
1 h3
F″ ( xi ) + c2 h
h 6
⇒
c2 =
fi h
− F ″ ( xi )
h 6
and
fi–1 =
LM
N
(57)
OP
Q
1 h3
F″ ( xi− 1 ) + c1h
h 6
fi − 1 h
− F ″ ( xi − 1 )
h
6
Putting the values of c1 and c2 in equation (56), we get
⇒
c1 =
LM
MN
(58)
( x − xi − 1 ) 3
1 ( xi − x) 3
″
(
)
+
x
F
F ″ ( xi )
1
i
−
F(x) = h
6
6
R h F″ (x )UV
+ (x – x) S f −
T 6
W
R h F″ (x )UVOP
+ (x – x ) S f −
T 6
WPQ
2
i− 1
i
i −1
2
i–1
i
i
(59)
596
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Denoting F″(xi) = Mi, we have
F(x) =
1
[( xi − x) 3 M i − 1 + ( x − xi − 1 ) 3 M i
6h
+ (xi – x) {6fi–1 – h2 Mi–1} + (x – xi–1) {6fi – h2 Mi}]
Now,
F′(x) =
(60)
1
[– 3(xi – x)2 Mi–1 + 3(x – xi–1)2 Mi
6h
+ 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
[– 3h2Mi–1 + h2Mi–1 – h2Mi + 6(fi – fi–1)]
6h
1
[– h2Mi – 2h2Mi–1 + 6(fi – fi–1)]
6h
(62)
Again in the interval [xi–2, xi–1],
F′(x) =
1
[– 3(xi–1 – x)2 Mi–2 + 3(x – xi–2)2 Mi–1 + 6(fi–1 – fi–2)
6h
+ h2Mi–2 – h2Mi–1]
(63)
(ii) From (63),
F′(xi–1 – 0) =
=
1
[3h2Mi–1 + 6fi–1 – 6fi–2 + h2Mi–2 – h2Mi–1]
6h
1
[2h2Mi–1 + h2Mi–2 + 6fi–1 – 6fi–2]
6h
(64)
As F′(x) is continuous at xi–1,
F′(xi–1 – 0) = F′(xi–1 + 0)
∴
∴
or
2h2Mi–1
+ h2Mi–2
h2 (Mi +
+ 6fi–1 – 6fi–2 = – h2Mi – 2h2Mi–1 + 6fi – 6fi–1
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)
where i = 1, 2,......, n
(65)
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
[(x – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
6h i
+ (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
[(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
6h
+ (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
∴
and
Here,
and
M0 + 4M1 + M2 = 6(f2 – 2f1 + f0)
| For 0 ≤ x ≤ 1
M1 + 4M2 + M3 = 6(f3 – 2f2 + f1)
| For 1 ≤ x ≤ 2
M2 + 4M1 + M0 = 6[– 8 – 2(– 6) + 2] = 36
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
[(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) (6f0 – M0)
6
+ (x – 0) (6f1 – M1)]
1 3
[x (4.8) + (1 – x) (12) + x (– 36 – 4.8)]
6
= 0.8x3 – 8.8x + 2
For 1 ≤ x ≤ 2,
F(x) =
=
1
[(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1}
6
+ (x – 1) {6f2 – M2}]
1
[(2 – x)3 (4.8) + (x – 1)3 (16.8) + (2 – x) {– 36 – 4.8}
6
+ (x – 1) {– 48 – 16.8}]
= 2x3 – 3.6x2 – 5.2x + 0.8
For 2 ≤ x ≤ 3,
F(x) =
=
1
[(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) {6f2 – h2M2}
6
+ (x – 2) {6f3 – h2M3}]
1
[(3 – x)3 (16.8) + (3 – x) {– 48 – 16.8} + (x – 2) (12)]
6
| using M3 = 0
STATISTICAL COMPUTATION
⇒
F(x) =
=
599
1
[(27 – x3 – 27x + 9x2) (16.8) – 64.8 (3 – x) + 12x – 24]
6
1
[– 16.8x3 + 151.2x2 – 376.8x + 235.2]
6
= – 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
[(xi – x)3 Mi–1 + (x – xi–1)3 Mi + (xi – x) {6fi–1 – h2Mi–1}
6h
+ (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]
and
M0 = M3 = 0
(67)
(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
and
M0 + 4M1 + M2 = 6[33 – 4 + 1] = 180
(71)
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
[(1 – x)3 M0 + (x – 0)3 M1 + (1 – x) {6f0 – M0}
6
+ (x – 0) {6f1 – M1}] | ∵ h = 1
=
1 3
[x (– 24) + (1 – x) {6} + x(12 + 24)]
6
=
1
[– 24x3 + 6 – 6x + 36x] = – 4x3 + 5x + 1
6
For 1 ≤ x ≤ 2,
F(x) =
=
1
[(2 – x)3 M1 + (x – 1)3 M2 + (2 – x) {6f1 – M1}
6
+ (x – 1) {6f2 – M2}]
1
[(2 – x)3 (– 24) + (x – 1)3 (276) + (2 – x) (12 + 24)
6
+ (x – 1) {198 – 276}]
1
[(2 – x)3 (– 24) + 276 (x – 1)3 + 36(2 – x) – 78(x – 1)]
6
= 50x3 – 162 x2 + 167 x – 53
For 2 ≤ x ≤ 3,
=
F(x) =
=
1
[(3 – x)3 M2 + (x – 2)3 M3 + (3 – x) (6f2 – M2)
6
+ (x – 2) (6f3 – M3)]
1
[(3 – x)3 (276) + (x – 2)3 (0) + (3 – x) (198 – 276)
6
+ (x – 2) {(6 × 244) – 0}]
1
[(27 – x3 – 27x + 9x2) (276) + (3 – x) (– 78) + 1464 (x – 2)]
6
= – 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)
d2 y
dx
2
− 2x
dy
+ n ( n + 1) y = 0
dx
Pn(– x) = (– 1)n Pn(x).
we have
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) =
LM
N
OP
Q
n(n − 1) n− 2 n(n − 1)(n − 2)(n − 3) n− 4
1.3.5...... (2n − 1) n
x
x
x −
− ......
+
n!
2(2n − 1)
2.4.(2n − 1) (2n − 3)
602
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
In particular,
P2(x) =
3x2 − 1
,
2
P3(x) =
5x3 − 3 x
2
P4(x) =
35 x 4 − 30 x 2 + 3
,
8
P5(x) =
63 x 5 − 70 x 3 + 15 x
8
Legendre polynomials Pn(x) are orthogonal on the interval [– 1, 1] with
respect to the weight function W(x) = 1
We have
z
1
Pm ( x) Pn ( x) dx =
–1
7.38
R| 0, if m ≠ n U|
S| 2 , if m ≠ nV|
W
T 2n + 1
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θ
θ = cos–1 x or x = cos θ
where
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θ
θ = cos–1 x or x = cos θ
where
NOTE
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 −1 x}
1− x
2
=
U n +1 (x)
1 − x2
.
STATISTICAL COMPUTATION
7.39
603
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:
z
(1)
(2)
7.41
−1
z
1
−1
R|
S|
1− x
T
R|0;
( x) U ( x)
dx = Sπ / 2;
1− x
|T0;
Tn ( x) Tm ( x)
1
Un
2
U|
V|
W
if m ≠ n
U|
if m = n ≠ 0V .
if m = n = 0|
W
0;
if m ≠ n
dx = π / 2; if m = n ≠ 0
if m = n = 0
π;
m
2
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
7.42
ALITER TO FIND CHEBYSHEV POLYNOMIALS
AND
STATISTICAL TECHNIQUES
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
[T (x) + T2(x)]
2 0
x3 =
1
[3 T1(x) + T3(x)]
4
x4 =
1
[3 T0(x) + 4T2(x) + T4(x)]
8
STATISTICAL COMPUTATION
x5 =
1
[10 T1(x) + 5T3(x) + T5(x)]
16
x6 =
1
[10 T0(x) + 15T2(x) + 6T4(x) + T6(x)]
32
605
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
FG 2k − 1 πIJ , k = 1, 2, ......, n on the interval [– 1, 1]
H 2n K
(iii) Tn(x) assumes extreme values at (n + 1) points xk = cos
......, n and the extreme value at xk is (– 1)k.
(iv) | Tn(x) | ≤ 1, x ∈ [– 1, 1]
kπ
, k = 0, 1, 2,
n
(v) Tn(x) are orthogonal on the interval [– 1, 1] with respect to the weight
function
W(x) =
1
1 − x2
~
Tn ( x)
(vi) If pn(x) is any monic polynomial of degree n and Tn ( x) = n − 1 is the
2
monic Chebyshev polynomial, then
~
max |Tn ( x)|≤ max | pn ( x)|.
− 1≤ x ≤ 1
− 1≤ x ≤ 1
7.45
CHEBYSHEV POLYNOMIAL APPROXIMATION
Let f(x) be a continuous function defined on the interval [– 1, 1] and let c0 + c1x
+ c 2 x2 + ...... + c nx n be the required minimax (or uniform) polynomial
approximation for f(x).
606
COMPUTER-BASED NUMERICAL
Suppose
f(x) =
STATISTICAL TECHNIQUES
AND
a0
+
2
∞
∑
ai Ti ( x) is the Chebyshev series expansion for f(x).
i= 1
Then the truncated series or the partial sum
Pn(x) =
a0
+
2
n
∑
ai Ti ( x)
(75)
i= 1
is very nearly the solution to the problem
n
max
−1 ≤ x ≤ 1
f (x ) −
∑
ci x i = min
−1 ≤ x ≤ 1
i= 0
n
f (x ) −
∑c
i
xi
i= 0
i.e., the partial sum (75) is nearly the best uniform approximation to f(x).
Reason. Suppose we write
f(x) =
a0
+ a1T1(x) + a2T2(x) + ...... + anTn(x) + an + 1Tn + 1(x) + remainder
2
(76)
Neglecting the remainder, we obtain from (76),
f(x) –
LM a + a T ( x)OP = a
MN 2 ∑
PQ
n
0
i i
n+1Tn+1(x)
(77)
i =1
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
L ANCZOS 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) =
∑ ax ,–1≤x≤1
i
i
(78)
i =0
Then we change each power of x in (78) in terms of Chebyshev polynomials
and we obtain
∞
f(x) =
∑ c T (x)
i i
i =0
(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
n
Pn(x) =
∑ c T (x)
(80)
i i
i=0
is a good uniform approximation to f(x) in the sense
max | f(x) – Pn(x) | ≤ | cn + 1 | + | cn + 2 | + ...... ≤ ε (say)
−1 ≤ x ≤ 1
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 − x 2 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
[3T1(x) + T3(x)]
4
2x3 + 3x2 = 2
=
LM 1 {3T (x) + T (x)}OP + 3x
N4
Q
1
3
2
3
1
3
1
T1 ( x) + T3 ( x) + 3 x 2 = 3x2 + x + T3 ( x)
2
2
2
2
[∵ T1(x) = x]
608
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
3
x is the
2
1
required lower order approximation to the given cubic with a max. error ± in
2
range [– 1, 1].
Since
| T3(x) | ≤ 1, – 1 ≤ x ≤ 1 therefore, the polynomial 3x2 +
Example 3. Express 2 T0 (x) –
Sol. 2T0 (x) –
1
1
T (x) + T4 (x) as polynomials in x.
8
4 2
1
1
T2 (x) + T4 (x)
4
8
= 2 (1) −
=2−
1
1
(2 x 2 − 1) + (8 x 4 − 8 x 2 + 1)
4
8
1 2 1
1
x + + x4 − x2 +
2
4
8
= x4 −
3 2 19
x +
.
4
8
Example 4. Express 1 – x2 + 2x4 as sum of Chebyshev polynomials.
Sol.
1 – x2 + 2x4 = 1 – x2 + 2
= 1 – x2 +
= 1−
0
2
4
3
1
T0 ( x) + T2 ( x) + T4 ( x)
4
4
1
3
1
[T0 ( x) + T2 ( x)] + T0 ( x) + T2 ( x) + T4 ( x)
2
4
4
= T0 ( x) −
=
LM 1 {3T (x) + 4T (x) + T (x)}OP
N8
Q
1
1
3
1
T0 ( x) − T2 ( x) + T0 ( x) + T2 ( x) + T4 ( x)
2
2
4
4
5
1
1
T0 ( x) + T2 ( x) + T4 ( x) .
4
2
4
Example 5. Economize the power series: sin x ≈ x −
three significant digit accuracy.
x3
x5
x7
+ ...... to
+
−
6
120 5040
Sol. The truncated series is
sin x ≈ x −
x3
x5
+
6
120
(81)
STATISTICAL COMPUTATION
which is obtained by truncating the last term since
609
1
= 0.000198 will produce
5040
a change in the fourth decimal place only.
Converting the powers of x in (81) into Chebyshev polynomials, we get
sin x ≈ T1 ( x) −
≈ T1 ( x) −
≈
LM
N
OP
Q
LM
N
1
1
1 1
{3T1 ( x) + T3 ( x)} +
{10T1 ( x) + 5T3 ( x) + T5 ( x)}
120 16
6 4
OP
Q
1
1
[3T1 ( x) + T3 ( x)] +
[10T1 ( x) + 5T3 ( x) + T5 ( x)]
24
120 × 16
169
5
1
T1 ( x) −
T3 ( x) +
T5 ( x)
192
128
1920
Truncated series is
sin x ≈
169
5
T1 ( x) −
T3 ( x)
192
128
which is obtained by truncating the last term since
duce a change in the fourth decimal place only.
Economized series is
sin x ≈
=
1
= 0.00052 will pro1920
169
5
(4x3 – 3x)
x−
192
128
383
5 3
x−
x = 0.9974x – 0.1526x3
384
32
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
−1
1 − x2
(x4 – C0T0 – C1T1 – C2T2)2 dx
which is to be minimum.
Normal equations are given by
∂U
=0 ⇒
∂C 0
z
1
−1
( x 4 − C 0 T0 − C1T1 − C2 T2 )
T0
1 − x2
dx = 0
610
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
∂U
=0 ⇒
∂C 1
∂U
=0 ⇒
∂C 2
and
We find that
C0 =
1
π
C1 =
2
π
2
C2 =
π
z
z
z
1
z
z
1
( x 4 − C 0 T0 − C1T1 − C2 T2 )
−1
1
−1
( x 4 − C 0 T0 − C1T1 − C2 T2 )
x 4 T0
2
−1
1− x
1
x 4 T1
−1
1 − x2
1
−1
x 4 T2
1− x
2
dx =
T1
1 − x2
T2
1 − x2
dx = 0
dx = 0
3
8
dx = 0
dx =
1
2
Hence the required approximation is f(x) =
3
1
T0 + T2 .
8
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 +
x2 x3 x4
x5
+
+
+
+ ......
2
6
24 120
1
= 0.008......, therefore
120
Since
ex = 1 + x +
x2 x3 x 4
+
+
2
6
24
(82)
with a tolerance of ε = 0.02.
get
Changing each power of x in (82) in terms of Chebyshev polynomials, we
ex = T0 + T1 +
=
1
1
1
(T0 + T2) +
(3T1 + T3) +
(3T0 + 4T2 + T4)
4
24
192
81
9
13
1
1
T0 + T1 +
T2 +
T3 +
T4
64
8
48
24
192
(83)
STATISTICAL COMPUTATION
We have
by
611
1
= 0.005 ......
192
∴ 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
or
ex =
81
9
13
1
T0 + T1 +
T2 +
T3
64
8
48
24
ex =
x 3 13 2
191
.
x + x+
+
6
24
192
Example 8. The function f is defined by
1
f(x) =
x
z
x
0
2
1 − e−t
dt
t2
Approximate f by a polynomial P(x) = a + bx + cx2 such that
max. | f(x) – P(x) | ≤ 5 × 10–3.
|x|≤1
Sol. The given function
f(x) =
1
x
z
= 1−
x
0
F 1 − t + t − t + t − t + ......I dt
GH 2 6 24 120 720 JK
2
4
6
8
10
x2 x4
x6
x8
x 10
+
−
+
−
+ ......
6
30 168 1080 7920
(84)
The tolerable error is 5 × 10–3 ≈ 0.005.
Truncating the series (84) at x8, we get
P(x) = 1 −
x2 x4
x6
x8
+
−
+
6
30 168 1080
= T0 –
1
1
(T2 + T0) +
(T + 4T2 + 3T0)
12
240 4
–
1
(T6 + 6T4 + 15T2 + 10T0)
5376
+
1
(T + 8T6 + 28T4 + 56T2 + 35T0)
138240 8
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 =
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
1
[T0(x) + T2(x)]
2
y = A 1eλ 1 x + A 2 eλ 2 x
to the given data.
6.
7.
Obtain y(1.5) from the following data using cubic spline.
x:
1
2
3
y:
–8
–1
18
Economize the series
f(x) = 1 −
8.
x x2
x3
−
−
2
8
16
Economize the series sinh x = x +
x3
x5
x7
on the interval [– 1, 1] allowing for a
+
+
6
120 5040
tolerance of 0.0005.
9.
10.
Economize the series cos x = 1 −
x2
x4
x6
.
+
−
2
24 720
Obtain the cubic spline approximation valid in [3, 4], for the function given in the tabular form
x:
1
2
3
4
f(x):
3
10
29
65
under the natural spline conditions:
M(1) = 0 = M(4)
STATISTICAL COMPUTATION
11.
613
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.
14.
Find the natural cubic spline that fits the data
x:
1
2
3
4
f(x):
0
1
0
0
Find whether the following functions are splines or not?
U|
V
− x + 2x , 0 ≤ x ≤ 1 |
W
− x − 2 x , − 1 ≤ x ≤ 0 U|
(ii) f(x) =
V
x + 2 x , 0 ≤ x ≤ 1 W|
(i) f(x) =
− x2 − 2 x3 , − 1 ≤ x ≤ 0
2
2
3
3
2
3
[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) =
RSx − αx + 1, 1 ≤ x ≤ 2UV
T3 x − β, 2 ≤ x ≤ 3 W
2
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=
z
1
0
1
dx using the cubic spline method.
1+ x
18. Explain approximation of function by Taylor series by taking suitable example.
614
COMPUTER-BASED NUMERICAL
7.47
REGRESSION ANALYSIS
AND
STATISTICAL TECHNIQUES
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
615
STATISTICAL COMPUTATION
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.
Y
Y
Pi(xi, yi)
B
B
Pi(xi, yi)
H(xi, yi)
H(xi, yi)
A
A
O
O
X
FIGURE (a)
X
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
n
U=
∑
i=1
Ei2 =
n
∑ (y
i
i=1
− a − bxi ) 2
(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
= 0 and
∂a
∂U
=0
∂b
n
From (86),
∂U
(yi – a – bxi)(– 1)
=2
∂a
i=1
∑
∂U
= 0 gives 2
∂a
⇒
n
∑ (y – a – bx )(– 1) = 0
i=1
i
i
Σy = na + b Σx
(87)
n
Also,
∂U
=2
( yi − a − bxi )( − xi )
∂b
i=1
∑
∂U
= 0 gives 2
∂b
⇒
n
∑ (y – a – bx )(– x ) = 0
i=1
i
i
i
Σxy = a Σx + b Σx2
(88)
Equations (87) and (88) are called normal equations.
Solving (87) and (88) for ‘a’ and ‘b’, we get
1
Σx Σy
n Σxy − Σx Σy
n
b=
=
2
2
1
Σx 2 − (Σx) 2 n Σx − (Σx)
n
Σxy −
and
a=
Σy
Σx
−b
= y − bx
n
n
(89)
(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 = byx ( x − x )
where x and y are mean values while
byx =
n Σxy − Σx Σy
n Σx 2 − (Σx) 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
b=r
⇒
2
∵ Σ( x − x ) = 0
1
Σ( x − x ) 2 = σ x 2
n
Σ ( x − x )( y − y)
and
=r
nσ x σ y
σ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 =
or
n Σxy − Σx Σy
n Σy 2 − (Σy) 2
bxy = r
σx
σy
where the terms have their usual meanings.
618
NOTE
7.52
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.
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 relationship 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.
STATISTICAL COMPUTATION
7.54
619
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σ y
Geometric mean between them =
σx
×
rσ y
σx
and
rσ x
.
σy
rσ x
= r 2 = r = co-efficient of
σy
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 =
Let
byx > 1, then
σx
and bxy =
rσ x
.
σy
1
<1
byx
byx. bxy = r2 ≤ 1
Since
rσ y
(92)
(∵ – 1 ≤ r ≤ 1)
1
< 1.
byx
∴
bxy ≤
Similarly, if
bxy > 1, then byx < 1.
| using (92)
Property III. Arithmetic mean of regression co-efficients is greater
than the correlation co-efficient.
Proof. We have to prove that
byx + bxy
2
or
r
σy
σx
+r
>r
σx
> 2r
σy
or
σx2 + σy2 > 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 =
byx =
x–a
y−b
,v=
, where a, b, h and k are constants
h
k
rσ y
σx
= r.
F I
GH JK
kσ v
k rσ v
k
=
= bvu
hσ u h σ u
h
620
COMPUTER-BASED NUMERICAL
Similarly,
AND
STATISTICAL TECHNIQUES
h
b .
k uv
are both independent of a and b but not of h and k.
bxy =
Thus, byx and bxy
Property V. The correlation co-efficient and the two regression coefficients have same sign.
Proof. Regression co-efficient of y on x = byx = r
Regression co-efficient of x on y = bxy = r
σy
σx
σ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 θ =
σ xσ y
1 − r2
. 2
,
r
σx + σ y2
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=
Their slopes are
∴
rσ y
m1 =
σx
(x − x)
rσ y
σx
and
x−x =
and
m2 =
rσ x
( y − y)
σy
σy
rσ x
.
rσ y
σy
−
rσ x
σx
m2 − m1
=±
tan θ = ±
1 + m2 m1
σ y2
1+
σ x2
=±
σ xσ y
σ 2
1 − r2 σ y
1 − r2
.
. 2 x 2 =±
. 2
σx σx + σy
r
r
σ x + σ y2
Since r2 ≤ 1 and σx, σy are positive.
∴ +ve sign gives the acute angle between the lines.
STATISTICAL COMPUTATION
Hence
when r = 0, θ =
tan θ =
621
σ xσ y
1 − r2
. 2
r
σ x + σ y2
π
∴ The two lines of regression are perpendicular to each
2
other.
Hence the estimated value of y is the same for all values of x and viceversa.
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
7.57
PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A
REGRESSION LINE OF Y ON X
AND
STATISTICAL TECHNIQUES
#include<stdio.h>
#include<conio.h>
#include<math.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;i<data;i++)
{
printf("Value of x%d:",i+1);
scanf("%f",&x[i]);
}
printf{"\nEnter the value of f(x):\n"};
for(i=0;i<data;i++)
{
printf("Value of f(x%d):",i+1);
scanf("%f",&y[i]);
}
for(i=0;i<data;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("\n\nThe REGRESSION LINE OF Y on X is:\n");
printf("\t\t\t y=%.2f *x - (%.2f)",sum1,z);
getch(1);
}
7.58
PROGRAM TO IMPLEMENT LEAST SQUARE FIT OF A
REGRESSION LINE OF X ON Y
#include<stdio.h>
#include<conio.h>
#include<math.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;i<data;i++)
{
printf("Value of x%d: ",i+1);
scanf("%f",&x[i]);
}
printf("\nEnter the value of f(x): \n");
for(i=0;i<data; i++)
{
printf("Value of f(x%d):", i+1);
scanf("%f",&y[i]);
}
624
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
for(i=0;i<data;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("\n\nThe REGRESSION LINE OF X on Y is:\n");
printf("\t\t\t 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 =
and
bxy =
n Σxy − Σx Σy
n Σx 2 − (Σx) 2
n Σxy − Σx Σy
n Σy 2 − (Σy) 2
STATISTICAL COMPUTATION
625
Let us prepare the following table:
x
x2
y
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 =
∴
and
bxy =
(8 × 599) − (36 × 107)
(8 × 204) − (36) 2
(8 × 599) − (36 × 107)
(8 × 1763) − (107)
2
=
4792 − 3852 940
=
= 2.7976
1632 − 1296 336
=
940
= 0.3540
2655
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
Here,
∴
AND
STATISTICAL TECHNIQUES
n=5
x=
Σx 25
=5
=
n
5
y=
Σy 99
= 19.8
=
n
5
n Σxy − Σx Σy
byx =
n Σx 2 − (Σx) 2
=
(5 × 533) − (25 × 99)
(5 × 165) − (25) 2
= 0.95
Regression line of y on x is given by
y − y = byx ( x − x )
⇒
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
Multiplying (93) by 5,
8 x − 10 y + 66 = 0
(93)
40 x − 18 y − 214 = 0
(94)
40 x − 50 y + 330 = 0
(95)
32 y − 544 = 0
Subtracting (95) from (94),
y = 17
∴
∴ From (93),
or
8 x – 170 + 66 = 0
8 x = 104
Hence
x = 13,
(b) Variance of x = σx2 = 9
∴
σx = 3
∴
x = 13
y = 17
(given)
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
The regression co-efficient of x on y is
rσ y
= .8
σx
(96)
rσ x
= .45
σy
Multiplying (96) and (97), r2 = .8 × .45 = .36
(97)
∴ r = 0.6
(+ve sign with square root is taken because regression co-efficients are
+ve).
.8σ x .8 × 3
=
= 4.
0.6
r
Example 5. The regression lines of y on x and x on y are respectively y = ax + b,
x = cy + d. Show that
From (96),
σy =
σy
σx
=
bc + d
ad + b
a
and y =
,x=
.
1 − ac
1 − ac
c
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
∴
bxy = c
We know that,
byx = r
and
bxy = r
(99)
σy
(100)
σx
σx
σy
(101)
Dividing eqn. (100) by (101), we get
byx
bxy
=
σ y2
σx
2
⇒
2
a σy
= 2
c σx
⇒
σy
σx
=
a
c
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
1 − ac
bc + d
.
1 − ac
Example 6. For two random variables, x and y with the same mean, the two
regression equations are
y = ax + b and x = αy + β
Similarly, we get
x=
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)
⇒
and
y = ax + m (1 – a)
(104)
x – m = α(y – m)
⇒
x = αy + m (1 – α)
Comparing (104) and (105) with the given equations.
b = m (1 – a), β = m (1 – α)
∴
b 1− a
=
β 1− α
Again
m=
b
β
=
1− a 1− α
Since regression lines pass through ( x , y )
∴
and
x = αy + β
y = ax + b will hold.
⇒
m = am + b
m = αm + β
⇒
⇒
am + b = αm + β
m=
β−b
.
a−α
(105)
629
STATISTICAL COMPUTATION
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
(106)
y – y = byx ( x − x )
where byx is the coefficient of regression given by
byx =
n Σxy − Σx Σy
n Σx 2 − (Σx) 2
Now we form the table as,
x2
x
y
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 =
Also,
and
xy
mean x =
(5 × 537.949) − (12.28 × 209.1)
(5 × 32.6682) − (12.28)
2
=
121.997
= 9.726
12.543
Σx 12.28
= 2.456
=
n
5
Σy 2091
.
=
= 41.82
n
5
∴ From (106), we get
y=
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
Σx
= 13 and
n
Regression coefficient of y on x is
Sol. Here,
n = 10, x =
byx =
y=
n Σxy − Σx Σy
2
n Σx − (Σx)
=
2
=
Σy
= 22
n
(10 × 3467) − (130 × 220)
(10 × 2288) − (130) 2
34670 − 28600 6070
=
= 1.015
22880 − 16900 5980
∴ Regression line of y on x is
y – y = byx ( x − x )
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 2 − (Σy) 2
(10 × 3467) − (130 × 220)
(10 × 5506) − (220)
2
=
6070
= 0.9114
6660
Regression line of x on y is
x – x = bxy ( y − y)
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
σx2 = 130
Variance
σy2 = 165
Number of men,
n = 10
Σ(x – x )(y – y ) = 1220
∴ Coefficient of correlation,
r=
1220
122
Σ( x − x )( y − y )
=
=
= 0.83.
146.458
10 130 × 165
nσ x σ y
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
= 0.935.
130
Regression line of y on x is given by
y – y = byx ( x − x )
⇒
⇒
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
STATISTICAL TECHNIQUES
AND
Regression coefficients are
σy
byx = r
and
σx
= 0.95 ×
10.8
= 0.6107
16.8
σx
16.8
= 0.95 ×
= 1.477.
10.8
σy
bxy = r
Regression line of y on x is
y – y = byx ( x − x )
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 = bxy ( y − y)
⇒
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
= 10.556.
2
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
⇒
when x = 24,
633
y = 10.556x + 794.73
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
5
. What is the ratio of variances of x and y?
24
Sol. Regression line of x on y is
5x = 6y + 24
variability of x to that of y is
x=
6
24
y+
5
5
6
5
Regression line of y on x is
∴
bxy =
(108)
1000y = 768x – 3608
y = 0.768x – 3.608
∴
From (108),
r
From (109),
r
byx = 0.768
(109)
σx 6
=
σy 5
(110)
σ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
σ x2
σy
2
=
6
= 1.5625.
5 × 0.768
Taking the square root, we get
σx
5
= 1.25 =
4
σy
(113)
634
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Since the regression lines pass through the point ( x , y ), we have
5 x = 6 y + 24
1000 y = 768 x – 3608.
Solving the above equations for x and y , we get
x = 6 , y = 1.
Coefficient of variability of
Coefficient of variability of
∴ Required ratio =
σx
,
x
σy
y=
.
y
x=
F I 1×5 5
GH JK = 6 4 = 24 .
y σx
σx
y
×
=
x σy
σy
x
| 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 15000
= 150
=
n
100
Σy 6800
= 68
=
n
100
Regression coefficient of y on x,
y=
byx =
=
n Σxy − Σx Σy
2
n Σ x − ( Σ x)
2
=
(100 × 1022250) − (15000 × 6800)
(100 × 2272500) − (15000) 2
102225000 − 102000000
227250000 − 225000000
225000
= 0.1
2250000
Regression line of height (y) on weight (x) is given by
=
y – y = byx ( x − x )
⇒
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
Here, n = 7;
AND
STATISTICAL TECHNIQUES
x=
Σx 46 + 42 + 44 + 40 + 43 + 41 + 45
=
= 43
n
7
y=
Σy 40 + 38 + 36 + 35 + 39 + 37 + 41
= 38
=
n
7
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 2 − ( Σ x) 2
=
(7 × 11459) − (301 × 266)
(7 × 12971) − (301) 2
80213 − 80066 147
=
= 0.75
90797 − 90601 196
Regression line of y on x is given by
y – y = byx ( x − x )
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
2.
637
In a study between the amount of rainfall and the quantity of air pollution removed the
following data were collected:
Daily rainfall:
(in .01 cm)
4.3
4.5
5.9
5.6
6.1
5.2
3.8
2.1
Pollution removed: 12.6
(mg/m3)
12.1
11.6
11.8
11.4
11.8
13.2
14.1
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 regression 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 following 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
9
of the variance of y.
16
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
Variance of x 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
, find x , y and coefficient of correlation between x and y.
16
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
120
360
60
180
1280
1120
1120
760
Corn yield y:
(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:
7.59
x:
1
2
3
4
5
6
y:
5.0
8.1
10.6
13.1
16.2
20.0
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 – cxi2
n
Now, let
U=
∑E
i
2
i= 1
n
=
∑
i= 1
(yi – a – bxi – cxi2)2
By principle of Least squares, U should be minimum for the best values of
a, b and c.
For this,
∂U
∂U
∂U
= 0,
= 0 and
=0
∂a
∂b
∂c
∂U
=0
∂a
n
⇒
2
∑
i =1
⇒
(yi – a – bxi – cxi2) (– 1) = 0
Σy = na + bΣx + cΣx2
(116)
640
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
n
∂U
=0
∂b
⇒
2
∑
i=1
(yi – a – bxi – cxi2) (– xi) = 0
Σxy = aΣx + bΣx2 + cΣx3
⇒
(117)
n
∂U
=0
∂c
⇒
2
∑
i=1
⇒
(yi – a – bxi – cxi2) (– xi2) = 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
and
Σy = ma + bΣx + cΣx2
(120)
Σxy = aΣx + bΣx2 + cΣx3
(121)
Σx2y
(122)
=
aΣx2
+
bΣx3
+
cΣx4
STATISTICAL COMPUTATION
641
(a) Here m = 3
The table is as follows:
x
y
x2
x3
x4
xy
x2 y
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
x2 y
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
x2 y
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 2 + bΣx + 5c
Σxy = aΣx 3 + bΣx 2 + cΣx
Σx 2 y = aΣx 4 + bΣx 3 + cΣx 2
U|
V|
W
(132)
STATISTICAL COMPUTATION
643
The values of Σx, Σx2,...... etc., are calculated by means of the following
table:
x
y
x2
x3
x4
xy
x2 y
10
12
15
23
20
14
17
23
25
21
100
144
225
529
400
1000
1728
3375
12167
8000
10000
20736
50625
279841
160000
140
204
345
575
420
1400
2448
5175
13225
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)
x − 2.5
= 2x – 5 and v = y
0.5
The results in tabular form are:
Let
u=
x
y
u
v
u2
uv
u2 v
u3
1.0
1.5
2.0
2.5
3.0
3.5
4.0
1.1
1.3
1.6
2.0
2.7
3.4
4.1
–3
–2
–1
0
1
2
3
1.1
1.3
1.6
2.0
2.7
3.4
4.1
9
4
1
0
1
4
9
– 3.3
– 2.6
– 1.6
0
2.7
6.8
12.3
9.9
5.2
1.6
0
2.7
13.6
36.9
– 27
–8
–1
0
1
8
27
81
16
1
0
1
16
81
0
16.2
28
14.3
69.9
0
196
Total
u4
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
Σu2v = aΣu2 + bΣu3 + cΣu4
and
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
= x – 1933
1
v = y – 357
and the equation y = a + bx + cx2 is transformed to
v = a′ + b′u + c′u2
x
1929
1930
1931
1932
1933
1934
1935
1936
1937
Total
u
–
–
–
–
4
3
2
1
0
1
2
3
4
Σu = 0
y
v
uv
u2
u2 v
352
356
357
358
360
361
361
360
359
–5
–1
0
1
3
4
4
3
2
20
3
0
–1
0
4
8
9
8
16
9
4
1
0
1
4
9
16
– 80
–9
0
1
0
4
16
27
32
Σv = 11 Σuv = 51
Σu2 = 60 Σu2v = – 9
u3
u4
– 64
– 27
–8
–1
0
1
8
27
64
256
81
16
1
0
1
16
81
256
Σ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
u2 v
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
Σu = 0 Σv = 1140 Σu2 = 10 Σu2v = 2665 Σuv = 2055 Σu3 = 0 Σu4 = 34
Total
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
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.
(133)
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
Σy = ma + bΣx + cΣx 2
Σxy = aΣx + bΣx 2 + cΣx 3
Σx 2 y = aΣx 2 + bΣx 3 + cΣx 4
and
Here, m = 9
x
y
x2
x3
U|
V|
W
(134)
x4
xy
x2 y
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
Σxy = 421
Σx2y = 2771
Σx = 45
Σy = 74
Σx2 = 285
Σx3 = 2025 Σx4 = 15333
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)
647
STATISTICAL COMPUTATION
Sol. Normal equations to the parabola y = a + bx + cx2 are
Σy = ma + bΣx + cΣx2
and
(135)
cΣx3
(136)
Σx2y = aΣx2 + bΣx3 + cΣx4
(137)
Σxy = aΣx +
bΣx2
+
Here m = 4
The table is as follows:
x
y
x2
x3
x4
xy
–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
Σy = 5
Σx2 = 2
Σx4 = 2
Σxy = 0
Σx2y = 4
Σx = 0
Σx3 = 0
x2 y
Substituting these values in equations (135), (136) and (137); we get
and
5 = 4a + 2c
(138)
0 = 2b
(139)
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
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
649
650
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
A
For j = 0, 3
For i = 0, 3
If
i!=j
Yes
y = u(i, j)/u(j, j)
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)
Print a, b, c
STOP
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.
#include<stdio.h>
main()
{
int i,j,k,n;
No
STATISTICAL COMPUTATION
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; i<3; i++)
for(j=0; j<4; j++)
u[i][j]=0;
u[0][0]=n;
printf("\nEnter the value of x & y:\n");
for(i=0; i<n; 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;j<3;j++)
for (i=0;i<3;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];
651
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("\n\nEquation 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
n
U=
∑ (y
i
− a − bxi − czi ) 2
i=1
Differentiating U partially with respect to a, b, c; we get
n
∂U
=0 ⇒
∂a
2
∂U
=0 ⇒
∂b
2
∑ (y
i
− a − bxi − czi ) (– 1) = 0
i
− a − bxi − czi ) (– xi) = 0
i=1
n
∑ (y
i=1
STATISTICAL COMPUTATION
∂U
=0 ⇒
∂c
and
653
n
2
∑ (y
i
i=1
− a − bxi − czi ) (– 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
Σyz = aΣz + bΣzx + cΣz2
and
Here m = 4
x2
z2
yx
zx
yz
12
1
0
12
0
0
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
x
z
y
1
0
2
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
STATISTICAL TECHNIQUES
AND
ASSIGNMENT 7.6
1.
2.
3.
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
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
The profit of a certain company in
Xth
x:
1
2
3
4
5
y:
1250
1400
1650
1950
2300
year of its life are given by:
y − 1650
, show that the parabola of second degree of v on u is
50
v + 0.086 = 5.3 u + 0.643u2 and deduce that the parabola of second degree of y on x is
Taking u = x – 3 and v =
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 +
of Least Squares.
5.
7.61
cV2;
find a, b and c by using the Method
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
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
7.62
ADVANTAGES OF STATISTICAL QUALITY CONTROL
AND
STATISTICAL TECHNIQUES
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
7.63
657
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 inprocess 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
x =
Sample mean
x1 + x2 + ...... + x n 1
=
n
n
n
∑x
i
i=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=
and
R =
x1 + x2 + ...... + xk 1
=
k
k
k
∑x
i
i=1
R 1 + R 2 + ...... + R k 1
=
k
k
k
∑R
i
i=1
For X -chart
Central line =
x , when tolerance limits are not given
μ , when tolerance limits are given
UV
W
1
[LCL + UCL]
2
LCL is lower control limit and UCL is upper control limit
where
μ=
Now, LCL (for X -chart) = x − A 2 R
are set.
and UCL (for X -chart) = x + A 2 R
660
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
A2 depends on sample size n and can be found from the following table:
Sample 2
size (n)
A2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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) = D3 R
UCL (for R-chart) = D4 R 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 −
3R
d2
UTL = x +
3R
d2
where d2 is found from the above table.
Moreover, The process capability is given by 6σ = 6
deviation.
R
where σ is standard
d2
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(1 − p) .
∴ Mean value of fraction defective is p and standard deviation
σp =
∴
1
n
np(1 − p) =
p(1 − p)
n
CL = p
The upper and lower limits for P-chart are,
UCLP = p + 3σp = p + 3
p(1 − p)
n
662
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
p(1 − p)
.
n
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.
and
LCLP = p – 3σp = p – 3
CL = n p
where
p =
∑ np
∑n
UCLnp = n p + 3σnp = n p + 3 np (1 − p)
and
NOTE
(where σnp = nσp)
LCLnp = n p – 3 np (1 − p) .
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
663
STATISTICAL COMPUTATION
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=
C Number of defects in a sample
=
n
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 + 3
u
; LCLu = u − 3
n
u
and central line CL = u .
n
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 x = x + A 2 R = μ + A 2 R
LCL x = x − A 2 R = μ − A 2 R
where
Then,
R=
R 1 + R 2 + ...... + R 10 46
= 4.6
=
10
10
UCL X = 200 + (0.58 × 4.6) = 202.668
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
LCL X = 200 – (0.58 × 4.6) = 197.332.
(ii) Control limits for R chart.
Central limit
CL = R = 4.6
UCLR = D4 R = 2.11 × 4.6 = 9.706
LCLR = D3 R = 0 × 4.6 = 0
The X and R-charts are drawn below:
205
×
×
UCL = 202.668
CL = 200
LCL = 197.332
×
–
Sample mean X
200
195
190
1
2
3 4 5 6 7
Sample number
8
9
10
X-Chart
12
UCL = 9.706
Sample Range (R)
664
8
CL = 4.6
4
0
1
2
3 4 5 6
Sample number
7
R-Chart
8
9
10
LCL = 0
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.
x = 0.5230 cm
Sol. Mean diameter
S.D. σ = 0.0032 cm
n=4
(i) 2-sigma limits are as follows:
CL = x = 0.5230 cm
UCL = x + 2
LCL = x − 2
σ
n
σ
n
(ii) 3-sigma limits are as follows:
= 0.5230 + 2 ×
= 0.5230 − 2 ×
0.0032
4
0.0032
4
= 0.5262 cm
= 0.5198 cm.
CL = x = 0.5230 cm
σ
0.0032
= 0.5230 + 3 ×
UCL = x + 3
= 0.5278 cm
n
4
σ
0.0032
= 0.5230 − 3 ×
LCL = x − 3
= 0.5182 cm.
n
4
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
Number of
defective blades: 9 10 12 8
Sol. Here,
5
6
7
8
9 10 11 12 13 14 15
7 15 10 12 10 8
n = 1000
∑np = total number of defectives = 166
∑n = total number inspected = 1000 × 15
∴
p=
∑ np
166
=
= 0.011
∑ n 1000 × 15
7 13 14 15 16
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
n p = 1000 × 0.011 = 11
∴
Control limits are CL = n p = 11
UCLnp = np + 3 np (1 − p) = 11 + 3 11(1 − 0.011) = 20.894
LCLnp = np − 3 np (1 − p) = 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.
25
UCL = 20.894
Number of defective blades
666
20
15
10
5
LCL = 1.106
0
1
3
5
7
9
Sample number
(np-chart)
11
13
15
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
120
=
= 0.06
Total number of items inspected 20 × 100
UCLP = p + 3
p(1 − p)
= 0.06 + 3
n
LCLP = p − 3
p (1 − p)
0.06 (1 − 0.06)
= 0.06 − 3
= – 0.01095
n
100
0.06 (1 − 0.06)
= 0.13095
100
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
= 0.15 will go above UCLP.
100
(ii) After eliminating the 8th lot,
Revised value of p =
120 − 15
= 0.056
100 × 19
Revised control limits will be
UCLP = 0.056 + 3
0.056 (1 − 0.056)
= 0.125
100
LCLP = 0.056 – 3
0.056 (1 − 0.056)
= – 0.013 i.e., zero.
100
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
0.056 + 3
Squaring,
AND
STATISTICAL TECHNIQUES
0.056 (1 − 0.056)
= 0.09
n
FG
H
0.056 × 0.944
0.034
=
n
3
n=
0.056 × 0.944 0.034
=
n
3
⇒
IJ
K
2
= (0.01133)2
0.056 × 0.944
= 333.
0.01133 × 0.01133
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
2
= 2 + 1.96
= 3.239
n
5
LCLu = 2 – 1.96
2
= 0.761.
5
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 A 2 = 0.18, D3 = 0.41, D4 =
1.59 and d2 = 3.736. Also find the process capability.
Sol.
X=
∑ X 357.50
= 17.875
=
N
20
R=
∑ R 9.90
=
= 0.495
N
20
UCL X = X + A 2 R = 17.875 + (0.18 × 0.495) = 17.9641
LCL X = X − A 2 R = 17.875 – (0.18 × 0.495) = 17.7859
UCLR = D4 R = 1.59 × 0.495 = 0.78705
LCLR = D3 R = 0.41 × 0.495 = 0.20295
σ=
R 0.495
=
= 0.13253
d2 3.735
∴ 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
669
STATISTICAL COMPUTATION
Sub-group size is 2000
n = 2000
∴
CL = n p = 2000 × 0.1537 = 307.4
Central line
UCLnp = n p + 3σnp = np + 3 np (1 − p)
= 307.4 + 3 307.4 (1 − 0.1537) = 307.4 + 48.38774204
= 355.787742
LCLnp = np − 3 np (1 − p) = 307.4 – 48.38774204
and
= 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
2.
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]
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
4.
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
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.1
8
TESTING OF HYPOTHESIS
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.
671
672
COMPUTER-BASED NUMERICAL
8.2
SAMPLING
AND
STATISTICAL TECHNIQUES
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
z=
OF
HYPOTHESIS
673
t − E(t)
is normally distributed with mean 0 and variance unity.
S . E(t)
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
8.5
Statistic
Standard error
1.
x
σ/ n
2.
s
σ2 /2n
3.
Difference of two sample means x1 − x2
σ 12 σ 22
+
n1
n2
4.
Difference of two sample standard deviation s1 – s2
σ 12 σ 22
+
2n1 2n2
5.
Difference of two sample proportions p1 – p2
6.
Observed sample proportion p
P1Q1 P2Q2
+
n1
n2
PQ/n
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.
NOTE
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.
t − E(t )
S.E(t)
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
For larger samples corresponding to the statistic t, the variable z =
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.
Level of significance
Lower critical
value
(Two tailed test)
a
Upper critical
value
Rejection
region (a/2)
Rejection
region (a/2)
z = – za z = 0
Right tailed test
Acceptance
region
Rejection
region
(a)
z = 0 z = za
z = za
Left tailed test
Acceptance
region
Rejection
region
(a)
z = – za
z=0
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.
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)
Two tailed test
8.9
10% (0.1)
| z | = 1.966
Right tailed
zα = 2.33
zα = 1.645
zα = 1.28
Left tailed
zα = – 2.33
zα = – 1.645
zα = – 1.28
| z | = 0.645
STEPS IN TESTING OF STATISTICAL HYPOTHESIS
Step 1.
Step 2.
Step 3.
Step 4.
Step 5.
8.10
5% (0.05)
| zα | = 2.58
Null hypothesis. Set up H0 in clear terms.
Alternative hypothesis. Set up H1, so that we could decide whether
we should use one tailed test or two tailed test.
Level of significance. Select the appropriate level of significance
in advance depending on the reliability of the estimates.
t − E(t)
Test statistic. Compute the test statistic z =
under the null
S.E(t)
hypothesis.
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.
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) =
V(p) = V(X/n) =
S.E.(p) =
1
np
E( x) =
= p; E(p) = p
n
n
1
n
2
V(X) =
1(PQ)
= PQ/n
n
p − E( p)
p− p
PQ
=
;z=
~ N(0, 1)
S. E. ( p )
n
PQ/n
This z is called test statistic which is used to test the significant difference
of sample and population proportion.
NOTE
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
The confidence limits for the population proportion p are p ±
PQ
.
n
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
678
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
Here n = 400; X = Number of success = 216
p = proportion of success in the sample
X
216
=
= 0.54.
400
n
Population proportion = 0.5 = P; Q = 1 – P = 1 – 0.5 = 0.5.
Under H0, test statistic z =
|z|=
p−P
PQ/n
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.,
36
= 0.06
600
p = proportion of defectives in the population = 0.04
P = proportion of defective in the sample =
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−P
PQ/n
=
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
= 0.05
100
Q = 1 – P = 1 – 0.05 = 0.95
Alternative hypothesis. p > 0.05 (Right tailed test).
30
= 0.075
p = observed proportion of sample =
400
Under H0, the test statistic
z=
p−P
PQ/n
∴ 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
= 0.05 ± 0.02135 = 0.07136, 0.02865
400
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.
10
Sol. Here p = proportion of defective articles =
= 0.1;
100
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=
p1 − p2
PQ
FG 1 + 1 IJ
Hn n K
1
and
Q = 1 – P.
2
, where P =
n1 p1 + n2 p2
n1 + n2
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
X
800
4
800 2
=
= ;p = 2 =
=
n1 1000 5 2
n2 1200 3
P=
p1n1 + p2 n2
3
X + X2
800 + 800
8
=
= 1
=
;Q=
11
n1 + n2
n1 + n2
1000 + 1200 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=
p1 − p2
F 1 + 1 IJ
PQ G
Hn n K
1
=
2
0.8 − 0.6666
FG
H
8
3
1
1
×
+
11 11 1000 1200
IJ
K
= 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
= 0.032; n1 = 500
500
p2 =
3
= 0.03; n2 = 100
100
Null hypothesis H0: The machine has not improved due to overhauling,
p1 = p2.
H1: p1 > p2 (right-tailed)
∴
P=
p1n1 + p2 n2
19 ~
=
= 0.032
600
n1 + n2
682
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Under H0, the test statistic
z=
p1 − p2
F 1 + 1 IJ
PQ G
Hn n K
1
0.032 − 0.03
=
(0.032)(0.968)
2
FG 1 + 1 IJ
H 500 100 K
= 0.104.
Conclusion. The calculated value of | z | < 1.645, the significant value of
z at 5% level of significance, H 0 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.
H 0: Sample proportions are equal, i.e., the difference in population
proportions is likely to be hidden in sampling.
H1: p1 ≠ p2
z=
P1 − P2
P1Q1 P2Q 2
+
n1
n2
=
0.3 − 0.25
0.3 × 0.7 0.25 × 0.75
+
1200
900
= 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)
p1 − p2
Under H0, z =
1
1
PQ
+
n1 n2
FG
H
IJ
K
TESTING
P=
OF
HYPOTHESIS
683
n1 p1 + n2 p2 0.02(500) + (0.015)(800)
=
= 0.01692;
500 + 800
n1 + n2
Q = 1 – P = 0.9830
z=
0.02 − 0.015
F 1 + 1 IJ
0.01692 × 0.983 G
H 500 800 K
= 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.
x−μ
The test statistic is z =
, where σ is the standard deviation of the
σ/ n
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.
NOTE
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
σ .
n
n
At 5% level of significance, 95% confidence limits are
x − zα
σ
x − 1.96
< μ < x + zα
σ
< μ < x + 1.96
σ
n
n
At 1% level of significance, 99% confidence limits are
x − 2.58
σ
< μ < x + 2.58
σ
.
n
n
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
1.5/ 900
= | – 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
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
= 1.6666.
6
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 population.
4.
The guaranteed average life of certain type of bulbs is 1000 hours with a standard deviation 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 deviation 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 σ12. Let x2 be the mean of an independent sample of size n2 from
another population with mean μ2 and variance σ22. The test statistic is given
by z =
x1 − x2
σ 12 σ 2 2
+
n1
n2
.
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
x1 − x2
z=
σ
NOTE
1
1
+
n1 n2
.
1. If σ1, σ2 are not known and σ1 ≠ σ2 the test statistic in this case is
z=
x1 − x 2
s1 2 + s2 2
n1 + n 2
.
TESTING
2. If σ is not known and σ1 = σ2. We use σ2 =
z=
n1 s1 + n 2 s2 2
n1 + n 2
FG 1 + 1 IJ
Hn n K
1
HYPOTHESIS
687
n1 s1 2 + n2 s2 2
to calculate σ;
n1 + n 2
x1 − x 2
2
OF
.
2
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: x1 = x2 , H1: x1 ≠ x2
Under H0,
z=
x1 − x2
s12
2
s
+ 2
n1
n2
=
210 − 220
10 2 12 2
+
100 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 =
x1 − x2
s12
2
s
+ 2
n1
n2
=
75 − 73
8 2 10 2
+
60 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 deviation 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 average 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 standard 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
z=
s1 − s2
σ 12 σ 2 2
+
2n1 2n2
OF
HYPOTHESIS
689
, where σ1 and σ2 are population standard deviations.
When population standard deviations are not known, then z =
s1 − s2
s12
s 2
+ 2
2n1 2n2
.
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: H 0 = μ1 = μ2 i.e., sample means do not differ
significantly.
Alternative hypothesis: H1: μ1 ≠ μ2 (two tailed test)
z=
x1 − x2
s12 s2 2
+
n1
n2
=
67.42 − 67.25
(2.58) 2 (2.50) 2
+
1000
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=
s1 − s2
σ 12 σ 2 2
+
2n1 2n2
=
s1 − s2
s12
s 2
+ 2
2n1 2n2
(∵ σ1 = s1, σ2 = s2 for large samples)
=
2.58 − 2.50
(2.58) 2
(2.50) 2
×
2 × 1000 2 × 1200
=
0.08
6.6564 6.25
+
2000
2400
= 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
Mean yield per plot
Standard deviation per plot
2.
8.11
Set of 60 plots
1258 lb
1243 lb
34
28
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 ?
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 =
where
s=
x−μ
s/ n
~ t(n – 1 d. f) d.f–degrees of freedom
Σ(X − X ) 2
.
n−1
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 coefficients.
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
8.13
TEST I: t-TEST OF SIGNIFICANCE OF THE MEAN OF A RANDOM
SAMPLE
AND
STATISTICAL TECHNIQUES
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=
s2 =
X−μ
where X is mean of the sample.
s/ n
1
n−1
n
∑
( X i − X ) 2 with degrees of freedom (n – 1).
i=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 .
NOTE
Instead of calculating s, we calculate S for the sample.
Since
∴
s2 =
S2 =
1
n−1
1
n
n
∑
i=1
n
∑
(X i − X ) 2
i=1
(X i − X ) 2 .
| ∵ (n – 1)s2 = nS2
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;
t:
X−μ
s/ n
H1: μ ≠ 56
(Two-tailed test)
~ t(n – 1 difference)
X = 53, μ = 56, n = 16, Σ (X − X) 2 = 135
Given:
s=
Σ(X − X ) 2
=
n−1
53 − 56
135
= 3; t =
=–4
3/ 16
15
| 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
s
=X±
t0.05 = 53 ±
3
(1.725) = 51.706; 54.293
n
16
99% confidence limits of the population mean
s
=X±
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
Life in ‘000’ hrs.
1
2
3
4
5
6
7
8
9
10
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
STATISTICAL TECHNIQUES
AND
Applying the t-test:
t=
X−μ
~ t(10 – 1 difference)
s/ n
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 44
= 4.4
=
n
10
Σ (X − X) 2 = 3.12
Σ(X − X) 2
3.12
4.4 − 4
= 0.589; t =
= 2.123
=
0.589
n−1
9
10
= 2.26.
s=
For γ = 9, t0.05
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 =
Applying t-test
t=
LM
N
OP
Q
n
20
S2 =
(5)2 = 26.31
n−1
20 − 1
X−μ
s/ n
=
42 − 45
5.129/ 20
∴ s = 5.129
= – 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 442
Σ(X − X) 2
=
= 49.11; Σ (X − X) 2 = 54.89; s2 =
= 6.86
n
9
(n − 1)
s = 2.619
Applying t-test
t=
X−μ
s/ n
=
49.1 − 47.5
2.619/ 8
=
(1.6) 8
= 1.7279
2.619
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.
2.
3.
4.
8.14
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.
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.
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.
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.
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, ......, x n1 , 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)
1
1
s
+
n1 n2
~ t(n1 + n2 – 2 difference)
1. If the two sample’s standard deviations s1, s2 are given, then we have
NOTE
2
2
s2 = n1 s1 + n 2 s2 .
n1 + n 2 − 2
2. If n1 = n2 = n, t =
X −Y
s1 2 + s2 2
n−1
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 =
with degrees of freedom n – 1.
The test statistic is
t=
or
i.e.,
t=
d
s/ n
d
s/ n − 1
, where d is the mean of paired difference.
d i = xi – yi
di = X − Y , where (xi, yi) are the paired data i = 1, 2, ......, n.
X −μ
s/ n
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.
n1s12 + n2 s2 2 8(36) 2 + 7(40) 2
= 1659.076
=
n1 + n2 − 2
8+7−2
s2 =
∴
s = 40.7317
The t-statistic
t=
X1 − X2
s
1
1
+
n1 n2
=
1234 − 1036
40.7317
1 1
+
8 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.
n1
where
X =
∑
i=1
Xi
,
ni
n2
Y =
∑
j=1
Yj
n2
; s2 =
1
[ Σ ( X i − X ) 2 + ( Y j − Y) 2 ]
n1 + n2 − 2
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
X = 20.3, X 2 = 18.6; n1 = 10, n2 = 14, s1 = 3.5, s2 = 5.2
Given
s2 =
t=
n1s12 + n2 s2 2 10(3.5) 2 + 14(5.2) 2
= 22.775 ∴ s = 4.772
=
n1 + n2 − 2
10 + 14 − 2
X1 − X2
1
1
+
s
n1 n2
=
F
GH
20.3 − 18.6
I
JK
1
1
4.772
+
10 14
= 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
X 1 – X1
–5
–3
0
1
3
4
(X1 − X1 ) 2
25
9
0
1
9
16
X1 =
ΣX 1
= 68; Σ (X 1 − X 1 ) 2 = 60
n1
X2
61
62
65
66
69
70
71
72
73
X2 – X 2
– 6.66
– 5.66
– 2.66
1.66
1.34
2.34
3.34
4.34
5.34
(X 2 − X 2 ) 2
44.36 32.035 7.0756 2.7556 1.7956 5.4756 11.1556 18.8356 28.5156
X2 =
ΣX 2
= 67.66; Σ (X 2 − X 2 ) 2 = 152.0002
n2
TESTING
s2 =
=
OF
HYPOTHESIS
699
1
[ Σ(X 1 − X 1 ) 2 + Σ (X 2 − X 2 ) 2 ]
n1 + n2 − 2
1
[60 + 152.0002] = 16.3077 ∴ s = 4.038
6+9−2
X1 − X2
Under H0, t =
s
1
1
+
n1 n2
=
68 − 67.666
4.0382
1 1
+
6 9
= 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 =
d
s/ n − 1
~ t(n – 1 degrees of freedom)
5 + 2 + 8 + (− 1) + 3 + 0 + 6 + (− 2) + 1 + 5 + 0 + 4
= 2.583
12
Σd 2
1
− d2 =
[52 + 22 + 82 + (– 1)2 + 32 + 02 + 62
n
12
+ (– 2)2 + 12 + 52 + 02 + 42] – (2.583)2
= 8.744 ∴ s = 2.9571
s2 =
t=
d
s/ n − 1
=
2.583
2.9571 / 12 − 1
=
= 2.897 ~ t(n – 1 difference)
2.583 11
2.9571
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 =
t=
Σd − 7
Σd 2
29
=
− (d ) 2 =
= – 0.7778; s2 =
– (– 0.7778)2 = 2.617
n
9
n
9
d
s/ n − 1
=
− 0.7778
2.6172 / 8
=
− 0.7778 × 8
= – 1.359
1.6177
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
X 1 – X1
– 1.6
3.4
1.4
7.4
– 2.6
– 6.6
– 13.6
5.4
4.6
11.4
(X1 − X1 ) 2
2.56
X2
40
34
22
20
31
40
30
23
36
17
X2 – X 2
10.7
4.7
– 7.3
– 9.3
1.7
10.7
0.7
– 6.3
6.7
– 12.3
(X 2 − X 2 ) 2
11.56 1.96
43.56 184.96 29.16 21.16 129.96
114.49 22.09 53.29 86.49 2.89 114.49
10
X1 =
∑
i=1
X1
= 26.6
n1
Σ (X 1 − X 1 ) 2 = 486.4
s2 =
=
∴
54.76 6.76
10
X2 =
∑
i=1
0.49
39.67 44.89 151.29
X 2 293
=
= 29.3
n2
10
Σ (X 2 − X 2 ) 2 = 630.08
1
[ Σ(X 1 − X 1 ) 2 + Σ (X 2 − X 2 ) 2 ]
n1 + n2 − 2
1
[486.4 + 630.08] = 62.026
10 + 10 − 2
s = 7.875
702
COMPUTER-BASED NUMERICAL
STATISTICAL TECHNIQUES
AND
Under H0 the test statistic is given by
t=
X1 − X2
=
1
1
+
s
n1 n2
26.6 − 29.3
1
1
+
7.875
10 10
= – 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.
2.
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 ?
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
Diet B:
2
3
6
8
10
1
2
8
6
10
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
6.
8.15
OF
HYPOTHESIS
703
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?
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 s12 and s22. The
estimate of the population variance based on these samples is s12 =
n1s12
and
n1 − 1
n2 s2 2
. The degrees of freedom of these estimates are ν1 = n 1 – 1,
n2 − 1
ν2 = n2 – 1.
s2 2 =
To test whether these estimates, s12 and s22, 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: σ12 = σ22 = σ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 =
s12
s2 2
, the Numerator is greater than the
Denominator, i.e., s12 > s22.
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 σ12 to σ22 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
B
16
16
20
27
26
25
21
17
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: σ12 = σ22 i.e., the population variance do
not differ significantly.
Alternative hypothesis. H1: σ12 ≠ σ22
s12
, (if s12 > s22)
s2 2
Computations for s12 and s22
Test statistic:
F=
X1
X1 – X1
(X1 − X1 ) 2
X2
X2 – X 2
(X 2 − X 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
2
X 1 = 21.625; n1 = 8; Σ (X1 − X1 ) = 253.87
X 2 = 18.714; n2 = 7; Σ (X 2 − X 2 ) 2 = 182.859
s12 =
Σ(X 1 − X 1 ) 2 253.87
= 36.267;
=
n1 − 1
7
s22 =
Σ(X 2 − X 2 ) 2 182.859
= 30.47
=
n2 − 1
6
F=
s12
s2
2
=
36.267
= 1.190.
30.47
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 1 − X 1 ) 2 + Σ (X 2 − X 2 ) 2 253.87 + 182.859
= 33.594
=
n1 + n2 − 2
8+7−2
s = 5.796
t=
X1 − X2
1
1
+
s
n1 n2
=
21.625 − 18.714
1 1
5.796
+
8 7
= 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
Sample B
29
30
30
24
27
28
34
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., σ12 = σ22
i.e., the samples have been drawn from normal populations with same variance.
H1: σ12 ≠ σ22
Under null hypothesis, the test statistic F =
s12
s2 2
(s12 > s22)
Computations for s12 and s22
X1
X1 – X1
(X1 − X1 ) 2
X2
X2 – X 2
(X 2 − X 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
X 1 = 31,
n1 = 7; Σ (X 1 − X 1 ) 2 = 28
X 2 = 28,
n2 = 6; Σ (X 2 − X 2 ) 2 = 26
s12 =
F=
Σ(X 2 − X 2 ) 2 26
Σ(X 1 − X 1 ) 2 28
=
= 4.666; s22 =
= 5.2
=
n2 − 1
5
n1 − 1
6
s2 2
s12
=
5.2
= 1.1158.
4.666
(∵ s22 > s12)
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. σ12 = σ22
The population variance do not differ significantly.
Alternative hypothesis. σ12 ≠ σ22
Under the null hypothesis the test statistic is given by F =
s12
s2 2
, (s12 > s22)
Given: n1 = 16, n2 = 25; s12 = 40, s22 = 42
F=
∴
s12
s2
2
=
n1s12
n1 − 1
2
n2 s2
n2 − 1
=
16 × 40
24
×
= 0.9752.
15
25 × 42
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, X 1 = 440, X 2 = 460
s2 =
∴
n1 s12 + n2 s2 2 16 × 40 + 25 × 42
= 43.333
=
n1 + n2 − 2
16 + 25 − 2
s = 6.582
X1 − X2
t=
s
1
1
+
n1 n2
=
440 − 460
6.582
1
1
+
16 25
= – 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.
2.
3.
4.
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
Sample 2
16
16
20
16
20
17
15
21
17
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
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?
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
L (O
∑ MMN
n
χ2 =
i=1
i
− Ei )2
Ei
OP
PQ
where ΣOi = ΣEi = N (total frequency) and degrees of freedom (difference)
= (n – 1).
NOTE
(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.
NOTE
(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:
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.
NOTE
8.17
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.
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.
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.
8.18
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.
χ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
= 14
6
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 i − Ei ) 2 30
=
= 2.1428.
Ei
14
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
= 46.
6
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 i − Ei ) 2 980
=
= 21.30.
Ei
46
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
713
HYPOTHESIS
Example 3. The following table shows the distribution of digits in numbers
chosen at random from a telephone directory:
Digits
Frequency
0
1
1026 1107
2
3
4
997
966
5
1075 933
6
7
8
9
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
= 1000
10
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
χ2 =
784
1296 21609
Σ(O i − Ei )2 58542
=
= 58.542.
Ei
1000
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
= 800 × 1 ×
1
24
4
= 50
FG 1IJ FG 1IJ
H 2K H 2 K
1
N(1) = 800 × 4C1
FG 1IJ
H 2K
= 200; N(2) = 800 × 4C2
FG 1IJ FG 1IJ
H 2K H 2K
= 200; N(4) = 800 × 4C4
FG 1IJ FG 1IJ
H 2K H 2K
3
2
2
= 300
N(3) = 800 × 4C3
FG 1IJ FG 1IJ
H 2K H 2 K
1
3
0
4
= 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
(Oi − Ei ) 2
Ei
6.48
2.42
0.333
6.48
38.72
Σ(O i − Ei ) 2
= 54.433.
Ei
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.
χ2 =
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.
NOTE
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 =
Σfi xi 94
=
=2
Σfi
47
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 .
mr
, N is the total frequency.
r!
N(0) = 47 × e–2 .
(2) 0
(2) 1
= 6.36 ≈ 6; N(1) = 47 × e–2 .
= 12.72 ≈ 13
0!
1!
N(2) = 47 × e–2 .
( 2)2
(2) 3
= 12.72 ≈ 13; N(3) = 47 × e–2 .
= 8.48 ≈ 9
2!
3!
N(4) = 47 × e–2 .
(2) 4
(2)5
= 4.24 ≈ 4; N(5) = 47 × e–2 .
= 1.696 ≈ 2.
4!
5!
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
(Oi − Ei ) 2
Ei
0.2037
0.00616
0.00616
0.02716
0.0135
1.0026
χ2 =
Σ(O i − Ei ) 2
= 1.2864.
Ei
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
1600 × 3
= 900; E(G2) =
= 300;
16
16
E(G3) =
1600 × 3
1600 × 1
= 300; E(G4) =
= 100
16
16
To calculate the value of χ2.
Observed frequency Oi
882
313
287
118
Expected frequency Ei
900
300
300
100
(Oi − Ei ) 2
Ei
0.36
0.5633
0.5633
3.24
χ2 =
Σ(Oi − Ei ) 2
= 4.7266.
Ei
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.
2.
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
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
3.
4.
5.
6.
7.
8.
OF
717
HYPOTHESIS
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 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?
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
In the accounting department of bank, 100 accounts are selected at random and estimated 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?
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?
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
9.
χ20.05 = 11.07 for 5 degrees of freedom.
A survey of 320 families with 5 children shows the following distribution:
Number of boys 5 boys
& girls:
& 0 girl
Number of
families:
18
χ2
4 boys
3 boys
2 boys
1 boy
0 boy
& 1 girl & 2 girls & 3 girls & 4 girls & 5 girls
56
110
88
40
8
Total
320
Given that values of
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
8.19
χ2 TEST AS A TEST OF INDEPENDENCE
AND
STATISTICAL TECHNIQUES
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
r
attributes Ai and Bj. Also we have
s
∑ A =∑ B
i
i=1
j
= N where N is the total
j=1
frequency. The contingency table for r × s is given below:
A
A1
A2
A3
...Ar
Total
B1
(A1B1)
(A2B1)
(A3B1)
......(ArB1)
B1
B2
(A1B2)
(A2B2)
(A3B2)
......(ArB2)
B2
B
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
(A i )
Ai =
i = 1, 2, ......, r
N
P(Bj) = Probability that a person possesses the attribute Bj =
(B j )
N
TESTING
OF
HYPOTHESIS
719
P(AiBj) = Probability that a person possesses both attributes Ai and Bj
=
(A iB j )
N
If (AiBj)0 is the expected number of persons possessing both the attributes
Ai and Bj
(AiBj)0 = NP(AiBj) = NP(Ai)(Bj)
=N
χ2 =
(∵ A and B are independent)
L [(A B ) − (A B ) ] OP
∑ ∑ MM
PQ
N (A B )
r
Hence
( A i ) ( B j ) ( A i )( B j )
=
N
N
N
s
i
j
i
i
i=1 j=1
j 0
2
j 0
which is distributed as a χ2 variate with (r – 1)(s – 1) degrees of freedom.
NOTE
1. For a 2 × 2 contingency table where the frequencies are
calculated from independent frequencies as
χ2 =
a/b 2
, χ can be
c/d
(a + b + c + d)(ad − bc) 2
.
(a + b)(c + d)(b + d)(a + c)
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 (A iBj)0 =
frequency in each cell is =
(Ai )(B j )
N
i.e., expected
Product of column total and row total
.
whole total
ad − bc
a|b
is the 2 × 2 contingency table with two attributes, Q =
is
ad + bc
c|d
called the coefficient of association. If the attributes are independent
3. If
then
a c
= .
b 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.
1
those cell frequencies which are greater than expected
2
1
frequencies, and increase by
those which are less than expectation.
2
This will not affect the marginal columns. This correction is known as
Yates’s correction to continuity.
Decrease by
720
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
FG
H
IJ
K
2
1
N
2
After Yates’s correction χ2 =
when ad – bc < 0
(a + c)(b + d)(c + d)(a + b)
N bc − ad −
FG
H
IJ
K
2
1
N
2
χ2 =
(a + c)(b + d)(c + d)(a + b)
N ad − bc −
when ad – bc > 0.
EXAMPLES
Example 1. What are the expected frequencies of 2 × 2 contingency tables given
below:
a
b
(i)
c
Sol.
(i)
d
10
6
6
Observed frequencies
a
b
a+b
c
d
c+d
a+c
b+d
a+b+c+d=N
Observed frequencies
(ii)
2
(ii)
2
10
12
6
6
12
8
16
24
Expected frequencies
( a + c )( a + b )
a +b+c+d
(b + d)( a + b)
a+b+c+d
(a + c)(c + d)
a+b+c+d
(b + d)( c + d)
a+b+c+d
→
Expected frequencies
8 × 12
=4
24
16 × 12
=8
24
8 × 12
=4
24
16 × 12
=8
24
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
Eye color of father
Light
Not light
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
Light
619 × 522
= 359.02
900
289 × 522
= 167.62
900
522
Not light
619 × 378
= 259.98
900
289 × 378
= 121.38
900
378
619
289
900
Eye color
of father
Total
χ2 =
(471 − 359.02) 2 (51 − 167.62) 2 (148 − 259.98) 2 (230 − 121.38)2
+
+
+
359.02
167.62
259.98
121.38
= 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
L [(A B ) − (A B )]
∑ ∑ MM
N (A B )
2
χ2 =
Under H0,
3
i
j 0
i=1 j=1
i
i
j
2
j 0
OP
PQ
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 1 )(B 2 ) (2850) × (1000)
=
= 954.77;
N
2985
(A1B2)0 =
(A 1 )(B 2 ) (2850) × (990)
=
= 945.226
N
2985
(A1B3)0 =
( A 1 )(B 3 ) (2850) × (995)
=
= 950;
N
2985
(A2B1)0 =
(A 2 )(B 1 ) (135) × (1000)
=
= 45.27
N
2985
(A2B2)0 =
(A 2 )(B 2 ) (135) × (990)
=
= 44.773;
N
2985
(A2B3)0 =
( A 2 )(B 3 ) (135) × (995)
=
= 45.
N
2985
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
Sex
2.
3.
Middle
High school
College
Male
10
15
25
Female
25
10
15
Based on this information can you say the education depends on sex.
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 smoking and literacy.
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
2
3
4
5
1.00
0.82
0.77
0.74
0.73
6.31
0.92
2.32
2.13
2.02
12.71
4.30
3.18
2.78
2.57
31.82
6.97
4.54
3.75
3.37
63.66
6.93
5.84
4.60
4.03
636.62
31.60
12.94
8.61
6.86
6
7
8
9
10
0.72
0.71
0.71
0.70
0.70
1.94
1.90
1.80
1.83
1.81
2.45
2.37
2.31
2.26
2.23
3.14
3.00
2.90
2.82
2.76
3.71
3.50
3.36
3.25
3.17
5.96
5.41
5.04
4.78
4.59
11
12
13
14
15
0.70
0.70
0.69
0.69
0.69
1.80
1.78
1.77
1.76
1.75
2.20
2.18
2.16
2.15
2.13
2.72
2.68
2.65
2.62
2.60
3.11
3.06
3.01
2.98
2.95
4.44
4.32
4.22
4.14
4.07
16
17
18
19
20
0.69
0.69
0.69
0.69
0.69
1.75
1.74
1.73
1.73
1.73
2.12
2.11
2.10
2.09
2.09
2.58
2.57
2.55
2.54
2.53
2.92
2.90
2.88
2.86
2.85
4.02
3.97
3.92
3.88
3.85
21
22
23
24
25
0.69
0.69
0.69
0.69
0.68
1.72
1.72
1.71
1.71
1.71
2.08
2.07
2.07
2.06
2.06
2.52
2.51
2.50
2.49
2.49
2.83
2.82
2.81
2.80
2.79
3.83
3.79
3.77
3.75
3.73
26
27
28
29
30
0.68
0.68
0.68
0.68
0.68
1.71
1.70
1.70
1.70
1.70
2.06
2.05
2.05
2.05
2.04
2.48
2.47
2.47
2.46
2.46
2.78
2.77
2.76
2.76
2.75
3.71
3.69
3.67
3.66
3.65
∞
0.67
1.65
1.96
2.33
2.58
3.29
4.60
4.54
4.49
4.45
4.41
14
15
16
17
18
5.12
9
4.67
5.32
8
13
5.59
7
4.75
5.99
6
12
6.61
5
4.96
7.71
4
4.84
10.1
3
10
18.5
2
11
161
1
1
3.55
3.16
3.20
3.24
3.29
3.34
3.41
3.49
3.59
3.71
3.86
4.07
4.35
4.76
5.41
6.59
9.28
19.2
216
3
2.93
2.96
3.01
3.06
3.11
3.18
3.26
3.36
3.48
3.63
3.84
4.12
4.53
5.19
6.39
9.12
19.2
225
4
2.77
2.81
2.85
3.90
3.96
3.03
3.11
3.20
3.33
3.48
3.69
3.97
4.39
5.05
6.26
9.01
19.3
230
5
2.66
2.70
2.74
2.79
2.85
2.92
3.00
3.09
3.22
3.37
3.58
3.87
4.28
4.95
6.16
9.94
19.3
234
6
2.58
2.61
2.66
2.71
2.76
2.83
2.91
3.01
3.14
3.29
3.50
3.79
4.21
4.88
6.09
8.89
19.4
237
7
2.51
2.55
2.59
2.64
2.70
2.77
2.85
2.95
3.07
3.23
3.44
3.73
4.15
4.82
6.04
8.85
19.4
239
8
2.46
2.49
2.54
2.59
2.65
2.71
2.80
2.90
3.02
3.18
3.39
3.68
4.10
4.77
6.00
8.81
19.4
241
9
2.41
2.45
2.49
2.54
2.60
2.67
2.75
2.85
2.98
3.14
3.35
3.64
4.06
4.74
5.96
8.79
19.4
242
10
2.34
2.38
2.42
2.48
2.53
2.60
2.69
2.79
2.91
3.07
3.28
3.57
4.00
4.68
5.91
8.74
19.4
244
12
2.27
2.31
2.35
2.40
2.46
2.53
2.62
2.72
2.85
3.01
3.22
3.51
3.94
4.62
5.86
8.70
19.4
246
15
2.19
2.23
2.28
2.33
2.39
2.46
2.54
2.65
2.77
2.94
3.15
3.44
3.87
4.56
5.80
8.66
19.4
248
20
2.15
2.19
2.24
2.29
2.35
2.42
2.51
2.61
2.74
2.90
3.12
3.41
3.84
4.53
5.77
8.64
19.5
249
24
2.11
2.15
2.19
2.25
2.31
2.38
2.47
2.57
2.70
2.86
3.08
3.38
3.81
4.50
5.75
8.62
19.5
250
20
2.06
2.10
2.15
2.20
2.27
2.34
2.43
2.53
2.66
2.83
3.04
3.34
3.77
4.46
5.72
8.59
19.5
251
40
2.02
2.06
2.11
2.16
2.22
2.30
2.38
2.49
2.62
2.79
3.01
3.30
3.74
4.43
5.69
8.57
19.5
252
60
1.97
2.01
2.06
2.11
2.18
2.25
2.34
2.45
2.58
2.75
2.97
3.27
3.70
4.40
6.66
8.55
19.5
253
120
1.92
1.96
2.01
2.07
2.13
2.21
2.30
2.40
2.54
2.71
2.93
3.23
3.67
4.37
5.63
8.53
19.5
254
∞
OF
3.59
3.63
3.68
3.74
3.81
3.89
3.98
4.10
4.26
4.46
4.74
5.14
5.79
6.94
9.55
19.0
200
2
Degrees of freedom for numerator
TABLE 2: F-Distribution
Values of F for F-Distributions with 0.05 of the Area in The Right Tall
TESTING
HYPOTHESIS
725
3.07
3.00
4.00
3.92
3.84
60
120
∞
2.60
2.68
2.76
2.37
2.45
2.53
2.61
2.69
2.76
2.78
2.80
2.82
2.84
2.87
2.90
2.21
2.29
2.37
2.45
2.53
2.60
2.62
2.64
2.66
2.68
2.17
2.74
2.10
2.18
2.25
2.34
2.42
2.94
2.51
2.53
2.55
2.57
2.60
2.63
2.01
2.09
2.17
2.25
2.33
2.40
2.42
2.44
2.46
2.49
2.51
2.54
1.94
2.02
2.10
2.18
2.27
2.34
2.36
2.37
2.40
2.42
2.45
2.48
1.88
1.96
2.04
2.12
2.21
2.28
2.30
2.32
2.34
2.37
2.39
2.42
1.83
1.91
1.99
2.08
2.16
2.24
2.25
2.27
2.30
2.32
2.35
2.38
1.75
1.83
1.92
2.00
2.09
2.16
2.18
2.20
2.23
2.25
2.28
2.31
1.67
1.75
1.84
1.92
2.01
2.29
2.11
2.13
2.15
2.18
2.20
2.23
1.57
1.66
1.75
1.84
1.93
2.01
2.03
2.05
2.07
2.10
2.12
2.16
1.52
1.61
1.70
1.79
1.89
1.96
1.98
2.01
2.03
2.05
2.08
2.11
1.46
1.55
1.65
1.74
1.84
1.92
1.94
1.96
1.98
2.01
2.04
2.07
1.39
1.50
1.59
1.69
1.79
1.87
1.98
1.91
1.94
1.96
1.99
2.03
1.32
1.43
1.53
1.64
1.74
1.82
1.84
1.86
1.89
1.92
1.95
1.98
1.22
1.35
1.47
1.58
1.64
1.77
1.79
1.81
1.84
1.87
1.90
1.93
1.00
1.25
1.39
1.51
1.62
1.71
1.73
1.76
1.78
1.81
1.84
1.88
AND
3.15
2.84
2.92
2.99
3.01
3.03
3.05
3.07
3.10
3.13
COMPUTER-BASED NUMERICAL
3.23
3.32
3.39
3.40
4.08
4.26
24
3.42
40
4.28
23
3.44
4.24
4.30
22
3.47
4.17
4.32
21
3.49
25
4.35
20
3.52
30
4.38
19
726
STATISTICAL TECHNIQUES
TESTING
OF
727
HYPOTHESIS
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
of
freedom
(ν)
Probability (Level of significance)
0 = .99
0.95
0.50
0.10
0.05
0.02
0.01
1
2
3
4
5
6
7
8
9
10
.000157
.0201
.115
.297
.554
.872
.1.239
3.646
2.088
2.558
.00393
.103
.352
.711
1.145
2.635
2.167
2.733
3.325
3.940
.455
1.386
2.366
3.357
4.351
5.348
6.346
7.344
8.343
9.340
2.706
4.605
6.251
7.779
9.236
10.645
12.017
13.362
14.684
15.987
3.841
5.991
7.815
9.488
11.070
12.592
14.067
15.507
16.919
18.307
5.214
7.824
9.837
11.668
13.388
15.033
16.622
18.168
19.679
21.161
6.635
9.210
11.341
13.277
15.086
16.812
18.475
20.090
21.669
23.209
11
12
13
14
15
16
17
18
19
20
3.053
3.571
4.107
4.660
4.229
5.812
6.408
7.015
7.633
8.260
4.575
5.226
5.892
6.571
7.261
7.962
8.672
9.390
10.117
10.851
10.341
11.340
12.340
13.339
14.339
15.338
15.338
17.338
18.338
19.337
17.275
18.549
19.812
21.064
22.307
23.542
24.769
25.989
27.204
28.412
19.675
21.026
22.362
23.685
24.996
26.296
27.587
28.869
30.144
31.410
22.618
24.054
25.472
26.873
28.259
29.633
30.995
32.346
33.687
35.020
24.725
26.217
27.688
29.141
30.578
32.000
33.409
34.805
36.191
37.566
21
22
23
24
25
26
27
28
29
30
8.897
9.542
10.196
10.856
11.524
12.198
12.879
13.565
14.256
14.933
11.591
12.338
13.091
13.848
14.611
15.379
16.151
16.928
17.708
18.493
20.337
21.337
22.337
23.337
24.337
25.336
26.336
27.336
28.336
29.336
29.615
30.813
32.007
32.196
34.382
35.363
36.741
37.916
39.087
40.256
32.671
33.924
35.172
36.415
37.65
38.885
40.113
41.337
42.557
43.773
36.343
37.659
38.968
40.270
41.566
41.856
41.140
45.419
46.693
47.962
38.932
40.289
41.638
42.980
44.314
45.642
46.963
48.278
49.588
50.892
NOTE
For degrees of freedom (ν) greater than 30, the quantity
may be used as a normal variate with unit variance.
2χ 2 −
2ν − 1
P a r t
6
APPENDICES
APPENDIX A
ANSWERS TO
SELECTED EXERCISES
ASSIGNMENT 1.1
5. printf (“the given value is %f”, 22.23);
7. x = 10.0
Sum = 1 +
1 1 1 1 1 1 1 1
+ + + + + + + .
2 3 4 5 6 7 8 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
7. (i) 0.004, 0.0015772
5. 48.21, 2.37, 52.28, 2.38, 2.38, 81.26
(ii) 0.006, 0.0023659
9. (34.5588, 35.9694)
731
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
f(x): 1.0625 .125
–2
–1
0
1
2
3
4
– .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
15. .322
(ii) 2.621
19. 2.94282
21. (i) (– 3, – 2)
(iii) .682
17. 0.39188
(iv) .657, 1.834
(ii) Root lies in the interval (– 2.5, – 2.25)
ASSIGNMENT 3.2
1. 0.0912
3. (i) 2.9353
(iv) – .682327803
5. 5.4772
(ii) – .420365
(v) 2.690647448
7. 0.10260
(iii) 1.83928
(vi) 2.594313016
ANSWERS
TO
SELECTED EXERCISES
ASSIGNMENT 3.3
1. 2.942821
7. (i) 1.860, .2541
(iii) 1.2134
13. – 1.25115 and 0.55000
3. 1.875
(ii) 1.69562
(iv) 2.7473
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
3. (i) 2.279
(ii) 1.839286755
(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
(ii) 2.279
(ii) 0.657
(iii) 2.908
ASSIGNMENT 3.9
1. 1.856
3. (i) 2.094568
5. (i) 0.511
(iv) – 2.533
(vii) 1.896
(v) 1.171
(viii) 1.756
(vi) .739
(ix) 4.4934
733
734
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
9. 4.9324
11. 1.442
13. (a) 5.099 (b) 5.384 (c) 5.916
1
5
5
, q = , r = – ; Third order
9
9
9
17. Roots lie in (0, 1) and (1, 2); 0.100336, 1.679631
15. p =
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
ASSIGNMENT 4.2
1. 16.1, 2x is not a polynomial
5. 27, 125
ASSIGNMENT 4.3
1. 244
3. 0.4147
(ii) 6x
ANSWERS
ASSIGNMENT 4.4
1. 15.6993 nautical miles
5. 0.23589625
9. (a) 27 (b) 27
3. 43.704
7. 51
11. 0.1205
ASSIGNMENT 4.5
1. 0.3057
3. 15.47996
5. 421.875
9. 219
7. 0.783172
11. 6.36, 11.02
ASSIGNMENT 4.6
1. 19.407426
5. .046
3. 2290.0017
ASSIGNMENT 4.7
1. 22898
3. 1.2662
5. 0.70696
ASSIGNMENT 4.8
1. 0.9391002
5. 0.32495
3. 0.19573
ASSIGNMENT 4.9
1. 0.496798
5. 1.904082
3. 7957.1407
7. 3250.875
TO
SELECTED EXERCISES
735
736
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
ASSIGNMENT 4.10
1. 3.3756
3. 4913, 5052, 5185, 5315
5. 3250.875
9. 19523.5, 215914
7. 14.620947
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
5. 0.64942084
9. x4 – 3x3 + 5x2 – 6
3. (i) 100.99999
(ii) 25
7. 1294.8437
11. 12.45
13. 53
19. x5 – 9x4 + 18x3 – x2 + 9x – 18
17. 2.4786
ASSIGNMENT 4.12
1. 810
5. 328
9.
3. 521
7. (x – 1)3 + 2(x – 1)2 + 4(x – 1) + 11
1
1
1
+
−
2 ( x − 1) x − 2 2 ( x + 1)
11. 2.49136
13. 10.
ASSIGNMENT 4.13
1. f(x) = 2x4 – x2 + x + 1,
11 3
, .
8 8
3.
1
(5x3 – 3x5).
2
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
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
11. 232.869
9. 18, 18
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
5. 0.0490291.
3. 3.1428
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
11. y(.01) = 1.01, y(.02) = 1.0201.
9. 1.76393
737
738
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
ASSIGNMENT 6.3
1. 2.2052, 2.4214
3. y(x) = 1 + x −
x2 x3 5 4
+
− x ; 1.0954
2
2
8
5. y(0.1) = 2.0845,
y(0.2) = 2.1366338,
z(0.1) = 0.5867
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
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.
11. y(0.8) = 2.3164, y(1.0) = 2.3780
ANSWERS
TO
SELECTED EXERCISES
ASSIGNMENT 7.1
1. y = 2.4333 + 0.4x
5. y = 54.35 + 0.5184x°
3. y = – 4 + 6x
7. y = – 1.6071429x + 8.6428571
9. P = 2.2759 + 0.1879 W.
ASSIGNMENT 7.2
1. y = e0.5x
5. y = 99.86 (1.2)x
9. y = 0.509x2 –
2.04
x
13. xy = 16.18x + 40.78
3. y = 4.642 e0.46x
7. y = 2.978 x0.5143
11. y = 13.0065 +
6.7512 4.4738
−
x
x2
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
7
1
1
T0 ( x) + T1 ( x) − T2 ( x) + T3 ( x)
2
4
2
4
3. 2x + 2x2
9.
7.
15 1
− x
16 2
191 1 2
− x
192 2
11. M1 = 8, M2 = – 14
F(x) =
− 11x3 + 45 x 2 − 40 x + 18
;
3
F(1.5) = 7.375
739
740
COMPUTER-BASED NUMERICAL
13. M1 = −
18
,
5
M2 =
AND
STATISTICAL TECHNIQUES
12
5
For
3
2
1 ≤ x ≤ 2, F(x) = − 3 x + 9 x − x − 5
For
2 ≤ x ≤ 3,
F(x) =
For
3 ≤ x ≤ 4,
3
2
F(x) = − 2 x + 24 x − 94 x + 120
5
5 x3 − 39 x 2 + 95 x − 69
5
5
15. α = 1, β = 3
17. For 0 ≤ x ≤
For
For
1
, F(x) = 0.63x3 – 0.82x + 1
3
1
2
≤ x ≤ , F(x) = – 0.45x3 + 1.08x2 – 1.18x + 1.0
3
3
2
≤ x ≤ 1, F(x) = – 0.18x3 + 0.54x2 – 0.8x + 0.96
3
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:
Regression line of x on y:
y = 0.74306 x + 1.56821
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. CL X = 0.4988, UCL X = 0.5172, LCL X = 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. CL X = 10.66, UCL X = 14.295, LCL X = 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
5. 48.75, 51.25.
3. Highly significant
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
5. Poisson law fits the data
3. accepted
7. yes.
9. Accepted at 1% level of significance and rejected at 5% level of significance.
ASSIGNMENT 8.10
1. No
3. Not effective.
APPENDIX B
SAMPLE EXAMINATION
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
(b) Use the series
loge
FG 1 + x IJ = 2 FG x + x
H 1 – xK H 3
3
+
(iii) d3
I
JK
x5
+ ......
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
744
COMPUTER-B ASED NUMERICAL
AND
S TATISTICAL TECHNIQUES
(f) Determine p, q, and r so that the order of the iterative method
xn+1 = pxn +
qa
xn 2
+
ra 2
xn 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
Number of students
30–40
40–50
50–60
60–70
70–80
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
y
0.8
1
1.2
1.4
1.6
1.8
2
1.73036 1.95532 2.19756 2.45693 2.73309 3.02549
2.2
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
745
S AMPLE E XAMINATION
(c) Derive Simpson’s
FG 1IJ
H 3K
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
x2
= 2
dx y + 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
dy
= 1 and
= xy taking h = 0.2.
dx
(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
APPENDIX C
ABOUT THE CD-ROM
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
INDEX
A
Algorithm of Simpson’s 3/8th rule, 433
Absolute error, 37
Algorithmic errors, 31
Acceptance sampling, 655
Alternative hypothesis, 673
Adams-Moulton (or Adams-Bashforth)
formula, 537
Analysis of data, 655
Adams-Moulton corrector formula, 539
Applications of t-distribution, 691
Adams-Moulton predictor formula, 538
Approximations, 601
Advantages of statistical quality control, 656
Area diagrams, 555
Advantages/Features of ‘C’ language, 7
Argument, 202
Algebraic and transcendental equations, 77
Arrays, 18
Algorithm for linear regression, 621
Assembler, 6
Algorithm of Euler’s method, 493
Assumptions for interpolation, 200
Algorithm of Milne’s predictor-corrector
method, 528
Asymptotic error constant, 80
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 trapezoidal rule, 429
Angle between two lines of regression, 620
Averaging operator μ, 205
B
Backward difference operator, 203
Backward differences, 203
749
750
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Bell shaped curve, 553
Curve of regression, 614
Bessel’s interpolation formula, 312
Curve-Fitting by sum of exponentials, 588
Bisection (or Bolzano) method, 77
Boole’s rule, 426
D
C
Debugging, 80
‘C’ constants, 8
Degrees of freedom, 709
“C instructions”, 10
“C” variables, 9
Detection of errors by use of difference tables,
234
χ2 test as a test of goodness of fit, 711
Differences of a polynomial, 207
χ2 test as a test of independence, 718
Carl Runge, 513
Decision making instructions in “C”, 14
Discrete variables, 548
Divided differences, 361
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
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
Critical value of t, 691
Cubic spline interpolation, 594
Cumulative frequency, 549
F
Cumulative frequency curve or the ogive, 553
Factorial notation, 225
Curve fitting, 556
Fibonacci numbers, 27
INDEX
Finite differences, 202
Finite inverse, 671
751
I
Floating point representation of numbers, 61
Initial-value and boundary-value problems,
480
Flow-chart for trapezoidal rule, 430
Interpolating polynomial, 200
Flow-chart of Euler’s method, 494
Interpolation by unevenly spaced points, 338
Flow-chart of Milne’s predictor-corrector
method, 529
Inverse interpolation, 360
Flow-chart of modified Euler’s method, 498
Iteration method, 94
First order Runge-Kutta method, 514
Inverse problems, 46
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
J
J-shaped curve, 554
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
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
G
Lines of regression, 614
Gauss’s backward difference formula, 289
Lower limit, 549
Loop control structure, 17
Gauss’s forward difference formula, 278
Gaussian quadrature formula, 463
Graeffe’s root-squaring method, 190
Grouped frequency distribution, 549
M
Machine computation, 71
Machine epsilon, 34
H
Maclaurin’s expansion, 61
Hermite’s interpolating polynomial, 381
Mathematical preliminaries, 60
Hermite’s interpolation formula, 381, 382
Horner’s method, 156
Hypothetical universe, 671
Marching methods, 481
Maxima and minima of a tabulated function,
402
752
COMPUTER-BASED NUMERICAL
AND
STATISTICAL TECHNIQUES
Mean value theorem for derivatives, 61
Order of convergence, 80
Merits and demerits of Lagrange’s formula,
365
Orthogonal properties, 603
Osculating interpolation formula, 381
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
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
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
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
Newton’s Gregory backward interpolation
formula, 262
Program of Milne’s method, 530
Newton’s Gregory forward interpolation
formula, 243
Program of Runge-Kutta method, 517
Newton’s iterative formulae, 163
Non-periodic spline, 597
Normalized floating point, 62
Program of modified Euler’s method, 499
Program to implement least square fit of a
regression, 622, 623
Program to implement Simpson’s 1/3rd
method, 439
np chart, 662
Program writing, 80
Numerical evaluation of singular integrals,
465
Properties of chebyshev polynomials, 605
Properties of divided differences, 362
Numerical solution of ordinary differential
equations, 479
Properties of regression co-efficients, 619
O
One-step predictor-corrector method, 497
Q
Quotient-difference method, 152
INDEX
753
R
Taylor’s series for a function of one variable,
61
Ramanujan’s method, 195
Taylor’s series for a function of two variables,
61
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
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
S
Two point rule, 466
Type I error, 674
Scatter or dot diagram, 556
Type II error, 675
Secant method, 132
Types of frequency curves, 553
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
U
u-chart, 661
Simpson’s one-third rule, 425
U-shaped curve, 554
Simplson’s three-eighth rule, 426
Use of regression analysis, 618
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
V
Values of F for F-distributions, 725
W
Student’s t-distribution, 691
Weddle’s rule, 427
Successive approximation method, 94
Wilhelm Kutta, 513
T
Y
t-statistic, 691
Yates’s correction, 719
Taylor’s method, 506
Download