I like the typesetting of Root objects. For example:
3-Sqrt[2]+Sqrt[3]//RootReduce
But can I get the same root object with its typesetting for simple roots like follows?
3-Sqrt[2]//RootReduce
expr = 3 - Sqrt[2];
Use ToNumberField
to convert the expression to an AlgebraicNumber
expr2 = expr // ToNumberField
The short form display of the AlgebraicNumber
is similar to that of Root
RootReduce
will convert the expression back to the radical representation.
expr2 // RootReduce
(* 3 - Sqrt[2] *)
You can discover the polynomial with MinimalPolynomial
:
p = MinimalPolynomial[3 - Sqrt[2]]
(* 7 - 6 #1 + #1^2 & *)
p[x]
(* 7 - 6 x + x^2 *)
Root[p, 1]
(* 3 - Sqrt[2] *)
From the documentation of Root
:
For linear and quadratic polynomials
f[x]
,Root[f,k]
is automatically reduced to explicit rational or radical form.
MinimalPolynomial
the root is?
$\endgroup$
Commented
Dec 18, 2020 at 18:47
3-Sqrt[2] // ToNumberField
will provide an AlgebraicNumber
with short form display similar to Root
. RootReduce
will convert the AlgebraicNumber
back to the radical representation.
$\endgroup$
Commented
Dec 18, 2020 at 20:46
You can wrap HoldForm only around Root.
Edit
p = MinimalPolynomial[ro = 3 - Sqrt[2]];
a = Select[Range[10], Root[p, #] == ro &][[1]] // Quiet;
hf = HoldForm[Root][p, a]
(* Root(#1^2-6 #1+7&,1) *)
hf // ReleaseHold
(* 3 - Sqrt[2] *)
Root[…]
expression as shown in Akku14's answer? $\endgroup$Root
expression to print like that without automatically turning into explicit roots that is even better. $\endgroup$Root
objects to avoid numerical instability. $\endgroup$