Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Given a large (say 10x10) sparse Hermitian matrix with symbolic entries, I need four specific entries of the inverse matrix. It seems wasteful to me to compute 100 entries of which I only need a few in the end.

Is there a way to compute a small number of specific entries of the inverse matrix that is significantly more efficient than finding the inverse matrix and then extracting the elements?

Here's an example. N is half the dimension of the matrix. For N = 8, inverting takes 51 seconds on my university's computer, and we would ideally like to reach much larger N.

A = Table[If[Abs[i - j] == 1, (j - i) a, 0], {i, #}, {j, #}] &;
B = Table[If[Abs[i - j] == 1, b, 0], {i, #}, {j, #}] &;

\[Sigma]1[N_] := B@N + Table[
    If[Abs[i - j] == 0, 2 \[Mu], 0] + If[i == j == 1, -x, 0] + 
     If[i == j == N, -x, 0]
    , {i, N}, {j, N}];
\[Sigma]2[N_] := -B@N + Table[
    +If[i == j == 1, -y, 0] + If[i == j == N, -y, 0]
    , {i, N}, {j, N}];

(* Elements of M *)
el[N_, i_, j_] := Which[i <= N && j <= N,
  \[Sigma]1[N][[i, j]], i > N && j > N,
  \[Sigma]2[N][[i - N, j - N]], i > N && j <= N,
  A[N][[i - N, j]], i <= N && j > N,
  -A[N][[i, j - N]]] 

M[N_] := Table[el[N, i, j], {i, 2 N}, {j, 2 N}];

Daniel Lichtblau's idea LinearSolve[M@8,UnitVector[16,8]] takes 4.1 seconds, so it is certainly much faster than inverting the entire matrix, even if it has to be done seperately for each entry.

share|improve this question
2  
If you have ACM access, search for Lin Lin et al SelInv paper. –  rasher Mar 24 at 21:22
1  
As it is stated, the Q is off-topic. –  Sektor Mar 24 at 21:43
    
This question appears to be off-topic because it is not about Mathematica. –  bobthechemist Mar 24 at 22:21
1  
@bobthechemist I have to disagree here. It is clear that you can do an Inverse matrix calculation in Mathematica, and checking to see whether a fast version of Inverse[m][[{3,4},{2,1}]] exists is not unreasonable. It can be very advantageous. Many functions in Mathematica can be 'cut-off' to stop early and give a restricted set of solutions. Take, for instance, Ordering or Position. –  Sjoerd C. de Vries Mar 24 at 22:28
5  
LinearSolve[mat,ej] will give the jth column only of the inverse, when ej is the jth coordinate axis unit vector. I would expect that to be 2-3 times faster than using Inverse. –  Daniel Lichtblau Mar 24 at 22:37

1 Answer 1

up vote 0 down vote accepted

Looking at http://en.wikipedia.org/wiki/Matrix_inverse, the lines below avoid calculating more than needed (less than 1 sec on M[8]):

Cofactor[mat_,i_,j_]/;(And@@Thread[{i,j}<=Dimensions[mat]]):=(-1)^(i+j)*Det[Drop[#,{j}]&/@Drop[mat,{i}]];   
inverseElement[mat_, i_,  j_] /; (And @@ Thread[{i, j} <= Dimensions[mat]]) := 
 Cofactor[mat, j, i]/Det[mat];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.