Solving systems of linear equations using the Gaussian method. Single division scheme

When solving a system of equations

The simplest version of the Gaussian method results in large errors. The reason is the appearance of large coefficients, the rounding of which results in a large absolute error D ~ 0.5. In turn, large coefficients are obtained after dividing by a small leading coefficient .

Conclusion: To reduce the impact of rounding errors, you need to choose a leading element that is not just different from 0, but also large enough.

First modification of Gauss's method– search by strings. In the algorithm, the leading element must be selected from the condition.

Lack of modification. Suppose x i is found with an error of D. Then, when searching for any x s, it is necessary, according to the inverse formula, to multiply . In this case, the error D will also be multiplied by . If the value is large, the error will increase.

Conclusion: it is necessary to ensure that the leading element is not just large, but the largest modulo in its line. Then, when normalizing the leading line, all other coefficients, according to formula (5), will be less than 1 in absolute value, and the errors will be decrease.

Second modification of the Gauss method– search by columns. This requirement can be met if the unknowns x i are excluded in random order, and the leading line is searched for , delivering . This will be the next leading element. After determining the leading element, swap the k-th and r-th columns.

Attention. With such a replacement, the numbering of the unknowns x i changes. To ensure such a replacement, it is necessary to enter an array p 1 ,…p n with the real numbers of the unknowns during programming. At the beginning of the forward stroke, all p i = i are the usual numbering. After finding the leading element, swap p k and p r . During the reverse stroke, the renumbered x i are calculated using formula (7). After calculating all the unknowns, we must put y]:=x[i], and an array y[i] will be the final solution to the problem.

The third modification of the Gauss method– full search. The delivering element is selected as the leader. In this case, the k-th and r-th columns, p k and p r, as well as the m-th and k-th rows are swapped. This modification provides maximum accuracy, but is also the most complex.



Application of the Gauss method to solve various linear algebra problems

1. Matrix inversion. Let it be necessary to calculate the inverse matrix of the square matrix A. Let us denote X = A –1. As you know, AX = I, where I is the identity matrix, in which 1s are located along the diagonal, and the remaining elements are 0. In other words, the i-th column of matrix I is equal to

(1 is in the i-th place). Let x (i) be the i-th column of the matrix X. Then, by virtue of the matrix multiplication rule (the row is multiplied by the column), we have A x (i) = e (i). This means that to invert the matrix we need to solve n systems of linear equations with identical matrices and different right-hand sides:

Oh = e (1) ; Oh = e (2) ; …; Oh = e (n) . (2.1)

Having solved these systems, we find that the found solutions x (1), x (2), ..., x (n) are columns of the matrix A –1.

2. Calculation of determinants. In the process of converting matrix A to triangular form using the Gaussian method, we performed the following actions with it:

1) rearranged rows or columns depending on the modification of the method;

2) divide the leading line by a non-zero leading element;

3) a leading row multiplied by a certain number was added to the rows of the matrix.

As is known, during such transformations the determinant of the matrix undergoes corresponding changes:

1) changes sign;

2) is divided by the same element;

3) does not change.

After the forward move, matrix A will be reduced to upper triangular form with ones on the main diagonal. The determinant of such a matrix is ​​obviously equal to 1. Taking into account the changes that the determinant of matrix A underwent during the transformation process, we have the following formula:

det A = (–1) s × a 11 × a 22 ×…× a n n ,

where a j j are leading elements, s is the number of permutations of rows and/or columns when searching for leading elements.

TEST QUESTIONS AND TASKS

1. Manually implement the Gaussian method (with search in rows, columns, throughout the entire matrix - depending on the task option) for a given system of equations

and complete the following tasks

1) Solve this system of equations

2) Calculate the determinant of the matrix of this system ( Gaussian method– see p 2 ).

3) Invert the matrix of this system ( Gaussian method– see p 1 ).

In the future, use the result of solving this problem as a test example.

2. Create a program for solving a linear system using the Gaussian method (with a search in rows, columns, throughout the entire matrix - depending on the version of the task) and perform matrix inversion using this program.

We continue to consider systems of 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, during his lifetime, received recognition as the greatest mathematician of all time, a genius, and even the nickname “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 a unique solution. 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! In 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 return to the simplest system from the lesson 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 – this is the same matrix of the system plus a column of free terms, 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 there are (or have appeared) proportional (as a special case - identical) rows in the matrix, then you should 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 is very useful because it simplifies further transformations of the matrix.

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. Let's look at our matrix from a 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.

