AlgebraicNumber, again

10 views
Skip to first unread message

Martin R

unread,
Apr 29, 2026, 7:42:42 AM (2 days ago) Apr 29
to FriCAS - computer algebra system
Dear all,

is there currently a (good) way to get a numeric approximation of an AlgebraicNumber?

Here are some random things I tried.  Using complexSolve looks promising, but a bit cumbersome...

(1) -> l := rootsOf(x^5+1)

   (1)
                         2         3           3          2
   [%x0, %x0 %x1, %x0 %x1 , %x0 %x1 , - %x0 %x1  - %x0 %x1  - %x0 %x1 - %x0]
                                                  Type: List(AlgebraicNumber)
(2) -> definingPolynomial(l.2)

   (2)  - %x0 %x1 + %%var
                                                        Type: AlgebraicNumber
(3) -> (l.2)::INFORM

   (3)
   (::

     (*  (rootOf (+ (^ %x0 5) 1) %x0)
      (rootOf (+ (+ (+ (+ (^ %x1 4) (^ %x1 3)) (^ %x1 2)) %x1) 1) %x1))

    (AlgebraicNumber))
                                                              Type: InputForm

(4) -> complexSolve(multivariate(minPoly((kernels(l.2).1))::SUP Complex INT, x), 0.1)

   (4)
   [x = - 0.809018135 - 0.5877847672 %i,
    x = 0.3090168578_6352017689_4598989747_4673038078 - 0.9510564804 %i,

       x
     =
         0.3090168578_6352017689_4598989747_4673038078
       +
         0.9510564804_0771484375 %i
     ,
    x = - 0.809018135 + 0.5877847671_5087890625 %i]
                             Type: List(Equation(Polynomial(Complex(Float))))

Grégory Vanuxem

unread,
Apr 29, 2026, 8:56:46 AM (2 days ago) Apr 29
to fricas...@googlegroups.com
complex Numeric? 

--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/b60042e5-cdfb-4834-91a9-cc31263ee1a3n%40googlegroups.com.

Martin R

unread,
Apr 29, 2026, 9:01:05 AM (2 days ago) Apr 29
to FriCAS - computer algebra system
No, that doesn't do it - unless I am missing something.

Qian Yun

unread,
Apr 29, 2026, 9:16:44 AM (2 days ago) Apr 29
to fricas...@googlegroups.com
My understanding is that, you can't.

Roots of irreducible polynomials are indistinguishable algebraically,
unless you do it numerically.

x^2=2 has 2 roots, but for function sqrt, people takes the positive one.

(1) -> rootsOf(x^2-2)

(1) [%x0, - %x0]

(2) -> zerosOf(x^2-2)

+-+ +-+
(2) [\|2 , - \|2 ]


You can pin %x0 to either sqrt(2) or -sqrt(2).

For fifth degree polynomial, you can't get radical results.

Now compare with sagemath. Correct me if I'm wrong.
When Sage solves fifth degree polynomial, it pins a numeric value
to each of the roots. I think currently FriCAS doesn't have a
counterpart of that.

Is there a counterpart of FriCAS behavior in Sage?

I think there's plenty things missing in FriCAS AlgebraicNumber domain.

- Qian
> --
> You received this message because you are subscribed to the Google
> Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to fricas-devel...@googlegroups.com <mailto:fricas-
> devel+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-
> devel/b60042e5-cdfb-4834-91a9-cc31263ee1a3n%40googlegroups.com <https://
> groups.google.com/d/msgid/fricas-devel/b60042e5-cdfb-4834-91a9-
> cc31263ee1a3n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Martin R

unread,
Apr 29, 2026, 10:38:18 AM (2 days ago) Apr 29
to FriCAS - computer algebra system
Well, the InputForm *does* pin a (complex) numeric value to each AN.  So in principle, it should be doable.

I should disclose that I am just trying to improve the interface between sagemath and fricas.  This is interesting for sagemath users, because some things FriCAS does really well.  In particular, it is best at symbolic integration and it is the only player in guessing.  It is a bit ironic that the main strong points of FriCAS seem to be the ones where strict typing plays a minor role :-)

