2020-05-26 04:30:56 -0500 received badge ● Popular Question (source) 2018-03-16 19:03:27 -0500 received badge ● Notable Question (source) 2017-12-10 16:05:33 -0500 received badge ● Nice Question (source) 2017-12-10 16:04:08 -0500 received badge ● Popular Question (source) 2017-02-13 14:49:17 -0500 received badge ● Teacher (source) 2017-02-13 06:38:32 -0500 answered a question Code error in sagemath SageMath code is written in Python (with a few extensions by the preparser). Your code does not resemble Python. Indentation matters, no end is required, forloops are written as for b in s:, functions are defined as def bruteforce():, write print instead of puts. 2017-02-10 05:54:37 -0500 asked a question Conversion fraction field(QQ[X]) to fraction field(ZZ[X]) How to I convert an element of the fraction field of QQ[X] to the fraction field of ZZ[X]? sage: R. = ZZ[] sage: F = R.fraction_field() sage: e = (1/2)/(x+1) sage: e.parent() Fraction Field of Univariate Polynomial Ring in x over Rational Field sage: F(e) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer  In my use case, e is the result of a lengthy computation where at some point beyond my control the result was coerced into QQ[X]. In my particular case, I prefer the fraction field of ZZ[X] because the output is nicer. 2017-01-04 07:40:30 -0500 commented answer Lifting a matrix from $\mathbb{Q}[Y]/(Y-1)$ Thank you, the work-around works for me. Is the underlying problem a known bug or shall I create a ticket? 2017-01-03 23:34:11 -0500 asked a question Linear Combination for Resultant Let R. = ZZ[] f = 1 - a*X^2 g = 1 - b*X^3  I need to compute polynomials u and v such that u f + v g = r where r = f.resultant(g, X). Pari has a function polresultantext for that purpose, so one solution for my problem is (u, v, r) = (R(p) for p in f._pari_().polresultantext(g._pari_(), 'X'))  Nevertheless, I have a few questions: Is there a method in Sage which directly does this? Is the detour via Pari the recommended solution? Or is there an alternative, e.g., in singular? If there is currently no method in Sage for doing this directly, what name would you recommend? resultant_ext ? 2016-12-15 04:23:52 -0500 asked a question What is _SAGE_VAR_(0)? Using SageMath 7.4, I do the following: sage: var('u R omega') sage: hs = (1+u^R).series(u==omega, 2); hs (omega^R + 1) + (R*omega^R/omega)*(-omega + u) + Order((omega - u)^2) sage: hs.subs({omega^R: -1}).simplify() R*(omega - u)/omega + Order((omega - u)^2) + _SAGE_VAR_(0)  I am wondering what _SAGE_VAR_(0) shall be and how to get rid of it. 2016-11-12 23:47:52 -0500 asked a question Lifting a matrix from $\mathbb{Q}[Y]/(Y-1)$ I have a matrix in $\mathbb{Q}[Y]/(Y-1)$ and want to lift it to $\mathbb{Q}[Y]$, however, I get an error: sage: D. = QQ[] sage: B = matrix(D, [[Y, 0]]) sage: Dbar = D.quotient(Y-1) sage: Bbar = B.change_ring(Dbar) sage: Bbar.lift() Traceback (most recent call last): ... TypeError: unable to convert 1 to a rational  Lifting single elements instead of a matrix works: sage: Dbar(Y^2).lift() 1  Lifting a matrix from the integers modulo a prime works also: sage: B = matrix(ZZ, [[7, 0]]) sage: Dbar = ZZ.quotient(5) sage: Bbar = B.change_ring(Dbar) sage: Bbar.lift() [2 0]  So how do I lift the matrix? Building a new matrix by hand und lifting componentwise seems to be an option; however, I think that it is somewhat ugly. 2016-10-03 06:59:24 -0500 commented answer How to extend ring homomorphism to polynomial ring (or its fraction field) I now have performance problems with my above solution: R. = AA[] v = QQbar.polynomial_root(AA.common_polynomial(x^5 - 2), CIF(RIF(RR(0.35496731310463009), RR(0.35496731310463014)), RIF(RR(1.0924770557774537), RR(1.0924770557774539)))) rho = 1/60*v^4 + 1/30*v^3 + 1/60*v^2 + 1/30*v + 1/15 mp = rho.minpoly() %time NumberField(mp, 'rho', embedding=rho) CPU times: user 1min 5s, sys: 64 ms, total: 1min 5s Wall time: 1min 5s Number Field in rho with defining polynomial x^5 - 1/3*x^4 + 1/30*x^3 - 1/600*x^2 + 1/24000*x - 1/2400000  Any ideas? 2016-09-27 01:24:43 -0500 commented answer How to extend ring homomorphism to polynomial ring (or its fraction field) It worked once, but then my code came accross another example and UniqueRepresentation gave me problems. So I ended up avoiding as_number_field_element alltogether and replacing it by alpha_qqbar = QQbar(sqrt(2)) nf = NumberField(alpha_qqbar.minpoly(), 'alpha', embedding=alpha_qqbar) hom = nf.coerce_embedding() x1 = polygen(nf, 'x') x2 = polygen(QQbar, 'x') 1/x1 - 1/x2  2016-09-26 22:28:44 -0500 received badge ● Supporter (source) 2016-09-26 22:28:28 -0500 received badge ● Scholar (source) 2016-09-26 22:28:23 -0500 commented answer How to extend ring homomorphism to polynomial ring (or its fraction field) Thank you, the shortcut was exactly what I need. 2016-09-26 12:02:31 -0500 received badge ● Student (source) 2016-09-26 09:11:42 -0500 asked a question How to extend ring homomorphism to polynomial ring (or its fraction field) I have a homomorphism from a number field nf to the field of algebraic numbers QQbar: nf, alpha, hom = QQbar(sqrt(2)).as_number_field_element() I now work in the polynomial ring R over nf: R. = nf[] f = x - alpha; f How do I get a homomorphism from R to the polynomial ring over QQbar extending hom? For the moment, I can use f.map_coefficients(hom) Same question about the fraction field of R, e.g., g = f/(x+1) Is there a more elegant way than calling g.numerator().map_coefficients(hom)/g.denominator().map_coefficients(hom) So basically, I'd like to extend my homomorphism hom to the polynomial ring and its field of fractions.