Solving systems using the Gaussian elimination method. Gauss method: description of the algorithm for solving a system of linear equations, examples, solutions

We continue to consider systems linear equations. This lesson is the third on the topic. If you have a vague idea of ​​what a system of linear equations is in general, if you feel like a teapot, then I recommend starting with the basics on the page Next, it is useful to study the lesson.

The Gaussian method is easy! Why? The famous German mathematician Johann Carl Friedrich Gauss received recognition during his lifetime greatest mathematician of all times, a genius and even nicknamed “the king of mathematics.” And everything ingenious, as you know, is simple! By the way, not only suckers get money, but also geniuses - Gauss’s portrait was on the 10 Deutschmark banknote (before the introduction of the euro), and Gauss still smiles mysteriously at Germans from ordinary postage stamps.

The Gauss method is simple in that the KNOWLEDGE OF A FIFTH-GRADE STUDENT IS ENOUGH to master it. You must know how to add and multiply! It is no coincidence that teachers often consider the method of sequential exclusion of unknowns in school mathematics electives. It’s a paradox, but students find the Gaussian method the most difficult. Nothing surprising - it’s all about the methodology, and I will try to talk about the algorithm of the method in an accessible form.

First, let's systematize a little knowledge about systems of linear equations. A system of linear equations can:

1) Have only decision. 2) Have infinitely many solutions. 3) Have no solutions (be non-joint).

The Gauss method is the most powerful and universal tool for finding a solution any systems of linear equations. As we remember, Cramer's rule and matrix method are unsuitable in cases where the system has infinitely many solutions or is inconsistent. And the method of sequential elimination of unknowns Anyway will lead us to the answer! On this lesson We will again consider the Gauss method for case No. 1 (the only solution to the system), an article is devoted to the situations of points No. 2-3. I note that the algorithm of the method itself works the same in all three cases.

Let's go back to the simplest system from class How to solve a system of linear equations? and solve it using the Gaussian method.

The first step is to write down extended system matrix: . I think everyone can see by what principle the coefficients are written. The vertical line inside the matrix does not have any mathematical meaning - it is simply a strikethrough for ease of design.

Reference : I recommend you remember terms linear algebra. System Matrix is a matrix composed only of coefficients for unknowns, in this example the matrix of the system: . Extended System Matrix is the same matrix of the system plus a column of free terms, in in this case: . For brevity, any of the matrices can be simply called a matrix.

After the extended system matrix is ​​written, it is necessary to perform some actions with it, which are also called elementary transformations.

The following elementary transformations exist:

1) Strings matrices Can rearrange in some places. For example, in the matrix under consideration, you can painlessly rearrange the first and second rows:

2) If the matrix has (or has appeared) proportional (like special case– identical) lines, then it follows delete from the matrix all these rows except one. Consider, for example, the matrix . In this matrix, the last three rows are proportional, so it is enough to leave only one of them: .

3) If a zero row appears in the matrix during transformations, then it should also be delete. I won’t draw, of course, the zero line is the line in which all zeros.

4) The matrix row can be multiply (divide) to any number non-zero. Consider, for example, the matrix . Here it is advisable to divide the first line by –3, and multiply the second line by 2: . This action very useful because it simplifies further matrix transformations.

5) This transformation causes the most difficulties, but in fact there is nothing complicated either. To a row of a matrix you can add another string multiplied by a number, different from zero. Consider our matrix of practical example: . First I'll describe the transformation in great detail. Multiply the first line by –2: , And to the second line we add the first line multiplied by –2: . Now the first line can be divided “back” by –2: . As you can see, the line that is ADDED LIhasn't changed. Always the line TO WHICH IS ADDED changes UT.

In practice, of course, they don’t write it in such detail, but write it briefly: Once again: to the second line added the first line multiplied by –2. A line is usually multiplied orally or on a draft, with the mental calculation process going something like this:

“I rewrite the matrix and rewrite the first line: »

“First column. At the bottom I need to get zero. Therefore, I multiply the one at the top by –2: , and add the first one to the second line: 2 + (–2) = 0. I write the result in the second line: »

“Now the second column. At the top, I multiply -1 by -2: . I add the first to the second line: 1 + 2 = 3. I write the result in the second line: »

“And the third column. At the top I multiply -5 by -2: . I add the first to the second line: –7 + 10 = 3. I write the result in the second line: »

Please carefully understand this example and understand the sequential calculation algorithm, if you understand this, then the Gaussian method is practically in your pocket. But, of course, we will still work on this transformation.

Elementary transformations do not change the solution of the system of equations

! ATTENTION: considered manipulations can not use, if you are offered a task where the matrices are given “by themselves.” For example, with “classical” operations with matrices Under no circumstances should you rearrange anything inside the matrices! Let's return to our system. It is practically taken to pieces.

Let us write down the extended matrix of the system and, using elementary transformations, reduce it to stepped view:

(1) The first line was added to the second line, multiplied by –2. And again: why do we multiply the first line by –2? In order to get zero at the bottom, which means getting rid of one variable in the second line.

(2) Divide the second line by 3.

The purpose of elementary transformations reduce the matrix to stepwise form: . In the design of the task, they just mark out the “stairs” with a simple pencil, and also circle the numbers that are located on the “steps”. The term “stepped view” itself is not entirely theoretical, in scientific and educational literature it is often called trapezoidal view or triangular view.

As a result of elementary transformations, we obtained equivalent original system of equations:

Now the system needs to be “unwinded” in the opposite direction - from bottom to top, this process is called inverse of the Gaussian method.

In the lower equation we already have a ready-made result: .

Let's consider the first equation of the system and substitute the already known value of “y” into it:

Let's consider the most common situation, when the Gaussian method requires solving a system of three linear equations with three unknowns.

Example 1

Solve the system of equations using the Gauss method:

