1
$\begingroup$

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, Root[{-3 + #1 + #1^E &, 1.2``1}] and Root[-3 + #1 + #1^5 &, 1].

MatchQ[Root[{-3 + #1 + #1^E &, 1.2``1}], Root[{_, _Real}]]
(* True *)

MatchQ[Root[-3 + #1 + #1^5 &, 1], Root[_, _Integer]]
(* False *)

The last result looks unexpected. An investigation shows that there is a third, invisible and, apparently, undocumented argument 0:

Root[-3 + #1 + #1^5 &, 1] // InputForm
(* Root[-3 + #1 + #1^5 & , 1, 0] *)

Once we know this, pattern matching is easy to fix, but still there are some questions:

  • What's the purpose of this parameter? Is it documented anywhere?
  • Why is it invisible in StandardForm and OutputForm?
  • Are there cases when I might need to explicitly provide an argument for it?
$\endgroup$
  • 1
    $\begingroup$ Some info here. Curiously enough, it was asked today :) $\endgroup$ – Dr. belisarius Oct 25 '13 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.