To come in
Speech therapy portal
  • Bacteria Biology Project
  • Creating a biological pond for wastewater treatment What are the types of biological ponds
  • Types, methods and means of measurement
  • Tips before the exam in the Russian language
  • For these universities, exam alone is not enough
  • What are the compulsory subjects included in the hya
  • Euler's method for solving an ode. Euler's method. Improved Euler method. Classical Runge-Kutta method. Oscillations with one degree of freedom

    Euler's method for solving an ode.  Euler's method.  Improved Euler method. Classical Runge-Kutta method.  Oscillations with one degree of freedom

    Euler's method refers to numerical methods that give a solution in the form of a table of approximate values ​​of the desired function y (x)... It is relatively crude and is used primarily for rough calculations. However, the ideas underlying the Euler method are the starting point for a number of other methods.

    Consider the first-order differential equation

    with the initial condition

    x= x 0 , y(x 0 )= y 0 (3.2)

    It is required to find a solution to the equation on the interval [ but, b].

    We split the segment [ a, b] into n equal parts and obtain the sequence x 0 , x 1 , x 2 , ..., x n where x i = x 0 + ih (i=0,1,…, n), but h=(b- a)/ n- step of integration.

    In Euler's method, the approximate values y (x i +1 ) y i +1 are calculated sequentially by the formulas:

    y i + 1 = at i + hf (x i , y i ) (i = 0,1,2 ...) (3.3)

    In this case, the sought-for integral curve y = y (x) passing through the point M 0 (x 0 , at 0 ), replaced by a broken line M 0 M 1 M 2 with peaks M i (x i , y i ) (i=0,1,2,…); every link M i M i +1 this broken line, called Euler's broken line, has a direction coinciding with the direction of the integral curve of equation (1), which passes through the point M i(see figure 2):

    Figure 2. View of Euler's broken line

    Modified Euler's method more accurate. First, the auxiliary values ​​of the required function are calculated at k + 1/2 in points x k + 1/2, then the value of the right-hand side of equation (3.1) is found at the midpoint y k + 1/2 = f ( xk + 1/2 , y k + 1/2 ) and define at to + :

    Then:
    (3.4)

    Formulas (3.4) are recurrent formulas of the Euler method.

    To estimate the error at the point x to carry out calculations at to with step h, then with a step 2 h and take 1/3 of the difference between these values:

    ,

    Where y (x)- exact solution of the differential equation.

    Euler's method can be easily extended to systems of differential equations and to higher-order differential equations. The latter must be preliminarily brought to the system differential equations first order.

    3.2. Runge-Kutta method

    Runge-Kutta methods have the following properties:

      These methods are one-step: to find at k + 1 need information about the previous point (x to y to )

      The methods agree with the Taylor series up to the terms of the order h p where the degree R is different for different methods and is called a serial number or method order

      They do not require the calculation of the derivatives of f (xy) but require the calculation of the function itself самой

    Runge-Kutta Algorithm third order:

    (3.5)

    Runge-Kutta Algorithm fourth order:

    (3.6)

    Algorithms of the third and fourth orders require three and four calculations of the function at each step, respectively, but they are very accurate.

    3.3. Adams method

    The Adams method refers to multi-step schemes for solving differential equations, characterized by the fact that the solution at the current node depends on the data not in one previous or subsequent grid node, as is the case in one-step methods, but depends on the data in several neighboring nodes.

    The idea behind the Adams methods is to use the values ​​calculated already in the previous steps to improve the accuracy

    Y k -1 , Y k -2 , Y k -3 …

    If values ​​are used in k previous nodes, then we speak of the k-step method of integrating the equation. One way to build multi-step methods is as follows. An interpolation polynomial of degree (k-1) -L k -1 (x) , which is used when integrating the differential equation by the expression:

    In this case, the integral is expressed through the quadrature formula:

    Where λ l - quadrature coefficients.

    The family of formulas obtained in this way is called explicitk -step Adams scheme... As you can see, at k=1 Euler's formula is obtained as a special case.

    For example, for a formula of the 4th order we have:

    (3.7)

    y ( p ) k +1 - “forecast”, calculated using the values ​​at the previous points, f ( p ) k +1 - the approximate value of the function, calculated at the point of obtaining the forecast, y ( c ) k +1 - "correction" of the predicted value, y k +1 Is the required value according to Adams.

    The advantage of this method for solving differential equations is that at each point only one value of the function is calculated F (x, y). The disadvantages include the impossibility of starting the multistep method from a single starting point, since for calculations based on k-step formula requires the value of the function value in k nodes. Therefore it is necessary (k-1) solution at first nodes x 1 , x 2 , ..., x k-1 to obtain with the help of any one-step method, for example, the Runge-Kutta method of the 4th order.

    Another problem is the impossibility of changing the step in the solution process, which is easily implemented in one-step methods.

    4. Brief description of the C ++ program and presentation of the results of its execution

    It is known that ordinary differential equation of the first order has the form: The solution to this equation is a differentiable function, which, when substituted into the equation, turns it into an identity. The graph of the solution to the differential equation (Fig. 1) is called integral curve.

    The derivative at each point can be geometrically interpreted as the tangent of the slope of the tangent to the graph of the solution passing through this point, i.e.:.

    The original equation defines a whole family of solutions. To highlight one solution, set initial condition:, where is some given value of the argument, and - the initial value of the function.

    Cauchy problem is to find a function that satisfies the original equation and the initial condition. Usually, the solution to the Cauchy problem is determined on the segment to the right of the initial value, i.e., for.

    Even for simple first-order differential equations, it is not always possible to obtain an analytical solution. Therefore, numerical solution methods are of great importance. Numerical methods make it possible to determine the approximate values ​​of the desired solution on a certain selected grid of argument values. The points are called mesh nodes, and the value is the grid step. Often considered uniform mesh, for which the step is constant. In this case, the solution is obtained in the form of a table, in which each grid node corresponds to the approximate values ​​of the function at the grid nodes.

    Numerical methods do not allow finding a solution in general view, but they are applicable to a wide class of differential equations.

    Convergence numerical methods solutions to the Cauchy problem. Let be the solution to the Cauchy problem. Let's call error the numerical method is a function given at the grid nodes. Let us take the value as an absolute error.

    The numerical method for solving the Cauchy problem is called converging if for it at. They say that a method has the th order of accuracy, if the error is valid for the estimate, constant,.

    Euler's method

    The simplest method for solving the Cauchy problem is the Euler method. We will solve the Cauchy problem

    on the segment. Let's select steps and build a grid with a system of nodes. The Euler method calculates the approximate values ​​of the function at the grid points: Replacing the derivative with finite differences on the segments ,,, we obtain an approximate equality: ,, which can be rewritten as follows:,.

    These formulas and the initial condition are calculation formulas of the Euler method.

    The geometric interpretation of one step of the Euler method is that the solution on a segment is replaced by a tangent drawn at the points of the integral curve passing through this point. After completing the steps, the unknown integral curve is replaced by a broken line (Euler's broken line).

    Error estimation. To estimate the error of Euler's method, we use the following theorem.

    Theorem. Let the function satisfy the conditions:

    .

    Then the following error estimate is valid for Euler's method: , where is the length of the segment. We see that Euler's method has the first order of accuracy.

    Estimating the error of Euler's method is often difficult, since it requires calculating the derivatives of the function. A rough estimate of the error is given by Runge rule (double counting rule), which is used for various one-step methods that have the -th order of precision. Runge's rule is as follows. Let be the approximations obtained with a step, and be the approximations obtained with a step. Then the approximate equality is true:

    .

    Thus, in order to estimate the error of the one-step method with a step, you need to find the same solution with a step and calculate the value on the right in the last formula, that is. Since the Euler method has the first order of accuracy, that is, the approximate equality has view:.

    Using Runge's rule, one can construct a procedure for the approximate calculation of the solution to the Cauchy problem with a given accuracy . To do this, starting the calculations from a certain step value, sequentially reduce this value by half, each time calculating an approximate value, . Calculations stop when the condition is met:. For Euler's method, this condition will take the form :. An approximate solution will be the values .

    Example 1. Let us find a solution on an interval of the following Cauchy problem:,. Let's take a step. Then.

    The calculation formula of the Euler method is as follows:

    , .

    The solution is presented in the form of table 1:

    Table 1

    The original equation is the Bernoulli equation. Its solution can be found explicitly:.

    To compare the exact and approximate solutions, we present the exact solution in the form of Table 2:

    table 2

    The table shows that the error is

    Definition of the Euler differential equation. Methods of its solution are considered.

    Content

    Euler's 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 is:
    .
    This equation is reduced to a simpler form by substituting t = ax + b, which we will consider.

    Reduction of the Euler differential equation to an equation with constant coefficients.

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

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

    Thus, factors containing x m are canceled. Members with constant coefficients remain. However, in practice, to solve the Euler equations, one can apply methods for solving linear differential equations with constant coefficients without using the above substitution.

    Solving 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 cancel by x k. We get the characteristic equation:
    .
    We solve it and get n roots, which can be complex.

    Consider the real roots. Let k i - multiple root multiplicity m. These m roots correspond to m linearly independent solutions:
    .

    Consider complex roots. They appear in pairs together with complex conjugate ones. Let k i be a multiple root of multiplicity m. Let us 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 have been obtained, we obtain a general solution to equation (2):
    (3) .

    Examples of

    Solve equations:


    Solution examples>>>

    Solution of the inhomogeneous Euler equation

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

    First, we solve homogeneous equation (2) and obtain its general solution (3). Then we consider the constants as functions of the variable x. Differentiate (3) n - 1 time. We get expressions for n - 1 derivatives of y with respect to x. At each differentiation, the terms containing derivatives are equated to zero. So we get n - 1 equations connecting derivatives. Next, we find the nth derivative y. We substitute the obtained derivatives into (1) and obtain the n-th equation connecting 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 the substitution
    ,
    and decide

    Introduction

    When solving scientific and engineering problems, it is often necessary to describe a dynamic system mathematically. This is best done in the form of differential equations ( DU) or a system of differential equations. Most often, such a problem arises when solving problems associated with 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 transformed to a form in which the highest derivative is expressed in an explicit form. This form of writing is called an equation that is resolved with respect to the highest derivative (while the highest derivative is absent on the right side of the equation):

    The solution of 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 the integration of the differential equation.

    Historically, the first and simplest way to numerically solve the Cauchy problem for a first-order ODE is the Euler method. It is based on the approximation of the derivative by the ratio of the 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 increased by using a more accurate integration formula to approximate the integral - trapezoidal formula.

    This formula turns out to be implicit with respect to y i + 1 (this value is on 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 an iterative method (in such form it can be considered as an iterative formula of the simple iteration method).

    The composition of the course work: Course work consists of three parts. In the first part, a brief description of the methods. In the second part, the statement 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

    An equation containing one or more derivatives is called a differential equation. Differential equations fall into two categories depending on the number of independent variables.

      Ordinary Differential Equations (ODE)

      Partial differential equations.

    Ordinary differential equations are those equations that contain one or more derivatives of the desired function. They can be written as

    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

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

    The main problem associated with a linear ODE is known as the Kashi problem:

    Find a solution to equation (2) in the form of a function satisfying 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 construct 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 set 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 ​​graphical construction of the solution of a differential equation, but this method simultaneously provides a way to find the desired function in numerical form or in a table.

    Let equation (2) with the initial condition be given, that is, the Kasha problem is posed. Let us first solve the following problem. 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 to the sought-for integral curve at the point with coordinates

    The tangent equation has the form

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

    Having an approximate solution at a point, you can repeat the previously described procedure: construct a straight line passing through this point with an angular coefficient, and from it 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 small enough, then the resulting approximations 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 required 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 step-by-step. Euler's 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) itself is approximate, that is, the error at each next step increases systematically. The most used method for assessing the accuracy of step-by-step methods for the approximate numerical solution of ODE is the method of double passage of 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 a point), but along the center of the segment. But since the value of the derivative between the points is not calculated, then we go to the double sections of the center, in which the point is, and the equation of the straight line takes the form:

    And formula (5) takes the form

    Formula (7) is applied only for, therefore, values ​​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 formula (5), find the value

    (8)

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

    (9)

    After finding further calculations for is produced according to the formula (7)

    A system of differential equations is called a system of the form

    where x is an independent argument,

    y i - dependent function,

    y i | x = x0 = y i0 - initial conditions.

    Functions y i (x), substitution of which the system of equations turns into identity is called solution by the system of differential equations.

    Numerical methods for solving systems of differential equations.


    Differential equation of the second order is called an equation of the form



    The function y (x), upon substitution of which the equation becomes an identity, is called by solving the differential equation.

    A particular solution of equation (2) is searched numerically, which satisfies the given initial conditions, that is, the Cauchy problem is solved.

    For a numerical solution, a second-order differential equation is transformed into a system of two first-order differential equations and reduced to machine view (3). For this, a new unknown function is introduced, on the left in each equation of the system, only the first derivatives of unknown functions are left, and in the right-hand sides of the derivatives there should not be

    . (3)


    The function f 2 (x, y 1, y) was formally introduced into system (3) so that the methods that will be shown below could be used to solve an arbitrary system of first-order differential equations. Consider several numerical methods for solving system (3). The calculated dependences for i + 1 integration steps are as follows. To solve a system of n equations, the calculation formulas are given above. To solve a system of two equations, it is convenient to write the calculation formulas without double indices in the following form:

    1. Euler's method.

      y 1, i + 1 = y 1, i + hf 1 (x i, y 1, i, y i),

      y i + 1 = y i + hf 2 (x i, y 1, i, y i),

    2. Runge-Kutta method of the fourth order.

      y 1, i + 1 = y 1, i + (m 1 + 2m 2 + 2m 3 + m 4) / 6,

      y i + 1 = y i + (k 1 + 2k 2 + 2k 3 + k 4) / 6,

      m 1 = hf 1 (x i, y 1, i, y i),

      k 1 = hf 2 (x i, y 1, i, y i),

      m 2 = hf 1 (x i + h / 2, y 1, i + m 1/2, y i + k 1/2),

      k 2 = hf 2 (x i + h / 2, y 1, i + m 1/2, y i + k 1/2),

      m 3 = hf 1 (x i + h / 2, y 1, i + m 2/2, y i + k 2/2),

      k 3 = hf 2 (x i + h / 2, y 1, i + m 2/2, y i + k 2/2),

      m 4 = hf 1 (x i + h, y 1, i + m 3, y i + k 3),

      k 4 = hf 2 (x i + h, y 1, i + m 3, y i + k 3),

      where h is the integration step. Initial conditions in numerical integration, they are taken into account at the zero step: i = 0, x = x 0, y 1 = y 10, y = y 0.

    Control task for credit work.

    Oscillations with one degree of freedom

    Purpose. Study of numerical methods for solving second-order differential equations and systems of first-order differential equations.

    The task. Find numerically and analytically:

    1. the law of motion of a material point on a spring x (t),
    2. the law of variation of the current strength I (t) in the oscillatory circuit (RLC - circuit) for the modes specified in Table 1.2. Build graphs of the required functions.

    Job options.


    Mode table



    Job options and mode numbers:

    1. point movement
    2. RLC - circuit


    Let us consider in more detail the procedure for compiling differential equations and reducing them to machine form to describe the movement of a body on a spring and an RLC circuit.


    1. Title, purpose of work and task.
    2. Mathematical description, algorithm (structogram) and program text.
    3. Six graphs of dependence (three exact and three approximate) x (t) or I (t), conclusions on the work.