Numerical Methods for Ordinary Differential Equations with Programs 1783323663, 9781783323661

Differential equations find its applications in all fields of science and engineering because it can describe the modeli

1,681 311 7MB

English Pages 260 [261] Year 2018

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

Numerical Methods for Ordinary Differential Equations with Programs
 1783323663, 9781783323661

Table of contents :
Full title page
Copyright
PREFACE
CONTENTS
LIST OF PROGRAMS
Chapter 1_IVP
Chapter 2_shooting
Chapter 3_FDM
Chapter 4_Control_volume
Chapter 5_CSM
Chapter 6_vari_method
Chapter 7_FEM
Appendix_A
Appendix_B
REFERENCES AND BIBLIOGRAPHY
Index

Citation preview

Numerical Methods for Ordinary Differential Equations with Programs

Ashok Kumar Singh Arvind Kumar Singh

α Alpha Science International Ltd. Oxford, U.K.

Numerical Methods for Ordinary Differential Equations with Programs 260 pgs.

Ashok Kumar Singh Arvind Kumar Singh Department of Mathematics Banaras Hindu University Varanasi Copyright © 2018 ALPHA SCIENCE INTERNATIONAL LTD. 7200 The Quorum, Oxford Business Park North Garsington Road, Oxford OX4 2JZ, U.K. www.alphasci.com ISBN 978-1-78332-366-1 E-ISBN 978-1-78332-441-5 Printed from the camera-ready copy provided by the Authors.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior written permission of the publisher.

PREFACE The study of differential equations started very soon after the invention of the calculus. Sir Isaac Newton in 1676 solved a differential equation by the use of an infinite series. Differential equations have its applications in almost all fields of the Science and Technology because it can describe the modeling of nearly all systems undergoing changes. Due to this fact, it finds a central position in the Science and Technology from which different lines of development extend in many directions. It has also widespread applications in the social sciences. Many mathematicians have studied the nature of these equations and many complicated systems can also be described quite precisely with the help of compact mathematical expressions. However, many systems involving the differential equations are so complex, or the systems that they describe are so large, that a purely mathematical analysis is not possible and we have to seek approximate solution by means of the numerical methods. It is in these complex systems, where the computer simulations and numerical approximations are useful. The techniques for solving the differential equations based on the numerical approximations were developed long before programmable computers existed. It was common to see equations solved in the rooms of people working on the mechanical calculators. As the computers have increased in the speed while decreased in the cost and as a result of which the complex systems of the differential equations can be solved on a common PC. Currently even laptop could compute the long term trajectories of about one million interacting molecules with relative ease, a problem that was inaccessible to the fastest supercomputers just twenty years ago. Every-one knows the benefits from the well known topics such as wave mechanics, theory of heat conduction, solid mechanics, fluid dynamics, electromagnetic and potential theory and we can credit all these benefits due to the differential equations. Further, a great motivating factor for the construction of the computer has been the problem of solving the differential equations occurring in the trajectories of bullets. In fact, whenever a real life problem is solved by means of the mathematical tools, you may find that most of the times it involves the solution of a system of equations and/or differential equations. Their solutions remain a challenging task and for the application purposes, we are using the approximate solutions working satisfactorily enough. Mathematical modeling has been steadily and increasingly spreading in the natural and social sciences over the last few decades. It is now well established in vastly different areas spreading from the physical sciences to the biological sciences, environmental sciences and economics. Depending on the conditions, the numerical solution of a differential equation can be classified into two parts such as the initial value problems and boundary value problems. The numerical methods which are generally used to find the numerical

iv 

Preface