NB: if anybody is interested in (and capable of) improving the guessing facility, I'd love to help.

Best wishes,

Martin

Qian Yun

unread,
Apr 29, 2026, 10:54:44 AM (2 days ago) Apr 29
to fricas...@googlegroups.com
On 4/29/26 10:38 PM, 'Martin R' via FriCAS - computer algebra system wrote:
> Well, the InputForm *does* pin a (complex) numeric value to each AN.  So
> in principle, it should be doable.

How to do that?

> I should disclose that I am just trying to improve the interface between
> sagemath and fricas.  This is interesting for sagemath users, because
> some things FriCAS does really well.  In particular, it is best at
> symbolic integration and it is the only player in guessing.  It is a bit
> ironic that the main strong points of FriCAS seem to be the ones where
> strict typing plays a minor role :-)
>
About the fricas-sagemath interface, regarding AlgebraicNumber,
I guess that some integration result returns that?

Well, they are generally in the form of
RootSum(some_poly, univariate_function)

That is doing sum of a function for all roots, so the value of each
root does not matter, there is no need to enumerate each root.

I know there is an github issue for sagemath to implement RootSum,
but is it possible for sagemath to implement a "dummy RootSum"
function, that only display its arguments?

And on the FriCAS's side, there was a discussion long long time
ago on returning RootSum instead of the expanded version (where
root is computed by rootsOf and plugged in the univariate_function).

- Qian

Martin R

unread,
Apr 29, 2026, 11:37:17 AM (2 days ago) Apr 29
to FriCAS - computer algebra system
(1) -> l := rootsOf(x^7 + x + 1)

   (1)  [%x0, %x1, %x2, %x3, %x4, %x5, - %x5 - %x4 - %x3 - %x2 - %x1 - %x0]
                                                  Type: List(AlgebraicNumber)
(2) -> l.1::INFORM

   (2)  (:: (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) (AlgebraicNumber))
                                                              Type: InputForm
(3) -> l.2::INFORM

   (3)
   (::


     (rootOf

       (+

         (+

           (+

             (+

               (+

                 (+  (^ (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) 6)
                  (* %x1 (^ (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) 5)))

                (* (^ %x1 2) (^ (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) 4)))

              (* (^ %x1 3) (^ (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) 3)))

            (* (^ %x1 4) (^ (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) 2)))

          (* (^ %x1 5) (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0)))

        (+ (^ %x1 6) 1))

      %x1)

    (AlgebraicNumber))

Martin

Dima Pasechnik

unread,
Apr 29, 2026, 11:37:43 AM (2 days ago) Apr 29
to fricas...@googlegroups.com
Sage (and other CA systems) solves (degree d) polynomial equations
numerically for a given embedding of the underlying field extension
into the complex numbers
(or, more generally, into a field where one can compute approximately,
e.g. reals).
For an embedding is suffices to pin an approximate value of the
primitive element - the precision should be high enough to distinguish
the embeddings, d of them in total, one from the other.

For the real solutions, another approach, via Thom encoding, is possible.

Dima
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/d558853b-7c84-4464-807e-9a55f05441df%40gmail.com.

Waldek Hebisch

unread,
Apr 29, 2026, 12:10:31 PM (2 days ago) Apr 29
to 'Martin R' via FriCAS - computer algebra system
On Wed, Apr 29, 2026 at 08:37:17AM -0700, 'Martin R' via FriCAS - computer algebra system wrote:
> (1) -> l := rootsOf(x^7 + x + 1)
>
> (1) [%x0, %x1, %x2, %x3, %x4, %x5, - %x5 - %x4 - %x3 - %x2 - %x1 - %x0]
> Type:
> List(AlgebraicNumber)

'rootOf' is unsound. Results are supposed to live in a field, but
current implementation may introduce zero divisors. It is enough
for some purposes but may lead to wrong results or errors in other
cases. Sound version of this is 'split', but 'split' is expensive.

