» Lab: Finding the root of a non-linear equation. Methods for solving a system of nonlinear equations. Algebra Separating the roots of a non-linear equation

Lab: Finding the root of a non-linear equation. Methods for solving a system of nonlinear equations. Algebra Separating the roots of a non-linear equation

Mathematics as a science arose in connection with the need to solve practical problems: measurements on the ground, navigation, etc. As a result, mathematics was numerical mathematics and its goal was to obtain a solution in the form of a number. The numerical solution of applied problems has always interested mathematicians. The largest representatives of the past combined in their studies the study of natural phenomena, obtaining their mathematical description, i.e. his mathematical model and his research. The analysis of complicated models required the creation of special, usually numerical methods for solving problems. The names of some of these methods indicate that they were developed by the largest scientists of their time. These are the methods of Newton, Euler, Lobachevsky, Gauss, Chebyshev, Hermite.

The present time is characterized by a sharp expansion of the applications of mathematics, largely associated with the creation and development of computer technology. As a result of the emergence of computers in less than 40 years, the speed of operations has increased from 0.1 operations per second with manual counting to 10 operations per second on modern computers.

The widespread opinion about the omnipotence of modern computers gives rise to the impression that mathematicians have got rid of all the troubles associated with the numerical solution of problems, and the development of new methods for solving them is no longer so significant. In reality, the situation is different, since the needs of evolution, as a rule, set before science tasks that are on the verge of its capabilities. The expansion of the application of mathematics led to the mathematization of various branches of science: chemistry, economics, biology, geology, geography, psychology, medicine, technology, etc.

There are two circumstances that initially led to the desire for the mathematization of sciences:

firstly, only the use of mathematical methods makes it possible to give a quantitative character to the study of one or another phenomenon of the material world;

secondly, and this is the main thing, only the mathematical way of thinking makes an object. This method of research is called a computational experiment - the study is fully objective.

AT recent times there is another factor that has a strong impact on the processes of mathematization of knowledge. it fast development computer facilities. The use of computers for solving scientific, engineering, and applied problems in general is entirely based on their mathematization.

Mathematical models.

Modern technology for the study of complex problems is based on the construction and analysis, usually with the help of a computer, of mathematical models of the problem being studied. Usually, a computational experiment, as we have already seen, consists of a number of stages: setting a problem, building a mathematical model (mathematical formulation of the problem), developing a numerical method, developing an algorithm for implementing a numerical method, developing a program, debugging a program, performing calculations, analyzing results.

So, the use of computers for solving any scientific or engineering problem is inevitably associated with the transition from a real process or phenomenon to its mathematical model. Thus, the use of models in scientific research and engineering practice is the art of mathematical modeling.

A model is usually called a represented or materially realized system that reproduces the main most significant features of a given phenomenon.

The main requirements for the mathematical model are the adequacy of the phenomenon under consideration, i.e. it should adequately reflect character traits phenomena. At the same time, it should have comparative simplicity and accessibility of research.

The mathematical model reflects the dependence between the conditions for the occurrence of the phenomenon under study and its results in certain mathematical constructions. The most commonly used structures are: mathematical concepts Keywords: function, functional, operator, numerical equation, ordinary differential equation, partial differential equation.

Mathematical models can be classified according to different criteria: static and dynamic, concentrated and distributed; deterministic and probabilistic.

Consider the problem of finding the roots of the nonlinear equation

The roots of equation (1) are those values ​​of x that, when substituting, turn it into an identity. Only for the simplest equations it is possible to find a solution in the form of formulas, i.e. analytical form. More often it is necessary to solve equations by approximate methods, the most widespread among which, in connection with the advent of computers, are numerical methods.

The algorithm for finding roots by approximate methods can be divided into two stages. At the first, the location of the roots is studied and their separation is carried out. There is an area in which there is a root of the equation or an initial approximation to the root x 0 . The simplest way The solution to this problem is to study the graph of the function f(x) . In the general case, to solve it, it is necessary to involve all means of mathematical analysis.

The existence on the found interval of at least one root of equation (1) follows from the Bolzano condition:

f(a)*f(b)<0 (2)

It is also assumed that the function f(x) is continuous on the given segment. However, this condition does not answer the question about the number of roots of the equation on a given interval. If the requirement of continuity of the function is supplemented with the requirement of its monotonicity, and this follows from the sign-constancy of the first derivative, then we can assert the existence of a unique root on a given segment.

When localizing roots, it is also important to know the basic properties of this type of equation. For example, recall some properties of algebraic equations:

where are real coefficients.

  • a) An equation of degree n has n roots, among which there can be both real and complex ones. Complex roots form complex conjugate pairs and, therefore, the equation has an even number of such roots. For an odd value of n, there is at least one real root.
  • b) The number of positive real roots is less than or equal to the number of variable signs in the sequence of coefficients. Replacing x with -x in equation (3) allows you to estimate the number of negative roots in the same way.

At the second stage of solving equation (1), using the obtained initial approximation, an iterative process is constructed that makes it possible to refine the value of the root with some predetermined accuracy. The iterative process consists in successive refinement of the initial approximation. Each such step is called an iteration. As a result of the iteration process, a sequence of approximate values ​​of the roots of the equation is found. If this sequence approaches the true value of the root x as n grows, then the iterative process converges. An iterative process is said to converge to at least order m if the following condition is satisfied:

where С>0 is some constant. If m=1 , then one speaks of first-order convergence; m=2 - about quadratic, m=3 - about cubic convergence.

The iterative cycles end if, for a given permissible error, the criteria for absolute or relative deviations are met:

or the smallness of the residual:

This work is devoted to the study of an algorithm for solving nonlinear equations using Newton's method.

There are many different methods for solving nonlinear equations, some of them are presented below:

  • 1)Iteration Method. When solving a non-linear equation by iteration, we use the equation in the form x=f(x). The initial value of the argument x 0 and the accuracy e are given. The first approximation of the solution x 1 is found from the expression x 1 \u003d f (x 0), the second - x 2 \u003d f (x 1), etc. In the general case, the i+1 approximation is found by the formula xi+1 =f(xi). We repeat this procedure until |f(xi)|>e. The condition for the convergence of the iteration method |f"(x)|
  • 2)Newton's method. When solving a nonlinear equation by the Newton method, the initial value of the argument x 0 and the accuracy e are set. Then, at the point (x 0, F (x 0)) we draw a tangent to the graph F (x) and determine the intersection point of the tangent with the abscissa axis x 1. At the point (x 1, F (x 1)) we again build a tangent, find the next approximation of the desired solution x 2, etc. We repeat this procedure until |F(xi)| > e. To determine the point of intersection (i + 1) of the tangent with the abscissa axis, we use the following formula

x i+1 \u003d x i -F (x i) F "(x i).

Convergence condition for the tangent method F(x 0) F""(x)>0, etc.

3). dichotomy method. The solution technique is reduced to the gradual division of the initial uncertainty interval in half according to the formula

C to \u003d a to + in to / 2.

In order to choose the necessary one from the two resulting segments, it is necessary to find the value of the function at the ends of the resulting segments and consider the one on which the function will change its sign, that is, the condition f (a k) * f (in k)<0.

The process of dividing the segment is carried out until the length of the current uncertainty interval is less than the specified accuracy, that is, in k - a k< E. Тогда в качестве приближенного решения уравнения будет точка, соответствующая середине интервала неопределённости.

4). chord method. The idea of ​​the method is that a chord is built on the segment that contracts the ends of the arc of the graph of the function y=f(x), and the point c, the intersection of the chord with the abscissa axis, is considered an approximate value of the root

c = a - (f(a) x (a-b)) / (f(a) - f(b)),

c \u003d b - (f (b) × (a-b)) / (f (a) - f (b)).

The next approximation is sought on the interval or depending on the signs of the function values ​​at points a,b,c

x* O if f(c) H f(a) > 0 ;

x* O if f(c) x f(b)< 0 .

If f "(x) does not change sign to , then denoting c \u003d x 1 and considering a or b as the initial approximation, we get the iterative formulas of the chord method with a fixed right or left point.

x 0 \u003d a, x i + 1 \u003d x i - f (x i) (b-x i) / (f (b) -f (x i), with f "(x) H f "(x)\u003e 0;

x 0 \u003d b, x i + 1 \u003d x i - f (x i) (x i -a) / (f (x i) -f (a), with f "(x) H f "(x)< 0 .

The convergence of the chord method is linear

Algebraic and transcendental equations. Root localization methods.

The most general form of the nonlinear equation:

f(x)=0 (2.1)

where is the function f(x) is defined and continuous on a finite or infinite interval [a, b].

Definition 2.1. Any number that inverts a function f(x) to zero is called the root of equation (2.1).

Definition 2.2. A number is called the root of the k-th multiplicity, if together with the function f(x) its derivatives up to (k-1)-th order inclusive are equal to zero:

Definition 2.3. A single root is called a simple root.

Nonlinear equations with one variable are subdivided into algebraic and transcendental.

Definition 2.4 . Equation (2.1) is called algebraic if the function F(x) is algebraic.

By algebraic transformations, from any algebraic equation, one can obtain an equation in canonical form:

where are the real coefficients of the equation, x is the unknown.

It is known from algebra that every algebraic equation has at least one real or two complex conjugate roots.

Definition 2.5. Equation (2.1) is called transcendental if the function F(x) is not algebraic.

Solving equation (2.1) means:

  • 1. Determine whether the equation has roots.
  • 2. Determine the number of roots of the equation.
  • 3. Find the values ​​of the roots of the equation with a given accuracy.

Equations encountered in practice often cannot be solved analytical methods. Numerical methods are used to solve such equations.

The algorithm for finding the root of an equation using a numerical method consists of two stages:

  • 1) department or localization root, i.e. setting an interval that contains one root:
  • 2) clarification root values ​​by the method of successive approximations.