Let's write the extended matrix of the system:

Now I will immediately draw the result that we will come to during the solution: And I repeat, our goal is to bring the matrix to a stepwise form using elementary transformations. Where to start?

First, look at the top left number: Should almost always be here unit. Generally speaking, –1 (and sometimes other numbers) will do, but somehow it has traditionally happened that one is usually placed there. How to organize a unit? We look at the first column - we have a finished unit! Transformation one: swap the first and third lines:

Now the first line will remain unchanged until the end of the solution. Now fine.

Unit in left top corner organized. Now you need to get zeros in these places:

We get zeros using a “difficult” transformation. First we deal with the second line (2, –1, 3, 13). What needs to be done to get zero in the first position? Need to to the second line add the first line multiplied by –2. Mentally or on a draft, multiply the first line by –2: (–2, –4, 2, –18). And we consistently carry out (again mentally or on a draft) addition, to the second line we add the first line, already multiplied by –2:

We write the result in the second line:

We deal with the third line in the same way (3, 2, –5, –1). To get a zero in the first position, you need to the third line add the first line multiplied by –3. Mentally or on a draft, multiply the first line by –3: (–3, –6, 3, –27). AND to the third line we add the first line multiplied by –3:

We write the result in the third line:

In practice, these actions are usually performed orally and written down in one step:

No need to count everything at once and at the same time. The order of calculations and “entering” the results consistent and usually it’s like this: first we rewrite the first line, and slowly puff on ourselves - CONSISTENTLY and ATTENTIVELY:
And I have already discussed the mental process of the calculations themselves above.

IN in this example This is easy to do, divide the second line by –5 (since all numbers there are divisible by 5 without a remainder). At the same time, we divide the third line by –2, because the smaller the numbers, the simpler the solution:

At the final stage of elementary transformations, you need to get another zero here:

For this to the third line we add the second line multiplied by –2:
Try to figure out this action yourself - mentally multiply the second line by –2 and perform the addition.

The last action performed is the hairstyle of the result, divide the third line by 3.

As a result of elementary transformations, an equivalent system of linear equations was obtained: Cool.

Now the reverse of the Gaussian method comes into play. The equations “unwind” from bottom to top.

In the third equation we already have a ready result:

Let's look at the second equation: . The meaning of "zet" is already known, thus:

And finally, the first equation: . “Igrek” and “zet” are known, it’s just a matter of little things:

Answer:

As has been repeatedly noted, for any system of equations it is possible and necessary to check the solution found, fortunately, this is easy and quick.

Example 2

This is an example for an independent solution, a sample of the final design and an answer at the end of the lesson.

It should be noted that your progress of the decision may not coincide with my decision process, and this is a feature of the Gauss method. But the answers must be the same!

Example 3

Solve a system of linear equations using the Gauss method

We look at the upper left “step”. We should have one there. The problem is that there are no units in the first column at all, so rearranging the rows will not solve anything. In such cases, the unit must be organized using an elementary transformation. This can usually be done in several ways. I did this: (1) To the first line we add the second line, multiplied by –1. That is, we mentally multiplied the second line by –1 and added the first and second lines, while the second line did not change.

Now at the top left there is “minus one”, which suits us quite well. Anyone who wants to get +1 can perform an additional movement: multiply the first line by –1 (change its sign).

(2) The first line multiplied by 5 was added to the second line. The first line multiplied by 3 was added to the third line.

(3) The first line was multiplied by –1, in principle, this is for beauty. The sign of the third line was also changed and it was moved to second place, so that on the second “step” we had the required unit.

(4) The second line was added to the third line, multiplied by 2.

(5) The third line was divided by 3.

A bad sign that indicates an error in calculations (more rarely, a typo) is a “bad” bottom line. That is, if we got something like , below, and, accordingly, , then with a large share probability, it can be argued that an error was made during elementary transformations.

We charge the reverse, in the design of examples they often do not rewrite the system itself, but the equations are “taken directly from the given matrix.” The reverse stroke, I remind you, works from bottom to top. Yes, here is a gift:

Answer: .

Example 4

Solve a system of linear equations using the Gauss method

This is an example for you to solve on your own, it is somewhat more complicated. It's okay if someone gets confused. Full solution and sample design at the end of the lesson. Your solution may be different from my solution.

In the last part we will look at some features of the Gaussian algorithm. The first feature is that sometimes some variables are missing from the system equations, for example: How to correctly write the extended system matrix? I already talked about this point in class. Cramer's rule. Matrix method. In the extended matrix of the system, we put zeros in place of missing variables: By the way, that's pretty easy example, since there is already one zero in the first column, and there are fewer elementary conversions to perform.

The second feature is this. In all the examples considered, we placed either –1 or +1 on the “steps”. Could there be other numbers there? In some cases they can. Consider the system: .

Here on the upper left “step” we have a two. But we notice the fact that all the numbers in the first column are divisible by 2 without a remainder - and the other is two and six. And the two at the top left will suit us! In the first step, you need to perform the following transformations: add the first line multiplied by –1 to the second line; to the third line add the first line multiplied by –3. This way we will get the required zeros in the first column.

Or something like this conditional example: . Here the three on the second “step” also suits us, since 12 (the place where we need to get zero) is divisible by 3 without a remainder. It is necessary to carry out the following transformation: add the second line to the third line, multiplied by –4, as a result of which the zero we need will be obtained.

Gauss's method is universal, but there is one peculiarity. Confidently learn to solve systems using other methods (Cramer’s method, matrix method) you can literally the first time - there is a very strict algorithm. But in order to feel confident in the Gaussian method, you should “get your teeth into” and solve at least 5-10 ten systems. Therefore, at first there may be confusion and errors in calculations, and there is nothing unusual or tragic about this.

Rainy autumn weather outside the window.... Therefore, for everyone who wants more complex example for independent solution:

