# Speeding up inversion of symbolic matrices by invoking caching

Is it possible to reduce the computation time taken to find inverse of symbolic matrices USING CACHING TECHNIQUES accessible (if any)?

I am trying to compute inverse of symbolic matrices of size 12x12. I see that when the timing recudes drastically when I repeat the calculation.

For[i= 1, i <= 10, i++,
AbsoluteTiming[
K1inv = Simplify@Inverse[K1];
][[1]] // Print
]

gives output timings

21.6312373
2.9041661
1.2300704
1.2350706
1.2360707
1.2270702
1.2260701
1.2340706
1.2630723
1.3620779

Is there a way to USE the CACHING to speedup the computations of such matrices in general?

This link on SE points in that direction, but not answers the caching aspect

EDIT 1:

To be precise, the question is,

• is there any predicatable takeaway from the caching - i.e. something that I can count on (in terms of time-saving)?

• Is there anything I can do as a user to speedup further operations.

This question arises since I am not aware of how exactly caching helps - does it extend to only the EXACT SAME matrix (wherein memoization would solve it) OR does the caching speedup inversions of the SAME ORDER (i.e. for ANY other matrix of 12x12) OR would it speedup ANY ORDER less than the current order OR anything else ?

• I don't understand your question. As you demonstrate, caching is already being used. What else are you looking for? If you want to implement caching yourself, look up memoization. Mar 13, 2014 at 21:42
• Sorry. My question was, is there any predicatable takeaway from the caching - i.e. something that I can count on (in terms of time-saving)? Is there anything I can do as a user to speedup further operations. The doubt here is since I am not aware of how the exactly caching helps - does it extend to only the EXACT SAME matrix (wherein memoization would solve it) OR does the caching speedup inversions of the SAME ORDER (i.e. for ANY other matrix of 12x12) OR would it speedup ANY ORDER less than the current order OR anything else ? Mar 13, 2014 at 21:51
• (1) What internal caching has sped up in this case is not Inverse but rather Simplify. Mar 13, 2014 at 22:57
• (2) If you define your own inversion by cofactors (not using the built-in Method->"CofactorExpansion") then you have the ability to memoize (cache) all cofactors you construct. This can make for good speed. It might also dine on all your RAM and maybe gnash on your hard drive. Mar 13, 2014 at 22:57
• @cherzieandkressy - I found that caching was always kicks in to help save time - it requires at least one computation to kick in. Feb 16, 2016 at 9:11