This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Debugging  /
TraceBackward

  • TraceBackward is an option for Trace and related functions which specifies whether to include preceding expressions on the evaluation chain that contains the pattern form sought.
  • TraceBackward -> True includes the first expression on the evaluation chain that contains form.
  • TraceBackward -> All includes all expressions before form on the evaluation chain that contains form.
  • TraceBackward allows you to see the previous forms that an expression had during an evaluation.
  • See the Mathematica book: Section 2.5.10.
  • See also: StackComplete.

    Further Examples

    Here is the recursive definition of the Fibonacci numbers.

    In[1]:=

    Here are the end conditions for the recursion.

    In[2]:=

    Out[2]=

    This shows that the number 5 came from the evaluation of fib[5] during the evaluation of fib[4].

    In[3]:=

    Out[3]=