GPL Mathematica clone (written in Java)

340 views
Skip to first unread message

Dr. David Kirkby

unread,
Apr 20, 2011, 4:50:39 AM4/20/11
to sage-devel
This is interesting.

http://code.google.com/p/symja/

Apparently it can parse a large percentage of the Mathematica language and has
nearly 295 functions. I note it has "D[]" and "Integrate[]" as two of them.

You can try it online at

http://mobmath.appspot.com/

It did not take me too long to find a bug using the online version.

N[Sin[1/1000],100]
Error:
Expected number of arguments: 1 but got 2 arguments:
N[Sin[1/1000], 100]

But that is valid Mathematica syntax:


From the real Mathematica.

In[3]:= N[Sin[1/1000],100]

Out[3]= 0.0009999998333333416666664682539710097001513147348086584190048145102\

> 714673516376365515440749327845858917

Dave

Jason Grout

unread,
Apr 20, 2011, 5:13:24 AM4/20/11
to sage-...@googlegroups.com
On 4/20/11 3:50 AM, Dr. David Kirkby wrote:
> This is interesting.
>
> http://code.google.com/p/symja/
>
> Apparently it can parse a large percentage of the Mathematica language
> and has nearly 295 functions. I note it has "D[]" and "Integrate[]" as
> two of them.
>
> You can try it online at
>
> http://mobmath.appspot.com/
>


Interesting. Looking through the docs to the integration functions
leads to this website with a large number of rules for integration,
which claims that in some cases, it performs much better than MMA and Maple:

http://www.apmaths.uwo.ca/~arich/

Jason

Dr. David Kirkby

unread,
Apr 20, 2011, 6:40:36 AM4/20/11
to sage-...@googlegroups.com

Though I can't find it now, I've seen that site before, and there was (is??)
something on the site to say that the good results compared to the commercial
products is to be expected. I can't recall the reasons, but I suspect it is
based on the fact that the tests are used during the software development. If
you know in advance what the tests are, its a lot easier to tweak the code to
give the right results.

It's interesting that Mathematica 7 performed significantly better than Maple
13, with slightly less "messy" results and around a third of the number of
incorrect results (0.9% for Mathematica, 2.7% for Maple). From discussions I've
had with Vladimir Bondarenko, he is of the opinion that Wolfram Research take
quality control more seriously than Maplesoft.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Dave

Dr. David Kirkby

unread,
Apr 20, 2011, 6:46:37 AM4/20/11
to sage-...@googlegroups.com
On 04/20/11 11:40 AM, Dr. David Kirkby wrote:
> On 04/20/11 10:13 AM, Jason Grout wrote:

>> Interesting. Looking through the docs to the integration functions leads
>> to this website with a large number of rules for integration, which
>> claims that in some cases, it performs much better than MMA and Maple:
>>
>> http://www.apmaths.uwo.ca/~arich/
>>
>> Jason
>>
>
> Though I can't find it now, I've seen that site before, and there was
> (is??) something on the site to say that the good results compared to
> the commercial products is to be expected. I can't recall the reasons,
> but I suspect it is based on the fact that the tests are used during the
> software development. If you know in advance what the tests are, its a
> lot easier to tweak the code to give the right results.

I found what I was looking for:

http://www.apmaths.uwo.ca/~arich/TestResultHighlights/TestResultHighlights.html

"Since Rubi was developed in conjunction with the test suite, it's good
performance is to be expected"

Simon

unread,
Apr 20, 2011, 8:48:26 AM4/20/11
to sage-...@googlegroups.com
The whole symja thing is interesting... 
how much of Mathematica's syntax are they allowed to copy without breaching some sort of intellectual property rights?

Since some claims were made about symja's integration capabilities, I tested a few integrals...
It didn't take long to find simple integrals that Mathematica could do but symja left unevaluated.
More worryingly were results like the following 
(where it looks like it repeatedly did integration by parts the "wrong way around"...)

