130
$\begingroup$

I've seen questions before such as "What is the best open-source equivalent for Mathematica?", but that specific question (and that line of inquiry in general) cares more about the computer algebra system and less about the core language and its unique and powerful features.

My interest in Mathematica come from a slightly different angle--namely, I find a tremendous amount of value in the power and flexibility of the language that Mathematica implements (I think of it as a slightly less scary looking syntax for Lisp with some very novel additions such as the powerful pattern matching system).

Are there any projects that have made a concerted effort to build a Mathematica-the-language work-alike instead of focusing on the Computer Algebra System?

Mathics is the closest project I've found so far (since it does, in fact, try to stay faithful to Mathematica syntax where it can), but even it pitches itself as a computer algebra system. And it was written in Python, which isn't bad by itself, but it sets itself up to not be as fast as Mathematica for computationally intensive tasks.

It seems to me that Wolfram Research would actually benefit tremendously from having an even bigger programmer community around Mathematica as a language and developer platform, because more packages would be produced to solve more off-the-shelf programming problems (just like almost any other programming language).

An open (or at least freely available) implementation of the core programming language wouldn't even dilute their secret sauce which I would say primarily lies in Mathematica's base of mathematical rules and algorithms, in the scientific computing tools that they've bundled into one enormous and broad package, and into the insanely well-integrated notebook experience that they should have no trouble keeping ahead of any kind of open source project.

$\endgroup$
13
  • 18
    $\begingroup$ "Nope" is perhaps too short an answer for such a long question. But nonetheless is true. $\endgroup$ Apr 19, 2012 at 4:29
  • 4
    $\begingroup$ It feels almost like flamebait on this site, but it's worth mentioning anyways, at the very least for future googlers: you may also want to look into Octave, the open-source equivalent to Matlab's language. $\endgroup$ Apr 19, 2012 at 10:00
  • 26
    $\begingroup$ @BlueRaja-DannyPflughoeft The question was asked specifically about Mathematica, which is sufficiently different from Matlab to make your comment of no relevance here, particularly given the context of the question. $\endgroup$ Apr 19, 2012 at 11:01
  • 8
    $\begingroup$ @sblom, you may find this interesting. In the first few paragraphs Stephen talks about a more freely available pure language aspect of Mathematica. $\endgroup$
    – user21
    Apr 19, 2012 at 11:24
  • 8
    $\begingroup$ @GeorgeWolfe, I think it's more like a generic than a counterfeit. And inexpensive or not, the price tag even for the Home Edition (which I own) is high enough to disqualify Mathematica from participation in programming competitions like Google Code Jam. I really want to see a day where Mathematica has as rich of an ecosystem of shared packages as MATLAB has, and I believe that a free clone is very possibly part of the equation. $\endgroup$
    – sblom
    Oct 9, 2012 at 3:56

3 Answers 3

94
$\begingroup$

I've been collecting these links for a while, so this question is a good excuse for a link dump. I'm not sure which project is the "best", but I think that mathics and symja are two of the more active and developed projects.

Lisp:
MockMMA is probably the first implementation of the Mathematica language. It was written by Richard Fateman who had a bit of a scuffle with Wolfram Research over the code.

Python:
Mathics (which you mentioned in the question) is primarily a syntax layer ontop of sympy and sage, not an independent implementation of the Mathematica language.
Pythonica is an abandoned python implementation of Mathematica.

Java:
symja is a pure Java library for symbolic mathematics that uses Mathematica notation and supports Rubi Integration rules.
omath is an project that is still under development that will have a Mathematica like syntax, but does not aim to blindly copy Mathematica.

Go:

expreduce an experimental computer algebra system written in Go.


The omath page also has some interesting links to papers describing some of the Mathematica language's algorithms:
Matching in flat theories by Temur Kutsia. A detailed description of Mathematica's flat pattern matching. (But quite technical!) (original link)

Mathematica as a Rewrite Language by Bruno Buchberger.

On the implementation of a rule-based programming system and some of its applications by Mircea Marin and Temur Kutsia. These people obviously understand Mathematica's pattern matching enumeration system forwards and backwards.

Discussions about whether computer languages can be copyrighted, 1, 2, 3.