The unit in the top left corner is 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 “writing in” 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 this example, this is easy to do; we 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 already been noted several times, 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 high degree of probability we can say 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, this is a fairly easy example, since the first column already has one zero, and there are fewer elementary transformations 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 another conventional 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. You can confidently learn to solve systems using other methods (Cramer’s method, matrix method) literally the first time - they have 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 a more complex example to solve on their own:

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 systems of linear algebraic equations (SLAEs). 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 is ​​equal to zero;
  • thirdly, the Gaussian method leads to results with a relatively small number of computational operations.

Brief overview of the article.

First, we give the necessary definitions and introduce notations.

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 the sequential elimination of unknown variables. Therefore, the Gaussian method is also called the method of sequential elimination of unknowns. We will show detailed solutions of 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. Typically, an extended matrix is ​​denoted by the letter T, and the column of free terms is separated by a 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 an 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 by adding the left side of the first to the left side of the second equation, and the right side to the right side, 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. The process of sequentially finding unknown variables while 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 unknown 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 non-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 sides of the second, third and fourth equations, 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, to the elements of the last row 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 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. It is better to move from decimal fractions 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 values, we will obtain different solutions to the system 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.

Solve a homogeneous system of 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:

The Gaussian method, also called the method of sequential elimination of unknowns, is as follows. Using elementary transformations, a system of linear equations is brought to such a form that its matrix of coefficients turns out to be trapezoidal (the same as triangular or stepped) or close to trapezoidal (direct stroke of the Gaussian method, hereinafter - simply straight stroke). An example of such a system and its solution is in the figure above.

In such a system, the last equation contains only one variable and its value can be unambiguously found. The value of this variable is then substituted into the previous equation ( inverse of the Gaussian method , then just the reverse), from which the previous variable is found, and so on.

In a trapezoidal (triangular) system, as we see, the third equation no longer contains variables y And x, and the second equation is the variable x .

After the matrix of the system has taken a trapezoidal shape, it is no longer difficult to understand the issue of compatibility of the system, determine the number of solutions and find the solutions themselves.

Advantages of the method:

  1. when solving systems of linear equations with more than three equations and unknowns, the Gauss method is not as cumbersome as the Cramer method, since solving with the Gauss method requires fewer calculations;
  2. the Gauss method can solve indeterminate systems of linear equations, that is, those that have a general solution (and we will analyze them in this lesson), and using the Cramer method, we can only state that the system is indeterminate;
  3. you can solve systems of linear equations in which the number of unknowns is not equal to the number of equations (we will also analyze them in this lesson);
  4. The method is based on elementary (school) methods - the method of substituting unknowns and the method of adding equations, which we touched on in the corresponding article.

In order for everyone to understand the simplicity with which trapezoidal (triangular, step) systems of linear equations are solved, we present a solution to such a system using reverse motion. A quick solution to this system was shown in the picture at the beginning of the lesson.

Example 1. Solve a system of linear equations using inverse:

Solution. In this trapezoidal system the variable z can be uniquely found from the third equation. We substitute its value into the second equation and get the value of the variable y:

Now we know the values ​​of two variables - z And y. We substitute them into the first equation and get the value of the variable x:

From the previous steps we write out the solution to the system of equations:

To obtain such a trapezoidal system of linear equations, which we solved very simply, it is necessary to use a forward stroke associated with elementary transformations of the system of linear equations. It's also not very difficult.

Elementary transformations of a system of linear equations

Repeating the school method of algebraically adding the equations of a system, we found out that to one of the equations of the system we can add another equation of the system, and each of the equations can be multiplied by some numbers. As a result, we obtain a system of linear equations equivalent to this one. In it, one equation already contained only one variable, substituting the value of which into other equations, we come to a solution. Such addition is one of the types of elementary transformation of the system. When using the Gaussian method, we can use several types of transformations.

The animation above shows how the system of equations gradually turns into a trapezoidal one. That is, the one that you saw in the very first animation and convinced yourself that it is easy to find the values ​​of all unknowns from it. How to perform such a transformation and, of course, examples will be discussed further.

