This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

TraceScan

TraceScan
applies f to all expressions used in the evaluation of expr.
TraceScan
includes only those expressions which match form.
TraceScan
includes all evaluations which use transformation rules associated with the symbol s.
TraceScan
applies f before evaluation and fp after evaluation to expressions used in the evaluation of expr.
  • All expressions are wrapped in HoldForm to prevent evaluation before f or fp are applied to them.
  • The function fp is given as an argument for both the form before evaluation and the form after evaluation.
  • TraceScan returns the result of evaluating expr.
Print all expressions used for evaluation:
Count additions and multiplications of machine numbers needed for a numerical computation:
A recursive definition for finding Fibonacci numbers:
Count calls to required:
Redefine so that it saves results:
Count calls to required:
The second time through it takes only one call since the value was saved:
Print all expressions used for evaluation:
In[1]:=
Click for copyable input
Out[1]=
 
Count additions and multiplications of machine numbers needed for a numerical computation:
In[1]:=
Click for copyable input
Out[1]=
 
A recursive definition for finding Fibonacci numbers:
In[1]:=
Click for copyable input
Count calls to required:
In[2]:=
Click for copyable input
Out[2]=
Redefine so that it saves results:
In[3]:=
Click for copyable input
Count calls to required:
In[4]:=
Click for copyable input
Out[4]=
The second time through it takes only one call since the value was saved:
In[5]:=
Click for copyable input
Out[5]=
New in 2