19
$\begingroup$

Is there a simple way to copy mathematical expressions between Mathematica and Maple (or at least in one direction)? I mean only expressions built from numbers and predefined mathematical functions, whithout any patterns or programmatical constructs like Function, Map or Nest.

Ideally, I want functions with different definitions to be automatically adjusted, for example the Mathematica expression EllipticF[Pi/6, 1/4] should be converted to the Maple expression EllipticF(1/2, 1/2).

$\endgroup$
1
  • 1
    $\begingroup$ it may well be that other solutions will work much better but I think for this question one should at least mention MathML, which (in its content markup version) is the official standard aiming to make exactly such exchange between programs more easy. Have you tried that (copy/paste or import/export as MathML)? I probably should note that my own experience with MathML is limited and I 'd expect problems when using it in practice, but probably it's worth a try. And both companies were involved in the specification so you could well ask for official support if something won't work :-) $\endgroup$ Sep 7, 2013 at 10:28

4 Answers 4

26
$\begingroup$

I assume you have Maple to use. If so, Simply open Maple and type the Mathematica command itself directly into Maple using the FromMma package built-into Maple, like this:

restart; 
with(MmaTranslator); #load the package
(*[FromMma, FromMmaNotebook, Mma, MmaToMaple]*)

and now can use it

FromMma(`Integrate[Cos[x],x]`);

Mathematica graphics

One can also use Maple convert command with the FromMma option, like this:

convert(`Integrate[Cos[x],x]`, FromMma);

Mathematica graphics

For your example:

FromMma(`EllipticF[Pi/6, 1/4]`);

Mathematica graphics

You can also use a Mathematica computational expression, not just single commands, like this, and then use the resulting Maple command inside Maple:

r:=convert(`Table[i,{i,10}];`, FromMma);
(* r := [seq(i, i = 1 .. 10)] *)

Now run the result in Maple:

r;
(*[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]*)

see http://www.maplesoft.com/support/help/Maple/view.aspx?path=MmaTranslator for information on the MmaTranslator package.

For translating Maple back to Mathematica: The only program I know about that converts Maple to Mathematica is http://library.wolfram.com/infocenter/Conferences/5397

From Maple 9 Worksheets to Mathematica Notebooks

by Yves Papegay. However, I can't find the actual program or the software. You can try to contact the author on this. This was from The 2004 Wolfram Technology Conference.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much! Your answer helped me a lot. Do you by any chance know how to convert Maple expressions back to Mathematica? $\endgroup$ Sep 6, 2013 at 23:17
16
$\begingroup$

You can open a whole Mathematica notebook in Maple using its Open... menu, and all expressions in the notebook will be converted to Maple representation:

Open Menu in Maple

$\endgroup$
12
$\begingroup$

Convert Maple expressions to Mathematica:

Through latex: enter image description here enter image description here

Through free form input:

enter image description here enter image description here

$\endgroup$
4
$\begingroup$

There is actually a dedicated (yet outdated) package for converting Maple code to Mathematica: MapleConverter by L. Hohmuth

https://library.wolfram.com/infocenter/Demos/188

Recently I got in touch with Mr. Hohmuth and WRI and after some friendly e-mail exchange they kindly agreed to relicense the code under the MIT license

https://library.wolfram.com/infocenter/Demos/188/Readme.txt

Licensing

Copyright 2020 Wolfram Research, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Notice that the code is very much outdated and doesn't enjoy any support from the WRI side, but since it is open source now, nothing prevents us from forking it and adding various improvements. At least this is something I'm planning to do. However, I'm more interested in parsing single expressions and not whole worksheets.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.