Example 5

Solve a system of 4 linear equations with four unknowns using the Gauss method.

Such a task is not so rare in practice. I think even a teapot who has thoroughly studied this page will understand the algorithm for solving such a system intuitively. Fundamentally, everything is the same - there are just more actions.

Cases when the system has no solutions (inconsistent) or has infinitely many solutions are discussed in the lesson Incompatible systems and systems with a common solution. There you can fix the considered algorithm of the Gaussian method.

I wish you success!

Solutions and answers:

Example 2: Solution : Let us write down the extended matrix of the system and, using elementary transformations, bring it to a stepwise form.
Elementary transformations performed: (1) The first line was added to the second line, multiplied by –2. The first line was added to the third line, multiplied by –1. Attention! Here you may be tempted to subtract the first from the third line; I highly recommend not subtracting it - the risk of error greatly increases. Just fold it! (2) The sign of the second line was changed (multiplied by –1). The second and third lines have been swapped. note , that on the “steps” we are satisfied not only with one, but also with –1, which is even more convenient. (3) The second line was added to the third line, multiplied by 5. (4) The sign of the second line was changed (multiplied by –1). The third line was divided by 14.

Reverse:

Answer : .

Example 4: Solution : Let us write down the extended matrix of the system and, using elementary transformations, bring it to a stepwise form:

Conversions performed: (1) A second line was added to the first line. Thus, the desired unit is organized on the upper left “step”. (2) The first line multiplied by 7 was added to the second line. The first line multiplied by 6 was added to the third line.

With the second “step” everything gets worse , the “candidates” for it are the numbers 17 and 23, and we need either one or –1. Transformations (3) and (4) will be aimed at obtaining the desired unit (3) The second line was added to the third line, multiplied by –1. (4) The third line was added to the second line, multiplied by –3. The required item on the second step has been received . (5) The second line was added to the third line, multiplied by 6. (6) The second line was multiplied by –1, the third line was divided by -83.

Reverse:

Answer :

Example 5: Solution : Let us write down the matrix of the system and, using elementary transformations, bring it to a stepwise form:

Conversions performed: (1) The first and second lines have been swapped. (2) The first line was added to the second line, multiplied by –2. The first line was added to the third line, multiplied by –2. The first line was added to the fourth line, multiplied by –3. (3) The second line was added to the third line, multiplied by 4. The second line was added to the fourth line, multiplied by –1. (4) The sign of the second line was changed. The fourth line was divided by 3 and placed in place of the third line. (5) The third line was added to the fourth line, multiplied by –5.

Reverse:

Answer :


Gauss method perfect for solving linear systems algebraic equations(SLAU). It has a number of advantages compared to other methods:

  • firstly, there is no need to first examine the system of equations for consistency;
  • secondly, the Gauss method can solve not only SLAEs in which the number of equations coincides with the number of unknown variables and the main matrix of the system is non-singular, but also systems of equations in which the number of equations does not coincide with the number of unknown variables or the determinant of the main matrix equal to zero;
  • thirdly, the Gaussian method leads to results with relatively small quantity computing operations.

Brief overview of the article.

First let's give necessary definitions and introduce the notation.

Next, we will describe the algorithm of the Gauss method for the simplest case, that is, for systems of linear algebraic equations, the number of equations in which coincides with the number of unknown variables and the determinant of the main matrix of the system is not equal to zero. When solving such systems of equations, the essence of the Gauss method is most clearly visible, which is consistent exclusion unknown variables. Therefore, the Gaussian method is also called the method of sequential elimination of unknowns. We'll show you detailed solutions several examples.

In conclusion, we will consider the solution by the Gauss method of systems of linear algebraic equations, the main matrix of which is either rectangular or singular. The solution to such systems has some features, which we will examine in detail using examples.

Page navigation.

Basic definitions and notations.

Consider a system of p linear equations with n unknowns (p can be equal to n):

Where are unknown variables, are numbers (real or complex), and are free terms.

If , then the system of linear algebraic equations is called homogeneous, otherwise - heterogeneous.

The set of values ​​of unknown variables for which all equations of the system become identities is called decision of the SLAU.

If there is at least one solution to a system of linear algebraic equations, then it is called joint, otherwise - non-joint.

If a SLAE has a unique solution, then it is called certain. If there is more than one solution, then the system is called uncertain.

They say that the system is written in coordinate form , if it has the form
.

This system in matrix form records has the form , where - the main matrix of the SLAE, - the matrix of the column of unknown variables, - the matrix of free terms.

If we add a matrix-column of free terms to matrix A as the (n+1)th column, we get the so-called extended matrix systems of linear equations. Usually the extended matrix is ​​denoted by the letter T, and the column of free terms is separated vertical line from the remaining columns, that is,

The square matrix A is called degenerate, if its determinant is zero. If , then matrix A is called non-degenerate.

The following point should be noted.

If you perform the following actions with a system of linear algebraic equations

  • swap two equations,
  • multiply both sides of any equation by an arbitrary and non-zero real (or complex) number k,
  • to both sides of any equation add the corresponding parts of another equation, multiplied by arbitrary number k,

then you get an equivalent system that has the same solutions (or, just like the original one, has no solutions).

For an extended matrix of a system of linear algebraic equations, these actions will mean carrying out elementary transformations with the rows:

  • swapping two lines,
  • multiplying all elements of any row of matrix T by a nonzero number k,
  • adding to the elements of any row of a matrix the corresponding elements of another row, multiplied by an arbitrary number k.

Now we can proceed to the description of the Gauss method.

Solving systems of linear algebraic equations, in which the number of equations is equal to the number of unknowns and the main matrix of the system is non-singular, using the Gauss method.

What would we do at school if we were given the task of finding a solution to a system of equations? .

Some would do that.

