Biographies Characteristics Analysis

Examples of solving systems of differential equations by numerical methods. Numerical methods for solving differential equations

Introduction

When solving scientific and engineering problems, it is often necessary to mathematically describe any dynamic system. This is best done in the form of differential equations ( DU) or systems of differential equations. Most often, such a problem arises when solving problems related to modeling the kinetics of chemical reactions and various transfer phenomena (heat, mass, momentum) - heat transfer, mixing, drying, adsorption, when describing the movement of macro- and microparticles.

In some cases, the differential equation can be converted to a form in which the highest derivative is expressed explicitly. This form of writing is called an equation resolved with respect to the highest derivative (in this case, the highest derivative is absent on the right side of the equation):

A solution to an ordinary differential equation is a function y(x) that, for any x, satisfies this equation in a certain finite or infinite interval. The process of solving a differential equation is called differential equation integration.

Historically, the first and simplest way to numerically solve the Cauchy problem for first-order ODEs is the Euler method. It is based on the approximation of the derivative by the ratio of finite increments of the dependent (y) and independent (x) variables between the nodes of a uniform grid:

where y i+1 is the required value of the function at the point x i+1 .

The accuracy of the Euler method can be improved if we use a more accurate integration formula to approximate the integral: trapezoid formula.

This formula turns out to be implicit with respect to y i+1 (this value is on both the left and right sides of the expression), that is, it is an equation for y i+1 , which can be solved, for example, numerically, using some iterative method (in such form, it can be considered as an iterative formula of the simple iteration method).

The composition of the course work: The course work consists of three parts. In the first part, a brief description of the methods. In the second part, the formulation and solution of the problem. In the third part - software implementation in the computer language

The purpose of the course work: to study two methods for solving differential equations - the Euler-Cauchy method and the improved Euler method.

1. Theoretical part

Numerical differentiation

A differential equation is one that contains one or more derivatives. Depending on the number of independent variables, differential equations are divided into two categories.

    Ordinary Differential Equations (ODEs)

    Partial Differential Equations.

Ordinary differential equations are called such equations that contain one or more derivatives of the desired function. They can be written in the form

independent variable

The highest order included in equation (1) is called the order of the differential equation.

The simplest (linear) ODE is equation (1) of order resolved with respect to the derivative

A solution to a differential equation (1) is any function that, after substituting it into the equation, turns it into an identity.

The main problem related to the linear ODE is known as the Kashi problem:

Find a solution to equation (2) in the form of a function that satisfies the initial condition (3)

Geometrically, this means that it is required to find the integral curve passing through the point ) when equality (2) is satisfied.

Numerical from the point of view of the Kashi problem means: it is required to build a table of function values ​​that satisfies equation (2) and the initial condition (3) on a segment with a certain step . It is usually assumed that, that is, the initial condition is given at the left end of the segment.

The simplest of the numerical methods for solving a differential equation is the Euler method. It is based on the idea of ​​graphically constructing a solution to a differential equation, but this method also provides a way to find the desired function in numerical form or in a table.

Let the equation (2) be given with the initial condition, that is, the Kashi problem is set. Let's solve the following problem first. Find in the simplest way the approximate value of the solution at some point where is a sufficiently small step. Equation (2) together with the initial condition (3) define the direction of the tangent of the desired integral curve at the point with coordinates

The tangent equation has the form

Moving along this tangent, we obtain the approximate value of the solution at the point :

Having an approximate solution at a point, you can repeat the procedure described earlier: construct a straight line passing through this point with a slope , and use it to find the approximate value of the solution at the point

. Note that this straight line is not tangent to the real integral curve, since the point is not available to us, however, if it is small enough, then the resulting approximate ones will be close to the exact values ​​of the solution.

Continuing this idea, we construct a system of equally spaced points

Getting a table of values ​​of the desired function

according to the Euler method consists in the cyclic application of the formula

Figure 1. Graphical interpretation of the Euler method

Methods for the numerical integration of differential equations, in which solutions are obtained from one node to another, are called stepwise. The Euler method is the simplest representative of step-by-step methods. A feature of any step-by-step method is that, starting from the second step, the initial value in formula (5) is itself approximate, that is, the error at each next step systematically increases. The most used method for estimating the accuracy of step-by-step methods for the approximate numerical solution of ODEs is the method of double passing a given segment with a step and with a step

1.1 Improved Euler method