solution of an initial value problem are the Euler method, Euler-Cauchy method, Runge Kutta fourth order method, predictor-corrector method and many others. The numerical methods which are widely used in the numerical solution of boundary value problems are the finite difference method and finite element method. It has been observed that the finite difference method is used for simple (regular) geometry while finite element method can be used to both regular as well as irregular geometries. Numerical analysists have revealed that the finite element method suited well in the fields of solid and structural mechanics. The particular attraction of this method is that the elements may be of arbitrary shapes and can be positioned so as to follow closely the boundary of the interested domain. In the field of fluid dynamics, it has been observed that the finite element method is in general confined to the solution of those problems where diffusion term dominates compared to convective term i.e., when the flow formation is at small Reynolds number. There are also other methods such as the shooting method, control volume method, cubic spline method, variational method and many others which are used to solve the boundary value problems. Depending on the boundary conditions, the boundary value problems are classified into three categories which are the first kind, second kind and third kind. This book has seven chapters in which the first chapter provide the methods to obtain the numerical solution of the initial value problems only. In the considered method, both single step methods and multi step methods are discussed. Due to the complexity and wide applications of the numerical solution of the boundary value problems, the numerical solution procedures are described through chapters 2-7. In Chapter 2, the numerical solution of the boundary value problems of all kinds of boundary conditions by the shooting method are given in details. Chapter 3 provides the numerical solution of the boundary value problems of all kinds by the finite difference method. Chapter 4 contains the numerical solution of the boundary value problems of all kinds by the control volume method. Chapter 5 contains the numerical solution of the boundary value problems of all kinds by the cubic spline method. Chapter 6 gives the solution procedure of the boundary value problems by the variational method. Chapter 7 contains the numerical solution of the boundary value problems of all kinds by the finite element method. The problem associated with the numerical methods is its implementation for obtaining the numerical solutions up to desired accuracy because the numerical method is a discrete analysis. The accuracy of the obtained numerical solution can be improved by involving computational procedure at more points and it is not possible by manual computations. Thus, we have to use the computer through an appropriate algorithm and to fulfil this purpose we have also provided the algorithm through programming in C language. Ashok Kumar Singh Arvind Kumar Singh

CONTENTS Preface

iii

Chapter 1. Numerical Methods for Initial Value Problems 1.1 Introduction 1.2 Single Step Methods 1.3 Taylor Series Method 1.4 Picard’s Method 1.5 Euler method 1.6 Modified Euler’s method 1.7 Runge-Kutta method 1.7.1 Second order Runge-Kutta Method 1.7.2 Fourth order Runge-Kutta Method Exercise 1.1 1.8 Predictor-corrector method 1.9 Milne-Simpson Method 1.10 Adams-Bashforth-Moulton Method Exercise 1.2 1.11 System of Simultaneous First Order Differential Equation 1.12 Second Order Initial Value Problem Exercise 1.3

1.1 1.1 1.3 1.4 1.7 1.10 1.14 1.19 1.21 1.22 1.29 1.32 1.32 1.40 1.47 1.50 1.63 1.68

Chapter 2. Solution by Shooting Method 2.1 Introduction 2.2 Converting into two first order initial value problems 2.2.1 Boundary condition of first kind 2.2.2 Boundary condition of second kind 2.2.3 Boundary condition of third kind 2.3. Converting into two second order initial value problems 2.3.1 Boundary condition of first kind 2.3.2 Boundary condition of second kind 2.3.3 Boundary condition of third kind Exercise 2

2.1 2.1 2.1 2.2 2.5 2.6 2.6 2.6 2.11 2.16 2.23

Chapter 3. Solution by Finite Difference Method 3.1 Introduction 3.2 Difference equation of linear differential equation 3.3 Boundary conditions of first kind 3.4 Boundary conditions of second kind 3.5 Boundary conditions of third kind 3.6 Stability of finite difference schemes

3.1 3.1 3.1 3.4 3.8 3.13 3.20

vi  3.7 Convergence of difference schemes 3.8 Fourth order method when first derivative is absent 3.9 Convergence of Numerov method Exercise 3

Contents

3.22 3.25 3.26 3.30

Chapter 4. Solution by Control Volume Method 4.1 Introduction 4.2 Methodology involved in control volume method 4.3 Procedures for control volume formulation 4.3.1 Grid point cluster 4.3.2 Assumption of profile 4.3.3 Discretization of equation 4.3.4 Solution of discretization equation 4.4 Important points of discretization 4.5 Numerical Solution for Boundary condition of first kind 4.6 Numerical Solution for Boundary condition of second kind 4.7 Numerical Solution for Boundary condition of third kind Exercise 4

4.1 4.1 4.2 4.3 4.3 4.3 4.3 4.4 4.5 4.6 4.14 4.20 4.27

Chapter 5. Solution by Cubic Spline Method 5.1 Introduction 5.2 Cubic spline polynomial 5.3 Cubic spline of a second order linear differential equation 5.4 Absent of first derivative in differential equation 5.5 Boundary conditions of first kind 5.6 Boundary conditions of second kind 5.7 Boundary conditions of third kind Exercise 5

5.1 5.1 5.2 5.4 5.7 5.8 5.11 5.15 5.23

Chapter 6. Solution by Variational Methods 6.1 Introduction 6.2 Variational principle 6.3 Ritz Method 6.4 Functional for a differential equation 6.5 Galerkin’s Method 6.6 Collocation Method Exercise 6

6.1 6.1 6.1 6.3 6.5 6.10 6.14 6.16

Chapter 7. Solution by Finite Element Method 7.1 Introduction 7.2 Ritz finite element method 7.3 Galerkin finite element method Exercise 7