In[9]=Integrate[x*Cos[x],x]
Out[9]=1/2*Cos[x]*x^2+1/2*(1/3*x^3*Sin[x]-1/3*(1/4*Cos[x]*x^4+1/4*(1/5*x^5*Sin[x]-1/5*(
1/6*Cos[x]*x^6+1/6*(1/7*x^7*Sin[x]-1/7*(1/8*Cos[x]*x^8+1/8*(1/9*x^9*Sin[x]-1/9*(
1/10*Cos[x]*x^10+1/10*(1/11*x^11*Sin[x]-1/11*(1/12*Cos[x]*x^12+1/12*(1/13*x^13*Sin[x]
-1/13*(1/14*Cos[x]*x^14+1/14*(1/15*x^15*Sin[x]-1/15*(1/16*Cos[x]*x^16+1/16*(1/17*x^
17*Sin[x]-1/17*(1/18*Cos[x]*x^18+1/18*(1/19*x^19*Sin[x]-1/19*(1/20*Cos[x]*x^20+1/
20*(1/21*x^21*Sin[x]-1/21*(1/22*Cos[x]*x^22+1/22*(1/23*x^23*Sin[x]-1/23*(1/24*Cos[x]*x^
24+1/24*(1/25*x^25*Sin[x]-1/25*(1/26*Cos[x]*x^26+1/26*(1/27*x^27*Sin[x]-1/27*(1/
28*Cos[x]*x^28+1/28*(1/29*x^29*Sin[x]-1/29*(1/30*Cos[x]*x^30+1/30*(1/31*x^31*Sin[x]
-1/31*(1/32*Cos[x]*x^32+1/32*(1/33*x^33*Sin[x]-1/33*(1/34*Cos[x]*x^34+1/34*(1/35*x^
35*Sin[x]-1/35*(1/36*Cos[x]*x^36+1/36*(1/37*x^37*Sin[x]-1/37*(1/38*Cos[x]*x^38+1/
38*(1/39*x^39*Sin[x]-1/39*(1/40*Cos[x]*x^40+1/40*(1/41*x^41*Sin[x]-1/41*(1/42*Cos[x]*x^
42+1/42*(1/43*x^43*Sin[x]-1/43*(1/44*Cos[x]*x^44+1/44*(1/45*x^45*Sin[x]-1/45*(1/
46*Cos[x]*x^46+1/46*(1/47*x^47*Sin[x]-1/47*(1/48*Cos[x]*x^48+1/48*(1/49*x^49*Sin[x]
-1/49*(1/50*Cos[x]*x^50+1/50*(1/51*x^51*Sin[x]-1/51*(1/52*Cos[x]*x^52+1/52*(1/53*x^
53*Sin[x]-1/53*(1/54*Cos[x]*x^54+1/54*(1/55*x^55*Sin[x]-1/55*(1/56*Cos[x]*x^56+1/
56*(1/57*x^57*Sin[x]-1/57*(1/58*Cos[x]*x^58+1/58*(1/59*x^59*Sin[x]-1/59*(1/60*Cos[x]*x^
60+1/60*(1/61*x^61*Sin[x]-1/61*Integrate[Cos[x]*x^61,x])))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

rjf

unread,
Apr 20, 2011, 12:45:37 PM4/20/11
to sage-devel
I tried
Do[print[i];If[i>4,Return[toobig]], {i,1,10}]

which failed. So it can't iterate

I tried

a + f[8] /. f[x_?(# > 7 &)] -> aha

which it refused to parse, much less do pattern matching.


Nothing on the web site interface can include a left-hand-side for
assignment.

While I think this program can do some computations, it is sort of
like the stopped clock that is right twice a day.



On Apr 20, 5:48 am, Simon <simonjty...@gmail.com> wrote:
> The whole symja thing is interesting...
> how much of Mathematica's syntax are they allowed to copy without breaching
> some sort of intellectual property rights?

This is probably not the right forum to discuss Wolfram's claims on
what is owned by his company.

personally, I think he was not the first to use + as in A+B. :)

RJF

Simon

unread,
Apr 20, 2011, 6:01:37 PM4/20/11
to sage-...@googlegroups.com
On Thursday, 21 April 2011 02:45:37 UTC+10, rjf wrote:
I tried
Do[print[i];If[i>4,Return[toobig]], {i,1,10}]

which failed. So it can't iterate

It's lack of basic (working) loop constructions it a bit disheartening.

Nothing on the web site interface can include a left-hand-side for
assignment.

Sure, but the single .jar file is easy to download and run. 

On Apr 20, 5:48 am, Simon <simon...@gmail.com> wrote:
> The whole symja thing is interesting...
> how much of Mathematica's syntax are they allowed to copy without breaching
> some sort of intellectual property rights?

This is probably not the right forum to discuss Wolfram's claims on
what is owned by his company.

I was just musing out loud....
 
personally, I think he was not the first to use  +   as in A+B. :)

:) 
 

David Kirkby

unread,
Apr 21, 2011, 7:49:19 AM4/21/11
to sage-...@googlegroups.com
On 20 April 2011 13:48, Simon <simon...@gmail.com> wrote:
> The whole symja thing is interesting...

Symja would be much more so if it worked reasonably well. I'm told
there's no support for high precision floating point numbers, which is
why N[] is expecting only one argument. But it seems to have multiple
issues.

> how much of Mathematica's syntax are they allowed to copy without breaching
> some sort of intellectual property rights?

I don't think it can, though it might depend on your country. Many
argue that a language can't be copyrighted.

http://stackoverflow.com/questions/1113384/are-computer-language-copyrighted-can-i-make-a-compiler-or-ide-or-anything-for-a


I believe Richard Fateman had issues with Wolfram Research's lawyers
over this topic, but his code is still available on the university web
site, so I guess WRI gave up. I don't k know if issue has ever been
tested in court. I can't find any case of where a company has managed
to win a copyright case with a computer language. Of course, if in
implementing that language you needed to use a technology which was
patented, then it would be a different matter.

Octave is quite a good clone of MATLAB. I'm not sure if Mathworks have
ever tried to stop Octave, but if they have, they have not succeeded.
I suspect that's why WRI's lawyers never succeeded with Richard
Fateman.

> Since some claims were made about symja's integration capabilities, I tested
> a few integrals...
> It didn't take long to find simple integrals that Mathematica could do but
> symja left unevaluated.

I'm not sure how much relationship there is between Rubi test results

http://www.apmaths.uwo.ca/~arich/TestSuiteResults/RubiResults/RubiTestResults.html

and Symja

http://code.google.com/p/symja/

which is a fork of MathEclipse

http://sourceforge.net/projects/matheclipse/

Does Symja have anything whatsoever to do with Rubi ?

> More worryingly were results like the following
> (where it looks like it repeatedly did integration by parts the "wrong way
> around"...)
> In[9]=Integrate[x*Cos[x],x]
> Out[9]=1/2*Cos[x]*x^2+1/2*(1/3*x^3*Sin[x]-1/3*(1/4*Cos[x]*x^4+1/4*(1/5*x^5*Sin[x]-1/5*(
> 1/6*Cos[x]*x^6+1/6*(1/7*x^7*Sin[x]-1/7*(1/8*Cos[x]*x^8+1/8*(1/9*x^9*Sin[x]-1/9*(

<SNIP>

Symja seems to be basically broken, but I thought I'd mention it.

I would very much like to see a Mathematica clone. Basing it on using
LLVM as a back-end for generating compiled code would be interesting.

http://llvm.org/pubs/2010-09-HASKELLSYM-LLVM-GHC.pdf

makes a good case for using LLVM rather than generating C and
compiling the C code as Cython does. I've discussed with a couple of
people, including Ira Baxter of Semantic Designs

http://www.semanticdesigns.com/

about approaches for a parser. Ira is of the opinion that a GLR parser
is suitable. In fact he says Mathematica is not a particularly
difficult language to parse, but then he is an expert at writing
parsers.

But any attempt to create a clone would appear to me to need a huge
amount of resources and skill.

Dave

rjf

unread,
Apr 21, 2011, 11:44:03 AM4/21/11
to sage-devel
There is so much wrong with Kirkby's statements, it is hard to know
where to start.

1. This symja is not a Mathematica "clone". At best it is an attempt
to build a computer algebra system in Java, and has used pieces of the
Mathematica design as a guide for some of its surface language and a
sprinkling of its evaluation.

A computer algebra system written in Java has the advantages and
disadvantages of being written in Java. Personally, I think it is not
a good idea.

2. Kirkby is, so far as I can tell, the only person who says it is a
Mathematica clone.


3. There are programs that are considerably more like Mathematica than
symja.

4. Kirkby is not a lawyer, nor am I.

5. Sage-devel is not a useful venue to discuss intellectual property
issues, seeing as how (I expect) not a single one of us is a lawyer.
Just a note, though: sometimes people are happy to pay money to a
company for software and support even if similar software is available
"free".

6. Kirkby repeats the thought that somehow the difficult part of
Mathematica is a parser, a notion which anyone who has taken an
undergraduate course in computer programming language implementation
knows to be quite false. The use or non-use of LLVM is quite
irrelevant, and compiling Mathematica programs into machine code,
except for small segments doing essentially only evaluation of
floating-point expressions, is pointless.

7. The fact that Ira Baxter says that Mathematica is not difficult to
parse has been discussed previously. According to his company web
site, something like 23 languages are supported but not Mathematica,
which is only "under development".

Perhaps Ira can say what his parser produces for

1.2.3

45/.45->60

a=b+c
+d

a.2

2.a

%%%%

%4

A!=B>C

A!=B!=C




But the goal of Ira's program for Mathematica is stuff like a code
formatter or perhaps a translator into some intermediate language.
This is quite different from a clone of full a run-time system for
Mathematica.

7. I agree that building a complete clone of Mathematica would be a
substantial undertaking, Especially since it continues to be
developed, an endless task. Since you can just buy a copy for much
much less than the cost of developing a clone, it doesn't make
economic sense, so there must some other explanation. I know why I
wrote my stuff ( http://www.cs.berkeley.edu/~fateman/lisp/mma4max )
which was to give me (and others) an opportunity to run (some)
Mathematica programs with a different underlying semantics for
floating-point arithmetic, pattern-matching, and possibly other
features. It was revived and improved to give Rubi, as written by
Albert Rich, a potential host system using only ANSI standard Common
Lisp, of which there are many implementations, some free. There is a
potential larger issue, which is whether the approach used in Rubi can
cover (much) more mathematics.

8. Why do YOU feel you need a Mathematica clone?




On Apr 21, 4:49 am, David Kirkby <david.kir...@onetel.net> wrote:
> On 20 April 2011 13:48, Simon <simonjty...@gmail.com> wrote:
>
> > The whole symja thing is interesting...
>
> Symja would be much more so if it worked reasonably well. I'm told
> there's no support for high precision floating point numbers, which is
> why N[] is expecting only one argument. But it seems to have multiple
> issues.
>
> > how much of Mathematica's syntax are they allowed to copy without breaching
> > some sort of intellectual property rights?
>
> I don't think it can, though it might depend on your country. Many
> argue that a language can't be copyrighted.
>
> http://stackoverflow.com/questions/1113384/are-computer-language-copy...
>
> I believe Richard Fateman had issues with Wolfram Research's lawyers
> over this topic, but his code is still available on the university web
> site, so I guess WRI gave up. I don't k know if issue has ever been
> tested in court. I can't find any case of where a company has managed
> to win a copyright case with a computer language. Of course, if in
> implementing that language you needed to use a technology which was
> patented, then it would be a different matter.
>
> Octave is quite a good clone of MATLAB. I'm not sure if Mathworks have
> ever tried to stop Octave, but if they have, they have not succeeded.
> I suspect that's why WRI's lawyers never succeeded with Richard
> Fateman.
>
> > Since some claims were made about symja's integration capabilities, I tested
> > a few integrals...
> > It didn't take long to find simple integrals that Mathematica could do but
> > symja left unevaluated.
>
> I'm not sure how much relationship there is between Rubi test results
>
> http://www.apmaths.uwo.ca/~arich/TestSuiteResults/RubiResults/RubiTes...

Dr. David Kirkby

unread,
Apr 21, 2011, 7:58:35 PM4/21/11
to sage-...@googlegroups.com
On 04/20/11 05:45 PM, rjf wrote:
> I tried
> Do[print[i];If[i>4,Return[toobig]], {i,1,10}]
>
> which failed. So it can't iterate
>
> I tried
>
> a + f[8] /. f[x_?(#> 7&)] -> aha

>
> which it refused to parse, much less do pattern matching.
>
>
> Nothing on the web site interface can include a left-hand-side for
> assignment.
>
> While I think this program can do some computations, it is sort of
> like the stopped clock that is right twice a day.
>
>
>
> On Apr 20, 5:48 am, Simon<simonjty...@gmail.com> wrote:
>> The whole symja thing is interesting...
>> how much of Mathematica's syntax are they allowed to copy without breaching
>> some sort of intellectual property rights?
>
> This is probably not the right forum to discuss Wolfram's claims on
> what is owned by his company.
>
> personally, I think he was not the first to use + as in A+B. :)
>
> RJF
>

It's clear it's not implemented very well. I still find it quite interesting,
but it's clearly not worth spending any time with.

Dr. David Kirkby

unread,
Apr 21, 2011, 8:01:44 PM4/21/11
to sage-...@googlegroups.com
On 04/21/11 04:44 PM, rjf wrote:
> There is so much wrong with Kirkby's statements, it is hard to know
> where to start.

I do have a forename. I'd appreciate if you used it.

rjf

unread,
Apr 22, 2011, 6:00:26 PM4/22/11
to sage-devel
visit sage-flame for more on this topic.


Robert Dodier

unread,
Apr 22, 2011, 11:05:23 PM4/22/11
to sage-devel
On Apr 20, 2:50 am, "Dr. David Kirkby" <david.kir...@onetel.net>
wrote:

> This is interesting.
>
> http://code.google.com/p/symja/
>
> Apparently it can parse a large percentage of the Mathematica language and has
> nearly 295 functions. I note it has "D[]" and "Integrate[]" as two of them.

Well, to the extent that it's interesting to be able to call
symbolic math functions in Java, I think one's time would
be better spent trying to build an interface to an
existing system rather than creating a new one.
As you know, symbolic math is hard, and while it is easy
to get started, it is a tremendously long haul.

Existing symbolic math systems are mostly written in languages
other than Java, and often weren't created with the idea that
programmatic interaction is any kind of goal, so bolting another
program onto them is often tedious and messy. But even so that's
a much, much easier problem to solve than replicating all of
the algorithms.

As a proof of concept, I've compiled Maxima with ABCL which
is a Lisp implementation in Java and called Maxima functions
from a Java program. It is clumsy, but, if I really wanted to do
it, it would be a lot easier to improve the interface than to
reimplement the algorithms of interest. I suppose a similar
exercise could be carried out with Jython (Python implementation
in Java) and Sympy or any pure-Python code in Sage.

There is also CL-Python which is an implementation of Python
is Lisp. One could, I guess, link Lisp functions into the image
and call them from Python; then Python could be your user
language.

FWIW

Robert Dodier

Dr. David Kirkby

unread,
Apr 25, 2011, 4:51:35 AM4/25/11
to sage-...@googlegroups.com
On 04/20/11 01:48 PM, Simon wrote:
> The whole symja thing is interesting...
> how much of Mathematica's syntax are they allowed to copy without breaching
> some sort of intellectual property rights?

Although this case was in the USA, and different countries have different laws,
this situation arose when Borland made a clone of Lotus 123 (a spreadsheet),
which they called "Quattro Pro". Lotus took Borland to court, arguing copyright
infringement.

This was eventually settled in the United States Supreme Court, with Lotus
losing their case. The court said it would be absurd for users to have to
re-write macros if using other software.

http://en.wikipedia.org/wiki/Lotus_Dev._Corp._v._Borland_Int%27l,_Inc.

So it looks like in the US at least, one can't copyright the commands or layout
of a program.

Dave

Reply all
Reply to author
Forward
0 new messages