constructing lists of algebraic numbers

4 views
Skip to first unread message

Martin R

unread,
Apr 28, 2026, 12:18:15 PM (3 days ago) Apr 28
to FriCAS - computer algebra system
Dear all,

I am puzzled by the following:

(1) -> [[3, rootOf(x^5+1)$AN], [4, rootOf(x)$AN]]$List(Record(k: NNI, c: AN))

   (1)  [[k = 3, c = x], [k = 4, c = 0]]
                 Type: List(Record(k: NonNegativeInteger,c: AlgebraicNumber))

(2) -> [[3, rootOf(x^5+1)$AN]]$List(Record(k: NNI, c: AN))

   (2)  [[3, x]]
                                                              Type: List(Any)
(3) -> []$List(Record(k: NNI, c: AN))

   (3)  []
                 Type: List(Record(k: NonNegativeInteger,c: AlgebraicNumber))

What makes lists of length 1 special?

Best wishes,

Martin

Ralf Hemmecke

unread,
Apr 28, 2026, 4:02:58 PM (3 days ago) Apr 28
to fricas...@googlegroups.com
It's indeed a good question.

Interestingly, this gives the right type.

%%% (4) -> [([3, rootOf(x^5+1)$AN]$Record(k: NNI, c: AN))]

(4) [[k = 3, c = x]]
Type: List(Record(k: NonNegativeInteger,c: AlgebraicNumber))

I also got hit by this weird behaviour. But I cannot reproduce the
situation now.

Anyhow, it seems that your (2) first constructs
[3, rootOf(x^5+1)$AN] as a list of two things, in fact, AN elements.
With that it is probably hard to convert it to the result type you want.

But hey, it seems that the function selection looks not so bad.
Unfortunately, List AlgebraicNumber is converted to Any and I don't
think there is a function Any -> Record(k: NNI,c: AN).

Ralf

=================
%%% (10) -> )set mess bott on

%%% (9) -> li := [[3, rootOf(x^5+1)$AN]] $ List(Record(k: NNI, c: AN))

Function Selection for ^
Arguments: (VARIABLE(x), PI)
Default target type: Polynomial(Integer)

[1] signature: (POLY(INT), NNI) -> POLY(INT)
implemented: slot (NonNegativeInteger) from POLY(INT)
[2] signature: (POLY(INT), PI) -> POLY(INT)
implemented: slot (PositiveInteger) from POLY(INT)


Function Selection for +
Arguments: (POLY(INT), PI)

[1] signature: (POLY(INT), POLY(INT)) -> POLY(INT)
implemented: slot from POLY(INT)


Function Selection for rootOf
Arguments: POLY(INT)
Target type: AN
From: AN

[1] signature: POLY(AN) -> AN
implemented: slot (Polynomial %) from AN


Function Selection for map by coercion facility (map)
Arguments: ((INT -> AN), POLY(INT))
Target type: POLY(AN)

[1] signature: ((INT -> AN), POLY(INT)) -> POLY(AN)
implemented: slot (Polynomial (AlgebraicNumber))(Mapping
(AlgebraicNumber) (Integer))(Polynomial (Integer)) from POLY2(INT,AN)


Function Selection for map by coercion facility (map)
Arguments: ((ANY -> Record(k: NNI,c: AN)), LIST(ANY))
Target type: LIST(Record(k: NNI,c: AN))

[1] signature: ((ANY -> Record(k: NNI,c: AN)), LIST(ANY)) ->
LIST(Record(k: NNI,c: AN))
implemented: slot (List (Record (: k (NonNegativeInteger)) (: c
(AlgebraicNumber))))(Mapping (Record (: k (NonNegativeInteger)) (: c
(AlgebraicNumber))) (Any))(List (Any)) from LIST2(ANY,Record(k: NNI,c: AN))


(9) [[3, x]]
Type: List(Any)

%%% (11) -> first li

Function Selection for first
Arguments: LIST(ANY)
-> no appropriate first found in Any

[1] signature: LIST(ANY) -> ANY
implemented: slot (Any) from LIST(ANY)


(11) [3, x]
Type: List(AlgebraicNumber)

Qian Yun

unread,
Apr 28, 2026, 6:36:13 PM (3 days ago) Apr 28
to fricas...@googlegroups.com
Probably somewhere in the type resolution function messed up.

I want to say, using "@" is more appropriate than "$"
in this situation, because you want the target type.

(1) -> [[3, rootOf(x^5+1)$AN]]@List(Record(k: NNI, c: AN))

(1) [[k = 3, c = x]]
Type: List(Record(k: NonNegativeInteger,c: AlgebraicNumber))

- 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/f69b8b8c-86fe-4a82-837a-26b7f2caaaf8n%40googlegroups.com <https://
> groups.google.com/d/msgid/fricas-devel/
> f69b8b8c-86fe-4a82-837a-26b7f2caaaf8n%40googlegroups.com?
> utm_medium=email&utm_source=footer>.

Martin R

unread,
Apr 29, 2026, 7:15:45 AM (2 days ago) Apr 29
to FriCAS - computer algebra system
cool, thank you, that works nicely!
Reply all
Reply to author
Forward
0 new messages