# 3-How to solve for x-y by L-U Decomposition?

## How to solve for x-y by L-U Decomposition?

### Illustration by using the Gauss elimination method for the U matrix formation.

We have a matrix as A with two rows and two columns as (2 3 3 4), how to develop the upper matrix U for matrix A?

We use Gauss elimination through elementary row operations to convert the matrix A into an upper matrix and later, use the back substitution to solve for the values of unknowns.

For matrix A 2×2 which is given as (2 3 3 4) To convert this matrix into an upper matrix, we want this diagonal to be non-zeros and let  a21 be zero.

Using a11 as a  pivot, divide a21/a11 multiply by the minus sign by R1, and add the result to row R2. The second row  R2 will be changed.

We will have a new second row as (0- ½). As we have noticed, there was no operation in the first row of matrix A, which is the same in the upper matrix. Element U22, second row /2nd column is equal to (a22-(a12/a11).

What about the Lower Matrix? We have by definition L11=L22=1 and L12=0. While for L21 it is equal to (a21/a11), considering that a11 is a pivot. Place the result as a new second row, we can get a zero value for U21, the first element in the second row and first column.

If we want to check whether  L*U  multiplication will lead us to ( 2 3 3 4), we can use row-column multiplication. (1*2+0*0)=2, and (1*3+(0*-1/2)=3. (3/2*2+1*0) =3+0=3 which we will lead us to 3 and (3/2 * 3+1*(-1/2)=4.50-0.50=4. We have a valid L*U  through a valid multiplication. We will use the same matrix A to solve for the values of two unknowns x&y.

Now the A matrix as the product of L*U is shown by using the matrix symbols.

### Write an expression of (L*C)=b as the first step to developing an expression to solve for x-y for two equations-L-U.

Consider the two simultaneous linear equations, The two equations can be expressed by using matrices as A*X=b, where A is a matrix 2×2 for our example, Matrix X, is a ( 2×1) matrix that contains (X Y), the unknown variables, while C is a matrix (2×1) of value (13 18). we use matric C as an intermediate stage to solve for x-y by L-U Decomposition.

Since we have expressed that matrix A is a product of(L*U), we can further write a new expression as (L*U)*X=b.
The values of L& U and B are known, the only unknown is the column vector matrix X.

A new expression as (U*x)=C, C is a new item that is unknown. Finally, A*x=b can be expressed as(L)*C=b. To solve for a value of C, an inverse matrix of L-1 is to be presented and to be multiplied by the two sides of the given equation. That process will enable us to get a value for matrix C. The modified expression is shown in the next slide image.

### Find the inverse of the L matrix as the second step to solve for x-y by L-U decomposition.

In the lower matrix  L, the element is (1  0, +3/2 1), then its inverse of the lower matrix is L-1, we can estimate the determinant value of l, which is =1-0=1.

We divide the adjoint matrix by the determinant. We will swap and make a change of sign of (3/2) to (-3/2), and( 0) Will be the same. The final value of L-1 can be expressed as a matrix of 2×2 and is = ( 1 0 -3/2 1).

### Get the value of C as the third step to develop an expression to solve for x-y by L-U decomposition.

Get the value of C as the third step to develop an expression to solve for x-y by L-U decomposition. The matrix c is the product of (L-1)*(B), since both two values are known we can then get the value of C, multiplying two matrices(2×2) by(2×1) will yield a new matrix with (2×1) with a value of (13 -1.5). The details of the estimation is shown in the next slide image.

### Get the value of X as the fourth step to solve for x-y by L-U decomposition.

Get the value of X as the fourth step to solve for x-y f by L-U decomposition. Remember that we have the expression of U*x=C, get an inverse matrix of C which is a new matrix of 2×2, the X=(U-1)*X, Then the final value of X is( 2 3), the matrix x is a (2×1) matrix. The value of x=2 and y=3.

### Substitute by the values of x and y to check whether x,y values are right or wrong.

After checking the two given equations we find that the estimated value of x and Y satisfy the two equations. We have x = 2 &  y = 3. In the last step, we would like to check if our solution is correct. 2x+3*y=13 and + 3x + 4 y=18. We introduce x value as=2 and y value is 3, then (2*2+3*3)=13, which will give us the right-hand side as 13.

While 3*2+4 *3=6+12=18, which is already equal to the right-hand side of the second equation. Both are OK. In the end, we have used L&U the inverse Of L, and the inverse of U to estimate the values for x& y for simultaneous equations.