Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

field extensions in python

You can define a field extenion at the sage prompt with

QC.<j> = QQ.extension(x^2+1)

however this same line in a python script yields a syntax error

def mytest(): QC.<j> = QQ.extension(x^2+1); return

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_51.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZGVmIG15dGVzdCgpOiBRQy48aj4gPSBRUS5leHRlbnNpb24oeF4yKzEpOyByZXR1cm4="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpZb9Kh9/___code___.py", line 3 def mytest(): QC.<j> = QQ.extension(x**_sage_const_2 +_sage_const_1 ); return ^ SyntaxError: invalid syntax

Note:syntax error point to < character

eval also fails

eval('QC.<j> = QQ.extension(x^2+1)')

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_53.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXZhbCgnUUMuPGo+ID0gUVEuZXh0ZW5zaW9uKHheMisxKScp"),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpGvzU29/___code___.py", line 2, in <module> exec compile(u"eval('QC.<j> = QQ.extension(x^2+1)')" + '\n', '', 'single') File "", line 1, in <module>

File "<string>", line 1 QC.<j> = QQ.extension(x^2+1) ^ SyntaxError: invalid syntax

I also have similar problems with defining Quaternion Algebras in python HQ.<q1,q2,q3> = QuaternionAlgebra(QC,-1,-1)

so why does QC.<j> = QQ.extension(x^2+1) work at the sage prompt and not in python or with eval(string)

Thanks, Steve

field extensions in python

You can define a field extenion at the sage prompt with

QC.<j> = QQ.extension(x^2+1)

QC.<j>; = QQ.extension(x^2+1)

however this same line in a python script yields a syntax error

def mytest(): 
    QC.<j> = QQ.extension(x^2+1);
    return

return Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_51.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZGVmIG15dGVzdCgpOiBRQy48aj4gPSBRUS5leHRlbnNpb24oeF4yKzEpOyByZXR1cm4="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpZb9Kh9/___code___.py", line 3 ... def mytest(): QC.<j> = QQ.extension(x**_sage_const_2 +_sage_const_1 ); return ^ SyntaxError: invalid syntax

syntax

Note:syntax error point to < character

eval also fails

eval('QC.<j> = QQ.extension(x^2+1)')

eval('QC.&lt;j&gt; = QQ.extension(x^2+1)')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_53.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXZhbCgnUUMuPGo+ID0gUVEuZXh0ZW5zaW9uKHheMisxKScp"),globals())+"\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

File "/tmp/tmpGvzU29/___code___.py", line 2, in <module> exec compile(u"eval('QC.<j> = QQ.extension(x^2+1)')" + '\n', '', 'single') File "", line 1, in <module>

File "<string>", line 1 .... QC.<j> = QQ.extension(x^2+1) ^ SyntaxError: invalid syntax

syntax

I also have similar problems with defining Quaternion Algebras in python python

HQ.<q1,q2,q3> = QuaternionAlgebra(QC,-1,-1)  

QuaternionAlgebra(QC,-1,-1)

so why does QC.<j> = QQ.extension(x^2+1) work at the sage prompt and not in python or with eval(string)

Thanks, Steve

click to hide/show revision 3
retagged

field extensions in python

You can define a field extenion at the sage prompt with

QC.<j>; = QQ.extension(x^2+1)

however this same line in a python script yields a syntax error

def mytest(): 
    QC.<j> = QQ.extension(x^2+1);
    return

Traceback (most recent call last):
...
def mytest(): QC.<j> = QQ.extension(x**_sage_const_2 +_sage_const_1 ); return
                 ^
SyntaxError: invalid syntax

Note:syntax error point to < character

eval also fails

eval('QC.&lt;j&gt; = QQ.extension(x^2+1)')

Traceback (most recent call last):
....    
QC.<j> = QQ.extension(x^2+1)
   ^
SyntaxError: invalid syntax

I also have similar problems with defining Quaternion Algebras in python

HQ.<q1,q2,q3> = QuaternionAlgebra(QC,-1,-1)

so why does QC.<j> = QQ.extension(x^2+1) work at the sage prompt and not in python or with eval(string)

Thanks, Steve