Hello everybody!

Thanks for your help.
 I'm realizing that i'm definitely really bad in sage, perhaps i'll be
best in another life!!lol!
This is a piece of a code for changing a symbolic mathematica list
expression to a sage list expression:

def mmatosage(mma_list):
    # Convert the mathematica object to a string
    string = repr(mma_list)
    # Convert mathematica-style {} to python style []
    string = string.replace('{','[').replace('}',']')
    # Replace mathematica's crazy exponent notation with the standard
one
    string = string.replace('^', '**')
    # Delete new lines (both \n and \r\n appear sporadically)
    string = string.replace('\n', ' ').replace('\r', ' ')
    sage_stuff = sage_eval(string,locals =
{'E':'E','x':'x','y':'y'},preparse=False,)
    return sage_stuff

I get the folowing error when I apply it to this mathematica
expression {((1 + E^x^2)*x)/(1 + E^x^2 + 2*E^x^2*x^2),
 ((-1 + E^y^2)*y)/(-1 + E^y^2 + 2*E^y^2*y^2)}

---> 41     sage_stuff = sage_eval(string,locals =
{'E':'E','x':'x','y':'y'},preparse=False)
     42     return sage_stuff

/usr/local/src/sage-4.0.2/local/lib/python2.5/site-packages/sage/misc/
sage_eval.pyc in sage_eval(source, locals, cmds, preparse)
    197         return locals['_sage_eval_returnval_']
    198     else:
--> 199         return eval(source, sage.all.__dict__, locals)
    200
    201

/usr/local/src/sage-4.0.2/local/lib/python2.5/site-packages/sage/
all.pyc in <module>()

TypeError: unsupported operand type(s) for ** or pow(): 'str' and
'int'

I have any idea.

Thankx for your help!

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to