3 Nov 2008 18:51

### Re: Selection of roots

```On Thu, Oct 30, 2008 at 8:39 AM, Alejandro Jakubi wrote:
> I wonder how it is done in Axiom the selection of roots of a polynomial
> with some property. As in this example, select the positive roots out
> of the list of three roots generated by:
>
>

Since the discriminant is positive we know all roots are real, so in
principle we should be able to solve the problem like this:

(1) -> discriminant(p^3-p+1/10)

373
(1)  ---
100
Type: Fraction(Integer)

+------------------+2
|    +-+    +-----+
+---+       |- 3\|3  + \|- 373
(- 3\|- 3  - 3)  |------------------  + 2
3|         +-+
\|      60\|3
(2)  [p= -----------------------------------------]
+------------------+
|    +-+    +-----+
+---+       |- 3\|3  + \|- 373
```

3 Nov 2008 19:32

### Re: [fricas-devel] Re: Selection of roots

```"Bill Page" <bill.page <at> newsynthesis.org> writes:

> As I understand it AlgebraicNumber is supposed to be able to properly
> order the roots.

No, that's RECLOS.

Unfortunately, there is no coercion from AN to RECLOS, and this would actually
be tricky, since sqrt(-3) is not allowed in RECLOS.

Martin
```
3 Nov 2008 20:30

### Re: [open-axiom-devel] Re: [Axiom-math] Selection of roots

```On Mon, Nov 3, 2008 at 1:32 PM, Martin Rubey wrote:
>
> Bill Page writes:
>
>> As I understand it AlgebraicNumber is supposed to be able to properly
>> order the roots.
>
> No, that's RECLOS.
>
> Unfortunately, there is no coercion from AN to RECLOS, and this would actually
> be tricky, since sqrt(-3) is not allowed in RECLOS.
>

Hmmm... So what is the meaning of < in AN? Ok, I guess that it is just
whatever is exported by Expression Integer. The fact that the positive
roots appear < 0 while the negative roots appear > 0 must be just an
accident of some strange lexical ordering rules for expressions.

Regards,
Bill Page.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
```
3 Nov 2008 20:53

### Re: [open-axiom-devel] Re: [Axiom-math] Selection of roots

```"Bill Page" <bill.page@...> writes:

> Hmmm... So what is the meaning of < in AN? Ok, I guess that it is just
> whatever is exported by Expression Integer. The fact that the positive
> roots appear < 0 while the negative roots appear > 0 must be just an
> accident of some strange lexical ordering rules for expressions.

Well, it's not so strange, it's the order used for hashing.

Yes, it's high time to separate mathematical order and internal hashing order.
Waldek proposed a programme in the thread "RFC: Orders in algebra" some time
ago, as you know.  There was a long discussion, but little result.

I believe that we wanted too much.

Here is the original programme:

> 1) create a new category, say Comparable which has functions
>    like lessThen, lessOrEqual etc.
> 2) Change domains that use unnatural order to use comparisons from
>    Comparable
> 3) Undefine unnatural orders (remove them from OrderedSet)
> 4) If possible define natural ones
>
> In particular for Expression w probably should _not_ define an
> order, but rather make '<' produce elements of new domain
> 'Inequality' (like Equation, but for ordered comparisons).

I guess it would be best to just go ahead and implement a simple version of
this at first.  In fact, Bill, you did already implement a version of
```

3 Nov 2008 21:55

### Re: [fricas-devel] Re: Selection of roots

```On Mon, Nov 3, 2008 at 1:32 PM, Martin Rubey wrote:
>
> "Bill Page" <bill.page <at> newsynthesis.org> writes:
>
>> As I understand it AlgebraicNumber is supposed to be able to
>> properly order the roots.
>
> No, that's RECLOS.
>
> Unfortunately, there is no coercion from AN to RECLOS, and this would
> actually be tricky, since sqrt(-3) is not allowed in RECLOS.
>

Thanks Martin, that was a very useful reference. Actually it turns out
that RealClosure is pretty cool.

Thank you Renaud!

(1) -> P:=p^3-p+1/10

3        1
(1)  p  - p + --
10
Type: Polynomial Fraction Integer

(2) -> S:=select(positive?,allRootsOf(P)\$RealClosure(Fraction Integer))

(2)  [%A36,%A37]
Type: List RealClosure Fraction Integer

```