7.1 7.1 7.2 7.21 7.42

Appendix A Appendix B References and Bibliography Index

A.1 B.1 R.1 I.1

LIST OF PROGRAMS Program Name of Program

Page No.

1.1

Taylor’s series method

1.6

1.2

Euler’s method

1.13

1.3

Modified Euler’s method

1.17

1.4

Runge-Kutta fourth order method

1.28

1.5

Milne’s Simpson Predictor-Corrector method

1.39

1.6

Adams-Bashforth-Moulton Predictor-Corrector method

1.46

1.7

Runge-Kutta fourth order method for second order initial-value problem

1.62

1.8

Runge-Kutta-Nyström method for second order initial-value problem

1.66

2.1

Shooting method for boundary value problem of first kind by converting into two first order differential equation

2.4

2.2

Shooting method for boundary value problem of first kind by converting into two second order initial value problem

2.9

2.3

Shooting method for boundary value problem of second kind by converting into two second order initial value problem

2.14

2.4

Shooting method for boundary value problem of third kind by converting into two second order initial value problem

2.21

3.1

Finite difference method for boundary value problem of first kind

3.6

3.2

Finite difference method for boundary value problem of second kind

3.12

P.2

viii 

Numerical Methods for Ordinary Differential Equations with Programs

List of Programs

3.3

Finite difference method for boundary value problem of third kind

3.18

3.4

Numerov method for boundary value problem of first kind

3.28

4.1

Control volume method for boundary value problem of first kind

4.12

4.2

Control volume method for boundary value problem of second kind

4.19

4.3

Control volume method for boundary value problem of third kind

4.24

5.1

Cubic spline method for boundary value problem of first kind

5.9

5.2

Cubic spline method for boundary value problem of second kind

5.14

5.3

Cubic spline method for boundary value problem of third kind

5.18

7.1

Ritz finite element method to solve boundary value problem of first kind

7.10

7.2

Ritz finite element method to solve boundary value problem of mixed kind

7.19

7.3

Galerkin finite element problem of first kind

method to solve boundary value

7.27

7.4

Galerkin finite element problem of mixed kind

method to solve boundary value

7.37

Chapter 1

NUMERICAL METHODS FOR INITIAL VALUE PROBLEMS 1.1. INTRODUCTION Numerical method for the ordinary differential equation is a part of numerical analysis which describes the numerical solution of ordinary differential equations (ODEs). This field is also known under the name numerical integration, but some people reserve this term for the computation of integrals. Many differential equations cannot be solved analytically; however, in science and technology, a numerical approximation to the solution is often good enough to solve a problem. The algorithms described here can be used to compute such an approximation. An alternative method is to use techniques from calculus to obtain a solution. Ordinary differential equations occur in many scientific and technological disciplines, for instance in physics, chemistry, biology, civil, mechanical, electrical, chemical and economics. In addition, some methods in the numerical partial differential equations convert the partial differential equation into an ordinary differential equation, which then can be solved. The general analytical solution of a differential equation includes arbitrary constants in a number equal to the order of the equation. If the same number of conditions on the solution is given then these constants can be evaluated. When all the conditions of the given problem are specified at the same point for the independent variable, the problem is termed as an Initial-value problem. If these conditions are given at more than one point for independent variables (usually at the boundaries of the some region of interest) then it is called as a Boundary-value problem. This chapter describes the various techniques for solving the initial-value problems by the numerical methods. With an initial-value problem, the numerical solution begins at the initial point and marches from there to increasing values for the independent variable. A general nonlinear order initial-value problem is given by (

)

(1.1) (1.2)

1.2

Numerical Methods for Ordinary Differential Equations with Programs

Reduction of Higher Order Differential Equations to the System of First Order Differential Equations The order differential Eq. (1.1) with initial conditions given by Eq. (1.2) may be written as an equivalent system of first order initial value problem as follows: Let , , ,

, , , which in vector notation becomes ,

(1.3)

where [ [

] , ] ,

[

] .

Thus the methods for the solution of the first order initial-value problem ,

(1.4)

may be used to solve the system of first order initial-value problem (1.3) and hence the order initial-value problem (1.1). Before attempting to solve a differential equation, we must be sure that there exists a solution and the solution, we get, is unique. This requires that in (1.4) meet, the Lipschitz condition. Let be defined and continuous on the region that contains the point . We assume the region is a closed and bounded rectangle. Then is

1.3

Numerical Methods for Initial value Problems

said to satisfy the Lipschitz condition if there is a we have | | | Theorem 1.1. Assume that constant so that |

|

|

. If there exists a

|

and use mean value theorem to get |