Note that adding to the left side of the second equation left side first, and to the right side - the right one, you can get rid of the unknown variables x 2 and x 3 and immediately find x 1:

We substitute the found value x 1 =1 into the first and third equations of the system:

If we multiply both sides of the third equation of the system by -1 and add them to the corresponding parts of the first equation, we get rid of the unknown variable x 3 and can find x 2:

We substitute the resulting value x 2 = 2 into the third equation and find the remaining unknown variable x 3:

Others would have done differently.

Let us resolve the first equation of the system with respect to the unknown variable x 1 and substitute the resulting expression into the second and third equations of the system in order to exclude this variable from them:

Now let’s solve the second equation of the system for x 2 and substitute the result obtained into the third equation to eliminate the unknown variable x 2 from it:

From the third equation of the system it is clear that x 3 =3. From the second equation we find , and from the first equation we get .

Familiar solutions, right?

The most interesting thing here is that the second solution method is essentially the method of sequential elimination of unknowns, that is, the Gaussian method. When we expressed the unknown variables (first x 1, at the next stage x 2) and substituted them into the remaining equations of the system, we thereby excluded them. We carried out elimination until there was only one unknown variable left in the last equation. The process of sequentially eliminating unknowns is called direct Gaussian method. After completing the forward move, we have the opportunity to calculate the unknown variable found in the last equation. With its help, we find the next unknown variable from the penultimate equation, and so on. Process sequential finding unknown variables when moving from the last equation to the first is called inverse of the Gaussian method.

It should be noted that when we express x 1 in terms of x 2 and x 3 in the first equation, and then substitute the resulting expression into the second and third equations, the following actions lead to the same result:

Indeed, such a procedure also makes it possible to eliminate the unknown variable x 1 from the second and third equations of the system:

Nuances with the elimination of unknown variables using the Gaussian method arise when the equations of the system do not contain some variables.

For example, in SLAU in the first equation there is no unknown variable x 1 (in other words, the coefficient in front of it is zero). Therefore, we cannot solve the first equation of the system for x 1 in order to eliminate this unknown variable from the remaining equations. The way out of this situation is to swap the equations of the system. Since we are considering systems of linear equations whose determinants of the main matrices are different from zero, there is always an equation in which the variable we need is present, and we can rearrange this equation to the position we need. For our example, it is enough to swap the first and second equations of the system , then you can resolve the first equation for x 1 and exclude it from the remaining equations of the system (although x 1 is no longer present in the second equation).

We hope you get the gist.

Let's describe Gaussian method algorithm.

Suppose we need to solve a system of n linear algebraic equations with n unknowns variables of the form , and let the determinant of its main matrix be different from zero.

We will assume that , since we can always achieve this by rearranging the equations of the system. Let's eliminate the unknown variable x 1 from all equations of the system, starting with the second. To do this, to the second equation of the system we add the first, multiplied by , to the third equation we add the first, multiplied by , and so on, to the nth equation we add the first, multiplied by . The system of equations after such transformations will take the form

where , and .

We would have arrived at the same result if we had expressed x 1 in terms of other unknown variables in the first equation of the system and substituted the resulting expression into all other equations. Thus, the variable x 1 is excluded from all equations, starting from the second.

Next, we proceed in a similar way, but only with part of the resulting system, which is marked in the figure

To do this, to the third equation of the system we add the second, multiplied by , to the fourth equation we add the second, multiplied by , and so on, to the nth equation we add the second, multiplied by . The system of equations after such transformations will take the form

where , and . Thus, the variable x 2 is excluded from all equations, starting from the third.

Next, we proceed to eliminating the unknown x 3, while we act similarly with the part of the system marked in the figure

So we continue the direct progression of the Gaussian method until the system takes the form

From this moment we begin the reverse of the Gaussian method: we calculate x n from the last equation as , using the obtained value of x n we find x n-1 from the penultimate equation, and so on, we find x 1 from the first equation.

Let's look at the algorithm using an example.

Example.

Gauss method.

Solution.

The coefficient a 11 is different from zero, so let’s proceed to the direct progression of the Gaussian method, that is, to the exclusion of the unknown variable x 1 from all equations of the system except the first. To do this, to the left and right parts of the second, third and fourth equation let's add the left and right sides of the first equation, multiplied by , respectively, And :

The unknown variable x 1 has been eliminated, let's move on to eliminating x 2 . To the left and right sides of the third and fourth equations of the system we add the left and right sides of the second equation, multiplied by respectively And :

To complete the forward progression of the Gaussian method, we need to eliminate the unknown variable x 3 from the last equation of the system. Let us add to the left and right sides of the fourth equation, respectively, the left and right sides of the third equation, multiplied by :

You can begin the reverse of the Gaussian method.

From the last equation we have ,
from the third equation we get,
from the second,
from the first one.

To check, you can substitute the obtained values ​​of the unknown variables into the original system of equations. All equations turn into identities, which indicates that the solution using the Gauss method was found correctly.

Answer:

Now let’s give a solution to the same example using the Gaussian method in matrix notation.

Example.

Find the solution to the system of equations Gauss method.

Solution.

The extended matrix of the system has the form . At the top of each column are the unknown variables that correspond to the elements of the matrix.

The direct approach of the Gaussian method here involves reducing the extended matrix of the system to a trapezoidal form using elementary transformations. This process is similar to the elimination of unknown variables that we did with the system in coordinate form. Now you will see this.

Let's transform the matrix so that all elements in the first column, starting from the second, become zero. To do this, to the elements of the second, third and fourth lines we add the corresponding elements of the first line multiplied by , and accordingly:

Next, we transform the resulting matrix so that in the second column all elements, starting from the third, become zero. This would correspond to eliminating the unknown variable x 2 . To do this, to the elements of the third and fourth rows we add the corresponding elements of the first row of the matrix, multiplied by respectively And :

