First time here? Check out the FAQ!

Ask Your Question
1

find square root of of an algebraic number

asked 8 years ago

Sha gravatar image

I have an algebraic number -4536*sqrt(33)+61128. How can I find the root of this number using Sage?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 8 years ago

slelievre gravatar image

updated 8 years ago

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.

Preview: (hide)
link

Comments

Thank you for explaining this to me. It is so useful for my calculation.

Sha gravatar imageSha ( 8 years ago )
1

The following question is useful for understanding different number types:

https://ask.sagemath.org/question/995...

paulmasson gravatar imagepaulmasson ( 8 years ago )
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
dan_fulea gravatar imagedan_fulea ( 8 years ago )

Thank you. This has been so helpful.

Sha gravatar imageSha ( 8 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: 8 years ago

Seen: 2,855 times

Last updated: Dec 17 '16