> (2) -> l.1::INFORM
>
> (2) (:: (rootOf (+ (+ (^ %x0 7) %x0) 1) %x0) (AlgebraicNumber))
> Type:
> InputForm
> (3) -> l.2::INFORM

That does not choose complex numbers, single 'rootOf' corresponds
to multiple numbers, and you stil need to do the choice. And
to avoid errors you need 'split' intead of 'rootsOf'.

--
Waldek Hebisch

Waldek Hebisch

unread,
Apr 29, 2026, 12:21:57 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
On Wed, Apr 29, 2026 at 09:16:39PM +0800, Qian Yun wrote:
>
> Now compare with sagemath. Correct me if I'm wrong.
> When Sage solves fifth degree polynomial, it pins a numeric value
> to each of the roots. I think currently FriCAS doesn't have a
> counterpart of that.

We have Complex(RealClosure(Fraction(Integer))) which allows
such functionality, but currently lacks a solver for higher
degree equations.

There is code by Ralf Hemmecke, which uses values in finite
fields to identify roots. This code in principle could be
modified to use numeric values.

--
Waldek Hebisch

Waldek Hebisch

unread,
Apr 29, 2026, 12:25:14 PM (2 days ago) Apr 29
to 'Martin R' via FriCAS - computer algebra system
On Wed, Apr 29, 2026 at 04:42:42AM -0700, 'Martin R' via FriCAS - computer algebra system wrote:
> Dear all,
>
> is there currently a (good) way to get a numeric approximation of an
> AlgebraicNumber?
>
> Here are some random things I tried. Using complexSolve looks promising,
> but a bit cumbersome...
>
> (4) -> complexSolve(multivariate(minPoly((kernels(l.2).1))::SUP Complex
> INT, x), 0.1)
>
> (4)
> [x = - 0.809018135 - 0.5877847672 %i,
> x = 0.3090168578_6352017689_4598989747_4673038078 - 0.9510564804 %i,
>
> x
> =
> 0.3090168578_6352017689_4598989747_4673038078
> +
> 0.9510564804_0771484375 %i
> ,
> x = - 0.809018135 + 0.5877847671_5087890625 %i]
> Type:
> List(Equation(Polynomial(Complex(Float))))

complexSolve will give you set of possible values. This could be
improved by having a single functions that is doing equivalent
of computing minimal polynomial and complexSoleve, but conceptually
it the only thing possible.

--
Waldek Hebisch

Grégory Vanuxem

unread,
Apr 29, 2026, 3:00:56 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
Martin,

Le mer. 29 avr. 2026 à 13:42, 'Martin R' via FriCAS - computer algebra
system <fricas...@googlegroups.com> a écrit :
I wonder why you want that in SageMath, there is an interface to
FLINT, no? I do not know exactly what it is interfaced. But FLINT
include now the Calcium library from Fredrik Johansson. As an example
using Julia in FriCAS, an extension, Julia has a Nemo package that
interfaces FLINT (NM means Nemo here):

