Ask Your Question
2

Algebraic to symbolic expression

asked 2020-08-11 23:17:24 +0100

creyesm1992 gravatar image

updated 2024-04-23 13:43:37 +0100

FrédéricC gravatar image

Hello! When I write AA(sqrt(3)+sqrt(2)) i get 3.146264369941973?, and I use to recover the original symbolic expression sqrt(2)+sqrt(3) simply by asking the minimal polynomial of 3.146264369941973?, which is of degree 4, and looking for the appropiate root. But I want to know if there is a reasonable way to get the symbolic expression from an algebraic expression which I know it comes from a lot of operations, knowing that the function "minpoly()" in that case does not give an answer for hours. I hope you can help me!!!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2020-08-13 20:16:25 +0100

tmonteil gravatar image

You can use the radical_expression method:

sage: a = AA(sqrt(3)+sqrt(2))                                                                                                                                                                                
sage: a                                                                                                                                                                                                      
3.146264369941973?
sage: a.radical_expression()                                                                                                                                                                                 
sqrt(2*sqrt(6) + 5)

Note that this is not a "complete" feature, as there might be some algebraic numbers admitting a radical decomposition that this feature will not find.

edit flag offensive delete link more

Comments

The first thing this method does is compute a.minpoly()...

rburing gravatar imagerburing ( 2020-08-14 00:03:40 +0100 )edit
0

answered 2020-08-11 23:45:40 +0100

rburing gravatar image

updated 2020-08-12 17:00:07 +0100

I'm not sure how minpoly() works but I'm pretty sure the following numerical approach (using PSLQ) is different:

z = AA(sqrt(3)+sqrt(2))
max_degree = 4
from mpmath import mp, findpoly
mp.dps = 15 # decimal places
f = ZZ['x'](findpoly(z.numerical_approx(digits=mp.dps), max_degree))
print(f)
print(f(z.numerical_approx(digits=mp.dps)))
print(f(z).is_zero())
print(f.roots(SR))

Output:

x^4 - 10*x^2 + 1
1.31006316905768e-14
True
[(-sqrt(2*sqrt(6) + 5), 1), (sqrt(2*sqrt(6) + 5), 1), (-sqrt(-2*sqrt(6) + 5), 1), (sqrt(-2*sqrt(6) + 5), 1)]

It can be used to find minimal polynomials with some degree of uncertainty, but likely at a higher speed. I hope it can be useful.

Edit: The uncertainty of z being a root can be eliminated by checking f(z).is_zero(), and the uncertainty of minimality could be eliminated e.g. by checking f.is_irreducible().

edit flag offensive delete link more

Comments

thanks rburing, i was looking for something exact, and "minpoly()" is exact (I verified checking if f(z))=0 with your polinomial and, as you said, it is approximately 0, and the exactitude is reached by the function obtained in minpoly()). Thanks for your help in this and my other question :-)

creyesm1992 gravatar imagecreyesm1992 ( 2020-08-12 16:18:25 +0100 )edit

You're welcome :) This approach is not exact but if for an algebraic number z you manage to find an f in this way, then you can check whether it is actually exact e.g. with f(z).is_zero(). (If this is the case, it is not guaranteed that f will be of minimal degree, but it is likely, and you could check it in another way, e.g. by f.is_irreducible().)

rburing gravatar imagerburing ( 2020-08-12 16:52:34 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-11 23:17:24 +0100

Seen: 817 times

Last updated: Aug 13 '20