The main idea of ​​this method: the next value calculated by formula (5) will be more accurate if the value of the derivative, that is, the slope of the straight line replacing the integral curve on the segment, will be calculated not along the left edge (that is, at the point), but along the center of the segment. But since the value of the derivative between the points is not calculated, then let's move on to the double sections of the center, in which the point is, while the equation of the straight line takes the form:

And formula (5) takes the form

Formula (7) is applied only for, therefore, the value cannot be obtained from it, therefore, they are found using the Euler method, while to obtain a more accurate result, they do this: from the beginning, using the formula (5), find the value

(8)

At point and then is found by formula (7) with a step

(9)

After further calculations are found for produced by formula (7)

Lab 1

Numerical methods of solution

ordinary differential equations (4 hours)

When solving many physical and geometric problems, one has to look for an unknown function by a given relation between the unknown function, its derivatives, and independent variables. This ratio is called differential equation , and finding a function that satisfies a differential equation is called solution of a differential equation.

Ordinary differential equation is called equality

, (1)

wherein

is an independent variable changing in some interval , and - unknown function y ( x ) and her first n derivatives. called the order of the equation .

The problem is to find a function y that satisfies equality (1). Moreover, without specifying this separately, we will assume that the desired solution has a certain degree of smoothness necessary for the construction and "legitimate" application of a particular method.

There are two types of ordinary differential equations

Equations without initial conditions

Equations with initial conditions.

Equations without initial conditions are an equation of the form (1).

Equation with initial conditions is an equation of the form (1) in which it is required to find such a function

, which for some satisfies the following conditions: ,

those. at the point

the function and its first derivatives take preassigned values.

Cauchy problems

When studying methods for solving differential equations by approximate methods main task counts Cauchy problem.

Consider the most popular method for solving the Cauchy problem - the Runge-Kutta method. This method makes it possible to construct formulas for calculating an approximate solution of almost any order of accuracy.

Let us derive the formulas of the Runge-Kutta method of the second order of accuracy. To do this, we represent the solution as a piece of the Taylor series, discarding terms with an order higher than the second. Then the approximate value of the desired function at the point x 1 can be written as:

(2)

second derivative y "( x 0 ) can be expressed in terms of the derivative of the function f ( x , y ) , however, in the Runge-Kutta method, instead of the derivative, the difference is used

appropriately choosing the values ​​of the parameters

Then (2) can be rewritten as:

y 1 = y 0 + h [ β f ( x 0 , y 0 ) + α f ( x 0 + γh , y 0 + δh )], (3)

where α , β , γ and δ - some parameters.

Considering the right side of (3) as a function of the argument h , let's break it down in powers h :

y 1 = y 0 +( α + β ) h f ( x 0 , y 0 ) + ah 2 [ γ fx ( x 0 , y 0 ) + δ f y ( x 0 , y 0 )],

and select options α , β , γ and δ so that this expansion is close to (2). Hence it follows that

α + β =1, αγ =0,5, α δ =0,5 f ( x 0 , y 0 ).

Using these equations, we express β , γ and δ via parameters α , we get