When solving systems of linear equations with any number of equations and unknowns in the system of equations and in the extended matrix of the system Can:

  1. rearrange lines (this was mentioned at the very beginning of this article);
  2. if other transformations result in equal or proportional rows, they can be deleted, except for one;
  3. remove “zero” rows where all coefficients are equal to zero;
  4. multiply or divide any string by a certain number;
  5. to any line add another line, multiplied by a certain number.

As a result of the transformations, we obtain a system of linear equations equivalent to this one.

Algorithm and examples of solving a system of linear equations with a square matrix of the system using the Gauss method

Let us first consider solving systems of linear equations in which the number of unknowns is equal to the number of equations. The matrix of such a system is square, that is, the number of rows in it is equal to the number of columns.

Example 2. Solve a system of linear equations using the Gauss method

When solving systems of linear equations using school methods, we multiplied one of the equations term by term by a certain number, so that the coefficients of the first variable in the two equations were opposite numbers. When adding equations, this variable is eliminated. The Gauss method works similarly.

To simplify the appearance of the solution let's create an extended matrix of the system:

In this matrix, the coefficients of the unknowns are located on the left before the vertical line, and the free terms are located on the right after the vertical line.

For the convenience of dividing coefficients for variables (to obtain division by unity) Let's swap the first and second rows of the system matrix. We obtain a system equivalent to this one, since in a system of linear equations the equations can be interchanged:

Using the new first equation eliminate the variable x from the second and all subsequent equations. To do this, to the second row of the matrix we add the first row, multiplied by (in our case, by ), to the third row - the first row, multiplied by (in our case, by ).

This is possible because

If there were more than three equations in our system, then we would have to add to all subsequent equations the first line, multiplied by the ratio of the corresponding coefficients, taken with a minus sign.

As a result, we obtain a matrix equivalent to this system of a new system of equations, in which all equations, starting from the second do not contain a variable x :

To simplify the second line of the resulting system, multiply it by and again obtain the matrix of a system of equations equivalent to this system:

Now, keeping the first equation of the resulting system unchanged, using the second equation we eliminate the variable y from all subsequent equations. To do this, to the third row of the system matrix we add the second row, multiplied by (in our case by ).

If there were more than three equations in our system, then we would have to add a second line to all subsequent equations, multiplied by the ratio of the corresponding coefficients taken with a minus sign.

As a result, we again obtain the matrix of a system equivalent to this system of linear equations:

We have obtained an equivalent trapezoidal system of linear equations:

If the number of equations and variables is greater than in our example, then the process of sequentially eliminating variables continues until the system matrix becomes trapezoidal, as in our demo example.

We will find the solution “from the end” - the reverse move. For this from the last equation we determine z:
.
Substituting this value into the previous equation, we'll find y:

From the first equation we'll find x:

Answer: the solution to this system of equations is .

: in this case the same answer will be given if the system has a unique solution. If the system has an infinite number of solutions, then this will be the answer, and this is the subject of the fifth part of this lesson.

Solve a system of linear equations using the Gaussian method yourself, and then look at the solution

Here again we have an example of a consistent and definite system of linear equations, in which the number of equations is equal to the number of unknowns. The difference from our demo example from the algorithm is that there are already four equations and four unknowns.

Example 4. Solve a system of linear equations using the Gauss method:

Now you need to use the second equation to eliminate the variable from subsequent equations. Let's carry out the preparatory work. To make it more convenient with the ratio of coefficients, you need to get one in the second column of the second row. To do this, subtract the third from the second line, and multiply the resulting second line by -1.

Let us now carry out the actual elimination of the variable from the third and fourth equations. To do this, add the second line, multiplied by , to the third line, and the second, multiplied by , to the fourth line.

Now, using the third equation, we eliminate the variable from the fourth equation. To do this, add the third line to the fourth line, multiplied by . We obtain an extended trapezoidal matrix.

We obtained a system of equations to which the given system is equivalent:

Consequently, the resulting and given systems are compatible and definite. We find the final solution “from the end”. From the fourth equation we can directly express the value of the variable “x-four”:

We substitute this value into the third equation of the system and get

,

,

Finally, value substitution

The first equation gives

,

where do we find “x first”:

Answer: this system of equations has a unique solution .

You can also check the solution of the system on a calculator using Cramer's method: in this case, the same answer will be given if the system has a unique solution.

Solving applied problems using the Gauss method using the example of a problem on alloys

