Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The output of Trace[expr] can be nicely represented as a tree, I guess. Here is an example trace.

x = 5;
Trace[Mod[(3 + x)^2, x - 1]]

(* {{{{x,5},3+5,8},8^2,64},{{x,5},5-1,4},Mod[64,4],0} *)

How can I make a tree graph from this list?

share|improve this question
9  
Please see this answer. –  Szabolcs May 7 '12 at 8:16
add comment

2 Answers 2

up vote 4 down vote accepted

This shows a graphical tree of the expression.

HoldForm[{{{{x, 5}, 3 + 5, 8}, 8^2, 64}, {{x, 5}, 5 - 1, 4}, 
   Mod[64, 4], 0}] // TreeForm

Mathematica graphics

share|improve this answer
add comment

Taking and running with image_doctor's example, you can get a representation without "HoldForm" visible like this:

Unevaluated @ Unevaluated[
 {{{{x, 5}, 3 + 5, 8}, 8^2, 64}, {{x, 5}, 5 - 1, 4}, Mod[64, 4], 0}
] // TreeForm

Mathematica graphics

See these comments for some valuable thoughts about this method.

share|improve this answer
    
Could you please summarize the content of those comments? –  rm -rf May 11 '12 at 21:44
3  
@R.M you want me to summarize Leonid? I don't think that is within my capabilities. :^) –  Mr.Wizard May 11 '12 at 21:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.