On Jun 22, 11:13 am, cjung <cjun...@gmx.de> wrote: > My question is now, if this is a bug or just a mistake in my code?
I suspect that you create your roots of unity using exponents that are floats. In that case it may be a bug in Sage that it doesn't throw an error. It may be what you are triggering: We create an "approximate" 6th root of unity. Of course the input data shouldn't be interpreted as an algebraic number because 0.333 can easily mean a non-rational number. This is where it might be safer if sage threw an error instead of accepting the input sage: c=QQbar(e^(I*pi*0.333)) sage: c 0.5009066253607099? + 0.865501330253019?*I As this example shows, sage has done a "best guess" as to interpreting the input as an algebraic number: sage: c.minpoly() x^800 - x^600 + x^400 - x^200 + 1 Indeed, its cube is close to -1, but not equal to it: sage: c^3 -0.9999950652018582? + 0.003141587485879564?*I QQbar clearly tries too hard to interpret symbolic expressions as algebraic numbers. More blatant non-algebraic input gets recognised: sage: QQbar(1.34) TypeError: Illegal initializer for algebraic number sage: QQbar(1.13+3.2*I) TypeError: Illegal initializer for algebraic number Since QQbar(...) is a forced coercion, perhaps this is what you should expect. You are asking the system to try to make sense of what you're asking if at all possible and in some sense it does ... but rather unexpectedly. I don't know how robust the strategies are that the system uses, but for smallish input it seems to work rather well: sage: u1=QQbar(1958*e^(pi*I*-2/5)+34/5*e^(pi*I*3/7)) sage: u2=(QQbar(1958*e^(pi*I*-2/5))+QQbar(34/5*e^(pi*I*3/7))) sage: u3=1958*QQbar.zeta(10)^(-2)+34/5*QQbar.zeta(14)^3 sage: u1 == u2 and u1 == u3 and u2 == u3 True sage: u1.minpoly() == u2.minpoly() True sage: u3.minpoly()(u2) == 0 True If it uses numerical methods somewhere along the way to recognise these symbolic expressions as algebraic numbers, I suspect you can break it by feeding it some devious input. The "problem" is probably the minpoly routine on symbolic expressions: sage: v=e^(I*pi*0.333) sage: v.minpoly() x^800 - x^600 + x^400 - x^200 + 1 sage: (e^(I*pi*333/1000)).minpoly() x^800 - x^600 + x^400 - x^200 + 1 sage: (e^(I*pi*1.0/3)).minpoly() x^2 - x + 1 -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org