Processing math: 100%
Ask Your Question
0

Sage not returning roots of polynomimal

asked 7 years ago

Andres Mejia gravatar image

I have a polynomial

w=q^32 - q^30 + 3q^28 - 3q^26 + 6q^24 - 6q^22 + 9q^20 - 9q^18 + 12q^16 - 9q^14 + 9q^12 - 6q^10 + 6q^8 - 3q^6 + 3*q^4 - q^2 + 1

and I tried using solve(w==0,q).

But sage only returns

[0 == q^32 - q^30 + 3q^28 - 3q^26 + 6q^24 - 6q^22 + 9q^20 - 9q^18 + 12q^16 - 9q^14 + 9q^12 - 6q^10 + 6q^8 - 3q^6 + 3*q^4 - q^2 + 1]

why is this? I'm looking for complex roots.

Preview: (hide)

Comments

also for approx solutions, try with: solve(f, x, to_poly_solve=True)

mforets gravatar imagemforets ( 7 years ago )

3 Answers

Sort by » oldest newest most voted
0

answered 7 years ago

fidbc gravatar image

Maybe not all roots of w can be found exactly. You may be able to obtain approximations with the following code.

P=CC[x](x^32 - x^30 + 3*x^28 - 3*x^26 + 6*x^24 - 6*x^22 + 9*x^20 - 9*x^18 + 12*x^16 - 9*x^14 + 9*x^12 - 6*x^10 + 6*x^8 - 3*x^6 + 3*x^4 - x^2 + 1)
P.roots()

Here CC denotes the Complex Field and CC[x] denotes the Polynomial Ring over CC.

Preview: (hide)
link

Comments

To be precise :

sage: CC
Complex Field with 53 bits of precision

It is a set of numerical approximations... and therefore not exact. Hence the interestof working in QQbar, which is exact (i. e. it can hold algebraic properties if your variables and give you arbitrary precision). OTOH, if you have to explicitly use a transcendental quantity (such as π), you're SOL (unless you are willing to replace it by some algebraic approximation of precision sufficient for your needs).

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 7 years ago )
0

answered 7 years ago

Emmanuel Charpentier gravatar image

updated 7 years ago

Try :

SQ=w.roots(ring=QQbar)

(or, equivalently, replace CC by QQbar in fidbc's answer). It turns out that :

sage: SQ[0][0].parent()
Algebraic Field

which is exact :

sage: SQ[0][0].parent().is_exact()
True

a property that holds for all the roots thus obtained :

sage: all(map(lambda r:r[0].parent().is_exact(), SQ))
True

(Here, "exact" means that Sage can give you arbitrary precision for a numerical approximation). However, you won't (always : you might get lucky, but there is no guarantee...) get algebraic expressions for that (ISTR that someone called Galois explained why...).

If you need algebraic expressions of these roots and happen to be able to read French, you might have a look at the excellent "Calcul mathématique avec Sage", which IMHO, should be translated in English, and might benefit from an updated edition : Sage(math) has made huge progress since this book was written).

You might also explicitely work in the ring of polynomials in q, but I'll defer to the official documentation...

HTH,

Preview: (hide)
link

Comments

"Calcul Mathématique avec Sage" has a preliminary english version available on their website!

vdelecroix gravatar imagevdelecroix ( 7 years ago )

Thanks, Vincent. I wasn't aware of this...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 7 years ago )

sage: print([SQ[i*2][0].minpoly().degree() for i in range(16)]) [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]

rws gravatar imagerws ( 7 years ago )
0

answered 7 years ago

dan_fulea gravatar image

This is a further answer to the question, although fidbc and Emmanuel Charpentier did already said all.

But the given polynomial is a special one, it is a reciprocal polynomial in q2, so we may go some steps further. (But unfortunately i could not find an explicit form either.)

So it is natural to make the substitution t=q2+1q2=q2+r2 ,r=1q . I am doing this substitutions my way...

R.<q,r, t> = PolynomialRing(QQ)
W = q^32 - q^30 + 3*q^28 - 3*q^26 + 6*q^24 - 6*q^22 + 9*q^20 - 9*q^18 + 12*q^16 - 9*q^14 + 9*q^12 - 6*q^10 + 6*q^8 - 3*q^6 + 3*q^4 - q^2 + 1
J = R.ideal( [ W, q^2 + r^2 - t, q*r-1 ] )
K = J.elimination_ideal( [ q,r ] )
P = K.gens()[0]
print P

and the polynomial in t is after substitution (or rather elimination):

