Mockmma release candidate



I have checked in a release candidate of Mockmma, which emulates a small subset of Mathematica (tm) commands using Maxima. Please let me know whether you think this is ready to be included in the August 2009 release of Maxima. To install, check out the trunk/mockmma directory of the sourceforge project mockmma into the share directory of your Maxima installation; note that the name of the init2.lisp file is now mockmma.lisp, and the invocation command (tl) is now (mockmma). I am adding new commands at a fast pace now; other developers remain welcome.

(Excerpt from .texi file and tests follow)

Mockmma uses Maxima to emulate a small subset of commands in Mathematica (tm), which is a trademark of 
Wolfram Research Incorporated (WRI) and is in no way associated with WRI. 
Mockmma is based on code originally created by Richard Fateman in 1990. This is the first release of Mockmma in this format
and it should be considered experimental. 

To run mockmma, type  load("mockmma/mockmma.lisp") 
and type :lisp (mockmma). You should see the prompt "In[1] :=". In wxMaxima, you can load the file
Mockmma.wxm in the share\Mockmma directory.  

You can enter commands such as the following: 
2+3, 3^7, IntegerQ[2], PrimeQ[31], 10!,
y=5, y^2,  Exp[1], Sin[0], Cos[0], Cos[Pi], Sin[1.0], 2.2+3.1, Sqrt[4], Sqrt[3.0], {a,b,c}[[2]], %, %1, %^2
2>1, 2<1, FactorInteger[24], Expand[(1+x)^5], Log[E], I*I, D[Log[x],x], Factor[x^2+2*x+1], f[x_]:=x^2, Map[f,{1,2}],
True && False, False || True, Factor[x^2+2x+1], {a,b}.{c,d}, If[True,a,b]

Mockmma is not Mathematica, but is a different interface to Maxima. Mathematica has incorporated a number of commands from MACSYMA, 
the predecessor to Maxima; for instance, "primep(23)" became "PrimeQ(23)". 
Mockmma inverts that process, by translating the command "PrimeQ(23)" to "primep(23)", evaluating "primep(23)" in Maxima, 
and translating the result "true" in Maxima to "True" in Mathematica. Several commands however are evaluated outside of Maxima, 
for instance, "Out[5]" or "%5" in Mockmma does not correspond to (o%5) in Maxima. In addition, Mockmma does its own 
pattern matching, so "f[x_]:=x^2" in Mockmma does not create a function "f(x):=x^2" in Maxima. 
Finally, "Equal" is calculated outside of Maxima, e.g. "Equal[PrimeQ[23], True]".

Because most Mockmma commands are evaluated in Maxima, the result may not be the same as Mathematica (tm). 

To run tests, use the commands "batch("mockmma/rtest_mockmma.mac", 'test)" which should produce
the following results:

