Ask Your Question
1

PowerSeriesRing Not Accepting QuotientRing [closed]

asked 2022-06-21 00:36:51 +0100

MarsK gravatar image

Hi,

I'm simply trying to define a power series ring on a quotient ring in python as shown below

var('x w y z t')
P = PolynomialRing(CC,'x, w, y, z')
I = P.ideal(x*w-1, y*z-1)
R = P.quotient_ring(I)
S = PowerSeriesRing(R, 't')

All of it works up until initializing S, at which point I get the following (very long) error message (note: I changed the path address to the python file to "Path/to/test.py" in the error message below, but everything else is unchanged):

Traceback (most recent call last):
  File "sage/misc/cachefunc.pyx", line 996, in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:5974)
  File "sage/misc/weak_dict.pyx", line 704, in sage.misc.weak_dict.WeakValueDictionary.__getitem__ (build/cythonized/sage/misc/weak_dict.c:3736)
KeyError: ((<class 'sage.rings.power_series_ring.PowerSeriesRing_generic'>, Quotient of Multivariate Polynomial Ring in x, w, y, z over Complex Field with 53 bits of precision by the ideal (x*w - 1.00000000000000, y*z - 1.00000000000000), 't', 20), (('implementation', None), ('sparse', False)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sage/misc/cachefunc.pyx", line 1943, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10303)
KeyError: ((False,), ())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sage/misc/cachefunc.pyx", line 1943, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10303)
KeyError: (('sy',), ())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Path/to/test.py", line 7, in <module>
    S = PowerSeriesRing(R, 't')
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/power_series_ring.py", line 417, in PowerSeriesRing
    sparse=sparse, implementation=implementation)
  File "sage/misc/classcall_metaclass.pyx", line 322, in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1761)
  File "sage/misc/cachefunc.pyx", line 1001, in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:6100)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/structure/unique_representation.py", line 1007, in __classcall__
instance = typecall(cls, *args, **options)
  File "sage/misc/classcall_metaclass.pyx", line 486, in sage.misc.classcall_metaclass.typecall (build/cythonized/sage/misc/classcall_metaclass.c:2223)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/power_series_ring.py", line 546, in __init__
    R = PolynomialRing(base_ring, name, sparse=sparse)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 649, in PolynomialRing
    return _single_variate(base_ring, names, **kwds)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 731, in _single_variate
    elif base_ring.is_integral_domain(proof=False):
  File "sage/misc/cachefunc.pyx", line 1948, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10437)
  File "sage/misc/cachefunc.pyx", line 1824, in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:9916)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/quotient_ring.py", line 864, in is_integral_domain
    return self.defining_ideal().is_prime()
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 952, in is_prime
    CPD = self.complete_primary_decomposition(**kwds)
  File "sage/misc/cachefunc.pyx", line 1948, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:10437)
  File "sage/misc/cachefunc.pyx", line 1824, in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:9916)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/libs/singular/standard_options.py", line 141, in wrapper
    return func(*args, **kwds)
  File "/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py", line 768, in complete_primary_decomposition
    P = primdecSY(self)
  File "sage/libs/singular/function.pyx", line 1333, in sage.libs.singular.function.SingularFunction.__call__ (build/cythonized/sage/libs/singular/function.cpp:15181)
TypeError: Cannot call Singular function 'primdecSY' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>'

I have no idea how to analyze this, the ring R is of course commutative, so in theory there should be no problems initizializing S. PowerSeriesRing works with easier rings like ZZ.quotient_ring(ZZ*5), so I'm guessing it has something to do with conflicting precisions between the PowerSeriesRing and the base_ring? But I don't know how to change that, I'd appreciate any help or direction on figuring out how I can get a power series ring from R.

Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Max Alekseyev
close date 2023-09-22 19:30:44.609887

Comments

At very least you mix up symbolic and polynomial variables. Replace var('x w y z t') with P.inject_variables()

Max Alekseyev gravatar imageMax Alekseyev ( 2022-06-21 11:55:30 +0100 )edit

Thanks for the reply Max, I've fixed that but I still get the same exact error message.

MarsK gravatar imageMarsK ( 2022-06-21 20:04:18 +0100 )edit

It looks like a bug. The error is produced by the following if:

/home/sc_serv/sage/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/libs/singular/function.pyx in sage.libs.singular.function.SingularFunction.__call__ (build/cythonized/sage/libs/singular/function.cpp:15301)()
   1331                 ring = dummy_ring
   1332         if not (isinstance(ring, MPolynomialRing_libsingular) or isinstance(ring, NCPolynomialRing_plural)):
-> 1333             raise TypeError("Cannot call Singular function '%s' with ring parameter of type '%s'"%(self._name,type(ring)))
   1334         return call_function(self, args, ring, interruptible, attributes)

You may try to comment it out to see if it's just a missing clause.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-06-21 23:02:11 +0100 )edit

Hi Max, I've struggled for a long time to compile the modified function.pyx file to no avail; is there a way to use sage to compile it? I've tried using "sage -b function.pyx" in the sage shell but I get errors like "/opt/sagemath-9.3/build/pkgs/sagelib/spkg-install: line 5: cd: src: No such file or directory" In general, I'd much appreciate a link or some basic outline of how I should go about this. Many thanks.

MarsK gravatar imageMarsK ( 2022-06-22 08:04:41 +0100 )edit

Alright, so I've managed to circumvent this situation entirely by simply writing

P = LaurentPolynomialRing(CC,'x, y')
S = PowerSeriesRing(P, 't')

I don't know what's wrong with the original code, but this works well enough.

MarsK gravatar imageMarsK ( 2022-06-22 08:56:44 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-06-27 16:16:48 +0100

dan_fulea gravatar image

Usually, in such situation i'm doing the following:

P.<x, w,winv, y, z,zinv> = PolynomialRing(QQ)
J = P.ideal([x*winv, y*zinv, w*winv - 1, z*zinv -1])
R = P.quotient_ring(J)
S.<t> = PowerSeriesRing(R)

In words, always introduce a variable for the inverse of some given variable.

Always arrange to have a polynomial ring having the variables (names and used variables) that i want. It is not enough to assing the names, you also have to inject them.

Note that there is a clear distinction between "variables" as initialized by var:

sage: var('x');
sage: type(x)
<class 'sage.symbolic.expression.Expression'>

and "variables" as used as transcendental generators of some polynomial ring:

sage: R.<x> = PolynomialRing(QQ)
sage: type(x)
<class 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>

Things are tricky to digest, when we type...

sage: var('x');
sage: R = PolynomialRing(QQ, names='x')

and now comes the question: What is $x$ now...?! It turns out that the $x$ is the reminiscent global variable from var('x'):

sage: type(x)
<class 'sage.symbolic.expression.Expression'>

Why? The reason is that we have introduced R, it has a transcendent variable, the name for it is x, but we can only access this variable using the generators of R so far. To have access to "the polynomial variable $x$", we have to inject variables:

sage: var('x');
sage: R = PolynomialRing(QQ, names='x')
sage: R.inject_variables()
Defining x
sage: type(x)
<class 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>

That message shown by the sage interpreter, Defining x, is the needed message.

Alternatively, use the preparsed definition:

R.<x>  = PolynomialRing(QQ)

to arrange for both, setting the names of $R$ - as they are shown in prints, and using the global variable with same name.

edit flag offensive delete link more

Comments

If you introduce an inverse for each variable, then it's more natural to use LaurentPolynomialRing upfront.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-06-27 17:06:20 +0100 )edit

Question Tools

Stats

Asked: 2022-06-21 00:36:51 +0100

Seen: 625 times

Last updated: Jun 27 '22