Systems of linear equations are used to model real objects in the physical world. Let's solve one of these problems - alloys. Similar problems are problems on mixtures, the cost or share of individual goods in a group of goods, and the like.

Example 5. Three pieces of alloy have a total mass of 150 kg. The first alloy contains 60% copper, the second - 30%, the third - 10%. Moreover, in the second and third alloys taken together there is 28.4 kg less copper than in the first alloy, and in the third alloy there is 6.2 kg less copper than in the second. Find the mass of each piece of the alloy.

Solution. We compose a system of linear equations:

We multiply the second and third equations by 10, we obtain an equivalent system of linear equations:

We create an extended matrix of the system:

Attention, straight ahead. By adding (in our case, subtracting) one row multiplied by a number (we apply it twice), the following transformations occur with the extended matrix of the system:

The direct move is over. We obtained an expanded trapezoidal matrix.

We apply the reverse move. We find the solution from the end. We see that.

From the second equation we find

From the third equation -

You can also check the solution of the system on a calculator using Cramer's method: in this case, the same answer will be given if the system has a unique solution.

The simplicity of Gauss's method is evidenced by the fact that it took the German mathematician Carl Friedrich Gauss only 15 minutes to invent it. In addition to the method named after him, the saying “We should not confuse what seems incredible and unnatural to us with the absolutely impossible” is known from the works of Gauss - a kind of brief instruction on making discoveries.

In many applied problems there may not be a third constraint, that is, a third equation, then you have to solve a system of two equations with three unknowns using the Gaussian method, or, conversely, there are fewer unknowns than equations. We will now begin to solve such systems of equations.

Using the Gaussian method, you can determine whether any system is compatible or incompatible n linear equations with n variables.

The Gauss method and systems of linear equations with an infinite number of solutions

The next example is a consistent but indeterminate system of linear equations, that is, having an infinite number of solutions.

After performing transformations in the extended matrix of the system (rearranging rows, multiplying and dividing rows by a certain number, adding another to one row), rows of the form could appear

If in all equations having the form

Free terms are equal to zero, this means that the system is indefinite, that is, it has an infinite number of solutions, and equations of this type are “superfluous” and we exclude them from the system.

Example 6.

Solution. Let's create an extended matrix of the system. Then, using the first equation, we eliminate the variable from subsequent equations. To do this, add to the second, third and fourth lines the first, multiplied by :

Now let's add the second line to the third and fourth.

As a result, we arrive at the system

The last two equations turned into equations of the form. These equations are satisfied for any value of the unknowns and can be discarded.

To satisfy the second equation, we can choose arbitrary values ​​for and , then the value for will be determined uniquely: . From the first equation the value for is also found uniquely: .

Both the given and the last systems are consistent, but uncertain, and the formulas

for arbitrary and give us all solutions of a given system.

Gauss method and systems of linear equations without solutions

The next example is an inconsistent system of linear equations, that is, one that has no solutions. The answer to such problems is formulated this way: the system has no solutions.

As already mentioned in connection with the first example, after performing transformations, rows of the form could appear in the extended matrix of the system

corresponding to an equation of the form

If among them there is at least one equation with a nonzero free term (i.e. ), then this system of equations is inconsistent, that is, it has no solutions and its solution is complete.

Example 7. Solve the system of linear equations using the Gauss method:

Solution. We compose an extended matrix of the system. Using the first equation, we exclude the variable from subsequent equations. To do this, add the first line multiplied by to the second line, the first line multiplied by the third line, and the first line multiplied by the fourth line.

Now you need to use the second equation to eliminate the variable from subsequent equations. To obtain integer ratios of coefficients, we swap the second and third rows of the extended matrix of the system.

To exclude the third and fourth equations, add the second one multiplied by , to the third line, and the second multiplied by , to the fourth line.

Now, using the third equation, we eliminate the variable from the fourth equation. To do this, add the third line to the fourth line, multiplied by .

The given system is therefore equivalent to the following:

The resulting system is inconsistent, since its last equation cannot be satisfied by any values ​​of the unknowns. Therefore, this system has no solutions.

2. Modifications of the Gauss method

Gaussian method with selection of the main element. The main limitation of the Gauss method is the assumption that all elements into which division is performed at each forward step are not equal to zero. These elements are called principal elements and are located on the main diagonal of the matrix A.

