maxima

    A port of the Maxima computer algebra system to MoonBit

    maxima
    computer-algebra
    symbolic
    cas
    math
    Download zip
    Version
    0.1.0
    License
    GPL-2.0
    Last updated
    20 days ago
    Downloads
    26

    #Maxima in MoonBit

    A port of the Maxima computer algebra system from Common Lisp to MoonBit, compiled to native code.

    The port is a faithful, function-by-function translation of Maxima's Lisp sources (.repos/maxima, Maxima 5.50post). It keeps Maxima's internal expression representation (Lisp s-expressions such as ((mplus simp) 1 $x)), so it behaves like Maxima down to the details and is validated with Maxima's own test suites.

    CI

    #Building and running

    The port reads Maxima's share packages, test files and Lisp sources from a Maxima source tree at run time, so fetch the exact tree it was translated from first (about 150 MB):

    tools/fetch-maxima.sh # clones calyau/maxima at the pinned commit into .repos/maxima moon build --release ./_build/native/release/build/cmd/main/main.exe # interactive ./_build/native/release/build/cmd/main/main.exe --batch-string='integrate(x^2*sin(x),x);' ./_build/native/release/build/cmd/main/main.exe -b file.mac

    The program finds .repos/maxima by looking in the current directory, the program's directory and their parents; set MAXIMA_PREFIX to use a Maxima source tree elsewhere (tools/fetch-maxima.sh <dir> fetches one there).

    As a library (moon add moonbit-community/maxima), @core.initialize() sets Maxima up and @core.cli_main(args) runs it with Maxima's command-line options.

    #Status

    Test suitePassing
    Core (run_testsuite(), 92 files)16435 / 16441 (99.96%), all files complete — docs/TESTS.md
    Share packages (share_tests=only, 72 files)5027 / 5061 (99.3%) — docs/TESTS_SHARE.md
    rtest_translator (not in the default list; batch(file, test))307 / 307

    The LAPACK tests (rtest_dgemm, rtest_dgeqrf, rtest_dgesv) are left out of Maxima's test list under SBCL; run with batch(file, test) they pass.

    Every Lisp function of Maxima's sources and share packages is ported (tools/unported.py lists none). This includes:

    • the translator (translate, compile, translate_file, compile_file): the generated Lisp runs on a Lisp evaluator (core/lisp_eval*.mbt), which also loads Lisp source files and serves :lisp and to_lisp();
    • plotting through gnuplot / xmaxima / geomview, draw, and system();
    • the help system (describe, ?, ??), which needs Maxima's built info index (the source tree has none until the documentation is built with texinfo), the debugger and break commands, the command-line options, and the -s <port> client mode;
    • all the Fortran libraries Maxima ships as f2cl-generated Lisp (SLATEC, QUADPACK, LAPACK/BLAS, ODEPACK, LBFGS, MINPACK, COBYLA, FFTPACK5, HOMPACK, COLNEW).

    Not available: the server side of share/contrib/maxima-server (the runtime cannot listen on sockets or fork), and loaded Lisp code that redefines a ported function only changes calls made through the function cell.

    #Layout

    • lisp/ — Common Lisp runtime: values, symbols and property lists, conses, the CL numeric tower (with SBCL-exact float and complex arithmetic), strings, hash tables, arrays, streams, format, a literal reader.
    • core/ — the translated Maxima system (simplifier, evaluator, parser, display, rational functions, factoring, assumptions, integration, limits, Taylor series, solve, special functions, …) and the ported share packages (core/share_*.mbt).
      • core/gen_*.mbt — generated by tools/gen.py / tools/gen_init.py from the Lisp sources: a declare fn for every Lisp function (the contract every translated file implements), symbol constants, function registration and initialization in SBCL's load order.
    • slatec/, lbfgs/, odepack/, lapack/, minpack/, cobyla/, fftpack5/, hompack/, colnew/, f2cl/ — the Fortran numerical libraries Maxima ships as f2cl-generated Lisp, translated mechanically by tools/f2cl2mbt.py and checked bit-for-bit against SBCL.
    • cmd/main/ — the command-line program.
    • tools/ — the source analyzer/generators, test runners (rtests.py, difftest.py, rtest_problem.py) and a reference Maxima built from the same source (maxima-ref).
    • docs/ — porting conventions (PORTING.md), debugging guide (FIXING.md), APIs of the bigfloat layer (BIGFLOAT.md) and SLATEC (SLATEC.md), test status, and known follow-ups (FOLLOWUPS.md).

    #Testing

    python3 tools/rtests.py # core test suite, one process per file python3 tools/rtests.py --share # share-package test suite python3 tools/rtests.py --check # fail on any file below docs/TESTS.md (CI) python3 tools/difftest.py 'expr;' ... # compare with the reference Maxima moon test # runtime, numerics and evaluator unit tests

    #License

    GPL-2.0, as Maxima.