y 1 = y 0 + h [(1 - α ) f ( x 0 , y 0 ) + α f ( x 0 +, y 0 + f ( x 0 , y 0 )], (4)

0 < α ≤ 1.

Now if instead of ( x 0 , y 0 ) in (4) substitute ( x 1 , y 1 ), we obtain a formula for calculating y 2 approximate value of the desired function at the point x 2 .

In the general case, the Runge-Kutta method is applied on an arbitrary partition of the segment [ x 0 , X ] on the n parts, i.e. with variable pitch

x 0 , x 1 , …, x n ; h i \u003d x i+1 - x i, x n \u003d X. (5)

Options α choose equal to 1 or 0.5. Let us write down the final calculation formulas of the Runge-Kutta method of the second order with a variable step for α =1:

y i+1 =y i +h i f(x i + , y i + f(x i , y i)), (6.1)

i = 0, 1,…, n -1.

and α =0,5:

yi+1 =yi + , (6.2)

i = 0, 1,…, n -1.

The most used formulas of the Runge-Kutta method are formulas of the fourth order of accuracy:

yi+1 =yi + (k 1 + 2k 2 + 2k 3 + k 4),

k 1 \u003d f (x i, y i), k 2 \u003d f (x i + , y i + k1), (7)

k 3 = f(x i + , y i + k 2), k 4 = f(x i + h, y i + hk 3).

For the Runge-Kutta method, the Runge rule for error estimation is applicable. Let be y ( x ; h ) is the approximate value of the solution at the point x , obtained by formulas (6.1), (6.2) or (7) with a step h , a p order of accuracy of the corresponding formula. Then the error R ( h ) values y ( x ; h ) can be estimated using the approximate value y ( x ; 2 h ) point solutions x , obtained with a step 2 h :

(8)

where p =2 for formulas (6.1) and (6.2) and p =4 for (7).

To solve differential equations, it is necessary to know the value of the dependent variable and its derivatives for some values ​​of the independent variable. If additional conditions are specified for one value of the unknown, i.e. independent variable, then such a problem is called the Cauchy problem. If the initial conditions are given at two or more values ​​of the independent variable, then the problem is called a boundary problem. When solving differential equations of various types, the function whose values ​​you want to determine is calculated in the form of a table.

Classification of numerical methods for solving difr. Lv. types.

The Cauchy problem is one-step: Euler methods, Runge-Kutta methods; – multi-step: Main method, Adams method. A boundary value problem is a method of reducing a boundary value problem to the Cauchy problem; – method of finite differences.

When solving the Cauchy problem, difr. ur. order n or system difr. ur. of the first order from n equations and n additional conditions for its solution. Additional conditions must be specified for the same value of the independent variable. When solving a boundary problem, eq. n-th order or a system of n equations and n additional conditions for two or more values ​​of the independent variable. When solving the Cauchy problem, the desired function is determined discretely in the form of a table with some given step . When determining each next value, you can use information about one previous point. In this case, the methods are called single-step methods, or you can use information about several previous points - multi-step methods.

Ordinary differential ur. Cauchy problem. One step methods. Euler method.

Given: g(x,y)y+h(x,y)=0, y=-h(x,y)/g(x,y)= f(x,y), x 0 , y( x 0)=y 0 . Known: f(x,y), x 0 , y 0 . Determine the discrete solution: x i , y i , i=0,1,…,n. The Euler method is based on the expansion of a function in a Taylor series around the point x 0 . The neighborhood is described by step h. y(x 0 +h)y(x 0)+hy(x 0)+…+ (1). The Euler method takes into account only two terms of the Taylor series. Let us introduce notation. Euler's formula will take the form: y i+1 =y i +y i , y i =hy(x i)=hf(x i ,y i), y i+1 =y i +hf(x i ,y i) (2), i= 0,1,2…, x i+1 = x i +h

Formula (2) is the formula of the simple Euler method.

Geometric interpretation of Euler's formula

To obtain a numerical solution, the f-la of the tangent passing through Eq. tangent: y=y(x 0)+y(x 0)(x-x 0), x=x 1 ,

y 1 \u003d y (x 0) + f (x 0, y 0)  (x-x 0), because

x-x 0 \u003d h, then y 1 \u003d y 0 + hf (x 0, y 0), f (x 0, y 0) \u003d tg £.

Modified Euler Method

Given: y=f(x,y), y(x 0)=y 0 . Known: f(x,y), x 0 , y 0 . Determine: the dependence of y on x in the form of a tabular discrete function: x i , y i , i=0,1,…,n.

Geometric interpretation

1) calculate the slope angle tangent at the starting point

tg £=y(x n ,y n)=f(x n ,y n)

2) Calculate the value  y n+1 on

at the end of the step according to the Euler formula

 y n+1 \u003d y n + f (x n, y n) 3) Calculate the tangent of the slope

tangent at n+1 points: tg £=y(x n+1 ,  y n+1)=f(x n+1 ,  y n+1) 4) Calculate the arithmetic mean of the angles

slope: tg £=½. 5) Using the tangent of the slope angle, we recalculate the value of the function at n+1 points: y n+1 =y n +htg £= y n +½h=y n +½h is the formula of the modified Euler method. It can be shown that the resulting f-la corresponds to the expansion of the f-ii in a Taylor series, including terms (up to h 2). The modified Eilnr method, in contrast to the simple one, is a method of the second order of accuracy, since the error is proportional to h 2 .

Ordinary differential equations are called such equations that contain one or more derivatives of the desired function y=y (x). They can be written in the form

Where x is the independent variable.

The highest order n of the derivative in the equation is called the order of the differential equation.

Methods for solving ordinary differential equations can be divided into the following groups: graphical, analytical, approximate and numerical.

Graphical methods use geometric constructions.

Analytical methods are found in the course of differential equations. For first-order equations (with separable variables, homogeneous, linear, etc.), as well as for some types of higher-order equations (for example, linear with constant coefficients), it is possible to obtain solutions in the form of formulas by analytical transformations.

Approximate methods use various simplifications of the equations themselves by reasonable rejection of some of the terms contained in them, as well as by a special choice of classes of the desired functions.

