Mathematica/Magma/Sage dictionaries ?

120 views
Skip to first unread message

Nathann Cohen

unread,
Dec 13, 2011, 6:51:19 PM12/13/11
to Sage devel
Hello everybody !!!

I have been contacted by an enlightened colleague who planned to teach a bit of Sage at the local university, instead of Magma and Mathematica as it was formerly done. Now, enthusiasm is a wonderful thing that can achieve many things by itself, and for instance to the scary task of translating a semester's worth of Magma/Mathematica exercises and lecture notes into Sage ones.

But really.. Wouldn't it be much much easier if someone around here already knew of an index of equivalents between Mathematica/Sage or Magma/Sage ? :-)

With my thanks for your cumulated wisdom,

Nathann

Jason Grout

unread,
Dec 13, 2011, 7:15:45 PM12/13/11
to sage-...@googlegroups.com

Great idea. Tim Daly has long been asking people around here to
contribute to the Rosetta Stone [1].

Jason

[1] http://axiom-developer.org/axiom-website/rosetta.html or
http://www.univ-orleans.fr/EXT/ASTEX/astex/doc/en/rosetta/htmla/roseta.htm
-- I'm not sure where the original source is or how to add things to it.

Dan Drake

unread,
Dec 13, 2011, 7:36:39 PM12/13/11
to sage-...@googlegroups.com
On Wed, 14 Dec 2011 at 12:51AM +0100, Nathann Cohen wrote:
> I have been contacted by an enlightened colleague who planned to teach a
> bit of Sage at the local university, instead of Magma and Mathematica as it
> was formerly done. Now, enthusiasm is a wonderful thing that can achieve
> many things by itself, and for instance to the scary task of translating a
> semester's worth of Magma/Mathematica exercises and lecture notes into Sage
> ones.
>
> But really.. Wouldn't it be much much easier if someone around here already
> knew of an index of equivalents between Mathematica/Sage or Magma/Sage
> ? :-)

Such a document would be nice...but I remember when I decided to learn
emacs (after many years with vim). I found a couple such "dictionaries",
but ultimately they weren't that helpful. You just need to think a
little differently when using emacs rather than vim.

But as a starting point, such a document would be useful. Just make sure
to point people to a Python tutorial as well!

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc
Message has been deleted

John H Palmieri

unread,
Dec 13, 2011, 9:25:30 PM12/13/11
to sage-...@googlegroups.com

For a start, you could try looking at the files mathematica.py and magma.py (etc.) in SAGE_ROOT/devel/sage/sage/
interfaces/.  If you have a bunch of Mathematica code and want to convert it to Sage, it looks like you could try commands like

            sage: m = mathematica('Sin[Sqrt[1-x^2]] * (1 - Cos[1/x])^2')  # optional - mathematica
            sage: m.sage()                          # optional - mathematica
            (cos(1/x) - 1)^2*sin(sqrt(-x^2 + 1))

--
John

daly

unread,
Dec 14, 2011, 1:18:03 AM12/14/11
to sage-...@googlegroups.com

William Stein

unread,
Dec 14, 2011, 2:11:09 AM12/14/11
to sage-...@googlegroups.com
On Tue, Dec 13, 2011 at 4:36 PM, Dan Drake <dr...@kaist.edu> wrote:
> On Wed, 14 Dec 2011 at 12:51AM +0100, Nathann Cohen wrote:
>> I have been contacted by an enlightened colleague who planned to teach a
>> bit of Sage at the local university, instead of Magma and Mathematica as it
>> was formerly done. Now, enthusiasm is a wonderful thing that can achieve
>> many things by itself, and for instance to the scary task of translating a
>> semester's worth of Magma/Mathematica exercises and lecture notes into Sage
>> ones.
>>
>> But really.. Wouldn't it be much much easier if someone around here already
>> knew of an index of equivalents between Mathematica/Sage or Magma/Sage
>> ? :-)
>
> Such a document would be nice...but I remember when I decided to learn
> emacs (after many years with vim). I found a couple such "dictionaries",
> but ultimately they weren't that helpful. You just need to think a
> little differently when using emacs rather than vim.
>
> But as a starting point, such a document would be useful.

