Hi Felix,

On Sat, Aug 15, 2009 at 11:06 PM, thelamecamel<[email protected]> wrote:
>
> Hi Viny,
>
> The following works for me:
>
> 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 e.g. 6.05*^3 ==> 6.05e3
>    string = string.replace('*^', 'e')
>    # 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})
>    return sage_stuff
>
> sage: var('E')
> sage: var('x')
> sage: var('y')
> sage: mma_list = mathematica("{((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)}")
> sage: arr = mmatosage(mma_list)
> sage: print arr
> [(E^(x^2) + 1)*x/(2*E^(x^2)*x^2 + E^(x^2) + 1), (E^(y^2) - 1)*y/(2*E^
> (y^2)*y^2 + E^(y^2) - 1)]
> sage: print "1st element:", arr[0]
> 1st element: (E^(x^2) + 1)*x/(2*E^(x^2)*x^2 + E^(x^2) + 1)
>
> This seems to do what you want.  It seems to be the best way to import
> symbolics from mathematica.  I hope that Sage will eventually do the
> var() and locals={} bits automatically when you call mma_list.sage(),
> but in the meantime we can do it the dirty way.
>
> I'd be happy to help out with the implementation of this method, but
> I've only ever hacked together my code, and so don't really know
> anything about how to contribute.

Thank you for considering to contribute to Sage. There are a number of
people working on the symbolics aspect of Sage. People who come to my
mind are Burcin Erocal and Golam Mortuza Hossain. The Developers'
Guide is a handy reference for contributors/developers:

http://www.sagemath.org/doc/developer/index.html

If there is anything else you would like to know, don't hesitate to
ask on the sage-devel or sage-support mailing lists.

-- 
Regards
Minh Van Nguyen

--~--~---------~--~----~------------~-------~--~----~
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