Gaussian elimination element method

Source: Internet
Author: User

Self-taught a burst of Gauss extinction, feeling this thing listening to the advanced, in fact, is still very logical (logical). Below I will share my own understanding of the Gaussian elimination, hope can also help beginners understand the algorithm.

First, we need to be clear: the purpose of Gaussian elimination is to find the solution of the linear equation Group.

So, let's start with an example of a small solution equation set:

Great math geniuses .... Just tell me 233, I put this equation set AK.

Still thinking of the students, come to think ~ the answer is (2,3,3)

Let's review how the teachers in junior high schools teach us how to solve the equation.

(because I found that only 10 photos can be uploaded ....) So there is no need to write board ... () The number in the () indicates the subscript)

First step: ②*2-① x (1) Get 7x (2) +3x (3) =30 ... ④

Step two: ③*2-①*3 again x (1) × (2) +7x (3) =18 ... ⑤

Step Three: ④+⑤*7 x (2) to 52x (3) =156 ... ⑥

Solution of X (3) =156/52=3

Then substituting ④ or ⑤ to eliminate X (2) = 3, and then X (2), X (3) values into the ① type, x (1) =2

Does it feel simple? .... In fact, this is the idea of Gaussian elimination--addition and subtraction of the yuan & into the elimination of the Yuan

Of course, the Gaussian elimination is to become a ' Thief King ' algorithm (to be able to solve other general equations), of course, there must be a general method to carry out this step.

First we apply a thing called a matrix, we take out the coefficients of each variable in the equation set to become the coefficients of the matrix, the coefficients of the same equation on the same line, the coefficients of the same variable are placed in the same column

Just like the equation above can be turned into a 3*4 matrix A

The 4th column is the constant term, and the other three columns are the coefficients of the equation. Now let's define some basic line transformations about matrices.

Exchange transformation: RI<->RJ, which corresponds to exchanging all the elements of Ri with Rj

Second, Multiply method transformation: Ri=ri*k, indicating that all elements of the Ri row are multiplied by a constant k

Third, elimination transformation: Ri=ri+rj*k, indicating that all the elements of the Ri line plus the Rj line element k times

Does wowow~ feel the relationship between the base line of the Matrix and the transformation of the peace and the elimination of the element?

The elements in the matrix are the coefficients in the equation, so that we can use the matrix transformation to eliminate the coefficients of some variables in the equation to 0, and then we can find out the value of a variable.

For example (with the matrix above): R1:2 3 1, r2:1 5 2 23

We want to eliminate the first element in the first row, then we get the new r1:0-7-3-30 with the R1-R2*2 (elimination transformation), which is equivalent to our addition and elimination of the yuan.

So what kind of state does our final matrix desire to get?

In general we will have two states of desire:

Mode one: "Standard matrix"

Obviously, we can find that the value of this variable can be obtained by dividing the coefficient of the variable by a constant term by a variable of 0 in each row.

Let's talk about how to get a matrix like this.

First we select the first column from the first row to leave the element, and all the other rows with the first row eliminate the coefficients on the column I selected. As an example:

"2" 3 1 16//"" means which column is eliminated, and the column on the other row is eliminated as 0

"0" 3.5 1.5 15 ..... r2=r2-r1*0.5

"0"-0.5 3.5 9 ..... r3=r3-r1*1.5

Above is the method of practical number solution, and the method of solving the integer solution (eliminating the target coefficient with least common multiple when the element is eliminated)

"2" 3 1 16

"0" 7 3 30 because of LCM = 2, so r2=r2* (2/1)-r1* (2/2) =r2*2-r1*1

"0"-1 7 18 because LCM (3,2) = 6, so r3=r3* (6/3)-r1* (6/2) =r3*2-r1*3

...... The other rows and so on, because when the column I is processed, the first i-1 column is only one element of not 0, so the addition and subtraction of the time will not affect (the elements have been decided to add a 0*k, no impact) hope that you hand push this least common multiple the following steps, See if we get the matrix below

2 0 0 4

0 7 0 21

0 0 52 156

Mode two: "Upper triangular Matrix"

