[sage-support] Re: Intersection (and quotient) of ideals in a single variable polynomial ring
Link: https://share.cocalc.com/share/df81e09e5b8f16f28b3a2e818dcdd4560e7818ae/support/2020-08-18-mpoly.ipynb?viewer=share On Tuesday, August 18, 2020 at 9:56:00 AM UTC-7 William wrote: > Hi Luis, > > It's actually not a bug, but a missing feature. The problem is that in > the first case R is a *univariate* polynomial ring, and in the second case > it is a multivariate polynomial ring and different functionality is > available in each case. Read the docs for PolynomialRing (via > PolynomialRing?) for more details. To fix your code, just use the > implementation="singular" option to get a multivariate polynomial ring in 1 > variable: > > R. = PolynomialRing(QQ, implementation="singular") > > -William > > On Tuesday, August 18, 2020 at 6:31:55 AM UTC-7 Luis Garcia-Puente wrote: > >> The following code does not run in a Jupyter notebook inside cocalc >> >> R. = PolynomialRing(QQ) >> f = x^3+6*x^2+12*x+8; >> g = x^2+x-2; >> I = R.ideal([f]); >> J = R.ideal([g]); >> I.intersection(J) >> >> This produces an error that ends with the line: >> >> AttributeError: 'Ideal_1poly_field' object has no attribute 'intersection' >> >> Similarly, we get an error in the following line >> >> I.quotient(J) >> >> AttributeError: 'Ideal_1poly_field' object has no attribute 'quotient' >> >> However, if we use the ring on 2 variables >> >> R. = PolynomialRing(QQ) >> >> all computations execute. >> >> -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/525ad011-8c83-4eae-8058-597e034be223n%40googlegroups.com.
[sage-support] Re: Intersection (and quotient) of ideals in a single variable polynomial ring
Hi Luis, It's actually not a bug, but a missing feature. The problem is that in the first case R is a *univariate* polynomial ring, and in the second case it is a multivariate polynomial ring and different functionality is available in each case. Read the docs for PolynomialRing (via PolynomialRing?) for more details. To fix your code, just use the implementation="singular" option to get a multivariate polynomial ring in 1 variable: R. = PolynomialRing(QQ, implementation="singular") -William On Tuesday, August 18, 2020 at 6:31:55 AM UTC-7 Luis Garcia-Puente wrote: > The following code does not run in a Jupyter notebook inside cocalc > > R. = PolynomialRing(QQ) > f = x^3+6*x^2+12*x+8; > g = x^2+x-2; > I = R.ideal([f]); > J = R.ideal([g]); > I.intersection(J) > > This produces an error that ends with the line: > > AttributeError: 'Ideal_1poly_field' object has no attribute 'intersection' > > Similarly, we get an error in the following line > > I.quotient(J) > > AttributeError: 'Ideal_1poly_field' object has no attribute 'quotient' > > However, if we use the ring on 2 variables > > R. = PolynomialRing(QQ) > > all computations execute. > > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/e22e6b65-eb8f-4cb9-a78b-11c69ad0a155n%40googlegroups.com.
[sage-support] Re: intersection
On Wed, May 14, 2014 at 1:25 AM, nas mer wrote: > Hi > Thank you > I attach the program of intersection in sage. > please, look at the attach file. See attached. > Best regard This is an elementary problem in matrix theory. Is this homework for a class? -- 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: p = 13 sage: F = K = GF(p) sage: y1 = 3 sage: V = F^9 sage: v1 = vector(F, [0,0,0,-y1-1,1,0,0,0,0]) sage: v2 = vector(F, [y1,-y1,-1,1,0,y1,1,0,0]) sage: v3 = vector(F, [0,y1,-y1,0,0,0,0,0,1]) sage: v4 = vector(F, [y1,0,0,0,0,0,0,1,0]) sage: W = V.span([v1, v2, v3, v4]) sage: W sage: U = F^9 sage: u1 = vector(F, [0,0,1,0,0,0,1,0,0]) sage: u2 = vector(F, [0,0,0,1,0,1,0,0,0]) sage: u3 = vector(F, [1,0,0,0,0,0,0,0,0]) sage: u4 = vector(F, [0,0,0,0,0,0,0,0,1]) sage: u5 = vector(F, [0,0,0,0,1,0,0,0,0]) sage: u6 = vector(F, [0,1,0,0,0,0,0,1,0]) sage: E = U.span([u1, u2, u3, u4, u5, u6]) sage: E
Re: [sage-support] Re: Intersection a cone with hyperplanes
Thank you. that's exactly what I was looking for. bg, Johannes On 25.11.2012 14:56, Volker Braun wrote: > Construct cone and hyperplane: > > sage: C = Cone([(1,0),(0,1)]) > sage: H = Polyhedron(eqns=[(-2,1,1)]) > sage: H.Hrepresentation() > (An equation (1, 1) x - 2 == 0,) > > Compute the intersection polyhedron: > > sage: P = H.intersection( C.polyhedron() ); P > A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices > sage: P.Vrepresentation() > (A vertex at (2, 0), A vertex at (0, 2)) > > > On Sunday, November 25, 2012 1:42:24 PM UTC, Johhannes wrote: > > Hi List, > Is there a build-in-way to get the intersection of a given cone C with > an given hyperplane h? > > In detail I have the following situation: > > C = Cone( [List of primitive generators] ) > H_h = Hyperplane {x : \sum x_i = h}. > > C intersected with H_h will be a bounded polytope. > > If there's not such an function, where would be the best place to place > it? Extend/overwrite the existing intersection function of the cone? > > regards, > Johannes > > -- > 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. > > -- 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: Intersection a cone with hyperplanes
Construct cone and hyperplane: sage: C = Cone([(1,0),(0,1)]) sage: H = Polyhedron(eqns=[(-2,1,1)]) sage: H.Hrepresentation() (An equation (1, 1) x - 2 == 0,) Compute the intersection polyhedron: sage: P = H.intersection( C.polyhedron() ); P A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices sage: P.Vrepresentation() (A vertex at (2, 0), A vertex at (0, 2)) On Sunday, November 25, 2012 1:42:24 PM UTC, Johhannes wrote: > > Hi List, > Is there a build-in-way to get the intersection of a given cone C with > an given hyperplane h? > > In detail I have the following situation: > > C = Cone( [List of primitive generators] ) > H_h = Hyperplane {x : \sum x_i = h}. > > C intersected with H_h will be a bounded polytope. > > If there's not such an function, where would be the best place to place > it? Extend/overwrite the existing intersection function of the cone? > > regards, > Johannes > -- 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: Intersection of complex Ideals
On Mar 1, 12:59 pm, Robert Goss 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
Re: [sage-support] Re: Intersection of complex Ideals
> What kind of generators of ideals are you dealing with? For reference all the input generators are in QQ. 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
Re: [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. Ah yes that would make a lot of sense. I will go back to my problem and see the best way of dealing with it. Thank you for your help. Regards, 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
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 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. = PolynomialRing(QQ,2) > > > or if you need complex numbers, you may try with a number field > > > N. = NumberField(x^2+1) > > R. = 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
Re: [sage-support] Re: Intersection of complex Ideals
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. = PolynomialRing(QQ,2) > > or if you need complex numbers, you may try with a number field > > N. = NumberField(x^2+1) > R. = 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
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. = PolynomialRing(QQ,2) or if you need complex numbers, you may try with a number field N. = NumberField(x^2+1) R. = 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
Re: [sage-support] Re: Intersection of complex Ideals
On Tuesday 01 March 2011, Simon King wrote: > Hi Robert, > > On 1 Mrz., 01:00, Robert Goss wrote: > > I have 2 ideals over the complex field and I would like to take their > > intersection. If I try and use the intersection method on one of the > > ideals i get an error message from singular stating the following type > > error: > > > > TypeError: Cannot call Singular function 'intersect' with ring > > parameter of type ' > 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_dom > > ain'>' > > Sage uses a C-library version of Singular to do intersection > (libSingular), but... > > > This was generated by the code: > > R. = PolynomialRing(CC, 2) > > ... unfortunately it does not use libSingular for rings with complex > coefficients: I started changing that (only RR so far) in: http://trac.sagemath.org/sage_trac/ticket/7577 but the ticket got stuck because we need to decide whether it's okay to use MPF instead of MPFR for multivariate polynomials. Cheers, Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://martinralbrecht.wordpress.com/ _jab: martinralbre...@jabber.ccc.de -- 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
Hi Robert, On 1 Mrz., 01:00, Robert Goss wrote: > I have 2 ideals over the complex field and I would like to take their > intersection. If I try and use the intersection method on one of the > ideals i get an error message from singular stating the following type > error: > > TypeError: Cannot call Singular function 'intersect' with ring > parameter of type ' 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain'>' Sage uses a C-library version of Singular to do intersection (libSingular), but... > This was generated by the code: > R. = PolynomialRing(CC, 2) ... unfortunately it does not use libSingular for rings with complex coefficients: sage: type(R) sage: from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular sage: R. = MPolynomialRing_libsingular(CC,2) Traceback (most recent call last): ... NotImplementedError: Base ring is not supported. > Am I doing something wrong? Would anyone suggest a better way of doing > this computation? I think you did nothing wrong -- it should work the way you did it. Here is a work around: sage: R. = CC[] sage: I = x*R sage: J = y*R sage: singular(I).intersect(J) x*y That uses another Singular interface (not a C-library). The result lives there, so, you need to pull it back into your ring R: sage: parent(singular(I).intersect(J)) Singular sage: R*list(singular(I).intersect(J)) Ideal (x*y) of Multivariate Polynomial Ring in x, y over Complex Field with 53 bits of precision The second best solution is to work with a base ring that is supported by libSingular: sage: R. = ZZ[] sage: I = x*R sage: J = y*R sage: I.intersection(J) Ideal (-x*y) of Multivariate Polynomial Ring in x, y over Integer Ring sage: R. = QQ[] sage: I = x*R sage: J = y*R sage: I.intersection(J) Ideal (x*y) of Multivariate Polynomial Ring in x, y over Rational Field Of course, the best solution would be to wrap Singular's complex coefficients in libSingular. Is there a trac ticket for it? Kind regards, Simon -- 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
Singular supports working with floating-point complex numbers (CDF in Sage), so it should work. Having said that, floating-point computations with polynomials are often dangerous because of the limited precision. Its usually better to work with arbitrary-precision coefficients like QQ or cyclotomic numbers... sage: R.=QQ[] sage: R.ideal(x).intersection(R.ideal(y)) Ideal (x*y) of Multivariate Polynomial Ring in x, y 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
Re: [sage-support] Re: intersection of ideals
On Tue, Dec 7, 2010 at 4:58 PM, Simon King wrote: > On 7 Dez., 17:48, andrew ewart wrote: > > I thought I1=R=<1> > > As I said, nobody could guess that you believe that 1 is in R. > > > also the intersection should be in R, not just in P, so how is this > > achieved? > > Read my previous post, it is answered there. > > -- > 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 > yeah i posted it before i noticed u had replied, sorry about that your suggestion makes it works thankyou -- 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 7 Dez., 17:48, andrew ewart wrote: > I thought I1=R=<1> As I said, nobody could guess that you believe that 1 is in R. > also the intersection should be in R, not just in P, so how is this > achieved? Read my previous post, it is answered there. -- 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
Re: [sage-support] Re: intersection of ideals
On Tue, Dec 7, 2010 at 4:29 PM, luisfe wrote: > On Dec 7, 5:03 pm, andrew ewart wrote: > > I have the following code > > > > P. = PolynomialRing(QQ,order='degrevlex') > > I = Ideal(x0^4-y0,x0^3*x1-y1,x0*x1^3-y2,x1^4-y3) > > print I > > R. = 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 > I thought I1=R=<1> also the intersection should be in R, not just in P, so how is this achieved? -- 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
Hi, On 7 Dez., 17:03, andrew ewart wrote: > I have the following code > > P. = PolynomialRing(QQ,order='degrevlex') > I = Ideal(x0^4-y0,x0^3*x1-y1,x0*x1^3-y2,x1^4-y3) > print I > R. = 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 No. The problem is not that I does not lie in R. The problem is that I1 does not lie in P: sage: P. = PolynomialRing(QQ,order='degrevlex') sage: I = Ideal(x0^4-y0,x0^3*x1-y1,x0*x1^3-y2,x1^4-y3) sage: R. = PolynomialRing(QQ,order='degrevlex') sage: I1=Ideal(1) sage: I.ring() is P True sage: I1.ring() Integer Ring There is no reason to believe that any CAS could guess that you want Ideal(1) to be an ideal in P or R or whatever ring if you don't state it -- 1 is an integer, and thus Ideal(1) is an ideal in ZZ. This is an answer to your question. But it seems to me that your question is actually not relevant to your problem. If I understand correctly, you want to eliminate the variables x0 and x1, right? So, you could do sage: I.elimination_ideal([x0,x1]) Ideal (y1*y2 - y0*y3, y2^3 - y1*y3^2, y0*y2^2 - y1^2*y3, y1^3 - y0^2*y2) of Multivariate Polynomial Ring in x0, x1, y0, y1, y2, y3 over Rational Field Of course, the elimination ideal still belongs to P, not to R, although the variables x0,x1 are not used anymore. If you want to obtain an ideal in R, you could do sage: R.ideal_monoid()(I.elimination_ideal([x0,x1])) Ideal (y1*y2 - y0*y3, y2^3 - y1*y3^2, y0*y2^2 - y1^2*y3, y1^3 - y0^2*y2) of Multivariate Polynomial Ring in y0, y1, y2, y3 over Rational Field or sage: I.elimination_ideal([x0,x1]).change_ring(R) Ideal (y1*y2 - y0*y3, y2^3 - y1*y3^2, y0*y2^2 - y1^2*y3, y1^3 - y0^2*y2) of Multivariate Polynomial Ring in y0, y1, y2, y3 over Rational Field Best regards, Simon -- 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 wrote: > I have the following code > > P. = PolynomialRing(QQ,order='degrevlex') > I = Ideal(x0^4-y0,x0^3*x1-y1,x0*x1^3-y2,x1^4-y3) > print I > R. = 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: intersection of two lines
I have code that defines a line segment as a point and a vector. So for line pq, I compute point q from l.p and l.v when necessary. I also refer to x and y coords eg. (p.x+q.x, p.y+q.y) So I've wrapped line2d and point2d from sage using them as __repr__ in my new class and I'm wondering if this is going to work and if it will impact performance. class Line2: __slots__ = ['p', 'v'] def __init__(self, p, v): self.p = p self.v = v def __repr__(self): return line2d([self.p, (self.p+self.v)], thickness=1, color="black") -- 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 points of circles - irritating
fixed at http://trac.sagemath.org/sage_trac/ticket/8487 R.M. On 9 bře, 05:26, Markus wrote: > Hi, > > when trying to compute the intersection points of 2 circles i got > strange results. > > Example 1: > > c1(x,y)=(x-5)^2+y^2-25; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the expected result: > > [[x == (45/17), y == (75/17)], [x == 0, y == 0]] > > Example 2: > (circle 1 smaller) > > c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the unexpected result: > > [] > > whereas intersection points do exist, e.g. > x=(-9(sqrt(55)-15)/68, y=(-3(sqrt(55)-41)/68 > > Is it because Example 1 has a rational result, whereas Examples 2 has > an irrational one? > > Thanks for any help. > > Markus -- 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 points of circles - irritating
I got the following message from Andrej Vodopivec: You can solve this system in maxima with to_poly_solve: (%i2) to_poly_solve([(x-5)^2+y^2-16, (y-3)^2+x^2-9], [x,y], use_grobner=true); (%o2) %union([x=-(9*sqrt(55)-135)/68,y=-(3*5^(3/2)*sqrt(11)-123)/68], [x=(9*sqrt(55)+135)/68,y=(3*5^(3/2)*sqrt(11)+123)/68]) HTH, Andrej On 9 bře, 12:02, "ma...@mendelu.cz" wrote: > No, it is because Maxima (which solves equations for Sage) cannot > solve this system. My suggestions: > > 1. (better but long term) - improve Maxima's solver > > 2. (shorter) - help Maxima and write your simstem in simpler form like > this > > sage: x,y=var('x y') > sage: c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 > sage: c2b(x,y) = expand(c2(x,y)-c1(x,y)) > sage: solve([c1(x,y)==0,c2b(x,y)==0],[x,y]) > [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(5)*sqrt(11) + > 123/68], [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(5)*sqrt(11) + > 123/68]] > > And we can doublecheck the answer > > sage: sol=_ > sage: c1(sol[0][0].rhs(),sol[0][1].rhs()).expand().simplify_full() > 0 > sage: c2(sol[0][0].rhs(),sol[0][1].rhs()).expand().simplify_full() > 0 > sage: c1(sol[1][0].rhs(),sol[1][1].rhs()).expand().simplify_full() > 0 > sage: c2(sol[1][0].rhs(),sol[1][1].rhs()).expand().simplify_full() > 0 > > Robert > > On 9 bře, 05:26, Markus wrote: > > > Hi, > > > when trying to compute the intersection points of 2 circles i got > > strange results. > > > Example 1: > > > c1(x,y)=(x-5)^2+y^2-25; c2(x,y)=(y-3)^2+x^2-9 > > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > > produces the expected result: > > > [[x == (45/17), y == (75/17)], [x == 0, y == 0]] > > > Example 2: > > (circle 1 smaller) > > > c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 > > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > > produces the unexpected result: > > > [] > > > whereas intersection points do exist, e.g. > > x=(-9(sqrt(55)-15)/68, y=(-3(sqrt(55)-41)/68 > > > Is it because Example 1 has a rational result, whereas Examples 2 has > > an irrational one? > > > Thanks for any help. > > > Markus -- 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 points of circles - irritating
No, it is because Maxima (which solves equations for Sage) cannot solve this system. My suggestions: 1. (better but long term) - improve Maxima's solver 2. (shorter) - help Maxima and write your simstem in simpler form like this sage: x,y=var('x y') sage: c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 sage: c2b(x,y) = expand(c2(x,y)-c1(x,y)) sage: solve([c1(x,y)==0,c2b(x,y)==0],[x,y]) [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(5)*sqrt(11) + 123/68], [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(5)*sqrt(11) + 123/68]] And we can doublecheck the answer sage: sol=_ sage: c1(sol[0][0].rhs(),sol[0][1].rhs()).expand().simplify_full() 0 sage: c2(sol[0][0].rhs(),sol[0][1].rhs()).expand().simplify_full() 0 sage: c1(sol[1][0].rhs(),sol[1][1].rhs()).expand().simplify_full() 0 sage: c2(sol[1][0].rhs(),sol[1][1].rhs()).expand().simplify_full() 0 Robert On 9 bře, 05:26, Markus wrote: > Hi, > > when trying to compute the intersection points of 2 circles i got > strange results. > > Example 1: > > c1(x,y)=(x-5)^2+y^2-25; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the expected result: > > [[x == (45/17), y == (75/17)], [x == 0, y == 0]] > > Example 2: > (circle 1 smaller) > > c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the unexpected result: > > [] > > whereas intersection points do exist, e.g. > x=(-9(sqrt(55)-15)/68, y=(-3(sqrt(55)-41)/68 > > Is it because Example 1 has a rational result, whereas Examples 2 has > an irrational one? > > Thanks for any help. > > Markus -- 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 points of circles - irritating
One alternative is to use the optional package phcpack. You have to install that ("sage -i phc-2.3.53.p0") and then you could do something like: sage: from sage.interfaces.phc import phc sage: R. = PolynomialRing(CDF,2) sage: sols = phc.blackbox([(x-5)^2+y^2-16, (y-3)^2+x^2-9],R) sage: sols = sols.classified_solution_dicts() sage: sols['real'] [{y: 0.172897392552427, x: 1.00373843553146}, {y: 3.44474966627110, x: 2.96684979976266}] -M. Hampton On Mar 8, 10:26 pm, Markus wrote: > Hi, > > when trying to compute the intersection points of 2 circles i got > strange results. > > Example 1: > > c1(x,y)=(x-5)^2+y^2-25; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the expected result: > > [[x == (45/17), y == (75/17)], [x == 0, y == 0]] > > Example 2: > (circle 1 smaller) > > c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 > solve([c1(x,y)==0,c2(x,y)==0],x,y) > > produces the unexpected result: > > [] > > whereas intersection points do exist, e.g. > x=(-9(sqrt(55)-15)/68, y=(-3(sqrt(55)-41)/68 > > Is it because Example 1 has a rational result, whereas Examples 2 has > an irrational one? > > Thanks for any help. > > Markus -- 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 points of circles - irritating
On 9 bře, 14:57, "ma...@mendelu.cz" wrote: > I got the following message from Andrej Vodopivec: > > You can solve this system in maxima with to_poly_solve: > > (%i2) to_poly_solve([(x-5)^2+y^2-16, (y-3)^2+x^2-9], [x,y], > use_grobner=true); > (%o2) %union([x=-(9*sqrt(55)-135)/68,y=-(3*5^(3/2)*sqrt(11)-123)/68], > [x=(9*sqrt(55)+135)/68,y=(3*5^(3/2)*sqrt(11)+123)/68]) > > HTH, Andrej And this is Andrej's solution in Sage Andrej, many thanks for pointing to use_grobner. R. -- | Sage Version 4.3.3, Release Date: 2010-02-21 | | Type notebook() for the GUI, and license() for information.| -- sage: x,y=var('x y') sage: c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9 sage: M=c1._maxima_().parent() sage: M.to_poly_solve([c1,c2],[x,y],'use_grobner=true').sage() [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(5)*sqrt(11) + 123/68], [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(5)*sqrt(11) + 123/68]] sage: -- 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