Group Abstract Group Abstract

Message Boards Message Boards

0
|
10.5K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

What is Mathematica doing?

Posted 11 years ago
POSTED BY: Lenny Johnson
3 Replies
Posted 11 years ago

One of the things to learn about Mathematica (Wolfram) is to search the documentation for functions that may simplify your work. Try guide/NumberTheoreticFunctions in the documentaion. There you'll find Divisors[] and DivisorSum[]. A number is perfect if Total[Divisors[n]]/2==n or DivisorSum[n, Identity]/2 == n.

POSTED BY: Douglas Kubler
Posted 11 years ago

The "speed-up" does indeed seem to be due to the internal compilation that is occurring from the use of Map. For anyone wanting a nice review of the compilation features and limits see the link How to compile effectively

POSTED BY: Lenny Johnson

It is likely that at that value the internal automatic compilation of some of the code is kicking in:

In[16]:= SystemOptions[CompileOptions]

Out[16]= {"CompileOptions" -> {"ApplyCompileLength" -> \[Infinity], 
   "ArrayCompileLength" -> 250, "AutoCompileAllowCoercion" -> False, 
   "AutoCompileProtectValues" -> False, "AutomaticCompile" -> False, 
   "BinaryTensorArithmetic" -> False, "CompileAllowCoercion" -> True, 
   "CompileConfirmInitializedVariables" -> True, 
   "CompiledFunctionArgumentCoercionTolerance" -> 2.10721, 
   "CompiledFunctionMaxFailures" -> 3, 
   "CompileDynamicScoping" -> False, 
   "CompileEvaluateConstants" -> True, 
   "CompileOptimizeRegisters" -> False, 
   "CompileParallelizationThreshold" -> 10, 
   "CompileReportCoercion" -> False, "CompileReportExternal" -> False,
    "CompileReportFailure" -> False, "CompileValuesLast" -> True, 
   "FoldCompileLength" -> 100, "InternalCompileMessages" -> False, 
   "ListableFunctionCompileLength" -> 250, "MapCompileLength" -> 100, 
   "NestCompileLength" -> 100, "NumericalAllowExternal" -> False, 
   "ProductCompileLength" -> 250, "ReuseTensorRegisters" -> True, 
   "SumCompileLength" -> 250, "SystemCompileOptimizations" -> All, 
   "TableCompileLength" -> 250}}

If you play with some of these using

SetSystemOptions[
 "CompileOptions" -> {"ApplyCompileLength" -> \[Infinity], 
   "ArrayCompileLength" -> 250, "AutoCompileAllowCoercion" -> False, 
   "AutoCompileProtectValues" -> False, "AutomaticCompile" -> False, 
   "BinaryTensorArithmetic" -> False, "CompileAllowCoercion" -> True, 
   "CompileConfirmInitializedVariables" -> True, 
   "CompiledFunctionArgumentCoercionTolerance" -> 2.1072099696478683`,
    "CompiledFunctionMaxFailures" -> 3, 
   "CompileDynamicScoping" -> False, 
   "CompileEvaluateConstants" -> True, 
   "CompileOptimizeRegisters" -> False, 
   "CompileParallelizationThreshold" -> 10, 
   "CompileReportCoercion" -> False, "CompileReportExternal" -> False,
    "CompileReportFailure" -> False, "CompileValuesLast" -> True, 
   "FoldCompileLength" -> 100, "InternalCompileMessages" -> False, 
   "ListableFunctionCompileLength" -> 250, "MapCompileLength" -> 100, 
   "NestCompileLength" -> 100, "NumericalAllowExternal" -> False, 
   "ProductCompileLength" -> 250, "ReuseTensorRegisters" -> True, 
   "SumCompileLength" -> 250, "SystemCompileOptimizations" -> All, 
   "TableCompileLength" -> 250}]

You will be able to see if the threshold where the timing makes a jump moves according to the change in the threshold for the system options setting.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard