• Advertisement
Sign in to follow this  

Solving linear equations

This topic is 3185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a system of linear equations in this form: A*x = d, where A is a matrix approximately in range of 5x5 up to 20x20. My first question: What is more efficient: 1) Calculating the inverse of A and solving for x with a simple matrix multiplication in this way: x = A^-1 * d, or 2) Directly solving the system of linear equations (with gauss elemination for example). And a little additional question to option 2: In the case I want to programm a solver for a system of linear equations in C++. What is the most efficient method? Gauss-Eleminition? Gauss-Jordan-Elimination? LU-Decomposition? Or something else? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by schupf
My first question: What is more efficient:
1) Calculating the inverse of A and solving for x with a simple matrix multiplication in this way: x = A^-1 * d, or
2) Directly solving the system of linear equations (with gauss elemination for example).


#2 is faster.

Quote:
Original post by schupf
And a little additional question to option 2: In the case I want to programm a solver for a system of linear equations in C++. What is the most efficient method? Gauss-Eleminition? Gauss-Jordan-Elimination? LU-Decomposition?


The LU Decomposition is computed using one of the elimination methods you mentioned, so it's not really a separate method. Anyway, Gaussian elimination is more efficient than Gauss-Jordan. The algorithm you want is "Gaussian Elimination with Pivoting."

(This ignores iterative algorithms like Gauss-Seidel and conjugate gradient... but for small matrices elimination algorithms are better anyway...)

Share this post


Link to post
Share on other sites
Quote:
Original post by Emergent
[...] The algorithm you want is "Gaussian Elimination with Pivoting."

To be more specific, you probably want "Gaussian Elimination with Partial Pivoting."

Share this post


Link to post
Share on other sites
#2 is indeed faster, and Gaussian Elimination with Partial Pivoting is indeed the most efficient algorithm. It is also numerically stable - inverting a matrix, especially up to 20x20, can be numerically dangerous.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement