# fastest solution to simultaneous linear equations

• Aug 2nd 2011, 07:06 AM
fredhenry
fastest solution to simultaneous linear equations
Hi, I'm writing a program which solves for a list of coefficients in
matrix form:
b = [b1,b2,b3...]

The equation I'm trying to solve is:
Ab = z
where A is a symmetric matrix and z has the same dimensions as b.

The obvious solution is b = invs(A) z. However A is at least a 12x12 so
the inverse takes a long time to calculate (obviously).
Is there some other method which is faster?

• Aug 2nd 2011, 02:39 PM
Aryth
Re: fastest solution to simultaneous linear equations
Well, technically, as long as the matrix is not symbolic or ridiculously complex, the inverse method should work. But if you want another method, try LU decomposition followed by either the Gauss-Seidel method or the Jacobi method. Not sure how much faster these methods will be though. They are well researched if you want to find either an algorithm or just a mathematical representation of them somewhere.
• Aug 3rd 2011, 09:19 AM
fredhenry
Re: fastest solution to simultaneous linear equations
Thanks, I will look into them
• Aug 3rd 2011, 09:28 AM
TheChaz
Re: fastest solution to simultaneous linear equations
Quote:

Originally Posted by fredhenry
Thanks, I will look into them

fred,
I don't know if you've seen it yet, but CRG posted a good answer at a cross-posting local...
http://www.mymathforum.com/viewtopic...=linear#p88811

-----------------

Quote:

Originally Posted by CRGreathouse
As a rule of thumb, never invert.

Usually equations like this are solved directly. For example, in gp (see my .sig):
Code:

```A=mathilbert(12) \\ example matrix b=vectorv(12,i,i) \\ example column vector matsolve(A,b)```
This is fast -- the example system can be solved in less than 400 microseconds on my machine, even using rational arithmetic. The 100x100 version takes 40 milliseconds at 28-digit precision.

What language are you using?