3 Nov 2008 23:00

### Re: [fricas-devel] Re: Selection of roots

```On Mon, 3 Nov 2008, Bill Page wrote:

> Thanks Martin, that was a very useful reference. Actually it turns out
> that RealClosure is pretty cool.
>
> Thank you Renaud!
>
> (1) -> P:=p^3-p+1/10
>
>         3        1
>   (1)  p  - p + --
>                 10
>                                    Type: Polynomial Fraction Integer
>
> (2) -> S:=select(positive?,allRootsOf(P)\$RealClosure(Fraction Integer))
>
>   (2)  [%A36,%A37]
>                                    Type: List RealClosure Fraction Integer
>

Thank you Bill for showing how to use 'RealClosure' in this example. In fact,
I have been looking a pair of days on how to use it, but, because of the lack
of proper documentation the best that I could get was:

L:=allRootsOf(p^3 - p + 1/10)\$RECLOS(FRAC INT)

[%A1,%A2,%A3]
Type: List RealClosure Fraction Integer

map(mainCharacterization,L)
```

3 Nov 2008 23:14

### Re: [fricas-devel] Re: Selection of roots

```Alejandro Jakubi <jakubi <at> df.uba.ar> writes:
> Now, my next question is about selecting the two real roots out of the four
>
> f:=(x^3+x^2-4*x-4)/(2*x^2+7*x-4)
> fp:=differentiate(f,x)
>
> The problem is that
>
> allRootsOf(fp)\$RealClosure(Fraction Integer)

try

allRootsOf(numer fp)\$RealClosure(Fraction Integer)

Martin
```
3 Nov 2008 23:38

### Re: [open-axiom-devel] Re: [Axiom-math] Selection of roots

```On Mon, Nov 3, 2008 at 5:00 PM, Alejandro Jakubi wrote:
>
> Thank you Bill for showing how to use 'RealClosure' in this example.

You are welcome.

> In fact, I have been looking a pair of days on how to use it, but,
> because of the lack of proper documentation the best that I could
> get was:
>
> L:=allRootsOf(p^3 - p + 1/10)\$RECLOS(FRAC INT)
>
>  [%A1,%A2,%A3]
>                               Type: List RealClosure Fraction Integer
>
> map(mainCharacterization,L)
>
>             1   1
>  [[- 4,0[,[0,-[,[-,1[]
>             2   2
> Type: List Union(RightOpenIntervalRootCharacterization(RealClosure
> Fraction Integer,SparseUnivariatePolynomial RealClosure Fraction
> Integer),"failed")
>
> which it was not so far.
>

Why, that's almost there!   I agree that tutorial documentation is
a problem. If you haven't already seen it, perhaps you would be
interested in:
```

4 Nov 2008 00:21

### Re: [fricas-devel] Re: Selection of roots

```On Mon, 3 Nov 2008, Martin Rubey wrote:

> Alejandro Jakubi <jakubi <at> df.uba.ar> writes:
>> Now, my next question is about selecting the two real roots out of the four
>>
>> f:=(x^3+x^2-4*x-4)/(2*x^2+7*x-4)
>> fp:=differentiate(f,x)
>>
>> The problem is that
>>
>> allRootsOf(fp)\$RealClosure(Fraction Integer)
>
> try
>
> allRootsOf(numer fp)\$RealClosure(Fraction Integer)
>

Fine. Now, how I recover the algebraic expressions, as produced by
'radicalSolve', associated with such labels like %A1, %A2 ?

Alejandro Jakubi
```
4 Nov 2008 00:41

### Re: [fricas-devel] Re: Selection of roots

```Alejandro Jakubi <jakubi <at> df.uba.ar> writes:

> Fine. Now, how I recover the algebraic expressions, as produced by
> 'radicalSolve', associated with such labels like %A1, %A2 ?

perhaps

(63) -> mainDefiningPolynomial(first allRootsOf(numer fp)\$RECLOS(FRAC INT))

4     3   3  2
(63)  ?  + 7?  + - ?  + 4? + 22
2
Type: Union(SparseUnivariatePolynomial(RealClosure(Fraction(Integer))),...)

Martin
```

Gmane