Re: Dependence of precision on execution speed of Inverse

*To*: mathgroup at smc.vnet.net*Subject*: [mg81615] Re: Dependence of precision on execution speed of Inverse*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Sat, 29 Sep 2007 02:31:09 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <fdi5li$q8j$1@smc.vnet.net>

Andrew Moylan wrote: > m1=RandomReal[1,{50,50}]; > m2=SetPrecision[m1,14]; > Do[Inverse[m1];,{1500}]//Timing > Do[Inverse[m2];,{10}]//Timing > > On my machine, both Timing results are about the same, indicating that > Inverse (of 50x50 matrices) is about 150 times faster for machine-precision > numbers than for arbitrary precision numbers (of precision ~14). This factor > of 150 seems large. Does Mathematica employ an Inverse algorithm that is > optimised for Mathematica's arbitrary-precision numbers? > > Notes: > * Changing the precision of m2 from 14 to e.g. 17 makes little difference. > * Calling Developer`FromPackedArray[] on m1 makes little difference. > * Calling LinearSolve on Inverse yields somewhat different results, but > still shows a difference in execution time of a factor of order 100. FWIW, On my system, machine-precision inversion seems to be 192 times faster than the arbitrary precision. In[1]:= m1 = RandomReal[1, {50, 50}]; m2 = SetPrecision[m1, 14]; Do[Inverse[m1];, {1500}] // Timing Do[Inverse[m2];, {10}] // Timing Out[3]= {0.843, Null} Out[4]= {1.078, Null} In[5]:= %%[[1]]/1500 Out[5]= 0.000562 In[6]:= %%[[1]]/10 Out[6]= 0.1078 In[7]:= %/%% Out[7]= 191.815 In[8]:= m1 = RandomReal[1, {50, 50}]; m2 = SetPrecision[m1, 14]; Do[Inverse[m1];, {1920}] // Timing Do[Inverse[m2];, {10}] // Timing Out[10]= {1.11, Null} Out[11]= {1.11, Null} In[12]:= $Version Out[12]= "6.0 for Microsoft Windows (32-bit) (June 19, 2007)" -- Jean-Marc