The Gauss-Jordan (Gauss-jordan) elimination method of the selected principal element to solve the linear equation Group/inverse matrix

Source: Internet
Author: User

To do data structure in the course of information, mainly to look at the inverse matrix of knowledge.

The Gaussian-approximate (Gauss-jordan) elimination method of the chosen principal element is used in many places, for example, to find the inverse matrix of a matrix, to solve a linear equation group (one of the steps of the LM algorithm), and so on. Its speed is not the fastest, but it is very stable (from the definition of the Internet: A calculation method, if in the calculation process using this method, the rounding error is controlled, the calculation results are less affected, called the method is numerically stable), and its solution process is relatively clear, so people use more. I'll use an example to tell you how to solve the Gauss-jordan method. Mention a few caveats and expand the topic by the way.

You can refer to this link for an explanation of the concepts such as "principal elements" mentioned in this article.

Assume the following equation set:

Written in matrix form is: Ax=b, which:

and x= (X1, X2, X3) T.

Matrix A is now an elementary transformation, while Matrix B also makes the same elementary transformation, when a is a unit matrix, there are:

Obviously, we get the solution x= (1, 2, 4) T of the equation set.

Therefore, we must apply a series of elementary transformations to A and B with a certain strategy, and B is the solution of the equations when a is a unit matrix.

The G-j elimination method of the chosen principal element is used to make the elementary transformation: In each cycle, the main element is first searched, and the main element is moved to the main diagonal of the matrix by the row transform (no column transformation required), then all the elements within the row of the main element are divided by the main element, making the main element 1 , and then observe the other elements on the column where the main element is located, multiplying the row where they are in the row minus the main element by a certain multiplier, so that the aligns of the main element, and other elements other than the primary, are 0, which makes the column of the main element the form of the unit matrix. This is the work done in a loop. Then, in the process of the second round, regardless of the row and column elements in the previous round of calculations, the main element is found in the remaining matrix range, and then (if it is not on the main diagonal) it is moved to the main diagonal, and the column is processed again, and is listed in the form of the unit matrix. The rest of the steps and so forth. For an example of a specific computational process, consider the process of the inverse matrix that I'm lifting.

If we want to solve n equations with the same coefficient matrix and different right-end vectors, when designing the program, there is no need to "solve N-Order equations", we can express all the right-end vectors in the program with the data structure of the matrix (similar to the two-dimensional array), when the coefficient matrix is transformed by the line, Each right-end vector in the matrix also does the same transformation, so that in the process of solving the operation, we are actually solving n equations at the same time, which is a place to pay attention to.

So why can the G-j method be used to find the inverse matrix?

Suppose Ax=e, where A is an n-order coefficient matrix (compared to the above solution of a linear equation), E is the unit matrix, i.e. e= (e1,e2,..., en), where ei (i=1,2,..., N) is the unit column vector, and X is a matrix of n column vectors, x= (x1,x2,..., xn), where XI (i=1,2,..., N) is the column vector. Therefore, the equation ax=e can be regarded as solving n linear equations Axi=ei (i=1,2,..., N), after all the XI is obtained, that is, the Matrix X. And by Ax=e, the matrix x is the inverse matrix of a, namely x=a-1. In this way, the inverse matrix of a is obtained. Therefore, the process of the inverse matrix is turned into the process of understanding the linear equations, so we can use the Gauss-jordan elimination method to find the inverse matrix.

When the inverse matrix is obtained, the coefficient matrix A and the unit matrix E can share a single storage area, and the coefficient matrix is replaced by its inverse matrix gradually during each reduction.

Here, I use a practical example to illustrate the process of g-j the inverse matrix:

Like the following equation group:

It is obvious that the coefficients matrix A and the right-end vector Matrix B (there is only one right-end vector) for this equation group are:

In fact, in the process of seeking the inverse matrix, matrix B does not matter, can be ignored, but here still write it out. Below, the unit matrix E is attached to the right of a, forming another matrix (a| E):

Below, we pass the elementary transformation of the Matrix, A to the unit matrix E, and E to the inverse matrix of a. Here are the conversion steps:

    • The "Step 01" main element is selected as 3, so the Row1 (first line) is exchanged with Row2 (the second line):

    • All elements of the line containing the "Step 02" are divided by the main element:

    • "Step 03" Row1-row2,row3-2xrow2:

Now, the original matrix A has a column that is transformed into the form of a unit array.

    • "Step 04" re-select the main element, this time the main element is selected as 5/3, so ROW1÷5/3 (all elements of the row are divided by the principal):

    • "Step 05" Row2-(1/3) xrow1,row3-(4/3) XRow1:

Now, the original matrix A and a column has been transformed into the form of the unit array.

    • "Step 06" re-select the main element, this time the main element is selected as-1/5, so Row3÷ ( -1/5) (the main element is the row of all elements divided by the principal):

    • "Step 07" Row1-(2/5) Xrow3,row2-(1/5) XROW3:

Now, all the columns of the original matrix A are transformed into the form of a unit array.

As can be seen, the above procedure is very suitable for solving computer programming.

At this point, we have completed the conversion from A to E, which uses the method of selecting the main element, but does not use the column exchange. Thus, the original unit matrix E becomes the A-1, namely:

Some people say that in the process of conversion, if a certain step found that the selected main element is 0, what should I do? Of course, this is not going to happen (the matrix is singular).

Reprint Please specify source:http://www.codelast.com/

The Gauss-Jordan (Gauss-jordan) elimination method of the selected principal element to solve the linear equation Group/inverse matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.