226 47 20MB
English Pages [673] Year 2023
Table of contents :
Front Cover
Title Page
Copyright
Preface
Contents
Chapter 1: Computer Arlthmettc And Errors
1.1 Introduction
1.2 Some Mathematical Preliminaries
1.3 Number System
1.4 Base Conversion
1.5 Binary Arithmetic
1.6 Approximations and Errors
1.7 Accuracy of Numbers
1.8 Errors and their Analysis
1.9 Inherent Errors
1.10 Rounding off Error
1.11 Truncation Error
1.12 The General Formula fur Errors
1.13 Floating Point Arithmetic and Errors
1.14 Computer Storage
1.15 Concept of Normalized Floating Point
1.16 Pitfalls of Floating Point Representation
1.17 Error in a Series Approximation
1.18 Error in Determinants
1.19 Application of Error Formula to the Fundamental Operations of Arithmetics
1.20 Order of Approximations
1.21 Propagation of Error
1.22 Blunders
1.23 Numerical Instability
1.24 Sensitivity Analysis
1.25 Machine Computations
1.25 Computer Software
Chapter 2: Finite Difference Operators
2.1 Introduction
2.2 Difference Schemes
2.3 Relation between Operators
2.4 Fundamental Theorem of Difference Calculus
2.5 Method of Separation of Symbols
2.6 Effect of an Error in a Tabular Value
2.7 Factorial Notation
2.8 To Express a given Polynomial into Factorial Notation
2.9 Problems Based on Missing Terms
2.10 Differences of Zero
2.11 Divided Difference
2.12 Differences between Divided Difference and Ordinary Difference
Chapter 3: Interpolation with Equal Intervals
3.1 Introduction
3.2 Interpolation
3.3 Methods of Interpolation
3.4 Finite Difference Calculus
3.5 Newton-Gregory Formula fur Forward Interpolation with Equal Intervals
3.6 Newton-Gregory's Backward Interpolation Formula with Equal Intervals
3.7 Some Words Problems based on Newton's Formulae
3.8 Central Differences Interpolation Formulae
3.9 Stirling's Difference Formula
3.10 Bessel's Difference Formula
3.11 Everett's Difference Formula
3.12 Choice to select the suit.able Interpolation Formula
Chapter 4: Interpolation with Unequal Intervals
4.1 Introduction
4.2 Newton's Divided Difference Formula
4.3 Lagrange's Interpolation Formula
4.4 Hermite's Interpolation Formula
4.5 Inverse Interpolation
Chapter 5: Numerical Differentiation and Integrations
5.1 Introduction
5.2 Derivative using Newton's Forward Interpolation Formula
5.3 Derivatives using Newton's Backward Difference Formula
5.4 Derivatives using Stirling's Formula
5.5 Derivatives using Bessel's Central Difference Formula
5.6 Derivative using Newton's Divided Difference Formula
5.7 Maxima and Minima of Tabulated Function
5.8 Error Analysis in Numerical Differentiation
5.9 Error in Higher Order Derivatives
5.10 Numerical Quadrature
5.11 General Quadrature Formula for Equally Spaced Arguments
5.12 The Trapezoidal Rule
5.13 Simpson's 1/3 Rule
5.14 Simpson's 3/8 Rule
5.15 Weddle's Rule
5.16 Romberg's Method
5.17 Newton-Cote's Formula
5.18 Properties of Cote's Numbers
5.19 Deductions from Newton-Cote's Formula
5.20 Gauss's Quadrature Formula
5.21 Chebychev's Formula
5.22 Higher Order Rules
5.23 Numerical evaluation of the Singular Integral
5.24 Numerical Double Inte ration
Chapter 6: Numerical Roots of Polynomial and Transcendental Equations in One Variable
6.1 Introduction
6.2 Properties of the Equations and Its Roots
6.3 Methods of Solution
6.4 Bisection Method
6.5 Iteration Method
6.6 Iterative Method for the System of Non-Linear Equations
6.7 Regula-Falsi Method (or Method of False Position)
6.8 Secant Method
6.9 Newton-Raphson's Method
6.10 Newton's Formula for finding Special type of Roots
6.11 Comparison of Newton's Method and Regula-Falsi Method
6.12 Birge-Viet.a Method
6.13 Complex Roots
6.14 Newton's Method for Complex Roots
6.15 Muller's Method
6.16 Lin-Bairstow's Method
6.17 Graeffe's Root Square Method
6.18 The Quotient-Difference Method
Chapter 7: Numerical Solution of System of Simultaneous Equations
7.1 Introduction
7.2 System of Simult.aneous Linear Equations
7.3 Existence of Solution
7.4 Solution Methods using Matrices
7.5 Solution Methods based on Successive Elimination: Direct Method
7.6 Gauss Elimination Method
7. 7 LU Decomposition Method or Method of Factorization
7.8 Jordan's Method
7.9 Crout's Method
7.10 Iterative Methods
7 .11 Ill Conditioned and Well Conditioned Equations
7.12 Advantages and Disadvantages of Different Methods
Chapter 8: Matrix Inversion
8.1 Introduction
8.2 Gauss-Elimination Method
8.3 Gauss-Jordan Method
8.4 Triangularisation Method (Doolittle Method)
8.5 Crout's Method
8.6 Choleski's Method
8.7 Escalator Method
8.8 Iterative Method
8.9 Inversion of Complex Matrices
Chapter 9: Eigen Values and Eigen Vectors of a Matrix
9.1 Introduction
9.2 Relation between Eigenvalues and Eigenvectors
9.3 Eigenvalues of Special type of Matrices
9.4 Power Method
9.5 Inverse Power Method
9.6 Rutishauser Method
9.7 Jacobi's Method
9.8 Given's Method
9.9 House Holder's Method
9.10 The Cayley-Hamilton Theorem
Chapter 10: Eigen Values and Eigen vectors of a Matrix
10.1 Introduction
10.2 Relation between Eigenvalues and Eigenvectors
10.3 Euler's Method
10.4 Euler's Modified Method
10.5 Solution by Taylor Series
10.6 Picard's Method of Successive Approximations
10.7 Runge-Kutta Method
10.8 Simultaneous Differential Equations
10.9 Solution of Second Order Differential Equations
10.10 Milne's Methods
10.11 Adam-Bashforth Method
10.12 Error Analysis
10.13 Convergence of a Method
10.14 Stability Analysis
Chapter 11: Initial Value Problems of Partial Differential Equations
11.1 Introduction
11.2 Difference Quotients
11.3 Classification of Partial Differential Equations
11.4 Elliptic Equations
11.5 Solution of Laplace Equations by LIEBERMANN's Iteration Process
11.6 Parabolic Equations
11.7 Solution by Forward Difference Method
11.8 Solution by Bender-Schmidt's Method
11.9 Crank-Nicholson Method
11.10 Dufort and Frankel's Method
11.11 Iterative Method
11.12 Solution of Two-Dimensional Heat Equation: ADE Method
11.13 Hyperbolic Equation
Chapter 12: Fitting of Curves and Cubic Splines
12.1 Introduction
12.2 Continuous Frequency Distribution
12.3 Graphical Representation
12.4 Curve Fitting
12.5 Method of Least Squares
12.6 Most Plausible Solution of a System of Linear Equations
12.7 Method of Curve-Fitting
12.8 Fitting of Some Special Curves
12.9 Curve Fitting by sum of Exponentials
12.10 Spline Function
12.11 Regression Analysis
12.12 Properties of Regression Coefficients
12.13 Angle between two lines of Regression
12.14 Fitting a Polynomial Function
12.15 Non-Linear Regression
12.16 Simplified Determination of Regression Analysis
12.17 Regression Analysis of Grouped Data
12.18 Multiple Linear Regression
Chapter 13: Data Approximation of Functions
13.1 Introduction
13.2 Weirstress Theorem
13.3 Norm
13.4 Types of Approximations
13.5 Use of Orthogonal Functions
13.6 Gram-Schmidt Orthogonalizing Process
13.7 Legendre and Chebyshev Polynomials
13.8 Uniform Approximation
13.9 Chebyshev Polynomial Approximations
13.10 Lanczos Economization of Power Series for a General Function
13.11 Rational Approximation
13.12 Approximation with Trigonometric Functions
Chapter 14: Difference Equations
14.1 Introduction
14.2 Difference Equation as a Relation among the value of Yx
14.3 Order of Difference Equation
14.4 Degree of Difference Equation
14.5 Solution of Difference Equation
14.6 Linear Difference Equation
14.7 Existence and Uniqueness theorem
14.8 Solution of the equation Yx + 1 ~ Ayx + B
14.9 Solution as Sequences
14.10 Linear Homogeneous equation with Constant Coefficients
14.11 Linearly Independent Solution or Fundamental Set of Solutions
14.12 General Solution Of Second Order Homogeneous Difference Equation
14.13 General Solution Of The Homogeneous Difference Equation Of Order N
14.14 Particular Solution Of The Complete Difference Equation
14.15 Solution Of Simultaneous Difference Equations
Bibliography
Index
Back Cover
APPLIED
NUMERICAL ANALYSIS Useful for Undergraduate and postgraduate students of mathematics, statistics, computer science, physical science, management and other professional courses and competitive examinations
DR. SUDHIR KUMAR PUNDIR M.Sc., M.Phil, NET, J.R.F., S.R.F. (C.S.I.R.), Ph.D.
HEAD, Department of Mathematics S.D. (P.G.) College, Muzaffarnagar (U.P.)
CBS Publishers & Distributors Pvt Ltd New Delhi • Bengaluru • Chennai • Kochi • Kolkata • Mumbai Bhopal • Bhubaneswar • Hyderabad • Jharkhand • Nagpur • Patna • Pune • Uttarakhand • Dhaka (Bangladesh) • Kathmandu (Nepal)
Disclaimer Science and technology are constantly changing fields. New research and experience broaden the scope of information and knowledge. The authors have tried their best in giving information available to them while preparing the material for this book. Although, all efforts have been made to ensure optimum accuracy of the material, yet it is quite possible some errors might have been left uncorrected. The publisher, the printer and the authors will not be held responsible for any inadvertent errors, omissions or inaccuracies.
eISBN: 978-93-546-6970-5 Copyright © Authors and Publisher First eBook Edition: 2023 All rights reserved. No part of this eBook may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system without permission, in writing, from the authors and the publisher. Published by Satish Kumar Jain and produced by Varun Jain for CBS Publishers & Distributors Pvt. Ltd. Corporate Office: 204 FIE, Industrial Area, Patparganj, New Delhi-110092 Ph: +91-11-49344934; Fax: +91-11-49344935; Website: www.cbspd.com; www.eduport-global.com; E-mail: [email protected] Head Office: CBS PLAZA, 4819/XI Prahlad Street, 24 Ansari Road, Daryaganj, New Delhi-110002, India. Ph: +91-11-23289259, 23266861, 23266867; Fax: 011-23243014; Website: www.cbspd.com; E-mail: [email protected]; [email protected].
Branches Bengaluru: Seema House 2975, 17th Cross, K.R. Road, Banasankari 2nd Stage, Bengaluru - 560070, Kamataka Ph: +91-80-26771678/79; Fax: +91-80-26771680; E-mail: [email protected] Chennai: No.7, Subbaraya Street Shenoy Nagar Chennai - 600030, Tamil Nadu Ph: +91-44-26680620, 26681266; E-mail: [email protected] Kochi: 36/14 Kalluvilakam, Lissie Hospital Road, Kochi - 682018, Kerala Ph: +91-484-4059061-65; Fax: +91-484-4059065; E-mail: [email protected] Mumbai: 83-C, 1st floor, Dr. E. Moses Road, Worli, Mumbai - 400018, Maharashtra Ph: +91-22-24902340 - 41; Fax: +91-22-24902342; E-mail: [email protected] Kolkata: No. 6/B, Ground Floor, Rameswar Shaw Road, Kolkata - 700014 Ph: +91-33-22891126 - 28; E-mail: [email protected]
Representatives Hyderabad Pune Nagpur Manipal Vijayawada Patna
Preface The book entitled ':t\pplied NUMERICAL ANALYSIS" meet the needs of Mathematics, Statistics, Computer science, Physical science, Management and engineering students of UG and PG levels. Besides, it will also be very useful for students preparing for various competitive and professional examinations. The contents of this book are derived from the curricula offered by various universities across the country. This book consists of fourteen chapters. In each chapter an ample amount of theory is given which is supported by solved examples followed by exercises along with their answers. The text is organised around mathematical problems, with each chapter devoted to a single type of problem. Within each chapter the presentation begins with the simplest and most basic methods, progressing gradually to more advance topics. A list of objective questions is given at the end of each chapter. I express my gratitude to the authors and publishers of various books I consulted during the preparation of the book. I wish to sincerely thank Sh S.K. Jain and Sh Varun Jain, Managing Director, CBS Publishers and Distributors, New Delhi for encouragement and help in bringing out this publication in a present nice form. My special thanks to Sh. YN. Arjuna, Senior director publishing, editorial and publicity and Smt. Ritu Chawla, publishing head, CBS Publishers and Distributors, New Delhi whose encouragement and unstinted support enabled me to complete the book. I also take this opportunity to express my sincere gratitude to Sh. Sunil Dutt, CBS Publishers and Distributors, New Delhi who gave me the inspiration throughout the preparation of the book. Sh. Suresh Sharma, CBS, New Delhi deserve special mention for their kind support and help in this endeavour. I must also record my appreciation due to my wife Dr. Rimple, daughter Rijuta and son Shrish for their understanding and love during the long period that I have taken to complete this book. Above all I am thankful to The Almighty God, without whose grace nothing is possible for any one. Readers are welcomed to point out errors, if any and send their valuable suggestions for improving the quality of the book. Dr. Sudhir Kumar Pundir email: [email protected]
CONTENTS Com uter Arlthmettc And Errors
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 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.25 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12
Introduction Some Mathematical Preliminaries Number System Base Conversion Binary Arithmetic Approximations and Errors Accuracy of Numbers Errors and their Analysis Inherent Errors Rounding off Error Truncation Error The General Formula fur Errors Floating Point Arithmetic and Errors Computer Storage Concept of Normalized Floating Point Pitfalls of Floating Point Representation Error in a Series Approximation Error in Determinants Application of Error Formula to the Fundamental Operations of Arithmetics Order of Approximations Propagation of Error Blunders Numerical Instability Sensitivity Analysis Machine Computations Computer Software Finite Difference Operators Introduction Difference Schemes Relation between Operators Fundamental Theorem of Difference Calculus Method of Separation of Symbols Effect of an Error in a Tabular Value Factorial Notation To Express a given Polynomial into Factorial Notation Problems Based on Missing Terms Differences of Zero Divided Difference Differences between Divided Difference and Ordinary Difference
1 1 2 3 11
13 13 16 23 23 24 26 28 29 30 30 35 36 37 44
45 48 48 49 49 51 53 53 57 59 65 69 72 73 77
80 81 82
Interpolation with Equal Intervals 3.1 Introduction 3.2 Interpolation 3.3 Methods of Interpolation 3.4 Finite Difference Calculus 3.5 Newton-Gregory Formula fur Forward Interpolation with Equal Intervals 3.6 Newton-Gregory's Backward Interpolation Formula with Equal Intervals 3.7 Some Words Problems based on Newton's Formulae 3.8 Central Differences Interpolation Formulae 3.9 Stirling's Difference Formula
95 95 95 96 96 106 112 117 119
3.10 Bessel's Difference Formula 3.11 Everett's Difference Formula 3.12 Choice to select the suit.able Interpolation Formula Interpolation with Unequal Intervals 4.1 Introduction 4.2 Newton's Divided Difference Formula 4.3 Lagrange's Interpolation Formula 4.4 Hermite's Interpolation Formula 4.5 Inverse Interpolation Numerical Differentiation and Integrations 5.1 Introduction 5.2 Derivative using Newton's Forward Interpolation Formula 5.3 Derivatives using Newton's Backward Difference Formula 5.4 Derivatives using Stirling's Formula 5.5 Derivatives using Bessel's Central Difference Formula 5.6 Derivative using Newton's Divided Difference Formula 5.7 Maxima and Minima of Tabulated Function 5.8 Error Analysis in Numerical Differentiation 5.9 Error in Higher Order Derivatives 5.10 Numerical Quadrature 5.11 General Quadrature Formula for Equally Spaced Arguments 5.12 The Trapezoidal Rule 5.13 Simpson's 1/3 Rule 5.14 Simpson's 3/8 Rule 5.15 Weddle's Rule 5.16 Romberg's Method 5.17 Newton-Cote's Formula 5.18 Properties of Cote's Numbers 5.19 Deductions from Newton-Cote's Formula 5.20 Gauss's Quadrature Formula 5.21 Chebychev's Formula 5.22 Higher Order Rules 5.23 Numerical evaluation of the Singular Integral Numerical Double Inte ration
120 120 121
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
249 249 250 250 261 268 269 278 283 286 287 297 306 306 308 313 320 326
Introduction Properties of the Equations and Its Roots Methods of Solution Bisection Method Iteration Method Iterative Method for the System of Non-Linear Equations Regula-Falsi Method (or Method of False Position) Secant Method Newton-Raphson's Method Newton's Formula for finding Special type of Roots Comparison of Newton's Method and Regula-Falsi Method Birge-Viet.a Method Complex Roots Newton's Method for Complex Roots Muller's Method Lin-Bairstow's Method Graeffe's Root Square Method The Quotient-Difference Method Introduction System of Simult.aneous Linear Equations
135 135 143 158 162 165 165 166 167 168 169 169 185 186 192 192 192 197 198 207 209 212 213 215 220 225 228 234
7.3 7.4 7.5 7.6 7. 7 7.8 7.9 7.10 7.11 7.12 8.1 8.2 8.3 8.4 8.5 8.6
9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10
Existence of Solution Solution Methods using Matrices Solution Methods based on Successive Elimination: Direct Method Gauss Elimination Method LU Decomposition Method or Method of Factorization Jordan's Method Crout's Method Iterative Methods Ill Conditioned and Well Conditioned Equations Advantages and Disadvantages of Different Methods Matrix Inversion Introduction Gauss-Elimination Method Gauss-Jordan Method Triangularisation Method (Doolittle Method) Crout's Method Choleski's Method Escalator Method Iterative Method
Introduction Relation between Eigenvalues and Eigenvectors Eigenvalues of Special type of Matrices Power Method Inverse Power Method Rutishauser Method Jacobi's Method Given's Method House Holder's Method The Cayley-Hamilton Theorem
338 339 340 340 346 351 353 358 368 370 373 373
407 426 432 434 437 444 448 452
10.2 10.3 10.4 10.5 10.6 10.7
Existence and Uniqueness of Solution of Differential Equation Euler's Method Euler's Modified Method Solution by Taylor Series Picard's Method of Successive Approximations Runge-Kutta Method Simultaneous Differential Equations Solution of Second Order Differential Equations Milne's Methods Adam-Bashforth Method Error Analysis Convergence of a Method Stability Analysis
463 465 468 473 477 484
11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9
Introduction Difference Quotients Classification of Partial Differential Equations Elliptic Equations Solution of Laplace Equations by LIEBERMANN's Iteration Process Parabolic Equations Solution by Forward Difference Method Solution by Bender-Schmidt's Method Crank-Nicholson Method
517 517 518 519 520 529 529 530 531
11.10 11.11 11.12 11.13
-
Dufort and Frankel's Method Iterative Method Solution of Two-Dimensional Heat Equation: ADE Method Hyperbolic Equation Fitting of Curves and Cubic Splines Introduction Continuous Frequency Distribution Graphical Representation Curve Fitting Method of Least Squares Most Plausible Solution of a System of Linear Equations Method of Curve-Fitting Fitting of Some Special Curves Curve Fitting by sum of Exponentials Spline Function Regression Analysis Properties of Regression Coefficients Angle between two lines of Regression Fitting a Polynomial Function Non-Linear Regression Simplified Determination of Regression Analysis Regression Analysis of Grouped Data Multiple Linear Regression Data Approximation of Functions Introduction Weirstress Theorem Norm Types of Approximations Use of Orthogonal Functions Gram-Schmidt Orthogonalizing Process Legendre and Chebyshev Polynomials Uniform Approximation Chebyshev Polynomial Approximations Lanczos Economization of Power Series for a General Function Rational Approximation Approximation with Trigonometric Functions Difference Equations Introduction Difference Equation as a Relation among the value of Yx Order of Difference Equation Degree of Difference Equation Solution of Difference Equation Linear Difference Equation Existence and Uniqueness theorem Solution of the equation Yx + 1 ~ Ayx + B Solution as Sequences Linear Homogeneous equation with Constant Coefficients Linearly Independent Solution or Fundamental Set of Solutions General Solution Of Second Order Homogeneous Difference Equation General Solution Of The Homogeneous Difference Equation Of Order N Particular Solution Of The Complete Difference Equation Solution Of Simultaneous Difference Equations Bibliography
-
Index
12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 12.10 12.11 12.12 12.13 12.14 12.15 12.16 12.17 12.18 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 13.10 13.11 13.12 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 14.10 14.11 14.12 14.13 14.14 14.15
532 532 538 540 551 552 552 554 554 555 558 558 571 574 579 580 581 588 590 593 594 594 601 601 601 602 606 607 608 612 613 614 614 615 625 625 625 626 626 628 629 629 634 637 638 643 644 647 653
Computer Arithmetic and Errors
1
1
Computer Arithmetic and Errors
1.1 introduction When we solve a mathematical problem on a computer, a step-by-step procedure utilising the characteristics of a computer should be evolved. It should be observed that only the arithmetic operations may be used even when solving problems involving the operations of calculus. In numerical analysis, the analysis of error is of great importance. So far we have used various data on the assumptions that they are pure and the techniques of their computations are perfect, but this is not the case all the time, either the data can be impure or there can be error in the computational procedure. In this chapter we shall discuss different types of errors, their determination along with the computer arithmetic. This chapter is divided into two sections namely (i) Computer arithmetic (ii) Errors in Numerical Computations Now, before discussing the above sections, let us recall some mathematical preliminaries.
1.2 some mathematical preliminaries In this section we state some certain mathematical results which are very useful. 1. Intermediate Theorem. If f(x) is a continuous function in a closed interval [a, b] i.e. a [ x [ b and if f(a) and f(b) are of opposite signs then there must exist a number c lies between a and b such that f(c) = 0. 2. Rolle's Theorem. Let f(x) be a function defined on [a, b] such that it is (i) continuous in a closed interval [a, b] (ii) differentiable in the open interval (a, b) (iii) f(a) = f(b) Then there exists at least one value of x say c in (a, b) such that f´(c) = 0 3. Lagrange's mean value Theorem. Let f(x) be a function defined on (a, b) such that it is (i) continuous in a closed interval [a, b] (ii) differentiable in the open interval (a, b) Then there exists at least one value of x say c between a and b such that
f (b) − f (a) = f ′(c ) b−a
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 including 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) + … + f (a) + Rn( x ) 2! (n − 1)!
Applied Numerical Analysis
2 where Rn(x) is the remainder term given by Rn( x ) =
f ( x ) = f (0) + xf ′(0) +
x2 xn n f ′′(0) + … + f (0) + … 2! n!
6. Taylor's series for a function of two variables. We have f ( x1 + ∆ x1 , x 2 + ∆ x 2 ) = f ( x1 , x 2 ) +
+
a 0 Solution.
given, u(x, 0) = 0, u(0, t) = 0, u(1, t) = 50t. Compute u for two steps in t-direction taking h = 1/4. Here, we have a = 16, h = 1/4
\
1 k = ah2 = 16 = 1 16
Numerical Solution of Partial Differential Equations
The Crank-Nicholson scheme is given by ui, j +1 =
1 [u + ui −1, j +1 + ui +1, j , ui −1, j ] 4 i +1, j +1 i
j
0
0.25
0.5
0.75
...(1) 1
0
0
0
0
0
0
1
0
u1
u2
u3
50
2
0
u4
u5
u6
100
Applying equation (1) at the mesh-points u1, u2, u3, we get u 1 [0 + 0 + 0 + u2 ] = 2 ...(2) 4 4 1 1 u2 = [0 + 0 + u1 + u3 ] = (u1 + u3 ) ...(3) 4 4 1 1 u3 = [0 + 0 + u2 + 50] = (u2 + 50) ...(4) 4 4 u1 =
537
Substituting (4) and (2) in (3), we get u2 =
1 1 1 u + [u + 50] 4 4 2 4 2
⇒ 16u2 = 2u2 + 50 ⇒ u2 = 3.5714 u1 = 0.89285, u3 = 13.39285 Applying equation (1) again at the mesh-points u4, u5 and u6, we get
1 u ...(5) 4 5 1 u5 = (u6 ) ...(6) 4 1 u6 = (u5 + 100) ...(7) 4 u4 =
On solving, we get u4 = 1.7857, u5 = 7.1429 and u6 = 26.7857 .
∂u ∂2u = in 0 < x < 5, t 0 given that u(x,0)= 20, u(0, t) = 0, ∂t ∂x 2
Example 5. Solve
u(5, t)= 100. Compute u for the time-step with h = 1 by Crank-Nicholson method. (Anna-2006) Solution. Here, we have a = 1 and h = 1 k = ah2 = 1 ⇒ k = 1 The Crank-Nicholson scheme is given by ui, j +1 =
i
...(1)
0
1
2
3
4
5
0
0
20
20
20
20
100
1
0
u1
u2
u3
u4
100
j
1 [u + ui −1, j +1 + ui +1, j , ui −1, j ] 4 i +1, j +1
Applying equation (1) at the mesh-points u1, u2, u3 and u4, we get
Applied Numerical Analysis
538
1 [u + 20] 4 2 1 u2 = [u1 + u3 + 40] 4 1 u3 = [u2 + u4 + 40] 4 1 u4 = [u3 + 220] and 4 u1 =
...(2) ...(3) ...(4) ...(5)
From eqn. (2), (3), (4) and (5), we get u1 = 10.05, u2 = 20.2, u3 = 30.75 and u4 = 62.69 which is the required values of u1, u2, u3 and u4. Example 6. Solve the boundary value problem ut = uxx under the conditions u(0,t) = u(1,t)= 0 and u(x, 0) = sin px, 0 ≤ x ≤ 1 using Schmidt method (Take (Chennai-2003) h = 0.2 and a= 1/2). Solution. Here, we have h = 0.2 and a = 1/2 k = a . h2 =
then
1 × 0.04 = 0.02 2
We have Bendre-Schmidt relation ui, j +1 =
1 [u + (1 − 2a) ui, j + aui +1, j ] 4 i −1, j
...(1)
Therefore, u(0, 0) = 0, u(0.2, 0) = sin p/5 = 0.5875 Similarly u(0.4, 0) = 0.9511, u(0.6, 0) = 0.9511 u(0.8, 0) = 0.5875, u(1, 0) = 0 Hence, the recurrence relations table as shown below : x→ t ↓
i
0
0.2
0.4
0.6
0.8
1.0
0
1
2
3
4
5
0
0.5878
0.9511
0.9511
0.5878
0
j
0
0
0.02
1
0
0.4756
0.7695
0.7695
0.4756
0
0.04
2
0
0.3848
0.6225
0.6225
0.3848
0
0.06
3
0
0.3113
0.5036
0.5036
0.3113
0
0.08
4
0
0.2518
0.4074
0.4074
0.2518
0
0.1
5
0
0.2037
0.3296
0.3296
0.2037
0
11.12 solution of two-dimensional heat equation: Ade method Consider a two-dimensional heat equation
∂ 2u ∂ 2u ∂u = C 2 2 + 2 ...(1) ∂t ∂y ∂x
Consider a square region 0 [ x [ y [ a and assume that u is known at all points within and on the boundary of this square. Let h be the step size, then a mesh-point (x, y, t) = (ih, jh, nl) may be denoted as simply (i, j, n). Now, replacing the derivatives in (1) by their finite difference approximation, we get
Numerical Solution of Partial Differential Equations
ui, j ,n +1 − ui, j ,n l
⇒ ui, j ,n +1
=
C2
[(ui −1, j ,n − 2ui, j ,n + ui +1, j ,n ) + (ui, j −1, n − 2ui, j , n + ui, j +1, n )] h2 = ui, j ,n + α(ui −1, j ,n + ui +1, j ,n + ui, j +1,n + ui, j −1,n − 4 ui, j ,n ) ...(2) α=
where,
539
lC 2 h2
The above method is known as ADE (Alternating Direction Explicit) method.
Example. Solve the equation
∂u ∂2u ∂2u = + ∂t ∂x 2 ∂y 2
subject to the initial conditions
u(x, y, 0)= sin 2px sin2py, 0 [ x , y [ 1 and the conditions u(x, y, t) = 0, t > 0, on the boundaries, using ADE method with h =
Solution.
By ADE method, we have
1 ui, j ,n +1 = ui, j ,n + (ui −1, j ,n + ui +1, j ,n + ui, j +1,n + ui, j −1,n − 4 ui, j ,n ) 8 1 1 ⇒ ui, j ,n +1 = ui, j ,n + (ui −1, j ,n + ui +1, j ,n + ui, j +1,n + ui, j −1,n ) 2 8
ui, j ,0 =
1 1 u + (u + ui +1, j ,0 + ui, j +1,0 + ui, j −1,0 ) ...(2) 2 i, j ,0 8 i −1, j ,0
Step-1. Put i = j = 1 in (2), we get u1,1,0 =
1 1 u1,1,0 + [u0,1,0 + u2,1,0 + u1,2,0 + u1,0,0 ] 2 8 2
...(1)
Now, we shall find the mesh-points. At the Zeroth level (n = 0), the initial and boundary conditions are
1 1 and α = . 8 3
=
1 2π 1 4π 2π 2π 4π sin sin + sin + 0 sin + 0 + sin 2 3 8 3 3 3 3
=
3 1 3 3 3 3 3 + − × − × = 8 8 2 2 2 2 16
Step-2. Put i = 2, j = 1 in (2), we get 1 1 u + [u + u3,1,0 + u2,2,0 + u2,0,0 ] 2 2,1,0 8 1,1,0 2 2 1 4π 2π 1 2π 4π sin = sin + sin + 0 + sin + 0 2 3 3 8 3 3 2 2 2 − 3 1 3 1 3 3 =− + + = − 16 2 2 8 2 2
u2,1,0 =
Step-3. Put i = 1, j = 2 in (2), we get
1 1 u + (u + u2,2,0 + u1,3,0 + u1,1,0 ) 2 1,2,0 8 0,2,0 2 2 1 2π 4 π 1 4π 2π sin = sin + 0 + sin + 0 + sin 2 3 3 8 3 3
u1,2,0 =
=−
3 1 3 3 3 + + =− 8 8 4 4 16
Applied Numerical Analysis
540 Step-4. Put i= 2, j = 2 in (2), we get
1 1 u + (u + u3,2,0 + u2,3,0 + u2,1,0 ) 2 2,2,0 8 1,2,0
u2,2,0 =
=
1 4π 1 2π 4π 4π 2π sin + 0 + 0 + sin sin sin + sin 2 3 8 3 3 3 3
=
3 1 3 3 3 + − − = 8 8 4 4 16
2
Similarly we may obtain the mesh values of the second and higher levels.
11.13 Hyperbolic equation An equation of the type a2
∂ 2u ∂x 2
=
∂ 2u ∂t 2
or a2uxx – utt = 0 is said to the hyperbolic equation. (RGPV Bhopal-2008)
11.13.1 Solution by Method of Finite Difference Consider the equation subject to the conditions and u xx =
Put
a h
2
1 h
2
a2
∂ 2u ∂x 2
=
∂ 2u ∂t 2
...(1)
u(0, t) = 0 ...(2) u(l, t) = 0 ...(3) u(x, 0) = f(x)...(4) ut(x, 0) = 0 ...(5)
[ui +1, j − 2ui, j + ui −1, j ] and utt =
[ui +1, j − 2ui, j + ui −1, j ] −
1 k2
1 k2
[ui, j +1 − 2ui, j + ui, j −1 ] in (1), we get
[ui, j +1 − 2ui, j + ui, j −1 ] = 0
⇒ λ 2a2[ui +1, j − 2ui, j + ui −1, j ] − [ui, j +1 − 2ui, j + ui, j −1 ] = 0 where, λ =
k . h
⇒ ui, j +1 = 2(1 − λ 2a2 )ui, j + λ 2a2(ui +1, j + ui −1, j ) − ui, j −1 ...(6) The boundary condition (2) and (3) can be put in the difference form as u0, j = 0 = un, j ; j = 1, 2, 3 The initial condition (4) as ui, 0 = f(ih), i = 1, 2,... and (5) as
...(7)
1 (u − ui,0 ) = 0 when t = 0, i.e., j = 0 k i , j +1
ui, 1 – ui, 0 = 0 ...(8) ⇒ ui, 1 = ui, 0 = f(ih)...(9) Now, equation (7) and (8) give the values of u on the first two rows j = 0 and j = 1. Putting j = 1 in (6), we get
ui,2 = 2(1 − λ 2a 2 )ui,1 + λ 2a2(ui +1,1 + ui −1,1 ) − ui,0 ...(10)
Now, RHS of (10) involves the values of u on the first two rows j = 0 and j = 1. These are known from the initial condition (7) and (8). Hence, we can find ui, 2.
Numerical Solution of Partial Differential Equations
541
Example 1. Use the finite difference method to find the solution of the problem ∂2u
−
∂2u
=0 ∂t 2 ∂x 2 ∂u with u( x , 0) = x( π − x ), ( x , 0) = 0 ; ∂t
u(0, t) = u(p, t) = 0 π . The given problem is 18
Solution.
Here, we consider a square grid with spacing h = k =
symmetric over the interval [0, p]. Therefore, we find the solution in the interval [0, p/2]. The value of u10 are given by the initial condition u10 = xi(p – x). u00 = 0, u10 = 0.518, u20 = 0.975, u30 = 1.371, u40 = 1.706, u50 = 1.980, u60 = 2.193,
u70 = 2.346, u80 = 2.437, u90 = 2.467 To find the solution for the next time step we use the Taylor series. We write ui1 = ui0 + k
∂ui0 ∂ 2u ∂ 2ui0 = 0, 2i0 = = −2 ∂t ∂t ∂x 2
∂ui0 k 2 ∂ 2ui0 + ∂t 2 ∂t 2
ui1 = ui0 − k 2 = ui0 − 0.03048 Therefore, the values of ui1 are
u01 = 0, u11 = 0.487, u21 = 0.944,
u31 = 1.340, u41 = 1.675, u51 = 1.950, u61 = 2.163, u71 = 2.315, u81 = 2.406,
u91 = 2.437
We now compute the values of ui, j + 1 for j = 1, 2, .... using the finite difference representation ui, j + 1 – 2uij + ui, j – 1 = ui + 1, j – 2ui, j + ui – 1, j ⇒ ui, j + 1 = ui + 1, j + ui – 1, j – ui,j – 1 u22 = u31 + u11 − u20 = 1.340 + 0.487 − 0.975 = 0.853 Therefore,
u32 = u41 + u21 − u30 = 1.675 + 0.944 − 1.371 = 1.249
u42 = u51 + u31 − u40 = 1.950 + 1.340 − 1.706 = 1.584
u52 = u61 + u41 − u50 = 2.163 + 1.675 − 1.980 = 1.858
u82 = u91 + u71 − u80 = 2.437 + 2.315 − 2.437 = 2.315
u92 = u10,1 + u81 − u90 = 2.406 + 2.406 − 2.467 = 2.346
u62 = u71 + u51 − u60 = 2.315 + 1.950 − 2.346 = 2.224
Example 2. Solve utt = 4uxx with the boundary conditions u(0, t) = 0 = u(4, t), ut(x,0)=0 Solution.
and u(x, 0) = x(4 – x). Here, the given equation is
∂ 2u ∂t
2
=4
∂ 2u ∂x 2
...(1)
Comparing with the standard equation, we get 2 ⇒ a = 2. a = 4
Applied Numerical Analysis
542 h
1
Taking h = 1 ⇒ k = = = 0.5 . a 2 From the boundary conditions u(0, t) = 0 ⇒ u = 0 along line x = 0. u(4, t) = 0 ⇒ u = 0 along line x = 4. which can be written in difference form as follows u4, j = 0, " j u0, j = 0 and
u(x, 0) = x(4 – x)
Now,
⇒ u(0, 0) = 0, u(1, 0) = 3, u(2, 0) = 4, u(3, 0) = 3, u(4, 0) = 0 In difference notation ui, 0 = u(i, 0) = i(4 – i), for different i. Putting i = 0, 1, 2, 3, 4, we get u0, 0 = 0, u1, 0 = 3, u2, 0 = 4, u3, 0 = 3, u4, The condition ut(x, 0) gives
0
=0
1 (u − ui, j ) = 0 k i , j +1
when j = 0, ui, 1 = ui, 0 "i ⇒ u on the first two rows are equal. Consider the recurrence relation ui, j + 1 = ui + 1, j + ui – 1, j – ui, j – 1 If we put j = 1, we get ui, 2 = ui + 1, 1 + ui – 1, 1 – ui, 0 Putting i = 1, 2, 3, ... successively, we get u1, 2 = u2, 1 + u0, 1 – u1, 0 = 4 + 0 – 3 = 1 u2, 2 = u3, 1 + u1, 1 – u2, 0 = 3 + 3 – 4 = 2 u3, 2 = u4, 1 + u2, 1 – u3, 0 = 0 + 4 – 3 = 1. In the similar way, we can fill in the remaining rows as shown in following table : i
0
1
2
3
4
0
0
3
4
3
0
1
0
3
4
3
0
2
0
1
2
1
0
j
3
0
–1
–2
–1
0
4
0
–3
–4
–3
0
Example 3. Solve utt = uxx upto t = 0.5 with a spacing of 0.1 subject to u(0, t) = 0, Solution.
u(1, t) = 0, ut(x, 0) = 0 and u(x, 0) = 10 + x(1 – x). Here, the given equation is
∂u 2 ∂t 2
=
∂2u ∂x 2
Comparing with the standard equation, we get a2 = 1, h= 0.1, k = 0.1 From the boundary conditions, u(0, t) = 0, u(1, t) = 0 which can be written in difference from as follows u 0, j = 0, u1, j = 0 Now, u(x, 0) = 10 + x (1– x)
(Anna-2004)
Numerical Solution of Partial Differential Equations
543
ui, 0 = 10 + i (1 – i) Consider the recurrence relation ui, j + 1 = ui + 1, j + ui – 1, j – ui, j – 1 Putting i = 0.1, 0.2, ...., 0.9 successively, we get
u0.1, 0 = 10.09, u0.2, 0 = 10.16, u0.3, 0 = 10.21
u0.4, 0 = 10.24, u0.5, 0 = 10.25, u0.6, 0 = 10.24
...(1) ...(2)
u0.7, 0 = 10.21, u0.8, 0 = 10.16, u0.9, 0 = 10.08 For second row, we have ut ( x ,0) = 0 ⇒ (ui, j +1 , − ui, j −1 ) = 0
...(3)
If j =0 , then ui, 1 = ui, –1 Now, putting j = 0 in equation (2), we get ui,1 = ui −1,0 + ui +1,0 − ui, −1 From (3), we get 1 ui,1 = (ui −1,0 + ui +1,0 ) 2
Putting i = 1, 2, 3, ...9 successively, we get the values of second row. In the similar way, we can fill the remaining rows as shown in following table : i
0
1
2
3
4
0
0
10.19
10.16 10.21
10.24
1
0
5.08
10.15 10.20
10.23
5
6
7
8
9
10
10.25 10.24 10.21
10.16
10.09
0
10.24 10.23 10.20
10.15
5.08
0
j
2
0
0.06
5.12
10.17
10.20
10.21 10.20 10.17
10.12
0.06
0
3
0
0.04
0.08
5.12
10.15
10.16 10.15 10.12
10.08
0.04
0
4
0
0.02
0.04
0.06
5.08
10.09 10.08 10.06
10.04
0.02
0
5
0
0.00
0
0
0
0
–0.02
0
0
0
0
11.13.2 Solution by the Method of Characteristics In order to understand the method of characteristics, consider a quasi-linear PDE of the form
a
∂ 2u ∂x
2
+b
∂ 2u ∂ 2u + c 2 + h = 0 ...(1) ∂x ∂y ∂y ∂u
∂u
where, the coefficients a, b, c and h may be functions of u, and only. ∂y ∂x Here, we use the following notation
∂u ∂u ∂ 2u ∂ 2u ∂ 2u = p, = q, 2 = r , = s, 2 = t ...(2) dx ∂y ∂x ∂y ∂x ∂y
Then, (1) can be written as ar + bs + ct + h = 0 ...(3) Let C be the curve in the x-y plane such that the function representing C satisfies the above equation. The total differentials of p and q in the direction tangential to C are given by
dp =
∂p ∂p dx + dy ∂x ∂y
⇒
dq =
∂q ∂q dx + dy ∂x ∂y
⇒ dq = sdx + tdy...(5)
dp = rdx + sdy...(4)
Applied Numerical Analysis
544 Eliminate r and t from (3) using (4) and (5), we get
a c (dp − sdy ) + bs + (dq − sdx ) + h = 0 dx dy dy dx dp dq s −a + b − c + a + c + h = 0 dy dx dy dx
⇒
dp dq s(am2 − bm + c ) − am +c + hm = 0 ...(6) dx dx
⇒ where, m =
dy . dx
Equation (6) is independent of r and t. In order to make (6) independent of s, also, we choose the curve C such that the slope of the tangent at every point on it satisfies the quadratic equation 2 ...(7) am – bm + c = 0 2 The two directions given by (7) are real and distinct when b – 4ac > 0, i.e., the second order partial differential equation (1) is hyperbolic. The two curves characterised by the above two directions are called characteristic curves. The differential equation (3) along a characteristic curve, then, reduces to the simple form am +
dp dq +c + hm = 0 ...(8) dx dx
The two families of characteristic are termed as f- characteristic and g- characteristic, where
f=
b + b2 − 4 ac = constant...(9) 2a
g=
b − b2 − 4 ac = constant...(10) 2a
Let the value of u, p and q be prescribed on the initial curve C1, which does not belong to any characteristic family. Let E, F, G be any three neighbouring points on C1. Let the f-characteristic through E intersect the g-characteristic through F at P. Similarly, the f-characteristic through F intersects the g-characteristic at Q and so on. The points P, Q would lie on a neighbouring curve, say C2. Let the coordinate of P be (xP, yP) which are to be determined. Since E and F are close points. The curve EP and FP are approximated as straight line. If (xE, yE), (xF, yF) are the coordinates of E and F respectively, then we have
yP − yE = fE ...(11) xP − xE
yP − yF = g F ...(12) xP − xF
13
Since m (= fE or gE) satisfies (8), we have ...(13) aEfE(pP – PE) + CE(qP – qE) + hfE = 0 ...(14) aFgF(pP – PF) + CF(qP – qF) + hgF = 0 Using (11), (12) in (13) and (14) respectively, we have two equations for the two unknowns pP and qP. We can next determine uP, the value p using du = pdx + qdy...(15) This can be approximated as
uP − uE =
pP − pE q − qE (xP − xE ) + P ( yP − yE ) 2 2
Numerical Solution of Partial Differential Equations ⇒
uP = uE +
545
pP − pE q − qE (xP − xE ) + P ( y P − y E ) ...(16) 2 2
The value of u at the point Q can be determined in a similar manner. Thus, we can obtain the solution along a neighbouring non-characteristic curve C2 using the values u, p, q along C2, we can proceed to determine the values along the next non- characteristic curve C3 and so on.
Remark
¯¯ The method of characteristic cannot be applied to parabolic and elliptic partial differential
equations, since the characteristic directions are coincident for parabolic and are imaginary for elliptic differential equations.
Example. Use the method of characteristic to solve the boundary value problem ∂2u
∂x 2
+
∂2u ∂2u −2 2 +1 = 0 ∂x ∂y ∂y
u = x,
∂u = x for y = 0, 0 [ x [ 1. ∂y
Comparing the given equation, with the standard equation, we get a = 1, b = 1, c = –2, h = 1. The characteristic directions are given by 2 m –m–2=0
⇒
From the given condition, the initial curve C1 is the straight line y = 0 and
Solution.
m=
∂u = x along y = 0. ∂y ∂u ∂u = 1, q = = x along y = 0. p = ∂x ∂y
1± 3 which gives f = 2, g = –1. 2
u = x,
xF = 0.5 Let xE = 0.4 and qF = 0.5 qE = 0.4 uE = xE = 0.4, uF = x Fˆ = 0.5. Now, yP = yE + fE(xP – xE) = 0 + 2(xP – 0.4) = 2xP – 0.8, Also, yP = yF + gF(xP – xF) = 0 + (–1)(xP – 0.5) = –xP + 0.5 Equating these two equations, we get 2xP – 0.8 = –xP + 0.5 ⇒ xP = 0.433 Hence, yP = 0.5 – 0.433 = 0.067 Now, aEfE(pP – pE) + cE(qP – qE) + h(yP – yE) = 0 Therefore, 2(pP – 1) – 2(qP – 0.4) + 0.067 = 0 ⇒ pP – qP = 0.4665 and aFqF(pP – pF) + cF(qP – qF) + hF(yP – yF) + (PP – 1) = 0 ⇒ –pP – 2(qP – 0.5) = –0.067 ⇒ pP + 2qP = 2.067 Solving qP = 0.5335 and pP = 1
uP = uE +
pP + pE q + qE (xP − xE ) + P ( yP − yE ) 2 2
⇒
uP = 0.4 +
1+1 0.5335 + 0.4 (0.433 − 0.4) + (0.067) = 0.46425 2 2
Hence, the value of u at P is 0.46427 to a first approximation. The coordinates of p are xp = 0.433, yp = 0.067.
Applied Numerical Analysis
546
Exercise 11.1
1. Classify the following equations : (i) 3uxx + uxy – 4uyy + 3uy = 0 (ii) uxx – 6uxy + 9uyy – 17uy = 0 2. Solve the elliptic equation uxx + uyy = 0 for the following square mesh with boundary values as shown in the figure. Iterate until the maximum difference between two successive values at any point is less than 0.001.
6. Compute u for one time step by CrankNicholson method if ut = uxx; 0 < x < 5, t > 0; u(x, 0) = 20, u(0, t) = 0 and u(5, t) = 100. (Anna–2006) 7. Find the numerical solution to solve ut = uxx, 0 [ x [ 1, t m 0 under the conditions that u(0, t) = u(1, t) and for 0 ≤ x ≤ 1 / 2 2x , u( x ,0) = x 2(1 − ), for 1/2≤ x ≤1 8. Solve the hyperbolic partial differential equation for one half period of oscillation
14
3. Solve uxx – uyy = 0 over the square mesh of side four units satisfying the following boundary conditions : (i) u(0, y) = 0 for 0 [ y [ 4 (Cusat B.Tech-2008) (ii) u(4, y) = 12 + y for 0 [ y [ 4 (iii) u(x, 0) = 3x for 0 [ x [ 4 2
(iv) u(x, 4) = x for 0 [ x [ 4 ∂ 2u
∂ 2u
= 8 x 2 y 2 for square mesh, ∂x 2 ∂y 2 given u = 0 on the four boundaries dividing the square into 16-subsquares of length one unit. (JNTU–2004S) 5. Find the values of u(x, y) satisfying the Laplace equation ∇2u = 0 at the pivotal points of a square region with boundary (VTU-2009) values given below :
4. Solve
+
taking h = 1. utt = 25uxy, u(0, t) = u(5, t)= 0, ut(x, 0) = 0 if 0 ≤ x ≤ 2.5 2x , u( x ,0) = 10 − x , if 2.5 ≤ x ≤ 5
9. Evaluate the pivotal values for the following
equation taking
h = 1 and upto one half of
the period of vibration 16uxx = utt, given that 2 u(0, t) = u(5, t) = 0, u(x, 0) = x (x – 5) and
(Madras–2006) ut(x, 0) = 0. 10. Classify the following equations. (i) uxx + 2uxy + uyy = 0 [Madras–2001]
(ii) y2uxx – 2xyuxy + x2uyy + 2ux–3u = 0
(Madras–2003) (iii) y2uxx + uyy + u2x + u2y+7 = 0 (Madras–2003)
11. Solve the equation uxx + uyy = 0 for the
square mesh with boundary values as shown (Delhi–2002) in the fig.
16 15
Numerical Solution of Partial Differential Equations
17 12. Solve the elliptic equation uxx + uyy = 0 for the square mesh with boundary values as shown in fig. Iterate until the maximum difference between successive values at any point is less than 0.005.
18
547
19 13. Find the solution of the parabolic equation uxx = 2u, when u(0, t) = u(4, t) = 0 and 4(x, 0) = x(4 – x), taking h = 1. Find the values upto t = 5. [Madras–2001] ∂ 2u ∂u = 14. Solve the equation with the ∂x 2 ∂t conditions u(0, t), u(x, 0) = x(1 – x) and u(1, t) = 0. Assume h = 0.1. Tabulate u for t = k, 2k and 3k choosing an appropriate [Anna–2004] value of k. 15. Solve the boundary value problem utt = uxx with the conditions u(0, t) = u(1, t) = 0, 1 u( x ,0) = x(1 − x ) and ui(x, 0) = 0, taking 2 h = k = 0.1 for 0 ≤ t ≤ 0.4. Compare your solution with the exact solution at x = 0.5 [VTU–2003] and t = 0.3. ∂ 2u ∂ 2u = 16. Solve , 0 < x < 1, t > 0, given ∂t 2 ∂x 2 t > 0, given u(x, 0) = ut(x, 0) = u(0,1)=0 and u(1, t) = 100 sinpt. Compute u for 4 times with h = 0.25. [Anna–2003]
Answers 1. (i) Hyperbolic; (ii) Parabolic 2. u1 = 1.999, u2 = 2.999, u4 = 3.999 3. 2.37, 5.59, 9.87, 2.88, 6.13, 9.88, 3.01, 6.16, 9.51 4. –3, –2, –3, –2, –2, –2, –3, –2, –3 5. u 1 = 6.64, u2 = 11.25, u3 = 14.33, u4 = 6.60, u5 = 11.95, u6 = 16.25, u7 = 7.84, u8 = 13.67, u9=17.89 6.
7.
i
0
0.25
0.5
0.75
1
0
0
0
0
0
0
1/16
0
0.00116
0.004464
0.01674
1/16
1/8
0
0.005899
0.019132
0.052771
1/8
j
i
0
1
2
3
4
5
j 0
0
20
20
20
20
100
1
0
9.80
20.19
30.72
59.92
100
Applied Numerical Analysis
548 i
8.
0
0.2
0.4
0.6
0.8
1.0
0.8
0.6
0.4
0.2
0
j
9.
0
0
0.1936 0.3689 0.5400 0.6461 0.6291 0.6461 0.5400 0.3689
0.1936
0
1
2
0.1989 0.3956 0.5834 0.7381 0.7691 0.7381 0.5834 0.3956
0.1989
0
i
j
10.
0
1
2
3
4
5
0
0
2
4
4
2
0
0.2
0
2
4
4
2
0
0.4
0
2
2
2
2
0
0.6
0
0
0
0
0
0
0.8
0
–2
–2
–2
–2
0
1.0
0
–2
–4
–4
–2
0
i
0
1
2
3
4
5
0
0
4
12
18
16
0
1
0
4
12
18
16
0
2
0
8
10
10
2
0
3
0
6
6
–6
–6
0
4
0
–2
–10
–10
–8
0
5
0
–16
–18
–12
–4
0
j
11. (i) Parabolic; (ii) Parabolic (iii) Elliptic 12. u1 = 7.9, u2 = 13.7, u3 = 17.9, u4 = 6.6, u5 = 11.9, u6 = 16.3, u7 = 6.6, u8 = 11.2, u9 = 14.3 13. u1 = 26.66, u2 = 33.33, u3 = 43.33, u4 = 46.66 14. u1 = 0.99, u2 = 1.49, u3 = 0.49 i 0 1 15. j 0 0 3 1 2 3 4 5
0 0 0 0 0
2
2 1.5 1 0.75 0.5
3
4
4
3
0
3 2 1.5 1 0.75
2 1.5 1 0.75 0.5
0 0 0 0 0
1 6. i
0
1
2
3
4
5
6
7
8
9
10
0
0
0.9
0.16
0.21
0.24
0.25
0.24
0.21
0.16
0.09
0
1 2
0 0
0.8 0.75
0.15 0.14
0.20 0.19
0.23 0.22
0.24 0.23
0.23 0.22
0.20 0.19
0.15 0.14
0.08 0.075
0 0
3
0
0.7
0.13
0.18
0.21
0.22
0.21
0.18
0.13
0.07
0
j
Numerical Solution of Partial Differential Equations 17.
18.
549
t = 0.3, x =
0.1
0.2
0.3
0.4
0.5
Num. sol. u =
0.02
0.04
0.06
0.075
0.08
Exact. sol. u =
0.02
0.04
0.06
0.075
0.08
i
0
1
2
3
4
0
0
0
0
0
0
1 2 3 4
0 0 0 0
0 0 0 70.7
0 0 70.7 100
0 70.7 100 70.7
70.7 100 70.7 0
j
MULTIPLE CHOICE QUESTIONS (CHOOSE THE MOST APPROPRIATE ONE) (c) Jacobi’s method (d) none of these 5. ui, j +1 = ui, j −1
1. Parabolic equation is : ∂ 2u ∂ 2u (a) 2 + 2 = 0 ∂x ∂y
(c) a2
∂ 2u
=
∂ 2u
(b)
∂u ∂ 2u = α2 2 ∂t ∂x
+ 2α ui −1, j − (ui, j −1 + ui, j +1 ) + ui +1, j
(d) none of these
∂x 2 ∂t 2 2. Heat equation is also known as : (a) Elliptic (b) Hyperbolic
(c) Parabolic (d) none of these 3. The formula 1 +1) ( n) ( n) ( n +1) u(i,nj+1) = u(i −n1, j + ui +1, j + ui , j −1 + ui , j +1 4 is known by : (a) Libermann interation formula (b) Gauss-Seidal method (c) Jacobi’s method (d) none of these 4. The formula 1 ) ( n) ( n +1) ( n) u(i,nj+1) = u(i −n1, j + ui +1, j + ui , j +1 + ui , j −1 4 is known by : (a) Libermann iteration formula (b) Gauss-Seidal method
is known by : (a) Iterative method (b) Dufort and Frankel’s method (c) Crank Nicholson method (d) none of these
6. λ{ui +1, j +1 + ui −1, j +1 } − 2( λ + 1)ui, j +1 = 2( λ − 1)u i, j − λ(ui +1, j + ui −1, j ) (a) Iterative method (b) Dufort and Frankel’s method (c) Crank Nicholson method (d) none of these 7. The equation 3uxx+uxy –4uyy + 3uy = 0 is : (a) Hyperbolic (b) Parabolic (c) Elliptic (d) none of these 8. The Crank-Nicholson formula is convergent for all values of : (a) (l –1) (b) l (c) (l +1) (d) none of these
Answers 1. (b)
2. (c)
3. (a)
4. (c)
5. (b)
6. (c)
7. (a)
8. (b)
ARCHIVE 1. Evaluate the pivotal values of the following equation taking h =1 and upto one half of the
period of vibration 16
∂ 2u ∂x 2
=
∂ 2u ∂t 2
given that
u(0, t) = u(5, t) = 0; u(x, 0)= x2(5–x) and ut(x, 0)= 0.
(Meerut-2002; Chennai-2007; RGPV-2006)
Applied Numerical Analysis
550 ∂ 2u
2. Solve the equation
2
+
∂ 2u 2
∂u ∂ 2u = ∂t ∂x 2 under the boundary and initial conditions : (a) u(x, t) = 0 at x = 0 and x = 1 for t > 0. (Kurukshetra-2002, 03, 06, 08) (b) u(x, t) = sin px at t = 0 for 0 x 1, by Gauss-Seidal method. (Madurai-2004; Bilaspur-2006, 09) 5. (a) Solve the elliptic equation uxx+uyy=0 for the following square mesh with boundary values as shown. (RGPV-2009; Bangaluru-2006; 07) (b) Given the values of u(x, y) on the boundary of the square in the figure and evaluate the function u(x, y) satisfying the Laplace equation D2u=0 at the pivotal points of this figure by (Chennai-2004) (i) Jacobi’s Method (ii) Gauss Seidal method. (VTU-2007; Andhra-2000, 06)
= 0 for the
4. Solve the heat conduction equation
∂x ∂y region boundary by the square 0 x 4 and 0 y 4, subject to the bcs : u = 0 at x = 0 u + 8 +2y at x = 4. u = x2/2 at y = 0 u = x2 at y = 4. Choose h = k = 0.1 and use Gauss-Seidal method to compute u at the interval mesh points. ∂u ∂ 2u = subject to ∂t ∂x 2 the boundary and initial conditions as follows: u(x, 0) = 0, u(0, t) =0, u(1, t) = t.
3. Solve the heat equation
(Meerut-2003; Rohilkhand-2006, 09; Bhopal-2007; Bangluru-2004)
Answers 1.
i
0
1
2
3
5
0
0
4
12
18
16
0
1
0
4
12
18
16
0
2
0
0+12–4 =8
4+18–12=10
12+16–18=10
18+0–16=2
0
3
0
0+10–4=6
8+10–12=6
10+2–18=–6
10+0–16=–6
0
4
0
–2
–10
–10
–8
0
5
0
–16
–18
–12
–4
0
2. u1 = 1208, u2 = 782, u3 = 1042, u4 = 458. 4.
4
j
x
u(x)
0.0 0.0
0.2 0.5878
3. 0.53022.
0.4 0.9511
0.6 0.9511
0.8 0.5878
1.0 0.0
n=0
0.0
0.5878
0.9511
0.9511
0.5878
0.0
n=1
0.0
0.5129
0.8176
0.8078
0.4890
0.0
n=2
0.0
0.4907
0.7900
0.7868
0.4855
0.0
n=3
0.0
0.4861
0.7858
0.7855
0.4853
0.0
n=4
0.0
0.4854
0.7854
0.7854
0.4853
0.0
n=5
0.0
0.4853
0.7854
0.7854
0.4853
0.0
n=6
0.0
0.4853
0.7854
0.7854
0.4853
0.0
5. (a) u1 = 939, u2 = 1001, u4 = 1251 and 1126.
(b) (i) u1 = 1208, u2 = 792, u3 = 1042 and u4 = 458.
(ii) u1 = 1208, u2 = 792, u3 = 1042 and u4 = 458.
qqqq
Fitting of Curves and Cubic Splines
551
12 Fitting of Curves and Cubic Splines 12.1 Introduction If some values of a variate are collected in the arbitrary order, in which they occur, we cannot properly grasp the significance of the data. For example: Consider the marks of 50 students in Mathematics, arranged according to their roll numbers, the maximum marks being 100. 9, 70, 75, 15, 0, 33, 69, 66, 37, 99, 81, 12, 31, 22, 60, 79, 46, 73, 46, 79, 75, 65, 85, 22, 8, 12, 41, 87, 82, 72, 50, 22, 87, 50, 89, 28, 29, 50, 40, 36, 40, 30, 28, 87, 81, 90, 22, 15, 30, 35. The data given in the above form is called ungrouped data. If the data arranged in ascending or descending order of magnitude, it is said to be arranged in an array. If arranged the given data into class intervals 0-10, 10-20, ..., 90-100. Then, this method is known as tally method. If the identity of the individuals about whom, a particular information is taken is not relevant, nor the order in which the observations arise, then we divide the observed range of variables into a suitable number of class intervals and record the number of observation in each class. For example in the above case, the data may be expressed as in the following table : Such a table showing the distribution of the Marks No. of Students frequencies in the different classes is called a frequency 0–10 3 table and the way in which the class frequencies are 10–20 4 distributed over the class intervals is called the grouped frequency distribution of the variable. 20–30 7 The following points may be considerable for 30–40 7 classifications : 40–50 5 (i) The class should be clearly defined and should not lead to any ambiguity. 50–60 3 (ii) The number of class should never be less than 60–70 4 6 and not more than 30. Because with less 70–80 7 number of classes, the accuracy may be lost, and with more number of classes, the computations 80–90 8 become lengthy. 90–100 2 (iii) The observation corresponding to common point of two classes should always be put in the higher class. For example, a number corresponding to the values 20 is to be put up in the class 20-30 and not in 20-30. (iv) The classes should be of equal width.
12.1.1 Magnitude of the Class Interval Having fixed the number of classes, divide the range by it and nearest integer to this value gives the magnitude of the class interval.
Applied Numerical Analysis
552
12.1.2 Class Limits The class limit should be chosen in such a way that the mid value of the class interval and actual average of the observations in that class intervals are as near to each other as possible.
12.2 continuous frequency distribution If we deal with a continuous variable, it is not possible to arrange the data in the class interval. Let us consider the distribution of age in years. If we take the intervals 15-19, 20-24, then the persons with ages between 19 and 20 years are not taken into consideration. In such a case, we form the class interval as follows. Age in years Below 5 5 or more but less than 10 10 or more but less than 15 15 or more but less than 20 20 or more but less than 25 ............................................ where all the persons with any fraction of age are included in one group or the other. Practically, we re-write it as 0–5; 5–10; 10–15; 15–20; 20–25 This form of frequency distribution is known as continuous frequency distribution.
12.3 graphical representation It is often useful to represent a frequency distribution by means of a diagram which makes the unwidely data intelligible and conveys to the eye the general run of the observations. When data of two items is compared with one another, it is always easier to compare through graphs and diagrams. Here, we consider some important types of graphic representations.
12.3.1 Histogram In drawing the histograms of a given grouped frequency distribution, first we mark off along a horizontal base line all the class-intervals using a suitable scale, then draw rectangles with the areas proportional to the frequencies of the respective class intervals. For equal class-intervals, the height of the rectangles will be proportional to the frequencies. For unequal class-intervals, the heights of the rectangles will be proportional to the ratios of the frequencies to the width of the corresponding class. Then the diagram of continuous rectangles so obtained is called histogram.
Remarks
¯¯ Histograms are useful, when the class intervals are not of the same width. They are appropriate to cases in which the frequency changes rapidly.
¯¯ To draw the histogram for an ungrouped frequency distribution of a variable, assume that the frequency corresponding to the variate value x is distributed over the interval (x – h/2) to (x + h/2), where h is the jump from one value to the next. ¯¯ If the grouped frequency distribution is not continuous, convert it into continuous distribution and then draw the histogram. ¯¯ The height of each rectangle is proportional to the frequency of the corresponding class, the height of a fraction of the rectangle is not proportional to the frequency of the corresponding fraction of the class, therefore, the histogram cannot be directly used to read frequency over a fraction of a class interval.
Fitting of Curves and Cubic Splines
553
Consider the following example: Marks under 10 under 20 under 30 under 40 under 50
No. of Students 2 6 16 20 23
Marks under 60 under 70 under 80 under 90 under 100
No. of Students 31 32 37 48 50
Then the histogram from the above data is : 11 10 9 8 7 Frequency
6 5 4 3 2 1 0
12.3.2 Frequency Polygon
10 20 30 40 50 60 70 80 90 100 Marks Fig. 1
The frequency polygon is obtained by plotting points with abscissa as the variate values and the ordinates as the corresponding frequencies and joining the plotted points by a straight line taken in order. In a frequency polygon the variables or individuals of each class are assumed to be concentrated at the mid-points of the class-interval. 11 10 9 8 7
Frequency
6 5 4 3 2 1 0
10 20 30 40 50 60 70 80 90 100 Marks Fig. 2
Applied Numerical Analysis
554
12.3.3 Frequency Curve
12.3.4 Commulative Frequency Curve or Ogive If the upper limits of the class taken as x-coordinate and the commulative frequencies as the y-coordinate and the points are plotted, then, these points, when joined by a freehand smooth curve given the commulative frequency curve or the ogive.
12.4 curve fitting
Commulative Frequency
(UPTU(MCA)–2006) If through the vertices of a frequency polygon, a smooth freehand curve is drawn we get the frequency curve.
48
50 40 31
30 20
16
10 2
32
50
37
20 23
6
0 10 20 30 40 50 60 70 80 90 100 In applied mathematics, several Marks equations of different types can be obtained to express the given data approximately. But Fig. 3 we want to find the equation of the curve of best fit which may be most suitable for predicting the unknown values. The process of finding such an equation of best fit is known as curve fitting. By curve fitting we means an expression of the relationship between two variables by an equation. If there are n pair of observed values, then it is possible to fit the given data to an equation that contains n arbitrary constants for we can solve n simultaneous equation for n unknowns. Let us consider m independent linear equations
a11 x1 + a12 x 2 + ... + a1n x n = b1
a21 x1 + a22 x 2 + ... + a2n x n = b2 .......... ...................... ...(1) .......... ...................... am1 x1 + am2 x 2 + ... + amn x n = bm
where a´s and b´s are constants and x1, x2, ..., xn are n variables. Now, there are two cases : (i) If m = n, then there exists a unique set of values satisfying the given system of equations. (ii) If m > n, which implies that the number of equations is greater than the number of variables, then there exists no solution. In this case we try to find these values of variables x1, x2, ..., xn which satisfy as closed as possible to the given equation. These obtained values are called the most plausible values or the best fit values.
12.5 method of least squares Consider m independent linear equations in n unknowns x1, x2, ..., xn where m > n as a11 x1 + a12 x 2 + ... + a1n x n = b1
a21 x1 + a22 x 2 + ... + a2n x n = b2 .......... ...................... ...(1) .......... ...................... am1 x1 + am2 x 2 + ... + amn x n = bm
with constants a´s and b´s. Let x1, x2, ..., xn be the most plausible values then, we have Ei = (ai1 x1 + ai2 x 2 + ... + ain x n − bi ) (known as residual or deviation, or the error Ei) ⇒ Ei = (ai1 x1 + ai2 x 2 + ... + ain x n − bi ) i = 1, 2, ... m....(2)
Fitting of Curves and Cubic Splines
555
Let us suppose S is the sum of the squares of Ei. n
n
i =1
i =1
S = ∑ (ai1 x1 + ai2 x 2 + ... + ain x n − bi )2 = ∑ Ei2 ...(3)
Then, we get
To find the maximum or minimum values of S, we must have ∂S ∂S ∂S = 0, = 0,..., =0 ∂x1 ∂x 2 ∂x n
m
m
m
i =1
i =1
i =1
Then (3) ⇒ ∑ ai1 Ei = 0, ∑ ai2 Ei = 0,..., ∑ ain Ei = 0 ...(4) These n equations given by (4) are known as the normal equations and can be easily solved for the n variables x1, x2, ..., xn. The values of x1, x2, ..., xn so obtained are the most plausible or best values.
Remarks
¯¯ The principle of least squares, is first given by Gauss in 1795 but it was named and published for the first time in 1805 by Legendre.
¯¯ The method of least square does not help us to choose the degree of the curve to be fitted but helps us in finding the values of the constants when the form of the curve has already been given.
12.5.1 Normal equations
Consider the curve of nth degree y = a + bx + cx 2 + ... + kx n with (k g 0) Then, the normal equation obtained from (4), are Σy = ma + bΣx + ... + kΣx n
Σxy = aΣx + bΣx 2 + ... + kΣx n +1
Σx 2 y = aΣx 2 + bΣx 3 + ... + kΣx n + 2
Σx n y = aΣx n + bΣx n +1 + ... + kΣx 2n When second order partial derivatives are calculated and substituted these values, they gives a positive value of the function, which implies that S is minimum. In particular, if we take n = 1 then we get the equation of straight line y = a + bx and the normal equations are Σy = ma + bΣx ;
Σxy = aΣx + bΣx 2 ;
Σx 2 y = aΣx 2 + bΣx 3
12.6 most plausible solution of a system of linear equations Consider m number of independent linear equations in n unknowns x1, x2, …, xn of the form n
∑ aij x j , i = 1,2,… , m …(1)
j =1
where aij ′ s are constants. By applying the method of least square, we find the values of x1, x2, …, xn. The values obtained by the method of least squares are known as best values or plausible values.
WORKING PROCEDURE (To find the most plausible values) m Step 1. Let S = ∑ [ai1 x1 + ai2 x 2 + … + ain x n − bi ]2 j =1
∂S = 0, j = 1,2,… , n Step 2. Put ∂x j
Step 3.
Solve the equations obtained in the step 2.
Applied Numerical Analysis
556
Then solution of normal equations gives the most plausible solution to the system of linear equations.
Example 1. Find the normal equations and hence find the best fit values of x, y, z in
the least square sense from the following equations x + 2y + z = 1; 2x + y + z = 4; –x + y + 2z = 4; 4x + 2y – 5z = –7 Solution. The given equation can be written as
x + 2 y + z − 1 = 0 2 x + y + z − 4 = 0 ...(1) − x + y + 2 z − 4 = 0 4 x + 2 y − 5 z + 7 = 0
Now, to obtain the normal equations of x, we multiply these equations by the coefficient of x in that equation and then add. Then, the normal equations are 1( x + 2 y + z − 1) + 2(2 x + y + z − 4) + ( −1)( − x + y + 2z − 4) + 4(4 x + 2 y − 5z + 7) = 0 ⇒ 22 x + 11 y − 19 z + 23 = 0 ...(2) Similarly, for the normal equation of y, multiply these equations by the coefficient of y in that equation and then add, we get 2( x + 2 y + z − 1) + 1(2 x + y + z − 4) + 1( − x + y + 2z − 4) + 2(4 x + 2 y − 5z + 7) = 0 ...(3) ⇒ 11 x + 10 y − 5z + 4 = 0 Similarly, the normal equation for z is 1( x + 2 y + z − 1) + 1(2 x + y + z − 4) + 2( − x + y + 2z − 4) − 5(4 x + 2 y − 5z + 7) = 0 ⇒ 19 x + 5 y − 31z + 48 = 0 ...(4) Solving (2), (3) and (4) for x, y and z we get x = 0.910, y = –0.378 and z = 2.045 b Example 2. Find the normal equations for fitting the curve of type y = ax + by least x square method. Solution. The given equation can be written as –1 y = ax + bx Consider the n points ( x1 , y1 ),( x 2 , y2 ),...,( x i , yi ),...,( x n , yn ).
Then the residual or deviation of the ith point ( x i , yi ) is
The sum of the squares of the error is given by 2
b S = Σ yi − ax i − ...(1) xi
b yi = ax i + xi
For the maxima and minima of S, we have
∂S ∂S = 0, = 0, ∂a ∂b ∂S b = 0 ⇒ Σx i yi − ax i − = 0 ⇒ Σ( x i yi − ax i2 − b) = 0 xi ∂a Σx i yi = aΣx i2 + nb ...(2) 1 ∂S b = 0 ⇒ Σ yi − ax i − = 0 ∂b x i x i yi y b 1 Σ −a − 2 = 0 Σ i = na + bΣ 2 ⇒ ...(3) x x x x i i i i
⇒
⇒
Equation (2) and (3) gives the required normal equations.
Fitting of Curves and Cubic Splines
557
Example 3. Find the most plausible values of x and y from the following equations : x + y = 3.00, 2x – y = 0.5, x + 3y = 7.25, 3x + y = 4.95. Solution. The given equations can be written as
x + y − 3.00 = 0 2 x − y − 0.5 = 0 ...(1) x + 3 y − 7.25 = 0 3 x + y − 4.95 = 0
Now sum of the square ‘S’ of the errors is given by S = ( x + y − 3.00)2 + (2 x − y − 0.5)2 + ( x + 3 y − 7.25)2 + (3 x + y − 4.95)2 = 0 For the maxima and minima of S, we must have ∂S ∂S = 0, = 0, ∂x ∂y ∂S =0 Now, ∂x ⇒ ( x + y − 3.00) + 2(2 x − y − 0.50) + 1( x + 3 y − 7.25) + 3(3 x + y − 4.95) = 0
⇒
and
15 x + 5 y − 26.10 = 0 ...(2)
∂S =0 ∂y ⇒ ( x + y − 3.00) − (2 x − y − 0.50) + 3( x + 3 y − 7.25) + (3 x + y − 4.95) = 0
⇒ 5 x + 12 y − 29.20 = 0 ...(3) Solving (2) and (3), we get x = 1.234, y = 1.919. Example 4. Find the most plausible values of x and y from the following equations 3 x + y = 4.95; x + y = 3.00; 2 x − y = 0.5; x + 3 y = 7.25 (UPTU–2004)
Solution. Let S = (3 x + y − 4.95)2 + ( x + y − 3.00)2 + (2 x − y − 0.5)2 + ( x + 3 y − 7.25)2 = 0
∂S = 6(3 x + y − 4.95) + 2( x + y − 3.00) + 4(2 x − y − 0.5) + 2( x + 3 y − 7.25) ⇒ ∂x
...(1)
= 30x + 10y – 52.2 ∂S = 10 x + 24 y − 58.4 and ∂y
We obtained the normal equation by putting
∂S ∂S = 0 and =0 ∂y ∂x Therefore, 3 x + y = 5.22; x + 2.4 y = 5.84
On solving we get
x = 1.07871, y = 1.98387
Exercise 12.1 1. Find the values of x and y which satisfy the following equations most satisfactorily with the help of normal equation of x, y
3. Use the method of least squares to find the most plausible values of x and y from the following equations
x + 2.5 y = 21,3.2 x − y = 28, 4 x + 1.2 y = 42.04,1.5 x + 6.3 y = 40. 2. Find the most plausible values of x and y from the four equations x − y + 2z = 3,3 x + 2 y − 5z = 5, 4 x + y + 4 z = 21 and − x + 3 y + 3z = 14. (Meerut-2002)
x + y = 3.01,2 x − y = 0.03, x + 3 y = 7.03, 3 x + y = 4.97 4. Find the most plausible values of x and y from the following equations x + y = 301,2 x − y = 3, x + 3 y = 703,
3 x + y = 497.
Applied Numerical Analysis
558
Answers 1. x = 5.5, y = 4.7 2. x = 2.47, y = 3.55, z = 1.92
3. x = 0.999, y = 2.004 4. x = 100, y = 200
12.7 method of curve-fitting Let us consider the rth degree curve y = a + bx + cx 2 + ... + kx r , with k g 0
...(1)
with the given values ( x1 , y1 ),( x 2 , y2 ),...,( x m , ym ). The curve given by (1) has (r +1) unknown a, b, c, ..., k and so if m = r +1, we get (r + 1) equations when the values ( x1 , y1 ),( x 2 , y2 ),...,( x m , ym ) are substituted for (x, y) in (1) and thus a unique solution of the values of the unknown a, b, c, ..., k is possible. yi′ = a + bx i + cx i2 + ... + kx ir ...(2) Now let and let yi be the observed values y for xi. Then if ui be the residual for this point, we have ui = yi − yi′ = yi − (a + bx i + cx i2 + ... + kx ir ), from (2) ui = yi − a − bx i − cx i2 − ... − kx ir ...(3) Now in order to make the sum of the squares of the errors minimum, we define m
m
i =1
i =1
S = ∑ ui2 = ∑ ( yi − a − bx i − cx i2 − ... − kx ir )2 ...(4)
By the principle of maxima and minima, we must have ∂S ∂S ∂S = 0, = 0,..., = 0 ...(5) ∂a ∂b ∂k
which gives the following (r + 1) equations :
m ∂S = −2 ∑ ( yi − a − bx i − cx i2 − ... − kx ir ) = 0 ∂a i =1
m
2 r ∑ ( yi − a − bx i − cx i − ... − kx i ) = 0
⇒ ⇒
i =1 m
m
m
m
i =1
i =1
i =1
2 ∑ yi − ∑ a − ∑ bx i − ∑ cx i − ... = 0
i =1
Σyi = ma + bΣx i + c Σx i2 + ... ...(6)
∂S = 0 = −2Σ( yi − a − bx i − cx i2 − ... − kx ir )x i ∂b
Now or
Σ( yi − a − bx i − cx i2 − ... − kx ir )x i = 0
Σx i yi = aΣx i + bΣx i2 + c Σx i3 + ... ...(7)
Σx i2 yi = aΣx i2 + bΣx i3 + c Σx i4 + ... ...(8) Similarly The equations (6), (7) and (8) are known as normal equations and can be solved as simultaneous equations to evaluate a, b, c, ... k.
12.8 Fitting of Some Special Curves
12.8.1 Fitting of a Straight Line Let y = a + bx...(1) be the equation of the straight line to be fitted. Then the normal equations can be obtained as follows. S = u2 = Σ( yi − a − bx i )2 Let u = (yi – a – bxi) and
Fitting of Curves and Cubic Splines
559
For the maxima and minima of S, we must have
∂S =0 ∂a
Σ( yi − a − bx i ).1 = 0 ⇒ −2Σ( yi − a − bx i ).1 = 0 ⇒ Σyi = ma + bΣx i ...(2) ∂S =0 ∂a
Now
−2Σ( yi − a − bx i )( − x ) = 0
⇒ Σ( yi − a − bx i )x = 0
Σx i yi = aΣx i + bΣx i2 ...(3) Solving these two equations we can find the values of a and b. Special Case : If the straight line to be fitted passes through the origin, then the equation of the straight line is given by y = bx
Its normal equation is Σxy = bΣx 2 we can find the value of constant b easily.
12.8.2 Fitting of a Parabolic Curve y = a + bx + cx 2 ...(1) Let be the equations of the parabolic curve to be fitted. Then the normal equations are Σxy = aΣx + bΣx 2 + c Σx 3 ...(2) Σx 2 y = aΣx 2 + bΣx 3 + c Σx 4 Σy = ma + bΣx + c Σx 2
Solving above three equations for a, b and c simultaneously we can find the values of a, b and c.
12.8.3 Fitting of an Exponential Curve y = aebx ...(1) Let be the equation of the exponential curve to be fitted. Taking logarithms of both sides of (1) to the base 10. log10 y = log10 a + bx log10 e ...(2) We get Y = A + Bx ...(3) This is of the form
where Y = log10 y , A = log10 a and B = b log10 e . Now applying the method of fitting a straight lines we can find the values A and B and hence the values of a and b. x
12.8.4 Fitting of the Curve of the Type y = ab
Here the method of fitting is the same as given in part 12.8.3 above. b
12.8.5 Fitting of the Logarithmic Curve of the form y = ax We have
y = ax b
Taking log of both the sides, we get
log y = log a + b log x
Let us put log y = Y ,log a = A and log x = X Y = A + bX ...(1) Then, we have ΣY = An + bΣX Normal equation for (1) are ΣXY = AΣX + bΣX 2
Applied Numerical Analysis
560
12.8.6 Fitting of the Curve y = a + b/x Let put
1 = X . Then given equations becomes x
y = a +bx...(1) The normal equation for (1) are Σy = an + bΣx ...(2) ΣXy = aΣX + bΣX 2 ...(3) Solving these equations we get the required value of a and b.
12.8.7 Fitting of the Curve y = ax + b/x Let the curve y = ax +
b passes through the point ( x i , yi ), i = 1,2,..., n. The error of estimate for ith x
point ( x i , yi ) is di = yi − ax i −
b xi
By the principle of least squares, the sum of squares of the error should be minimum. n
S = ∑ di2 should be minimum.
i.e., ⇒
i =1
n
b
2
S = ∑ yi − ax i − should be minimum. xi i =1 ∂S ∂S = 0 and = 0. ∂a ∂b n ∂S b = 0 ⇒ − 2 ∑ x i yi − ax i − = 0 ∂a x i =1 i
We obtained the normal equations by
⇒
∑ x i yi = a ∑ x i2 + bx ...(1)
n
n
i =1
i =1
n 1 ∂S b = 0 ⇒ −2∑ yi − ax i − x = 0 ∂b x i =1 i i
and n
n 1 yi = an + b ∑ 2 x i =1 i i =1 x i
⇒
∑
...(2)
Solving (1) and (2) we get the required values of a and b. 2
12.8.8 Fitting of the Curve y = a + b/x + c/x
We have S = ∑ y − a −
b
−
c should be minimum.
Normal equations can be obtained by Now and
∂S ∂S ∂S = 0, = 0, =0 ∂a ∂b ∂c
n n 1 n 1 b c ∂S = 0 ⇒ − 2 ∑ yi − a − − 2 = 0 ⇒ Σyi = an + b ∑ +c∑ 2 ∂a xi xi i =1 i =1 x i i =1 x i
n 1 n y n 1 n 1 n 1 b c ∂S i =a = 0 ⇒ −2∑ +b∑ 2 +c∑ 3 ∑ yi − a − − 2 = 0 ⇒ ∑ x x x x ∂b xi i =1 i i =1 i i =1 i i =1 x i i =1 x i i n 1 n y n 1 n 1 n 1 b c ∂S = 0 ⇒ − 2 ∑ 2 yi − a − − 2 = 0 ⇒ ∑ 2i = a ∑ 2 + b ∑ 3 + c ∑ 4 ...(3) xi xi ∂c i =1 x i i =1 x i i =1 x i i =1 x i i =1 x i
Solving (1), (2) and (3), we get the required values of a, b and c.
Fitting of Curves and Cubic Splines
561
12.8.9 Fitting of the Curve y = ax2 + b/x n b S = ∑ yi − ax i2 − xi i =1
We have
2
n n n n b ∂S = 0 ⇒ − 2 ∑ x i2 yi − ax i2 − = 0 ⇒ ∑ x i2 yi = a ∑ x i4 + b ∑ x i ...(1) xi ∂a i =1 i =1 i =1 i =1 n 1 n y n n 1 b ∂S 2 i = 0 ⇒ −2∑ yi − ax i − x = 0 ⇒ ∑ x = a ∑ x i + b ∑ 2 ...(2) ∂b i =1 x i i =1 i i =1 i =1 x i i
Now
Solving (1) and (2) we get the values of a and b.
12.8.10 Fitting of the Curve y = a/x + b x n a S = ∑ yi − − b x i xi i =1
Here we have
n 1 n y n 1 n 1 a ∂S yi − − b x i = 0 ⇒ ∑ i = a ∑ 2 + b ∑ = 0 ⇒ −2∑ ...(1) ∂a xi i =1 x i i =1 x i i =1 x i i =1 x i
Now
2
n n n 1 n a ∂S = 0 ⇒ − 2 ∑ x i yi − − b x i = 0 ⇒ ∑ ( x i ) yi = a ∑ + b ∑ x i ...(2) ∂b xi i =1 i =1 i =1 x i i =1
On solving (1) and (2) we get the required values of a and b.
Example 1. Fit a straight line to the following data :
Solution.
x
1
2
3
4
5
y
5
7
9
10
11
Here, we have x
1
2
3
4
5
Sx = 15
y
5
7
9
10
11
Sy = 42
xy
5
14
27
40
55
Sxy = 141
2
1
4
9
16
25
Sx2 = 55
x
the equation of the line be y = a + bx...(1) Normal equation are Sy = ma + bSx 2 and Sxy = aSx + bSx Using the given values, 42 = 5a + 15b...(2) 141 = 15a + 55b ...(3) 3 39 ,a = 2 10
Solving (2) and (3), we get b =
b = 1.5, a = 3.9 or Hence, required straight line is given by y = (3.9) + (1.5)x
Remark
¯¯ For the sake of convenience, it is sometimes easy to change the origin and scale with the substitution x = respectively.
x−A y−B and y = , where A and B are the middle values of x and y series h h
Applied Numerical Analysis
562 Example 2. Fit a straight line to the following data :
Solution.
x
0
5
10
15
20
25
y
12
15
17
22
24
30
We observe that the number of values given is 6, i.e., even and the difference in the values of x is 5. In such a case the calculations can be simplified if we take half the common distance which is 2.5 here as unit of measurement. Also the two mid-values 1
are 10 and 15, so we take their mean, i.e., (10 + 15) , i.e.,12.5 as the origin. 2 Therefore, introduce two new variables
u=
x − 12.5 and v = y – 20 2.5
...(1)
Then we have
u:
0 − 12.5 5 − 12.5 10 − 12.5 15 − 12.5 20 − 12.5 25 − 12.5 , , , , , 2.5 2.5 2.5 2.5 2.5 2.5
Total
u
–5
–3
–1
1
3
5
v
12 – 20
15 – 20
17 – 20
22 – 20
24 – 20
30 – 20
=–8
=–5
=–3
=2
=4
= 10
0
uv
40
15
3
2
12
50
122
2
25
9
1
1
9
25
70
u
0
Now let the equation of line be v = a + bu...(2) Then its normal equations are Sv = ma + bSu; Svu = aSu + bSu2 ⇒ 0 = 6.a + 0.b...(3) 122 = 0.a + 70.b...(4) Solving (3) and (4) we get a = 0 and b = 1.743. Substituting these values in (2), the equation of the line is v = 0 + (1.743)u
or
x − 12.5 y − 20 = (1.743) 2.5
or
1.743 × 12.5 1.743 y − 20 = x− 2.5 2.5
[Using (1)]
y − 20 = 0.7 x − 8.715 y = 0.7 x + (20 − 8.715) ⇒ y = 0.7 x + 11.285 ⇒ y = 11.285 + 0.7 x ⇒
Remark
¯¯ If in such a problem, the number of values given is odd then the calculations are simplified
provided we take the common difference as the unit of measurement and the mid-values as the assumed origin.
Example 3. Fit a parabola of the second degree of 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.6
2.7
3.4
4.1
(UPTU(MCA)–2006, VTU–2009, Bhopal–2008)
Fitting of Curves and Cubic Splines
563
Solution.
Here we observe that the number of values given here is 7 which is odd, so we take the middle value 2.5, i.e., 4th value as our assumed mean and let
Let the second degree curve to be fitted is v = a + bu + cu2...(1) Its normal equations are
u=
x − 2.5 0.5
and v = y – 2.7
Σvu = aΣu + bΣu2 + c Σu3 ...(2)
Σvu2 = aΣu2 + bΣu3 + c Σu4 ...(3) Now from the given data, we have the following table: Total u
–3
–2
–1
0
1
2
3
0
v
– 1.6
–1.4
–1.1
– 0.1
0
0.7
1.4
– 14.1
vu
4.8
2.8
1.1
0
0
1.4
4.2
14.3
9
4
1
0
1
4
9
2.8
u
2 2
– 14.4
– 5.6
– 1.1
0
0
2.8
12.6
– 5.7
u
3
–27
–8
–1
0
1
8
27
0
u
4
81
16
1
1
16
81
196
vu
0 2
2
3
4
Substituting the values of Σu, Σv, Σuv, Σvu , Σu , Σu , Σu in (2), (3) and (4), we get –2.1 = 7a + 0.b + 27.c...(5) 14.3 = 0.a + 27b + 0.c...(6) –5.7 = 27a + 0.b + 196c...(7) Solving (5), (6) and (7), we get a = −0.04, b = 0.53, c = 0.03. Substituting these values of a, b and c in (1), we get v = −0.04 + 0.53u + 0.03u2
x − 2.5 x − 2.5 + 0.03 0.5 0.5
⇒ y − 2.7 = − 0.04 + 0.53
2
0.53 x 2.5 × 0.53 x − 2.5 − + 0.03 0.5 0.5 0.5
⇒ y − 2.7 = −0.04 +
⇒ y − 2.7 = −0.04 + 1.06 x − 2.65 + 0.03
⇒
⇒ y = 0.01 + 1.06 x + 0.12 x 2 − 0.60 x + 0.75
⇒ y = 0.76 + 0.46 x + 0.12 x 2
2
x 2 + 6.25 − 5.0 x 0.25
y = − 0.04 + 2.7 − 2.65 + 1.06 x + 0.12( x 2 − 5 x + 6.25)
Example 4. Fit a parabolic curve of regression of y on x to the seven pairs of values x
1.0
1.5
2.0
2.5
3.0
3.5
4.0
y
1.1
1.3
1.6
2
2.7
3.4
4.1
(MDU(B.E.)–2007)
Applied Numerical Analysis
564 x − 2.5 = 2 x − 5 and Y = y 0.5
Solution. Let X =
Then we have the following table x
y
X
Y
X2
XY
X 2Y
X3
X4
1.0
1.1
–3
1.1
9
–3.3
9.9
–27
81
1.5
1.3
–2
1.3
4
–2.6
5.2
–8
16
2.0
1.6
–1
1.6
1
–1.6
1.6
–1
1
2.5
2.0
0
2.0
0
0
0
0
0
3.0
2.7
1
2.7
1
2.7
2.7
1
1
3.5
3.4
2
3.4
4
6.8
6.9
8
16
4.0
4.1
3
4.1
9
12.3
12.3
27
81
0
16.2
28
14.3
69.9
0
196
Total
Let the equation of the parabolic curve be
Y = a + bX + cX 2 ...(1)
The normal equation of (1) are given by ΣYX = aΣX + bΣX 2 + c ΣX 3 ...(2) ΣYX 2 = aΣX 2 + bΣX 3 + c ΣX 4 ΣY = ma + bΣX + c ΣX 2
Putting the values in (2) from the table, we get 16.2 = 7a + 28c; 14.3 = 28b ; 69.9 = 28a + 196c ⇒ a = 2.07, b = 0.511, c = 0.061 Putting the values of a, b and c in (1), we get Y = 2.07 + 0.511 X + 0.061 X 2 ⇒ y = 2.07 + 0.511(2 x − 5) + 0.061(2 x − 5)2 ⇒ y = 1.04 − 0.193 x + 0.243 x 2 Example 5. Fit a second degree parabola to the following data
Solution.
x
1
2
3
4
5
y
1090
1220
1390
1625
1915
y − 1450 Let us define u and v such that u = x − 3, v = 5 and equation of the parabola is v = a + bu + cu2 ...(1)
Therefore, we have the following table : x
y
u
v
u2
u3
v4
uv
u 2v
1
1090
–2
–72
4
–8
16
144
–288
2
1220
–1
–46
1
–1
1
46
–46
3
1390
0
–12
0
0
0
0
0
4
1625
1
35
1
1
1
35
35
5
1915
2
93
4
8
16
186
372
0
–2
10
0
34
411
73
Total
Fitting of Curves and Cubic Splines
565
Then putting the values in the normal equations Σv = ma + bΣu + c Σu2 ; Σuv = aΣu + bΣu2 + c Σu3 ; Σu2 v = aΣu2 + bΣu3 + c Σu4 −2 = 5a + 0 + 10c; 411 = 0 + 10b + 0; 73 = 10a + 0 + 34 c we get Solving these equations for a, b and c we get a = −11.4, b = 41.1, c = 5.5 Put in (1), we get v = −11.4 + 41.1u + 5.5u2 Now changing the origin, we get the fit curve as ⇒
1 ( y − 1450) = −11.4 + 41.1( x − 3) + 5.5( x − 3)2 5 y = 1024 + 40.5 x + 27.5 x 2
Example 6. If P is a 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 following data : P W
12 50
15 70
21 100
25 120
Compute P where W = 150 Kg. (UPTU–2005, 07, VTU–2002) Solution. The given equation is P = mW + c...(1) The normal equations are
ΣP = 4 c + mΣW
ΣWP = c ΣW + mΣW
...(2)
Then, we have
W 50 70 100 120 SW = 340
2
P 12 15 21 25 SP = 73
W2 2500 4900 10000 14400 SW2 = 31800
WP 600 1050 2100 3000 SWP = 6750
Putting these values in (2), we get
73 = 4 c + 340m 6750 = 340c + 31800m
which gives m = 0.1879, c = 2.2785 Hence, the line of best fit is P = 2.2785 + 0.1879W P = 30.4635 Kg Now, for W = 150 Kg
Example 7. The pressure and the volume of a gas are related by the equation pV r = K , r and K being constants. Fit this equation to the following set of observations. P(Kg/cm2) V(litres)
0.5 1.62
1.0 1.00
1.5 0.75
2.0 0.62
2.5 0.52
3.0 0.46
(VTU–2011, Madras–2000)
Solution.
Take log of the given equation, we have log10 p + r log10 V = log10 K
⇒
where
1 1 Y = A + BX r r 1 1 X = log10 p, Y = log10 V , A = log10 K , B = − r r
log10 V = log10 K − log10 P ⇒
Applied Numerical Analysis
566
Now, have the following table: P
V
X
Y
XY
X2
0.5
1.62
–0.3010
0.2095
–0.0630
0.0906
1.0
1.00
0
0
0
0
1.5
0.75
0.1762
–0.1249
–0.0220
0.0310
2.0
0.62
0.3010
–0.2076
–0.0625
0.0906
2.5
0.52
0.3979
–0.2840
–0.1130
0.1583
3.0
0.46 Total
0.4771
–0.3372
–0.1609
0.2276
1.0511
–0.7442
–0.4214
0.5981
Now putting all these values in the normal equations and get the required fitted curve.
Example 8. Fit a second degree parabola to the following data taking as dependent variable.
Solution.
x
1
2
3
4
5
6
7
8
9
y
2
6
7
8
10
11
11
10
9
Let us introduce two new variables X and Y such that X = x − 5, Y = y − 7
Also, let the curve to be fit be Y = a + bX + cX 2 Then, we have the following table. x
y
X
Y
XY
X2
X2Y
X3
X4
1 2 3 4 5 6 7 8 9
2 6 7 8 10 11 11 10 9
–4 –3 –2 –1 0 1 2 3 4 0
–5 –1 0 1 2 4 4 3 2 11
20 3 0 –1 0 4 8 9 8 51
16 9 4 1 0 1 4 9 16 60
–80 –9 0 1 0 4 16 27 32 –9
–64 –27 –8 –1 0 1 8 27 64 0
256 81 16 1 0 1 16 81 256 708
Total
Therefore, the normal equations are 11 = 9a + 0 + 60c 51 = 0 + 60b −9 = 60a + 0 + 708c
Solving these equations for a, b and c, we get a = 3, b = 0.85 and c = –0.27 Hence, the curve of fit is Y = a + bX + cX 2 = 3 + 0.85 X − 0.27 X 2
2 y − 7 = 3 + 0.85( x − 5) − 0.27( x − 5)
⇒
= 3 + 0.85 x − 4.25 − 0.27 x 2 + 2.7 x − 6.75
y = −1 + 3.55 x − 0.27 x 2
⇒
Example 9. Fit a parabola y = ax 2 + bx + c by the method of least square using following data
x y
1 5
2 12
3 26
4 60
5 97
Fitting of Curves and Cubic Splines Solution.
567
The given equation of the parabola is y = ax 2 + bx + c Therefore, the normal equations are aΣx + bΣx + c Σx = Σxy ...(1) aΣx 4 + bΣx 3 + c Σx 2 = Σx 2 y aΣx 2 + bΣx + n.c = Σy 3
2
Here, we have n = 5 Now, we construct the following table. x 1
y 5
x2 1
2
12
3
26
4
60
5
97
Sx = 15
x3 1
x4 1
xy 5
4
8
16
24
48
9
27
81
78
234
16
64
256
240
960
625
485
25
Sy = 200
125
2
3
4
x 2y 5
2425 2
Sx = 225 Sx = 979 Sxy = 832 Sx y = 3672
Sx = 55
Putting all the above values in (1), we obtained 55a + 15b + 5c = 200 225a + 55b + 15c = 832 ...(2) 979a + 225b + 55c = 3672
Solving (2), we get a = 5.7143, b = −11.0858, c = 10.4001 Hence, the required parabola for best fit is y = 5.7143 x 2 − 11.0858 x + 10.4001
Example 10. By the method of least squares, find the curve y = ax + bx 2 that best fits the following data :
Solution.
x
1
y
1.8 th
Let error of estimate for i
2
3
4
5
5.1
8.9
14.1
19.8
point (xi, yi) be
Ei = ( yi − ax i − bx i2 ).
By principle of least
squares the values of a and b are such that 5
5
i =1
i =1
U = ∑ Ei2 = ∑ ( yi − ax i − bx i2 )2 is minimum
Normal equation are given by,
⇒
and
⇒
5
5
5
i =1
i =1
∂U = 0. ∂a
∑ x i yi = a ∑ x i2 + b ∑ x i3 i =1
5
∂U =0 ∂b
5
5
i =1
i =1
2 3 4 ∑ x i yi = a ∑ x i + b ∑ x i
i =1
Delete the suffix i, then normal equations are Σxy = aΣx 2 + bΣx 3 ...(1) Σx 2 y = aΣx 3 + bΣx 4 ...(2) and
Applied Numerical Analysis
568 x
y
x2
x3
x4
xy
x2y
1
1.8
1
1
1
1.8
1.8
2
5.1
4
8
16
10.2
20.4
3
8.9
9
27
81
26.7
80.1
4
14.1
16
64
256
56.4
225.6
5
19.8
625
99
25
125
2
3
49.5
4
2
Sx = 225 Sx = 979 Sxy = 194.1
Sx = 55
Sx y = 822.9
Putting all these values in equation (1) and (2), we get 194.1 = 55a + 225b
822.9 = 225a + 979b and On solving, we get
a=
83.85 317.4 = 1.52, b = = 0.48 55 664
Hence, required parabolic curve is y = 1.52 x + 0.48 x 2.
Example 11. Find a relation of the form y = AB x 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
The curve to be fitted is y = A( B)x . or, Y = a + bx where a = log10 A, b = log10 B and Y = log10 y
Solution.
Therefore, the normal equations are ΣY = 5a + bΣx and ΣxY = aΣx + bΣx 2 x
y
Y = log10y
x2
xY
2
8.3
0.1191
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
Sx = 20
2
SY = 7.5455
Sx = 90
SxY = 33.1812
Therefore, the normal equations becomes 7.5455 = 5a + 20b and 33.1812 = 20a + 90b 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 12. Using the method of least square, fit the non-linear curve of the form y = aebx to the following data :
x
0
2
4
y
5.012
10
31.62
Fitting of Curves and Cubic Splines
569
Solution. The curve of the form y = aebx is to fitted in the form
Y = A + Bx...(1)
Y = log10 y , A = log10 a and where The normal equations for (1) are ΣY = An + BΣx
B = b log10 e.
...(2)
ΣxY = AΣx + BΣx 2 ...(3) and The table is given below : x
y
Y = log10y
xY
x2
0
5.012
0.70001
0
0
2
10
1.00000
2.0000
4
4
31.62
1.49996
5.99984
16
6
46.632
3.19997
7.99984
20
2
n = 3, ΣY = 3.19997, ΣxY = 7.99984, Σx = 20. Here Substituting these values in (2) and (3), we get 3.19997 = 3 A + 6 B ...(4) 7.99984 = 6 A + 20 B ...(5) and Solving (4) and (5), we get A = 0.66667, B = 0.19999,
Since A = log10 a, B = b log10 e = (0.43429)b. Therefore a = 10 , b =
0.43429 i.e., a = 4.64162, b = 0.6050
⇒ a = (10)0.66667 , b =
0.19999 0.43429
Hence, the required curve of the best fit is given by y = 4.64162e0.4605 x
Example 13. Find the curve of the best fit of the type y = aebx to the following data by the method of least square x
1
5
7
9
12
y
10
15
12
15
21
Solution.
The given equation of the curve can be written as Y = A + Bx...(1) Y = log10 y , A = log10 a and B = b log10 e. where The normal equations for (1) are ΣY = An + BΣx ...(2)
ΣxY = AΣx + BΣx 2 ...(3)
and
Y = log10y
xY
x2
x
y
1
10
1
1
1
5
15
1.17609
5.88045
25
7
12
1.07918
7.55426
49
9
15
1.17609
10.58481
81
12
21
1.32222
15.86664
144
Sx = 34
Sy = 73
SY = 5.75358
SxY=40.88616
Sx2 = 300
Applied Numerical Analysis
570
Putting the values from table in (2) and (3), we get 5.75358 = 5 A + 34 B ...(4) 40.88616 = 34 A + 300 B ...(5) On solving (4) and (5), we get A = 0.97658, B = 0.02561
a = 10 A = 100.97658 = 9.47502,
⇒
and
Hence, the required curve of the best fit is
b=
0.02561 = 0.05897 0.43429 y = 9.47502e0.05897 x .
Example 14. Determine the constant 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
(UPTU–2004) bx
y = ae We have Taking log, we get log y = log a + bx
Solution.
Y = A + bx ...(1) i.e., where Y = log y and A = log a
Normal equations of equation (1) are ΣY = An + bΣx ...(2)
ΣxY = AΣx + bΣx 2
and x
y
Y = log y
xY
x2
2
4.077
1.4054
2.8107
4
4
11.084
2.4055
9.6220
16
6
30.128
3.4054
20.4327
36
8
81.897
4.4055
35.2437
64
10
222.62
5.4055
54.0547
100
Sx = 30
...(3)
SY = 17.0272 SxY = 122.1638 Sx2 = 220
Putting all these above values in equations (2) and (3), we get
17.0272 = 5 A + 30b ...(4)
122.1638 = 30 A + 220b ...(5)
From (4) and (5), we get b = 0.5, A = 0.4054 , i.e.,
Taking antilog, we get a = 1.4999 ⇒ a = 1.5 (app.)
A = log a = 0.4054
Fitting of Curves and Cubic Splines
571
Example 15. Fit a curve of the form y = aebx to the following data : x
0
1
2
3
1.05 2.10 3.85 8.30 y (JNTU–2009)
Solution.
The given equation of curve can be written as
Y = A + Bx…(1)
Where
Y = log10y, A = log10a and B = b log10e
The normal equations for (1) are SY = An + bSx…(2)
2 SxY = ASx + bSx …(3)
and x
y
Y = log10y
xy
x2
0
1.05
0.0212
0
0
1
2.10
0.3222
0.3222
1
2
3.85
0.5855
1.1710
4
3
8.30
0.9191
2.7573
9
SY = 1.8480
Sxy = 4.2505
Sx2 = 14
Sx = 6
Putting the values from table in (2) and (3), we get 1.848 = 4A + 6B 4.2505 = 6A + 14B Solving these equations, we get A = 0.0185, B = 0.2956
a = antilog A = 1.0186
Now
b = B/log10e = 0.6806
Hence, the curve of fit is, y = 1.0186e0.6806x.
12.9 curve fitting by sum of exponentials Consider the equation
y = A1e λ1 x + A2e λ 2 x ...(1)
It can be seen that the function given by (1) satisfy a differential equation of the type
d2 y dx
2
= a1
dy + a2 y ...(2) dx
where a1, a2 are constants. Assume that a is the initial value of x we get, by integrating (2) w.r.t. x from a to x. ⇒
y ′( x ) − y ′(a) = a1 y( x ) − a1 y(a) + a2 ∫ax y( x )dx …(3)
y ′( x ) =
dy dx
Applied Numerical Analysis
572 Again integrating (3) w.r.t. x from a to x, we get
y( x ) − y(a) − ( x − a) y ′(a) = a1 ∫ax y( x )dx − a1( x − a) y(a) + a2 ∫ax ∫ax ydxdx ...(4)
Now using the result x x ∫a ... ∫a f ( x )dx =
1 x n −1 f (t )dt ...(5) ∫ ( x − t) (n − 1)! a
The equation (5) can be written as
(By Convolution theorem of integration)
n times
y( x ) − y(a) − ( x − a) y ′(a) = a1 ∫ax ydx − a1( x − a) y(a) + a2 ∫ax ( x − t ) y(t )dt ...(6)
Now, choosing two points x1 and x2 such that a − x1 = x 2 − a, then (6) gives y( x1 ) − y(a) − ( x1 − a) y ′(a) = a1 ∫ax1 y( x )dx − a1( x1 − a) y(a) + a2 ∫ax1 ( x1 − t ) y(t )dt
and
y( x 2 ) − y(a) − ( x 2 − a) y ′(a) = a1 ∫ax 2 y( x )dx − a1( x 2 − a) y(a) + a2 ∫ax 2 ( x 2 − t ) y(t )dt
Adding above two equations and simplifying by using a − x1 = x 2 − a, we get y( x1 ) + y( x 2 ) − 2 y(a) = a1 ∫ax1 y( x )dx + ∫ax 2 y( x )dx + a2 ∫ax1 ( x1 − t ) y(t )dt + ∫ax 2 ( x 2 − t ) y(t )dt ...(7)
Now the equation (7) can be used to setup a linear system of equations for a1 and a2 and then 2 obtain l1 and l2 from the characteristic equation l = a1l + a2. Finally, A1 and A2 can be obtained by the method of least square.
Example. Fit a function of the form y = A1e
λ1 x
+ A2e
λ2 x
to the following data :
x
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
y
1.54
1.67
1.81
1.97
2.15
2.35
2.58
2.83
3.11
(UPTU–2003) Solution. To fit the given curve we use the following steps : Step 1 : Choose x1 and x2 such that a − x1 = x 2 − a ...(1) where a is the initial value of x taken from xi : i = 1, 2, ..., n.
Step 2 : Use
y( x1 ) + y( x 2 ) − 2 y(a) = a1 ∫ax1 y( x )dx + ∫ax 2 y( x )dx x1 x2 + a2 ∫a ( x1 − t ) y(t )dt + ∫a ( x 2 − t ) y(t )dt
...(2)
Step 3 : Repeat the step 1 and 2 by choosing another set of x1, x2 and a such that (2) is true. Therefore, we obtain a linear system of equations for a1 and a2. Solve these equation to get a1 and a2. Step 4 : Substitute the values of a1 and a2, obtained in step 3 in the characteristic equation l2 = a1l + a2…(3) Step 5 : Finally, use the method of least square to obtain A1 and A2 choosing x1 = 1.0, a = 1.2 and x2 = 1.4, we have Now equation (2) gives
1.0 1.4 1.0 1.4 1.54 + 2.15 − 3.62 = a1 ∫1.2 ydx + ∫1.2 ydx + a2 ∫1.2 (1.0 − t ) y(t )dt + ∫1.2 (1.4 − t ) ydt 1.2 1.4 1.2 1.4 ⇒ 0.07 = a1 − ∫1.0 ydx + ∫1.2 ydx + a2 − ∫1.0 (1.0 − t ) ydt + ∫1.2 (1.4 − t ) ydt
Fitting of Curves and Cubic Splines
573
On simplification, we get 1.81a1 + 2.180a2 = 2.10 ...(4) Again choosing x1 = 1.4, a = 1.6 and x2 = 1.8, so that we have a − x1 = 0.2 = x 2 − a and using equation (2), we get 2.88a1 + 3.104 a2 = 3.00 ...(5) Solving (4) and (5), we get a1 = 0.03204, a2 = 0.9364 Put these values in (3), we get λ 2 − 0.03204 λ − 0.9364 = 0 ⇒ l = 0.99, –0.96 Now, using the method of least squares, we get A1 = 0.499, A2 = 0.491
Hence, the required curve for best fit is y = 0.499e0.99 x + 0.491e −0.96 x .
Exercise 12.2 1. Show that the line of fit to the following data : x
6
7
7
8
8
8
9
9
y 5 5 4 5 4 3 4 3 3 (JNTU–2008) is given by y = −0.5 x + 8. 2. Show that the best-fitting linear function for
the points ( x1 , y1 ),( x 2 , y2 )...( x n , yn ) may be expressed in the form
x Σx
y Σy
1 n =0
Σx 2 Σy 2 Σx Show also that the line passes through the mean points ( x , y ). 2 3. Find the parabola of the form a + bx + cx which fit most closely with the observations : x y
–3
–2
–1
0
1
2
3
4.63 2.11 0.67 0.09 0.63 2.15 4.58
(VTU–2006, JNTU–2000S) 4. Fit a second degree parabola to the following data
x
1.0
1.5
2.0
2.5
3.0
3.5
4.0
y
1.1
1.1
1.6
2.0
2.7
3.4
4.1
5. The following table gives the results of the measurement of train resistance; V is the velocity in miles per hour, R is the resistance in pounds per ton.
V
20
40
R
5.5
9.1
60
80
100
data :
10
120
14.9 22.8 33.3 46.0
V
x y
30
40
50
1 0.5
2 2
3 4.5
4 8
5 12.5
8. The voltage V across a capacitor at time t seconds is given by the following table :
t
0
2
4
6
8
V
150
63
28
12
5.6
Use the method of least square to fit a curve of kt the form V = ae to the above data.
(Meerut–2005; UPTU–2001) 9. Applying the method of least squares to fit b the curves y = ax 2 + to the following data : x x
1
2
3
4
y
–1.51
0.99
3.88
7.66
(Meerut–2003; Madras–2003) 10. Use the method of least square to fit the curve m y = kx for the following data :
x
1
2
3
4
5
y
7.1
27.8
62.1
110
161
11. Use the method of least square to fit the straight line for the following data : x
(UPTU–2002)
6. Fit the relation R = a + bV 2 from the following
20
R 8 10 15 21 30 (Indore–2008) b 7. Fit a least square geometric curve y = ax to the following data :
If R is related to V by the relation R = a + bV + cV 2 , fit the curve.
10
71
68
73
69
67
65
y 69 72 70
70
68
67
66
67
68
64
(UPTU–2004)
Applied Numerical Analysis
574
Answers 3. y = 1.243 − 0.004 x + 0.22 x 2 4. y = 1.04 − 0.198 x + 0.244 x 2
5. R = 3.48 − 0.002V + 0.003V 2
6. R = 6.32 + 0.0095V 2
8. a = 146.3, k = −0.412
9. a = 0.51, b = −2.04
7. a = 0.5012, b = 1.9977 10. k = 7.17, m = 1.95
12.10 spline function Sometimes the problem of interpolation can be solved by dividing the entire range of points into subinterval and use low-order polynomials to interpolate each subinterval. Such types of polynomial are called piecewise polynomials. Here, we take these subinterval as the form of [xi, xi + 1] where i varies from 0 to 1. Piecewise polynomials Here, we observe that the piecewise polynomial shown in above figure exhibit discontinuity at some points, which connect these polynomials. Now it is possible to construct piecewise polynomials that prevent such type of discontinuities at the connecting points. Such piecewise polynomials are called Spline functions. Let s(x) denote the spline function of degree m. Then s(x) must satisfying the following conditions : (i) s(x) is a polynomial of degree atmost m in each of the xi xi+1 xi+2 xi–1 subintervals (xi, xi + 1), i = 0, 1, 2, ..., n. (ii) s(x) and its derivatives of order 1, 2, ..., m – 1 are Fig. 4 : Piecewise polynomial interpolation continuous in (x0, xn).
The process of constructing such type of polynomials is called Spline interpolation. Here, we shall discuss only cubic splines. If the second order derivative or piecewise polynomials exist but may not be continuous at the knots. Then it is possible to determine m0, m1, ..., mn in such a way that the resulting piecewise cubic interpolation is twice continuously differentiable. Such type of interpolation is called cubic spline interpolation.
f(xi)
f(xi–1)
xi–1
f(xi–1)
xi
xi+1
f(xi+1)
xi+2
Fig. 5 : Spline polynomial
Definition. A spline function of degree n with knots xi, i = 0, 1, ..., n is a function s(x) with the properties. (i) On each interval [xi – 1, xi], 1 ≤ i ≤ n, s(x) is a polynomial of degree n.
n–1 (x) are continuous on [a, b]. (ii) s(x) and s´(x), s˝(x), ..., s Cubic splines are popular because of their ability to interpolate data with smooth curve. To construct a cubic spline function which would interpolate the points (x0, f0), (x1, f1), ..., (xn, fn). Then the cubic splines s(x) consist of (n – 1) cubic corresponding to (n – 1) subintervals. Let us denote such cubic by si(x), then s(x) = si(x), i = 1, 2, ..., n Then, these cubic must satisfy the following conditions : (1) s(x) must interpolate f at all the points x0, x1, ..., xn, i.e., for each i, s(xi) = fi. (2) The functions values must be equal at all the interior knots, i.e., si(xi) = si + 1(xi).
Fitting of Curves and Cubic Splines
575
(3) The first derivative at the interior knots must be equal. ⇒ s´(x i 1) = s´ i + 1(xi) (4) The second derivative at the interior knots must be equal. ⇒ s˝i(x1) = s˝i + 1(xi) (5) The second derivative at the end points are zero. ⇒ s˝i(x0) = s˝i + 1(xn) = 0
12.10.1 Construction of a Cubic Spline Function Since s(x) is a piecewise cubic polynomials, therefore, s˝(x) is a linear function of x in the interval (xi – 1, xi) and hence, can be written as s′′( x ) =
xi − x ( x − x i −1 ) s′′( x i −1 ) + s′′( x i ) ...(1) x i − x i +1 ( x i − x i −1 )
On integrating (1) twice, with respect to x, we get s( x ) =
( x i − x )3 ( x − x i −1 )3 Pi −1 + Pi + C1 x + C2 ...(2) 6hi 6hi
where Pi = s˝(xi) and C1, C2 are constant to be determined by choosing s(xi – 1) = f(xi – 1) and s(xi) = f(xi). ( f − fi −1 ) 1 C1 = i − ( Pi − Pi −1 )h0 Then, we have
hi 6 ( x i fi −1 − x i −1 fi ) 1 C2 = − ( x i Pi −1 − x i −1 Pi )hi ...(3) hi 6
and
Putting the values of C1 and C2 in (2), we get
( x − x )[( x i − x )2 − hi2 ] ( x − x i −1 )[( x − x i −1 )2 − hi2 ] s( x ) = i Pi −1 + Pi 6hi 6h 1 1 + ( x i − x ) fi −1 + ( x − x i −1 ) fi ...(4) hi hi
s′′( x ) = −
and
( x i − x )2 ( x − x i −1 )2 ( P − Pi −1 )hi fi − fi −1 + Pi −1 + Pi − i 2hi 2hi 6 hi
...(5)
We want that the derivative f´(x) be continuous at x = xi ! e as e → 0. Letting s´(xi – e) = s´(xi + e) as e → 0. We get
hi h h h 1 1 (f − f ) Pi −1 + i Pi + ( fi − fi −1 ) = − i +1 Pi − i +1 Pi +1 + 6 3 3 6 hi hi +1 i +1 i
⇒
hi h + hi +1 h 1 1 ( fi +1 − fi ) − ( fi − fi −1 ) Pi −1 + i Pi + i +1 Pi +1 = 6 3 6 hi +1 hi
i = 1, 2, ..., n – 1
h2 0 2( h1 + h2 ) h 2( h + h ) h 2 2 3 3 : : : : : : 0 0 0 0 0 0
0 0 : : hn − 2 0
...(6)
0 0 P0 P 0 0 1 : : : = : : : : 2( hn − 2 + hn −1 ) hn −1 hn −1 2( hn − 2 + hn ) Pn
M1 M 2 : : : Mn
which is the system of (n – 1) linear equations in (n + 1) unknowns P0, P1, P2, ..., Pn and can also be expressed as where
f − f f − fi −1 M i = 6 i +1 i − i h hi i +1
hi = xi – xi – 1
i = 1, 2, ..., n – 1
Applied Numerical Analysis
576
Remarks
¯¯ If P0 = Pn = 0, then the spline is called the natural splines because the splines are assumed to take their natural straight line shape outside the intervals of approximations.
¯¯ If P0 = Pn, P1 = Pn + 1, f0 = fn, f1 = fn + 1, h1 = hn + 1, then the spline is called periodic splines. ¯¯ For a non-periodic spline we use s´(a) = f´(a) = f´(0) and s´(b) = f´(b) = f´n f 6 f −f 6 fn′ − fn − n −1 ⇒ 2 P0 + P1 = i 0 − f0′ ⇒ Pn −1 + 2 Pn = h1 h1 hn hn ¯¯ For equidistant knots hi = h, (4) and (6) gives 1 1 1 h2 h2 s( x ) = [( x i − x )3 Pi −1 + ( x − x i −1 )3 Pi ] + ( x i − x ) fi −1 − Pi −1 + ( x − x i −1 ) fi − P 6h 2 6 i h h 6 Pi −1 + 4 Pi + Pi +1 = 2 ( fi +1 − 2 fi + 2 fi −1 ) and h
WORKING PROCEDURE tep 1. S Step 2. Step 3. Step 4. Step 5. Step 6. Step 7. Step 8.
Give input data. Obtain step lengths and form the function differences. Obtain the coefficients of the tridiagonal matrix. Compute the RHS (M array) of the system of matrix. Use Gauss elimination method for Pi. Obtained the coefficients of natural cubic splines. Find the spline function at the given point. Print the obtained results.
Example 1. Estimate the function value f at x = 7 using cubic splines from the following data:
i
0
1
2
xi
4
9
16
2
3
4
fi Here, we get
Solution.
Now, we have
h1 = x1 – x0 = 9 – 4 = 5 h2 = x2 – x1 = 16 – 9 = 7 f0 = 2, f1 = 3, f2 = 4 f − f f −f h1 P0 + 2( h1 + h2 )a1 + h2a2 = 6 2 1 − 1 0 h h1 2 1
1
Using P2 = P0 = 0, Thus 2(5 + 7)P1 = 6 − 7 5
Therefore,
P1 =
6 × ( −2) = −0.0143 35 × 24
Now, since n = 3, therefore there are two cubic splines given by s1(x), x0 ≤ x ≤ x1 and s2(x) = x1 ≤ x ≤ x2 Since we want to find the value of f at x = 7 which lie in the domain of si(x), therefore we use only si(x) for estimation
Fitting of Curves and Cubic Splines s1( x ) =
577 P1(u03 − h12u0 ) 1 + ( f1u0 − f0u1 ) 6h1 h1
Now
where
Now substituting all the values, we get s1(7) = −
u0 = x – x0, u1 = x – x1
0.0143 [(7 − 4)3 − 52(7 − 4)] = 2.6229 6×5
Example 2. Obtain the cubic splines approximation for the function given by the following table x
0
1
2
1 2 33 f(x) and P(0) = 0, P(3) = 0. Solution. Here, the points xi are equispaced with h = 1, therefore, we have Pi – 1 + 4Pi + Pi + 1 = 6(fi + 1 – 2fi + fi – 1)
3 244
i = 1, 2
which implies that P0 + 4P1 + P2 = 6(f2 – 2f1 + f0)
P1 + 4P2 + P3 = 6(f3 – 2f2 + f1) Now using P0 = 0, P3 = 0 and the given values of the function we get 4P1 + P2 = 180 P1 + 4P2 = 1080 ⇒ P1 = –24, P2 = 276 Thus, the cubic splines in the corresponding intervals become – 4x3 + 5x + 1 in the interval [0, 1] 50x3 – 162x2 + 167x – 53 in the interval [1, 2] and – 46x3 + 414x2 – 985x + 715 in the interval [2, 3] Example 3. Estimate the value of f(2.5) using cubic spline functions with the following data : i
0
1
2
3
xi
1
2
3
4
0.5 0.3333 0.25 f(xi) Since the points are equally spaced. Here n = 4 ⇒ h1 = h2 = h3 = 1 ⇒ we have three intervals and three cubic splines. Now, we obtained only P0 and P1.
0.20
Solution.
We have
⇒
and
Now
and,
4 1 P0 M1 1 4 P = M 1 2 6 M1 = 2 ( f2 − 2 f1 + f0 ) = 6(0.25 − 2 × 0.3333 + 0.5) = 0.5004 h 6 M2 = 2 ( f3 − 2 f2 + f1 ) = 6(0.2 − 2 × 0.25 + 0.3333) = 0.1998 h M × 4 − M2 × 1 0.5004 × 4 − 0.1998 = = 0.1201 P1 = 1 15 15 M × 4 − M1 × 1 0.1998 × 4 − 0.5004 = = 0.0199 P2 = 2 15 15
Now, we want to find the value of f(x) at x = 2.5 which lies in the domain of s2(x).
P1 P [( x − x 2 ) + ( x − x 2 )3 ] + 2 [( x − x1 )3 − ( x − x1 )] 6 6 +[ f2( x − x1 ) − f1( x − x 2 )]
Now,
s2( x ) =
Applied Numerical Analysis
578
⇒
s2(2.5) =
0.1201 0.0199 [(2.5 − 3) − (2.5 − 3)3 ] + [(2.5 − 2)3 − (2.5 – 2)] 6 6
+ (0.25)(2.5 – 2) – 0.3333(2.5 – 3) = 0.2829
Example 4. Evaluate I = ∫01 Solution.
1 dx , using cubic spline method. 1+ x
Taking n = 2, i.e., h = 0.5, then the tables of values of x and y =
1 is given below 1+ x
x
0
0.5
1
y
1
2/3
1/2
Assuming P0 = P2 = 0, Since we have Pi −1 + 4 Pi + Pi +1 =
6 h2
( yi −1 − 2 yi + yi +1 )
Here n = 2 so we shall take i = 1 only.
∴ P0 + 4 P1 + P2 =
or
6 (0.5)2
( y0 − 2 y1 + y2 )
2 1 4 P1 = 24 1 − 2 + 3 2
or 4P1 = 4 ⇒ P1 = 1 2
h
h3
h3
h
h3
h
Thus, I = ∑ yi −1 − ( Pi −1 + Pi ) = ( y0 + y1 ) − ( P0 + P1 ) + ( y1 + y2 ) − ( P1 + P2 ) 24 2 24 4 i =1 2 2
0.5 2 (0.5)3 0.5 2 1 (0.5)3 (0 + 1) + (1 + 0) 1 + − + − 2 3 24 2 3 21 24 5 1 7 1 17 2 118 = − + − = − = = 0.702380952 . 12 336 24 336 24 336 168
∴
I=
Exercise 12.3 1. Fit the following four points by the cubic splines
i
0
1
2
3
xi
1
2
3
4
yi
1
5
11
8
Use the conditions y0′′ = y3′′ = 0 .
Hence, find (i) y(1.5) (ii) y´(2).
2. Suppose x=
fi = x i−2 and
fi′ = −2 x i−3 , where
1 , i = 1(1)4 are given. Fit these values by 2
the piecewise cubic Hermite polynomials. 3. Show that I = ∫01 sin πxdx = 0.62500000 using
cubic spline method. 4. Find the natural cubic spline which agrees with y(x) of the set of data points
x
2
3
4
y
11
49
123
Hence, compute y(2.5) and y´(2). 5. Find the cubic spline fit for the following data :
x
0
1
2
3
f(x)
1
4
10
8
Using f˝(0) = f˝(3) = 0 and valid in (1, 2). Hence, obtain the estimate f(1.5). 6. Show that the following function is a cubic spline − x − 2 x 3 , −1 ≤ x ≤ 0 f( x) = 2 3 − x + 2 x , 0 ≤ x ≤ 1
− x − 2 x 3 , −1 ≤ x ≤ 0 7. Show that f ( x ) = 2 3 − x + 2 x , 0 ≤ x ≤ 1 is not cubic splines.
Fitting of Curves and Cubic Splines
579
Answers
1 (17 x 3 − 51 x 2 + 94 x − 45); 1 ≤ x ≤ 2 15 103 94 1 ( −55 x 3 − 381 x 2 − 770 x + 53); 2 ≤ x ≤ 3 ; y(1.5) = , y ′(2) = 1. f ( x ) = 15 40 15 1 3 2 15 (38 x − 456 x + 1741 x − 1980); 3 ≤ x ≤ 4 1 −24 x 3 − 68 x 2 − 66 x + 23, ≤ x ≤1 2 3 1 ( −40 x 3 + 188 x 2 − 310 x + 189), 1 ≤ x ≤ 2. f ( x ) = 27 2 3 1 3 2 108 ( −28 x + 184 x − 427 x + 369), 2 ≤ x ≤ 2 213 , y ′(2) = 29 4. For n = 2, y(0.25) = 8 1 5. P1 = 8, P2 = −14, S(x) = ( −11 x 3 + 45 x 2 − 40 x + 118) 3
12.11 Regression Analysis 12.11.1 Scatter or Dot Diagram If we measure the heights and weights of a certain number of students, denote the quantity by x and y and plot them on a graph paper referring to two perpendicular axes. For each student, there shall be one point and thus we get scatter diagram.
Fig. 6 If the origin of axes is taken as ( x , y ) where x and y are the means of the values of x and y
respectively, the points may be scattered all around the region. For points lying in I and III quadrants, the product ( x − x )( y − y ) is positive and for those points which are lying in II and IV quadrants, it is negative.
12.11.2 Regression
Let us suppose that the scatter diagram indicates some relationship between the two variables x and y, the dots of the scatter diagram will be more or less concentrated round a curve. This curve is called the curve regression. The straight line about which the various points may be considered as scattered is called the regression line.
Remark
¯¯ It should be noted that one can predict exactly only if the two variables are perfectly related.
In that case, there is no scatter in the data and the various points lie exactly on the regression line, but when the correlation is less than perfect, i.e., there is a scatter of points on the scatter diagram, then the regression line is only a representation of the general trend.
Applied Numerical Analysis
580
12.11.3 Equation of the Line of Regression Let y = ax + b be the given equation of straight line. The method of least square can be used to fit a straight line to the set of points given on the scatter diagram. Now, transfer the origin to the points ( x , y ) , where x and y are the means of x-series and y-series, respectively. Suppose that x, y be the deviation from the respective means x and y . x = X − x and y = Y − y Therefore, Let Y = aX + b be the equation of the line of best fit of x. Changing the origin to ( x , y ) , we get the form y = ax + b ; where y = Y − y and x = X − x . Let P( x r , yr ) be any dot, then the difference between P and the line is yr − ax r − b Let I denote the sum of the squares of such distances given by I = Σ( y − ax − b)2 for all values of r. Now, using the principle of least squares, choose a and b such that I is minimum. For minima of I, we must have
∂I = − 2Σx ( y − ax − b) = 0 ⇒ Σxy − aΣx 2 − bΣx = 0 ∂a ∂I = − 2Σ( y − ax − b) = 0 ⇒ Σy − aΣx − nb = 0 ∂b
and
Since Σx = 0, Σy = 0 , then we get a=
Σxy Σx
2
=
rσ y σx
rσ ∵ y = σ x
and b = 0
Therefore, the line of fit is y = r
σy σx
Σy 2 n × n Σx 2 Σx 2 Σy 2 Σxy
.x
Now, rechanging the origin, we get Y − y = r
σy σx
( X − x)
This is known as regression line of Y on X. If X is taken to be dependent variable, then the regression line is X − x = r This is called the regression line of X on Y.
σx (Y − y ) σy
12.11.4 Least Square Regression The approach discussed above, is known as least square regression. Here if y = a + bx = f ( x ) is the given equation, then using the principle of least square and principle of maxima and minima, we may find the normal equations, given by Σx i = na + bΣyi and Σx i yi = aΣx i + bΣx i2 Solving the above equations for a and b, we get
a=
Σy i Σx − b i = y − bx and n n
b=
nΣx i yi − Σx i Σyi Σx i2 − ( Σx i )2
where x , y are the means of x-series and y -series respectively.
12.12 PROPERTIES OF REGRESSION COEFFICIENTS Theorem 1. Correlation coefficient is the geometric mean between the regression coefficients.
Fitting of Curves and Cubic Splines Proof.
581
The coefficient of regression are given by
rσ y σx
and
rσ x σy
Geometric mean between these two coefficients is given by rσ y rσ x ⋅ = r 2 = r = coefficient of correlation. σx σ y
Theorem 2. If one of the regression coefficient is greater than unity, then other must be Proof.
less than unity. We know that Two regression coefficients are b yx = r
σy σx
and bxy = r
σx ...(1) σy
1 1. Then
From (1) we obtain
byx∙bxy = r2 [ 1
⇒
bxy ≤
Similarly if bxy > 1 then byx < 1.
1 r or 2 σ2x + σ2y > 2σ x σ y
⇒
σ2x + σ2y − 2σ x σ y > 0
⇒
r
σx
+r
σy
> r
(σ x − σ y )2 > 0 which is always true.
Theorem 4. The regression coefficients are independent of the origin but not of scale. x −a y−b ,v = , where a, b, h and k are constants. h k σy kσ k rσ k b yx = r = r ⋅ v = v = bvu Now, σx σu h σu h
Proof. Let u =
Similarly
bxy =
h b k uv
Hence, byx and bxy are both independent of a and b but not of h and k.
Theorem 5. The correlation coefficient and the two regression coefficients have same Proof.
sign. σy The regression coefficient of y on x = b yx = r
and regression coefficient of x on y = bxy
σx σx =r σy
Since, sx and sy are both positive. Hence, byx, bxy and r having the same sign.
12.13 ANGLE BETWEEN TWO LINES OF REGRESSION If q is the acute angle between two regression lines in the case of two variables x and y, then
Applied Numerical Analysis
582
tan θ =
σ xσ y 1 − r2 . 2 r σ x + σ y2
where, r , σ x , σ y have their usual meaning. Explain the significance of the formula, when r = 0 and r = ±1. Proof. Equations of regression lines are given by y− y=r
σy
(x − x) σx σ x − x = r x ( y − y) σy
and
... (1) ... (2)
Slopes of (1) and (2) are given by m1 = r
\
tan θ = ±
=±
σy σx
and m2 =
m2 − m1 = 1 + m2m1
σy
rσ x σy rσ y − rσ x σx 1+
σ y2 σ x2
σ2 1 − r2 σ y 1 − r2 σ x σ y . . 2 x 2 =± . 2 σx σx + σ y r r σ x + σ y2
Now, since r 2 ≤ 1 and σ x σ y are positive, therefore, positive sign gives the acute angle between the lines. Hence, tan θ = Also, when r = 0 , θ =
1 − r2 σ x σ y . 2 r σ x + σ y2
π . Therefore, two lines of regression are perpendicular to each other. 2
Thus, the estimated value of y is the same for all values of x and vice-versa. When , r = ±1 , tan θ = 0 so that q = 0 or p. Hence, the lines of regression coincide and there is a perfect correlation between two variates x and y.
Example 1. Fit a straight line to the following set of data
Solution.
x
1
2
3
4
5
y
3
4
5
6
8
We have
8 7 6 5
xi
yi
x i2
x i yi
1
3
1
3
2
4
4
8
3
5
9
15
4
6
16
24
5
8
25
40
15
26
55
90
4 3 2 1 0
1
2
3
Fig. 7
4
5
6
Fitting of Curves and Cubic Splines Now, b =
583
nΣx i yi −Σx i Σyi
=
nΣx i2 − ( Σx i )2
Σy n
5 × 90 − 15 × 26 = 1.20 5 × 55 − 15 × 15
Σx i 26 5 = − 1.20 × = 1.60 n 5 5
a= i −b and
Therefore, the linear equation is y = 1.6 + 1.2 x which can be shown in the adjoining figure. Example 2. If the regression coefficients are 0.8 and 0.2, what would be the value of coefficient of correlation. [UPTU(B.Tech. (SUM))–2004]
Solution.
We have r 2 = b yx . bxy = 0.8 × 0.2 = 0.16
Since r , bxy and b yx having same sign as both the regression coefficients b yx and bxy . r = 0.16 = 0.4 Hence, Example 3. Find linear regression from the following data:
x
1
2
3
4
5
6
7
8
y
3
7
10
12
14
17
20
24
Solution. The regression coefficients are given by nΣxy − Σx Σy
b yx =
bxy =
Here, we have the following table x
[UPTU(MCA)–2001]
...(1)
nΣx 2 − ( Σx )2 nΣxy − Σx Σy nΣy 2 − ( Σy )2
...(2)
y
x2
y2
xy
1
3
1
9
3
2
7
4
49
14
3
10
9
100
30
4
12
16
144
48
5
14
25
196
70
6
17
36
289
102
7
20
49
400
140
8
24
64
576
192
36
107
204
1763
599
Also, n = 8 Putting these values from above table in (1) and (2), we get
b yx =
bxy =
and
(8 × 599) − (36 × 107) (8 × 204) − (36)2 (8 × 599) − (36 × 107) (8 × 1763) − (107)2
= 2.7976 = 0.3540 .
Example 4. The regression lines of y on x and x on y are respectively y = ax +b, x = cy+d. Show that
σy σx
=
ad + b a bc + d , x= and y = . c 1 − ac 1 − ac
Applied Numerical Analysis
584 Solution.
The regression line of y on x is given by y = ax +b ∴ byx = a Similarly, bxy = c Now,
b yx = r
and
bxy
Using (3) and (4), we get
σy
σx σx =r σy
2 σy a a σy = = , i.e., σx bxy σ x2 c σ x2 c Since, both the regression lines pass through the point ( x , y ) , therefore
y = ax + b, x = cy + d ax − y = − b ⇒ x − cy = d Multiplying (6) by a and then subtracting from (5), we get (ac − 1) y = − ad − b
b yx
σ y2
... (2) ... (3) ... (4)
⇒
... (5) ... (6)
ad + b 1 − ac bc + d x= . 1 − ac
⇒
=
... (1)
y=
Similarly, we get
Example 5. For two random variables x and y with the same mean, the two regression equations are y = ax + b and x = ay + b.
Show that
b 1−a = . Also, find the common ratio. β 1−α
Solution. We have byx = a, bxy = a If m be the common mean, then regression lines are given by y – m = a(x – m) ⇒ y = ax + m(1 – a)...(1) and x = ay + m(1 – a)...(2) On comparing (1) and (2) with the given equation, we get b = m(1 – a), b = m(1 – a) b 1−a = β 1−α b β m= = 1−a 1−α
Therefore,
Further
Now since regression lines passes through ( x , y )
and ⇒ and
x = αy + β
⇒
m =
y = ax + b will hold m = am + b m = am + b β−b a−α
Example 6. For 10 observations on price (x) and supply (y), the following data were obtained (in appropriate units) :
Σx = 130, Σy = 220, Σx 2 = 2288, Σy 2 = 5506 and Σxy = 3467 Find the two lines of regression and estimate the supply when the price is 16 units.
Fitting of Curves and Cubic Splines
585 Σx Σy = 13, y = = 22 n n
Solution.
We have n = 10, x =
Regression coefficient of y on x is
nΣxy −Σx Σy
b yx =
2
=
(10 × 3467) − (130 × 220)
n Σx − ( Σx ) (10 × 2288) − (130)2 34670 − 28600 6070 = = = 1.015 22880 − 16900 5980
2
Therefore, regression line of y on x is y − y = b yx ( x − x )
⇒ y − 22 = 1.015( x − 13) ⇒ y = 1.015 x + 8.805 Similarly, regression coefficient of x on y is
bxy =
nΣxy − Σx Σy 2
2
=
nΣy − ( Σy ) 6070 = = 0.9114 6600
(10 × 3467) − (130 × 220) (10 × 5506) − (220)2
∴ Regression line of x on y is x − x = bxy ( y − y )
x − 13 = 0.9114 ( y − 22) ⇒ x = 0.9114 y − 7.0508 ⇒ Now, since we are to estimate supply (y) when price (x) is given. Therefore, we are to use regression line of y on x. ∴ When x = 16 y = 1.015(16) + 8.805 = 24.045 Example 7. Find the line of regression of y on x for the following data :
x
1.53
1.78
2.60
2.95
3.42
y
33.50
36.30
40.00
45.80
53.50
We know that regression line of y on x is given by y − y = b yx ( x − x )
where
Here, we have the following table
Solution.
b yx =
nΣxy − Σx Σy n Σx 2 − ( Σx )2
... (1)
... (2)
x
y
x2
xy
1.53
33.50
2.3409
51.255
1.78
36.30
2.1684
64.614
2.60
40.00
6.76
104.00
2.95
45.80
8.7025
135.11
3.42
53.50
11.6964
182.97
12.28
209.1
32.6682
537.949
Also, n = 5.
Then,
b yx =
(5 × 537.949) − (12.28)(209.1) (5 × 32.6682) − (12.28)2
= 9.726
Applied Numerical Analysis
586
Also, Mean,
and
Σx 12.28 = = 2.456 n 5 Σy 20.91 y= = = 41.82 n 5
x=
Putting all these values in (1), we get y − 41.82 = 9.726( x − 2.456) = 9.726 x − 23.887 ⇒ y = 17.932 + 9.726 x which is the required equation of regression. Example 8. The equations of two regression lines, obtained in a correlation analysis of 60 observations are : 5 x = 6 y + 24 and 1000 y = 768 x − 3608 What is the correlation coefficient? Show that the ratio of the coefficients of variability of x to that of y is 5/24. What is the ratio of variances of x and y? Solution. As per given, the regression line of x on y is 5 x = 6 y + 24 6 24 x= y+ ⇒ 5 5 6 bxy = ⇒ 5
... (1)
Also, regression line of y on x is 1000 y = 768 x − 3608
y = 0.768 x − 3.608 ⇒ b yx = 0.768 ⇒ Using (1), we get
r
From (2)
r
... (2)
σx 6 = σy 5 σy σx
... (3)
= 0.768
... (4)
Multiplying (3) and (4), we get r 2 = 0.916 ⇒ r = 0.96 Now, dividing (4) by (3), we get
σ x2
σ y2
=
6 = 1.5625 5 × 0.768
σx 5 = 1.25 = 4 σy
⇒
Now, since the regression line passes through the point ( x , y ) , then
On solving, we get x = 6, y = 1
Also, coefficient of variability of x =
and coefficient of variability of y =
5 x = 6 y + 24 and 1000 y = 768 x − 3608 σx x σy
y σx y y σx 1 5 5 × = × = Hence, required ratio = . = 6 4 24 x x σy σy
... (5) ... (6)
Fitting of Curves and Cubic Splines
587
Example 9. The following data regarding the heights (y) and weights (x) of 100 college
students are given by 2 2 Sx = 1500, Sx = 2272500, Sy = 6800, Sy = 463025 and Sxy = 1022250 Find the equation of regression line of height on weight. Solution. We have Σx 15000 = = 150 n 100 Σy 6800 y= = = 68 n 100
x=
and
Regression coefficients of y and x is given by b yx =
=
nΣxy − Σx Σy nΣx 2 − ( Σx )2 (100 × 1022250) − (15000 × 6800) (100 × 2272500) − (15000)2
= 0.1
Hence, regression line of height (y) on weight (x) is given by y − y = b yx ( x − x ) ⇒ y − 68 = (0.1)( x − 150) ⇒ y = 0.1x – 15 + 68 i.e., y = 0.1x + 53 Example 10. The following table shows the arithmetic mean and standard deviation of the advertising expenditure (x) and sales of company (y) for the year 2001-02.
Statistical measure
Advertising expenditure (x) (in lacs)
Sales (y) (in lacs)
Arithmetic Mean
20
100
Standard deviation
3
12
The coefficient of correlation between x and y is 0.8 (i) Find the equation of two lines of regression. (ii) What would be the expected sales of the company if the advertising expenditure is ` 32 lacs. Solution. We have x = 20, y = 100, σ x = 3, σ y = 12 and r = 0.8
(i) Regression line of y and x is given by
y − y = b yx ( x − x ) = r
σy σx
(x − x)
12 ( x − 20) = 3.2( x − 20) = 3.2 x − 64 3
y − 100 = (0.8)
⇒ y = 3.2 x + 36 Similarly regression line of x on y is given by
σx ( y − y) σy 3 ⇒ x − 20 = (0.8) ( y − 100) = 0.2(y – 100) = 0.2y – 20 12
...(1)
x−x=r
i.e., x = 0.2y (ii) We have to determine expected sales of the company while advertising expenditure is given. So we will use the regression line of y on x.
Applied Numerical Analysis
588
Regression line of y on x is y = 3.2x + 36 when x = 32, y = 3.2(32) + 36 = 102.4 + 36 = 138.4 lacs Example 11. Find the coefficient of correlation when the two regression equations are x = –0.2y + 4.2 and y = –0.8x + 8.4. Solution. Given that x = –0.2y + 4.2 ...(1) y = –0.8x + 8.4 ...(2) Assume that eq. (1) is the regression line of x on y and eq. (2) is the regression line of y on x. Then Regression coefficients of x on y is bxy = –0.2 and Regression coefficient of y on x is byx = –0.8 We know that bxy and byx having the same sign and bxybyx = 0.16(< 1). Therefore, our assumption is correct. 2 Also bxy∙byx = r 2 ⇒ (–0.2)(–0.8) = r 2 ⇒ r = 0.16 ⇒ r = –0.4 ( r, sx and sy have the same sign)
12.14 fitting a polynomial function If a given set of data does not appear to satisfy a linear equation, then we try a suitable polynomial as a regression curve to fit the data. The least squares technique can be used to fit data to a polynomial. Let y = f(x) by a polynomial of degree (m – 1) such that y = a1 + a2 x + a3 x 2 + ... + am x m −1 (with am g 0) ...(1) = f(x) If the data contains n sets of x and y values, then the sum of squares of the errors is given by n
I = ∑ [ yi − f ( x i )]2 ...(2)
i =1
Now, since f(x) is a polynomial and contains coefficients a1, ..., am. Then we want to find all the coefficients. Using the principle of maxima and minima of I, we must have, from (2) ∂I = 0 ⇒ ∂a1 ∂I =0 ⇒ ∂a2
∂I = 0 ⇒ ∂am
∂f ( x i ) =0 ∂a1 i =1 n ∂f ( x i ) −2 ∑ [ yi − f ( x i )] =0 ∂a2 i =1 n
−2 ∑ [ yi − f ( x i )]
n
−2 ∑ [ yi − f ( x i )] i =1
which gives the general term
n ∂f ( x i ) ∂I = −2 ∑ [ yi − f ( x i )] =0 ∂a j ∂a j i =1
∂f ( x i ) = x1j −1 ∂a j
∂f ( x i ) =0 ∂am
Fitting of Curves and Cubic Splines
589
n
Therefore, we have ∑ [ yi − f ( x i )]x ij −1 i =1
n
j −1
∑ [ yi x i
i =1
j = 1,2,..., m.
− x ij −1 f ( x i )] = 0
n
n
i =1
i =1
⇒ ∑ [ x ij −1(a1 + a2 x i + a3 x i2 + ... + am x im −1 )] = ∑ yi x ij −1 [By substituting the values of f(x)] Then, we get the following normal equations : Σyi = na1 + a2Σx i + a3Σx i2 + ... + am Σx im −1 Σx i yi = a1Σx i + a2Σx i2 + a3Σx i3 + ... + am Σx im ...................................................................... ...................................................................... Σyi x im −1 = a1Σx im −1 + a2Σx im + a3Σx im +1 + ... + amΣx i2m − 2 The above set of normal equation can be written as in matrix form as follows : CA = B n Σx i Σx i2 Σx im −1 Σx i Σx i2 Σx i3 Σx im C= m −1 Σx im Σx i2m − 2 Σx i Σy i a1 Σy x a i i 2 A= and B = Σyi x i2 a m −1 m Σyi x i
where
Here, the element of the matrix C is n
C[ j, k] = ∑ x ij + k − 2
Similarly,
i =1
j = 1, 2, ..., m
k = 1, 2, ..., m n
B( j) = ∑ yi x ij −1
j =1
WORKING PROCEDURE Step 1. Read the number of data points n and the order of polynomial mp. Step 2. Take data values. Step 3. Check, If n [ mp then, the regression is not possible. Step 4. Set m = mp + 1. Step 5. Compute the coefficients of C and B matrices. Step 6. Solve for a1, a2, ..., am. Step 7. Write a1, a2, ..., am. Step 8. Estimate the function value at the given value of independent variable.
Example. Fit a second degree polynomial to the following data : x y
1.0 6.0
2.0 11.0
3.0 18.0
4.0 27.0
Applied Numerical Analysis
590 Solution.
Since, we want to fit a second order polynomials therefore the order of polynomial is 2. So, we will have three simultaneous normal equation as given below : a1 x + a2Σx i + a3Σx i2 = Σyi ...(1)
a1Σx i + a2Σx i2 + a3Σx i3 = Σyi x i ...(2)
a1Σx i2 + a2Σx i3 + a3Σx i4 = Σyi x i2 ...(3) Then, we have the following table.
x
y
x2
x3
x4
yx
yx2
1 2 3 4
6 11 18 27
1 4 9 16
1 8 27 64
1 16 81 256
6 22 54 108
6 44 162 432
10
62
30
100
354
190
644
Putting all these values in (1), (2) and (3), we get 4a1 + 10a2 + 30a3 = 62 10a1 + 30a2 + 100a3 = 190 30a1 + 100a2 + 354a3 = 644 Solving (4), (5) and (6) for a1, a2 and a3, we get a1 = 3; a2 = 2; a3 = 1 Hence, the least square quadratic polynomial is 2 y = 3 + 2x + x .
...(4) ...(5) ...(6)
12.15 Non-linear regression 12.15.1 Fitting Transcendental Equations Since the relationship between the dependent and independent variables is not always linear. The non-linear relationship between them may exist in the form of transcendental equations. For example (1), consider the equation for population growth given by kt ...(1) P = p0e where p0 is the initial value of the population P, k is the growth rate and ‘t’ is the time. (2) Consider the equation of gas law relating to the pressure and volume, given by P = avb Let I be sum of the square of the derivation, then we have n
I = ∑ [ pi − avib ]2
i =1
To minimize I, we must have
∂I ∂I = 0 and =0 ∂a ∂b
Σp1vib = aΣ( vib )2
which gives
Σp1vib log vi = aΣ( vib )2 log vi Solve the above equation for a and b. Now, since b appears under the summation sign, use iterative technique to solve for a and b. nΣ log vi log pi − Σ log vi Σ log pi
We get
b=
1 a = antilog Σ log pi − b′Σ log x i n
nΣ(log vi )2 − ( Σ log pi )2
Fitting of Curves and Cubic Splines
591
Example 1. Fit a power function model of the form y = axb using the following data : x
1
2
3
4
5
0.5 2 4.5 8 y Since, given curve is y = axb ⇒ log y = log a + b log x Now, we have the following table :
12.5
Solution.
xi
yi
log xi
log yi
(log xi)2
log(xi) log(yi)
1 2 3 4 5
0.5 2 4.5 8 12.5
0 0.6391 1.0986 1.3863 1.6094
–0.6931 0.6931 1.5041 2.0794 2.5257
0 0.4805 1.2069 1.9218 2.5903
0 0.4804 1.6524 2.8827 4.0649
Total = 10
27.5
4.7874
6.1092
6.1995
9.0804
b=
Therefore,
nΣ log x i log yi − Σ log x i log yi =
nΣ(log x i )2 − ( Σ log x i )2 5 × 9.0804 − 4.7874 × 6.1092
5 × 6.1995 − (4.7874)2 45.402 − 29.2472 = = 1.9998 30.9975 − 22.9192 6.1092 − (1.9998)(4.7847) log a = Also = – 0.6929 5
⇒ a = 0.5001 Hence, the fitted power function equation is given by 1.9998 y = 0.5001x
An Important Discussion If the data seems to fit a curve other than a straight line we can use same transformations to obtain a linear regression. We summarise in the table below some transformation which you can carry out to fit a given set of data of a straight line. S. No.
Form of function
Transformation
bx
1.
Exponential : y = ce
2.
Power : y = cx
3.
Reciprocal : y = a +
4.
Hyperbolic function :
d
b x x c + dx
Form of the linear regression equation
y* = log y
y* = a + bx
y* = log y, x* = log x
y* = a + bx*
x* =
1 x
y = a + bx*
y* =
1 * 1 ,x = y x
y* = a + bx*
Example 2. Given the following data :
x
1
5
3
2
1
1
7
3
y
6
1
0
0
1
2
1
5
(i) Fit a regression line of y on x.
(ii) Fit a regression line of x on y.
Applied Numerical Analysis
592 Solution. x
y
x2
y2
xy
1 5 3 2 1 1 7 3
6 1 0 0 1 2 1 5
1 25 9 4 1 1 49 9
36 1 0 0 1 4 1 25
6 5 0 0 1 2 7 15
23
16
99
68
36
(i) Regression equation of y on x : The regression equation of y on x is given by y = a + bx where the values of a and b are given by the normal equations Sy = na + bSx Sxy = aSx + bSx2 ⇒ 16 = 8a + 23b...(1) 36 = 23a + 99b...(2) Solving (1) and (2) for a and b, we get a = 2.874 b = –0.304 Hence, the regression equation of y on x is y = 2.874 – (0.304)x (ii) Regression equation of x on y is given by x = c + by...(1) when c and b are given by normal equations Sx = nc + bSy Sxy = cSy + bSy2 ⇒ 23 = 8c + 16b...(2) and 36 = 16c + 68b...(3) Now, solving (2) and (3) for b and c, we get c = 3.431 and b = –0.278 Therefore, the required regression equation of x on y is given by x = 3.431 – 0.278y Example 3. Obtain regression line of x on y for the given data : x
Solution.
1
2
5.0 8.1 y Regression line of x on y for the data :
x
1
2
3
4
5
6
10.6
13.1
16.2
20.0
3
4
5
6
13.1
16.2
20.0
5.0 8.1 10.6 y The normal for obtaining ‘a’ and ‘b’ are Sxi = na + bSyi
Σx i yi = aΣyi + bΣyi2
Substituting the value by given table
Fitting of Curves and Cubic Splines
593
x
y
xy
y2
1 2 3 4 5 6 21
5 8.1 10.6 13.1 16.2 20.0 73.0
5 16.2 31.8 52.4 66.0 60.0 231.4
25.00 65.61 112.36 171.61 262.44 400.00 1037.02
Substituting these values in required normal equations, we get 21 = 6a + 73b…(1) 231.4 = 73a + 1037.02b…(2) Now, solving (1) and (2) for a and b we get a = 5.45 and b = –0.161. Therefore, the required regression equation of x and y is given by x = 5.45 – 0.161y.
12.16 simplified determination of regression analysis Since we know that the regression line can be written as : y − y = b yx ( x − x ) ; for regression of y on x
... (1)
x − x = bxy ( y − y ) ; for regression of x on y. and This form leads to the following simplified equations :
b yx
... (2)
Σ( x − x )( y − y ) n = Σ( x − x )2 n
Example 1. A panel of two judges P and Q graded seven dramatic performance by independently awarding marks as follows : Performance Marks by P Marks by Q
1 46 40
2 42 38
3 44 36
4 40 35
5 43 39
6 41 37
7 45 41
The eight performance, which judge Q would not attend, was awarded 37 marks by judge P. If judge Q had been present, how many marks would be expected to have been awarded by him to the eighth performance. Solution. Here, we first calculate the means : 301 = 43 Mean marks by P(x variable) = x =
7 266 = 38 Mean marks by Q(y variable) = y = 7
To calculate byx, we have the following table No.
x
(x − x)
1 2 3 4 5 6 7 Total
46 42 44 40 43 41 45 301
+3 –1 +1 –3 0 –2 +2
( x − x )2 9 1 1 9 0 4 4 28
y
( y − y)
( y − y )( x − x )
40 38 36 35 39 37 41 266
+2 0 –2 –3 +1 –1 +3
+6 0 –2 +9 0 +2 +6 21
Applied Numerical Analysis
594 Now, we have
b yx =
Σ( x − x )( y − y ) Σ( x − x )2
=
21 = 0.75 28
Therefore, the regression line is y − 38 = 0.75( x − 43) y = 0.75 x + 5.75 ⇒ If x = 37, then we have y = (0.75) × (37) + 5.75 = 33.5 ⇒ Judge Q was likely to award 33.5 marks.
12.17 REGRESSION ANALYSIS OF GROUPED DATA The regression analysis of the grouped data will follow the same procedure as above, except the fact that all items falling with in a specified group are approximated as having a value equal to the mid-point value of the group. Since the grouping may be on both variables x and y, the data is usually organized in a two way matrix. The following formula may be used for the value of byx.
b yx
Σfxy − Σfx . Σfy n n n = 2 Σfx 2 Σfx − n n
12.18 MULTIPLE LINEAR REGRESSION If the dependent variable is a function of two or more variables, then we cannot fit the regression line by using our usual methods. For example, the salary of a salesman may be expressed as y = 500 + 5 x1 + 8 x 2 where x1 and x2 are the number of units sold of product 1 and 2 respectively. Now, we shall discuss an approach to fit the experimental data where the variable under consideration is a linear function of two independent variables. Consider a two-variable linear function y = a1 + a2 x + a3 z ... (1) Let I denote the sum of the squares of errors, then I is given by
n
I = ∑ ( yi − a1 − a2 x i − a3 zi ) 2 i =1
... (2)
Differentiating (2) with respect to a1, a2 and a3, we get and
∂I = − 2Σ( yi − a1 − a2 x i − a3 zi ) ∂a1 ∂I = − 2Σ( yi − a1 − a2 x i − a3 zi ) x i ∂a2 ∂I = − 2Σ( yi − a1 − a2 x i − a3 zi ) yi ∂a3
... (3) ... (4) ... (5)
By the principle of maxima and minima of I, we must have
∂I ∂I ∂I = 0, = 0 and =0. ∂a1 ∂a2 ∂a3
Thus, (3), (4) and (5) gives
Σyi x i = a1Σx i + + a3Σx i zi Σyi zi = a1Σzi + a2Σx i zi + a3Σzi2 Σyi = na1 + a2Σx i + a3Σzi
a2Σx i2
... (6)
Fitting of Curves and Cubic Splines
595
The system (6) can also be written in the matrix form as follows :
n Σx i Σzi
Σx i
Σx i2 Σx i z i
Σz i a Σy i 1 Σx i zi a2 = Σyi x i Σyi zi Σzi2 a3
The above equation can be solved using any standard method.
Remarks
¯¯ Since, this is a two-dimensional case, therefore, we obtain a regression plane rather than regression line.
¯¯ This case can be easily extended to the more general case
y = a1 + a2 x1 + a3 x 2 + ... + an +1 x m
Example 1. Obtain a regression plane to fit the data, using the following table
Solution.
x
1
2
3
4
y
0
1
2
3
z
12
18
24
30
Using the above table, we may get x
z
y
x2
z2
xz
yx
yz
1
0
12
1
0
0
12
0
2
1
18
4
1
2
36
18
3
2
24
9
4
6
72
48
4
3
30
16
9
12
120
90
10
6
84
30
14
20
240
156
Now putting all these values in the following normal equation : n Σx i Σzi
Σz i a Σy i 1 Σx i zi a2 = Σyi x i Σyi zi Σx i zi Σzi2 a3 4 a1 + 10a2 + 6a3 = 84 Σx i
Σx i2
We get
6a1 + 20a2 + 14 a3 = 156 Solving these equations for a1 , a2 and a3 , we get
10a1 + 30a2 + 20a3 = 240
a1 = 10, a2 = 2, a3 = 4 Hence, the required regression plane is y = 10 + 2 x + 4 z . Example 2. In a partially destroyed laboratory records of an analysis of correlation
data, the following results only are legible Variance of x is 9. Regression equation: 8 x − 10 y + 66 = 0 and 40 x − 18 y = 214 . Calculate : (a) The mean value of x and y (b) The standard deviation of y
(c) The coefficient of correlation between x and y. (Meerut–2010, 14, UPTU(MCA)–2008, 11, 14)
Applied Numerical Analysis
596 Solution.
We know that two regression lines pass through the point ( x , y ) where x and y are mean of x and y respectively (a) To find x and y , solve the equation
8 x − 10 y + 66 = 0
... (1)
40 x − 18 y − 214 = 0
... (2)
and
Solving (1) and (2), we get x = 13, y = 17 Hence, the values of x and y are respectively 13 and 17.
(b) and (c) The equations of the two regression lines can also be put in the following form y = 0.80 x + 6.60 , x = 0.45 y + 5.35 The regression coefficient of y on x is b yx and is given by
b yx = r
σy σx
= 0.80
... (3)
and the regression coefficient of x on y is bxy and is given by
bxy = r
From (3) and (4), we get
σx = 0.45 σy
... (4)
r 2 = 0.80 × 0.45 = 0.36 ⇒ r = 0.60 ∴ The coefficient of correlation between x and y is 0.60.
Also, since variance (σ x2 ) of x is given as 9. Therefore, S.D. = 3.
Putting these values in (4), we get σ y = 4 .
Exercise 12.4
1. The following table gives the various values of two variables : x
42
44
58
55
89
98
66
y 56 49 53 58 64 76 58 Determine the regression equations which may be associated with these values. 2. Obtain the line of regression of the following data: x
1
2
3
4
5
6
7
y
9
8
10
12
11
13
14
3. Find the regression lines using the following data:Mean height = 50.07, Mean age = 9.98, Standard deviation for height = 5.26, Standard deviation of age = 2.59 and r = 0.898. 4. Find the mean of the variables x and y and the coefficients of correlation, given the following regression equations 2 y − x = 50 , 3 y − 2 x = 10 .
5. Two lines of regression are given by x + 2 y − 5 = 0 and 2 x + 3 y − 8 = 0 and σ x2 = 12 . Calculate the mean value of x and y, variance of y and the coefficient of correlation between x and y. 6. Use multiple linear regression to fit : x1
1
2
3
4
5
x2
4
3
2
1
0
y 18 16 16 12 10 Compute coefficients and the error of estimate. 7. Obtain a regression plane to fit the following data: x1
5
4
3
2
1
x2
3
–2
–1
4
0
y
15
–8
–1
26
8
8. The mean of bivariate frequency distribution are at (3, 4) and r = 0.4 . The line of
Fitting of Curves and Cubic Splines
597
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. 9. The following table gives the results of the measurements of train resistance, V is the velocity in miles per hour, R is the resistance in pounds per ton
V
20
40
R
5.5
9.1
60
80
100
120
14.9 22.8 33.3
46
least square. 10. Fit a second degree parabola to the following data, taking y as dependent variable x
1
2
3
4
5
8
9
y
2
6
7
8
10 11 11 10
9
6
7
11. Find the multiple linear regression of x1 on x2 and x3 using the following data:
If R is related to V by the relation R = a + bV 2
+ cV , find a, b and c by using the method of
x1
4
6
7
9
23
15
x2
15
12
8
6
4
3
x3
30
24
20
14
10
4
Answers 1. y = 0.372 x + 35.27, x = 2.2 y − 65.9 3. y = 0.422 x − 12.15, x = 1.825 y + 31.86
2. Y = 0.929 x + 7.284, X = 0.929Y − 6.219 4. Mean of X =130 , Mean of Y = 90, r = 0.866
5. 1, 2, σ y2 = 6, r = 0.86
8. y = x + 1, x = 0.16 y + 2.36, x = 2.52 2
9. R = 4.35 + 0.00241V + 0.0028705V 10. y = –1 + 3.55x – 0.27x2
M
C
Q
ULTIPLE HOICE UESTIONS (CHOOSE THE MOST APPROPRIATE ONE) 1. If there are m independent linear equation in (d) none of these n unknowns then for the existence of unique 7. Euclidian norm is defined by : solution, we must have: 1/ p 1/2 n n (a) m = n (b) m>n (b) ∑ | x i |2 (a) ∑ | x i |p (c) m < n (d) none of these i =1 i =1 2. For no solution of m linear equation in n n unknowns we must have: (c) ∑ | x i |p (d) none of these (a) m = n (b) m>n i =1 (c) m < n (d) none of these 8. To find the least square approximation, we 3. The general problem of finding equation of always use : approximate curves which fit given set of data (a) Lp-norm (b) Euclidean is called : (c) both (a) and (b) are true (a) data fitting (b) curve fitting (d) none of these (c) both (a) and (b) (d) none of these 9. To compute the values of the function like ex, 4. The difference between the observed values sin x, cos x etc. for large values of the argument and expected values is called : x we use : (a) residue (b) residual (a) least square approximation (c) resistance (d) none of these (b) rational approximation 5. For the line y = a + bx the normal equations (c) polynomial approximation are given by : (d) none of these 2 (a) Sy = ma + bSx + cSx 10. The line of regression can be regarded as (b) Sxy = aSx + bSx2 + cSx3 fitting of (a) linear curves (b) quadratic curve (c) Sx2y = aSx2 + bSx3 + cSx4 (c) cubic curve (d) none of these (d) all are true 11. The principle of least square was first given 6. Norm of x is defined by: by : 1/ p n n p (a) Gauss (b) Newton (a) ∑ | x i |p (b) ∑ | xi | i =1 (c) Legendre (d) none of these i =1 (c) both (a) and (b) are true 12. The normal equations of the parabolic curve
Applied Numerical Analysis
598 y = a + bx + cx2 are given by : (a) Sy = ma + bSx + cSx2 (b) Sxy = aSx + bSx2 + cSx3 2
2
3
(a) all knots (c) exterior knots
4
(c) Sx y = aSx + bSx + cSx (d) all are true 13. The piecewise polynomial that prevent the discontinuities at the connecting points are called : (a) cubic function (b) square function (c) spline function (d) none of these 14. In spline function, the function values must be equal at :
(b) interior knots (d) none of these 15. The second derivation of the cubic of line function at the interior knots must be : (a) zero (b) equal (c) unequal (d) none of these 16. The second derivative of the cubic of spline function at the end points are (a) zero (b) equal (c) non-zero (d) none of these 17. If P0 = Pn = 0 then spline is called: (a) natural splines (b) odd splines (c) even splines (d) none of these
Answers 1. (a) 2. (b) 10. (a) 11. (a)
3. (b) 4. (b) 12. (d) 13. (c)
5. (d) 14. (b)
6. (a) 15. (b)
7. (b) 16. (a)
8. (b) 17. (a)
9. (b)
ARCHIVE x
1. Fit an exponential curve of the form y = ab (Tiruchirapalli–2001) to the following data : x
1
2
3
4
y
1
12 1.8 2.5 3.6 4.7 6.6 9.1 bx
2. Fit the curve y = ae
5
6
7
8
to the following data :
x
0
2
4
y
5.1
10
31.1
x
1989
1990
1991
1992
1993
y
352
356
357
358
360
x
1994
1995
1996
1997
y
361
361
360
359
(UPTU–2001, 09)
4. Find the best possible curve of the form y = a + bx, using method of least squares for the data : x
1
3
4
6
8
9
11
2
3
4
5
y
124
129
140
159
228
1
V
9
10
2
3
4
5
6
7
2.31 2.01 3.80 1.66 1.55 1.47 1.41
x
–1
0
1
2
y 2 5 3 0 (UPTU–2008) 8. Predict the mean radiation dose at an altitude of 3000 feet by fitting an exponential curve to the given data :
y 1 2 4 4 5 7 8 9 (VTU–2011) 5. Fit a second degree parabola to the following data : 1
8
(UPTU(MCA)–2010) 7. Find the least squares fit of the form 2 y = a0 + a1x to the following data :
14
x
7
289 315 302 263 210 y (UPTU–2009) 6. The velocity V of a liquid is known to vary with temperature according to a quadratic 2 law V = a + bT + cT . Find the best values of a, b and c for the following table : T
(Coimbatore–1997) 3. Fit a second degree parabola to the following data :
6
x
Amplitude (x)
50
450
780 1200
Dose of radiation (y)
28
30
32
Amplitude (x) Dose of radiation (y)
36
4400 4800 5300 51
58
69
(SVTU–2007, JNTU–2003)
Fitting of Curves and Cubic Splines
599
9. Fit the curve y = ax + b/x to the following data : x
1
2
3
4
y
5.4
6.3
8.2
10.3
x
5
6
7
8
y 12.6 14.9 17.3 19.5 (UPTU–2010) 10. Predict y at x = 3.75, by fitting a power curve b y = ax to the given data : x y
1
2
3
4
5
6
2.98 4.26 5.21 6.10 6.80 7.50
(JNTU–2003) bx
11. Fit the curve of the form y = ae following data : 77
100
185
239
285
y
2.4
3.4
7.0
11.1
19.6
t
27
45
41
19
3
e
57
64
80
46
62
t
39
19
49
15
31
e
72
52
77
57
68
Fit a straight line to the given data by the (JNTU–2004) method of least square. 2 13. Find the parabola of the form y = a + bx + cx which fits most closely with the observations:
y
–1
0
1
2
3
4.63 2.11 0.67 0.09 0.63 2.15 4.58
(VTU–2009)
14. By the method of least square, fit a parabola 2 of the form y = a + bx + cx , to the following data:
x
2
4
6
8
20
30
40
50
R
8
10
15
21
30
(Indore–2008)
16. Estimate y at x = 2.25 by fitting the in difference curve of the form xy = Ax + B to the following data:
x
1
2
3
4
y
3
1.5
6
7.5
y = axb to the given data:
(VTU–2011S, JNTU–2006) 12. A chemical company, wishing to study the effect of extraction time (t) on the efficiency of an extraction operation (e) obtained the data shown in the following table:
–2
10
(JNTU–2003) 17. Predict y at x = 3.75, by fitting a power curve
–3
V
to the
x
x
15. If V(km/hr) and R(kg/ton) are related by a 2 relation of the type R = a + bV , find by the method of least square a and b with the help of the following table :
10
6.07 12.85 31.47 57.38 91.29 y (JNTU–2008)
x y
1
2
3
4
5
6
2.98 4.26 5.21 6.10 6.80 7.50
(JNTU–2003) bx 18. Fit the exponential curve y = ae to the following data:
x
2
4
6
8
25 38 56 84 y (Madras–2003) 19. By the method of averages, fit a curve of the bx form y = ae to the following data:
x
5
15
20
30
35
40
y
10
14
25
40
50
62
(Madras–2002) 20. Fit a straight line to the following data, using the method of moments:
x
1
3
5
7
9
y
1.5
2.8
4.0
4.7
6.0
(Madras–2001) 21. By using the method of moments fit a parabola to the following data:
x
1
2
3
4
y
0.30
0.64
1.32
5.40
(Madras–2000)
Applied Numerical Analysis
600
Answers 1. y = 0.6823(1.384)x 4. a = 0.545, b = 0.636
2. a = 4.1, b = 0.43
5. y = 18.866 + 66.158 x − 4.333 2
6. V = 2.593 − 0.326T + 0.023T 9. a = 3, b = 2
3. y = −1000106.41 + 1034.29 x − 0.267 x 2
7. y = 4.167 − 1.111 x 2
10. y = 2.978 x
0.5143
;5.8769 2
12. y = 48.9 + 0.5067x
13. y =1.243 – 0.004x+0.22x
15. a = 6.32, b = 0.0095
16. y = 7.187 – 5.16/x; 4.894
18. a = 9.484, b = 0.315 19. a = 1.459, b = 0.062 2 21. y = 0.485 + 0.397x + 0.124x
8. y = 44.9 approx.
11. a = 0.1839, b = 0.0221 14. y = –0.703–0.858x+0.992x2 17. y = 2.978x0.5143, 5.8769 20. y = 1.184 + 0.523x
qqqq
Data Approximation of functions
601
13 Data Approximation of functions 13.1 Introduction The problem of approximation of a function is an important problem in numerical analysis. The commonly used classes of functions are polynomials, trigonometric functions, exponential functions and rational functions. The polynomial functions are most widely used in many applications. When we approximate a function, we choose such approximation for which the maximum components of the error is minimized. The approximation of functions which are commonly used, are the polynomials, trigonometric functions, exponential functions and rational functions. In this chapter we shall discuss all these types of approximations.
13.2 Weirstress Theorem Let a function f(x) is continuous on an interval [a, b], then for a given e > 0, $ a m > 0 and a polynomial P(x) of degree n such that |f(x) – P(x)| < e, " x c [a, b] Let us assume an expression of the form f(x) = P(x, c0, c1, ..., cn) = c0g0(x) + c1g1(x) + ... + cngn(x)...(1) where gi(x), i = 0, 1, 2, ..., n are linearly independent functions and ci, i = 0, 1, 2, ..., n are the parameters, which are to be determined. Here the error of approximation is defined as E(f, c) = yf(x) – [c0g0(x) + c1g1(x) + ... + cngn(x)]y...(2) where y∙y denote the norm of the function. The problem of approximations is to determine ci, i = 0, 1, 2, ..., n, such that this error is as small as possible.
Remarks
¯¯ The functions gi(x) are called coordinate functions and taken as gi(x) = xi, i = 0, 1, 2, ..., n for polynomial approximation.
¯¯ The norm of the function y∙y, is the distance of the different points to the origin. ¯¯ The criterion or a norm which marks the error, smallest is called the best approximations. ¯¯ For the minimization of error norm (2) solve the problem of best approximation.
13.3 norm The Norm can be classified as follows:
13.3.1 For Discrete data Let x = be the sequence of real or complex numbers then we define (i) Lp Norm : as follow 1/ p
n x = ∑ | x i |p i =1
p m 1, which can be written as yxyp.
Applied Numerical Analysis
602 (ii) Eucledian Norm : Take p = 2
1/2
n
i =1
x = ∑ | x i |2
The Eucledian norm is also known as square norm and written as yxy2. (iii) Uniform Norm : Take p = 0 x = max | x j |
1≤ j ≤ n
13.3.2 For Continuous data p
If the function f(x) is continuous on [a, b] and xf(x)x is integrable on [a, b], then (i) Lp Norm
1/ p
f = ∫ab| f ( x )|p dx
,p ≥1.
(ii) Eucledian Norm : Take p = 2 we have the Eucledian norm.
1/2
f = ∫ab| f ( x )|2 dx
.
(iii) Uniform norm : Take p = ∞ We have, the uniform norm
f = max | f ( x )| . a≤ x ≤b
Remark
¯¯ When we used the Eucledian norm, we obtained the least square approximation and when uniform norm is used, we obtained the uniform approximations.
13.4 types of approximations
13.4.1 Least Square Approximations It is the most commonly used approximations for approximating of given function f(x) in tabular form. To find the least square approximation, we always used the Eucledian norm. The approximation, for which the constant ci, i = 0, 1, 2, ..., n are determined in such a way that the aggregate of weight function W(x) with E2, i.e., W(x)E2 is as small as possible, is known as best approximation in the least square sense. Now, for discrete data, we have 2
n n I(c0 , c1...,c n ) = ∑ W( x k ) − ∑ ci gi( x k ) = minimum i=0 k = 0
...(1)
for continuous data, we have
2
n I(c0 , c1...,c n ) = ∫ab W( x ) f ( x ) − ∑ ci gi( x ) dx = minimum...(2) i 0 =
where, I(c0, c1, ..., cn) = sum of the square of the errors or residuals. For polynomial approximation, we choose gi(x) = xi, i = 1, 2, ..., n and W(x) = 1. Now, the necessary conditions for (1) or (2) to have a minimum are that
∂I = 0, j = 0, 1, 2, ..., n ∂c j
which gives a system of (n + 1) linear equations in (n + 1) unknowns c0, c1, ..., cn. These equations are called normal equations. The values of c0, c1, ..., cn can be obtained by solving these normal equations and substituted in the given equation.
Data Approximation of functions
603
Example 1. Obtain a linear polynomial approximations to the function f(x) = x3 on the interval [0,1] using the least square approximations with weight function W(x) = 1. Also find the linear polynomial approximation of the given function through the origin. Solution. Let us consider a linear polynomial approximation P(x) = a0 + a1x...(1) where a0 and a1 are the arbitrary parameters. Now, the sum of the squares of the error is given by I[a0 , a1 ] = ∫01[ x 3 − (a0 + a1 x )]2 dx
= ∫01[ x 6 − 2(a0 x 3 + a1 x 4 ) + a02 + 2a0a1 x + a12 x 2 ]dx
x7 x4 x5 x3 = − 2 a0 ⋅ + a1 + a02 x + a0a1 x 2 + a12 4 5 3 7 0
1
=
a a2 1 a − 2 0 + 1 + a02 + a0a1 + 1 4 7 5 3
For the minima of I(a0, a1), we must have
∂I 1 = 0 ⇒ − + 2a0 + a1 = 0 a = − 1 0 ∂a0 2 5 ⇒ 2 2 9 ∂I = 0 ⇒ − + a0 + a1 = 0 a1 = ∂a1 5 3 10
and
Put these values in (1), the required linear polynomial approximation is 1 9 9 x − 2 x= + 10 5 10 9 Also, the value of I(a0 , a1 ) = 700 P( x ) = −
Now, if we take the linear polynomial approximation through the origin, then P(x) = ax. We have I(a) = sum of the squares of the deviations or errors
= ∫01( x 3 − ax )2dx
x 7 2ax 5 a 2 x 3 = ∫01( x 6 − 2ax 4 + a 2 x 2 )dx = − + 5 3 7 0
1
=
1 2a a 2 − + 7 5 3
For the minima of I, we must have dI =0 da 2 2 − + a=0 5 3 3 a = . 5
⇒
⇒
Hence, the required linear polynomial approximation through the origin is given by P( x ) =
3 x 5
Applied Numerical Analysis
604 and I(a) =
1 2 3 1 9 16 − ⋅ + ⋅ = . 7 5 5 3 25 700
It may be noted that the approximating polynomials P(x) may or may not have common values with f(x).
Example 2. Obtain an approximation in the sense of the principle of least squares in the form of a polynomial of second degree to the function f ( x ) = the range –1 [ x [ 1. Let the required approximation be P(x) = a0 + a1x + a2x2 where a0, a1, a2 are arbitrary parameters. Now, we have I(a0, a1, a2) = sum of the squares of the errors
1 1 + x2
in
Solution.
2
1 = ∫−11 − a0 − a1 x − a2 x 2 dx 1 + x 2
For the minima of I, we must have ∂I =0 ∂a0
⇒
1 1 − a0 − a1 x − a2 x 2 ( −1)dx = 0 ∫−1 2 1 + x2
⇒
∫−11
1 − a0 − a1 x − a2 x 2 dx = 0 1 + x2 1
⇒
2[tan
−1
x ]10
− a0[ x ]1−1
x3 − 2a2 = 0 3 0
π 2 ⇒ − 2a0 − a2 = 0 2 3 ∂I 1 1 = 0 ⇒ ∫−1 2 − a0 − a1 x − a2 x 2 ( − x )dx = 0 Now, 1 + x2 ∂a1
...(1)
1
x3 2a = 0⇒ − 1 = 0 3 3 0
⇒
−2a1
⇒
∂I 1 = 0 ⇒ ∫−11 2 − a0 − a1 x − a2 x 2 ( − x 2 )dx = 0 Now, 1 + x2 ∂a2
⇒
⇒ ∫−11 1 −
⇒ [ x ]1−1 − 2[tan −1 x ]10 − 2a0
⇒
a1 = 0
...(2)
x2
− a0 x 2 − a1 x 3 − a2 x 4 dx = 0 1+ x
∫−11
2
1 1 + x2
− a0 x 2 − a1 x 3 − a2 x 4 dx = 0 1
1
x3 x5 − 2a2 = 0 3 0 5 0
2−
π 2a0 2a2 − − =0 2 3 5
Solving (1), (2), (3) for a0, a1 and a2, we get
...(3)
Data Approximation of functions a0 =
605 3 15 (2π − 5), a1 = 0, a2 = (3 − π ) 4 4
Hence, the required polynomial approximation is given by P( x ) =
3 15 (2π − 5) + (3 − π )x 2 4 4
Example 3. Obtain the least squares polynomials of degree one and two for the function f(x) = x1/2 on [0, 1].
[meerut–2018]
Solution.
Let us first suppose the least square polynomial approximation of degree 1 be P(x) = a0 + a1x where a0, a1 and arbitrary parameters. Now, we have I(a0, a1) = sum of the squares of the deviations or errors = ∫01[ x 1/2 − a0 − a1 x ]2 dx = minimum
For the minima of I, we must have
and
∂I = 0 ⇒ ∫01 2( x1/2 − a0 − a1 x )( −1)dx = 0 ⇒ ∫01( x1/2 − a0 − a1 x )dx = 0 ∂a0 1 2 a x2 2 ⇒ x 3/2 − a0 x − a1 = 0 ⇒ − a0 − 1 = 0 2 3 2 3 0
...(1)
∂I = 0 ⇒ ∫01 2( x1/2 − a0 − a1 x )( − x )dx = 0 ⇒ ∫01( x 3/2 − a0 x − a1 x 2 )dx = 0 ∂a1 1
2 x2 x3 ⇒ x 5/2 − a0 − a1 = 0 2 3 5 0
⇒
2 a0 a1 − − =0 5 2 3
...(2)
Solving (1) and (2) for a0 and a1 we get
a0 =
4 4 and a1 = 15 5
Hence, the required first degree least square approximations for x
1/2
on [0, 1] is
4 4 4 P( x ) = + x = (1 + 3 x ) 15 5 15
Now, we want to find the least square polynomial of approximation of degree 2. Let us define P(x) = a0 +a1x + a2x2 (a polynomial of degree 2) where a0, a1, a2 are arbitrary parameters. Now, we have I[a0, a1, a2] = sum of the squares of the deviation
= ∫01[ x1/2 − a0 − a1 x − a2 x 2 ]2dx = minimum For the minima of I, we must have ∂I = 0 ⇒ ∫01[ x 1/2 − a0 − a1 x − a2 x 2 ]dx = 0 ∂a0
a a 2 − a0 − 1 − 2 = 0 3 2 3 a1 a2 2 = ...(1) ⇒ a0 + + 2 3 3 ∂I = 0 ⇒ ∫01[ x 1/2 − a0 − a1 x − a2 x 2 ]( − x )dx = 0 Also, ∂a1
⇒
Applied Numerical Analysis
606
⇒ ∫01[ x 3/2 − a0 x − a1 x 2 − a2 x 3 ]dx = 0 2 a0 a1 a2 − − − =0 5 2 3 4 a a a 2 ⇒ 0 + 1 + 2 = ...(2) 2 3 4 5 ∂I = 0 ⇒ ∫01 2[ x1/2 − a0 − a1 x − a2 x 2 ]( − x 2 )dx = 0 and ∂a2
⇒
⇒ ∫01[ x 5/2 − a0 x 2 − a1 x 3 − a2 x 4 ]dx = 0 2 a0 a1 a2 − − − =0 7 3 4 5 a a a 2 ⇒ 0 + 1 + 2 = 3 4 3 7
⇒
...(3)
Solving (1), (2) and (3) for a0, a1 and a2 we get a0 =
6 48 20 ,a = , a =− 35 1 35 2 35
Hence, the required second degree least square approximation to x1/2 on (0, 1) is P( x ) =
6 48 20 2 + x− x 35 35 35
13.5 use of orthogonal functions For the large n, the normal equation of the curve becomes ill-conditioned, which gives large amount of error in the parameters a1, a2,..., an. This difficulties can be avoided if the coordinate function g(x) be chosen such that they are orthogonal with respect to the weight function W(x) on an interval (a, b).
13.5. 1 Orthogonal Functions (i) For Discrete Data: A set of real functions {gi(x)} is said to be orthogonal over a set of points x1, x2, ..., xn with respect to the weight function W(x) if m
∑ W( x k )gi( x k )g j ( x k ) = 0, whenever i g j
k =1
(ii) For Continuous Data: A set of real function {gi(x)} is said to be orthogonal on an interval [a, b] with respect to the weight function W(x) if b ∫a W( x )gi( x )g j ( x )dx = 0 , whenever i g j
If the functions gi(x), i = 0, 1, ..., n is orthogonal, then we get m
m
k =1
k =1
2 ∑ W( x i ) f ( x k )gi( x k ) = ∑ aiW( x k )gi ( x k )
m
⇒
ai =
∑ W ( x k )g i ( x k ) f ( x k )
k =1
m
2 ∑ W ( x k )g i ( x k )
, i = 0, 1,2, ..., n
k =1
Similarly, for continuous data, we have b
ai =
∫a W( x k )gi( x k ) f ( x k )dx b
2
∫a W( x k )gi ( x k )dx
, i = 0, 1, 2, ..., n
Data Approximation of functions
607
Remarks
¯¯ The use of orthogonal functions as coordinate functions not only avoids the problem of illconditioning in normal equations but also determines the constant ai, i = 0, 1, ..., n directly.
¯¯ Every set of linearly independent polynomials satisfies the condition of orthogonality. Sometimes it can be orthogonalized by the following methods.
13.6 gram-schmidt orthogonalizing process i
Let us suppose gi(x) = x be the given polynomial of degree i, i = 0, 1, 2, ..., n. Then the polynomial g*i (x) of degree i which are orthogonal over [a, b] with respect to the weight function W(x) can be generated from the recursion relation i −1
gi*( x ) = x i − ∑ air gr*( x ), i = 0, 1, 2, ..., n
where
air =
r =0 b i * ∫a W( x )x gr ( x )dx b *2 ∫a W( x )gr ( x )dx
and g0*(x) = 1.
Example . Using the Gram-Schmidt orthogonalization process, compute the first
Solution.
three orthogonal polynomials P0(x), P1(x), P2(x) which are orthogonal with respect to the weight function W(x) = 1, on [0, 1]. Use these polynomials to obtain the least square approximation of second degree for f(x) = x1/2 on [0, 1]. [meerut-2002, 04; agra-2010, 12; rohilkhand-2007, 09, 11, 14] From the Gram-Schmidt orthogonalization process, we have i −1
gi*( x ) = x i − ∑ air gr*( x ), i = 1, 2, ..., n
r =0
air =
b i * ∫a x gr ( x )dx b *2 ∫a gr ( x )dx
and
g0*(x) = 1
where
which implies g0*(x) = 1 = P0(x) then g*i(x) = x – a10g0*(x)
where
Also,
1
where
a20
a10 =
∫0 xdx 1 ∫0 dx
g1*( x ) = x −
1 2
1 = P1( x ) 2
g*2(x) = x2 – a20g*0(x) – a21g*1(x) 1 2 ∫0 x dx
1 = 1 = and a21 = 3 ∫0 dx
=
1 1 2 ∫0 x x − dx 2
=1 2 1 − dx 2 1 1 * 2 1 g2( x ) = x − − x − = x 2 − x + = P6( x ) . 3 2 6 1 ∫0 x
Using these polynomials, we have the sum of the square of the deviation I[c0 , c1 , c2 ] = ∫01[ x 1/2 − c0 P0( x ) − c1 P1( x ) − c2 P2( x )]2dx = minimum. Now for the minima of I, we must have
∂I = 0 ⇒ ∫01[ x 1/2 − c0 P0( x ) − c1 P1( x ) − c2 P2( x )]2 P0( x )dx = 0 ∂c 0
Applied Numerical Analysis
608
∂I = 0 ⇒ ∫01[ x 1/2 − c0 P0 − c1 P2 ]P1dx = 0 ∂c1
∂I = 0 ⇒ ∫01[ x 1/2 − c0 P0 − c1 P1 − c2 P2 ]P1dx = 0 ∂c 2
Now, using the orthogonality condition, we get
1 1/2
∫0 x
c0 =
1 2 ∫0 P0 ( x )dx
1 1/2
∫0 x
c1 =
and
P0( x )dx
1 2
P1( x )dx
∫0 P1 ( x )dx
=
1 1/2
∫0 x
dx
1 ∫0 dx
=
2 3
1 x − dx 4 2 = =− 1 7 1 2 ∫0 x − x + dx 6 1 1/2
∫0 x
Hence, the required least square approximation is given by 2 4 4 P ( x ) + P1( x ) − P2( x ) 3 0 5 7 2 4 1 4 1 = + x − − x2 − x + 3 5 2 7 6
y = P( x ) =
y=
35
(6 + 48 x − 20 x )
13.7 legendre and chebyshev polynomials In the theory of approximations, there are some orthogonal polynomials such as, Legendre and Chebyshev polynomial which can be used as the coordinate function, while applying the method of least squares.
13.7.1 Legendre Polynomials The Legendre polynomials Pn(x) defined on an interval (–1, 1) are given by ( n /2)
Pn( x ) = ∑ ( −1)r
where
r =0
(2n − 2r )! n
2 r !(n − 2r )!(n − r )!
⋅ x n − 2r
n / 2, if n is even n = (n − 1) 2 2 , if n is odd
Pn(x) is a polynomial in x of degree n and satisfies the Legendre differential equation
(1 − x 2 )
d2 y dx
2
− 2x
dy + n(n + 1) y = 0 dx
The Legendre polynomials satisfies the recurrence relation. (n + 1)Pn + 1(x) = (2n + 1)xPn(x) – nPn – 1(x).
13.7.2 Properties of Legendre Polynomial (i) The polynomials Pn(x) is an even polynomial if n is even and it is an odd polynomial if n is odd. (ii) The Legendre polynomial Pn(x) is an orthogonal polynomials and satisfy
if 0 1 ∫0 Pn( x )Pm( x )dx = 2 2n + 1 if
(iii) Pn(–x) = (–1)nPn(x).
m≠n m=n
Data Approximation of functions
609
13.7.3 Chebyshev Polynomials The Chebyshev polynomial of the first kind of degree n over the interval [–1, 1] is denoted by Tn(x), defined by the relation –1 Tn(x) = cos(n cos x) = cos nq –1 where q = cos x or x = cos q The Chebyshev polynomial Tn(x) satisfy the recurrence relation Tn + 1(x) = 2xTn(x) – Tn – 1(x) with T0(x) = 1, T1(x) = x The differential equation satisfying by the Chebyshew polynomial Tn(x) is
(1 − x 2 )
d2 y dx
2
−x
dy + n2 y = 0 . dx
The Chebyshev polynomial of second kind of degree n over the interval [–1, 1] be defined by –1 Un(x) = sin(n sin x) Therefore, U–n(x) = –Un(x) –1 Also Un(x) = sin nq, where cos x = q i.e., x = cos q
13.7.4 alternative forms of Chebyshev polynomial (i) First kind: We have Tn ( x ) = cos(n cos −1 x ) = cos nθ, where x = cos q 1 1 = (einθ + e − inθ ) = [(cos θ + i sin θ)n + (cos θ − i sin θ)n ] 2 2 1 2 n Tn( x ) = [( x + i 1 − x ) + ( x − i 1 − x 2 )n ] ⇒ 2
(ii) Second kind: We have
U n ( x ) = sin(n cos −1 x ) = sin nθ, where x = cos q 1 1 = (einθ − e − inθ ) = [(cos θ + i sin θ)n − (cos θ − i sin θ)n ] 2i 2i 1 = [( x + i 1 − x 2 )n − ( x − i 1 − x 2 )n ] 2i
13.7.5 Recurrence relations of Tn(x) and Un(x)
1. Tn +1( x ) = 2 xTn ( x ) − Tn −1( x )
Tn( x ) = cos nθ, where x = cos q…(1) P roof. We have, Since, we have cos(n + 1)θ + cos(n − 1)θ = 2cos nθ cos θ …(2) Using (1) and (2) we get Tn +1( x ) + Tn −1( x ) = 2 xTn( x ) ⇒ Tn +1( x ) = 2 xTn( x ) − Tn −1( x )
2. (1 − x 2 )Tn′ ( x ) = −nxTn ( x ) + nTn −1( x ) Tn( x ) = cos nθ, where x = cos q Proof. We have, ⇒ Therefore,
dθ dx 1 n sin nθ = − n sin nθ − = sin θ sin θ
Tn′ ( x ) = − n sin nθ
(1 − x 2 )Tn′ ( x ) = (1 − x 2 )
n sin nθ sin θ
Applied Numerical Analysis
610
n sin n = n sin θ sin nθ [ x = cos q] sin = n sin θ sin nθ + n cos θ cos nθ − n cos θ cos nθ = n cos(n − 1)θ − n cos θ cos nθ = nTn ( x ) − nxTn( x ) = (1 − cos θ)
(1 − x 2 )Tn′ ( x ) = − nxTn( x ) + nTn −1( x ) Hence, 3. U n +1( x ) = 2 xU n ( x ) − U n −1( x ) P roof. We have by definition U n( x ) = sin(n cos −1 x ) = sin nθ …(1) where x = cos q We know that sin(n + 1)θ + sin(n − 1)θ = 2sin nθ cos θ …(2) Using (1) and (2) we get U n +1( x ) + U n −1( x ) = 2 xU n( x ) U n +1( x ) = 2 xU n( x ) − U n −1( x ) ⇒
4. (1 − x 2 )U n′ ( x ) = −nxU n ( x ) + nU n −1( x )
Proof. We have
U n( x ) = sin(n cos −1 x )
⇒
n U n′ ( x ) = cos(n cos −1 x ) ⋅ − 1 − x2 (1 − x 2 )U n′ = − n 1 − x 2 cos(n cos −1 x )
⇒
= = = =
− n 1 − cos2 θ ⋅ cos nθ ( x = cos q) − n sin θ cos nθ − n sin θ cos nθ + n cos θ sin nθ − n cos θ sin nθ − n cos θ sin nθ + n sin(n − 1)θ = − nxU n( x ) + nU n −1( x )
(1 − x 2 )U n′ ( x ) = − nxU n( x ) + nU n −1( x )
Hence,
Some Chebyshev’s polynomials are: T0 ( x ) = 1,T1( x ) = x ,T2 ( x ) = 2x 2 − 1,T3 ( x ) = 4 x 3 − 3 x ,T4 ( x ) = 8 x 4 − 8 x 2 + 1,T5 ( x ) = 16 x 5 − 20 x 3 + 5 x T6 ( x ) = 32x 6 − 48 x 4 + 18 x 2 − 1
Remark
¯¯ The powers of x in terms of Chebyshev’s polynomial can be written as follows:
1 1 1 = T0( x ), x = T1( x ), x 2 = [T0( x ) + T1( x )], x 3 = [3T1( x ) + T3( x )], 2 4 1 1 4 5 x = [3T0( x ) + 4T2( x ) + T4 ( x )], x = [10T1( x ) + 5T3( x ) + T5( x )] 8 16 1 6 [10T0( x ) + 15T2( x ) + 6T4 ( x ) + T6( x )] x = 32
13.7.6 Orhtogonal properties of chebyshev polynomial (i) ∫−11
Proof.
Tm ( x )Tn ( x ) 1 − x2
m≠n 0; dx = π / 2; m = n ≠ 0 m=n=0 π;
(ii) ∫−11
U m ( x )U n ( x ) 1 − x2
m≠n 0; dx = π / 2; m = n ≠ 0 m=n=0 0;
(i) We have Tm(x) = cos mq, Tn(x) = cos nq where x = cos q, then
Data Approximation of functions
611
If m g n 1
∫−1
Tm( x )Tn( x ) 1− x
2
dx = ∫π0
cos mθ cos nθ ( − sin θdθ) sin θ
= − ∫π0 cos mθ cos nθdθ = =
1 π ∫ [cos(m + n)θ + cos(m − n)θ]dθ 2 0 π
1 sin(m + n)θ sin(m − n)θ 1 + = × 0, = 0 2 m + n m − n 0 2
If m = n g 0, then T ( x )T ( x )
1 m n dx = ∫0π cos2 nθdθ = ∫−1
1 − x2
If m = n = 0, then ∫−11
π
1 π 1 sin 2nθ π = ∫0 (1 + cos 2nθ)dθ = θ + 2 2 2n 0 2
Tm( x )Tn( x ) 1− x
2
dx = ∫0π cos2 0dθ = ∫0π dθ = π
(ii) We have Un(x) = sin nq, Um(x) = sin mq where x = cos q, then If m g n 1
∫−1
U m( x )U n( x ) 1− x
2
dx = ∫π0
sin mθ sin nθ ( − sin θdθ) sin θ
= − ∫π0 sin mθ sin nθdθ = =
1 π ∫ [cos(m − n)θ − cos(m + n)θ]dθ 2 0 π
1 sin(m − n)θ sin(m + n)θ 1 − = ×0= 0 2 m − n m + n 0 2
If m = n g 0, then U ( x )U ( x )
1 m n dx = ∫0π sin 2 nθdθ = ∫−1
1 − x2
If m = n = 0, then ∫−11
U m( x )U n( x ) 1 − x2
π
1 π 1 sin 2nθ π = ∫ (1 − cos 2nθ)dθ = θ + 2 0 2 2n 0 2 dx = ∫0π sin 2 0dθ = ∫0π 0dθ = 0
13.7.7 more Properties of Chebyshev Polynomial (i) Tn(x) is a polynomial of degree n. (ii) Tn(x) is even function of x if n is even and it is an odd function of x if n is odd. (iii) Tn(x) has n simple zeroes. (iv) Tn(x) assumes extreme values at (n + 1) points kπ x k = cos , k = 0, 1, 2, ..., n n
k and the extreme value at xk is (–1) . (v) |Tn(x)| [ 1, " x c [–1, 1] (vi) Tn(x) are orthogonal on the interval [–1, –1] with respect to the weight function
W( x ) =
1
1 − x2
0 π (vii) ∫01 Tm( x )Tn( x )cos θ = 2 π
if
m≠n
if
m=n≠0
if
m=n=0
Applied Numerical Analysis
612 (viii) If Pn(x) is a monic polynomial of degree n and Tn( x ) =
Tn( x ) 2n −1
is monic Chebyshev polynomial,
then max | Tn( x )|≤ max | Pn( x )| . −1≤ x ≤1
−1≤ x ≤1
This important property of Chebyshev polynomial is known as minimax property and can be stated as follows. “If all monic polynomial Pn(x) of degree n, the polynomial 21 – nTn(x) has the least upper bound (Supremum) for its absolute value in the range |x| [ 1, i.e., –1 [ x [ 1. Since |Tn(x)| [ 1, the upper bound 1–n ”. referred to above is 2
13.8 Uniform Approximation In uniform approximation, we use the uniform norm to continuous function over a close interval. Here, it should be noted that Weierstrass approximation theorem provide the possibility of uniform approximation. This theorem uses the Bernstein polynomial, as given below n k n Bn[ f , x ] = ∑ f x k (1 − x )n − k k=0 n k
...(1)
defined on [0, 1]. It has been shown that lim Bn[ f , x ] = f ( x ) , uniformly continuous on [0, 1]. n→∞
Remark
¯¯ When we use Bernstein polynomial, then the convergence of the approximation is very slow. Chebyshev polynomials are the best known polynomials which give a good rapid uniform approximation to a continuous function f(x).
13.8.1 Uniform Polynomial Approximation
Consider a continuous function f(x) defined on a closed interval [a, b], which is to be approximated n by the polynomials Pn(x) = a0 + a1x + ... + anx where a0, a1, ..., an are constants. In uniform polynomial approximation (also known as minimax approx.) we want to find the constant a0, a1, ..., an is such a way that the error En(f, a0, a1, ..., an) = f(x) – Pn(x) satisfy the minimax principle. max | En( f , a0 , a1 ,..., an )|= min | En( f , a0 , a1 ,..., an )|. a≤ x ≤b
a≤ x ≤b
If n = 0, then we want to approximate the function f(x) by a constant a0, let M = max | f ( x )| and m = min | f ( x )| . a≤ x ≤b
a≤ x ≤b
Now, by minimax principle, we require ⇒
max | f ( x ) − a0 | = min | f ( x ) − a0 |
a≤ x ≤b
a≤ x ≤b
M – a0 = –(m – a0) = – m + a0 1 2
⇒ a0 = (m + M ) 1 2
1 2
⇒ E0[ f , c0 ] = M − [ M + m] = ( M − m) The graph of the constant minimax approximation is given as follows : Now, we find from figure, that when the error curve. e(x) = f(x) – a0 is drawn, the value !E0(f, c0) is assumed at least twice, once with plus sign and once with minus sign, but always of equal value. If n = 1. Here, we want to approximate the
1
Data Approximation of functions
613
function f(x) by a first degree polynomial P1(x) = a0 + a1x The parameter a0 and a1 are to be so determined that the error E1(f, c0, c1) = f(x) – P1(x) satisfies the minimax principle max | E1( f , c0 , c1 )|= min | E1( f , c0 , c1 )| . a≤ x ≤b
a≤ x ≤b
Set e(x) = f(x) – c0 – c1x ⇒ e´(x) = f´(x) – c1. Now take three points x1, x2, x3, a [ x1 < x2 < x3 [ b such that e(xi) = !E1, i = 1, 2, 3, ... and the error must be alternate in signs at these points. Now, assume that x1 = a, x3 = b and x2 is some interior point in the open interval (a, b) i.e., a < x2 < b ⇒ e´(x2) = 0 ⇒ f´(x2) – c1 = 0 Therefore, we get the equation f(a) – (a0 + a1a) = –[f(x2) – (a0 + a1x2)] f(x2) – (a0 + a1x2) = –[f(b) – (a0 + a1b) and f´(x2) – a1 = 0 These equations give the values of a0, a1 and x1. Then the graph of the linear minimax approximation is
2
13.9 Chebyshev polynomial approximations n
Let f(x) be a continuous function defined on an interval (–1, 1) and let a0 + a1x + ... + anx be the required minimax polynomial approximation for f(x). c
∞
Let us suppose f ( x ) = 0 + ∑ ciTi( x ) , is the Chebyshev series expansion for f(x). Then, the series 2 i =1 of the partial sum is n c Pn( x ) = 0 + ∑ ciTi( x ) ...(1) 2
i =1
is very nearly the solution to the problem
n
n
max f ( x ) − ∑ ai x i = max f ( x ) − ∑ ai x i
−1≤ x ≤1
i=0
−1≤ x ≤1
i=0
⇒ the partial sum (1) is nearly the best uniform approximation to f(x). Because
f( x) =
c0 + c1T1( x ) + c2T2( x ) + ... + cnTn( x ) + cn +1Tn +1( x ) + Remainder...(2) 2
Now, neglecting the remainder term, we get
n c f ( x ) − 0 + ∑ ciTi( x ) = cn +1Tn +1( x ) ...(3) 2 i =1
Now since Tn + 1(x) has (n + 2) equal maxima and minima which is alternate in sign. Therefore the polynomial (1) of degree n is the best uniform approximation to f(x).
Applied Numerical Analysis
614
WORKING PROCEDURE To determine the best uniform approximation to a given continuous function defined on (–1, 1), we find it easy to start with the truncated Chebyshev expansion of the function and then improve. The polynomial (1) is called the minimax polynomial. By this process we can obtain the best lower order approximation, called the minimax approximation to a given polynomial.
13.9.1 Chebyshev Equioscillation Theorem Let f(x) be a continuous function on a closed interval (a, b) and let Pn(x) be the best uniform approximation according to the minimax principle max | f ( x ) − Pn( x )|= min | f ( x ) − Pn( x )| a≤ x ≤b
a≤ x ≤b
If we set En[ f , x ] = max | f ( x ) − Pn( x )| and e(x) = f(x) – Pn(x). a≤ x ≤b
Then, there are at least (n + 2) points a = x0 < x1 < x2 < ... < xn < xn + 1 = b where (i) e(xi) = !En, i = 0, 1, 2, ..., n + 1 and (ii) e(xi) = – e(xi + 1), i = 0, 1, 2, ..., n. Here, the condition (ii) implies, e´(xi) = 0, i = 0, 1, 2, ..., n.
Remark
¯¯ The best approximation is completely and uniquely determined under the above condition (i) and (ii).
13.10 lanczos economization of power series for a general function Let the given function f(x) can be expressed as power series in x such that
∞
f ( x ) = ∑ ai x i , − 1 ≤ x ≤ 1 ...(1) i =1
Here, we can change each power of x in (1) in the terms of Chebyshev polynomial and we get
∞
f ( x ) = ∑ ciTi( x ) ...(2) i =1
as the Chebyshev series expansion for f(x) on [–1, 1]. Here, it should be noted that for a large number of functions f(x), the series (2) converges more rapidly than the power series given by (1). The partial sum of (2) is ∞ P( x ) = ∑ ciTi( x ) ...(3) i =1
which is a good approximation to f(x) in the sense max | f ( x ) − Pn( x )| ≤ |cn +1| + |cn + 2| +... ≤ ε (say) .
−1≤ x ≤1
It for a given e, it is possible to find the number of terms that should be retained in (3), then this process is known as Lanczos economization.
Remark
¯¯ To find the economized polynomial approximation for f(x), replace each Ti(x) in (3) by its polynomial form and then rearranging the term.
13.11 rational approximation Since, the polynomial approximation is not always the best approximation. When the function behaves as a quotient of two polynomials, known as rational function, rational approximation can be used. A rational approximation for a function f(x) is written in the form
Data Approximation of functions
615 n
f ( x ) ≈ Rn,m( x ) =
a0 + a1 x + ... + an x n
b0 + b1 x + ... + bm x m
i ∑ ai x
i=0 m
=
j ∑ bj x
...(1)
j=0
The suffixes n, m in Rn,m(x) indicates that the numerator and denominator of the rational function (1) are polynomials of degree n and m respectively. Without any loss of generality we may take b0 = 1, because we can always divide the numerator and the denominator in (1) by b0. The constant b0 will not be zero, otherwise the function is not defined. Now, using the Maclaurin series expansion for f(x) given by ∞
f ( x ) = ∑ c j x j , in which cj ’s are known constant,
j =1
n
we get from (1)
∞
f ( x ) − Rn,m( x ) = ∑ c j x j − j=0
i ∑ ai x
j=0 m
j ∑ bj x
=
m n ∞ j j j ∑ c j x ∑ bj x − ∑ a j x j=0 j=0 j=0
j=0
m
j ∑ bj x
...(2)
j=0
Here, we determined (n + m + 1) constants ai, bi by equating the coefficient of x j, j = 0, 1, 2, ..., (m + n) in the numerator of (1) to zero. The first non-zero term in the numerator of (2) gives the order of approximation. If we take m = 0, then we simply obtain Maclaurin’s series expansion of f(x), otherwise we get an approximation of order M = n + m +1.
13.12 approximation with trigonometric functions We know that all trigonometric functions has orthogonal properties. These functions are periodic also. The use of trigonometric functions in approximations is of great importance. A trigonometric sum with a given data at (2l + 1) arguments may be given in the following form. y( x ) =
l 1 2πjx 2πjx a + ∑ a cos + b j sin 2l + 1 2l + 1 2 0 j =1 j
where the coefficients aj and bj are known and can be found by using the following orthogonal properties: n
2πkx
2πjx
0,
k ≠ j or k = j = 0
sin = n + 1 (i) ∑ sin n + 1 n + 1 , x =0 2 n
2πkx
k≠ j≠0
2πjx
=0 cos (ii) ∑ sin n + 1 n + 1 x =0 k≠ j 0, 2πkx 2πjx n + 1 cos = , k= j≠0 (iii) ∑ cos n + 1 n + 1 2 x =0 n + 1 k = j = 0 n
Example 1. Determine the least square approximation of the type ax2 + bx + c, to the Solution.
function 2x at the points xi = 0, 1, 2, 3, 4. Here, we want to determine a, b, c such that
4
I(a, b, c ) = ∑ [2 x i − ax i2 − bx i − c]2 is maximum. i=0
...(1)
Applied Numerical Analysis
616
The normal equation of (1) are given by
4 4 4 4 x 2 4 3 2 ∑ 2 i ⋅ x i − a ∑ x i − b ∑ x i − c ∑ x i = 0 i=0 i=0 i=0 i=0 4 4 4 4 xi 3 2 ∑ 2 x i − a ∑ x i − b ∑ x i − c ∑ x i = 0 ...(2) i=0 i=0 i=0 i=0 4 4 4 xi 2 and ∑ 2 − a ∑ x i − b ∑ x i − 5c = 0 i=0 i=0 i=0
Now, we have the following table
Total
x
2x
x2
x3
x4
x∙2x
x2∙2x
0 1 2 3 4
1 2 4 8 16
0 1 4 9 16
0 1 8 27 64
0 1 16 81 256
0 2 8 24 64
0 2 16 72 256
10
31
30
100
354
98
346
Substituting all the values from table in (2), we get 354 a + 100b + 30c = 346 100a + 30b + 10c = 98 ...(3) 3a + 10b + 5c = 31
Now, after solving (3) for a, b, c, we get a = 1.143, b = – 0.971, c = 1.286 x Hence, the required least squares approximation to 2 is 2 y = 1.143x – 0.971x + 1.286 Example 2. The following measurements of a function f were made x
–2
–1
0
1
3
f(x)
7.0
4.8
2.3
2
13.8
Fit a third degree polynomial P3(x) to the data by the least squares method. As the value for x = 1 is known to be exact and f´(1) = 1. Also, we have P3(1) = 2 and P´3(1) = 1. Solution. Let us take the polynomial of 3rd degree P3(x) = a0 + a1(x – 1) + a2(x – 1)2 + a3(x – 1)3…(1) since we have P3(1) = 2 and P´3(1) = 1. ⇒ a0 = 2, a1 = 1 Therefore, by the method of least squares approximation, we want to find a1, a2 such that, the sum of the squares of deviation 5
I(a2 , P3 ) = ∑ [ f ( x i ) − 2 − ( x i − 1) − a2( x i − 1)2 − a3( x i − 1)3 ]2 is minimum
i =1
...(2)
Then, the required normal equations are 5
5
i =1
i =1 5
5
2 3 ∑ ( x i − 1) f ( x i ) − 2 ∑ ( x i − 1) − ∑ ( x i − 1)
i =1
5
4
− a2 ∑ ( x i − 1) − a3 ∑ ( x i − 1)5 = 0
...(3)
5
i =1 5
i =1
5
5
6
i =1
i =1
i =1
i =1
i =1
and ∑ ( x i − 1)2 f ( x i ) − 2 ∑ ( x i − 1)3 − ∑ ( x i − 1)4 − a2 ∑ ( x i − 1)5 − a3 ∑ ( x i − 1)6 = 0 …(4)
Data Approximation of functions
617
Now, using the given data in (3) and (4), we get
−114 a2 + 244 a2 = −131.7 244 a2 − 858a3 = 177.3
and
...(5)
Now solving (5) for a2, a3, we get a2 = 1.8220, a3 = 0.3115
Hence, the required least square approximation is
2 3 P3(x) = 2 + (x – 1) + 1.822(x – 1) + 0.3115(x – 1) Example 3. Using the Chebyshev polynomials, obtain the least square approximation 4 of second degree for f(x) = x on [–1, 1]. Solution. Defined the Chebyshev polynomial P(x) as f(x) = P(x) = c0T0(x) + c1T1(x) + c2T2(x)...(1) Then, the sum of the square of the deviation
I(c0 , c1 , c2 ) = ∫−11
1 1− x
2
[ x 4 − c0T0 − c1T1 − c2T2 ]2 dx
which is to be minimum. Then, the normal equations are given by T0 ∂I dx = 0 = 0 ⇒ ∫−11[ x 4 − c0T0 − c1T1 − c2T2 ] ∂c 0 (1 − x 2 ) T1 ∂I dx = 0 ...(2) = 0 ⇒ ∫−11[ x 4 − c0T0 − c1T1 − c2T2 ] 2 ∂c1 x (1 − ) T2 ∂I 1 4 dx = 0 = 0 ⇒ ∫−1[ x − c0T0 − c1T1 − c2T2 ] ∂c 2 (1 − x 2 )
and
From (2), we obtained
c0 =
1 1 x 4T0 3 dx = ∫ 8 π −1 1 − x 2
2 1 x 4T1 dx = 0 ∫ π −1 1 − x 2 x 4T2 2 1 c3 = ∫−11 dx = and 2 2 π 1− x
c1 =
Hence, the required approximation is given by
f( x) =
3 1 T + T 8 0 2 2
Example 4. Determine as accurately as possible a straight line y = ax + b approximating 1 x2
Solution.
in the Chebyshev sense on the interval [1, 2]. What is the maximum
error? Calculate a and b to two correct decimals. The error of approximation E is given by
E( x ) =
1 x2
− ax − b = ε( x ) (say)...(1)
Let us choose the points 1, a, 2 and applying Chebyshev equioscillation theorem, we get e(1) = –e(a) ⇒ e(1) + e(a) = 0 ...(2) e(a) = –e(2) ⇒ e(2) + e(a) = 0 ...(3)
Applied Numerical Analysis
618
ε´( x ) = −
2 x3
− a …(4)
Now from (2), (3) and (4), we get − aα − b = 0 α 1 1 − 2a − b + 2 − aα − b = 0 ...(5) 4 α 2 + a = 0 3 α 1−a −b+
and
1
2
Solving (5) for a, b and a, we get
3 8 a = − , b = 1.66, α 3 = 4 3
Hence, the required approximating straight line is y = 0.75x +1.66 The maximum error in magnitude = |e(1)| = |1 – a – b| ≈ 0.1 Example 5. Determine the values of a, b, c and d in the polynomial 3 2 p(x) = ax + bx + cx + d which minimize max | p( x )− | x || . −1≤ x ≤1
Here, we want to find a, b, c and d such that max p( x ) − x is minimum.
Solution.
−1≤ x ≤1
The error of approximation e is given by e(x) = ax3 + bx2 + cx + d – |x| Take the points x0 = –1, x1 = –a, x2 = 0, x3 = a, x4 = 1 and using Chebyshev equioscillation theorem, we get e(–1) + e(–a) = 0 e(–a) + e(0) = 0 e(0) + e(a) = 0 e(a) + e(1) = 0 and e´(–a) = 0 = e´(0) = e´(a).
1 α 1 , d = , c = 0, a = 0 and α = . 2α 4 2 1 Hence, the values of a, b, c and d is given by a = 0, b = 1, c = 0, d = and the 8 1 approximation is x 2 + . 8
The solution of the system of equation is b =
Example 6. Find the polynomial of second degree, which is the best approximation in
1 4 9 9
maximum norm to x on the point set 0, , ,1 .
Solution. Let P2(x) is the required polynomial, which is given by 2 P2(x) = ax + bx + c The error function e(x) is given by
ε( x ) = ax 2 + bx + c − x Now, using Chebyshev equioscillation theorem, we have
1 ε(0) + ε = 0 9
Data Approximation of functions
which gives
619
1 4 ε + ε = 0 9 9 4 ε + ε(1) = 0 9 a 1 1 17 5 98 13 5 + b + 2c = ; a+ b + 2c = a + b + 2c = 1 ; 81 9 3 81 9 3 81 9
Solving these equations for a, b, c, we get
9 1 a = − , b = 2, c = 8 16
Hence, the best polynomial approximation is P2( x ) =
1 9 + 2x − x 2 16 8
Example 7. Find the best lower order approximation to the cubic polynomial 2x3 + 3x2 in the interval [–1, 1].
Solution.
1 4
Here, we know that x 3 = [3T1( x ) + T3( x )] therefore, 2x3 + 3x2 in terms of Chebyshev polynomials, we get
2 [3T ( x ) + T3( x )] + 3 x 2 4 1 3 1 3 1 = 3 x 2 + T1( x ) + T3( x ) = 3 x 2 + x + T3( x ) [ T1(x) = x] 2 2 2 2 3 Since |T3(x)| [ 1, –1 [ x [ 1 therefore the polynomial 3 x 2 + x is the required best 2 1 lower order approximation to the given cubic with a maximum error ± in the range 2
2x 3 + 3x 2 =
[–1, 1].
Example 8. Find a uniform polynomial approximation of degree 4 or less to ex in Solution.
[–1, 1] using Lanczos economization with a tolerance of e = 0.02. Since, we have f( x) = ex = 1 + x +
x2 x3 x4 x5 + + + + ... 2 6 24 120
1 = 0.008... 120
since
Therefore, we take f(x) upto
f( x) = ex = 1 + x + s.t.
x4 with a tolerance of e = 0.02 24
x2 x3 x4 + + 2 6 24
...(1)
Changing each power of x in (1) in terms of Chebyshev polynomials, we get
1 1 1 e x = T0 + T1 + (T0 + T1 ) + (3T1 + T3 ) + (3T0 + 4T2 + T4 ) 4 24 192 81 9 13 1 1 = T0 + T1 + T2 + T3 + T 64 8 48 24 192 4
Neglecting the last term because its magnitude 0.005 is less than 0.02. x Hence, the required economized polynomial approximation for e is given by
ex
81 9 13 1 x 3 13 2 191 T0 + T1 + T2 + T3 = x +x+ + 64 8 48 24 6 24 192
Example 9. Find a polynomial P(x) of degree as low as possible such that
2
max | e x − P( x )| ≤ 0.05 .
|x| ≤ 1
...(2)
Applied Numerical Analysis
620 Solution.
We know that
2
ex = 1 + x2 +
x 4 x 6 x 8 x10 + + + + .... 2 6 24 120
x4 x6 x8 + + = P( x ) 2 6 24 1 ≈ 0.0083 with error in the leading term as 120 = 1 + x2 +
...(1)
Now expressing (1) in terms of Chebyshev polynomials, we get 1 1 1 P( x ) = T0 + (T0 + T2 ) + (3T0 + 4T2 + T4 ) + (10T0 + 15T2 + 6T4 + T6 ) 2 16 192 1 + (35T0 + 56T2 + 28T4 + 8T6 + T8 ) 3072 1 = (5379T0 + 2600T2 + 316T4 + 24T6 + T8 ) 3072
Here, we have
1 (24T6 + T8 ) ≤ 0.0082 3072
< the required maximal error of approximation 0.05. Therefore, the required approximation
2
1 (5379T0 + 2600T2 + 316T4 ) 3072 1 = [5379 + 2600(2 x 2 − 1) + 316(8 x 4 − 8 x 2 + 1)] 3072 1 [3095 + 2672 x 2 + 2528 x 4 ] = 3072
ex ≈
= 1.0075 + 0.8698x2 + 0.8229x4. Example 10. Find the lowest order polynomial which approximates the function 4
f ( x ) = ∑ ( − x )r in the range 0 [ x [ 1, with an error less than 0.1. r =0
Solution.
Change the interval [0, 1] to [–1, 1] by using the transformation
1 x = (1 + t ) 2 4
Therefore, the function f ( x ) = ∑ ( − x )r = 1 − x + x 2 − x 3 + x 4 , 0 ≤ x ≤ 1 . r =0
1 1 1 1 transform to F(t ) = 1 − (1 + t ) + (1 + t )2 − (1 + t )3 + (1 + t )4 2 4 8 16 11 1 1 2 1 3 1 4 = − t+ t + t + t , −1 ≤ t ≤ 1 . 16 8 4 8 16
Now changing the power of t in F(t) in terms of Chebyshev polynomials, we get 11 1 1 1 1 (T + 4T2 + 3T0 ) T − T + (T + T ) + (T + 3T1 ) + 16 0 8 1 8 2 0 32 3 128 4 107 1 5 1 1 = T − T + T + T + T 128 0 32 1 32 2 32 3 128 4 1 1 T + T < 0.1, we get the approximation Now, since 32 0 148 4 107 1 5 107 1 5 5 2 t 87 t − F(t ) = T0 − T1 + T2 = − t + (2t 2 − 1) = + 128 32 32 128 32 32 16 32 128
F(t ) =
Data Approximation of functions
621
Replace t by (2x – 1), we get the required polynomial approximation as =
1 (160 x 2 − 168 x + 131) 28
Example 11. Obtain the rational approximation of the form Solution.
function ex. Since, we know that
a0 + a1 x
1 + b1 x + b2 x 2
to the
[kanpur–2012, 14; avadh–2014]
x2 x3 x4 + + + ... 2 6 24 a0 + a1 x
ex = 1 + x +
Let e x Consider ex −
1 + b1 x + b2 x 2
a0 + a1 x
1 + b1 x + b2 x 2
Set 1 + x +
=
x2 x3 + + .... (1 + b1 x + b2 x 2 ) − (a0 + a1 x ) 1 + x + 2 6 1 + b1 x + b2 x 2
∞ x2 x3 + + .... (1 + b1 x + b2 x 2 ) − (a0 + a1 x ) = ∑ p j x j . 2 6 j=0
To determine the four constants a0, a1, b1 and b2, we put pj = 0; j = 0, 1, 2, 3 and we get
1 − a0 = 0 b1 + 1 − a1 = 0 1 b2 + b1 + = 0 ...(1) 2 1 1 b2 + b1 + = 0 2 6
Solving (1) for a0, a1, b1, b2 we get
1 −2 1 ,b = ,b = 3 1 3 2 6 1 1+ x x 3 + o( x 4 ) e 2 1 1 − x + x4 3 6 a0 = 1, a1 =
Exercise 13.1
1. Use the method of least squares to fit the C curve y = 0 + a ⋅ x to the following table 2 x
0.1
0.2
0.4
0.5
1
2
y
21
11
7
6
5
6
2. An experiment with a periodic process give the following data
t0 0 50 100 150 y 0.754 1.762 2.041 1.412 t0 200 250 300 350 y 0.303 –0.484 380 0.520 Estimate the parameters a and b in the
model y = b + a sin t, using the least square approximation. 3. Obtain the Chebyshev linear polynomial approximation to the function f(x) = x3 on [0, 1]. 4. Prove that the polynomial of best approximation of degree not exceeding 3 for 1 |x| in the interval [–1, 1] is x 2 + . 8 5. Obtain the Chebyshev polynomial approximation of second degree to the function 3 f(x) = x on [0, 1]. What is the maximal error?
Applied Numerical Analysis
622 6. Determine the best minimax approximation |x| with a polynomial of degree 0 and 1 to e for |x| [ 1. 7. Find the best uniform approximation of 4 degree 3 or less to x on [–1, 1]. 3
2
8. The function P3(x) = x – 9x – 20x + 5 is given. Find a second degree polynomial
P2(x) such that
δ = max | P3( x ) − P2( x )| 0≤ x ≤ 4
becomes as small as possible. The value of d and the value of x for which |P3(x) – P2(x)| = d should also be given. 9. Economize the power series x3 x5 x7 + − , −1 ≤ x ≤ 1 . 6 120 5040 10. The function f is defined by
sin x ≈ x −
2
1 1 − e −t f ( x ) = ∫0x dt 2 t2 Approximate f by a polynomial P(x) = a + bx
+ cx2 such that
degree polynomial P3(x) so that
12. If we want to approximate a continuous function f(x) on |x| [ 1 by a polynomial Pn(x) of degree n, suppose that we have found
f(x) – Pn(x) = an + 1(x)Tn + 1(x) + r(x) where Tn + 1 denotes the Chebyshev polynomial of degree (n + 1) with 1 1 ≤ | α n +1 | ≤ n n +1 2 2 1 | r( x )| ≤ ⋅| α n +1 |, | x | ≤ 1 and 10 0.4 1.1 Show that n ≤ max | f ( x ) − Pn*( x )| ≤ n |x| ≤ 1 2 2 * Where, Pn(x) denotes the optimal polynomial of degree n for f(x) on |x| [ 1. x 13. Obtain the rational approximation for e of the form a a x (i) 0 1 [kanpur-2011, 13; rohilkhand-2010, 13] bx
(ii)
max | f ( x ) − P( x )| ≤ 5 × 10−3
|x| ≤ 1
1 et − 1 dt , by a third 11. Approximate F( x ) = ∫0x x t
max | F( x ) − P3( x )| ≤ 3 × 10−4
−1≤ x ≤1
a0 + a1 x + a2 x 2 1 + b1 x + b2 x 2
[kanpur-2011, 14; purvanchal-2013; rohilkhand-2003]
(iii)
a0 + a1 x + a2 x 2 1 + b1 x
Answers 1.97333 3 + 3.2878 x 2. y = 0.752575 + 1.312810 sin t 3. P1( x ) = x − 9 x 1 (e + 1) 2 (48 x − 18 x + 1) 6. P1( x ) = 5. P2( x ) = 32 2 383 5 3 2 1 x− x 7. P( x ) = x − 8. P2(x) = –3x2 – 29x + 7 9. sin x = 384 32 8 37 3 103 2 3455 4799 2 x + x + x+ 10. P(x) = 0.9966 – 0.1381x 11. P3( x ) = 3456 1800 13824 4800 1 1 1 2 2 1 1+ x 1+ x + x 1 + x + x2 x 3 x x 5 2 2 12 3 6 + 0( x ) (ii) e = + 0( x ) (iii) e = + 0( x 4 ) 13. (i) e = 1 1 1 2 1 1− x 1− x + 1− x x 2 2 12 3 1. y =
MULTIPLE CHOICE QUESTIONS (CHOOSE THE MOST APPROPRIATE ONE) 1. The criterion of a norm which makes the error smallest is called : (a) best approximation
(b) rational approximation (c) both (a) and (b) are true (d) none of these
Data Approximation of functions
623
2. Which of the following is/are true (a) when we used Euclidian norm, we obtained least square approximation (b) when uniform norm is used, we obtained the uniform approximation (c) both (a) and (b) are true (d) none of these 3. The approximation for which the constant ci, i = 0, 1, 2, …., n are determined in such a way that the aggregate of weight function is as smell as possible is called: (a) best approximation in the least square sense (b) best approximation in the uniform approximation sense (c) both (a) and (b) are true (d) none of these 4. A set of real functions [gi(x)] is said to be orthogonal over a set of points x1, x2,…, xn with respect to the weight function W(x) if m
∑ W ( x k )g i ( x k )g j ( x k ) =
k =1
(a) 1 (b) 0 (c) 2 (d) none of these 5. The polynomial defined by ( n /2) (2n − 2r )! x n − 2r Pn( x ) = ∑ ( −1)r n 2 r !(n − 2r )!(n − r )! r =0 is called : (a) Legendre polynomial (b) Chebyshev’s polynomial (c) Bassel’s polynomial (d) none of these 6. If Tn(x) is a Chebyshev’s polynomial then which of the following is/are true
(a) T0(x) = 1 (b) T1(x) = x (c) Tn + 1(x) = 2xTn(x) – Tn – 1(x) (d) all are true 7. The exponential curve y = abx which can be fitted to the data : x y
1
2
3
4
1.0 1.2 1.8 2.5
5
6
7
8
3.6 4.7 6.6 9.1
(a) 2x
(b) 3x
(c) (.68)(1.38)x
(d) none of these
8. The linear polynomial approximation for the function f(x) = x3 through the origin is: x 3x (a) (b) 5 5 4x (c) (d) none of these 5 9. The polynomial of best approximation of degree not exceeding 3 for |x| in the interval (–1, 1) is : 1 (a) x2 + 8 (b) x 2 + 8 3 (c) x 2 + (d) none of these 8 10. The best fit values of x, y, z in the least square since from the following equations x+2y+z=1, 2x+ y + z = 4, –x + y + 2z = 4 and 4x+2y– 5z = –7 are given by :
(a) 0.910, –0.378, 2.045 (b) 0.910, 0.378, 0.488 (c) 1, 0, 0 (d) none of these 11. The normal equation for fitting the curves of type y = ax + b / x by least square method is :
(a) Sxiyi = aSxi2 +nb (b)
Σy i 1 = na + bΣ 2 xi xi
(c) both (a) and (b) are true (d) none of these 12. The most plausible values of x and y from the following equations x + y = 3, 2x – y = 0.5, x + 3y = 7.25, 3x + y = 4.95 are given by: (a) 1.234, 1.919 (b) 2.23, 1.9 (c) 2.23, 2.9 (d) none of these 13. If x + 2.5y = 21, 3.2x – y = 28, 4x+1.2y = 42.04, 1.5x+6.3y = 40 then most plausible values are given by:
is y =
(a) 9.620, 4.064
(b) 8.620, 5.064
(c) 7.620, 1.98
(d) none of these
Answers 1. (a) 2. (c) 10. (a) 11. (c)
3. (a) 12. (a)
4. (b) 13. (a)
5. (a)
6. (d)
7. (c)
8. (b)
9. (b)
Applied Numerical Analysis
624
ARCHIVE 1. Prove that n
2πkx 2πjx sin ∑ sin n + 1 n + 1
x =0
k ≠ j or k = j = 0 0, [meerut–2004] = n + 1 k≠ j≠0 2 ,
n 2πkx 2πjx =0. cos 2. Prove that ∑ sin n + 1 n + 1 x =0 [meerut–2002, 05]
4. Prove that 1 − x 2 ⋅ Tn( x ) = U n +1( x ) − xU n( x ). [uptu–2003, 05] 5. Prove that Tn(x) and Un(x) are independent solutions of Chebyshev’s differential equation. [rgpv–2010] 6. Economize the series f ( x ) = 1 − 7. Economize the series:
3. Prove that
k≠ j 0, n + 1 2 π 2 π kx jx cos = , k= j≠0 ∑ cos n + 1 n + 1 2 x =0 n + 1 k = j = 0
n
x x2 x3 − − . 2 8 16 [uptu–2010]
x3 x5 x7 + + on interval [–1,1] 6 120 5040 allowing for a tolerance of 0.0005.
sinh x = x +
[bombay–2009]
[meerut–2003]
qqqq
Difference Equations
625
14 Difference Equations 14.1 Introduction An equation that consists of an independent variable x, a dependent variable yx and one or more of its difference ∆y x , ∆ 2 y x ,..., ∆ n y x is called a difference equation. It is of the form F[ x , y x , ∆y x , ∆ 2 y x ,..., ∆ n y x ] = 0 A difference equation is therefore a relation involving differences. For example :
Remarks
(1) Dyx + 2yx = 0
(2) D2yx + 3Dyx – 7yx = 0
(3) D3yx + 3D2yx – 6Dyx + yx = 3x + 2
(4) yxD3yx = 6
¯¯ When difference equation defined over some set A, then the relation among the values of yx, Dyx,
D2yx, … given by the equation and the set of values, denoted by A for which this relation is said to hold. ¯¯ The set A consists of either a finite or infinite set of successive integers. ¯¯ It is often convenient to have this set start with zero but it is not necessary. It is not necessary that the difference equations are defined over the set of all real numbers. They can be considered as difference equations over some other set.
14.2 Difference Equation as a Relation Among the Value of yx Let Dk = (E – 1)k and Ehyx = yx + h. If the interval of differencing is unity, then we can express Dyx = (E – 1)yx = Eyx – yx = yx + 1 – yx…(1) D2yx = (E – 1)2yx = (E2 – 2E + 1)yx = yx + 2 – 2yx + 1 + yx…(2) D3yx = (E – 1)3yx = (E3 – 3E2 + 3E – 1)yx = yx + 3 – 3yx + 2 + 3yx + 1 – yx…(3) For example: The above difference equation (3) can be written as yx + 3 – 9yx + 1 + 9yx = 3x + 2…(4) This equation can be written as y(x + 3) – 9y(x + 1) + 9y(x) = 3x + 2 3 ⇒ (E – 9E + 9)yx = 3x + 2 Similarly we can solve other equation (1), (2) and (4), we get (E + 1)yx = 0 2 (E + E – 9)yx = 0 (E3 – 3E2 + 3E – 1)yx2 = 6
14.3 Order of Difference Equation The order of a difference equation is the difference between the highest and the lowest subscripts
626
Applied Numerical Analysis
of the y, when it is free from D. Thus the order of equation (1) is (x + 1) – x = 1 equation (2) is of order (x + 2) – x = 2, equation (3) is of order (x + 3) – x = 3 and the equation (4) is of order (x + 4) – x = 4.
14.4 Degree of Difference Equation The degree of difference equation is highest power of y and free from D. The degree of equation y 2x +1 y 3x + 2 − y x +1 y x − y 2x = x is 3 and the order of this equation is 2.
14.5 Solution of Difference Equation A function y is called a solution of a difference equation over a set A if the value of y make the difference equation a true statement for every point of A.
Remarks
¯¯ A general solution of a difference equation of order n involves n arbitrary constants. ¯¯ A particular solution of a difference equation is obtained from the general solution by giving
particular values to the constants. For example: yx = A2x + B3x is the general solution to yx + 2 – 5yx + 1 + 6yx = 0 while yx = 2x or yx = 3x or yx = 5(2x) + 8(3x) are particular solutions.
Example 1. Form the difference equation corresponding to the family of curves
2 y = ax + bx – 3. Solution. The given equation is yx = ax2 + bx – 3 …(1) where, a and b are arbitrary constants to be determined 2 Now yx + 1 = a(x + 1) + b(x + 1) – 3 ⇒ yx + 2 = a(x + 2)2 + b(x + 2) – 3 We know that Dyx = yx + 1 – yx = (2x + 1) a + b…(2) 2 D yx = yx + 2 – 2yx + 1 + yx = 2a…(3)
1 2 ∆ yx 2
⇒
a=
From equation (2), we have
1 b = ∆y x − (2 x + 1)∆ 2 y x …(4) 2
Eliminating a, b from equation (1), (3) and (4), we get
( x + 1)x ∆ 2 y x − 2 x ∆y x + 2 y x + 6 = 0
( x 2 + x ) y x + 2 − 2( x 2 + 2 x ) y x +1 + ( x 2 + 3 x + 2) y x + 6 = 0.
Example 2. Form the difference equation, given that yn = A3n + B5n, where A and B
(Kurukshetra (NIT)–2013) are arbitrary constants. Given equation is yn = A3n + B5n…(1) n+1 + B5n + 1 = 3A3n + 5B5n…(2) yn + 1 = A3 n+2 + B5n + 2 = 9A3n + 25B5n…(3) yn + 2 = A3 Eliminating A and B from equations (1) to (3), we get
Solution.
yn 1 1 y n +1 3 5 = 0 yn + 2 9 25
or yn + 2 − 8 yn +1 + 15 yn = 0 . which is the required difference equation.
Difference Equations
627
Example 3. Find the order of the difference equation yx + 2 – 7yx = 5 Solution. The given equation is yx + 2 – 7yx = 5.
The difference between the highest and lowest subscripts of y is x + 2 – x = 2. Hence the order of the equation is 2. Example 4. Find the order of the following : 3 (i) yx + 4 – 5yx + 2 + 6yx = 0 (ii) D yx + 2Dyx + yx = x + 3
(i) The order of equation yx + 4 – 5yx + 2 + 6yx = 0 is x + 4 – x = 4. (ii) The given equation D3yx + 2Dyx + yx = x + 3 (yx + 3 – 3yx + 2 + 3yx + 1 – yx) + 2(yx + 1 – yx) + yx = x + 3 yx + 3 – 3yx + 2 + 5yx + 1 – 2yx = x + 3 Order of this equation is the difference between the highest and lowest subscript of y is given by (x + 3) – x = 3.
Solution.
x( x − 1) is a solution of the difference equation yx + 1 – yx = x. 2 x( x − 1) ( x + 1)x yx = We have . Therefore y x +1 = 2 2 ( x + 1)x x( x − 1) − = x , we get right hand side, Substituting these values in y x +1 − y x = 2 2 i.e., y x = [ x( x − 1)] / 2 satisfy the given difference equation. Hence, it is a solution of
Example 5. Show that y x = Solution.
given difference equation.
Example 6. Show that y x = 1 −
2 , x = 1,2, 3,... is a solution of the first order difference x
equation (x + 1)yx + 1 + xyx = 2x – 3, x = 1, 2, 3, … 2 2 ⇒ y x +1 = 1 − x x +1
Solution.
We have y x = 1 −
Substituting these values in LHS of given equation, we get ( x + 1) y x +1 + xy x
2 2 x + 1 − 2 x − 2 + x = ( x + 1) 1 − + x 1 − = x + 1 x + 1 x x +1 x
= x – 1 + x – 2 = 2x – 3 = RHS yx = 1 −
2 is the solution of the given first order difference equation. x
Example 7. Show that yx = C1 + C22x – x is a solution of the difference equation
yx + 2 – 3yx + 1 + 2yx = 1. We have yx = C1 + C22x – x. ⇒ yx + 1 = C1 + C22x + 1 – (x + 1) and yx + 2 = C1 + C22x + 2 – (x + 2) Substituting these values in LHS of given equation, we get yx + 2 – 3yx + 1 + 2yx = (C1 + C22x + 2 – x – 2) x+1 – x – 1)+ 2(C1 + C22x – x) – 3(C1 + C22 2 x = (2 – 3.2 + 2)C22 + 1 = 1 = RHS i.e., yx = C1 + C22x – x satisfy the given difference equation. Hence, this is the solution of given difference equation.
Solution.
Exercise 14.1
1. Form the difference equations by eliminating arbitrary constant 2 (i) y = C1x + C2x + C3
x
x
(ii) y = C13 + C28 (iii) y = (C1 + C2x)2x
628
Applied Numerical Analysis the solution yx = 2x(C1 + xC2), x = 0, 1, 2, …
2. Find the order of the difference equation. 3 2 (i) D yx + D yx + Dyx + yx = 0 (ii) yx + 2 + 3yx = 2
(iii) D3yx + 2Dyx + yx = x x
3. Show that C1 + C2e is the solution of the
difference equation yx+2 – 3yx+1+2yx = 0, x = 0, 1, 2, … 4. Show that the order of the difference equation 2 D yx + 3Dyx – 3yx = x is 2. x
5. Prove that yx = 3 (A yx + 2 – 6yx+1 + 9yx = 0.
+
Bx)
satisfy
6. Show that the difference equation yx + 2 – 4yx + 1 + 4yx = 0, x = 0, 1, 2, … has
for any constants. Find the solution satisfying the initial conditions y0 = 1 and y1 = 6. C is the solution of the 1 + Cx yx , x = 0, 1, difference equation y x +1 = 1 + yx 2, … 8. Form the difference equation by eliminating the arbitrary constants a and b from the relation (i) yn = a cos nq + b sin nq (ii) yn = an2 + bn (Kurukshetra–2007, 08, K urukshetra (NIT)–2009) 7. Show that y x =
Answers 1. (i) yx + 3 – 3yx + 2 + 3yx + 1 – yx = 0 (ii) y x + 2 – 11yx + 1 + 24yx = 0 (iii) yx + 2 + 4yx + 1 + 4yx = 0 2. (i) 2 (ii) 2 (iii) 3 8. (i) yn + 2 – 2 cos q yn + 1 + yn = 0 (ii) n(n + 1)D2yn – 2nDyn + 2yn = 0
14.6 Linear Difference Equation This is a most important type of difference equation and it has the general form a0yx + n + a1yx + n – 1 + a2yx + n – 2 + … + anyx = f(x)…(1) where a0, a1, a2, … an and f(x) are each functions of x (but not of yx) or L(E)yx = f(x)…(2)
where L(E) = a0En + a1En – 1 + a2En – 2 + … + an is a polynomial expression in E and is known as non homogeneous linear equation. If f(x) = 0 in equation (2) then L(E)yx = 0 …(3) and is known as homogeneous linear equation. Here, we notice an obvious analogy now with linear differential equations. In fact the general solution of (1) comprises a particular solution of it combined with the general solution of (3). This follows as an immediate consequence of the following theorems which arise from equation (1) and (3). Their proofs are so similar to those already given for corresponding linear difference equations. (i) If yx = f1(x) is a solution of equation (3), then yx = A1f1(x) is also a solution of equation (3), where A1 is any constant. (ii) If the homogeneous equation (3) is satisfied by equations yx = f1(x), yx = f2(x), …, yx = fn(x) then it is also satisfied by yx = A1f1(x) + A2f2(x) + … + ArFr(x) where A1, A2, …, Ar are constants. (iii) If yx = f1(x), yx = f2(x), yx = f3(x), … yx = fn(x) are n independent solutions of equation (3), then its general solution is yx = A1f1(x) + A2f2(x) + … + Arfr(x) where A1, A2, …, Ar are constants. (iv) If yx = f1(x), yx = f2(x) be solutions of the equation L(E)yx = g(x), L(E)yx = h(x) where f(x) = g(x) + h(x), then yx = f1(x) + f2(x) is a solution of equation (2). This is the superposition principle and is valid only for linear equations.
Difference Equations
629
(v) If yx = ux is a particular solution of (2), then with the conditions of (iv), the general solution of (2) is yx = ux + A1f1(x) + A2f2(x) + … Arfr(x)
14.7 Existence and Uniqueness Theorem
(Rohilkhand-2005, 07, 10; Agra-2004)
Some difference equations have infinitely many solutions whereas others have no solution at all. In the case of linear difference equations we can always find at least one solution. Before starting and proving the existence and uniqueness theorem for the linear difference equations of order n, first look a case of order two. The analysis about the second order difference equation will be helpful to understand the general theorem. The equation of second order difference equation is …(1) a0yx + 2 + a1yx + 1 + a2yx = f(x), x = 0, 1, 2… with a0 g 0, a2 g 0, x = 0, 1, 2, … Now, let y0 and y1 be given. Then, with x = 0, (1) gives a0y2 + a1y1 + a2y0 = f(0) ⇒ a0y2 = f(0) – a1y1 – a2y0 Since a0 g 0 for any x also a0(0) g 0 and hence y2 =
a (0) f (0) a1(0) y − 2 y − a0 ( 0) a0(0) 1 a0(0) 0
Thus with the help of y1 and y0, we can find y2. Now, we can find y3. For that put x = 1 in (1), we get a0y3 = f(1) – a1y2 – a2y1 and since a0(1) g 0.
y3 =
a (1) f (1) a1(1) − y − 2 y a0 (1) a0(1) 2 a0(1) 1
Continue this way, generating the unique solution of the second order difference equation.
Remark
¯¯ The linear difference equation of order n
a0yx + n + a1yx + n – 1 + … + an – 1yx + 1 + anyx = f(x) …(1) over a set A of consecutive integral values of x has one and only one solution y for which values at n consecutive x-values are arbitrary prescribed.
14.8 Solution of the Equation yx + 1 = Ayx + B The linear first order difference equation is of the form a0(x)yx + 1 + a1(x)yx = f(x); x = 0, 1, 2, ... … (1) Over the indicated set of x-values. The functions a0(x) and a1(x) according to the definition, are never zero, so if they are constant, they are non-zero. Dividing (1) by a0(x), we get
y x +1 =
− a1( x ) f( x) y + a0( x ) x a0( x )
If we now suppose a0 and a1 as well as f are constant function, we can write …(2) yx + 1 = Ayx + B; x = 0, 1, 2, … where A and B are constant and A g 0. To find the solution of equation (2), put x = 0 in (2), then y1 = Ay0 + B At x = 1, y2 = Ay1 + B = A(Ay0 + B) + B = A2y0 + AB + B = A2y0 + (A + 1)B
630
Applied Numerical Analysis
Again at x = 2, we get
y3 = Ay2 + B
2 3 2 = A[A y0 + (A + 1)B] + B = A y0 + (1 + A + A )B
yx = Axy0 + (1 + A + A2 + … + Ax – 1)B
2 x–1 is geometric progression, hence We know that 1 + A + A + … A
1 + A + A2 + ... + A x −1 =
1 − Ax , if A g 1 1− A
=x
if A = 1
x B(1 − A x ) A y0 + if yx = 1− A y0 + Bx if
We can write
Remarks
A≠1
…(3)
A=1
¯¯ The function y given by equation (3) is a solution, and the only solution of the difference equation (2) with y0 prescribed.
¯¯ The linear difference equations yx + 1 = Ayx + B, x = i, i + 1, i + 2
...(1) taken over the set of x-values has infinitely many solutions. If y is a solution and C is a constant such that
x −1 1 − A x −1 CA if A ≠ 1 +B yx = , x = i, i + 1, i + 2 …(2) 1− A ( ) if 1 + − = C B x i A if a single value of y is prescribed for one of the h values i, i + 1, i + 2, …, then a unique solution of (1) is determined. In particular, if yi is prescribed then solution of (1) is given by (2) with B = yi.
Example 1. Solve the difference equation : yx + 1 = 2yx + 3, x = 1, 2, 3, … and y0 = 0. Solution.
Comparing the given equation with yx + 1 = Ayx + B, where A = 2 and B = 3. The solution is
y x = A x y0 + B
1 − 2x 1 − Ax = 2 x.0 + 3 1− A 1−2
( y0 = 0)
x x = –3(1 – 2 ) = 3(2 – 1), x = 0, 1, 2, … Hence, we can write the sequence as 3, 9, 21, … Example 2. Solve the difference equation yx + 1 = – yx + 1, x = 0, 1, 2, … and y0 = 1. Solution. Comparing the given equation with yx+1= Ayx+ B, where A = –1 and B = 1, therefore solution is
1 − Ax 1− A 1 − ( −1)x 1 − ( −1)x x = ( −1) y0 + 1. = ( −1)x y0 + 1 − ( −1) 1+1 x 1 − ( − 1) = ( −1)x .1 + ( y0 = 1) 2 1 1 = ( −1)x + [1 − ( −1)x ] = [1 + ( −1)x ] , x = 0, 1, 2, … 2 2
y x = A x y0 + B
Hence, we can write the sequence as 1, 0, 1, 0, 1, 0, …
Difference Equations
631
Example 3. Find the solution of yx + 1 = 2yx – 1, x = 0, 1, 2, … with initial condition y0 = 5. Solution. Comparing the given equation with yx + 1 = Ayx + B, we have, A = 2 and B = –1.
y x = A x y0 + B
1 − Ax 1− A 1 − 2x ( y0 = 5) 1−2
= 2 x.5 + ( −1)
= 5.2 x + 1 − 2 x
= 4.2 x + 1 , x = 0, 1, 2, …
It gives the sequences 5, 9, 17, 33, 65, 129,…
Example 4. Solve the difference equation over the set of x values 0, 1, 2, … 3yx + 1 = 2yx + 3, y0 = 2. Solution. Comparing this equation with yx + 1 = Ayx + B.
We have A =
2 , B = 1 therefore we have 3
2 1− 3 1− A 2 x = .2 + 1. y x = A y0 + B 2 3 1− A 1− 3
x
x
x
x
2 1− 3 2 = 2 .2 + 1. 2 3 1− 3
x 2 x 2 = 2 + 3 1 − 3 3
x
x
2 y x = 3 − , x = 0, 1, 2, … 3 7 23 ,... 3 3
It gives the sequence 3, ,
Example 5. Solve yx + 1 = – yx + 2, x = 0, 1, 2, … Solution.
Comparing the given equation with yx + 1 = Ayx + B, where, A = –1, B = 2, solution is
y x = A x y0 + B
1 − Ax 1− A 1 − ( −1)x 1 − ( −1)
= ( −1)x y0 + 2.
= (–1)xy0 + 1 – (–1)x, x = 0, 1, 2, …
= (–1)xy0 + [1 – (–1)x], x = 0, 1, 2, …
x x If x = 0 or even integer, then (–1) = 1 and if x = an odd integer then (–1) = –1, we
obtain the sequence y0, – y0 + 2, y0, – y0 + 2, …
632
Applied Numerical Analysis
Example 6. Solve the difference equation (E – a)2yx = 0. Solution. We may write y ( E − a)2 y x = a x + 2∆ 2 xx = 0 a
⇒
y ∆ 2 xx = 0 ⇒ a yx = Ax + B ax
y ∆ xx = A a
Hence, yx = ax (Ax + B) is the solution of given equation. Example 7. Solve the equation yx + 1 = f(x)yx.
Solution.
n
Dividing both sides by ∑ f (r ) , we get r =1
n −1
r =1
r =1
∑ f (r ) = y x
y x +1
or ∆ y x
n
∑ f (r )
n −1
∑ f (r ) = 0 ⇒ r =1
yx
n −1
∑ f (r ) = A
r =1
n −1
y x = A ∑ f (r )
Hence,
r =1
Example 8. Solve the equation y x +1 = y x Solution.
We have log y x +1 = log y x
⇒
log y x +1 =
1 log y x 2
1 2
⇒ log y x +1 − log y x = 0 x
1
1 log y x = A = A2− x 2
⇒ E − log y x = 0 ⇒ 2
y x = exp( A2− x ) −x
A y x = k 2 where k = e Alternatively we have
2
(1/2) (1/2) y x = y1/2 x −1 = y x − 2 = ... = y 0
x
Example 9. Solve the equation y x y x + 2 = y 2x +1 Solution.
We have y x y x + 2 = y 2x +1
⇒
y x + 2 y x +1 = y x +1 yx y yx
∆ x +1 = 0 ⇒
or
( E − A) y x = 0
Hence,
y x = BA
⇒ ⇒
y x +1 =A yx y x +1 = Ay x
x
Example 10. Show that the solution yx of 2yx + 2 + 3yx + 1 – 2yx = 0, y0 = 1, y1 = 1/2 is Solution.
bounded and monotonically decreasing with limit zero. From the given difference equation, we have
y x +2 = −
3 y + yx 2 x +1
Difference Equations
633
3 3 1 1 y + y0 = − . + 1 = 2 1 2 2 4 3 3 1 1 1 x = 1, y3 = − y2 + y1 = − . + = 2 2 4 2 8 3 3 1 1 1 x = 2, y4 = − y3 + y2 = − . + = 2 2 8 4 16 3 3 1 1 1 x = 3, y5 = − y4 + y3 = − . + = 2 2 16 8 32
Put x = 0, y2 = −
Hence, solution of the given difference equation is bounded and monotonically decreasing.
Exercise 14.2
1. Consider the linear difference equation of order 2. yx + 2 – xyx + 1 – yx = 0, x = 0, 1, 2, … over the indicated set of x-values. Show that there is no solution of this difference equation for which y0 = 0 and y2 = 1. Show also that if the prescribed values y0 and y2 are equal, there are infinitely many different
is a solution, and only solution of the following difference equation with y0 prescribed. 6. Solve the following difference equation over
the set of x-values 0, 1, 2, … (i) yx + 1 = 3yx – 1, y0 = 6
solutions of the difference equation. Why the existence and uniqueness theorem is not valid by these facts. 2. Prove that a0(x) yx + 2 + a1(x) yx + 1 + a2(x) = f(x), x = 0, 1, 2, …, y0 = a, y1 = b has one and only one solution where a0, a1, a2 g 0. Hence, write down all possible solutions of
yx + 2 + sinh yx + 1 + (2x + 1)yx = 0, x = 2,
3, 4, …, y2 = 0, y3 = 0. x( x − 1) + B is the solution of 3. Show that y x = 2 the difference equation yx + 1 – yx = x. Find the particular solution satisfying the initial conditions y0 = 1. x 4. Show that yx = A1 + B1(–1) is the solution of the difference equation yx + 2 – yx = 0. Find the particular solution satisfying the
x 1− Ax A y0 + B if A ≠ 1 yx = , x = 0,1,2… 1− A y0 + Bx if A = 1
(ii) yx + 1 = yx + 2, y0 = 2 (iii) yx + 1 = 2yx + 1, y0 = 5 7. The difference equation xyx + 1 – yx = 0, x = 0, 1, 2, … is linear but not of first order over the indicated set of x-values. Why? If the initial condition y0 = 0 is given, show that y1 is not uniquely determined and there are infinitely many solutions of the difference equation with y0 = 0. Show also that if the value of y at any x-values different from zero is given, there is a unique solution of the difference equation. 8. Solve yx + 1 – 2 cos ayx + yx – 1 = 0 (Kurukshetra–2013) 9. A series of values of yn satisfy the relation yn + 2 + ayn + 1 + byn = 0, given y0 =0, y1 = 1,
initial condition y0 = 1, y1 = 2. 5. Prove that the function yx given by
y2 = y3 = 2, show that yn = 2n /2 sin
(Kurukshetra–2012, Kurukshetra (NIT)–2006, 08)
Answers x( x − 1) 3 1 + 1 4. y x = − ( −1)x 2 2 2 11 x 1 3 + 6. (i) y x = (ii) y x = 2(1 + x ) 2 2 8. yn = (1)x[C1 cos(x – 1)a + C2 sin(x – 1)a]
nπ . 4
3. y x =
(iii) y x = 6.2 x − 1
634
Applied Numerical Analysis
14.9 Solution as Sequences The linear first order difference equation is given by yx + 1 = Ayx + B; x = 0, 1, 2, … The solution of above equation is
x 1 − Ax A y0 + B yx = 1− A y Bx + 0
if
A≠1
if
A=1
…(1)
; x = 0,1,2,... …(2)
Thus, if the value of y0, A and B are given, then equation (2) will give a sequence . Two cases are here : Case I, A = 1 and Case II, A g 1. Case I if A = 1. Then
If is the solution sequence of the difference equation yx + 1 = yx + B, x = 0, 1, 2, … with y0 prescribed, then is a constant sequence if B = 0, it diverges to +∞ if B > 0 and diverges to –∞ if B < 0.
Proof. If A = 1, we have
yx = y0 + Bx [From equation (2)] Now, if B = 0, then yx = y0 for x = 0, 1, 2, … and is a constant sequence, as given. If B > 0, we will prove that diverges to +∞. By definition given, any positive number l, we must find a corresponding integer m such that yx > l " x > m Suppose integer m is given, then l [ y0 yx = y0 + Bx > l for all x > 0 we will take m = 1, therefore yx > l for all x m m = 1 Again if l > y0, then we want yx = y0 + Bx > l Or Bx > l – y0 for B > 0 Therefore, we choose m >
l − y0 , we have C
yx > l " x m m Similarly, we can show when B < 0, diverges to –∞. ase II if A g 1 C The solution of linear difference equation is
y x = A x y0 +
B B − Ax 1− A 1− A
B B = A x y0 − = A x ( y0 − y * ) + y * + 1− A 1− A y x − y * = A x ( y0 − y * ) , x = 0, 1, 2, ...
where y * =
B 1− A
Difference Equations
635
Hypothesis A
Conclusion
B
y0
for x = 0, 1, 2, … the sequence
(1)
Ag1
y0 = y*
yx = y*
constant (= y*)
(2)
A>1
y0 > y*
yx > y*
monotonic increasing diverges to +∞
(3)
A>1
y0 < y*
yx < y*
monotonic decreasing diverges to –∞
(4)
0 y*
monotonic decreasing converges to y*
(5)
0 0
monotonically increasing divergent
B 1, < y x > = ( y0 − 1) − 1 , When y0 < 1, = 1 – , y0 = 1, = 1 2 2
Difference Equations
637
14.10 Linear Homogeneous Equation with Constant Coefficients In order to obtain standard solutions of such equations, we first obtain alternative term for (E – a)yx and (E – a)ryx. First consider y y ( E − a) y x = y x +1 − ay x = a x +1 xx ++11 − xx a a y ( E − a) y x = a x +1∆ xx …(1) a
Thus, we have,
1 x +1 y x y a ∆ x = a x + 2∆ 2 xx x a a a
From (1), we get ( E − a)2 y x = a x +1∆ and so, in general for r = 1, 2, …
( E − a)r y x = a x + r ∆ r
yx
ax
…(2)
Case I : The equation Dyx = 0 Here, yx + 1 – yx = 0 so that yx + 1 = yx = yx – 1 … y1 = y0 yx = constant
…(3)
r
Case II : The equation D yx = 0 (r = 1, 2, …) Since, Dryx = 0; Dr – 1yx = A1 r–2
D
yx = A1x + A2
D–x 1(k) = constant + (x)k + 1/k + 1 (k = 0, 1, 2, …) So that integration of the last result gives x2
+ A2 x + A3 ∆ r − 3 y x = A1 2! Proceeding, we get A1 x 3 A2 x 2 + + A3 x + A4 3! 2!
∆ r − 4 y x =
yx =
A1 x r −1 A2 x r − 2 + + ... + Ar −1 x + Ar (r − 1)! (r − 2)!
This last equation is a polynomial in x of degree r and contains r constants. It may be rearranged in the more convenient form 2 r–1 …(4) yx = B0 + B1x + B2x + … + Br – 1x B0, B1, …, Br – 1 being constant. Case III : The equation yx + 1 = ayx can be written as ⇒
y x +1 a
x +1
−
yx
ax
yx a
x
=0
= A
or
y ∆ xx = 0 a
yx = Aax
⇒
Case IV : The equation (E – a)(E – b)yx = 0 (a g b) Solving for (E – b) yx = Aax Then above equation can be written as
y b x +1∆ xx = Aa x b
⇒
∆
yx
bx
=
A /b (a / b)x
…(5)
638
Applied Numerical Analysis
⇒
yx b
x
= B+
A x −1 a ∑ b r =0 b
r
x −1 a r
(a / b)x − 1 and so on ∑ = (a / b) − 1 r =0 b
A(a x − b x ) a−b
y x = B′ b x +
y x = A′a x + B′ b x …(6) A′ =
where
⇒
y x = B′ b x + A ′ a x
A A and B′ = B − a−b a−b
We can obtain general solution of the difference equations as the sum of the general solution of the homogeneous equation and particular solution of the complete equation. We will first discuss first order difference equation.
Remark
¯¯ Let us consider linear first order difference equation with constant coefficients
yx + 1 + a1yx = f(x) …(1) …(2) (i) The function Y be given yx = l(–a1)x with l an arbitrary constant is the general solution of the equation yx + 1 + a1yx = 0 …(3) (ii) If y´ is any particular solution of the complete equation, then Y + y´ is the general solution of the complete equation. That is if y is any solution then there is a value of l for which yx = l(a1)x + y´x …(4)
14.11 Linearly Independent Solution or Fundamental Set of Solutions
The rth order homogeneous difference equation yx + r + a1yx + r – 1 + a2yx + r – 2 + … + aryx = 0…(1)
y
(1)
,y
(2)
, …, y
(r)
are the solutions of equation (1) are said to form a fundamental set of solutions
th
of (1) if the r order determinant
y(1) 0
y(2) 0
...
y(0r )
y1(1)
y1(2)
...
y1( r )
y(1) r −1
y(2) r −1 ...
is different from zero.
y(rr−)1
Example 1. Solve: yx + 1 + 3yx = 8. Solution. The corresponding homogeneous equation is
yx + 1 + 3yx = 0 yx + 1 = – 3yx
On comparing it with yx + 1 = Ayx + B, we have A = –3 and B = 0, the solution is
y x = λA x + B
1 − Ax = l(–3)x = (–3)xl 1− A
Particular solution : We will use hit and trial method. We try to see whether the constant function is a solution or not. Let yx = A be a solution of the given equation.
Difference Equations
639
yx + 1 + 3yx = 8 ⇒ A + 3A = 8 4A = 8 A=2 Hence, A = 2 is a particular solution. Hence the general solution will be yx = l(–3)x + 2. Example 2. Solve: yx + 1 – yx = 1.
Solution.
The corresponding homogeneous equation is yx + 1 – yx = 0 On comparing it with yx + 1 = Ayx + B, we get A = 1 and B = 0. The solution will be y x = λ. A x + B
1 − Ax 1− A
x
⇒ yx = l(1) + 0 ⇒ yx = l For particular solution, we shall try hit and trial method. We will see first whether a constant function is solution or not. Let yx* = A be a solution of the given equation, we get A–A=1 0 = –1, not true We now try yx* = Ax + B so that y*x + 1 = A(x + 1) + B from yx + 1 – yx = 1, we get A(x + 1) + B – Ax – B = 1 A=1 Hence, y* = x is solution of the given equation. Hence, the general solution is yx = l + x
Example 3. Solve: yx + 1 – 2yx = 5…(1) Solution. The corresponding homogeneous equation is ⇒
yx + 1 – 2yx = 0 yx + 1 = 2yx
…(2)
On comparing it with yx + 1 = Ayx + B, we get A = 2 and B = 0.
The solution is
y x = λ. A x + B
1 − Ax 1− A
= l2x + 0 = l2x To find the particular solution, we will use hit and trial method. We first try to see whether the constant function is a solution or not. Let yx = A be a function of the given difference equation, we get A – 2A = 5 ⇒ A = –5 Hence, y*x = –5 is particular solution.
640
Applied Numerical Analysis
Hence, general solution will be x yx = l2 – 5.
Remark
¯¯ From the last equation, it is always possible to find any solution satisfying given condition.
Suppose we are interested in a solution for which y0 = 2 …(3) x ⇒ y0 = l20 – 5 = l – 5 Then from yx = l2 – 5 2=l–5 ⇒ l=7 x yx = 7(2 ) – 5 This satisfy both the difference equation (1) and the initial condition (3).
Example 4. Solve: 2yx + 1 – yx = 4, x = 0, 1, 2, ……(1) Solution.
The corresponding homogeneous equation of (1) is 2yx + 1 – yx = 0 1
On comparing it with yx + 1 = Ayx + B, we get A = and B = 0. The solution is given 2 by
y x = λ. A x +
x
B(1 − A x ) 1 1 = λ. + 0 = λ 2 1− A 2
x
For particular solution, we will use hit and trial method. Let us first see whether a constant function will be solution or not. Let yx* = A be a solution of (1), we get 2A – A = 4 ⇒ A=4 1
x
The general solution is given by y x = λ + 4 , x = 0, 1, 2 2
Example 5. Solve: yx + 1 – 2yx = 6. Solution. The corresponding homogeneous equation is
…(1)
yx + 1 – 2yx = 6. On comparing it with yx + 1 = Ayx + B, we get A = 2 and B = 0. Then solution is
y x = λ. A x + B
1 − Ax = λ.2 x + 0 = λ.2 x 1− A
For particular solution, we will use hit and trial method. Let us first try for a constant function. Let yx* = A is solution of the given difference equation, let yx* = A be the solution of equation (1) Then, A – 2A = 6 or A=–6 Hence, the general solution will be yx = l.2x – 6 Example 6. Show that y*x = x is the particular solution of the difference equation
yx + 2 – 3yx + 1 + 2yx = –1 (1)
Also, show that the functions y
and y
…(1) (2)
given by
y(1) x
= 1 and
yx(2)
= 2x
are solution of homogeneous difference equation corresponding to this difference equation and they form a fundamental set. Find the general
solution of the difference equation and two particulars solution for which (i) y0 = 0, y1 = 3, and (ii) y0 = –3, y1 = 5
Difference Equations
641
Solution. Given y*x = x. Therefore y*x + 1 = x + 1, y*x + 2 = x + 2 y*x + 2 – 3y*x + 1 + 2y*x = x + 2 –3(x + 1) + 2x = 3x – 3x + 2 – 3 = –1 Hence, yx* = x is a solution of difference equation (1). The corresponding homogeneous equation is yx + 2 – 3yx + 1 + 2yx = 0 …(2)
x yx(1) = 1, yx(2) = 2 are the solution of equation (2) because they satisfy equation (2).
Now,
y(1) 0
y(2) 0
y1(1)
y1(2)
=
1 1 = 2−1 = 1 ≠ 0 1 2
(2) The function y(1) x and yx form a fundamental set. The general solution is
* (2) yx = C1y(1) x + C2yx + yx
yx = C1(1) + C22x + x Now, y0 = 0 and y1 = 3 [from (i)], we get y0 = C1 + C2 = 0 ⇒ C1 = – C2 y1 = C1 + 2C2 + 1 y1 = –C2 + 2C2 + 1 = 3 ⇒ C2 = 2 and C1 = –2 The particular solution is x yx = –2(1) + 2·2 + x yx = x + 2x + 1 – 2 (ii) If y0 = –3 and y1 = 5, we get
y0 = C1 + C2 = –3
⇒ C1 = – 3 – C2 y1 = C1 + 2C2 + 1 = –3 – C2 + 2C2 + 1 = 5 ⇒ C2 = 7, C1 = –10 Hence, the particular solution is given by x yx = –10 + 7(2 ) + x. Example 7. Show that y*x = x – 2 is the particular solution of the difference equation 2yx + 2 + 3yx + 1 – 2yx = 3x + 1 …(1) 1
x
x (2) Also, show that the functions y(1) and y(2) given by y (1) x = and yx = –2 2
are solutions of the homogeneous difference equation corresponding to the difference equation and they form a fundamental set. Find the general solution of the difference equation and the particular solution satisfying the initial conditions y0 = 0 and y1 = 1. Solution. Since, y*x = x – 2, therefore ⇒ y*x + 1 = x – 1 and y* x+2=x Now, from equation (1), we get 2y*x + 2 + 3y*x + 1 – 2y*x = 2x + 3(x – 1) – 2(x – 2) = 3x + 1 y*x = x – 2 is a particular solution of the difference equation (1). Now, the corresponding homogeneous equation is …(2) 2yx + 2 + 3yx + 1 – 2yx = 0
642
Applied Numerical Analysis 1 2
x
y(1) Given x = , therefore
(1) (1) 2 2 y(1) x + 2 + 3 y x +1 − 2 y x
1 = 2 2
1 1 1 1 1 3 = 2. + 3. − 2 = + − 2 = 0 2 4 2 2 2 2
x +2
1 + 3 2
x +1
1 − 2 2
x
x
1
x
x
x (2) Hence, y(1) x = is a solution of equation (2). Similarly we can show yx = (–2) is 2
also a solution of equation (2). Now,
y(1) 0
y(2) 0
y1(1)
y1(2)
=
1
1
1 / 2 −2
= −2−
1 5 =− ≠0 2 2
(2) The functions y(1) x and yx form a fundamental set. The general solution is (1) * yx = C1yx + C2y(2) x + yx x
1 y x = C1 + C2( −2)x + x − 2 2
Now,
y0 = 0 and y1 = 1, we get y0 = C1 + C2 = 0 ⇒ C1 = –C2 1 2
y1 = C1 + C2( −2) + 1 − 2 =
1
12 2 and C2 = − 5 5
⇒ C1 =
Hence, the particular solution is given by x
yx =
12 1 2 x − ( −2) + x − 2 . 5 2 5
Exercise 14.4 Solve completely the following difference equations : 1. 2yx + 1 – yx = 2 2. yx + 1 + yx = 1 (1) (2) 3. Show that the function y and y given by
x (1) (2) yx = 1 and yx = (–1) are solutions of the difference equation yx + 2 – yx = 0
and they form a fundamental set. Find the general solution of the difference equation and a particular solution for which y0 = 0 and y1 = 2. 4. Solve yx + 1 – 2yx = x + 1. 5. Solve yx + 1 + 5yx = 2x. 6. Solve yx + 1 + 7yx = 2, x = 0, 1, 2. 7. Solve 2yx + 1 – 5yx = 3x + 1.
Answers x
1 1. y x = λ + 2 2. yx = l(–3)x + 2 2 1 1 4. yx = – x – 2 5. y x = λ( −5)x + x − 3 18 1 − Ax 7. y x = A x λ + B 1− A
3. C1 + C2 (–1)x, yx = 1 – (–1)x 6. yx = l(–1)x + 1, x = 0, 1, 2, …
Difference Equations
643
14.12 General Solution of Second Order Homogeneous Difference Equation The second order homogeneous difference equation is given by yx + 2 + a1yx + 1 + a2yx = 0 where a2 g 0.
…(1)
x
Let us suppose yx = m satisfies equation (1), where m (≠ 0) is any constant different from zero. Now, from (1), we get
x+2
m
+ a1mx + 1 + a2mx = 0 2
…(2) ⇒ m + a1m + a2 = 0 x It is auxiliary equation or characteristic equation of (1). If m is a root of (2) then yx = m is a solution of difference equation (1). The auxiliary equation is quadratic algebraic equation. Therefore, it has two non-zero roots say (1) x (2) (x) m1 and m2. Let yx = m1 and yx = m2 be the solutions. There are three cases that arise : (i) The roots m1 and m2 are real and unequal (m1 g m2). (ii) The roots m1 and m2 are real and equal (m1 = m2). (iii) The roots are complex. Case I : The roots are unequal. (1) x (2) x yx = m1 and yx = m2 form a fundamental set. To prove this we will calculate
y(1) 0
y(2) 0
y1(1)
y1(2)
=
1 1 = m2 – m1 g 0 m1 m2
[ m1 g m2]
Hence, m1 and m2 are real and unequal, the general solution of difference equation (1) is given by x x yx = C1m1 + C2m2
Case II : The roots are equal (m1 = m2) (2) Now y(1) x and yx cannot form a fundamental set because m1 = m2, the value of determinant will be zero. (2) (1) We have a function y(1) x but find a function yx which form a fundamental set with function yx .
(2) Now, we claim that a function yx is given as x y(2) x = x m1 Proof. Let m1 and m2 be the roots of second order difference equation, then we have m2 + a1m + a2 = 0 and m1 + m2 = –a1 ⇒ 2m1 + a1 = 0 ( m1 = m2) (2) x Now, we will show that yx = x m1 is a solution of the equation as given below
(2) (2) x +2 y(2) + a1( x + 1)m1x +1 + a2 xm1x x + 2 + a1 y x +1 + a2 y x = ( x + 2)m1
= xm1x [m12 + a1m1 + a2 ] + m1x [2 + a1 ] = 0
x Hence, y(2) x = xm1 is solution of the given equation. x (2) x Now, we will show that y(1) x = m1 , y x = xm1 form a fundamental set, we have
y(1) 0
y(2) 0
y1(1)
y1(2)
=
1 0 = m1 ≠ 0 m1 m1
No root of auxiliary equation is zero. Thus, when m1 = m2, the general solution will be y x = C1m1x + C2 xm1x = m1x (C1 + xC2 )
644
Applied Numerical Analysis
Case III : Complex roots We know that complex roots in quadratic equation always occur in conjugate pairs then m1 g m2. x (2) x Let y(1) x = m1 and y x = m2 form a fundamental set. The general solution is y x = C1m1x + C2m2x …(1) Equation (1) will be complex if m1 and m2 are themselves complex. But if C1 and C2 are complex then yx will be real. Let m1 = a.(cos q + i sin q); m2 = α.(cos θ − i sin θ) C = a(cos B + i sin B) ; C2 = a(cos B − i sin B) and m1x = α x (cos xθ + i sin xθ)
Then
⇒ C1m1x = aα x [(cos( xθ + B) + i sin( xθ + B)] Similarly C2m1x = aα x [(cos( xθ + B) − i sin( xθ + B)] y x = 2aα 2[(cos( xθ + B)] y x = Aα x [(cos( xθ + B)] [2a = A] = α x [ A cos xθ + B sin x θ] We summarize the above result for second order difference equation y x + 2 + a1 y x +1 + a2 y x = 0 Then, A. E is m2 + a1m + a2 = 0. Then solution is y x = C1m1x + C2m2x if m1 g m2 y x = (C1 + C2 x )m1x if m1 = m2 y x = C1α 2 cos( xθ + C2 ) , m1 and m2 are complex.
= α x (C1 cos xθ + C2 sin xθ)
14.13 General Solution of the Homogeneous Difference Equation of Order n The homogenous difference equation of nth order is y x + n + a1 y x + n −1 + a2 y x + n − 2 + ... + an y x = 0 , an g 0 x The auxiliary equation is given by when yx = m
…(1)
m x + a1m x −1 + a2m x − 2 + ... + an = 0 …(2) Solve equation (1). Let m1, m2, …, mn are the n roots. The general solution of the homogeneous difference equation depends upon these roots. There are three cases that arise: Case I : Roots are real and distinct. In this case general solution will be y x = C1m1x + C2m2x + ... + Cnmnx Case II : Roots are Equal. Some roots are repeated. Let root m1 is repeated k times then the general solution is
(C1 + C2 x + C3 x 2 + ... + Ck x k −1 )m1x
Case III : Roots are Complex. Let m1 and m2 are the complex roots, then solution is C1ρ x cos ( xθ + C2 ) or
ρ x (C1 cos x θ + C2 sin xθ) .
Example 1. Solve: yx + 2 – 2yx + 1 + 2yx = 0 Solution.
The corresponding auxiliary equation is 2 x m – 2m + 2 = 0, when yx = m
Difference Equations
645 m=
2± 4 −8 = 1± i 2
In polar form, m = 1 ! i = r(cos q ! i sin q) On equating real and imaginary parts of both sides, we get 1 = r cos q and 1 = r sin q π 4
⇒ ρ = 2 and θ =
Then, solution is y x = C1( 2)x cos
xπ + C2 4
Example 2. Solve the difference equation: yx + 3 – 3yx + 2 – 10yx + 1 + 24yx = 0. Solution. The auxiliary equation, when yx = mx is 3
2
m – 3m – 10m + 24 = 0 ⇒ (m – 2)(m + 3)(m – 4) = 0 m = 2, – 3, 4 Thus, the general solution is
y x = C1 2 x + C2( −3)x + C3 4 x Example 3. Solve the difference equation: yx + 2 – 7yx + 1 + 12yx = 0. x Solution. The auxiliary equation, when yx = m is 2 m – 7m + 12 = 0 ⇒ (m – 3)(m – 4) = 0 m = 3, 4 Thus, solution is yx = C13x + C24x
Example 4. Solve the difference equation : yx + 4 – 4yx + 3 + 6yx + 2 – 4yx + 1 + yx = 0. Solution. When yx = mx, then auxiliary equation is 4
3
2
m – 4m + 6m – 4m + 1 = 0 3 2 ⇒ (m – 1)(m – 3m + 3m – 1) = 0 2 ⇒ (m – 1)(m – 1)(m – 2m + 1) = 0 2 ⇒ (m – 1)(m – 1)(m – 1) = 0 m = 1, 1, 1, 1 Thus, solution is 2 3 x yx = (C1 + C2x + C3x + C4x ).1 .
Example 5. Solve the difference equation : yx + 4 – 8yx + 3 + 18yx + 2 – 27yx = 0. Solution.
The auxiliary equation is 4 3 2 ( yx = mx) m – 8m + 18m – 27 = 0 3 ⇒ (m + 1)(m – 3) = 0 ⇒ m = – 1, 3, 3, 3 x 2 x Thus, the general solution is yx = C1(–1) + (C2 + C3x + C4x )3 . Example 6. Solve the difference equation: yx + 3 + yx + 2 – 8yx + 1 – 12yx = 0. Solution. The auxiliary equation is m3 + m2 – 8m – 12 = 0 (When yx = mx) 2 2 ⇒ (m – 3)(m + 4m + 4) = 0 ⇒ (m – 3)(m + 2) = 0 ⇒ m = 3, –2, –2 Thus, the general solution is y x = C1 3 x + (C2 + C3 x )( −2)x .
Example 7. Solve: 2yx + 2 – 5yx + 1 + 2yx = 0.
(Agra-2006)
Also, find the particular solution satisfying the initial conditions y0 = 0 and y1 = 1.
646
Applied Numerical Analysis
Solution.
The auxiliary equation is 2 2m – 5m + 2 = 0 ⇒
( yx = mx)
(2m – 1)(m – 2) = 0
⇒ 2m – 1 = 0, m = 2 i.e., Thus, solution is
m=
1 ,2 2
x
1 y x = C1 + C2 2 x 2
When x = 0 and x = 1, we get
y0 = C1 + C2 = 0 and
y1 =
2
1 C + 2C2 = 1 2 1
2
Solving these, we get C1 = − and C2 = . Thus, particular solution with these 3 3 conditions is
x
2 1 2 y x = − + 2x . 3 2 3
Example 8. Solve the difference equation yx + 2 + yx = 0 with y0 = 0 and y1 = 1. Solution. When yx = mx, the auxiliary equation is 2 m +1=0
⇒
Thus, the general solution is
m = ± i = cos
π π ± i sin ; 2 2
θ=
π and ρ = 1 2
xπ y x = C1 cos + C2 2
When x = 0 and x = 1, we get
π + C2 = 1 2
y0 = C1 cos C2 = 0 and y1 = C1 cos π
Solving these, we get C1 = –1 and C2 = 2 Hence, the solution is
π xπ y x = − cos ( x + 1) = sin . 2 2
Exercise 14.5 1. Solve the difference equation 9yx + 2 – 6yx + 1 + yx = 0. Also find the particular solution satisfying the initial conditions y0 = 0 and y1 = 1. 2. Solve: yx + 1 – 2yx cos a + yx – 1 = 0. 3. Solve: 3yx + 2 – 6yx + 1 + 7yx = 0.
4. Solve: yx+4 – 4yx + 3 + 8yx + 2 – 8yx + 1 + 4 yx = 0. 5. Solve: yx + 2 + 6yx + 1 + 25yx = 0. 6. Form the Fibonacci difference equation and solve it. (Kurukshetra–2009, Kurukshetra(NIT)–2013)
Answers x
x
1 1 1. General solution is y x = (C1 + C2 x ) and particular solution is y x = 3 x . 3 3 x
2 xπ cos + C2 3. y x = C1 6 3 πx πx + (C3 + C4 x )sin ( 2)x 4. y x = (C1 + C2 x )cos 4 4
2. yx = C1 cos ax + C2sin ax
Difference Equations
647
4 5. y x = C1(5)x cos(θx + C2 ) when θ = tan −1 − 3 x
5 − 5 1 + 5 5 + 5 1 − 5 6. y x = + 10 2 10 2
x
14.14 Particular Solution of the Complete Difference Equation Let yx + 2 + a1yx + 1 + a2yx = f(x) be the given equation, we can find the general solution of the corresponding homogeneous equation. Now, we will find the particular solution. There are many cases for finding particular solution. x
Case I : When f(x) = a , where a is a constant
x
n
n–1
f(E)a = (a0E + a1E
x
+ … + an – 1E + an)a
= a0ax + n + a1ax + n – 1 + … + an – 1ax + 1 + anax
= (a0an + a1an – 1 + … + an – 1a + an) ax = f(a)ax 1 x 1 x a = a provided f(a) g 0. φ( E ) φ(a)
⇒
Case of failure : If f(a) = 0, then f(E) will have any one of the following factor
(E – a) or (E – a)2, etc. or (E – a)n 1 ax = yx E−a
Now, let
⇒ yx + 1 – ayx = ax ⇒
D(a– x yx) = a–1
Similarly, In general
a–(x + 1)yx + 1 – a– xyx = a–1
⇒
yx = xax – 1
⇒ ⇒
or
a–xyx = a–1x
1 a x = xa x −1 E−a 1 x( x − 1) x − 2 ax = a 2 2! ( E − a) 1 ( E − a)n
ax =
x( x − 1)...( x + n − 1) x − n a n!
x
Case II : When f(x) = a F(x), where F(x) is some function of x. Noting that We have
E na x F( x ) = a x + n F( x + n) = a x a n E n F( x ) φ( E ){a x F( x )} = a x (a0a n E n + a1a n −1 E n −1 + ... + an −1aE + an )F( x ) = a x φ(aE )F( x )
The inverse result is
1 1 {a x F( x )} = a x F( x ) φ( E ) φ(aE )
Case III: When f(x) is a polynomial in x of degree r(say) In this case
1 1 f( x) = f ( x ) = φ(1 + ∆ )−1 f ( x ) φ( E ) φ(1 + ∆ )
Here, we expand [φ(1 + ∆ )−1 ] in ascending powers of D and operate on f(x).
648
Applied Numerical Analysis
Example1. Solve the equation : yx + 2 – 3yx + 1 + 2yx = 1. x Solution. On substituting yx = m , the auxiliary equation is
2 m – 3m + 2 = 0 ⇒ (m – 1)(m – 2) = 0, m = 1, 2 The general solution of the reducible homogeneous equation is x yx = C1 + C22
1 1 =− 1x [ f(a) = 0] ( E − 1)( E − 2) ( E − 1)1 x = − 1x −1 = − x 1!
P.I. =
Now,
Hence, the general solution of the complete equation is yx = C1 + C22x – x Example 2. Solve: yx + 2 – 4yx + 1 + 4yx = 3x + 2x + 4. Solution. The auxiliary equation of the given equation is 2 2 m – 4m + 4 = 0 ⇒ (m – 2) = 0, m = 2, 2 Then general solution is x yx = (C1 + C2x)2
Now, particular solution of 3x
1
=
2
=
1 2
3x =
1
E − 4 E + 4 ( E − 2) (3 − 2)2 1 x( x − 1) x − 2 2x = 2 Particular solution of 2x = 2! ( E − 2)2
3x = 3x
Particular solution of 4
=
1 2
( E − 2)
4=4
1 ( E − 2)2
1x = 4
Hence, the complete solution is given by y x = (C1 + C2 x )2 x + 3 x + x( x − 1)2 x − 3 + 4 . Example 3. Solve yx + 2 – 3yx + 1 + 2yx = ax, where a is some constant. Solution. The auxiliary equation of the given equation is m2 – 3m + 2 = 0 ⇒ (m – 1)(m – 2) = 0 ⇒ m = 1, 2 The general solution is given by x yx = C1 + C22
Particular solution of a x =
=
1 ax ( E − 1)( E − 2)
1 a x (provided a g 1 and a g 2) (a − 1)(a − 2)
When a = 1 or a = 2, we will use Case of Failure: x When a = 1, particular solution of a
=
1 1 1 1 1x = − x = − x ax = ax = (1 − 2)( E − 1) 1 ( E − 1)( E − 2) (a − 2)( E − 1)
When a = 2, particular solution of ax
=
1 1 1 ax = 2x = 2x (2 − 1)( E − 2) ( E − 2) ( E − 1)( E − 2)
Difference Equations
=
x.2 x 1 x = x2 2! 2
Hence, the complete solution is given by
649
y x = C1 + C2 2 x +
1 ax (a − 1)(a − 2)
[When a g 1 and a g 2]
y x = C1 + C2 2 x − x and
[When a = 1]
1 y x = C1 + C2 2 x + x 2 x [When a = 2] 2
Example 4. Solve yx + 2 – 4yx + 1 + 3yx = 3x + 1. Solution. The auxiliary equation of the given equation is
2 ⇒ m – 4m + 3 = 0 (m – 1)(m – 3) = 0 ⇒ m = 1, 3 So, the general solution is given by x yx = C1 + C23 The particular solution of 3x + 1
1 1 1 (3 x + 1) = 3x + .1 ( E − 1)( E − 3) ( E − 1)( E − 3) ( E − 1)E − 3) 1 1 1 1 1 1 3x + 1x = x 3 x −1 − x(1)x −1 = x(3 x −1 − 1) = 3−1 E − 3 (1 − 3)( E − 1) 2 2 2 =
Hence, the general solution of the complete equation is
y x = C1 + C2 3 x +
1 x(3 x −1 − 1) 2
Example 5. Solve yx + 2 – 5yx + 1 + 6yx = 2.
Also, find the solution satisfying the initial conditions y0 = 1 and y1 = –1.
Solution.
The auxiliary equation of the given homogeneous equation is m2 – 5m + 6 = 0 ⇒ (m – 3)(m – 2) = 0 ⇒ m = 3, 2 Therefore, the general solution of the homogeneous equation is given by x x yx = C13 + C22
1 1 .1x .2 = 2. ( E − 3)( E − 2) ( E − 3)( E − 2) 1 2 = 2. = =1 (1 − 3)(1 − 2) −2 × −1
Also, Particular solution of 2 =
Hence, the general solution of the complete equation is x x yx = C13 + C22 + 1 When y0 = 1 and y1 = –1, we get y0 = C1 + C2 + 1 = 1 y1 = 3C1 + 2C2 + 1 = –1 We get C1 = –2 and C2 = 2 Hence, the solution is yx = –2.3x + 2x + 1 + 1. 2 Example 6. Solve: Dyx + D yx = sin x. Solution. The given equation in symbolic form can be written as 2 2 {(E – 1) + (E – 1) }yx = sin x ⇒ (E – E)yx = sin x (E – 1)yx + 1 = sin x
(Agra-2000, 09)
650
Applied Numerical Analysis
The auxiliary equation is m – 1 = 0, m = 1 x Then, general solution is yx = C11 = C1
Particular solution of sin x =
1 sin x E −1
1 ix e E −1 1 eix (ei )x = imaginary part of i = imaginary part of E −1 e −1
= imaginary part of
= imaginary part of
= imaginary part of
Hence, the general solution is
(ei − 1)(e − i − 1) ei( x −1) − eix 1 − (ei + e − i ) + 1
=
sin( x − 1) − sin x 2(1 − cos1)
sin( x − 1) − sin x 2(1 − cos1) sin( x − 2) − sin( x − 1) ⇒ y x = C1 + . 2(1 − cos1)
eix (e − i − 1)
y x +1 = C1 +
Example 7. Solve : y x + 2 + y x = sin x
π .…(1) 2
Solution.
The auxiliary equation of the given difference equation is 2 m +1=0 ⇒ m=!i ⇒
xπ y x = C1 cos + C2 2
For particular solution, we will use hit and trial method. Let
π π ± i sin 2 2
Therefore general solution of the reduced equation is
m = cos
y *x = A sin
xπ xπ + B sin 2 2
Substituting this value in equation (1), we get
π π πx πx πx + B sin = sin A sin( x + 2) + B sin( x + 2) + A sin 2 2 2 2 2 πx πx πx πx πx + B sin = sin − A sin − B sin + A sin 2 2 2 2 2 πx 0 = sin 2 xπ xπ y *x = A sin + B cos Hence, fails. 2 2 xπ xπ + Bx cos in equation (1), we get Now, substituting y *x = Ax sin 2 2 xπ xπ xπ π π + Bx cos = sin A( x + 2)sin( x + 2) + B( x + 2)cos( x + 2) − Ax sin 2 2 2 2 2 xπ xπ xπ xπ xπ + Bx sin = sin − A( x + 2)sin − B( x + 2)cos + Ax sin ⇒ 2 2 2 2 2 xπ xπ xπ sin ( −2 A) + cos ( −2 B) = sin ⇒ 2 2 2
Difference Equations
651
On comparing the coefficient of cos
xπ xπ and sin , we get 2 2
–2A = 1, –2B = 0 1 A=− , B=0 2
⇒
Hence, the general solution of the complete equation is given by xπ xπ 1 + C2 − x sin y x = 4 cos . 2 2 2
Example 8. Solve yx + 2 – 7yx + 1 – 8yx = (x2 – x)2x. Solution. The auxiliary equation is 2 m – 7m – 8 = 0 ⇒ m = 8, –1 The general solution is yx = C18x + C2(–1)x
⇒
Particular solution of (x2 – x)2x
1 1 ( x 2 − x )2 x = 2 x ( x2 − x) (2 E )2 − 7(2 E ) − 8) E2 − 7 E − 8 1 1 ( x 2 − x ) = 2 x −1 ( x2 − x) = 2x 2(1 + ∆ )2 − 7(1 + ∆ ) − 8 4 E 2 − 14 E − 8 =
= 2 x −1
=−
1 2∆ 2 − 3∆ − 9
( x2 − x) = −
2 x −1 2∆ 2 − 3∆ 1 − 9 C1
−1
( x2 − x)
2 2 x −1 2∆ 2 − 3∆ 2∆ 2 − 3∆ 1+ + + ... ( x 2 − x ) 9 9 9 2 x −1 2 2 ∆ ∆2 2 =− 1 + ∆ − + ( x − x) 9 9 9 9
=−
2 x −1 ∆ ∆2 2 1 − + ( x − x) 9 9 9
[Neglecting the higher order terms]
D(x2 – x) = {(x + 1)2 – (x + 1)} – (x2 – x) = 2x 2 2 2 D (x – x) = D[D(x – x)] = D(2x) = 2(x + 1) – 2x = 2
− 2 x −1 ∆ ∆2 2 −2 x −1 2 1 1 −2 x −1 (9 x 2 − 11 x − 2) x − x − (2 x ) − (2) = 1 − + ( x − x) = 9 9 9 9 9 9 81
⇒
Hence, the general solution of the complete equation is y x = C1 8 x + C2( −1)x −
2 x −1 (9 x 2 − 11 x − 2) . 81
Example 9. Solve : yx + 2 – 2cos ayx + 1 + yx = cos ax. Solution. The auxiliary equation of the given equation is m2 – 2 cos am + 1 = 0
Now,
2cos α ± (4 cos2 α − 4)2 = cos α ± i sin α 2
m=
C.F. = (1)x[C1cos ax + C2sin ax] = C1 cos ax + C2 sin ax P.I. = =
1
E 2 − 2 E cos α + 1 1 E 2 − E(eiα
⋅ cos αx
eiαx + e − iαx 2 + e − iα ) + 1
(Nagpur–2008)
652
Applied Numerical Analysis 1 1 1 iαx − iαx = ⋅e + ⋅e 2 ( E − eiα )( E − e − iα ) ( E − eiα )( E − e − iα ) (I) (II)
Now, puting e
and e
–ia
in I and II part respectively.
1 1 1 1 1 = ⋅ iα ⋅ eiαx + ⋅ − iα ⋅ e − iαx i α − i α − i α 2E −e e −e E−e e − eiα 1 1 1 = ⋅ eiαx + ⋅ e − iαx 4 i sin α E − eiα E − e − iα 1 iα( x −1) − iα( x −1) = [n ⋅ e − n⋅e ] 4 i sin α n eiα( x −1) − e − iα( x −1) x sin( x − 1)α = = 2sin α 2i 2sin α
ia
Hence, the complete solution is given by y = C.F. + P.I. y = C1 cos αx + C2 sin αx +
x sin( x − 1)α 2sin α
Example 10. Solve: yx + 2 – 2yx + 1 + yx = x2∙2x. Solution. Here, the auxiliary eqn is
(Nagpur–2008)
m2 – 2m + 1 = 0 ⇒ (m – 1)(m – 1) = 0 m = 1, 1 C.F. = (C1 + C2x)1x
P.I. =
Now,
1
2
( E − 1)
⋅ 2x ⋅ x 2 = 2x
1
2
(2 E − 1)
x 2 = 2x
1
(1 + 2∆ )2
x2
= 2x(1 + 2D)–2{x(x – 1) + 2x} = 2x(1 – 4D + 12D2 ...)([x]2 + (x))
x 2 = 2 {(x) + (x) – 4[2(x) + 1] + 12 × 2} = 2x[(x)2 – 7(x) + 20] = 2x(x2 – 8x + 20) Hence, the required solution is y = C1 + C2x + 2x(x2 – 8x + 20)
Exercise 14.6 Solve the following difference equations: x 1. yx + 2 – 4yx + 1 + 4yx = 3x + 2
2
(Meerut-2005, 07; Agra-2009)
2. yx + 2 – 4yx = 9x .
x
3. yx + 3 – 5yx + 2 + 8yx + 1 – 4yx = x2
4. yx + 2 – 6yx + 1 + 9yx = 3x (Kurukshetra(NIT)–2008, VTU–2010) 5. yx + 2 + yx = cos(x/2) (Madras–2001, Kurukshetra(NIT)–2008) x 6. yx + 2 – 5yx + 1 – 6yx = 4 , y0 = 0, y1 = 1. (Madras–2003)
x
7. yx + 2 + 6yx + 1 + 9yx = 2 , y0 = y1 = 0. (VTU–2008)
8. yx + 3 – 3yx + 2 + 3yx + 1 – yx = 1. (Kottayam–2005) 2 9. yx + 3 + yx = x + 1, y0 = y1 = y2 = 0. (Trichirapalli–2001)
x
10. yx + 3–5yx + 2+3yx + 1+9yx =2 + 3x.
2
x
(Nagpur–2009)
–x
11. (4E – 4E + 1)y = 2 + 2
x
(Madras–2001)
12. yx + 2 + 5yx + 1 + 6yx = x + 2 (Nagpur–2006) x
13. yx + 3 + 8yx = (2x + 3)2 2
x
2
(Madras–2005)
14. (E – 5E + 6)yx = 4 (x – x + 5). (Madras–2003)
Difference Equations
653
Answers 20 1. yx = (C1 + C2x)2x + 6 + 3x + x(x – 1)2x – 3 2. y x = C1( −2)x + C2 2 x − 3 x 2 − 4 x − 3 x(3) x −2 x x 1 x −2 (2) − x 2 3. y x = C1 + (C2 + C3 x )2 + 4. y x = (C1 + C2 x )3 + x( x − 1)3 2 6 xπ 1 x −1 1 + cos sec 5. y x = A cos 6. y = C1(–1)x + C2(6)x – 2x/12 2 2 2 2 1 2x 1 x − ( −3)x + 8. y = C1 + C2 x + C3 x 2 + x( x − 1)( x − 2) 7. y = 15 25 25 6 xπ xπ 1 1 3x x x + C3 sin + x( x − 3) 10. y = (C1 + C2 x )(3) + C3( −1)x + (2)x − 9. y = C1( −1) + C2 cos 3 3 2 3 4 11. y = (C1 + C2 x )2− x +
2x 1 + x( x − 1) 2 9
x −1
13. y = C1( −2)x + 2 x (C2 cos x π / 3 + C3 sin x π / 3) + 14. y = C1 ⋅ 2 x + C2 ⋅ 3 x +
12. y = C1( −2)x + C2( −3)x +
x 7 − 12 144
3 (2)x + 2 x − 4 (2 x + 3) 16
4x 2 ( x − 13 x + 61) 2
14.15 Solution of Simultaneous Difference Equations If two or more difference equations are given with the same number of unknown function, we can solve such equations simultaneously.
Example 1. Solve the simultaneous difference equations 2yx + 1 – 3yx + 5zx = 2 2yx + zx + 1 – 2zx = 7 Solution.
We can write these equations in the form of (2E – 3)yx + 5zx = 2 and 2yx + (E – 2)zx = 7 Operate on (1) with (E – 2), on (2) with 5 and subtract to give (2E2 – 7E – 4)yx = (E – 2)z – 35 = –37 (2E + 1)(E – 4)yx = –37
1 The auxiliary equation is (2m + 1)(m – 4) = 0 ⇒ m = − ,4 2
Therefore, general solution of A.E. is y x = C1 − + C2 4 x 2
1
x
Now, Particular solution of –37 1 =
1 ( −37) = ( −37) 1x (2 E + 1)( E − 4) (2 E + 1)( E − 4) 37 1 −37 = − 37 = = (2 + 1)(1 − 4) 3.( −3) 9
Hence, the general solution of complete equation is given by x
37 1 y x = C1 − + C2 4 x + 2 9
…(1) …(2)
…(3)
654
Applied Numerical Analysis Now, we have from (1)
2 1 − (2 E − 3) y x 5 5 1 x 37 2 1 = − (2 E − 3) C1 − + C2 4 x + 5 5 9 2 x +1 3 1 x 2 2 1 37 37 + C1 − + C2 4 x + = − C1 − + C 2 4 x +1 + 5 5 2 9 5 2 9
zx =
x
Hence,
zx =
11 4 1 + − C − C2 4 x . 9 5 2 1
Example 2. Solve the system of equations :
yx + 1 – yx + 2zx + 1 = 0
zx + 1 – zx – 2yx = 2x Solution. The given system of equation can be written as …(1) (E – 1)yx + 2Ezx = 0 x –2yx + (E – 1)zx = 2 …(2) Operating on (1) with E – 1 and (2) with 2E, subtracting, we get 2 x x+1 ((E – 1) + 4E)yx = –2E2 = –22 (E + 1)2yx = – 4.2x…(3) The auxiliary difference equation is (m + 1)2 = 0 m = –1, –1 General solution of the homogeneous equation is x yx = (C1 + C2x) (–1) 1 2x 4 x x 4 2 4 ( − 4.2 ) = − = − = − 2x 2 2 2 9 ( E + 1) ( E + 1) (2 + 1) 1
Also, Particular solution =
Hence, the general solution of the complete equation is
Now,
y x = (C1 + C2 x )( −1)x −
2zx + 1 = yx – yx + 1
4 x 2 9
4 x 4 2 – [C1 + C2( x + 1)( −1)x +1 − 2 x +1 ] 9 9 4 x x = (2C1 + C2 + 2C2 x )( −1) + 2 9 1 2 x x z x +1 = (C1 + C2 + C2 x )( −1) + 2 2 9 C2 2 + C2( x − 1) ( −1)x −1 + 2 x −1 z x = C1 + 2 9 C 1 z x = C1 − 2 + C2 x ( −1)x −1 + 2 x . 2 9
= (C1 + C2 x )( −1)x −
Miscellaneous Exercise
1. Solve the following homogeneous equations : (i) yx + 3 – 2yx + 2 – yx + 1 + 2yx = 0 (ii) yx + 2 – yx = 0 (iii) yx + 2 + 2yx + 1 + yx = 0
(iv) yx + 4 + yx + 3 – 13yx + 2 – yx + 1 + 12yx = 0 (v) yx + 2 + 8yx + 1 + 16yx = 0 (vi) yx + 2 – 5yx + 1 + 6yx = 0
Difference Equations
655
(vii) yx + 2 + 2yx + 1 + 7yx = 0
(viii) yx + 2 – 3yx + 1 + 2yx = 0 (ix) yx + 2 + 3yx + 1 + yx = 0
2
(xii) (E – 5E + 6)yx = x , y0 = 1, y(1) = –1 2
(xiii) yx + 2 – 5yx + 1 + 6yx = x – 1 (xiv) D2yx + 2Dyx + yx = 3x + 2
(x) yx + 4 – 9yx + 3 + 30yx + 2 – 44yx + 1
(Kurukshetra–2012) 2
+ 24yx = 0
(xi) 2yx + 3 – 7yx + 2 + 5yx + 1 + 2yx = 0 (xii) yx + 4 + yx = 0 (xiii) yx + 2 – yx + 1 + yx = 0 given y0 = 1 and 1+ 3 y1 = 2 (xiv) 3yx + 2 – 7yx + 1 – 6yx = 0, y0 = 0, y1 = 1 (xv) 9yx + 2 + 72yx + 1 + 79yx = 0, y0 = 1, y1 = –7 (xvi) yx + 2 – 5yx + 1 + 6yx = 0, y0 = 1, y1 = 2 2. Solve the following difference equations (i) yx + 2 – 6yx + 1 + 8yx = 4x
(xv) Dyx + D2yx = cos x (xvi) yx + 2 + yx + 1 + 2yx = 3x – 10 (xvii) yx + 2 – 4yx = 9x2 (xviii) yx + 1 – yx2 = y3x + 1, if y1 = 1, y2 = 2 3. What do you understand by linear difference equation of the nth order? (1) (2) 4. If y and y constitute a fundamental set for
2 yx +2 + a1 yx +1 + a yx = 0, x = 0, 1, 2, …, prove that a necessary and sufficient
condition (1)
for (2)
a1y
(1)
+
b1y(2)
and
(ii) yx + 2 – 2yx + 1 + yx = 5 + 3x (iii) yx + 2 – 3yx + 1 + 2yx = 1, y0 = 1, y1 = –1
+ b2y to be a fundamental set is a1b2 – a2b1 g 0. 5. If ux and vx are the solutions of the homogeneous difference equation y(x + 2) + p(x)y(x + 1) + q(x)y(x) = 0, then C1ux +
(viii) yx + 3 – 3yx + 1 + 2yx = 3x (ix) yx + 2 – yx + 1 + 1/2 yx = 1, y0 = 2, y1 = 3
C2vx is also a solution of the above equation. 6. Solve the following systems of simultaneous equations: (i) 2xt + 1 – 3xt + 5yt = 2 2xt + yt + 1 – 2yt = 7 (ii) xt + 1 – yt = 2(t + 1) yt + 1 – yt = – 2(t + 1) (iii) 2xt + 1 + yt + 1 = xt + 3yt xt + 1 + yt + 1 = xt + yt
(iv) yx + 2 – 3yx + 1 + 2yx = 5x + 2x x (v) 8yx + 2 – 6yx + 1 + yx = 2 xπ (vi) 8 y x + 2 − 6 y x +1 + y x = 5sin 2 (vii) yx + 2 – 4yx + 1 + 7yx = 3.2x + 5yx
(x) yx + 2 – 4yx + 1 + 3yx = 2x + 3x + 7
(xi) yx + 2 – 5yx + 1 + 6yx = x2 + x + 1
a2y
Answers x
x
1. (i) yx = C1 + C2(–1) + C32
(ii) yx = C1 + C2(–1)x (iii) yx = (C1 + C2x)(–1)x
(iv) yx = C1 + C2 (–1)x + C33x + C4(–4)x (v) yx = (C1 + C2x)(–4)x (vi) yx = C13x + C22x 2nπ 2nπ x x + C2 sin (vii) y x = C1 cos 2 (viii) yx = C1 + C22 3 3 x x −3 + 5 −3 − 5 + C2 (ix) y x = C1 (x) yx = (C1 + C2x + C3x2)2x + C4(–3)x 2 2 x x 3 + 17 3 − 17 x + C3 (xi) y x = C1 2 + C2 2 2 nπ nπ 3π πx x + C2 + C3 cos + sin + C4 (xiii) y x = cos (xii) y x = C1 cos 4 4 3 3 x
x
x
3 3 7 y x = 3 x − (xvi) (xiv) y x = C1 + C2 (xv) yx = 3x – 2x + 1 3 11 11 x x3 2. (i) y x = C1 2 x + C2 4 x + 4 x (ii) y x = (C1 + C2 x ) + x 2 + (iii) yx = 1 – 2x 8 2
656
Applied Numerical Analysis
(iv) y = C1 + C2 2 x +
− x 2x
x
x
1 x 1 1 2 (v) y x = C1 + C2 + 4 2 21
12 x x 5 πx 1 1 (vi) y x = C1 + C2 + sin (vii) yx = (C1 + C2x)2x + 3x(x – 1)2x – 3 + 5.4x – 1 4 2 3 2 1 πx π + +2 (viii) y x = C1 + C2 2 x + 3 x (ix) y x = − (2)x /2 cos 4 2 2 x 7x 1 y x = C1 2 x + C2 3 x + (2 x 2 + 8 x + 15) (x) y x = C1 + C2 3 x − 2 x + 3 x −1 − (xi) 4 2 2 3 x2 x+2 x+1 x x (xii) yx = 2 –3 (xiii) y x = C1 2 + C2 3 + 2 + x + 2 2 1 20 x x x x x 2 x 3 (xv) y x = C1 2 + C2( −2) − (3 x + 3 x + ) (xvi) yx = 22x – 1 – 1 (xiv) y x = C1 3 + C2( −4) − 1 + 21 3 t
t
37 4 1 11 1 , yt = − C1 4 t + − C2 + 6. (i) xt = −C1 4 t + C2 − + 2 5 2 9 9 (ii) xt = C1 + C2(–1)t + t, yt = C1 – C2(–1)t + (t + 1) (iii) xt = C1( −2)t + C2 , yt = −C1( −2)t +
C2 2
MULTIPLE CHOICE QUESTIONS (CHOOSE THE MOST APPROPRIATE ONE) 1. The equation involving the values of a function and their differences is called : (a) differential equation (b) difference equation (c) integral equation (d) none of these 2. The difference between the largest and smallest arguments for the function y involved in the equation is called : (a) order (b) degree (c) power (d) none of these 3. A solution of a difference equation of order n is called general solution if it involved : (a) exactly n arbitrary constants (b) at least n arbitrary constants (c) at most n arbitrary constants (d) none of these 4. The solution obtained by assuming particular values to the arbitrary constant is called : (a) general solution (b) singular solution (c) particular solution (d) none of these 5. The linear difference equation of order n over a set of consecutive integral values has : (a) unique solution (b) at least one solution (c) at most one solution
(d) none of these 6. The solution of the equation yh + 1 = yh + C is : (a) y0 (b) y0 + C (c) both (a) and (b) are true (d) none of these 7. The linear combination of two solutions of a given difference equation is : (a) also the solution of the given equation (b) not the solution of the given equation (c) may or may not be the solution (d) none of these
(1)
(2)
(n)
8. The solution y , y , ..., y are said to th form a fundamental set of solutions if n order determinant is : (a) = 0 (b) g 0 (c) g 1 (d) none of these 9. If the roots m1, m2 of auxilliary equation are real and unequal then general solution is given by :
(a) y h = C1m1h + C2m2h (b) y h = (C1 + C2 )m1h (c) y h = (C1 + C2 )m2h (d) none of these
Difference Equations
657
h
10. If R(h) = b , then particular solution is given by : 1 h b , φ(b) ≠ 0 (a) φ( E )
(b)
bh , φ(b) ≠ 0 φ(b)
(c) both (a) and (b) are true (d) none of these 11. If R(h) = P(h) a polynomial of degree m then particular solution is given by : 1 P( h) (a) φ(1 + ∆ ) 1 P( h) (b) φ( ∆ ) (c) both (a) and (b) are true (d) none of these 12. The generating function of the constant sequence 1, 1, 1, ... is given by : 1 (a) (1 – t) (b) 1−t 1 (c) (d) none of these 1+ t 13. The generating function of the sequence {h} is given by : t (a) (1 – t) (b) 1−t t (c) (d) none of these (1 − t )2 14. The generating function of the sequence {1 + h} is given by : 1 (a) (1 – t) (b) (1 − t )2
t (c) (d) none of these (1 − t )2 h 15. The generating function of the sequence {B } is given by : 1 (a) (1 – bt) (b) 1 − βt 1 (c) (d) none of these 1 + βt 16. The generating function for the general term yh + 1 is : y(t ) − y0 (a) y(t) (b) t y(t ) + y0 (c) (d) none of these t 17. If the general term is yh + 2, then generating function is given by : y(t ) − y0 y(t ) − y0 − y1(t ) (b) (a) 2 t t2 y(t ) − y1(t ) (c) (d) none of these t2 18. The order of the difference equation 2 D yh + 3Dyh – 3yh = h is : (a) 2 (b) 3 (c) 1 (d) 4 19. The order of the difference equation 3 2 D yh + D yh + Dyh + yh = 0 is : (a) 1 (b) 2 (c) 3 (d) 4 1 20. For which equation y h = h( h − 1) is the 2 solution : yh + 1 – yh = h (a) yh + 1 + yh = h (b) (c) yh – 1 – yh = h (d) none of these
Answers 1. (b) 2. (a) 10. (c) 11. (a) 19. (b) 20. (b)
3. (a) 12. (b)
4. (c) 13. (c)
5. (a) 14. (b)
6. (b) 15. (b)
7. (a) 16. (b)
8. (b) 17. (b)
9. (a) 18. (a)
ARCHIVE 1. Solve: yx+1–ayx = 0, a ≠1. (Rohilkhand-2006; Agra-2003, 06) x
2. Solve: yx+1–byx=ca b where c is a periodic function of period 1, when (a) b≠a (b) b = a.
(Rohilkhand-2008, 10; Agra-2005, 08)
3. Show that yx+2– 4yx+1+4yx = 0 ...(i) (x=0, 1, ....) has the solution. (Agra-2005, 07, 10)
4. Solve: yx+2–4yx+1 +13yx =0. (Agra-2008, 09) 5. Find the particular solution of yx+2 – 6yx+1+8yx = 0, such that y0 =3, y1 = 2. Also obtain y5. (Agra-2007) 2
6. Solve: yx+3 + yx+2–8yx+1–12yx = 2x + 5.
(Bhopal-2002; Agra-2007)
658
Applied Numerical Analysis x
7. Solve: yx+2 + yx+1 + yx = x. 2 . (Agra-2001, 07) 2
8. Solve: yx+2 – 5yx+1 + 6yx = x , by the method of variation of parameters. (Agra-2006) 2x
2 x2
9. Solve: yx+1 – e yx = 3x e
+x (1/6) (Agra-2002, 07)
10. Solve: yx+1 – ayx = cos nx.
(Bhopal-2002)
11. Solve the following equation:
yx+4 –5yx+3+9yx+2+7yx+1+2yx = 0. (Agra-2003)
12. Solve the following equations : x
(a) yx+1 – 3yx = 2 (Garhwal-2006) (b) yx+2 – 2myx+1 + (m2+ n2) yx = mx.
(c) yx+2 –5yx+2 + 8yx+1 – 4yx = x. 2
x
(Agra-2009)
(Gwalior - 2008)
13. Solve yx+3 – 6yx+2 + 11yx+1–6yx = 0 subject to the given condition y0 = 1, y1= 1, y2= 1. (Gwalior-2001, 05) 14. Solve the following difference equation: yx+1+ 3yx = 0, y0 = 2.
Answers bca x (b) yx = xcax a−b 3 4. y x = (13)x /2[C1 cos( xθ) + C2 sin( xθ)] where θ = tan −1 2 1. yx = Cax
2. (a) y x =
6. y x = [C1 3 x + (C2 + C3 x )( −2)x ] −
x2 x 17 + − 9 27 54
2x 10 8. y x = x − 7 7 2 2 3 yx = 9. y x = Ce x − x +(1/6) + e x − x +(1/6) + {( x )3 + x(2)} 10. 2 2 x 11. yx = C1 + C2x + C3x + C4(2) 7. y x = C1 cos xθ + C2 sin xθ +
12. (a) y0 = (a. 3x –2x)
5. –1888
3 x x 1 2 3 C1 2 + C2 3 + 2 x + 2 k + 2 cos(n − 1) x − a cos nx + c( x )a x 1 − 2a cos n + a 2
(b) yx = a1(–4)x + [(5x –6)/25]
x x x (3) (c) yx = C1(1) +(C2+C3x)2 + [2 x /24]. x x 13. yx = 5. 2 – 2.3 –3
14. yx = 2(–3)x
qqqq
Computer Arithmetic and Errors
659
1. Anita, H.M
1991
Numerical Methods for Scientists and Engineers,
2. Balagurusamy, E.
1999
Numerical Methods
TATA McGraw-Hill Publishing Company New Delhi. Tata McGraw-Hill, New Delhi. 3. Bradie, B
2007 A friendly introduction to Numerical Analysis, Pearson Prantice Hall, New Delhi,
4. Bunchanan, J.L.
1992
and P.R. Turner 5. Chapra, S.C. and
McGraw-Hill book company 1989
Canale, R.P. 6. Conte, S.D. and Carl
1981 Elementary Numerical Analysis, 3rd Edition McGraw-Hill Book Company, 1994
Wheatly. P.O. 8. Grewal, B.S.
Numerical Methods for Engineers, McGraw-Hill Book Company.
De Boor 7. Gerald, C.F. and
Numerical Methods and Analysis
Applied Numerical Analysis, Addison-Wesley Publishing Company.
2004
Numerical Methods in Engineering and Science Khanna Publishers.
9. Jain, M.K; Iyengar
2003
S.R.K and Jain R.K.
Numerical Methods for scientific and Engineering Computation New Age International publisher, India.
10. Mathews, J.H.
1944
Numerical Methods for Mathematics, Science and Engineering, 2nd Edition Prentice-Hall of India
11. Pearson, C.E.
1986
Numerical Methods for Engineering and Science Van Nostrand Rainhold, New-York.
12. Pundir, S.K.
2017
Numerical Methods in Science and Engineering, CBS Publishers and Distributors (Pvt.) Ltd., New Delhi
13. Salvadori, M.G. and
1961
Baron, M.L. 14. Schultz, M.H.
Numerical Methods in Engineering Prentice Hall, Englewood Cliffs, N.J.
1973
Spline Analysis, PHI Eaglewood Clifffs, N.J.
15. Young, D.
1971
16. Williamson, J.H.
1965
Iterative solutions of large linear systems, Academic Press, New York. The Algebraic Eigenvalue problems, Oxford University press, Oxford.
qqqq
Computer Arithmetic and Errors
A Accuracy of numbers 13 Adams-Bashforth 463, 510, 511 Angle between two lines of regression 582 Application of error formula to the fundamental operations of arithmetics 37
B Base conversion 3 Bessel’s difference formula 120 Binary arithmetic 11 Birge-Vieta method 297, 298, 300, 301, 302, 303, 306 Bisection method 250, 257, 258, 260, 269, 332, Blunders48
C Central differences interpolation formulae 117 Chebychev’s formula 225, 226, 228, 229, 241, 242 Chebyshev polynomial approximations 613 Choleski’s method 389, 390, 391, 392, 393, 394, 403, 404 Classification of partial differential equations 518 Complex roots 249, 306, 313, 320, 322, 326, 330, 332, 644 Computer software 51 Computer storage 29 Concept of normalized floating point 30, 31 Continuous frequency distribution 552 Convergence of a method 513 Crank-Nicholson method 531, 532, 534, 535, 537, 546 Crout’s method 353, 355, 356, 357, 370, 371, 372 Crout’s method 386, 387, 388, 394, 403, 404, 462 Curve fitting 96, 554, 571, 597 Curve fitting by sum of exponentials 571
D Deductions from Newton-Cote’s formula 215 Degree of difference equation 626 Derivative using Newton’s divided difference formula 169 Derivative using Newton’s forward interpolation 165 Derivatives using Newton’s backward difference formula166 Derivatives using Stirling’s formula 167
661
Difference equation as a relation among the value of yx 625 Difference quotients 517 Difference schemes 53 Differences between divided difference and ordinary difference 82 Differences of zero 80 Divided difference 133 Divided difference 81, 82, 83, 84, 135, 157, 163, 165, 169, 178, 179, 248 Dufort and Frankel’s method 532, 549
E Eigen values and eigen vectors 405, 436, 462 Eigenvalues of special type of matrices 407 Elliptic equations 519, 529 Error analysis 16, 185, 511 Error analysis in numerical differentiation 185 Error in a series approximation 35 Error in determinants 36 Error in higher order derivatives 186 Errors and their analysis 16 Euler’s method 465, 466, 467, 468, 469, 470, 471, 484, 485, 511, 513, 514, 515, 516 Euler’s modified method 468, 469, 470, 473, 483, 484, 516 Everett’s difference formula 121 Existence and uniqueness of solution of differential equation 463 Existence and uniqueness theorem 629, 633 Existence of solution 338
F Factorial notation 72, 73, 74, 75, 77 Finite difference calculus 96 Fitting a polynomial function 588 Fitting of some special curves 558 Floating point arithmetic and errors 28 Fundamental theorem of difference calculus 59
G Gauss elimination method340, 344, 345, 347, 372, 576 Gauss’s quadrature formula 220, 224, 225 Gauss-Jordan method 372, 373, 378, 379
Applied Numerical Analysis
662 General solution of second order homogeneous difference equation 643 General solution of the homogeneous difference equation of order n644 Given’s method 444, 445, 446, 451, 460 Graeffe’s root square method 320 Gram-Schmidt orthogonalizing process 607 Graphical representation 50, 465, 552
H Hermite’s interpolation formula Higher order rules House holder’s method Hyperbolic equation
158, 159, 161 229 448, 449, 451 540
I Interpolation 135, 161, 192, 213, 235, 238, 270, 333, 497, 508 Inverse power method 432 Inversion of complex matrices 401 Iteration method 261, 262, 263, 265, 269, 333 Iterative method 437, 445, 532, 549 Iterative method for the system of non-linear equations 268
J Jacobi’s method Jordan’s method
371, 441, 444, 451, 460 351, 352, 370, 404
L Lagrange’s interpolation formula 143, 144, 145, 147, 148, 150, 152, 153, 165, 238 Lanczos economization of power series for a general function 614 Legendre and Chebyshev polynomials 608 Lin-Bairstow’s method 313, 317 Linear difference equation628, 629, 633, 634, 655, 656 Linear equations 268, 340, 358, 372 Linear homogeneous equation with constant coefficients 637 Linearly independent solution or fundamental set of solutions 638 LU decomposition method or method of factorization 346
M Machine computations 49 Maxima and minima of tabulated function 169 Method of curve-fitting 558 Method of least squares 554, 555, 557, 567, 568, 570, 573, 598
Method of separation of symbols 65 Methods of interpolation 95 Methods of solution 250 Milne’s methods 497 Muller’s method 308, 309, 311, 312, 331 Multiple linear regression 594, 596, 597
N Newton’s divided difference formula 135, 136, 137, 138, 139, 140, 141, 143 Newton’s method for complex roots 306 Newton-Cote’s formula 212, 213, 215, 216, 219, 220 Newton-Raphson’s method 283, 285, 288, 289, 291, 330, 335 Non-linear regression 590 Number system 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 Numerical evaluation of the singular integral 234 Numerical instability 48 Numerical quadrature 192, 235
O Order of approximations Order of difference equation
44 625
P Parabolic equations 529 Picard’s method of successive approximations 477 Pitfalls of floating point representation 30 Power method 426, 427, 428, 429, 432, 433, 437, 460, 461 Propagation of error 45, 46 Properties of Cote’s numbers 214 Properties of regression coefficients 581 Properties of the equations and its roots 249
Q Quadrature formula for equally spaced arguments 192 Quotient-Difference method 326, 331
R Rational approximation 597, 614, 621, 622 Regression analysis 579, 593, 594 Regression analysis of grouped data 594 Relation between eigenvalues and eigenvectors 406 Rounding off error 23, 370 Runge-Kutta method 484, 496, 507, 513, 514, 515 Rutishauser method 434, 435
S Secant method
278, 279, 282, 283, 309, 333, 334
Computer Arithmetic and Errors Simplified determination of regression analysis 593 Simpson’s 1/3 rule 165, 197, 198, 202, 216, 240, 241, 243, 244, 245, 247 Simpson’s 3/8 rule 198, 199, 200, 205, 217, 243, 245, 247 Simultaneous differential equations 492 Solution as sequences 634 Solution by Bender-Schmidt’s method 530 Solution by forward difference method 529 Solution by Taylor series 473 Solution of difference equation 626, 641, 643 Solution of second order differential equations 493 Solution of simultaneous difference equations 653 Solution of two-dimensional heat equation: ADE method538 Spline function 574, 575, 576, 598
663 Stability analysis Stirling’s difference formula
513 119
T The Cayley-Hamilton theorem 452 The general formula for errors 26 The Trapezoidal rule 192, 193, 215, 236, 242, 246, 247 Triangularisation method 379, 380, 382, 385, 394 Truncation error 145, 165, 185, 186 Types of approximations 601, 602
U Uniform Approximation Use of orthogonal functions
612, 613, 614, 622, 623 606, 607
W Weddle’s rule 207, 208, 209, 210, 211, 212, 241, 242, 243, 244, 245
qqqq
Applied
Numerical Analysis is an introductory text aimed at undergraduate and postgraduate students of mathematics,
Contents
=• • , .
.
. .
® Finite Difference Operators ® Interpolation with Equal Intervals ® Interpolation with Unequal Intervals ® Numerical Differentiation and Integrations ® Numerical Roots of Polynomial and Transcendental Equations in One Variable ® Numerical Solution of System of Simultaneous Equations
® Eigen Values and Eigen Vectors of a Matrix ® Initial Value Problems of Ordinary Differential Equations ® Initial Value Problems of Partial Differential Equations ® Fitting of Curves and Cubic Splines ® Data Approximation of Functions ® Difference Equations