If at some step of the forward motion the main element = 0, then further solution of the system is impossible. If the main element has a small value, close to zero, then a strong increase in error is possible due to a sharp increase in the absolute value of the coefficients obtained as a result of division. In such situations, the Gaussian method becomes unstable.

The Gauss method with the choice of the main element allows us to exclude the occurrence of such cases.

The idea of ​​this method is as follows. At some kth step of the forward motion, it is not the next numbered variable x k that is excluded from the equations, but the variable whose coefficient is the largest in absolute value. This ensures that there is no division by zero and that the method remains stable.

If at the kth step ¹ is chosen as the main element, then in the matrix A¢ the rows with numbers k and p and the columns with numbers k and q must be swapped.

Rearranging the rows does not affect the solution, since it corresponds to reversing the equations in the system, but rearranging the columns means changing the numbering of the variables. Therefore, information about all rearranged columns must be preserved so that after the reverse move is completed, the original numbering of the variables can be restored.

There are two simpler modifications of the Gauss method:

With selection of the main element by column;

With selection of the main element by line.

In the first case, the largest element in absolute value of the kth row (among the elements , i = ) is selected as the main element. In the second - the largest element in absolute value of the kth column (among the elements , i = ). The first approach is most widespread, since the numbering of variables does not change here.

It should be noted that these modifications apply only to the forward motion of the Gaussian method. The reverse move is performed without changes, but after obtaining a solution, it may be necessary to restore the original numbering of the variables.

LU decomposition. In modern computer software, the Gaussian method is implemented using LU decomposition, which is understood as representing the coefficient matrix A as the product A = LU of two matrices L and U, where L is the lower triangular matrix, U is the upper triangular matrix

If the LU expansion is obtained, then the solution of the original system of equations (2) is reduced to the sequential solution of the following two systems of equations with triangular coefficient matrices

linear algebraic equation numerical


where Y = is a vector of auxiliary variables.

This approach allows you to repeatedly solve systems of linear equations with different right-hand sides B. In this case, the most labor-intensive part (LU decomposition of the matrix A) is performed only once. This procedure corresponds to the forward run of the Gaussian method and has a complexity estimate of O(n 3). Further solution of systems of equations (6) and (7) can be performed multiple times (for different B), and the solution of each of them corresponds to the inverse of the Gaussian method and has a computational complexity estimate of O(n 2).

To obtain the LU decomposition, you can use the following algorithm.

1. For the original system (1), perform the forward progression of the Gaussian method and obtain a system of triangular equations (5).

2. Determine the elements of the matrix U according to the rule

u ij = C ij (i = ; j = )

3. Calculate the elements of matrix L according to the rules

Calculation formulas for solving system (6) have the following form:

y 1 = b 1 / l 11 ;

Calculation formulas for solving system (7)

(i = n - 1, n - 2, …, 1).




At the same time, actually finding the inverse matrix is ​​a rather labor-intensive process and its programming can hardly be called an elementary task. Therefore, in practice, numerical methods for solving systems of linear equations are more often used. Numerical methods for solving systems of linear equations include the following: Gauss method, Cramer method, iterative methods. In the Gauss method, for example, they work on...

35437 x4=0.58554 5 x1=1.3179137 x2=-1.59467 x3=0.35371 x4=0.58462 6 x1=1.3181515 x2=-1.59506 x3=0.35455 x4=0.58557 5. Comparative analysis of various methods of numerical differentiation and integration 5.1 Numerical differentiation methods 5.1.1 Description method Let us assume that in a neighborhood of the point xi the function F (x) is differentiable a sufficient number of times. ...




In Turbo Pascal 7.0 for solving systems of linear algebraic equations using the simple iteration method. 1.2 Mathematical formulation of the problem Let A be a non-singular matrix and we need to solve a system where the diagonal elements of matrix A are non-zero. 1.3 Review of existing numerical methods for solving the problem Gaussian method In the Gaussian method, the SLAE matrix using equivalent...

Numbers). Next, using formulas (2), xn-1, xn-2,..., x1 are successively found for i=n-1, n-2,...,1, respectively. Thus, the solution of equations of type (1) is described by a method called the sweep method, which is reduced to calculations using three simple formulas: finding the so-called sweep coefficients δi, λi using formulas (3) for i=1,2,…,n (direct sweep) and then unknown xi by...