(%i2) batch("mockmma/rtest_mockmma.mac", 'test);

********************** Problem 1 ***************
Input:
(load(mockmma/mockmma.lisp),0)
Result:
0
... Which was correct.
********************** Problem 2 ***************
Input:
(load(mockmma/rtest_mockmma.lisp),0)
Result:
0
... Which was correct.
********************** Problem 3 ***************
Input:
mockmmatest(PrimeQ[23] )
Result:
true
... Which was correct.
********************** Problem 4 ***************
Input:
mockmmatest(2+3)
Result:
5
... Which was correct.
********************** Problem 5 ***************
Input:
mockmmatest(3^7)
Result:
2187
... Which was correct.
********************** Problem 6 ***************
Input:
mockmmatest(4!)
Result:
24
... Which was correct.
********************** Problem 7 ***************
Input:
mockmmatest(y=5)
Result:
5
... Which was correct.
********************** Problem 8 ***************
Input:
mockmmatest(y^2)
Result:
25
... Which was correct.
********************** Problem 9 ***************
Input:
mockmmatest(Sin[1.0])
Result:
0.8414709848079
... Which was correct.
********************** Problem 10 ***************
Input:
mockmmatest(5+1.0)
Result:
6.0
... Which was correct.
********************** Problem 11 ***************
Input:
mockmmatest(g[x_]:=x^3)
Result:
true
... Which was correct.
********************** Problem 12 ***************
Input:
mockmmatest(g[2])
Result:
8
... Which was correct.
********************** Problem 13 ***************
Input:
mockmmatest(Map[g, {1,2,3}]=={1,8,27})
Result:
true
... Which was correct.
********************** Problem 14 ***************
Input:
mockmmatest(Sqrt[4])
Result:
2
... Which was correct.
********************** Problem 15 ***************
Input:
mockmmatest(Sqrt[3.0])
Result:
1.732050807568877
... Which was correct.
********************** Problem 16 ***************
Input:
mockmmatest({1,4,9,16}[[3]])
Result:
9
... Which was correct.
********************** Problem 17 ***************
Input:
mockmmatest(Cos[0])
Result:
1
... Which was correct.
********************** Problem 18 ***************
Input:
mockmmatest(Sin[0])
Result:
0
... Which was correct.
********************** Problem 19 ***************
Input:
mockmmatest(Cos[Pi])
Result:
-1
... Which was correct.
********************** Problem 20 ***************
Input:
mockmmatest(Sin[Pi])
Result:
0
... Which was correct.
********************** Problem 21 ***************
Input:
mockmmatest(Sin[Pi/2])
Result:
1
... Which was correct.
********************** Problem 22 ***************
Input:
mockmmatest(Cos[Pi/2])
Result:
0
... Which was correct.
********************** Problem 23 ***************
Input:
mockmmatest(2>1)
Result:
true
... Which was correct.
********************** Problem 24 ***************
Input:
mockmmatest(2<1)
Result:
false
... Which was correct.
********************** Problem 25 ***************
Input:
mockmmatest(2>1)
Result:
true
... Which was correct.
********************** Problem 26 ***************
Input:
mockmmatest(1<2)
Result:
true
... Which was correct.
********************** Problem 27 ***************
Input:
mockmmatest(2<=1)
Result:
false
... Which was correct.
********************** Problem 28 ***************
Input:
mockmmatest(1>=2)
Result:
false
... Which was correct.
********************** Problem 29 ***************
Input:
mockmmatest(2>=2)
Result:
true
... Which was correct.
********************** Problem 30 ***************
Input:
mockmmatest(2<=2)
Result:
true
... Which was correct.
********************** Problem 31 ***************
Input:
mockmmatest(FactorInteger[24]=={{2, 3}, {3, 1}})
Result:
true
... Which was correct.
********************** Problem 32 ***************
Input:
mockmmatest(Expand[(1+x)^2]==1+2*x+x^2)
Result:
true
... Which was correct.
********************** Problem 33 ***************
Input:
mockmmatest(Log[E])
Result:
1
... Which was correct.
********************** Problem 34 ***************
Input:
mockmmatest(E==Exp[1])
Result:
true
... Which was correct.
********************** Problem 35 ***************
Input:
mockmmatest(I*I )
Result:
-1
... Which was correct.
********************** Problem 36 ***************
Input:
mockmmatest(D[Log[x],x]==1/x )
Result:
true
... Which was correct.
********************** Problem 37 ***************
Input:
mockmmatest(D[Sin[x],x]==Cos[x] )
Result:
true
... Which was correct.
********************** Problem 38 ***************
Input:
mockmmatest(D[Cos[x],x]==-Sin[x] )
Result:
true
... Which was correct.
********************** Problem 39 ***************
Input:
mockmmatest(Factor[x^2+2*x+1]==(x+1)^2 )
Result:
true
... Which was correct.
********************** Problem 40 ***************
Input:
mockmmatest(Integrate[x,x]==x^2 / 2)
Result:
true
... Which was correct.
********************** Problem 41 ***************
Input:
mockmmatest(Integrate[Sin[z]*z,z]== - z Cos[z] + Sin[z])
Result:
true
... Which was correct.
********************** Problem 42 ***************
Input:
mockmmatest(Integrate[x,{x,0,1}]==1/2)
Result:
true
... Which was correct.
********************** Problem 43 ***************
Input:
mockmmatest(True && True )
Result:
true
... Which was correct.
********************** Problem 44 ***************
Input:
mockmmatest(True && False )
Result:
false
... Which was correct.
********************** Problem 45 ***************
Input:
mockmmatest(True || False )
Result:
true
... Which was correct.
********************** Problem 46 ***************
Input:
mockmmatest(False || False )
Result:
false
... Which was correct.
********************** Problem 47 ***************
Input:
mockmmatest({a,b}.{c,d}==a*c + b * d )
Result:
true
... Which was correct.
********************** Problem 48 ***************
Input:
mockmmatest({2,3}.{5,3})
Result:
19
... Which was correct.
********************** Problem 49 ***************
Input:
mockmmatest(If[True,a,b]==a )
Result:
true
... Which was correct.
********************** Problem 50 ***************
Input:
mockmmatest(If[False,a,b]==b )
Result:
true
... Which was correct.
50/50 tests passed.