in ,

|

is defined in the region

then satisfies a Lipschitz condition in the variable the rectangle . Proof. Fix

so that for all

|

with Lipschitz constant

with |

over

so that ||

|

|

|

Theorem 1.2. (Existence and Uniqueness) Suppose that is continuous in the { }. If satisfies a Lipschitz condition on region in variable and , then the initial-value problem (1.4) has unique solution on some interval . Proof. See an advanced text on differential equations (such as Theory of Ordinary Differential Equations by E. A. Coddington and Norman Levinson, McGraw-Hill, New York, 1955). We will always assume the existence and uniqueness of the solution of the problems and examples which are considered in this chapter for the numerical solutions by different methods. The methods for the numerical solution of differential equation can be classified into two types, viz. single-step methods and multistep methods. In single-step method the value of depends on the knowledge of the preceding value only. In multistep methods, the value of depends more than one of the preceding values . A method in which depends preceding values only is said to be a -step method. In a -step method the computation cannot be started until and unless the values of are obtained by some other method known as a method of starting the solutions. 1.2. SINGLE STEP METHODS A general single step method for the solution of the initial-value problem (1.4) may be written as ,

(1.5)

where is a function of the arguments and in addition depends on . Here the positive integer, is called the order of the method and the function is called the increment function.

1.4

Numerical Methods for Ordinary Differential Equations with Programs

Neglecting the last term , the approximate values of can be found out by the Eq. (1.5). If can be determined simply by evaluating the right hand side of (1.5), then the single step method is called explicit, otherwise it is called implicit. The error in the approximation is , called as the truncation error. We now determine a few specific forms for the increment function . 1.3. TAYLOR SERIES METHOD Let us consider the differential equation of first order as . Differentiating above with respect to , we get . Similarly

where represent the partial derivatives of with respect to and and so on. The values of can be obtained by putting and . If is the exact solution, then the Taylor’s series for around is given by , which gives the value of for

(1.6)

for every value of for which Eq. (1.6) converges. Let then from Eq. (1.6), we have

After finding the value of for , etc can be evaluated at . Hence can be expended in a Taylor’s series about , and we have

Continuing in this manner, we obtain a discrete set of values approximations to the actual values of at the points Algorithm for Taylor’s series method is as follows:

which are .

1.5

Numerical Methods for Initial value Problems

Divide the interval [ ] into that the step length so that . Hence, we can write

grid points in equally spaced intervals such with and

, where , and the error term is given by . Remark: If is somewhat complicated mathematical expression, then the calculation of higher derivatives becomes tedious, therefore, we cannot apply the Taylor’s series method. This is the major drawback in the application of this method and due to this fact it has few applications for the computer programmes. Example 1.1. Using the Taylor series method, find places if satisfies the initial value problem

correct to four decimal

. Solution. From the Taylor series, we have . Here

. We have ,

, ,

, ,

,

,

, ,

Thus, the Taylor’s series for

.

becomes .

1.6

Numerical Methods for Ordinary Differential Equations with Programs

To obtain the value of correct to four decimal places, it is found that the terms upto should be considered. Therefore, we have . If we want to find the range of values of for which the above series, truncated after the terms containing , can be used to compute the value of correct to four decimal places, then or

.

Numerical Experiment 1.1. Write a program in C to find the numerical solution of initial-value problem . Tabulate the value of for different values of lying in the interval [ ]. The programming in C language by applying the Taylor’s series method is given in the Program 1.1 by using the mathematical expressions of , , , . Program 1.1 /* A program in C-language to solve initial value problem , by using the Taylor’s series method */ #include #include float y1x(float x, float y) { return(1.0+x*y); } float y2x(float x, float y, float y1) { return(y+x*y1); } float y3x(float x, float y1, float y2) { return(2.0*y1+x*y2); } float y4x(float x, float y2, float y3) { return(3.0*y2+x*y3); } float y5x(float x, float y3, float y4) { return(4.0*y3+x*y4); } void main() {

1.7

Numerical Methods for Initial value Problems

float x, x0, y0, h, y[6], cf; int i; printf("Enter the initial values x0 and y0 \n"); scanf("%f%f”,&x0,&y0); printf("Enter the value x at which y is required and size h: "); scanf("%f%f”,&x,&h); printf(“\n y(%5.2f)=%10.6f”,x0,y0); do { y[1]=y1x(x0, y0); y[2]=y2x(x0, y0, y[1]); y[3]=y3x(x0, y[1], y[2]); y[4]=y4x(x0, y[2], y[3]); y[5]=y5x(x0, y[3], y[4]); for(cf=1.0,i=1; i