applies f to all expressions used in the evaluation of expr.


includes only those expressions which match form.


includes all evaluations which use transformation rules associated with the symbol s.


applies f before evaluation and fp after evaluation to expressions used in the evaluation of expr.

Details and Options

  • 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[f,expr] returns the result of evaluating expr.


Basic Examples  (3)

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 fib required:

Redefine fib so that it saves results:

Count calls to fib required:

The second time through it takes only one call since the value was saved:

Introduced in 1991