It remains to exclude the unknown variable x 3 from the last equation of the system. To do this, go to the elements last line of the resulting matrix we add the corresponding elements of the penultimate row, multiplied by :

It should be noted that this matrix corresponds to a system of linear equations

which was obtained earlier after a forward move.

It's time to turn back. In matrix notation, the inverse of the Gaussian method involves transforming the resulting matrix such that the matrix marked in the figure

became diagonal, that is, took the form

where are some numbers.

These transformations are similar to the forward transformations of the Gaussian method, but are performed not from the first line to the last, but from the last to the first.

Add to the elements of the third, second and first lines the corresponding elements of the last line, multiplied by , on and on respectively:

Now let’s add to the elements of the second and first lines the corresponding elements of the third line, multiplied by and by, respectively:

At the last step of the reverse Gaussian method, to the elements of the first row we add the corresponding elements of the second row, multiplied by:

The resulting matrix corresponds to the system of equations , from where we find the unknown variables.

Answer:

NOTE.

When using the Gauss method to solve systems of linear algebraic equations, approximate calculations should be avoided, as this can lead to completely incorrect results. We recommend not rounding decimals. Better from decimals go to ordinary fractions.

Example.

Solve a system of three equations using the Gauss method .

Solution.

Note that in this example the unknown variables have a different designation (not x 1, x 2, x 3, but x, y, z). Let's move on to ordinary fractions:

Let us exclude the unknown x from the second and third equations of the system:

In the resulting system, the unknown variable y is absent in the second equation, but y is present in the third equation, therefore, let’s swap the second and third equations:

This completes the direct progression of the Gauss method (there is no need to exclude y from the third equation, since this unknown variable no longer exists).

Let's start the reverse move.

From the last equation we find ,
from the penultimate


from the first equation we have

Answer:

X = 10, y = 5, z = -20.

Solving systems of linear algebraic equations in which the number of equations does not coincide with the number of unknowns or the main matrix of the system is singular, using the Gauss method.

Systems of equations, the main matrix of which is rectangular or square singular, may have no solutions, may have a single solution, or may have an infinite number of solutions.

Now we will understand how the Gauss method allows us to establish the compatibility or inconsistency of a system of linear equations, and in the case of its compatibility, determine all solutions (or one single solution).

In principle, the process of eliminating unknown variables in the case of such SLAEs remains the same. However, it is worth going into detail about some situations that may arise.

Let's move on to the most important stage.

So, let us assume that the system of linear algebraic equations, after completing the forward progression of the Gauss method, takes the form and not a single equation was reduced to (in this case we would conclude that the system is incompatible). A logical question arises: “What to do next”?

Let us write down the unknown variables that come first in all equations of the resulting system:

In our example these are x 1, x 4 and x 5. On the left sides of the equations of the system we leave only those terms that contain the written unknown variables x 1, x 4 and x 5, the remaining terms are transferred to the right side of the equations with the opposite sign:

Let's give the unknown variables that are on the right sides of the equations arbitrary values, where - arbitrary numbers:

After this, the right-hand sides of all equations of our SLAE contain numbers and we can proceed to the reverse of the Gaussian method.

From the last equation of the system we have, from the penultimate equation we find, from the first equation we get

The solution to a system of equations is a set of values ​​of unknown variables

Giving Numbers different meanings, we will receive various solutions systems of equations. That is, our system of equations has infinitely many solutions.

Answer:

Where - arbitrary numbers.

To consolidate the material, we will analyze in detail the solutions of several more examples.

Example.

Decide homogeneous system linear algebraic equations Gauss method.

Solution.

Let us exclude the unknown variable x from the second and third equations of the system. To do this, to the left and right sides of the second equation, we add, respectively, the left and right sides of the first equation, multiplied by , and to the left and right sides of the third equation, we add the left and right sides of the first equation, multiplied by:

Now let’s exclude y from the third equation of the resulting system of equations:

The resulting SLAE is equivalent to the system .

We leave on the left side of the system equations only the terms containing the unknown variables x and y, and move the terms with the unknown variable z to the right side:

Let's consider one of the most common methods for solving systems of linear algebraic equations - the Gauss method. This method (also called the method of sequential elimination of unknowns) has been known in various versions for more than 2000 years.

Calculations using the Gaussian method consist of two main steps, called forward movement and backward movement (backward substitution). The direct approach of the Gauss method consists in sequentially eliminating unknowns from system (5.1) to transform it to equivalent system with an upper triangular matrix. Calculations of the values ​​of the unknowns are carried out at the reverse stage.

1. Scheme of a single division.

Let's consider first simplest option Gaussian method, called the single division scheme.

The forward move consists of elimination steps.

1st step. The purpose of this step is to eliminate the unknown from equations with numbers. Suppose that the coefficient We will call it the main (or leading) element of the 1st step.

Let's find the quantities

called 1st step multipliers. Let us subtract sequentially from the second, third, equations of system (5.1) the first equation, multiplied by respectively. This will allow us to turn into

zero coefficients in all equations except the first. As a result, we obtain an equivalent system

in which they are calculated using the formulas

2nd step. The purpose of this step is to eliminate the unknown from equations with numbers. Let where is a coefficient called the main (or leading) element of the step. Let's calculate the factors of the 2nd step

and subtract sequentially from the third, fourth, equations of system (5.30) the second equation, multiplied by , respectively. As a result, we obtain the system

Here the coefficients are calculated using the formulas

The remaining steps are carried out similarly. Let's describe the next step.

kth step. Assuming that the main (leading) element of the step is nonzero, we calculate the step multipliers

and subtract sequentially from the equations of the system obtained at the previous step the equation multiplied by

After the elimination step we obtain a system of equations

whose matrix is ​​upper triangular. This completes the forward calculations.

