Skip to content

jlapeyre/SymataSyntax.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SymataSyntax

Mathematica syntax for Symata

This version of SymataSyntax is for Juilia v.0.7. In order to use SymataSyntax you must add a dependency on SymataSyntax to the REQUIRE file of Symata. This is not done by default to avoid adding burdensome dependencies to Symata. This should not be necessary by Julia v1.0, and hopefully sooner.

SymataSyntax tagged with v0.4.0 is the last version that supports Julia v0.6.

This package provides Mathematica syntax for Symata. This package is unrelated to and independent of Mathematica and Wolfram language software from WRI. SymataSyntax uses the python package mathics for parsing and formatting.

This module provides a shell within the symata shell that reads and prints in Mathematica syntax. It also supports Jupyter. It also supports reading from a file. It also provides a shell to interact directly with the running mathics process. You can enter and leave the alternative syntax and mathics shells repeatedly during a symata session.

Requirements

SymataSyntax can be installed like this

julia> Pkg.clone("https://github.com/jlapeyre/SymataSyntax.jl")

SymataSyntax requires a development version of Symata.jl. You can install and switch to the development version like this

julia> Pkg.add("Symata")
julia> Pkg.checkout("Symata")

See the Symata page for more details.

SymataSyntax requires the python package mathics. At the moment, mathics cannot be installed automatically via Conda.jl. mathics can be installed using pip. The recommended way to install Symata is using Conda.jl, which installs python and sympy in your collection of Julia packages in the Conda directory. The program pip will also be installed (at least on Linux). The location of the python binaries, python, conda, pip, etc can be found as follows

julia> Using Conda
julia> Conda.bin_dir(Conda.ROOTENV)
"/home/someuser/.julia/v0.6/Conda/deps/usr/bin"

In this case, mathics can by installed from a shell like this

/home/someuser/.julia/v0.6/Conda/deps/usr/bin/pip install mathics

Alternatively, you can use a system- or user installation of mathics.

Using SymataSyntax

Mathematica-syntax mode

Use SymataSyntax from within Symata. The command The command MmaSyntax() loads SymataSyntax and enters Mathematica-syntax mode. Return to the standard Symata-syntax mode by typing ctrl-d. The Symata command MmaSyntax() will try to load SymataSyntax.jl.

symata 1> Table(i^2, [i, 1, 10])
Out(1) = [1,4,9,16,25,36,49,64,81,100]

symata 2> MmaSyntax()
In[2]:= ex = Table[x^i, {i,1,5}]
Out[2]= {x, x ^ 2, x ^ 3, x ^ 4, x ^ 5}

In[3]:=     # type ctrl-d to exit MmaSyntax mode
symata 3> ex
Out(3) = [x,x^2,x^3,x^4,x^5]

In Jupyter, use MmaSyntax(True) and MmaSyntax[False] to enter and exit the mode.

Reading from a file

Read and evaluate Mathematica syntax expressions from a file with GetMma.

symata 1> GetMma("fname")

Mathics mode

Enter the mathics REPL with the command Mathics(). Return to Symata by typing ctrl-d. At present, the Symata and mathics processes cannot communicate.

Symata, sympy, mpmath, and mathics

SymataSyntax and Symata rely on the following excellent software projects (in addition to Julia!).

Sympy is an active python project that implements a very large number of algebraic-manipulation algorithms and other general-purpose symbolic mathematics functions.

mpmath is a python library for arbitrary precision arithmetic. It implements a very large number of mathematical functions.

mathics is reimplementation of the Mathematica language in python. This is a volunteer, open-source project that is completely unrelated to Wolfram Mathematica software. Neither mathics nor Symata are supported in any way by the Wolfram company. mathics has implemented a very large part of the core of the language as well as many peripheral functions and packages. It reproduces the behavior very well and is very well documented. At present, mathics is more complete than Symata. However, mathics is rather slow in many cases, and is very slow in many cases. (The developers are working to improve performance). Symata is faster than mathics in all examples I have tried, and in some cases is much faster (by factors of perhaps of 5 to 1000). In general, the larger the expression, the larger the difference in performance.

Symata is fast enough for practical applications. I will release a notebook used for research once the corresponding manuscript is submitted. There are many optimizations that can be made to Symata with varying amounts of effort. However, pieces of Symata are regularly redesigned, so optimizing is not a good use of resources at this point.

About

Mathematica syntax for Symata.jl

Resources

License

Stars

Watchers

Forks

Packages

No packages published