Ask Your Question

Revision history [back]

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

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

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.