It would have the additional value of uncovering functionality that is
missing in Sage, but which should be there.

-- William

>
> Dan
>
> --
> ---  Dan Drake
> -----  http://mathsci.kaist.ac.kr/~drake
> -------

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Rajeev Singh

unread,
Dec 14, 2011, 2:58:46 AM12/14/11
to sage-...@googlegroups.com

Is it possible to run the above commands if I don't have mathematica?

Rajeev

kcrisman

unread,
Dec 14, 2011, 9:23:39 AM12/14/11
to sage-devel

> > For a start, you could try looking at the files mathematica.py and magma.py
> > (etc.) in SAGE_ROOT/devel/sage/sage/
> > interfaces/.  If you have a bunch of Mathematica code and want to convert it
> > to Sage, it looks like you could try commands like
>
> >             sage: m = mathematica('Sin[Sqrt[1-x^2]] * (1 - Cos[1/x])^2')  # optional - mathematica
> >             sage: m.sage()                          # optional - mathematica
> >             (cos(1/x) - 1)^2*sin(sqrt(-x^2 + 1))
>
> Is it possible to run the above commands if I don't have mathematica?

You can run them, but you'd get the following.

sage: m = mathematica('Sin[Sqrt[1-x^2]] * (1 - Cos[1/x])^2')

---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)

TypeError: Unable to start mathematica because the command 'math'
failed.

In order to use the Mathematica interface you need to have Mathematica
installed and have a script in your PATH called "math" that runs the
command-line version of Mathematica. Alternatively, you could use a
remote connection to a server running Mathematica -- for hints, type
print mathematica._install_hints_ssh()


(1) You might have to buy Mathematica (http://www.wolfram.com/).

(2) * LINUX: The math script comes standard with your Mathematica
install.

* APPLE OS X:
(a) create a file called math (in your PATH):
#!/bin/sh
/Applications/Mathematica\ 5.2.app/Contents/MacOS/
MathKernel $@

Note that the 5.2 part will depend on the version of
Mathematica you have, and the above path could be different
if you installed mathematica elsewhere.

(b) Make the file executable.
chmod +x math

* WINDOWS:

Install Mathematica for Linux into the VMware virtual machine
(sorry,
that's the only way at present).

However, if you have remote access to a machine with Mathematica
installed, you could do as above by installing Sage on it.

Could Rajeev even set the 'math' script on his home computer in such a
way that it called a remote installation of Mma? (Which probably
violates the user license, but just to know...)

Rajeev Singh

unread,
Dec 15, 2011, 12:34:13 AM12/15/11
to sage-...@googlegroups.com

Hi,

> However, if you have remote access to a machine with Mathematica
> installed, you could do as above by installing Sage on it.
>
> Could Rajeev even set the 'math' script on his home computer in such a
> way that it called a remote installation of Mma?  (Which probably
> violates the user license, but just to know...)

This is working on my Institute computer with access to Mathematica. I
was thinking about using it on my laptop while I am away from my
Institute. I think it is desirable that sage is able to translate a
piece of Mathematica code to Sage code even if one doesn't have
Mathematica.

Rajeev

kcrisman

unread,
Dec 15, 2011, 8:21:18 AM12/15/11
to sage-devel

>
> > However, if you have remote access to a machine with Mathematica
> > installed, you could do as above by installing Sage on it.
>
> > Could Rajeev even set the 'math' script on his home computer in such a
> > way that it called a remote installation of Mma?  (Which probably
> > violates the user license, but just to know...)
>
> This is working on my Institute computer with access to Mathematica. I
> was thinking about using it on my laptop while I am away from my
> Institute. I think it is desirable that sage is able to translate a
> piece of Mathematica code to Sage code even if one doesn't have
> Mathematica.

Actually, I think you *can* do that. You'd have to read the Mma
interface docs, but I don't see why this wouldn't be possible.

Reply all
Reply to author
Forward
0 new messages