# find square root of of an algebraic number

I have an algebraic number `-4536*sqrt(33)+61128`

. How can I find the root of this number using Sage?

find square root of of an algebraic number

I have an algebraic number `-4536*sqrt(33)+61128`

. How can I find the root of this number using Sage?

add a comment

3

First note that written as`-4536*sqrt(33)+61128`

, the number is part of Sage's
symbolic ring.

To work with algebraic numbers, the best is to work either

- in a number field,
- in the field of algebraic numbers,
`QQbar`

), - in the field of real algebraic numbers,
`AA`

.

Example of working in `AA`

:

```
sage: a = -4536*sqrt(33)+61128
sage: aa = AA(a)
sage: aa
35070.66383530351?
sage: aa.sqrt()
187.2716311545973?
sage: bb = aa.sqrt()
sage: bb
187.2716311545973?
sage: bb.radical_expression()
42*sqrt(33) - 54
```

Example of working in a number field:

First we check the approximate value of sqrt(33):

```
sage: sqrt(33).n()
5.74456264653803
```

Create an embedded number field:

```
sage: K.<r33> = NumberField(x^2-33, 5.8)
```

Check if our number field element is a square:

```
sage: a = -4536*r33+61128
sage: a.is_square()
True
```

Take the square root:

```
sage: a.sqrt()
42*r33 - 54
```

Final note: in all cases, the method `sqrt`

will return one of the two square roots.
Keep in mind that there is another one --- it's just the opposite of the one you got.

So if you let `b = a.sqrt()`

, then remember that `-b`

is also a square root of `a`

.

1

The following question is useful for understanding different number types:

1

Alternative code, working in a quadratic number field, as in our case, and factorizing in it.

```
sage: K.<a> = QuadraticField( 33 )
sage: K
Number Field in a with defining polynomial x^2 - 33
sage: s = 61128 - 4536*a
sage: sqrt(s)
42*a - 54
sage: factor(s)
(-184*a + 1057) * (-1/2*a - 5/2)^18 * (-1/2*a + 5/2)^4 * (-a + 6)^6
sage: w = (-184*a + 1057)
sage: w.is_unit()
True
sage: sqrt( w )
-4*a + 23
sage: u, = K.units()
sage: u
4*a + 23
sage: sqrt(s).factor()
(4*a - 23) * (-1/2*a - 5/2)^9 * (-1/2*a + 5/2)^2 * (-a + 6)^3
sage: s.norm()
3057647616
sage: s.norm().factor()
2^22 * 3^6
```

Asked: **
2016-12-17 00:39:15 -0500
**

Seen: **188 times**

Last updated: **Dec 17 '16**

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.