Reverse move. From the last equation of system (5.33) we find. Substituting the found value into the penultimate equation, we obtain. Carrying out the reverse substitution, we then successively find. Calculations of unknowns are carried out here using the formulas

The complexity of the method. Let us estimate the number of arithmetic operations required to implement the single division scheme.

Calculations of the 1st elimination step using formulas (5.29), (5.31) require division, multiplication and subtraction, i.e. total number arithmetic operations is Similarly, a step requires operations, and a step requires operations.

Let us now approximately calculate the total number of forward arithmetic operations, considering the dimension of the system to be sufficiently large:

As is easy to see, to implement the reverse stroke according to formulas (5.34) you need a total of operations, which for large ones is negligible compared to the number of forward stroke operations.

Thus, to implement the Gaussian method, approximately arithmetic operations are required, and the overwhelming majority of these operations are performed at the forward stage.

Example 5.7. Using the Gaussian method we solve the system

Direct move. 1st step. Let's calculate the factors. Subtracting from the second, third and fourth equations of system (5.35) the first equation multiplied by, respectively, we get

2nd step. Let's calculate the factors. Subtracting from the third and fourth equations of system (5.36) the second equation multiplied by, respectively, we arrive at the system

3rd step. By calculating the factor and subtracting from the fourth equation of system (5.37) the third equation multiplied by we reduce the system to triangular form:

Reverse move. From the last equation of the system we find. Substituting the value into the third equation, we find

The calculation results can be summarized in the following table.

Table 5.2 (see scan)

The need to select the main elements. Note that the calculation of factors, as well as reverse substitution, require division by the main elements. Therefore, if one of the main elements is equal to zero, then the single division scheme cannot be implemented. Common sense suggests that in a situation where all the main elements are different from zero, but among them there are those close to zero, an uncontrolled increase in error is possible.

Example 5.8. Using the Gauss method, we solve the system of equations

on a -bit decimal computer.

Direct move. 1st step. We calculate the factors and transform the system to the form

All calculations in this step are performed without rounding.

2nd step. After calculating the multiplier, the last equation of the system must be converted to the form where However, on the computer used, the equation will be obtained

Indeed, the coefficient is determined precisely, since when calculating it, there are no numbers whose mantissas have more than 6 digits. At the same time, when calculating, multiplying the coefficient 3.0001 by gives a 7-digit number 105003.5, after rounding to 6 digits the result is 105004. Calculation 62) is completed by performing the subtraction operation: . After rounding last date up to 6 digits of the mantissa we arrive at equation (5.41).

Reverse move. From equation (5.41) we also find 1.00001. Comparison with the true value shows that this value was obtained with very high accuracy for the computer used. Further calculations give

After rounding we have .

As is easy to see, the found values ​​of the unknowns have little in common with true values solutions

What is the reason for such a significant error? There is no need to talk about the accumulation of rounding errors, since a total of 28 arithmetic operations were performed and only in 4 cases was rounding required. The assumption that the system is poorly conditioned is not confirmed; the calculation gives the value and 100.

In reality, the reason is the use of a small leading element in the step. The consequence of this was the appearance of a large

multiplier and a significant increase in the coefficient in the last equation of the system.