we can make the matrix into a ladder, so that if we find the solution of the last equation, we can go back to the elimination, the known variable into the equation, and then a layer of the solution out of the unknown until the first line to get all the unknown value.

How to get an upper triangular matrix?

The elimination method is the same as the standard matrix, all using the elimination transformation, let the variable coefficients into 0, and then solve, the difference is that each row does not need to eliminate the element, as long as the current line below the elements of the elimination. Examples (with least common multiple method):

Step1

"2" 3 1 16

"0" 7 3 30

"0"-1 7 18

Step2

2 3 1 16

0 "7" 3 30

0 "0" 52 156

End. The X (3) = 3, then the second line, the X (3) =3, the 7x (2) +3*3=30, Solution x (2) = 3, and then the first line, get 2*x (1) +3*3+3=16,x (1) = 2.

This is the two basic conversion methods. Can solve the solution of a linear equation group.

Let's consider some of the things that are related to the equation.

Q1: How to judge the equation without solution?

A1: If the coefficients of all the variables of a row of equations are 0, and the constant term is not 0, the equation is of course no solution.

Q2: What is the condition of the multi-solution of the equation?

A2: If the coefficients of all the variables of a row of equations are 0 and the constant term is 0, then this means that there is a free element (which is the unknown number in this equation that is free to be freely valued), and the numbers of free elements = the number of rows that are all 0, which causes the equation to be much more solvable.

Q3: What does the unique solution of the equation look like?

A3: It's not the top two. Well, in fact, the matrix is the complete fine standard of the upper triangular matrix or standard matrix.

Q4: You said above is the solution of linear real or positive integer solution of the equation, but often encountered in the problem of the solution or equations, how to solve it?

A4: Yes Yes Ah ~ different or equations are often seen in the topic, such as a very classical switch problem .... Use of the idea is still we discussed above the addition and subtraction of the idea, the transformation matrix is also our matrix, but the matrix is usually only the coefficients of 0 and 1, that is, if the change of the column element will affect the row element, for example, open switch 1 can let the lamp 2 and lamp 3 change the state, then A (=a) (1,3 ) = 1, so that it is possible to find out whether the switch 1 is changed by the state of the 2,3. (You may not understand ....) That is, the equations we listed are the pre-and post-state of the known lights, and how these switches are used, then our known amount is the relationship between the lamp and the switch (coefficient) & the State of the lamp (constant term), the unknown quantity is the switch is used, is roughly a (*x[1) "Xor A () *x[2] Xor...xor A (1,n) *x[n] to solve the process of X[1..N], or do not understand just read my other title of the blog good.

The above is about the method of building the lower process, then we solve the equation when our elimination method will become an XOR or extinction, using 1 xor 1=0, if you want to solve a variable I will find a row I of the coefficient is not 0 to the current row (if the current row does not have this element, Can not solve the (the above ordinary equation to solve the same time)), and then find the other current variable coefficient is not 0, xor (each coefficient is different or, including constant), and finally can be converted to a standard or upper triangular matrix, thereby solving.

It is also special to note that if you know the number of free elements of the equation in the Xor equation, you can know how many groups of solutions are in total! Because there are only 1 or 2 possible, so the answer is 2^n (n is the number of free elements)

Q5: What's the use of Gauss elimination?

A5: It is also possible to relate to the expected probability, because the expectation of an event is likely to be related to other events associated with it, for example, I start from the origin, only one step at a time, up or to the right, then go to (I,J) the desired step is from (I-1,J) the desired number of steps * FROM (I-1,J) The probability of coming +1 plus the expected number of steps from (i,j-1) * FROM (i,j-1) come from the probability of +1, is not much like the equations of the group it ... By doing so the equations can also be set up (...). Ah ah ah, actually I began to feel a little bit of a feeling of the mouth .... I haven't played this question ~ Come on, you go to the film gods. ~moto_no.1 also told an online request for Gauss, we can go to see his blog, the probability of what, check the topic can be found (interesting "driving pigs" ...) )

All right.... I'll give you a statement here. I do not know the Welcome comment ~ I will do my best to help everyone.

Gaussian elimination element method

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.