First time here? Check out the FAQ!

Ask Your Question
2

Algebraic to symbolic expression

asked 4 years ago

creyesm1992 gravatar image

updated 0 years ago

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!!!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 4 years ago

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.

Preview: (hide)
link

Comments

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

rburing gravatar imagerburing ( 4 years ago )
0

answered 4 years ago

rburing gravatar image

updated 4 years ago

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().

Preview: (hide)
link

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 ( 4 years ago )

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 ( 4 years ago )

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: 4 years ago

Seen: 910 times

Last updated: Aug 13 '20