ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 14 Jul 2020 10:00:35 +0200One point from infinity varietyhttps://ask.sagemath.org/question/52460/one-point-from-infinity-variety/ Given an ideal, I want to compute a non-zero point in the variety of that ideal. This can be done with `.variety()` if the ideal has 0-dimension. How can I get a non-zero point in the variety if the ideal is not 0-dimensional?
Example:
R.<x,y> = PolynomialRing(QQ)
I = R.ideal([x^2-y^2])
I.variety()
yields an error. How can I get a point like (1,1) which lies in the variety?
Thanks!philipp7Tue, 14 Jul 2020 10:00:35 +0200https://ask.sagemath.org/question/52460/Find solution to Polynomial Sequences without going through varietyhttps://ask.sagemath.org/question/47357/find-solution-to-polynomial-sequences-without-going-through-variety/Hi everyone,
I'm computing the Groebner basis of an ideal defined over the QQ ring. Once I have this Groebner basis, I would like to obtain a set of values that satisfy the equations in the Groebner basis. I know that the full set is going to be the variety of the ideal, but since this object is huge, I might not be interested in finding those values.
In Maple, after computing the Groebner basis, I'm able to call the solve() method on it and even set a maximum number of solutions I want to obtain. As a small example:
P.<x,y,z,t>=PolynomialRing(QQ,4)
I = P.ideal(x*(x-1), y*(y-1), z*(z-1), t - x*y*z)
gb = I.groebner_basis()
Here I could have called `I.variety()` or `gb.variety()` and obtained the same set of solutions:
sage: gbI.variety()
[{y: 0, z: 0, t: 0, x: 0},
{y: 0, z: 0, t: 0, x: 1},
{y: 1, z: 0, t: 0, x: 0},
{y: 1, z: 0, t: 0, x: 1},
{y: 0, z: 1, t: 0, x: 0},
{y: 0, z: 1, t: 0, x: 1},
{y: 1, z: 1, t: 0, x: 0},
{y: 1, z: 1, t: 1, x: 1}]
But I would like to know if it is possible to call a method like (I can do this in Maple):
solve(gb,[max_sol=2])
Such that I can obtain a subset of the variety instead of the whole set. My motivation is that the size of the initial system of polynomials that I have is considerably larger than this example, and finding the feasible solutions on the reduced Groebner basis is more manageable. I might also not be interested in all the elements in the variety. Finally, if I transform the Groebner basis in an ideal itself and try to compute the variety on that object
gbI = ideal(gb)
gbI.variety()
I find the following error
RuntimeError: error in Singular function call 'groebner':
int overflow in hilb 3
error occurred in or before standard.lib::stdhilb line 299: ` intvec hi = hilb( Id(1),1,W );`
expected intvec-expression. type 'help intvec;'
leaving standard.lib::stdhilb
leaving standard.lib::groebner
bernaldeSat, 03 Aug 2019 03:27:39 +0200https://ask.sagemath.org/question/47357/Ideal.variety() when working with symbolic ringshttps://ask.sagemath.org/question/43873/idealvariety-when-working-with-symbolic-rings/I have a system of multivariate polynomials I would like to solve (the equations come from chemical reaction networks). I have many symbolic constants, but I've managed to generate a Groebner basis with the following code (using a toy example with solutions {{x: x0, y:0},{x: 0,y: x0}):
x0 = var('x0') # In practice, there are many constants
S.<x,y> = PolynomialRing(SR,order='lex'); # in practice, there are 3-10 variables
I = S.ideal(
x**2 + y**2 - x0**2,
x + y - x0
)
print(I.dimension()) # dimension should always be zero
# >> 0
print(I.groebner_basis())
# >> [x + y - x0,
# >> y^2 + (-x0)*y]
In practice, I get many resulting equations which are extremely long, and it is numerically challenging to sequentially find the roots of these polynomials (in downstream code, I will get values for the constant parameters and then need to return solutions to these equations on the fly). Using the `I.variety()` method would be great to symbolically isolate all possible solutions, but I get confusing internal errors when I try to evaluate it.
print(I.variety()) # should be equivalent to: I.variety(ring=SR)
#/Users/ksb/SageMath/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in _variety(T, V, v)
# 2340
# 2341 variable = f.variable(0)
#-> 2342 roots = f.univariate_polynomial().roots(ring=ring, multiplicities=False)
# 2343
# 2344 for root in roots:
#
#/Users/ksb/SageMath/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_element.pyx in sage.rings.polynomial.polynomial_element.Polynomial.roots (build/cythonized/sage/rings/polynomial/polynomial_element.c:68811)()
# 7714 return l
# 7715 else:
#-> 7716 return [val for val,m in l]
# 7717 vname = 'do_not_use_this_name_in_a_polynomial_coefficient'
# 7718 var = SR(vname)
# TypeError: 'sage.symbolic.expression.Expression' object is not iterable
Is this expected behavior? When I try `f.univariate_polynomial().roots(ring=ring, multiplicities=False)` (setting `multiplicities=True` is what `I.variety()` does and leads to the error) I get `[1/2*x0,2]` for roots, which makes little sense (it seems like the roots should be `[0,-x0]`).
I would be happy to convert the `MPolynomial_polydict` (or the `sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category.element_class` generated by `univariate_polynomial()`) into a symbolic expression that I could just set it equal to zero and use `solve` on it, but I don't know how to do this type conversion. ksbMon, 08 Oct 2018 19:41:03 +0200https://ask.sagemath.org/question/43873/