Thus, the above version of the Gauss method (single division scheme) turned out to be incorrect and, therefore, unsuitable for computer calculations. This method can lead to an emergency stop (if for some reason and the calculations using it may turn out to be unstable.

2. Gaussian method with selection of the main element by column (partial selection scheme).

Description of the method. At the forward step, the coefficients of the equations of the system with numbers are converted according to the formulas

It is intuitively clear that in order to avoid a strong increase in the system coefficients and associated errors, large multipliers should not be allowed to appear

In the Gaussian method with the selection of the main element by column, it is guaranteed that for all k. The difference between this version of the Gaussian method and the single division scheme is that at the elimination step the coefficient a, which has the maximum absolute value, is selected as the main element. for an unknown in the equations with numbers. Then the equation with the number corresponding to the selected coefficient is swapped with the equation of the system in order to main element took the place of the coefficient

After this permutation, the exclusion of the unknown is carried out, as in the single division scheme.

Example 5.9. Let us solve the system of equations (5.39) using the Gaussian method with the selection of the main element by column on a -bit decimal computer.

Direct move. 1st step. The maximum element of the matrix in the first column is in the first row, so rearranging the equations is not necessary. Here the 1st step is carried out exactly the same as in example 5.8.

2nd step. Among the elements of the matrix of system (5.40), the maximum one belongs to the third equation. Swapping the second and third equations, we obtain the system

After calculation, the last equation of the system is transformed to the form

Reverse move. From the last equation we find Further, we have In this case, the answer turned out to be accurate.

notice, that extra work the selection of the main elements in a partial selection scheme requires an order of actions, which practically does not affect the overall complexity of the method.

Computational stability of the partial selection scheme. A detailed study of the Gauss method shows that the real reason for the instability of the single division scheme is the possibility of unlimited growth of the elements of intermediate matrices in the process of forward motion. Since at step 1 of the partial selection scheme, the following estimate is valid for the elements calculated using formulas (5.42): Therefore, the maximum absolute value of the matrix elements increases at one step by no more than 2 times and in the most unfavorable case, the forward step will give a growth coefficient

The guarantee that the growth of matrix elements is limited makes the partial selection scheme computationally stable. Moreover, the following error estimate turns out to be valid for it:

Here is a computer-computerized solution to the system; its relative error; matrix condition number em - machine epsilon; finally, and some slowly growing function depending on the order of the system (such as power function with a small indicator), growth rate.

The presence of a multiplier in estimate (5.43) indicates that, if large, the partial choice scheme may turn out to be ill-conditioned and a significant loss of accuracy is possible. However, practice matrix calculations shows that significant growth of matrix elements occurs extremely rarely. In the vast majority of cases real value the growth factor does not exceed 8-10. If the system is well conditioned, then the error of the calculated solution is, as a rule, small.

Sometimes to check the quality of the approximate solution x

They calculate the discrepancy and try to judge the degree of closeness of the approximate solution to the exact one by how small the discrepancy is. This method is unreliable with respect to the partial choice scheme, since it is known that it is guaranteed to give small failures. More precisely, this statement can be formulated as follows: the estimate is fair

where is the same as in estimate (5.43). Note that inequality (5.44) does not include the condition number.

3. Gaussian method with samples of the main element throughout the matrix (full selection scheme).

This scheme allows for a violation of the natural order of eliminating unknowns.

At the 1st step of the method, among the elements, the element with the maximum absolute value is determined. The first equation of the system and the equation with the number are swapped. Next, the unknown x is excluded in a standard way from all equations except the first. (which is significantly less than the corresponding value for the partial selection scheme). We emphasize that a matrix has not yet been found for which full choice would give the value Thus, for well-conditioned systems, this version of the Gaussian method is well-conditioned.

However, the guarantee of good conditionality is achieved here at the cost of significant costs for the selection of the main elements. For this, in addition to arithmetic operations It is required to perform approximately comparison operations, which can significantly slow down the process of solving the problem on a computer. Therefore, in most cases, in practice, preference is still given to the partial choice scheme. As already noted, situations where a significant increase in elements occurs when using this version of the Gaussian method are extremely rare. Moreover, these situations can be easily identified using built-in modern programs effective methods tracking the growth of matrix elements.

4. Cases when the selection of main elements is not necessary.

It is known that for some classes of matrices, when using a single division scheme, the main elements are guaranteed to be located on the main diagonal and therefore there is no need to use partial selection. This is the case, for example, for systems with positive definite matrices, as well as for matrices with the following property diagonal dominance:

Matrices that satisfy condition (5.45) are such that in each row the modulus of the element located on the main diagonal is greater than the sum of the moduli of all other elements of the row.

5. Scaling.

Before starting the solution, it is advisable to scale the system so that its coefficients are on the order of unity.

There are two natural way scaling the system The first consists of multiplying each of the equations by some scaling factor. The second consists of multiplying each column of the matrix by the scaling factor, which corresponds to the replacement of variables (in fact, this is a replacement of units of measurement). IN real situations Most often, scaling can be accomplished without significant difficulties. However, we emphasize that in general case a satisfactory scaling method has not yet been found.

In practice, scaling is usually done by dividing each equation by its largest coefficient in magnitude. This is a completely satisfactory method for most real-life problems.

Today we are looking at the Gauss method for solving systems of linear algebraic equations. You can read about what these systems are in the previous article devoted to solving the same SLAEs using the Cramer method. The Gauss method does not require any specific knowledge, you only need attentiveness and consistency. Despite the fact that from the point of view of mathematics, it is enough to apply it school preparation, students often find it difficult to master this method. In this article we will try to reduce them to nothing!

Gauss method

M Gaussian method– the most universal method for solving SLAEs (with the exception of very large systems). Unlike what was discussed earlier, it is suitable not only for systems that have a single solution, but also for systems that have an infinite number of solutions. There are three possible options here.

  1. The system has a unique solution (the determinant of the main matrix of the system is not equal to zero);
  2. The system has an infinite number of solutions;
  3. There are no solutions, the system is incompatible.

So we have a system (let it have one solution) and we are going to solve it using the Gaussian method. How it works?

The Gauss method consists of two stages - forward and inverse.

Direct stroke of the Gaussian method

First, let's write down the extended matrix of the system. For this purpose in main matrix add a column of free members.

The whole essence of the Gauss method is to bring, through elementary transformations, this matrix to a stepped (or as they also say triangular) appearance. In this form, there should be only zeros under (or above) the main diagonal of the matrix.

What you can do:

  1. You can rearrange the rows of the matrix;
  2. If there are equal (or proportional) rows in a matrix, you can remove all but one of them;
  3. You can multiply or divide a string by any number (except zero);
  4. Null rows are removed;
  5. You can append a string multiplied by a number other than zero to a string.

Reverse Gaussian method

After we transform the system in this way, one unknown Xn becomes known, and you can reverse order find all the remaining unknowns by substituting the already known x's into the equations of the system, up to the first.

When the Internet is always at hand, you can solve a system of equations using the Gaussian method online. You just need to enter the coefficients into the online calculator. But you must admit, it is much more pleasant to realize that the example has not been solved computer program, but with your own brain.

An example of solving a system of equations using the Gauss method

And now - an example so that everything becomes clear and understandable. Let a system of linear equations be given, and you need to solve it using the Gauss method:

First we write the extended matrix:

Now let's do the transformations. We remember what we need to achieve triangular in appearance matrices. Let's multiply the 1st line by (3). Multiply the 2nd line by (-1). Add the 2nd line to the 1st and get:

Then multiply the 3rd line by (-1). Let's add the 3rd line to the 2nd:

Let's multiply the 1st line by (6). Let's multiply the 2nd line by (13). Let's add the 2nd line to the 1st:

Voila - the system is brought to the appropriate form. It remains to find the unknowns:

The system in this example has a unique solution. Solving systems with infinite number We will look at solutions in a separate article. Perhaps at first you will not know where to start transforming the matrix, but after appropriate practice you will get the hang of it and will crack SLAEs using the Gaussian method like nuts. And if you suddenly come across a SLA that turns out to be too tough a nut to crack, contact our authors! you can by leaving a request in the Correspondence Office. Together we will solve any problem!

(SLAE), consisting of equations with unknowns:

It is assumed that there is a unique solution to the system, that is.

This article will discuss the reasons for the error that arises when solving a system using the Gauss method, ways to identify and eliminate (reduce) this error.

Description of the method

Process of solving a system of linear equations

according to the Gauss method consists of 2 stages:

1. We assume that . Then we divide the first equation of the system by the coefficient, and as a result we obtain the equation. Then, from each of the remaining equations, the first one is subtracted, multiplied by the corresponding coefficient. As a result, the system is transformed to the form: 2. Assuming that , we divide the second equation by the coefficient and exclude the unknown from all subsequent equations, etc. 3. We obtain a system of equations with a triangular matrix: 1. From the equation of the system we determine 2. From the equation we determine, etc.

Analysis of the method

This method belongs to the class of direct methods for solving a system of equations, which means that final number steps, you can obtain an exact solution, provided that the input data (matrix and right part equations - ) are specified exactly and the calculation is carried out without rounding. To obtain a solution, multiplications and divisions are required, that is, the order of operations.

The conditions under which the method produces an exact solution are not feasible in practice - both input data errors and rounding errors are inevitable. Then the question arises: how accurate a solution can be obtained using the Gauss method, how correct is the method? Let us determine the stability of the solution with respect to the input parameters. Along with the original system, consider the perturbed system:

Let some norm be introduced. - is called the condition number of the matrix.

There are 3 possible cases:

The condition number of a matrix is ​​always . If it is large (), then the matrix is ​​said to be ill-conditioned. In this case, small disturbances on the right sides of the system, caused either by inaccuracy in specifying the initial data, or caused by calculation errors, significantly affect the solution of the system. Roughly speaking, if the error of the right-hand sides is , then the error of the solution will be .

Let us illustrate the results obtained with the following numerical example: Given a system

She has a solution.

Now consider the perturbed system:

The solution to such a system will be a vector.

With a very small perturbation of the right side we obtained incommensurably great outrage solutions. This “unreliability” of the solution can be explained by the fact that the matrix is ​​almost singular: the straight lines corresponding to the two equations almost coincide, as can be seen in the graph:

This result could have been predicted due to the poor conditionality of the matrix:

The calculation is quite complex, comparable to the solution of the entire system, therefore, cruder but simpler to implement methods are used to estimate the error.

Methods for assessing errors

1) Check sum: usually used to prevent random errors in the calculation process without the help of computers.

