unfortunately, this doesn't really help: the main reason is that the roots 
may not have an explicit expression in terms of radicals.  See 
https://trac.sagemath.org/ticket/32143

But even when explicit expressions exist, there seems to be a problem:

sage: var("y a")
(y, a)
sage: p = y^4 + y + a
sage: p.roots(y, multiplicities=False)[0]
-1/2*sqrt(1/3)*sqrt((4*a + 3*(1/6*sqrt(-256/3*a^3 + 9) + 
1/2)^(2/3))/(1/6*sqrt(-256/3*a^3 + 9) + 1/2)^(1/3)) - 
1/2*sqrt(-4/3*a/(1/6*sqrt(-256/3*a^3 + 9) + 1/2)^(1/3) - 
(1/6*sqrt(-256/3*a^3 + 9) + 1/2)^(1/3) + 6*sqrt(1/3)/sqrt((4*a + 
3*(1/6*sqrt(-256/3*a^3 + 9) + 1/2)^(2/3))/(1/6*sqrt(-256/3*a^3 + 9) + 
1/2)^(1/3)))
sage: R = PolynomialRing(SR, "y")
sage: Rp.roots(multiplicities=False)
[]



emanuel.c...@gmail.com schrieb am Donnerstag, 8. Juli 2021 um 09:46:28 
UTC+2:

> You may work on the univariate polynamial ring in your variable of 
> interest over a suitable ring. A simple example :
>
> sage: var("x, y, z")
> (x, y, z)
> sage: foo=x^3-x*sin(y+z)+1
> sage: foo.polynomial(ring=PolynomialRing(SR,"x")).parent()
> Univariate Polynomial Ring in x over Symbolic Ring
> sage: foo.polynomial(ring=PolynomialRing(SR,"x")).roots()
> [(-1/6*(-I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (-1/6*(I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(-I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (1/3*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3) + 
> (1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3),
>   1)]
>
> It might be interesting to create a more specific base ring, but only if 
> your expression is indeed a polynomial (e. g. no function calls as in my 
> oversimplified example…).
>
> It turns out that, in this precise case, it is not necessary to explicitly 
> create a polynomial ; but doing so gives a two orders of magnitude speed 
> gain (not exactly small potatoes) :
>
>  sage: %time foo.roots()
> CPU times: user 3.83 s, sys: 40.1 ms, total: 3.87 s
> Wall time: 2.9 s
> [(-1/6*(-I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (-1/6*(I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(-I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (1/3*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3) + 
> (1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3),
>   1)]
> sage: %time foo.polynomial(ring=PolynomialRing(SR,"x")).roots()
> CPU times: user 41.2 ms, sys: 17 µs, total: 41.2 ms
> Wall time: 41.1 ms
> [(-1/6*(-I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (-1/6*(I*sqrt(3) + 1)*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3) - 1/2*(-I*sqrt(3) + 1)*(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 
> 1/2)^(1/3),
>   1),
>  (1/3*sin(y + z)/(1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3) + 
> (1/6*sqrt(-4/3*sin(y + z)^3 + 9) - 1/2)^(1/3),
>   1)]
>
> HTH,
> ​
> Le lundi 5 juillet 2021 à 22:01:10 UTC+2, axio...@yahoo.de a écrit :
>
>> I am trying to fix #32133, which is about translating FriCAS expressions 
>> containing symbolic roots of polynomials, given by their minimal 
>> polynomials.
>>
>> This is easy enough if the polynomials are univariate, so the roots are 
>> algebraic numbers and I can use the wonderful machinery of QQbar.
>>
>> However, I don't see what I can do with polynomials containing extra 
>> variables.
>>
>> Any hints appreciated!
>>
>> Martin
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/9dc78039-31b3-4ddf-bbf4-49a538fa7176n%40googlegroups.com.

Reply via email to