Already at least in version 2 (I think), the function Solve calls the function Roots. At that time, I had a rather dirty trick, that still works, to verify this:
Unprotect[Roots];
Roots[x___] /; (Print[HoldForm[Roots[x]]];False) := Null;
Protect[Roots];
Solve[x^3 - 2 x + 12 ==0, x];
(* Roots[12-2 x+x^3==0,x,Cubics->True,Quartics->True] *)
Unprotect[Roots]; Clear[Roots]; Protect[Roots];
Later, this fact could be found much easier by using the function Trace with option TraceInternal->True. Since Trace wraps the expressions in HoldForm, the following worked much better:
Cases[Trace[Solve[x^3 - 2 x + 12 ==0, x], Roots, TraceInternal->True], HoldForm[_Roots], Infinity]
It seems that I have not used the function Trace for a long time, for I just found that this command does not longer work in version 10, nor in version 9. The option TraceInternal of Trace is not listed any more, though when we ask for the options of Trace, it turns up.
Is there a successor of this option, or is there a more elegant way nowadays to see that internally Solve calls Roots?
I also observed that the syntax colouring (version 10, windows 7) suggests that Trace can be used with only two arguments. All further arguments are shown in red, even if they are black when used as a second argument. Is that correct?
TraceInternal -> True
still works, although it is not documented and the syntax coloring suggests it is an error. But perhaps the way it works or the waySolve
works has changed. $\endgroup$Options[Trace]
in the question. I had used the following to check the dependence onRoots
:Block[{Roots = x == 1 &}, Solve[x^3 - 2 x + 12 == 0, x]]
. The syntax coloring is determined bySyntaxInformation[Trace]
. I do not know why it does not correspond to allowed usage. As to your main question, it might take someone from WRI to answer. $\endgroup$Solve
. $\endgroup$Block[{Roots = (Print[Inactive[Roots][##]]; x == 1) &}, Solve[x^3 - 2 x + 12 == 0, x]]
. Once again thanks! $\endgroup$