sage: print P
t^8 - t^7 - 5*t^6 + 4*t^5 + 8*t^4 - 5*t^3 - 4*t^2 + t + 2

(The further lines are misleading unless we are searching for exact solutions...)

The roots of this polynomial are:

sage: var( 't' );
sage: P = t^8 - t^7 - 5*t^6 + 4*t^5 + 8*t^4 - 5*t^3 - 4*t^2 + t + 2
sage: for root in P.roots( ring=QQbar, multiplicities=False ):
....:     print root
....:     
1.514032200639550?
1.791264905617066?
-1.480484671919947? - 0.2566820580880113?*I
-1.480484671919947? + 0.2566820580880113?*I
-0.4934011167978715? - 0.4011241207989847?*I
-0.4934011167978715? + 0.4011241207989847?*I
0.8212372355895106? - 0.3652199571071136?*I
0.8212372355895106? + 0.3652199571071136?*I

and the two real t-roots correspond to the eight roots of absolute value one of the initial polynomial:

sage: R.<q> = PolynomialRing(QQ)
....: W = q^32 - q^30 + 3*q^28 - 3*q^26 + 6*q^24 - 6*q^22 + 9*q^20 - 9*q^18 + 12*q^16 - 9*q^14 + 9*q^12 - 6*q^10 + 6*q^8 - 3*q^6 + 3*q^4 - q^2 + 1

sage: for w in W.roots( ring=QQbar, multiplicities=False ):
....:     if abs(w) != 1:    continue
....:     print "w = %s |w| = %.2f w^2 + w^-2 = %.8f" % ( w, abs(w), w^2+w^-2 )
....:     
w = -0.9735585377388802? - 0.2284376798948314?*I |w| = 1.00 w^2 + w^-2 = 1.79126491
w = -0.9735585377388802? + 0.2284376798948314?*I |w| = 1.00 w^2 + w^-2 = 1.79126491
w = -0.9372876026918778? - 0.3485569535099145?*I |w| = 1.00 w^2 + w^-2 = 1.51403220
w = -0.9372876026918778? + 0.3485569535099145?*I |w| = 1.00 w^2 + w^-2 = 1.51403220
w = 0.9372876026918778? - 0.3485569535099145?*I |w| = 1.00 w^2 + w^-2 = 1.51403220
w = 0.9372876026918778? + 0.3485569535099145?*I |w| = 1.00 w^2 + w^-2 = 1.51403220
w = 0.9735585377388802? - 0.2284376798948314?*I |w| = 1.00 w^2 + w^-2 = 1.79126491
w = 0.9735585377388802? + 0.2284376798948314?*I |w| = 1.00 w^2 + w^-2 = 1.79126491

So it is enough to understand the roots of P=t8t75t6+4t5+8t45t34t2+t+2 . Now - sometimes, but only sometimes - there is an implemented luck that allows to factorize a polynomial over some smaller field. In our case there is no obvious choice, since we cannot find easy subfields of the splitting field of P.

sage: K.<a> = NumberField( P )
sage: for L, _, _ in K.subfields():
....:     print "Subfield of degree %s and discriminant %s" % ( L.degree(), L.disc().factor() )

Subfield of degree 1 and discriminant 1
Subfield of degree 8 and discriminant -1 * 3^9 * 21157

Now i would need some more mathematical insight about the initial W, this in the hope that we can still solve by radicals. Sometimes, after adjoining a special element there appear subfields, and one can split over them. For instance, starting with the simple polynomial Q=x3x1, there are no non-trivial subfields of NumberField(Q). But if we adjoin 23...

sage: _.<x> = QQ[]
sage: Q = x^3 -x -1
sage: K.<b> = NumberField( Q )
sage: for L, _, _ in K.subfields(): print L.degree(), L.disc()
1 1
3 -23
K.<b,c> = NumberField( Q, x^2+23 )
sage: for L, _, _ in K.subfields(): print L.degree(), L.disc()
1 1
2 -23
3 -23
3 -23
3 -23
6 -12167

there is a field of degree 2, that is helping us to "solve the cubic". Of course, things would be clear, if sage could deliver in real time the Galois closure, for instance...

R.<t> = PolynomialRing( QQ )
P = t^8 - t^7 - 5*t^6 + 4*t^5 + 8*t^4 - 5*t^3 - 4*t^2 + t + 2
K.<a> = NumberField( P )
L.<b> = K.galois_closure()

(Had to abort the computation after a while.) So is there geometric insight for the initial polynomial W. (E.g. do we count points of some variety...?!)

Preview: (hide)
link

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: 7 years ago

Seen: 764 times

Last updated: Jul 29 '17