1 | initial version |

Instead of defining `f`

as a sympolic expression and using `solve`

,
one can define `f`

as a polynomial over the rationals, and get
its roots over the algebraic numbers.

Define ring of polynomials in `x`

over the rationals, then `f`

:

```
sage: R.<x> = QQ[]
sage: f = x^3 + x^2 - 1/10
```

Roots of `f`

in `QQbar`

(they are real: no imaginary part is shown):

```
sage: rr = f.roots(QQbar, multiplicities=False)
sage: print(rr)
[-0.8669513175959773?, -0.4126055722546906?, 0.2795568898506678?]
```

Further check that all roots are real:

```
sage: [r.imag() == 0 for r in rr]
[True, True, True]
```

Get radical expressions (involving `I`

even though all roots are real).

```
sage: [r.radical_expression() for r in rr]
[-1/2*(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3)*(-I*sqrt(3) + 1)
- 1/18*(I*sqrt(3) + 1)/(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3) - 1/3,
-1/2*(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3)*(I*sqrt(3) + 1)
- 1/18*(-I*sqrt(3) + 1)/(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3) - 1/3,
(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3)
+ 1/9/(1/180*I*sqrt(13)*sqrt(3) + 7/540)^(1/3) - 1/3]
```

See link provided by @Emmanuel_Charpentier for the mathematics of that.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.