Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Converting Polynomial Strings into Singular Polynomials
PostPosted: Thu Feb 28, 2019 5:26 pm 
I'm using Singular via Sage Math, and attempting to generate random polynomials and have Singular calculate their Milnor numbers. The issue arises when I attempt to convert polynomials generated by my algorithm into ones Singular recognizes, some get through successfully while others produce an error.

This is part of a larger piece of code, however this is the error producing step and the error can be replicated outside of the rest of the code. If seeing the rest of the code would be useful, I can provide it.

Working:

Code:
singular('-1s3-8g5-8g5')
singular('-5s5+9v5+9m8')
singular('-4p5+1l9+1l9')


Non-Working:

Code:
singular('+4j2-6a7-1e5')
singular('+7f7-7w5+1d8')


Error (When a Non-Working Polynomial is Entered):

Code:
sage: R = singular.ring(0,'(j,a,e)','ds')
sage: singular('+4j2-6a7-1e5')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-37-2b81feafe87b> in <module>()
----> 1 singular('+4j2-6a7-1e5')

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in __call__(self, x, type)
    796             x = str(x)[1:-1]
    797
--> 798         return SingularElement(self, type, x, False)
    799
    800     def _coerce_map_from_(self, S):

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in __init__(self, parent, type, value, is_name)
   1282             except SingularError as x:
   1283                 self._session_number = -1
-> 1284                 raise_(TypeError, TypeError(x), sys.exc_info()[2])
   1285             except BaseException:
   1286                 self._session_number = -1

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in __init__(self, parent, type, value, is_name)
   1277         if not is_name:
   1278             try:
-> 1279                 self._name = parent._create(value, type)
   1280             # Convert SingularError to TypeError for
   1281             # coercion to work properly.

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in _create(self, value, type)
    757         """
    758         name = self._next_var_name()
--> 759         self.set(type, name, value)
    760         return name
    761

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in set(self, type, name, value)
    700         cmd += '%s %s=%s;'%(type, name, value)
    701         self.__to_clear = []
--> 702         self.eval(cmd)
    703
    704     def get(self, var):

/Applications/SageMath-8.6.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.pyc in eval(self, x, allow_semicolon, strip, **kwds)
    658         # Singular actually does use that string
    659         if s.find("error occurred") != -1 or s.find("Segment fault") != -1:
--> 660             raise SingularError('Singular error:\n%s'%s)
    661
    662         if get_verbose() > 0:

TypeError: Singular error:
   ? error occurred in or before STDIN line 68: ``
   ? last reserved name was `def`
   skipping text from `4j2`


I am using the Sage Interpreter Interfaces Interface to Singular¶ documentation page.
(I can't link to it due to low karma, sorry!)


Report this post
Top
  
Reply with quote  
 Post subject: Re: Converting Polynomial Strings into Singular Polynomials
PostPosted: Thu Feb 28, 2019 11:41 pm 
This issue was fixed by moving the first term of the polynomial to the end of the polynomial.


Report this post
Top
  
Reply with quote  
 Post subject: Re: Converting Polynomial Strings into Singular Polynomials
PostPosted: Fri Mar 01, 2019 11:40 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
The reason:
Singular has a unary -, but no unary +.
Therefore
Code:
-2x5
is a valid polynomial,
while
Code:
+2x5
is not.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:56 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group