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.

Is there any way to track how Mathematica actually performs Simplify, so that we can see what those "Automatic" transformation functions it applies are and how it works with assumptions?

For example,

ClearSystemCache[];
Simplify[Sin[x]^2 + Cos[x]^2, ComplexityFunction -> ((Print[#]; LeafCount[#]) &)]

will output

Cos[x]^2+Sin[x]^2    
Cos[x]^2+Sin[x]^2    
Cos[x]^2+Sin[x]^2    
Cos[x]^2+Sin[x]^2    
Cos[x]^2+Sin[x]^2    
1    
1    
1

Is there a way to see what Mathematica does between these steps?

share|improve this question
    
@Nasser: Is there a way to filter it? I tried TableForm[ Trace[Simplify[Sqrt[x^2], x \[Element] Integers], TraceInternal -> True]], and it output far too much output to read ... –  Noon Silk Feb 23 '13 at 4:58
    
@NoonSilk. Trace takes a second argument that allows filtering. See this [documentation[(reference.wolfram.com/mathematica/ref/Trace.html) entry –  m_goldberg Feb 23 '13 at 5:07
    
Sorry, I should've worded my point better - even filtering won't help the problem I observed with the example I posted. Note that the problem is that one entry in the table is exceedingly long. –  Noon Silk Feb 23 '13 at 6:59
add comment

1 Answer

up vote 7 down vote accepted

As Nasser stated in his comment,

TableForm[Trace[Simplify[Sqrt[x^2], x ∈ Integers], TraceInternal -> True]]

will provide you the information you seek. Most of the very long output you encountered comes from Mathematica loading packages needed to carry out the simplification. If you evaluate

TableForm[Trace[Simplify[Sqrt[x^2], x ∈ Integers], TraceInternal -> True]]

a second time, the packages will be already loaded -- the output will still be messy but the Trace results will print in their entirety.

share|improve this answer
1  
thanks for the answer and the editing. Could you give some hint about how to interpret the trace result? And do you know some resources that discuss how MMA do the simplification? For example, from the trace result, I can see that it uses some numerical functions, but how does it sample the numerical parameter space and how it is sure the sample is large enough? –  user0501 Feb 24 '13 at 16:08
    
@user6048. Sorry, I don't have the expertise to answer you new questions. They are good questions, but they shouldn't be asked in a comment. I suggest you post some new questions to get the answers. –  m_goldberg Feb 25 '13 at 3:57
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.