Root localization methods. Theoretical basis the root separation algorithm is the Cauchy theorem on intermediate values ​​of a continuous function.

Theorem 2.1. If the function y \u003d f (x) is continuous on the segment [a, b] and f (a) \u003d A, f (b) \u003d B, then for any point C lying between A and B, there is a point that.

Consequence. If the function y \u003d f (x) is continuous on the segment [a, b] and takes values ​​of different signs at its ends, then on this segment there is at least one root of the equation f (x) \u003d 0.

Let the domain of definition and continuity of a function be a finite segment [a,b]. Divide the segment into n parts: ,

Calculating sequentially the values ​​of the function at points, we find such segments for which the condition is satisfied:

those. , or, . These segments contain at least one root.

Theorem 2.2. If the function y \u003d f (x) is continuous on the segment [a; b), f (a) f (b)<0 и f`(х) на интервале (а;b) сохраняет знак, то внутри отрезка [а;b] существует единственный корень уравнения f(х) = 0.

To separate the roots, you can also use the graph of the function at= f (X). The roots of equation (2.1) are those values X, at which the graph of the function y=f(x) crosses the x-axis. The construction of a graph of a function, even with low accuracy, usually gives an idea of ​​the location of the roots of equation (2.1). If plotting the function y \u003d f (x) causes difficulty, then the original equation (2.1) should be converted to the form c1(x)= c2(x) so that the graphs of the functions at= c1(x) and at= c2(x) were quite simple. The abscissas of the intersection points of these graphs will be the roots of equation (2.1).

Example 1 Separate the roots of the equation x 2 -2cosx=0.

Solution. Let's consider two ways of separating the roots.

  • a) Graphical way. Let's rewrite the equation in the form x 2 =2cosx and build a graph of the functions y=x 2 and y=2cosx in the same coordinate system (Figure 5). since these graphs intersect at two points, the equation has two roots located symmetrically about the origin on the intervals (-/2; 0) and (0; /2).
  • b) Analytical method. Let f(x)= x 2 -2cosx. Because f(x) is an even function, it suffices to consider only non-negative values ​​of x. Due to the inequality 2cosx2

Derivative f"(x)=2(x+sinx). On the interval (0; /2) f"(x)>0 , therefore, f(x) here monotonically increases and its graph can cross the axis X no more than one point. notice, that f(0)=- 2<0, аf(/2)=(/2) 2>0. This means that the equation has one positive root lying on the interval (0; /2). Since the function is even, the equation also has one negative root, symmetrical to the positive one. Now let's move on to the refinement of the root. To apply the combined root refinement method, you need to make sure that f ""(x) on (0; /2) preserves the sign, and choose the initial approximation of the root for applying the tangent method. It must satisfy the condition: f(x)f ""(x)>0. Because f ""(x)=2(1+cosx) is positive on , then /2 can be taken as the initial approximation of the root in the tangent method. Therefore, one can put x=/21,570796, x 1 =0 (see algorithm diagram). In our case, the chord method will give an approximate value of the root with a disadvantage, and the tangent method - with an excess.

Consider one iterative step of root refinement. Calculate the values f(0), f(/2), f"(/2). New values x 1 and x find, respectively, by the formulas:

|x-x 1 |=0.387680.4>10 -4 =.

The specified accuracy is not achieved, and the calculations must be continued.

Iteration number

x 1

f(x 1 )

|x-x 1 |

Therefore, the approximate value of the root with the required accuracy was found as a result of three iterations and is approximately equal to 1.0217.

Due to the symmetry of the graph of the function f(x) the value of the second root is approximately equal to -1.0217.

Root clarification.

Formulation of the problem . Let us assume that the desired root of equation (2.1) is separated, i.e. segment [a; b], which has one and only one root of the equation. Any point of this segment can be taken as an approximate value of the root. The error of this approximation does not exceed the length [a; b]. Consequently, the problem of finding an approximate value of the root with a given accuracy is reduced to finding the segment [a; b] (b - a<), содержащего только один корень уравнения (2.1). Эту задачу обычно называют задачей root refinements.

Description of numerical methods. Numerical methods make it possible to find solutions to certain problems, knowing in advance that the results obtained will be calculated with a certain error, therefore, for many numerical methods, it is necessary to know in advance the “level of accuracy” that the resulting solution will correspond to.

In this regard, the problem of finding the roots of a polynomial of the form (3.1)

is of particular interest, because the formulas for finding the roots of even a cubic equation are rather complicated. If it is necessary to find the roots of a polynomial whose degree is, for example, 5, then one cannot do without the help of numerical methods, especially since the probability of such a polynomial having natural (or integer, or exact roots with a "short" fractional part) is quite small, and there are no formulas for finding the roots of an equation of degree greater than 4. De facto, all further operations will be reduced to clarification of the roots, whose intervals are approximately known in advance. The easiest way to find these "approximate" roots is to use graphical methods.

To find the roots of a polynomial, there are several numerical methods: the iteration method, the method of chords and tangents, the half division method, the secant method.

Bisection method(also known as the "method of dividing a segment in half") is also recursive, i.e. provides for repetition, taking into account the results obtained.

The essence of the method of half division is as follows:

  • - the function F(x) is given;
  • - the permissible error Q is determined;
  • - some interval [ a , b ] is defined, which exactly contains the solution of the equation.

1) We calculate the value of the coordinate E, taking the middle of the segment, i.e.

E \u003d (a + b) / 2 (3.2)

  • 2) Calculate the values ​​of F(a), F(b), F(E), and perform the following check: If F(E)>Q, then the root is found with the specified accuracy. If F(E)
  • 3) Go to point 1.

Method simple iterations(method of successive approximations). We replace equation (2.1) with an equivalent equation

x=(x) (3.3)

can be done in various ways, for example

x=x+cf(x), c0. (3.4)

Let us assume that some initial approximation of the root of equation (3.3) is chosen. We define a numerical sequence by the formulas

X n+1 =(x n ), n=0,1,2,… (3.5)

Such a sequence is called iterative.

If on the segment containing x 0 and all subsequent approximations x n , nN, the function (x) has a continuous derivative "(x) and |"(x)|q<1, то итерационная последовательность (3.5) сходится к единственному на корню уравнения (3.3). Скорость сходимости определяется неравенством

From this inequality, in particular, it follows that the rate of convergence of the method of simple iteration depends on the value of q: the smaller q, the faster the convergence.

Therefore, in practice, when finding the roots by the method of simple iteration, it is desirable to represent equation (2.1) in the form (3.3) in such a way that the derivative "(x) in the neighborhood of the root is possibly smaller in absolute value. For this, the parameter c from the formula is sometimes used (3.4).

Newton's method (tangent method). If a sufficiently good initial approximation is known for which the following inequality holds:

then you can calculate the only root of the equation using Newton's formula

As an initial approximation, you can use the boundaries of the interval, and:

If on.

At each iteration of this method, the amount of calculations is greater than in the methods of bisections and iterations, since it is necessary to find not only the value of the function, but also its derivative. However, the rate of convergence of Newton's method is much higher.

Theorem. Let be the root of the equation, i.e. , and is continuous. Then there is a neighborhood of the root such that if the initial approximation belongs to this neighborhood, then for Newton's method the sequence of values ​​converges to at. The error of the th approximation of the root can be estimated by the formula:

where is the largest value of the modulus of the second derivative on the segment, is the smallest value of the modulus of the first derivative on the segment.

Stop rule:

Method of chords and tangents (combined). This method is based on constructing a schematic graph of a function, determining the intervals of its intersection with the abscissa axis, and then “compressing” this interval using constructed chords and tangents to the graph of this function.

It should be noted that there are also separately the method of chords (gives the value of the root with a deficiency) and the method of tangents (with an excess). However, the advantage of the combined method lies in the "two-sided compression" of the segment under consideration.

Consider the following case:

  • - the function F(x) is given and its graph is built;
  • - the permissible error Q is determined
  • - on the basis of the graph, a segment is defined on which the graph of the function intersects the abscissa axis, therefore, on this segment there is a root of the polynomial under consideration (we denote it by A)

The further algorithm is reduced to the following actions:

  • 1) we build a tangent to the graph of the function at the point F(b)
  • 2) we calculate the x-coordinate of the intersection of the tangent with the abscissa axis according to the formula (3.9) and denote it by b "
  • 3) we construct a chord to the graph of the function passing through the points F(a) and F(b).
  • 4) We calculate the point of intersection of the chord with the abscissa axis according to the formula (2) and denote it by a".

Thus, we get a new segment , which (according to the definitions of the chord and tangent) still contains the solution of equation A.

Now we take the segment as a new segment and repeat steps 1-4 until the difference F (b) - F (a) becomes less than the initially embedded error Q. We also note that after this it is recommended to take the arithmetic mean F as the desired solution (a) and F(b).

Thus, if the chord (tangent) gives the value of the root with an excess, then this root is taken as the new right boundary, and if with a deficiency, then the left one. In both cases, the exact root lies between the intersection points of the chord and the tangent with the abscissa axis.

Remarks on the method of chords and tangents. Since the solution of the problem requires finding the derivative of the function F(x), the method of chords and tangents is quite difficult to implement at the program level, because the rules for calculating derivatives in general are rather cumbersome for the "understanding" of a computer; when directly specifying the derivative for each degree of the polynomial, the computer memory is seriously loaded, which greatly slows down the work, and setting the function and, accordingly, its derivative directly in the program code is unacceptable. However, using this method, the convergence of the interval to the root occurs most quickly, especially if the method of chords and tangents is combined with the bisection method, because the middle of the new segment often gives a completely satisfactory solution.

The secant method. The secant method can be obtained from Newton's method by replacing the derivative with an approximate expression - the difference formula:

Formula (3.8) uses the two previous approximations u. Therefore, for a given initial value, it is necessary to calculate the next approximation, for example, by the Newton method with an approximate replacement of the derivative by the formula

Algorithm of the secant method:

1) the initial value and error are given. Compute

2) for n= 1,2, ….. while the condition is satisfied, we calculate by formula (3.8).

Let a function be given that is continuous together with its several derivatives. It is required to find all or some real roots of the equation

This task is divided into several subtasks. First, it is necessary to determine the number of roots, to investigate their nature and location. Second, find the approximate values ​​of the roots. Thirdly, to choose from them the roots of interest to us and calculate them with the required accuracy. The first and second tasks are solved, as a rule, by analytical or graphical methods. In the case when only the real roots of equation (1) are sought, it is useful to compile a table of function values. If the function has different signs in two neighboring nodes of the table, then between these nodes lies an odd number of roots of the equation (at least one). If these nodes are close, then most likely there is only one root between them.

The found approximate values ​​of the roots can be refined using various iterative methods. Let's consider three methods: 1) the method of dichotomy (or dividing the segment in half); 2) simple iteration method; and 3) Newton's method.

Methods for solving the problem

Bisection method

The simplest method for finding the root of the nonlinear equation (1) is the half division method.

Let a continuous function be given on the segment. If the values ​​of the function at the ends of the segment have different signs, i.e. then this means that there is an odd number of roots inside the given segment. Let, for definiteness, have only one root. The essence of the method is to halve the length of the segment at each iteration. We find the middle of the segment (see Fig. 1) Calculate the value of the function and select the segment on which the function changes its sign. Divide the new segment in half again. And we continue this process until the length of the segment is equal to the predetermined error in calculating the root. The construction of several successive approximations according to formula (3) is shown in Figure 1.

So, the algorithm of the dichotomy method:

1. Set the interval and error.

2. If f(a) and f(b) have the same signs, issue a message about the impossibility of finding the root and stop.

Fig.1.

3. Otherwise calculate c=(a+b)/2

4. If f(a) and f(c) have different signs, put b=c, otherwise a=c.

5. If the length of the new segment, then calculate the value of the root c=(a+b)/2 and stop, otherwise go to step 3.

Since the length of the segment is reduced by 2 N times in N steps, the given error in finding the root will be reached in iterations.

As can be seen, the rate of convergence is low, but the advantages of the method include simplicity and unconditional convergence of the iterative process. If the segment contains more than one root (but an odd number), then one will always be found.

Comment. To determine the interval in which the root lies, an additional analysis of the function is required, based either on analytical estimates or on the use of a graphical solution method. It is also possible to organize a search of function values ​​at different points until the function sign-changing condition is met

Objective

To get acquainted with the main methods for solving nonlinear equations and their implementation in the MathCAD package.

Guidelines

An engineer often has to write and solve non-linear equations, which can be a stand-alone task or be part of more complex tasks. In both cases, the practical value of the solution method is determined by the speed and efficiency of the solution obtained, and the choice of the appropriate method depends on the nature of the problem under consideration. It is important to note that the results of computer calculations should always be treated critically, analyzed for plausibility. To avoid "pitfalls" when using any standard package that implements numerical methods, you need to have at least a minimal idea of ​​what kind of numerical method is implemented to solve a particular problem.

Nonlinear equations can be divided into 2 classes - algebraic and transcendental. Algebraic equations are called equations containing only algebraic functions (whole - in particular, a polynomial, rational, irrational). Equations containing other functions (trigonometric, exponential, logarithmic, etc.) are called transcendent. Nonlinear equations can be solved accurate or approximate methods. Exact Methods allow us to write the roots in the form of some finite relation (formula). Unfortunately, most transcendental equations, as well as arbitrary algebraic equations of degree above four, do not have analytic solutions. In addition, the coefficients of the equation can only be known approximately and, therefore, the very problem of exact determination of the roots loses its meaning. Therefore, for the solution, iterative methods successive approximation. First follows first separate the roots(i.e. find their approximate value or a segment containing them), and then refine them by the method of successive approximations. You can separate the roots by setting the signs of the function f(x) and its derivative at the boundary points of the region of its existence, estimating approximate values ​​from the physical meaning of the problem, or from solving a similar problem with other initial data.

Widespread graphic way determining approximate values ​​of real roots - build a graph of the function f(x) and mark the points of intersection with the axis OH. Plotting can often be simplified by replacing the equation f(x)= 0 by an equivalent equation , where the functions f 1 (x) and f 2 (x) - simpler than the function f(x). In this case, you should look for the point of intersection of these graphs.

Example 1 Graphically separate the roots of an equation x lg x= 1. Rewrite it as an equality lg x= 1/x and find the abscissas of the intersection points of the logarithmic curve y= log x and hyperbole y= 1/x (Fig. 5). It can be seen that the only root of the equation .

Implementation of classical approximate solution methods in the MathCAD package.

Half division method

The segment, at the ends of which the function takes on values ​​of different signs, is divided in half and, if the root lies to the right of the central point, then the left edge is pulled to the center, and if to the left, then the right edge. The new narrowed segment is again divided in half and the procedure is repeated. This method is simple and reliable, always converges (although often slowly - the cost of simplicity!). Its software implementation in the MathCAD package is considered in laboratory work No. 7 of this manual.

chord method

As successive approximations to the root of the equation, the values ​​are taken X 1 , X 2 , ..., x n points of intersection of the chord AB with the abscissa axis (Fig. 6).

Chord equation AB has the form: . For the point of its intersection with the abscissa axis ( x=x 1 ,y= 0) we have:

Let, for definiteness, the curve at = f(x) will be convex downward and therefore located below its chord AB, i.e. on the segment f²( x)>0. Two cases are possible: f(a)>0 (Fig. 6, a) and f(a)<0 (рис. 6, b).

In the first case, end a motionless. Successive iterations form a bounded monotonically decreasing sequence: and are determined according to the equations:

x 0 = b; . (4.1)

In the second case, the end is fixed b, successive iterations form a bounded monotonically increasing sequence: and are determined according to the equations:

x 0 = a; . (4.2)

Thus, the fixed end should be chosen for which the sign of the function f(X) and its second derivative f²( X) coincide, and successive approximations x n lie on the other side of the root x, where these signs are opposite. The iterative process continues until the modulus of the difference of two successive approximations becomes less than the given accuracy of the solution.

Example 2 Find the positive root of the equation f(x) º x 3 –0,2x 2 –0,2X–1.2 = 0 with an accuracy of e= 0.01. (The exact root of the equation is x = 1.2).

To organize iterative calculations in the MathCAD document, the function is used until( a, z), which returns the value of the quantity z while the expression a does not become negative.

Newton's method

The difference between this method and the previous one is that instead of a chord at each step, a tangent to the curve is drawn y=f(x)at x=x i and the point of its intersection with the abscissa axis is searched (Fig. 7):

In this case, it is not necessary to set the segment [a, b] containing the root of the equation), but it is enough just to set the initial approximation of the root x \u003d x 0, which should be at the same end of the interval [a, b], where the signs of the function and its second derivative match.

Equation of a tangent drawn to a curve y=f(x) through the point AT 0 with coordinates X 0 and f(X 0) has the form:

From here we find the following approximation of the root X 1 as the abscissa of the point of intersection of the tangent with the axis Oh(y= 0):

Similarly, subsequent approximations can be found as points of intersection with the abscissa axis of the tangents drawn at the points IN 1, AT 2 and so on. Formula for ( i + 1) approximation has the form:

The condition for the termination of the iterative process is the inequality ï f(x i

Example 3. Implementation of Newton's iterative method.

Simple iteration method ( successive iterations)

Let us replace the original nonlinear equation f(X)=0 by an equivalent equation of the form x=j( x). If the initial approximation of the root is known x = x 0 , then a new approximation can be obtained by the formula: X 1 =j( X 0). Further, substituting each time a new value of the root into the original equation, we obtain a sequence of values:

The geometric interpretation of the method is that each real root of the equation is the abscissa of the intersection point M crooked y= j( X) with a straight line y=x(Fig. 8). Departing from an arbitrary t. BUT 0 [x 0 ,j( x 0)] initial approximation , we build a broken line BUT 0 AT 1 BUT 1 AT 2 BUT 2 .., which has the shape of a "ladder" (Fig. 8, a) if the derivative j’(x) is positive and the shape of the “spiral” (Fig. 8, b) otherwise.

in)
Rice. 8. Simple iteration method: a, b is a convergent iteration, in is a divergent iteration.

Note that it is necessary to check in advance the flatness of the curve j( X), because if it is not sufficiently flat (>1), then the iteration process can be divergent (Fig. 8, in).

Example 4 . Solve the equation x 3 – x– 1 = 0 by simple iteration method with accuracy e = 10 -3 . The implementation of this task is presented in the following MathCAD document.

Implementation of approximate solution methods by built-in MathCAD functions

Function useroot

For equations of the form f(x) = 0 the solution is found using the function: root( f(X ),x,a,b) , which returns a value X , belonging to the segment [a, b] , in which the expression or function f(X) becomes 0. Both arguments x and f(x) of this function must be scalars, and the arguments a, b – are optional and, if used, must be real numbers, with a< b. The function allows you to find not only real, but also complex roots of an equation (when choosing an initial approximation in complex form).

If the equation has no roots, they are located too far from the initial approximation, the initial approximation was real, and the roots are complex, the function f(X) has discontinuities (local extrema between the initial approximations of the root), then a message will appear (no convergence). The cause of the error can be found by examining the graph f(x). It will help to find out the presence of the roots of the equation f(x) = 0 and, if they are, then determine their approximate values. The more precisely the initial approximation of the root is chosen, the faster the function will converge root.

For Expression f(x) with known root a finding additional roots f(x) is equivalent to finding the roots of the equation h(x)=f(x)/(x-a). It's easier to find the root of the expression h(x) than trying to find another root of the equation f(x)=0 by choosing different initial approximations. A similar trick is useful for finding roots that are close together, and is implemented in the document below.

Example 5. Solve an algebraic equation using the root function:

Note. If you increase the value of the system variable TOL (tolerance), then the function root will converge faster, but the answer will be less accurate, and as TOL decreases, slower convergence provides higher accuracy, respectively. The latter is necessary if it is required to distinguish between two closely spaced roots, or if the function f(x) has a small slope near the desired root, since the iterative process in this case can converge to a result far enough away from the root. In the latter case, an alternative to improving accuracy is to replace the equation f(x) = 0 on g(x) = 0, where .

Function usepolyroots

If the function f(x) is a polynomial of degree n , then to solve the equation f(x)=0 it is better to use the function polyroots(a) than root, since it does not require an initial approximation and returns all the roots at once, both real and complex. Its argument is the vector a, composed of the coefficients of the original polynomial. It can be generated manually or using the command Symbols Þ Polynomial coefficients(the polynomial variable x is highlighted by the cursor). Function application example polyroots:

Function usesolveand decision block

Keyword decision block ( Given-Find or Given–Minerr) or function solve make it possible to find a solution to an arbitrary non-linear equation if the initial approximation is preliminarily given.

Note that between the functions Find and root there is some kind of competition. One side, Find allows you to search for the roots of both equations and systems. From these positions, the function root like it's not needed. But on the other hand, the design Given Find cannot be pasted into MathCAD programs. Therefore, in programs, it is necessary to reduce the system to one equation by substitutions and use the function root.

Symbolic solution of equations in the MathCAD package

In many cases, MathCAD allows you to find an analytical solution to an equation. In order to find a solution to an equation in analytical form, it is necessary to write down an expression and select a variable in it. After that, select from the menu item symbolic subparagraph Solve for Variable .

Other options for finding a solution in symbolic form are (examples of solving the same equation are given) - using the function solve from the palette of mathematical operations Symbols (symbolic).

using a solve block (with keywords Given - Find)

An equation like F(x)=0 or x=f(x) is called non-linear. To solve an equation means to find such an x ​​for which the equation becomes an identity. In general, an equation can have 0; one; 2;...∞ roots. The numerical methods considered below for solving nonlinear equations make it possible to find one root on a given interval. In this case, only one root must exist on the interval. Consider several methods for solving nonlinear equations.

  1. enumeration method. When solving a nonlinear equation by enumeration, the initial value of the argument x=a and the step h are specified, which at the same time determines the accuracy of finding the roots of the nonlinear equation. While the condition F(x)*F(x+h)>0 is satisfied, the argument x is increased by step h (x=x+h). If the product F(x)*F(x+h) becomes negative, then there is a solution to the equation on the interval. The structogram of the method is shown in the figure.


  2. Half division method. When solving a non-linear equation by the bisection method, an interval is specified on which there is only one solution, and the desired accuracy ε. Then the middle of the interval с=(а+b)/2 is determined and the condition F(a)∙F(c) is checked<0. Если указанное условие выполняется, то правую границу интервала b переносим в среднюю точку с (b=c). Если условие не выполняется, то в среднюю точку переносим левую границу(a=c). Деление отрезка пополам продолжается пока |b-a|>ε. The structogram for solving nonlinear equations by the bisection method is shown in the figure.

    While |b-a|>ε

    F(a)∙F(c)<0


    Rice. Structogram for bisection method

  3. chord method. When solving a non-linear equation by the chord method, the interval , on which there is only one solution, and the accuracy ε are specified. Then, through two points with coordinates (a, F (a)) and (b, F (b)) we draw a straight line segment (chord) and determine the point of intersection of this line with the abscissa axis (point c). If, in addition, F(a)∙F(c)<0, то правую границу интервала переносим в точку с (b=c). Если указанное условие не выполняется, то в точку c the left boundary of the interval is transferred (a=c). The search for a solution stops when the specified accuracy |F(c)|< ε. Для определения точки пересечения хорды с осью абсцисс воспользуемся следующей формулой (try to get the formula yourself). The structogram of the chord method is shown in the figure.

    While |F(c)|>ε

    F(a)∙F(c)<0


    Rice. Structogram for the chord method

  4. Tangent method. When solving a nonlinear equation by the tangent method, the initial value of the argument x 0 and the accuracy ε are specified. Then, at the point (x 0, F (x 0)) we draw a tangent to the graph F (x) and determine the point of intersection of the tangent with the x-axis x 1. At the point (x 1, F (x 1)) we again build a tangent, find the next approximation of the desired solution x 2, etc. We repeat this procedure until |F(x i)| > ε. To determine the point of intersection (i + 1) of the tangent with the abscissa axis, we use the following formula (get the formula yourself). Convergence condition for the tangent method F(x 0)∙F""(x 0)>0. The structogram of the solution of nonlinear equations by the tangent method is shown in Fig. .


  5. Chord-tangent method. If in the method of tangents the derivative of the function F "(x i) is replaced by the ratio of finite increments, then we obtain the calculation formula for the method of chord-tangents . The procedure for performing calculations in this method is similar to that considered earlier.
  6. Iteration Method. When solving a nonlinear equation by the iteration method, we use the equation in the form x=f(x). The initial value of the argument x 0 and the precision ε are specified. The first approximation of the solution x 1 is found from the expression x 1 \u003d f (x 0), the second - x 2 \u003d f (x 1), etc. In the general case, i+1 approximation can be found by the formula x i +1 =f(x i). We repeat this procedure until |f(x i)|>ε. The condition for the convergence of the iteration method |f"(x)|<1. Структограмма метода итераций показана на рис.


Control task. Laboratory work 4.

Solution of non-linear equations.

Exercise. Solve the nonlinear equation indicated in Table. methods, pre-determining the interval on which there is a solution to the equation. Check the solution.

Variants of equations and methods for their solution are given in the table.


Variants of equations and methods for their solution

The equation

Solution Methods

busting and chord

Busting and tangents

Busting and chord-tangents

Brute force and half division

busting and chord

Busting and tangents

Busting and chord-tangents

Brute force and half division

busting and chord

Busting and tangents

Busting and chord-tangents

Brute force and half division

busting and chord

Busting and tangents

Busting and chord-tangents

Brute force and half division

busting and chord

Busting and tangents

x2=exp(-x2)-1

Busting and chord-tangents

Brute force and half division

busting and chord

Busting and tangents

Busting and chord-tangents

Brute force and half division


  1. Title, purpose of work and task.
  2. Mathematical description, algorithm (structogram) and program text.
  3. The results of the calculation, verification and conclusions on the work.