(1) -> R:=NUP(NINT,'x)

(1) NMUnivariatePolynomial(NMInteger,x)
Type: Type
(2) -> x:=x::R

(2) x
Type: NMUnivariatePolynomial(NMInteger,x)
(3) -> p:=x^5+1

5
(3) x + 1
Type: NMUnivariatePolynomial(NMInteger,x)
(4) -> v:=roots p

(4)

5-element Vector{QQBarFieldElem}:
{a1: -1.00000}
{a4: 0.809017 + 0.587785*im}
{a4: 0.809017 - 0.587785*im}
{a4: -0.309017 + 0.951057*im}
{a4: -0.309017 - 0.951057*im}
Type: JLVector(NMAlgebraicNumber)
(5) -> minimalPolynomial(v.2)

4 3 2
(5) ? - ? + ? - ? + 1
Type: SparseUnivariatePolynomial(Integer)
(6) -> minimalPolynomial(v.2)@R

4 3 2
(6) x - x + x - x + 1
Type: NMUnivariatePolynomial(NMInteger,x)
(7) -> v.2::NMComplexField

(7)
[0.809016994374947424 +/- 1.04e-19] + [0.5877852522924731291
+/- 8.88e-20]*im
Type: NMComplexField

Is it just for better support of FriCAS AlgebraicNumber (AN) in
SageMath or to have another way to solve this?

Greg

Qian Yun

unread,
Apr 29, 2026, 5:23:25 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
On the subject, is there good literature (book/paper) on the
subject of Algebraic Number? I mean it shall contain both
the theory and algorithm, aka suitable for implementing in
computer algebra system.

- Qian

Qian Yun

unread,
Apr 29, 2026, 5:25:29 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
Hi Waldek,

Are there obstacles remaining for using rootSum directly
instead of rootsOf in integration results?

- Qian

Waldek Hebisch

unread,
Apr 29, 2026, 5:52:32 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
Yes, there are. Beside indefinite integrals we also want to
compute definite ones. This may require computing limits,
so we need to teach limit code how to handle rootSum.
Doing this correctly is somewhat tricky. We could cheat
and "expand" rootSum to what rootsOf produce. But currently
"new" limit code is based on proven results. Planting
cheats there would expand scope of unsound routines.
Let me add that (slowly) we removed unsoundness from some
places. If we allow unsoundness to spead into currently
sound areas we risk the we never will have sound system.
That is why I want to do limits of rootSum in "right way",
and as I wrote, this is tricky.

--
Waldek Hebisch

Qian Yun

unread,
Apr 29, 2026, 6:04:52 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
Do we actually get meaningful result from limit for
degree>=5 rootSum (in expanded form)?

Just random thought, limit(rootSum(p, f), x, x0)
should equal to rootSum(p, limit(f, x, x0)) ?

Another one, can we keep current form for degree<=4,
while return rootSum for higher degree?

- Qian

Waldek Hebisch

unread,
Apr 29, 2026, 6:14:41 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
There is a lot, most of them rather specialized (handling
some algebraic numbers but not all). Some general algortithms
are the same for algebraic numbers and expressions (that is
why out AlgebraicNumber is essentially special case of
Expression(Integer)).

You may be interested in paper

Steel, Allan
A New Scheme for Computing with Algebraically Closed Fields,

I have reference pointing to a conference proceedings
"Algorithmic Number Theory", but AFAIR later version
appeared in Journal of Symbolic Computation.

Ralf Hemmecke created code based on this.

--
Waldek Hebisch

Waldek Hebisch

unread,
Apr 29, 2026, 6:32:41 PM (2 days ago) Apr 29
to fricas...@googlegroups.com
On Thu, Apr 30, 2026 at 06:04:48AM +0800, Qian Yun wrote:
> Do we actually get meaningful result from limit for
> degree>=5 rootSum (in expanded form)?
>
> Just random thought, limit(rootSum(p, f), x, x0)
> should equal to rootSum(p, limit(f, x, x0)) ?

In easy cases. Tricky ones are when there is cancellation
between roots. In such case individual terms may diverge,
but sum over root converges. Also, when coefficients are
real rootSum is real too, but individal roots may be (and
frequently are) compolex. The most powerful limit routine
that we have (MRV algorithm) is sound only for real
functions. That is the tricky part: theory tells you
that rootSum behaves nicely, trying to split it leads
to expressions that may behave quite badly.

AFAIKS that way to go is to handle "reasonable" cases
of rootSum and signal failure in other cases.

--
Waldek Hebisch

Qian Yun

unread,
6:39 AM (7 hours ago) 6:39 AM
to fricas...@googlegroups.com
Before we have proper support for doing limit for rootSum,
can we have a flag in IntegrationResultToFunction to
control whether to use zerosOf or rootSum?
(like setSimplifyDenomsFlag)

- Qian
Reply all
Reply to author
Forward
0 new messages