Numerical methods for solving differential equations are currently the main tool in the study of scientific and technical problems described by differential equations. At the same time, it should be emphasized that these methods are especially effective in combination with the use of modern computers.

The simplest numerical method for solving the Cauchy problem for ODEs is the Euler method. Consider the equation in the vicinity of the nodes (i=1,2,3,…) and replace the derivative on the left side with the right difference. In this case, the values ​​of the function at the nodes will be replaced by the values ​​of the grid function:

The obtained approximation of the DE is of the first order, since an error is allowed when replacing with .

Note that it follows from the equation

Therefore, it is an approximate finding of the value of the function at a point using the expansion in a Taylor series with the rejection of terms of the second and higher orders. In other words, the increment of a function is assumed to be equal to its differential.

Assuming i=0, using the relation we find the value of the grid function at:

The value required here is given by the initial condition, i.e.

Similarly, the values ​​of the grid function at other nodes can be found:

The constructed algorithm is called the Euler method

Figure - 19 Euler Method

The geometric interpretation of the Euler method is given in the figure. The first two steps are shown, i.e. the calculation of the grid function at points is illustrated. The integral curves 0,1,2 describe the exact solutions of the equation. In this case, curve 0 corresponds to the exact solution of the Cauchy problem, since it passes through the starting point A (x 0, y 0). Points B,C are obtained as a result of the numerical solution of the Cauchy problem by the Euler method. Their deviations from curve 0 characterize the error of the method. When performing each step, we actually get to another integral curve. Segment AB is a segment of the tangent to curve 0 at point A, its slope is characterized by the value of the derivative. The error appears because the increment in the value of the function in the transition from x 0 to x 1 is replaced by an increment in the ordinate of the tangent to curve 0 at point A. The tangent BC is already drawn to another integral curve 1. Thus, the error of the Euler method leads to the fact that on each step, the approximate solution passes to another integral curve.

Definition of the Euler differential equation. The methods of its solution are considered.

Content

The Euler differential equation is an equation of the form
a 0 x n y (n) + a 1 x n-1 y (n-1) + ...+ a n- 1 xy′ + a n y = f(x).

In a more general form, the Euler equation has the form:
.
This equation is reduced to a simpler form by substituting t = ax + b, which we will consider.

Reducing the Euler differential equation to an equation with constant coefficients.

Consider the Euler equation:
(1) .
It is reduced to a linear equation with constant coefficients by substitution:
x = e t .
Indeed, then
;
;
;

;
;
..........................

Thus, the factors containing x m cancel out. There are terms with constant coefficients. However, in practice, to solve the Euler equations, it is possible to apply methods for solving linear differential equations with constant coefficients without using the above substitution.

Solution of the homogeneous Euler equation

Consider the homogeneous Euler equation:
(2) .
We are looking for a solution to equation (2) in the form
.
;
;
........................
.
Substitute in (2) and reduce by x k . We get the characteristic equation:
.
We solve it and get n roots, which can be complex.

Consider real roots. Let k i be a multiple root of multiplicity m . These m roots correspond to m linearly independent solutions:
.

Consider complex roots. They appear in pairs together with complex conjugates. Let k i be a multiple root of multiplicity m . We express the complex root k i in terms of the real and imaginary parts:
.
These m roots and m complex conjugate roots correspond to 2 m linearly independent solutions:
;
;
..............................
.

After n linearly independent solutions are obtained, we obtain the general solution of equation (2):
(3) .

Examples

Solve Equations:


Solution of examples > > >

Solution of the inhomogeneous Euler equation

Consider the inhomogeneous Euler equation:
.
The method of variation of constants (Lagrange method) is also applicable to the Euler equations.

First, we solve the homogeneous equation (2) and obtain its general solution (3). Then we consider the constants as functions of the variable x . Differentiate (3) n - 1 once. We get expressions for n - 1 derivatives of y with respect to x. With each differentiation, the terms containing derivatives are equated to zero. So we get n - 1 equations relating derivatives. Next, we find the nth derivative of y . We substitute the obtained derivatives into (1) and obtain the nth equation relating the derivatives . From these equations we determine . After that, integrating, we obtain the general solution of equation (1).

Example

Solve the equation:

Solution > > >

Inhomogeneous Euler equation with a special inhomogeneous part

If the inhomogeneous part has a certain form, then it is easier to obtain a general solution by finding a particular solution to the inhomogeneous equation. This class includes equations of the form:
(4)
,
where are polynomials in degrees and , respectively.

In this case, it is easier to make a substitution
,
and decide