We compose a control column consisting of control elements of the system:

When transforming equations, the same operations are performed on control elements as on free members Eq. As a result control element of each new equation must be equal to the sum of the coefficients of this equation. A large discrepancy between them indicates errors in the calculations or the instability of the calculation algorithm with respect to the computational error.

2) Relative error of a known solution allows you to obtain a judgment about the error of the decision without significant additional costs.

A certain vector is specified with components that have, if possible, the same order and sign as the components of the desired solution. The vector is calculated, and the system is solved along with the original system of equations.

Let and be the actually obtained solutions of these systems. A judgment about the error of the desired solution can be obtained based on the hypothesis: relative errors when solving systems with the same matrix and different right-hand sides, which are the quantities and respectively, by the elimination method, they do not differ very much big number once.

3) Changing scales - a technique used to obtain an idea of ​​the real magnitude of the error arising due to rounding in calculations.

Along with the original system, the system is solved using the same method

, where and are numbers

If there were no rounding error, then equality would hold for the solutions of the original and scaled systems: . Therefore, for and , which are not powers of two, comparison of vectors gives an idea of ​​the magnitude of the computational error

Improving the Gaussian Elimination Method

The modifications of the Gauss method discussed below can reduce the error of the result.

Selecting the main element

The main increase in error in the method occurs during the forward move, when the leading -th row is multiplied by the coefficients. If the coefficients are 1%20" alt=" >1 ">, then the errors obtained in the previous steps accumulate. To avoid this, a modification of the method is applied Gaussian with selection of the main element. At each step, a selection is added to the usual circuit. maximum element by column as follows:

Let the system of equations be obtained by eliminating the unknowns:

, .

Let us find such that we swap the positions of the -e and -e levels.

In many cases, such a transformation significantly reduces the sensitivity of the solution to rounding errors in calculations.

Iterative improvement of the result

If there is a suspicion that the resulting solution is severely distorted, then you can improve the result as follows. The quantity is called the residual. The error satisfies the system of equations

.

Solving this system, we obtain an approximation to and assume

.

If the accuracy of this approximation is unsatisfactory, then we repeat this operation.

The process can be continued until all components are small enough. In this case, you cannot stop the calculations just because all the components of the residual vector have become sufficiently small: this may be the result of poor conditioning of the coefficient matrix.

Numerical example

Consider, for example, a 7x7 Vandermonde matrix and 2 different right-hand sides:

These systems were solved in two ways. Data type is float. As a result, we got the following results:

Regular method
1 2
1 2 1 2
0.999991 1 0.999996 1
1.00019 1 7.4774e-0052.33e-008
0.998404 1 0.999375 1
1.00667 1 0.00263727 1.12e-006
0.985328 1 0.994149 1
1.01588 1 0.00637817 3.27e-006
0.993538 1 0.99739 1
0,045479 2.9826e-006 0,01818 8.8362e-006
0,006497 4.2608e-007 0,0045451 2.209e-006
0,040152 4.344e-005 0,083938 2.8654e-006
With leading element selection by line
1 2
1 2 1 2
1 1 1 1
1 1 -3.57628e-0051.836e-007
1.00001 1 1.00031 1
0.999942 1 -0.00133276 7.16e-006
1.00005 1 1.00302 0,99998
1.00009 1 -0.0033505 1.8e-005
0.99991 1 1.00139 0,99999
0,000298 4.3835e-007 0,009439 5.0683e-005
4.2571e-0056.2622e-008 0,0023542 1.2671e-005
0,010622 9.8016e-007 0,29402 1.4768e-006


Did you like the article? Share with your friends!