Decomposing A into L and U (matrices)

  • Thread starter physicsCU
  • Start date
  • Tags
    Matrices
In summary, the conversation discusses the task of writing a program to create lower and upper triangular matrices from a given matrix A. The idea of using if statements is suggested, with specific conditions for U(i,j) and L(i,j) based on the values of i and j. The use of a nested for loop is also mentioned as a possible solution, with the language being either Fortran or Matlab. The programmer shares that they have successfully written the program and are willing to share it with others.
  • #1
physicsCU
202
1
I need to write a program to take A and make the lower and upper triangular matrices for it.

My idea is to use if statements, since what I am doing is setting U(i,j) equal to A(i,j) if i <= j and U(i,j) = 0 if i > j

For L(i,j), its equal to A(i,j) if i > j, 1 if i = j and 0 if i < j.

Any ideas how to do this? I am stumped on how to get the i and j parts working.
 
Physics news on Phys.org
  • #2
I guess it depends on what language. If it were fortran (it's been a long time) I'd say you have to do a nested for...next loop.

For i=1 to #_of_colums
For j=1 to #_of_rows
Blah blah blah
Next j
Next i
 
  • #3
this is matlab, sorry.

i came to the same conclusion, but i guess i will have to do a nested for loop. I hate those. Oh well.

I think this will work, I will try to write the program today, but two other labs are due soon as well.
 
  • #4
Just wanted to update that I wrote the program the way we both thought of, and it worked the right way right off the bat!

That is a first for me i think!

Overall its a quick little loop and I would be willing to share it once my lab is turned in.
 
  • #5
Sweeeeeeeeeettt.
 

1. What is the purpose of decomposing a matrix A into L and U?

Decomposing a matrix A into L and U is a useful technique in linear algebra for solving systems of linear equations. It allows us to break down a complex matrix into two simpler matrices that are easier to work with.

2. How does the process of decomposing A into L and U work?

The process of decomposing A into L and U involves using Gaussian elimination to reduce the original matrix into an upper triangular matrix (U), and then using the elimination steps to create a lower triangular matrix (L). The resulting matrices L and U can then be used to solve for the original matrix A.

3. What are the benefits of using L and U matrices instead of the original matrix A?

There are several benefits to using L and U matrices instead of the original matrix A. These include easier computation and manipulation, as well as the ability to solve systems of equations more efficiently. Additionally, L and U matrices can provide insight into the structure and behavior of the original matrix A.

4. Can any matrix A be decomposed into L and U?

Yes, any square matrix A can be decomposed into L and U. However, not all matrices will have a unique decomposition. Matrices with certain properties, such as being symmetric or having a diagonal that is all non-zero, will have a unique decomposition into L and U.

5. Are there other methods for decomposing a matrix besides using L and U?

Yes, there are other methods for decomposing a matrix, such as the LU decomposition and the QR decomposition. Each method has its own advantages and uses, and the choice of which method to use will depend on the specific problem at hand.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
720
  • Engineering and Comp Sci Homework Help
Replies
19
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
940
  • Calculus and Beyond Homework Help
Replies
0
Views
148
  • Engineering and Comp Sci Homework Help
Replies
1
Views
839
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
603
Back
Top