Re: [sage-support] The behavior of empty sums
On Tuesday, June 25, 2019 at 10:03:03 AM UTC+2, Peter Luschny wrote: > > How that? Look at the output above. Sage *knows* that the terms of the sum > are polynomials. So it should return the zero of that ring, which is the > null polynomial. > > Not in the first case, look at what are you passing to sum as argument sage: sage: R=ZZ['x'] sage: R=ZZ['x'] sage: def ib(m, n): return [binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1)] sage: for n in (0..6): : print(ib(2,n)) : [] [x + 1] [x + 1, 3*x^2 + 3] [x + 1, 10*x^2 + 10, 5*x^2 - 5*x + 5] [x + 1, 21*x^2 + 21, 35*x^2 - 35*x + 35, 7*x^4 + 7] [x + 1, 36*x^2 + 36, 126*x^2 - 126*x + 126, 84*x^4 + 84, 9*x^4 - 9*x^3 + 9*x^2 - 9*x + 9] [x + 1, 55*x^2 + 55, 330*x^2 - 330*x + 330, 462*x^4 + 462, 165*x^4 - 165*x^3 + 165*x^2 - 165*x + 165, 11*x^4 - 11*x^2 + 11] When n =0, k ranges from 0 to -1 so there is no k and the list constructed in ib(n,m) is just the empty list. Not an empty list of polynomials, just an empty list. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/f26ea001-2dda-4d8f-a1fd-36d794d3bc41%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] The behavior of empty sums
On Monday, June 17, 2019 at 2:12:58 PM UTC+2, Peter Luschny wrote: As I see it the problem is that the sum runs over (0..n-1). > Thus for n = 0 it returns by convention the integer 0 for the > empty sum (is this correct?) which of course has no list. > > But shouldn't it return the null polynomial in this case? > And isn't the null polynomial represented by the empty list? > > No, because sum has no way to know that you are expecting a polynomial. You can add a zero polynomial to make the sum over it to obtain a polynomial as a result. With David function: sage: R=ZZ['x'] sage: zero = R(0) sage: def ib(m, n): return sum([binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1)], zero) sage: type(ib(2,2)) sage: ib(2,0) 0 sage: type(ib(2,0)) sage: for n in (0..6): :print(ib(2, n).list()) : [] [1, 1] [4, 1, 3] [16, -4, 15] [64, -34, 56, 0, 7] [256, -134, 171, -9, 93] [1024, -494, 539, -165, 638] -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/c402036f-b729-494b-a1d0-0ceca9a03fa2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] The behavior of empty sums
On Monday, June 17, 2019 at 2:12:58 PM UTC+2, Peter Luschny wrote: As I see it the problem is that the sum runs over (0..n-1). > Thus for n = 0 it returns by convention the integer 0 for the > empty sum (is this correct?) which of course has no list. > > But shouldn't it return the null polynomial in this case? > And isn't the null polynomial represented by the empty list? > > No, because sum is not adding polynomials, it is adding the empty list, there is no way that the sum known that you are expecting a polynomial. sage: for n in (0..6): :print(ib(2, n).list()) : [] [1, 1] [4, 1, 3] [16, -4, 15] [64, -34, 56, 0, 7] [256, -134, 171, -9, 93] [1024, -494, 539, -165, 638] sage: sum([]) 0 sage: *def* *ib*(m, n): *return* sum(binomial(m*n-*1*, m*k) *for* k in (*0.* .n-*1*)) This function should return integers, no polynomials. If you want to return a flint polynomial, you could instruct to make the sum over the polynomial zero using an additional argument. With David function sage: R=ZZ['x'] sage: zero = R(0) sage: def ib(m, n): return sum([binomial(m*n-1, m*k)*cyclotomic_polynomial(m*(k+1)) for k in (0..n-1)], zero) sage: type(ib(2,2)) sage: ib(2,0) 0 sage: type(ib(2,0)) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/3c6eb571-cbcf-455f-9ac2-ff2737f6b411%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] surface normal vector of polyhedron face
On Wednesday, February 27, 2019 at 2:52:36 PM UTC+1, Daniel Krenn wrote: > > I suppose in non-full-dimensional case you still can use > > P.inequalities() as above, > > projecting them on the affine hull of P. > > Yes, this is the interesting case. The problem then is going back from > the projection. I guess that orthogonality is ususally destroyed here... > You should use Gram-Smidth on the normal vectors of the equations in the linearity space and the inequality defining the facet right? sage: P = Polyhedron([[4,1,5,6],[2,3,1,4],[3,3,3,3]]) sage: P.equations() (An equation (0, 4, 1, 2) x - 21 == 0, An equation (2, 0, -1, 0) x - 3 == 0) sage: f = P.faces(1)[0] sage: f <0,1> sage: f.ambient_Hrepresentation() (An equation (0, 4, 1, 2) x - 21 == 0, An equation (2, 0, -1, 0) x - 3 == 0, An inequality (0, 0, 1, 2) x - 9 >= 0) sage: # Not sure if the Hrepresentation of f is always the linearity space + inequality, check the code, the following is just to be on the safe side sage: M = matrix([ec.vector()[1:] for ec in P.equations() ] + [inec[1:] for inec in f.ambient_Hrepresen : tation() if inec.is_inequality()]) sage: M [ 0 4 1 2] [ 2 0 -1 0] [ 0 0 1 2] sage: v = M.gram_schmidt()[0].row(-1); v (4/13, -12/13, 8/13, 20/13) sage: #This should be the inner normal vector of the facet in the linearity space sage: f.vertices() (A vertex at (2, 3, 1, 4), A vertex at (3, 3, 3, 3) sage: a = vector([2,3,1,4]) sage: b = vector([3,3,3,3]) sage: c = (a+b)/2 sage: c in P True sage: c + 1/100*v in P True sage: P.relative_interior_contains(c) False sage: P.relative_interior_contains(c+1/100*v) True -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: differences between the "image()" and "column_space()" commands on a matrix
Sage interprets that matrices M acts on row vectors v on the left, v*M so in fact the method image corresponds to row_space >From the help of image: Return the image of the homomorphism on *rows* defined by this matrix. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: About finding roots of polynomials in specific domains
On Thursday, June 11, 2015 at 5:26:28 PM UTC+2, Phoenix wrote: I have two polynomials $p(x)$ and $q(x)$ and I want to know if there are roots of the equation $\frac{p'}{p} = \frac{q'}{q}$ in the domain $(a,\infinity)$ - where $a = max \{ roots(p),roots(q) \}$ This is the same as asking for the roots of the polynomial, $p'q - pq' = 0$ in the same domain. - Can something in Sage help? Depending on the coefficient field, the degree of the polynomials, accuracy etc. You can also take a look at Sturm's theorem and Sturm's sequence. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Expression to polynomial
On Friday, June 12, 2015 at 11:17:37 AM UTC+2, Néstor wrote: Hello, I've got a rational expression in sage and I would like to convert it to a polynomial with coefficients in some fraction field. More precisely, I've got something like this: a , x = var( 'a , x' ) ; P = x/a ; and I would like to see it like a polynomial in the polynomial ring in the variable x with coefficients on the fraction field Q(a) of rational expressions in the variable a: C.a = PolynomialRing(QQ) ; B = FractionField(C) ; A.x = PolynomialRing(B) ; But when I try P.polynomial(A) I get the following error TypeError: unable to coerce since the denominator is not 1 try sage: A(P) 1/a*x sage: _.parent() Univariate Polynomial Ring in x over Fraction Field of Univariate Polynomial Ring in a over Rational Field Sometimes, when Sage is not smart enough to perform a conversion between complicated rings, I where able to perform the conversion with the ugly hack: sage: A(str(P)) -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: elements of a field extensions
On Tuesday, June 9, 2015 at 5:36:01 PM UTC+2, black...@gmx.de wrote: Thank you, and i already tried this. In this case it obiously does work but in case i have denominators, can u explain me how to solve it? for example: K(s/(s+t),s^2*t^2) then i have to calculate the elimination ideal of ((a0-s,a1-s^2t^2):(s+t)^\inf) where (I:J^\inf) is the saturation of I with respect to J? You should look for elimination theory, If you have a subfield K(f1/g1,...,fr/gr) in K(x1,...,xn) han have an element h, You should construct the Ideal I = Ideal ( g1*a1-f1, , gr*ar-fr, h-b) Where a1,...,ar, b are new variables. You saturate with respect to g1*g2*...*gr. For efficiency reasons, it might be faster to succesively saturate with respect to each gi Then eliminate the variables x1,...,xn, I0 = I.elimination_ideal([x1,...,xn]) Now you have to check if there is a polynomial in I0 of degree exactly 1 in b. You can obtain this from a Grobner basis with respect to an appropriate order. In general, if every generator of I0 has degree 0 in b, then h is transcendent over K(f1/g1,...fr/gr) otherwise, the polynomial with minimal degree in b is in fact (a multiple of) the minimal polynomial of h over K(f1/g1,...,fr/gr) I think that if you can factor and compute gcd of multivariate polynomials, you can also approach the problem using resultants. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Homomorphism from power series ring to residue field
Within a specific interactive session, you could do the following, when creating the rings: sage: R = PowerSeriesRing(GF(2),'t') sage: F = R.residue_field() sage: phi = R.hom([0], F) sage: F.register_coercion(phi) This way, you are indicating that the morphism phi should be considered a coercion morphism from R to F. Then, you are done, Sage is smart enough to extend it to polynomial rings. sage: PR = PolynomialRing(R,'x,y') sage: PF = PolynomialRing(F,'x,y') sage: PR.hom(PF) Ring Coercion morphism: From: Multivariate Polynomial Ring in x, y over Power Series Ring in t over Finite Field of size 2 To: Multivariate Polynomial Ring in x, y over Finite Field of size 2 Note that you will encounter problems. There is already a canonical coercion from F to R, namely the inclusion. This can be seen as the composition of the canonical inclusions F subset F['t'] subset F[['t']]. So, with both coercions you end up with: sage: t = R.gen() sage: one = F(1) sage: t+one 1+t sage: (t+one).parent() is R True sage: one+t 1 sage: (one+t).parent() is R False sage: (one+t).parent() is F True Both elements are coerced to the ring of the left element. Thus, adding elements from R and F is not conmutative, nor PR and PF. This will soon end in trouble if you are not careful enough. I recommend you instead to define phi but without adding it to the coercion framework: sage: R = PowerSeriesRing(GF(2),'t') sage: t = R.gen() sage: F = R.residue_field() sage: phi = R.hom([0], F) sage: one = F(1) And then, be explicit in the operations when you want to pass to the residue field. sage: phi(t) + one 1 sage: PR = PolynomialRing(R, 'x,y') sage: PF = PolynomialRing(F, 'x,y') sage: x, y = PR.gens() sage: f = (1+t)+(1-t^2)*x + (1+2*t)*y^3 sage: f y^3 + (1 + t^2)*x + 1 + t sage: g = f.map_coefficients(phi); g y^3 + x + 1 sage: g.parent() is PR False sage: g.parent() is PF True -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: elements of a field extensions
Have you tried using elimination ideals? K=QQ['s,t,a0,a1,a2'] K.inject_variables() I = Ideal( a0-s^2, a1-t^2, a2 - (s^2+t^2)) I.elimination_ideal([s,t]) Ideal (a0 + a1 - a2) of Multivariate Polynomial Ring in s, t, a0, a1, a2 over Rational Field So a2 = a0 + a1 The elimination ideal tells you which algebraic relations are between s^2, t^2 and s^2+t^2. In general, you have to check if there is a polynomial in the elimination ideal that is linear in a2. I think that you can attain this taking a Grobner basis with respect to a block order where a2 [a0,a1,x,y,z] If you have denominators, you have to saturate the ideal with respect to them before attempting the elimination. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Typo in provided documentation
It looks right to me. I am not a native English speaker so I could be (very) wrong, but I understand that the comparison x2 is evaluated, which is completely true, independently if the condition is evaluated as True or False. In fact, next lines tell why x2 is evaluated False and that h(x) returns x-2. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Computing Grobner Basis for general coefficients denoted by some variables.
In general, I prefer to put the parameters a_i as variables and then interpret the results. Another approach you may try is to work in the field: GF(2^d)['a_1,a_2,a_3'].fraction_field()['x_1,x_2,x_3'] but then you may encounter specialiation problems with denominators, another problem is that your coefficients will probably be huge. If you are interested in finite fields, you may also try to put the parameters a_i as variables and, moreover, add to your ideal the polynomials a_i^(2^d)-a_j to denote that a_i is an arbitrary element of the ground field GF(2^d). -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] segmentation fault computing discriminants
On Wednesday, March 26, 2014 10:34:35 AM UTC+1, John Cremona wrote: Looking at the code used, it uses the resultant formula which in turn evaluates a determinant. I agree with you that for small degrees it would be better (almost certainly in a lot of cases) be better to substitute into the generic formula. Even if it is not the best code around, it should not segfault. I will try the latest beta... -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: groebner bases of polynomials with complex coefficients
On Monday, February 17, 2014 6:39:38 PM UTC+1, sahi...@gmail.com wrote: OK, I tried the following: S.i,x,y = PolynomialRing(QQ,order='lex') I = ideal(i^2+1,(1+i)*x+y,x+(1-i)*y-(1-i)) G = I.groebner_basis() G would give me [i - x - 1, x^2 + 2*x + 2, y - 2] which are the results. But I am confused; why I can't get the result when I try to get a polynomial ring in the field of complex numbers implemented by sage? Also, does adding i**2+1=0 really extend the rational numbers to complex number field? The problem with CC is that it is an *inexact field. *If you do computations with coefficients in CC, you will end up with roundup errors. For instance, buchberger algorithm to compute Grobner basis would yield the ideal (1) with high probability. In the case, you are not computing on the complex numbers, only on the gaussian rationals. Essentially, you are working on QQ[i] without naming it. In this case your solutions live on QQ[i] so it is not a problem. Consider the following example: system x^2+i+y^3, y^4-x sage: S.i,x,y=PolynomialRing(QQ,order='lex') sage: I=Ideal(x^2+i+y^3, y^4-x) sage: I.groebner_basis() [i + y^8 + y^3, x - y^4] Then, y is any of the 8 roots of the polynomial *'i + y^8 + y^3*', and for each one of these roots, *x=y^4*. So you get 8 pairs (x,y) of solutions. By the way, the suggestion given by John Perry is to do: sage: N.i = NumberField(x^2+1) sage: S.x,y=PolynomialRing(QQ,order='lex') if you do this, then sage: i^2 -1 you are really working on QQ[i] -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-support] Can I change QQ[sqrt(a),sqrt(b)] to QQ[\alpha] ?
Nevermind, I found it. Call K2.structure() for the maps. Thank you! Moreover, you can register these isomorphisms as coercions. I do not recommend the following for noninteractive scripts. But I find it very convenient: sage: K=QQ[sqrt(2),sqrt(3)] sage: s2,s3=K.gens() sage: L=K.absolute_field('a') sage: a=L.gen() sage: phi = L.structure() sage: phi (Isomorphism map: From: Number Field in a with defining polynomial x^4 - 10*x^2 + 1 To: Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field, Isomorphism map: From: Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field To: Number Field in a with defining polynomial x^4 - 10*x^2 + 1) sage: K.register_coercion(phi[0]) sage: L.register_coercion(phi[1]) sage: s2+a 2*sqrt2 - sqrt3 sage: a+s2 1/2*a^3 - 7/2*a -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: Floating point exception when factoring over QQ['x,y']
On Wednesday, November 28, 2012 9:27:58 PM UTC+1, Simon King wrote: Hi Georgi, On 2012-11-28, Georgi Guninski guni...@guninski.com javascript: wrote: Probably the problem is in Singular. Probably not. If I am not mistaken, Singular is involved in polynomial factorisation over *finite* fields. I agree with Georgi, the problem is either in Singular or in a library that Singular uses. Multivariate factorization over QQ is done through Singular and, if you start Singular and tries to factorize the polynomial you get a segfault. -- You received this message because you are subscribed to the Google Groups sage-support group. 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. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] Re: Floating point exception when factoring over QQ['x,y']
I can confirm the problem with sage 5.4, I cannot reproduce it with sage 5.3 -- You received this message because you are subscribed to the Google Groups sage-support group. 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. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Strange results with multivariate resultants
On Wednesday, September 19, 2012 6:34:52 AM UTC+2, Georgi Guninski wrote: Hi, I may be missing something, but the resultant = 1 confuses me. According to wikipedia [1] the multivariate resultant or Macaulay's resultant of n homogeneous polynomials in n variables is a polynomial in their coefficients that vanishes when they have a common non-zero solution Note that this means n homogeneous polynomials in n variables, in your example you only have two polynomials in four variables, it is not the same case of Macaulay's resultant. My pain is $1$ can't vanish while solutions exist. Here is homogeneous example: sage: K.x1,x2,x3,x4=QQ[] sage: p1,p2=(x2)*(x3-x4),x2*(x3-2*x4) sage: p1.resultant(p2,x1) 1 Certainly p1 and p2 have common solutions while the res. w.r.t. x1 never vanishes (got this in a real world situation). As said, in this case the resultant is computed in the ring QQ(x2,x3)[x1] and the resultant will vanish if the two (univariate) polynomials have a common root in the algebraic closure of QQ(x2,x3). This is the standard resultant of multivariate polynomials with respect to one variable. -- You received this message because you are subscribed to the Google Groups sage-support group. 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. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Strange results with multivariate resultants
On Thursday, September 20, 2012 1:05:56 PM UTC+2, Georgi Guninski wrote: pari disagrees with sage and maxima agrees with it. which way is it? maxima session: (%i12) p1:(x2)*(x3-x4);p2:x2*(x3-2*x4); (%i14) resultant(p1,p2,x1); (%o14) 1 In this case, there is no evaluation of x1 in the algbebraic closure of QQ(x2,x3,x4) that makes both polynomials zero. (%i15) resultant(p1,p2,x2); (%o15) 0 In this case, there is a common root in the algebraic closure of QQ(x1,x3,x4), namely x2=0 -- You received this message because you are subscribed to the Google Groups sage-support group. 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. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] rotation of a scene and tachyon
I have a problem to set an animation. I have the following: sage: L1 = sphere((0,0,0),5) sage: L2 = L1.rotateZ(pi/3) sage: L1.save('one.png',aspect_ratio=[1,1,1],frame=False) sage: L2.save('dos.png',aspect_ratio=[1,1,1],frame=False) One of the images is much smaller than the other, this posses problems for making an animation like: http://www.youtube.com/watch?v=Htm50rC4vBc For that animation I onstructed the frame and then put it inside a transparent sphere containing the whole scene. But this is an ugly hack. What is the propeer way to rotate an object without suffering zooming effect? This is related to the more general question. Is there a way to deal with the camera using tachyon viewer? For instance, it seems that for implicit3d objects, the tachyon viewer has the camera hard-coded. Thanks -- 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
[sage-support] Re: Question about scoping
On Jan 16, 5:53 pm, Ed Scheinerman edward.scheiner...@gmail.com wrote: I'm confused by the fact that variables defined inside functions can leak out and become global variables. Here's what I've noticed. The problem is twith the function var. According to its documentation: (var?) The new variable is both returned and automatically injected into the global namespace. If you need symbolic variable in library code, it is better to use either SR.var() or SR.symbol(). The var function is only intended to be used on an interactive session by the user. If you need variables inside a function you need SR.var def steiner(a,b,c): Given three points in the plane, find the point p that minimizes the sum of the distances to those three points. x = SR.var('x') y = SR.var('y') p = (x,y) # unknown point # objective function to minimize obj = dist(p,a) + dist(p,b) + dist(p,c) # start search at center of mass of the three points p0 = ( (a[0]+b[0]+c[0])/3., (a[1]+b[1]+c[1])/3. ) print Starting optimiztion at, p0 print obj.subs(x=p0[0], y=p0[1]) return minimize(obj,p0) Then: sage: x = [1,2,3] sage: y = [4,5,6] sage: x [1, 2, 3] sage: y [4, 5, 6] sage: steiner((1,1), (2,3), (5,2)) Starting optimiztion at (2.6665, 2.0) 5.4788343901030965 Optimization terminated successfully. Current function value: 5.303240 Iterations: 6 Function evaluations: 7 Gradient evaluations: 7 (2.20179756615, 2.46316721759) sage: x [1, 2, 3] sage: y [4, 5, 6] -- 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
[sage-support] Re: Question about minimal polynomial to build GF
sage: F.x=GF(2^8,name='x',modulus=z^8+z^4+z^3+z^2+1,check_irreducible=False) sage: F Finite Field in x of size 2^8 sage: F.polynomial() x^8 + x^4 + x^3 + x^2 + 1 Andrzej Chrzeszczyk In this case sage does not complaint, but check_irreducible is not intended for this use, but to avoid the time of checking that your polynomial is irreducible whenever you are sure it is irreducible. If you put a reducible polynomial then the behaviour of GF is undefined and will probably be wrong. sage: K.z=GF(2)[] sage: F.x=GF(2^8,name='x',modulus=z^8 + z^7 + z^4 + z^3 + z + 1,check_irreducible=False) sage: F Finite Field in x of size 2^8 sage: F.polynomial() x^8 + x^4 sage: x+1 1 sage: x+ (1-1) x sage: (x+1)-1 0 sage: x^8 x^4 If you really want to work with this modulus, you do not have to use GF which is for finite fields. You are looking for quotient algebras sage: F.x=K.quotient(z^8 + z^7 + z^4 + z^3 + z + 1) sage: x+1 x + 1 sage: x^8 x^7 + x^4 + x^3 + x + 1 sage: 1/x x^7 + x^6 + x^3 + x^2 + 1 sage: 1/(x+1) ... ZeroDivisionError: element x + 1 of quotient polynomial ring not invertible -- 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
[sage-support] Re: Increasing memory limit?
On Oct 17, 2:51 pm, Eric enordens...@gmail.com wrote: Does anyone know how to enlarge the memory limits set by sage? I get the following message when running a certain computation that involves computing large determinants. Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again. Available restarts: 1. (CONTINUE) Extend heap size Top level. What are the coefficients of the matrix? In which ring do they live? If m is the matrix, please post the result of m.parent() -- 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
[sage-support] Problem with VirtualBox image
Hi list, I have downloaded the virtualbox sage image to run under windows to make a presentation of the capabilities of Sage. I wanted to try in windows and an old machine to try to force things. So I took my five- years good old laptop. The problem is that sage in virtualbox does not run. Sage complains that the processor does not have the instructions pni, ssse3 While I assume that performance will be very very poor on this virtualized environment (I do neither have virtualization extensions in the processor). I had assumed that at least it would run. Is it a bug? What is the minimum hardware in wich Sage is expected to run? OK I know at least those flags in the processor. What I mean is if this restriction is intended. -- 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
[sage-support] Re: Problem with VirtualBox image
On Sep 23, 7:06 pm, Volker Braun vbraun.n...@gmail.com wrote: I'll look into lowering the processor requirements. Though SSE3 has been out for a looong time... You can rebuild Sage inside the virtual machine. Just interrupt the notebook server (Ctrl-C), go to the Sage directory, run make distclean and then make. Let it run overnight ;-) Thanks for the tip. On the very same laptop I have Debian installed and Sage runs smooth. But I have always installed from source, so never noticed any problems with distributed binaries. Recompiling is not great for my purposes, because is no more vanilla Sage. For sure I will not try that on the virtual machine. I will try to compile inside a chrooted enviroment on the Debian OS. -- 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
[sage-support] Re: Bug in pari/gp or sage? Any fixes?
On Sep 15, 12:43 pm, Amir amirg...@gmail.com wrote: Hi I have the same problem. I am using sage 4.6 installed on windows vista. This is part of code I have written in sage. Is there anyway I can catch this error and make an exception? Thanks An exception is not the way to dela with this error. We need gp to work without problems. Do you use the VirtualBox image to deal get this problem? I will try to reproduce it. -- 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
[sage-support] Re: Bug in pari/gp or sage? Any fixes?
On Sep 13, 9:11 am, vasu tewari.v...@gmail.com wrote: Hi all I am trying to run a particular piece of code and it gives an error saying there is a bug in Pari/gp. It turns out that the bug is not present in previous versions of Pari like 2.3.4 (on Windows at least). And if I understand correctly that Sage ships with the newest install of Pari. Is there any way to use the latest Sage version with an old version of Pari?? Any input is appreciated. For those interested, what follows is the code along with the error message. t=gp.thueinit(x^3+21*x^2-2*x-25,1); m=gp.thue(t,1) Hi Vasu, Which version of Sage are you running? Which plattform? How have you installed it? I cannot reproduce your error in Sage 4.7.1 sage: t=gp.thueinit(x^3+21*x^2-2*x-25,1); sage: m=gp.thue(t,1) sage: m [[1, 0]] -- 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
[sage-support] Re: How to calculate the affine coordinats of a point
On Jul 16, 1:33 am, Johannes dajo.m...@web.de wrote: a very easy example would be this: sage: p1 = vector([-3,1,1]) sage: p2 = vector([1,-3,1]) sage: p = vector([0,-2,1]) #now i'm looking for some x,y such that #x * p1 + y * p1 == p x,y = var('x,y') sage: assume(x 0) sage: assume(y 0) sage: solve([x * p1 + y * p2 == p],x,y) [] #but: x = 1/4 and y = 3/4 is a solution of this equation. in the end i need this kind of calculation for every latticepoint on the border of a lattice-simplex. like the example above shows how it should work for a line, it also should be extendable to n+1 points on each n dimensional facet of the simplex, where the points p0,,pn are given as the vertices of the facet. greatz Johannes This is a linear algebra problem. You have a vector p that is a linear combinations of others p1,p2 and you want the coordinates of p in terms of B. This is only a change of basis problem. Assuming that the points of B form a basis of the linear span of B you can do: sage: m = matrix([p1,p2]) sage: m.solve_left(p) (1/4, 3/4) The rows of m are the vectors p1 and p2. You want to express p as combination of these rows. -- 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
[sage-support] Re: How to calculate the affine coordinats of a point
On Jul 18, 3:48 pm, Johhannes dajo.m...@web.de wrote: thnx. I see that the problem can be also formulated as marix problem. but the way i did it is in this case the more natural one for me. is there any reason why it only works this way and solve does not lead to any result? For me it looks like: In solve, when writting a == b you assume that a and b are expressions involving several variables. If a and b are expressions, then a == b is also an expression. However, p and x*p1+y*p2 are NOT expressions, but vectors. And equality of vectors is not the same as equality of expressions sage: x == y x == y sage: type(_) type 'sage.symbolic.expression.Expression' sage: vector([x]) == vector([y]) False sage: type(_) type 'bool' So, in fact, you are passing the following command: sage: [x * p1 + y * p2 == p] [False] sage: solve([False],x,y) Which has no solution. It is subtle, but I would not consider it a bug. If you really want to use solve, you may try the following: sage: solve(x * p1 + y * p2 - p,x,y) [[x == (1/4), y == (3/4)]] In this case, the input is a vector, that is an iterable, so solve extracts its components and equals them to zero. Being said that, I recommend you to use the linear algebra interpretation that I suggested, since it will probably be much more efficient. -- 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
[sage-support] Re: Polynomials Mod 7
On Jul 14, 3:23 am, Mel chemmyg...@gmail.com wrote: Hi, I've been having an issue with a program I've written in sage. I need to calculate a polynomial mod 7. When I do this using the command line, I don't have any trouble. Example: sage: x = var('x') sage: y = var('y') sage: IntegerPolyRing.x,y = ZZ[] sage: ideal = -6*x - y sage: ideal = IntegerPolyRing(ideal) sage: print type(ideal) type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular' sage: print ideal%7 x + 6*y However, when my program calculates an ideal which is equal to -6*x - y and has the type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular', it always gets 0 for ideal%7. This happens for every ideal that the program calculates. I'm flummoxed. Any ideas as to what might be causing this? We need more information. My guess is that at some point you are jumping to an ideal with rational coefficients, maybe clearing the content of a polynomial. In that case 7 is a unit of QQ, so f % 7 will be zero -- 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
[sage-support] Re: Decomposing polynomials from other polynomials using Gröbner bases
On Apr 5, 2:10 pm, Johan S. R. Nielsen santaph...@gmail.com wrote: Oops, continuing: more precisely, we wish to find a q in Q[Y1, Y2] such that q(f1, f2) = g. In this case, we have q(Y1, Y2) = Y1^2 + Y1*Y2 - Y2 as a solution, as f1^2 + f1*f2 - f2 = g This is an elimination problem. Note that it is not enough that g belongs to the ideal to be able to write it in the desired form. You instead want to check if g belongs to the ring Q[f1,f2] that is a different problem. I can think of the following: First you add new variables for your polynomials f1,f2 and g, call them y1,y2,z and a polynomial ring with a block elimination term order. sage: K=PolynomialRing(QQ, 'x,z,y1,y2',order=TermOrder('degrevlex', 2)+TermOrder('degrevlex',2)) sage: K.inject_variables() Defining x, z, y1, y2 In this ring, x and z are greater than y1,y2 now construct the ideal defining your polynomials I=Ideal(x^2+1-y1, x+3-y2, x^4+x^3+4*x^2+x+3-z) If we eliminate x from this ideal we will get the ideal of algebraic dependence on f1,f2,g sage: J=I.elimination_ideal([x]) sage: J Ideal (y2^2 - y1 - 6*y2 + 10, z - y1^2 - y1*y2 + y1) of Multivariate Polynomial Ring in x, z, y1, y2 over Rational Field If I am not making any mistake, the reduction of z under this ideal with this term ordering should give the desired polynomial. sage: J.reduce(z) y1^2 + y1*y2 - 4*y1 + 3 -- 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
[sage-support] Re: full_simplify and trig_simplify
hi Jose Luis, By the error do you mean a NameError? There are no such global functions defined in Sage. I would rather use simplify_full and simplify_trig because there would be easier to discover by a user writing simpl and pressing tab. On the one hand it is true that for newcomers simplify_full(q) is a more common sintax than q.simplify_full. On the other hand by the object oriented nature of python you will never get rid of class.function sintax entirely and once you get used, I rather tend to use the second sintax more often. So the question is if simplify_full is common enough to promote it to have a top level function. In fact the function is pretty easy def simplify_full(q): try: return q.simplify() except AttributeError: return q On Mar 8, 3:58 am, Juan Luis Varona juanluis.var...@gmail.com wrote: Dear sagefriends, (sorry for my English) Let us define var('t'); q=sin(t)^2 + cos(t)^2 By using simplify(q) we again get sin(t)^2 + cos(t)^2 Instead of simplify() we can use full_simplify() and trig_simplify(). But both full_simplify(q) and trig_simplify(q) give an error message. You must use q.full_simplify() or q.trig_simplify() to get the answer 1. But this kind of notation as a method is very strange for many people. Wy not to add the possibility of use full_simplify(q) or similar for many other methods? Perhaps it is too complicate to implement it, I don't know... Yours, Juan Luis Varona -- 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
[sage-support] Re: Intersection of complex Ideals
Robert, You have been answered how to solve the problem. But I would like to remark Volker's advice. Do not use ideals over CC. CC is an inexact ring, so most operations will fail. Work instead over the rationals. R.x,y = PolynomialRing(QQ,2) or if you need complex numbers, you may try with a number field N.I = NumberField(x^2+1) R.x,y = PolynomialRing(N, 2) -- 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
[sage-support] Re: Intersection of complex Ideals
No, it is not an exact computation over the complex, they are gauss rationals a+b*I where a and b are rationals. As far as I know there is no exact complex field implementation that is good for working with ideals. What kind of generators of ideals are you dealing with? Note that even if the input generators are in QQ, the answers of computations are to be interpreted over the complex. On Mar 1, 11:59 am, Robert Goss goss.rob...@gmail.com wrote: Thank you very much for your advice. I was trying to work out if the problem lay with me sage or documentation. Do not use ideals over CC. CC is an inexact ring, so most operations will fail. Work instead over the rationals. R.x,y = PolynomialRing(QQ,2) or if you need complex numbers, you may try with a number field N.I = NumberField(x^2+1) R.x,y = PolynomialRing(N, 2) Thank you for this I have a lot of computations to do over the complex number field. While i knew that CC was inexact i wasnt aware of NumberField. Is this the best was of having an exact version of the complex numbers? Robert -- 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
[sage-support] Re: Intersection of complex Ideals
On Mar 1, 12:59 pm, Robert Goss goss.rob...@gmail.com wrote: What kind of generators of ideals are you dealing with? For reference all the input generators are in QQ. Robert Then, definitely you should work in PolynomialRing(QQ,2) -- 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
[sage-support] Re: Isolating real roots of exact univariate polynomial
Just for the record. The problem seems to be related to RIF. For the inexact ring RR, it works: len(e.roots(ring=RR)) 13 len(e.real_roots()) 13 numeric approximations of the two missing roots are: 0.953956769342757, 0.957223630414975 This pair of roots is exactly the pair of most close roots among all. So it seems that a sign change is not detected. On Feb 18, 3:41 pm, zteitler zteit...@gmail.com wrote: I was not sufficiently careful in posting my polynomial e(x) and apparently some bad line breaks and spaces were introduced. This reply is to post a properly-wrapped copy of the polynomial. Zach Teitler -- 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
[sage-support] Re: Error in using PolynomialRing(QQ, vars) and elimination_ideal()
The first method creates the ring AND add the variables so that they are available to the user by tipping their name. for instance: sage: R.x,y,z,A,B,k,i,j,m=QQ[] sage: x x sage: type(x) type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular' Note that this is not python, but a sage-specific shortcut. However, the second creation of R only creates a polynomial ring with variables x,y,z,A,B,k,i,j,m. sage: vs = var('x,y,z,A,B,k,i,j,m') sage: x x sage: type(x) type 'sage.symbolic.expression.Expression' x is a symbolic variable (not a polynomial variable) sage: R = PolynomialRing(QQ,vs) sage: x x sage: type(x) type 'sage.symbolic.expression.Expression' x is still a symbolic variable. Not an element of R. Sage is smart enough to make sense of the creation of the ideal. But you cannot eliminate the variables k,i,j,m,A,B from the ideal because this variables are symbolic variables. Not the variables of R. What would be equivalent to the first method would be: sage: vs = var('x,y,z,A,B,k,i,j,m') sage: R = PolynomialRing(QQ,vs) sage: R Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: R.inject_variables() Defining x, y, z, A, B, k, i, j, m sage: invs = [i*A+j*B-x,k*A+m*B-y,(i-k)*A+(j-m)*B-z] sage: I = R*invs sage: I Ideal (A*i + B*j - x, A*k + B*m - y, -A*k + A*i + B*j - B*m - z) of Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: J=I.elimination_ideal([k,i,j,m,A,B]) The method R.inject_variables() introduces the variables in the polynomialring so that the user can acces them. Why is this? Suppose that you define sage: R1 = QQ['t'] sage: R2 = GF(2)['t'] sage: R3 = QQ['t','s'] This creates three rings. Where t should belong to? Each of those polynomial ring introduces its own variable t and it may happen that I just want the variable t to be other thing different from those variables. In fact, what Sage is really doing with your first attempt is: sage: preparse('R.x,y,z,A,B,k,i,j,m=QQ[]') R = QQ['x, y, z, A, B, k, i, j, m']; (x, y, z, A, B, k, i, j, m,) = R._first_ngens(9) Creating the ring R and then inserting the variables so they are available to the user. On Feb 14, 6:54 pm, tvn nguyenthanh...@gmail.com wrote: I thought the below 2 versions would be the same but version 2 using PolynomialRing(QQ,vars) seems to have problem as listed below. Am I missing something ? Version 1: -- | Sage Version 4.6.1, Release Date: 2011-01-11 | | Type notebook() for the GUI, and license() for information.| -- sage: R.x,y,z,A,B,k,i,j,m=QQ[] sage: R Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: invs = [i*A+j*B-x,k*A+m*B-y,(i-k)*A+(j-m)*B-z] sage: I = R*invs sage: I Ideal (A*i + B*j - x, A*k + B*m - y, -A*k + A*i + B*j - B*m - z) of Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: J=I.elimination_ideal([k,i,j,m,A,B]) sage: Version 2: $ sage -- | Sage Version 4.6.1, Release Date: 2011-01-11 | | Type notebook() for the GUI, and license() for information.| -- sage: vs = var('x,y,z,A,B,k,i,j,m') sage: R = PolynomialRing(QQ,vs) sage: R Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: invs = [i*A+j*B-x,k*A+m*B-y,(i-k)*A+(j-m)*B-z] sage: I = R*invs sage: I Ideal (A*i + B*j - x, A*k + B*m - y, -A*k + A*i + B*j - B*m - z) of Multivariate Polynomial Ring in x, y, z, A, B, k, i, j, m over Rational Field sage: J=I.elimination_ideal([k,i,j,m,A,B]) --- TypeError Traceback (most recent call last) /home/tnguyen/USB/SVN/DCBA/code/ipython console in module() /home/tnguyen/Src/Devel/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in wrapper(*args, **kwds) 367 368 with RedSBContext(): -- 369 return func(*args, **kwds) 370 371 from sage.misc.sageinspect import sage_getsource /home/tnguyen/Src/Devel/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in elimination_ideal(self, variables) 1822 R = self.ring() 1823 Is = MPolynomialIdeal(R,self.groebner_basis()) - 1824 return MPolynomialIdeal(R, eliminate(Is, prod(variables)) ) 1825 1826 @redSB /home/tnguyen/Src/Devel/sage/local/lib/python2.6/site-packages/sage/libs/singular/function.so in sage.libs.singular.function.SingularFunction.__call__ (sage/libs/singular/function.cpp:9634)()
[sage-support] parallel map
I thought I have already asked this. But I do not see it on the history of the group. Apologize for multiple posting. Is there an equivalent in Sage to ParallelMap in mathematica? I am looking a method that applies a given function to a list of objects for a small presentation of Sage I am preparing. I am aware of the @parallel decorator. That does exactly what I am looking for. However, the output of the decorator is a little ugly and I am looking for something even more transparent to the user. I am currently using the following function: sage: def parallel_map(funcion, list_of_values): : @parallel : def par_funcion(*args, **kwds): : return funcion(*args, **kwds) : output_list = [foo for foo in par_funcion(list_of_values)] : dictionary = {} : for i in output_list: : dictionary[i[0][0][0]] = i[1] : return [dictionary[i] for i in list_of_values] : sage: K = QQ[x] sage: L = [K.random_element(450)*K.random_element(450) for i in range(2)] sage: r1 = map(factor, L) sage: r2 = parallel_map(factor, L) sage: r1 == r2 True That is just @parallel with some treatment on the output and seems to work for simple enough functions. This is enough for my presentation, but, is there anything similar already in Sage? Thanks, Luis -- 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
[sage-support] Re: simplify ans sqrt
On Jan 26, 8:42 am, Loïc xl...@free.fr wrote: Hello list, Version: sage 4.6.1 I'm quite a newbie with Sage but I'm really impressed this powerful software. Since an hour, I'm on a stupid problem: sage: sqrt(2)*sqrt(3) sqrt(2)*sqrt(3) sage: sqrt(2)*sqrt(3)-sqrt(6) sqrt(2)*sqrt(3)-sqrt(6) I would expect sqrt(6) and 0... I try with the command simplify() too but it doesn't do anything. That's very odd because: sage: sqrt(75)+2*sqrt(48) 13*sqrt(3) (Here it simplifies the operation) Can anyone help me ? Hi, There are several simplify procedures, by default sage does not apply them. For simplifying radicals, the preferable one is simplify_radical that is not available as a top command. If you do sage: a = sqrt(2)*sqrt(3) - sqrt(6) and then write a.simplify and press the tab button, you will see the different possibilities for simplifying that expression, these methods depend on the input. In this case, you get: a.simplifya.simplify_factorial a.simplify_log a.simplify_rational a.simplify_expa.simplify_full a.simplify_radical a.simplify_trig It looks that simplify_radical is what you are looking for: sage: a.simplify_radical() 0 In doubt, you can always try simplify_full that will try to do its bests applying different methods. With the second example, sqrt(75) is transformed into 5*sqrt(3) and sqrt(48) into 4*sqrt(3), since there is a common factor sqrt(3), then sage collects these terms without asking to do so, but for other kind of identities like sqrt(2)*sqrt(3) = sqrt(6) you have to be explicit. Luis -- 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
[sage-support] Re: Hermite Normal Form
On Dec 28, 5:27 pm, Santanu Sarkar sarkar.santanu@gmail.com wrote: Is there any faster method to compute Hermite Normal Form of a matrix A and corresponding transformation matrix? I use A.hermite_form(transformation=true). However it is very slow. Also is there any transformation matrix corresponding to the LLL algorithm. What are the size/shape of your problem? If you just want the hermite_form you can use A.hermite_form(algorithm = ...), where the algorithms available can be checked in A.echelon_form. If you need transformation = true. Then the method will always be a padic one, that is asymptotically fast, but may be slow for small matrices. Concerning the question of LLL. I may be wrong, but I think that there is not right now a built-in method to obtain the transformation matrix. You could solve the linear system of equations sage: A = random_matrix(ZZ, 25, 50) sage: B = A.LLL() sage: trans_matrix = A \ B sage: A * trans_matrix == B True -- 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
[sage-support] Re: Hermite Normal Form
On Dec 28, 6:23 pm, Santanu Sarkar sarkar.santanu@gmail.com wrote: Size of my matrix is (90, 36) with entries are around 2^1000. What is the fastest method to compute Hermite Normal Form? In that case, the fastest may be the default one you are already using. Note that computing the Hermite form is fast, the hard part is computing the transformation matrix. In my matrix number of rows greater than number of columns. That is A= random_matrix(ZZ, 90, 36). Then how can I calculate transformation matrix of LLL? I made a mistake, if the lattice is represented by the rows, then it is not A\B but trans_matrix = A.solve_left(B), look at the documentation of the methods. trans_matrix * A = B express the rows of B as combinations of rows of A -- 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
[sage-support] Re: intersection of ideals
On Dec 7, 5:03 pm, andrew ewart aewartma...@googlemail.com wrote: I have the following code P.x0,x1,y0,y1,y2,y3 = PolynomialRing(QQ,order='degrevlex') I = Ideal(x0^4-y0,x0^3*x1-y1,x0*x1^3-y2,x1^4-y3) print I R.y0,y1,y2,y3 = PolynomialRing(QQ,order='degrevlex') I1=Ideal(1) J=I.intersection(I1) print J but gives error File /usr/local/sage/sage-4.6/local/lib/python2.6/site-packages/sage/ rings/polynomial/multi_polynomial_ideal.py, line 369, in wrapper return func(*args, **kwds) File /usr/local/sage/sage-4.6/local/lib/python2.6/site-packages/ sage/rings/polynomial/multi_polynomial_ideal.py, line 1327, in intersection raise ValueError, other must be an ideal in the ring of self, but it isn't. ValueError: other must be an ideal in the ring of self, but it isn't. becuase I doesnt lie in R so how do I change this so that sage will be happy for I, an ideal in P, intersecting with any ideal in R (also R is supposed to be a subring of P where the x0 and x1 are removed) Sort answer, you cannot intersect ideals in different rings. Note that I1 is an ideal of ZZ since you wrote Ideal(1) which is assumed to be 1 in ZZ. You could define the ideal 1 in R as (for instance) I1 = Ideal(R(1)) I2 = I1.change_ring(P) # Now it is an ideal in P with the same generators as I1 I2.intersection(I) Ideal (x1^4 - y3, x0*x1^3 - y2, x0^3*x1 - y1, x0^4 - y0) of Multivariate Polynomial Ring in x0, x1, y0, y1, y2, y3 over Rational Field -- 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
[sage-support] Re: newbie working in polynomial quotient rings
On Dec 5, 1:58 pm, eggartmumie eggartmu...@googlemail.com wrote: Hi, I am a newbie working in polynomial quotient rings: I want to implement the Patterson algorithm to decode Goppa Codes. Therefore, I need to split a polynomial p in a quotient ring in its even part p0 and its odd part p1 such that p(z) = p0^2(z)+z*p1^2(z). I run into several problems to do so in SAGE: I define I guess you mean p0(z^2)+zp1(z^2), you can use list filters {{{ sage: K.x=QQ[x] sage: p = 3+4*x^4+5*x^3+6*x^7+8*x^9+10*x^12 sage: p0 = K(p.list()[::2]) sage: p1 = K(p.list()[1::2]) sage: p0 10*x^6 + 4*x^2 + 3 sage: p1 8*x^4 + 6*x^3 + 5*x sage: p0(x^2)+x*p1(x^2)-p 0 }}} Read about list slicing -- 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
[sage-support] Re: Bug in genus of an ideal
On Nov 21, 6:22 am, VictorMiller victorsmil...@gmail.com wrote: sage: T.t1,t2,u1,u2 = QQ[] sage: TJ = Ideal([t1^2 + u1^2 - 1,t2^2 + u2^2 - 1, (t1-t2)^2 + (u1- u2)^2 -1]) sage: TJ.genus() 4294967295 sage: TJ.dimension() 1 Yes, there is a bug in the code. If I try Sage 32 bits, the answer to TJ.genus() is -1. Is I use Sage 64 bits I get your result. The genus -1 looks like the ideal is not (absolutely) prime. This looks odd at first sight since the ideal is prime over the rationals and the projection onto [t1,t2] or [u1,u2] gives rational curves. But, after a little research the answer looks right. sage: T.t1,t2,u1,u2,t=QQ[sqrt(3)][] sage: TJ = Ideal([t1^2 + u1^2 - 1,t2^2 + u2^2 - 1, (t1-t2)^2 + (u1- u2)^2 -1]) sage: TJ.is_prime() False sage: TJ.primary_decomposition() [Ideal (3*t2 + (-2*sqrt3)*u1 + (sqrt3)*u2, 3*t1 + (-sqrt3)*u1 + (2*sqrt3)*u2, 4*u1^2 - 4*u1*u2 + 4*u2^2 - 3) of Multivariate Polynomial Ring in t1, t2, u1, u2, t over Number Field in sqrt3 with defining polynomial x^2 - 3, Ideal (3*t2 + (2*sqrt3)*u1 + (-sqrt3)*u2, 3*t1 + (sqrt3)*u1 + (-2*sqrt3)*u2, 4*u1^2 - 4*u1*u2 + 4*u2^2 - 3) of Multivariate Polynomial Ring in t1, t2, u1, u2, t over Number Field in sqrt3 with defining polynomial x^2 - 3] The ideal is the union of two rational conjugate curves. -- 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
[sage-support] Re: elimination of variables
On 5 nov, 21:45, andrew ewart aewartma...@googlemail.com wrote: i want to write a polynomial p of variables x and y such that p(x,y)=0 i also have that x and y can be expressed in terms of a variable u such that 2x=2u^2+2u-1 and -y^2=u^4+2u^3-2u-1 how to write code to eliminate u, hence finding p You could use resultants in this case to eliminate de u. {{{ sage: K.x,y,u=QQ[] sage: f= 2*x -(2*u^2+2*u-1 ) sage: g=-y^2- (u^4+2*u^3-2*u-1) sage: h=f.resultant(g,u); h 16*x^4 + 32*x^2*y^2 + 16*y^4 - 24*x^2 - 24*y^2 - 16*x - 3 }}} -- 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
[sage-support] Re: sage won't simplify something that is clearly 0
On 2 nov, 17:00, Rob H. robert.har...@gmail.com wrote: Hi, so here is some sample code: var('chi,k') R.x=SR[] I=R.ideal(x^2) Rbar.epsilon=R.quotient_ring(I) expr=Rbar(epsilon-(chi^(k-1))^5+chi^(2*k-2)*(chi^(k-1))^3) view(expr) print (expr) For the kind of operations you are doing, you should work in QQ[] instead as you have been advised. However, this looks like a bug in latex for me. {{{ sage: expr epsilon sage: latex(expr) epsilon - {\left(\chi^{{\left(k - 1\right)}}\right)}^{5} + \chi^{{\left(2 \, k - 2\right)}} {\left(\chi^{{\left(k - 1\right)}} \right)}^{3} }}} -- 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
[sage-support] Polyhedron from inequalities
Suppose that I define a set of equalities and inequalities {{{ sage: var('x,y,z,t') (x, y, z, t) sage: L = [x==y+z, x=t-z, x+3*y=0] }}} Is there an easy way to construct the Polhyedron of the solutions of this system? The constructor of Polyhedron does not seem very user- friendly for Hrepresentations. I can program my own function to do this, but I wonder if Sage already has this. -- 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
[sage-support] Re: Lot of segfaults...
On Oct 16, 1:59 pm, Thierry Dumont tdum...@math.univ-lyon1.fr wrote: Hello, On our Sage server, we have a lot a students doing simple computer algebra. Our version of Sage is 4.5.3 on Debian Lenny. We have a lot of segfaults in maxima: Could you post more information of the problem? Did you install sage from source or binary? It is a 32 or 64 machine? Could you please post a command that produces the segfault in maxima? Yours Luis -- 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
[sage-support] Re: common devisor
On Sep 27, 3:34 pm, Johannes dajo.m...@web.de wrote: Hi list, is there a way to get a sum of fraction to a common devisor? or even better into a product of a fraction like \frac{1}{something here} and a sum of integers? and my next step would be this, i dont have a single value, which i want to get as the above produkt, but i've got a vector for wich i want to write as produkt of a skalar times an integervektor. how can i do this? greatz Johannes Hi, Is this what you want? sage: v = vector([2/3,1/4,0]) sage: common_denom = denominator(v) sage: common_denom 12 sage: vector_of_nums = v * common_denom sage: vector_of_nums (8, 3, 0) note that here, internally, vector of nums is a vector with rational entries. If you want a vector of sage integers you could do sage: vector_of_nums = vector_of_nums.change_ring(ZZ) And you will have a vector with Integer entries, if you need this last command or not depends on what do you want to do with your vector. Luis -- 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
[sage-support] Re: Testing if polynomial is in ideal
On Sep 8, 2:49 am, Cary Cherng cche...@gmail.com wrote: This works but is too slow for more complicated examples. Is there a way to speed up x in I for much bigger examples? Or does this already use the fastest algorithm based on groebner basis or something else. Blind checking if a polynomial is in an ideal is, and will always be, a hard problem. If I recall correctly, it is a exponential-space complete problem. -- 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
[sage-support] Re: why does constructing this ring take forever?
On Jul 7, 2:21 am, dmharvey dmhar...@cims.nyu.edu wrote: sage: R.x = PolynomialRing(Integers(16219299585*2^16612 - 1)) Maybe not literally forever, but I got sick of waiting. Should be instantaneous. david When constructing a polynomial ring over Z/nZ sage distingishes between prime modulus or not. Moreover, Sage is exigent and is not happy with only a pseudoprimality test (this is intended). So, the time in constructing the PolynomialRing is in fact checking if 16219299585*2^16612 - 1 is a proven prime. -- 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
[sage-support] Possible bug in relative number fields homomorphisms
I found the following: {{{ sage: N.s2,s3,s5 = NumberField([x^2-2, x^2-3, x^2-5],'s2,s3,s5') sage: M = N.absolute_field('gamma') sage: N_to_M = M.structure()[1] sage: phi = N.hom([N_to_M(s2)]) sage: phi(s2) == N_to_M(s2) True sage: phi(s3) == N_to_M(s3) True sage: phi(s5) == N_to_M(s5) False sage: phi(s5) == -N_to_M(s5) True }}} I would expect that phi(s5) == N_to_M(s5), but I am not sure if this is a bug or a feature. Relative number fields seem hard to deal with. -- 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
[sage-support] Re: Conversion from number field to polynomial
On 19 abr, 12:07, samuele.anni samuele.a...@gmail.com wrote: Hello, I'm trying to implement an algorithm for complete my thesis work about congruence between modular forms and Galois representation. A step of the algorithm I am working on consists in replacing a generator of the number field with a fixed value obtained, clearly the command substitute cannot work because the elements of the matrix are algebraic integers of the number field so nothing is seen as a “variable”. The only thing that comes in my mind is to find a way to convert my vector into a polynomial vector substituing to alpha a variable x, but I cannot find a way to do this. sage: K.alpha = NumberField(x^4 - 30*x^2 - 40*x + 5);K Number Field in alpha with defining polynomial x^4 - 30*x^2 - 40*x + 5 sage: A=[alpha - 1, 1/2*alpha^3 - 5/2*alpha^2 - 1/2*alpha + 17/2, -alpha^3 +4*alpha^2 + alpha - 10, alpha^2 - 2*alpha - 3, 2*alpha^3 - 8*alpha^2 -4*alpha + 22, -2*alpha^3 + 8*alpha^2 + 2*alpha - 18, -2*alpha^3 +8*alpha^2 + 3*alpha - 21, 3/2*alpha^3 - 15/2*alpha^2 + 3/2*alpha + 33/2,-3/2*alpha^3 + 11/2*alpha^2 + 7/2*alpha - 27/2, 2*alpha^3 - 7*alpha^2 -4*alpha + 15, -1/2*alpha^3 + 1/2*alpha^2 + 5/2*alpha - 1/2, -alpha^3 +6*alpha^2 - alpha - 16, -alpha^3 + 3*alpha^2 + 6*alpha - 12, 3/2*alpha^3- 11/2*alpha^2 - 5/2*alpha + 21/2, -3*alpha^3 + 13*alpha^2 + 5*alpha -35]; sage: A1=[A[i].substitute(alpha=12) for i in range(0, len(A))];A1 [alpha - 1, 1/2*alpha^3 - 5/2*alpha^2 - 1/2*alpha + 17/2, -alpha^3 + 4*alpha^2 + alpha - 10, alpha^2 - 2*alpha - 3, 2*alpha^3 - 8*alpha^2 - 4*alpha + 22, -2*alpha^3 + 8*alpha^2 + 2*alpha - 18, -2*alpha^3 + 8*alpha^2 + 3*alpha - 21, 3/2*alpha^3 - 15/2*alpha^2 + 3/2*alpha + 33/2, -3/2*alpha^3 + 11/2*alpha^2 + 7/2*alpha - 27/2, 2*alpha^3 - 7*alpha^2 - 4*alpha + 15, -1/2*alpha^3 + 1/2*alpha^2 + 5/2*alpha - 1/2, -alpha^3 + 6*alpha^2 - alpha - 16, -alpha^3 + 3*alpha^2 + 6*alpha - 12, 3/2*alpha^3 - 11/2*alpha^2 - 5/2*alpha + 21/2, -3*alpha^3 + 13*alpha^2 + 5*alpha - 35] Does anybody know a way to solve my problem? Thanks for the help Samuele If x is an element of K, x.polynomial() returns a representation of x as a polynomial (the representative of x of minimal degree thinking K=QQ[x]/f(x)) So, you can do sage: A1=[x.polynomial()(12) for x in A];A1 [11, 1013/2, -1150, 117, 2278, -2298, -2289, 3093/2, -3543/2, 2415, -1525/2, -892, -1236, 3561/2, -3287] -- 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
[sage-support] Re: p-adic implementation in SAGE
On 24 mar, 06:13, Barukh Ziv barukh@gmail.com wrote: Dear all, I would like to ask you about a problem I am encountering while using NTL library for p-adic numbers manipulation. Sometimes, I get the following internal error from NTL function: can't grow this _ntl_gbigint Are you using ntl_ZZ_p or ntl_ZZ_pE? I have experienced the same type of errors with the latter (due to bad manipulations of ntl_ZZ_pEContext by myself. -- 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 To unsubscribe from this group, send email to sage-support+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[sage-support] Re: p-adic implementation in SAGE
On 24 mar, 12:53, Barukh Ziv barukh@gmail.com wrote: Guys, Thank you for the quick reply. I will answer to both questions: Are you using ntl_ZZ_p or ntl_ZZ_pE? I have experienced the same type of errors with the latter (due to bad manipulations of ntl_ZZ_pEContext by myself. Yes, I experience problems while using ZZ_pE as in this case NTL does block allocation, and cannot re-allocate a single ZZ_p. On Mar 24, 11:08 am, Mike Hansen mhan...@gmail.com wrote: Are you able to post the code that causes this problem? That would help a lot with trying to figure out what's going on. --Mike Mike, unfortunately, the code is too complicated to be presented here, but I will try my best to explain what kind of the problem I am facing. Basically, the problem occurs once an ZZ_pX was created with a certain modulus N, and then assigned from another ZZ_pX created with a bigger modulus N' N. Semantically, consider the following algorhtm: ZZ_pE a, ap; // Initialize ap while (precision max_precision) { a = f(ap); // * ap = a; // ** precision++; } where calculations in f() are done with modulus 2^precision. IMHO, both statements (*) and (**) may lead to an error, as they should be overwritten with bigger array. This is essentially a problem stated in the aforementioned SAGE doc page on p-adic element. So, I wonder, do you know any good ways to overcome this? In particular, is there a way to explicitly re-allocate a previously allocated ZZ_pX object? Yes you can, altought if your code is very low level I am not sure on the impact. Consider this: sage: a = ntl.ZZ_pContext(128) sage: polynomial = ntl.ZZ_pX([1,2,3,4,5],a) sage: for i in range(128): : a = ntl.ZZ_pContext(a.modulus()*2) : f = f.convert_to_modulus(a) : sage: f [1 2 3 4 5] sage: f.get_modulus_context() NTL modulus 43556142965880123323311949751266331066368 This create a new polynomial modulus the right context.However, this will not work to change context in ZZ_pEX in which you are changing your defining polynomial (succesive residuals of a p-adic f) For example, Suppose f = 15 + x ^2 and you want an algorithm to compute in (ZZ/2^nZZ)[x] / ( f(x) ) sage: p = ntl.ZZ_pContext(2) sage: f = [15, 0, 1] sage: pe = ntl.ZZ_pEContext( ntl.ZZ_pX(f, p) ) sage: poly = ntl.ZZ_pEX([[1], [0], [0,1]], pe) sage: p2 = ntl.ZZ_pContext(4) sage: poly = poly.convert_to_modulus(p2) sage: sage: poly.get_modulus_context() NTL modulus [1 0 1] (mod 4) Which is not what we want. Instead, you could add to ntl_ZZ_pEX a function like (In the following function one should omit the pcontext input c and use cE.get_pc() instead) def convert_to_pE(self, ntl_ZZ_pContext_class c, ntl_ZZ_pEContext_class cE): Returns a new ntl_ZZ_pE which is the same as self, but considered modulo a different pE (but the SAME polynomial). cE.restore_c() cdef ntl_ZZ_pEX ans = PY_NEW(ntl_ZZ_pEX) _sig_on ZZ_pEX_conv_modulus(ans.x, self.x, c.x) _sig_off ans.c = cE return ans with this function, the previous example would be: sage: p = ntl.ZZ_pContext(2) sage: f = [15, 0, 1] sage: pe = ntl.ZZ_pEContext( ntl.ZZ_pX(f, p) ) sage: poly = ntl.ZZ_pEX([[1], [0], [0,1]], pe) sage: p2 = ntl.ZZ_pContext(4) sage: pe2 = ntl.ZZ_pEContext( ntl.ZZ_pX(f, p2) ) sage: poly = poly.convert_to_pE(p2, pe2) sage: poly.get_modulus_context() NTL modulus [3 0 1] (mod 4) Another question: does NTL perform an automatic garbage collection in any way? No idea, sorry -- 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 To unsubscribe from this group, send email to sage-support+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[sage-support] cython cimport problems
Hi, I am trying to work with cython. I have the following code: from sage.libs.ntl.ntl_ZZ cimport ntl_ZZ cdef ntl_ZZ dummy(ntl_ZZ a, int b): return a If I compile it with sage -bI get the following error: building 'sage.rings.polynomial.polynomial_absolute_number_field_dense' extension gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes - fPIC -I/opt/SAGE/sage/local//include -I/opt/SAGE/sage/local//include/ csage -I/opt/SAGE/sage/devel//sage/sage/ext -I/opt/SAGE/sage/local/ include/python2.6 -c sage/rings/polynomial/ polynomial_absolute_number_field_dense.c -o build/temp.linux-i686-2.6/ sage/rings/polynomial/polynomial_absolute_number_field_dense.o -w sage/rings/polynomial/polynomial_absolute_number_field_dense.c:304: error: field ‘x’ has incomplete type The relevant line in the code says: /* Type declarations */ /* /opt/SAGE/sage-4.3.3/devel/sage-luisfe/sage/libs/ntl/ntl_ZZ.pxd:4 * include decl.pxi * * cdef class ntl_ZZ: # * cdef ZZ_c x * cdef public int get_as_int(ntl_ZZ self) */ struct __pyx_obj_4sage_4libs_3ntl_6ntl_ZZ_ntl_ZZ { PyObject_HEAD struct __pyx_vtabstruct_4sage_4libs_3ntl_6ntl_ZZ_ntl_ZZ *__pyx_vtab; struct ZZ x; }; I am not sure if this is a bug with cython or a Im doing wrong the import statementes. Any hint? -- 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 To unsubscribe from this group, send email to sage-support+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[sage-support] Re: numerator has a funny parent() -- intentional ?
On 1 mar, 20:46, Pierre pierre.guil...@gmail.com wrote: oooh wait wait wait. I've said something totally confusing. My previous two posts apply to rational fractions... for which indeed, the numerator method gives the 'correct' answer ! The issue I raised in my original post is the 'funny' behaviour when you ask for the numerator of something in QQ[x] -- which, come to think of it, is mathematically a little unsound. I just totally assumed this should give the same answer as coercing into the field of rational fractions and then applying numerator(), but it doesn't. You (Robert) assumed something absolutely different. (Now i still think it would be less surprising is sage acted as i suggested, but i don't have strong feelings about it anymore :) ) so in any case, having realized this, i have found an ugly fix : sage: N= P.parent().fraction_field()(P).numerator() # gives what i want !! always work ! Yes, this is intentional, I think that it is used somewhere for number theory. As pointed out, there is no good definition for numerator of an element in QQ[x]. The current implementation for polynomial rings K[x1,..,xn] is as following: -For the denominator: if there is a denominator function for the coefficients and these denominators have a lcm function, then return the lcm of the coefficients. This is an element of K, not K[x1,...,xn] -If the previous computation fails, then return K(1) not K[x1,...,xn] (1) The numerator is the original polynomial times its denominator. This is always in K[x1,..,xn] It has its drawbacks, as you have found. In particular, the numerator of an element in QQ[x] is not necessarily the same as the numerator of the same element in QQ(x). It has its advantages though. If you try this: sage: K=QQ['x'] sage: L=K.fraction_field()['y'] sage: f=L.random_element() sage: f.numerator() sage: QQ['x','y'](f.numerator()) f lives in Q(x)[y], but its numerator can be coerced to Q[x,y] wich is nice for some computations. So, in fact, it depends much on what are you computing. -- 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
[sage-support] Re: Fwd: sage bug report
On 17 dic, 11:48, ma...@mendelu.cz ma...@mendelu.cz wrote: And another observation: maxima returns answer immediatelly (with a lag necessary to start maxima) m is the original matrix from x.py sage: m._maxima_().determinant().expand().sage() x0^2*x2^2*x3^2*x7^2 - 2*x0*x1*x2*x3*x4*x5*x6*x7 + x1^2*x4^2*x5^2*x6^2 Anyway, the answer is different from expected one. I do not konw which one is correct. Robert If you perform the computations over the polynomial ring, sage gives an answer sage: R=FractionField(PolynomialRing(GF(2),,.join(map(genVar,range (0,10) sage: n=matrix(R.base(),m) sage: n-m [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] sage: det(n) x1^2*x4^2*x5^2*x6^2 + x0^2*x2^2*x3^2*x7^2 However, the result differs from the one in maxima and maple About the result, the matrix is mod 2, so the expected anwer in maxima equals the one computed above sage: factor(det(n)) (x1*x4*x5*x6 + x0*x2*x3*x7)^2 -- 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
[sage-support] Re: Dealing with algebraic elements and rational functions
On 20 mar, 14:07, Mike Hansen mhan...@gmail.com wrote: The best way to work with this object is to do like you did: sage: K.a=NumberField(x^4+x+1) sage: R.x,y,z,t=K['x,y,z,t'] Then, we can construct some elements of this field: sage: f = (a^2*x + y)*(z+a*t); f (a^2)*x*z + y*z + (a^3)*x*t + (a)*y*t sage: g = f/(x+a) sage: g ((a^2)*x*z + y*z + (a^3)*x*t + (a)*y*t)/(x + (a)) (1) Obtain a representation in base a, that is, write f as f0 + f1*a + f2*a^2 + f3*a^3 I can't think of a way to do this other than what the following function does: def powers_of_a(f): powers = {} for m, fc in zip(f.monomials(), f.coefficients()): for i, c in enumerate(fc): powers[i] = powers.get(i, 0) + c*m for i, p in powers.items(): print i, :, p sage: powers_of_a(f) 0 : y*z 1 : y*t 2 : x*z 3 : x*t Thank you for your answer, in fact I had a similar solution to polynomials. However, this or similar code will not work for rational functions. powers_of_a(1/(x^2-a)) Traceback (click to the left for traceback) ... AttributeError: 'sage.rings.fraction_field_element.FractionFieldEle' object has no attribute 'monomials' This is related with how to compute norms of polynomials. I will try to implement this norm and apply it to compute this representation for rational functions. --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Dealing with algebraic elements and rational functions
Hi all, I am wondering how to make some computations with rather specific field extensions. I cannot figure out how to solve the following on SAGE. Mathematically, I have the following field: Q(x,y,z,t,a) Where x,y,z,t are indeterminates and a is an algebraic number over the rationals (lets say degree 4). If I have some elements, let say f,g,h in this field I would like to: (1) Obtain a representation in base a, that is, write f as f0 + f1*a + f2*a^2 + f3*a^3 (2) Compute the norm of f with respect to the extension [Q (x,y,z,t,a) : Q(x,y,z,t) ] (3) Extract a valid numerator and denominator of f, that is, compute polynomials r,s in Q[x,y,z,t,a] such that f=r/s (4) Construct ideals and compute a Grobner basis of a series of polynomials extracted as numerators of rational fuctions (5) Factorize polynomials in Q[x,y,z,t,a] extracted from numerators/denominatos of rational functions. Depending on how I represent the field I think that I cannot do almost all of the above, for example I have tried working with R.x,y,z,t,a=QQ['x,y,z,t,a'] L=R.quotient_ring(R.ideal(a^4+a+1)) Quotient ring in general does not apply to this problem because the system cannot know if this is a field. So another approach like R.x,y,z,t,a=QQ['x,y,z,t,a'] R.quotient_ring(R.ideal(a^4+a+1)) neither work If I do K.a=NumberField(x^4+x+1) R.x,y,z,t=K['x,y,z,t'] I do not know how to solve problems (1), (2), (5) Is there a construction that allows me to do the previous? Maybe it is possible to construct several isomorphic fields, each one having a representation that allows to solve some of the problems above and construct explicit isomorphism between them in order to pass from one representation to another. Any hint about this? Thanks! Luis --~--~-~--~~~---~--~~ 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 URLs: http://www.sagemath.org -~--~~~~--~~--~--~---