# Solving equation with algebraic numbers

Hello, SAGE gives me error when I load this: solve(x^2-AA(sqrt(3))==0,x) but it gives no problem when I load solve(x^2-sqrt(3)==0,x) This is a small example of a bigger problem I have in which I must solve a system of equations involving algebraic numbers through AA(.) and QQbar(.). How can I make SAGE solve equations with this type of numbers? or there is no way? Thanks!

edit retag close merge delete

You can convert algebraic numbers to symbolic expressions using SR(...). Probably you would rather want to define an ideal in a polynomial ring, and compute a Gröbner basis and/or the associated variety (if the system has finitely many solutions). Can you add the system you actually want to solve?

Hello rburing, i tried loading solve(x^2-SR(AA(sqrt(3)))==0,x) but it gives error, what do you think?

It seems Maxima can't handle the symbolic wrapper around AA elements. Try SR(AA(sqrt(3))).numerical_approx() for numerics, or AA(sqrt(3)).radical_expression() for an exact expression. Not all algebraics are expressible in terms of radicals, so this is not a good approach in general. Also solve may return only approximate solutions in more complicated cases. I would instead create an ideal I in a polynomial ring and call I.variety(AA) or I.variety(QQbar).

Sort by » oldest newest most voted

A possible one-liner :

sage: (AA["x"](x^2-AA(sqrt(3)))).roots()


which can be abrbreviated as

sage: (x^2-AA(sqrt(3))).polynomial(AA).roots()


HTH,

more