Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Are you perhaps looking for AlgebraicNumberPolynomial?

AlgebraicNumberPolynomial[AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}], HoldForm[q]]
-3 + 2 q

The question states: "... show algebraic numbers" and "I would like to view ..." If you would like to display the AlgebraicNumber expression this way but retain its full syntax you can use a formatting function. You typically have several choices including Format, MakeBoxes, and $PrePrint. MakeBoxes is usually preferredpreferred for robustness and performance. For example:

MakeBoxes[p : AlgebraicNumber[_, {__}], fmt_] :=
  ToBoxes[Interpretation[AlgebraicNumberPolynomial[p, HoldForm @ q], p], fmt]

Now:

AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}]
-3 + 2 q
% // InputForm
AlgebraicNumber[(1 + Sqrt[5])/2, {-3, 2}]

Are you perhaps looking for AlgebraicNumberPolynomial?

AlgebraicNumberPolynomial[AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}], HoldForm[q]]
-3 + 2 q

The question states: "... show algebraic numbers" and "I would like to view ..." If you would like to display the AlgebraicNumber expression this way but retain its full syntax you can use a formatting function. You typically have several choices including Format, MakeBoxes, and $PrePrint. MakeBoxes is usually preferred for robustness and performance. For example:

MakeBoxes[p : AlgebraicNumber[_, {__}], fmt_] :=
  ToBoxes[Interpretation[AlgebraicNumberPolynomial[p, HoldForm @ q], p], fmt]

Now:

AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}]
-3 + 2 q
% // InputForm
AlgebraicNumber[(1 + Sqrt[5])/2, {-3, 2}]

Are you perhaps looking for AlgebraicNumberPolynomial?

AlgebraicNumberPolynomial[AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}], HoldForm[q]]
-3 + 2 q

The question states: "... show algebraic numbers" and "I would like to view ..." If you would like to display the AlgebraicNumber expression this way but retain its full syntax you can use a formatting function. You typically have several choices including Format, MakeBoxes, and $PrePrint. MakeBoxes is usually preferred for robustness and performance. For example:

MakeBoxes[p : AlgebraicNumber[_, {__}], fmt_] :=
  ToBoxes[Interpretation[AlgebraicNumberPolynomial[p, HoldForm @ q], p], fmt]

Now:

AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}]
-3 + 2 q
% // InputForm
AlgebraicNumber[(1 + Sqrt[5])/2, {-3, 2}]
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Are you perhaps looking for AlgebraicNumberPolynomial?

AlgebraicNumberPolynomial[AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}], HoldForm[q]]
-3 + 2 q

The question states: "... show algebraic numbers" and "I would like to view ..." If you would like to display the AlgebraicNumber expression this way but retain its full syntax you can use a formatting function. You typically have several choices including Format, MakeBoxes, and $PrePrint. MakeBoxes is usually preferred for robustness and performance. For example:

MakeBoxes[p : AlgebraicNumber[_, {__}], fmt_] :=
  ToBoxes[Interpretation[AlgebraicNumberPolynomial[p, HoldForm @ q], p], fmt]

Now:

AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}]
-3 + 2 q
% // InputForm
AlgebraicNumber[(1 + Sqrt[5])/2, {-3, 2}]