$\endgroup$
5
  • $\begingroup$ Fixed the broken links - the RISC site is really handy for references! Some good packages (some of which I've played with) and notes are also on that site. $\endgroup$
    – Simon
    Apr 19, 2012 at 6:18
  • 4
    $\begingroup$ you might be interested in Roman Maeder's papers on AlgBench. $\endgroup$
    – user21
    Apr 19, 2012 at 11:28
  • $\begingroup$ Now what is the best supported? It doesn't really say that in the answer. Better yet do you mind posting some examples? $\endgroup$
    – William
    Sep 8, 2015 at 3:25
  • 1
    $\begingroup$ @Liam: Mathics and Symja are still active - but I don't know about best supported. Both have the same syntax as Mathematica (although they have not implemented all of the Wolfram Language) - so there is no need to post examples. Both also have a online demo that you can try $\endgroup$
    – Simon
    Jun 26, 2016 at 12:32
  • 1
    $\begingroup$ should "understand Mathematica's pattern matching enumeration system backwards" be "[...] backwards and forwards"? $\endgroup$
    – lirtosiast
    Aug 2, 2019 at 23:42
44
$\begingroup$

Yes.

According to Mathematica's creator, Stephen Wolfram, Mathematica is just an implementation of a language that as of 2013 has been named Wolfram

Two other implementations have been developed by a Kernel Developer at Wolfram Research (poeschko.com).

One is called Mathador, which is implemented in C++ and is no longer maintained, but the source may be of interest to you.

The other is called Mathics and is currently (as of 2022) being maintained. It is implemented in Python, uses the SymPy package to perform symbolic computations, and has a web browser interface. You can check it out online at mathics.org.

$\endgroup$
6
  • $\begingroup$ hi, just to make sure I understand, are you saying that the Wolfram Language is/will be an "open-source" implementation of language Mathematica? $\endgroup$
    – Nasser
    Nov 10, 2013 at 0:06
  • 2
    $\begingroup$ @Nasser Switch "Wolfram language" and "Mathematica". $\endgroup$
    – Sektor
    Nov 10, 2013 at 0:33
  • $\begingroup$ I am actually looking forward to seeing the Wolfram LRM (Language reference manual), which I assume will be published at some point in the future now that there is an official language called Wolfram. $\endgroup$
    – Nasser
    Nov 10, 2013 at 1:27
  • $\begingroup$ @Nasser I don't think it is open source, in fact I don't really think that Mathics is 100% legal so it really isn't a cross compiler, but actually interpreter. $\endgroup$
    – William
    Sep 26, 2015 at 3:08
  • 1
    $\begingroup$ Thanks for this answer - it's interesting to see that WRI hired Jan Pöschko to work on Wolfram Cloud after he had written Mathics... makes sense! $\endgroup$
    – Simon
    Jun 26, 2016 at 12:44
27
$\begingroup$

Expreduce

Expreduce is a new MIT-licensed project that has a fairly complete implementation of the language semantics. Further, it has a nice collection of definitions that provide CAS functionality, along with documentation to match. There is also a large testing suite for verification. It aims to have a small core with most of the functionality implemented in the language itself using the rewrite rule paradigm. The kernel is written in Go. Here are some examples of what can be computed:

In[1]:= D[Cos[Log[Sin[x]]+x]+x,x]

Out[1]= (1 + (-1 * (1 + Cot[x]) * Sin[(x + Log[Sin[x]])]))

In[2]:= Integrate[5*E^(3*x),{x,2,a}] // Expand

Out[2]= ((-5/3 * E^6) + (5/3 * E^(3 * a)))

The CAS functionality uses a collection of rewrite rules. For example, the product rule for derivatives is implemented using only one line:

D[a_*b_,x_] := D[a,x]*b + a*D[b,x]

The implementation is currently lacking in visualizations and the functionality of Solve among other things. Right now it is just a terminal, but perhaps there will be a Jupyter notebook interface for it in the future. It has virtually no dependencies. Since it does not call out to another open source CAS, there are many operations that it cannot do. Fortunately, the rule paradigm allows for fast development of new features. It could also benefit by getting the Risch algorithm for integration. Right now the integrations are mostly solved using heuristics.

mmaclone

There is also an interesting Haskell implementation of the pattern matching engine by Yonghao Jin at https://github.com/jyh1/mmaclone.

$\endgroup$
3
  • 3
    $\begingroup$ I am wondering if it is capable of running RUBI. $\endgroup$
    – Szabolcs
    Jul 24, 2017 at 9:51
  • $\begingroup$ I sent an email to Albert Rich to get his thoughts on this. It's an extremely impressive collection of rules, with a vast testing suite. I tried parsing one of the rule sets in Expreduce and it worked. I was even able to get some correct results returned. That said, there are many Q functions (some standard, some defined in the utils source) in his conditionals that Expreduce does not support. I would say that the pattern matching is there, but it would need some more built in functions. I think support for this collection should drive v0.3 development. Pull requests welcome :P. $\endgroup$ Jul 25, 2017 at 4:25
  • 1
    $\begingroup$ Expreduce supports rubi $\endgroup$
    – darvin
    May 30, 2018 at 21:53

Your Answer

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

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