org.mentat/emmy

The Emmy Computer Algebra System.

https://github.com/mentat-collective/emmy

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.5%) to scientific vocabulary

Keywords

automatic-differentiation calculus clojure clojurescript computer-algebra differential-geometry explorable-explanations hamiltonian lagrangian-mechanics mathematics physics physics-simulation sussman symbolic-math
Last synced: 4 months ago · JSON representation ·

Repository

The Emmy Computer Algebra System.

Basic Info
  • Host: GitHub
  • Owner: mentat-collective
  • License: gpl-3.0
  • Language: Clojure
  • Default Branch: main
  • Homepage: https://emmy.mentat.org
  • Size: 10.7 MB
Statistics
  • Stars: 440
  • Watchers: 10
  • Forks: 25
  • Open Issues: 106
  • Releases: 0
Topics
automatic-differentiation calculus clojure clojurescript computer-algebra differential-geometry explorable-explanations hamiltonian lagrangian-mechanics mathematics physics physics-simulation sussman symbolic-math
Created about 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Funding License Citation

README.md

Emmy logo

[![Build Status][build-status]][build-status-url] [![License][license]][license-url] [![Codecov branch][codecov]][codecov-url] [![cljdoc badge][cljdoc]][cljdoc-url] [![Clojars Project][clojars]][clojars-url] [![Discord Shield][discord]][discord-url]

Emmy is a Clojure(Script) implementation of the scmutils system for math and physics investigations in the Clojure and ClojureScript languages. Emmy provides facilities for

And implementations of many different mathematical objects, all built on a tower of generic, extensible mathematical operations.

Scmutils is extensively used in the textbooks The Structure and Interpretation of Classical Mechanics and Functional Differential Geometry by G.J. Sussman and J. Wisdom.

:wave: Need help getting started? Say hi on Clojurians Slack in #emmy.

Quickstart

Note Emmy is best experienced in an interactive environment like the REPL. We support many environments with rich support for TeX rendering and plotting.

Install Emmy into your Clojure(Script) project using the instructions at its Clojars page:

Clojars Project

Or grab the most recent code using a Git dependency:

clj ;; Replace $GIT_SHA with the most recent commit: {io.github.mentat-collective/emmy {:git/sha "$GIT_SHA"}}

Require emmy.env in your Clojure(Script) namespace:

clj (ns my-app (:require [emmy.env :as e :refer :all]))

Or clone this repository:

sh git clone git@github.com:mentat-collective/emmy.git cd emmy

then install the Clojure command line tool and run the following command to launch a REPL with emmy.env already loaded:

sh clj -M:test:dev:repl

Math works as expected (see Generics for the full menu of operations), but notice that the numeric tower includes complex numbers, and proper ratios in ClojureScript:

```clj (- (* 7 (/ 1 2)) 2) ;;=> 3/2

(asin -10) ;;=> #emmy/complex [-1.5707963267948966 2.9932228461263786] ```

Symbols are interpreted as abstract complex numbers, and arithmetic on them generates symbolic expressions. You can render these with ->TeX and ->infix:

```clojure (def render (comp ->infix simplify))

(square (sin (+ 'a 3))) ;;=> (expt (sin (+ a 3)) 2)

(render (square (sin (+ 'a 3)))) ;;=> "sin(a + 3)" ```

Use the D operator to perform forward-mode automatic differentiation and simplify to collapse symbolic expressions into tidy form:

```clojure ((D cube) 'x) ;;=> (+ (* x (+ x x)) (* x x))

(simplify ((D cube) 'x)) ;;=> (* 3 (expt x 2))

(->infix (simplify ((D cube) 'x))) ;;-> "3 x" ```

Emmy is based on the engine behind The Structure and Interpretation of Classical Mechanics, and has a built-in API for exploring Lagrangian and Hamiltonian mechanics.

Define a Lagrangian for a central potential U acting on a particle with mass m:

clojure (defn L-central-polar [m U] (fn [[_ [r] [rdot thetadot]]] (- (* 1/2 m (+ (square rdot) (square (* r thetadot)))) (U r))))

and generate the two Euler-Lagrange equations of motion for the r and theta coordinates:

clojure (let [potential-fn (literal-function 'U) L (L-central-polar 'm potential-fn) state (up (literal-function 'r) (literal-function 'theta))] (render (((Lagrange-equations L) state) 't))) ;;=> "down(- m r(t) (D(t)) + m Dr(t) + DU(r(t)), m (r(t)) D(t) + 2 m r(t) Dr(t) D(t))"

There is so much more! This is a dense library, and lots of documentation remains to be written. Some suggested next steps, for now:

Clerk Support

If you want to use Emmy with Clerk, check out the emmy/clerk template. This deps-new template will generate a Clerk project for you, fully configured to use Emmy in your Clerk notebooks.

Interactive Documentation via Clerk

The project's interactive documentation was generated using Nextjournal's Clerk. If you'd like to edit or play with the documentation, you'll need to install

Next, clone the repository:

bash git clone git@github.com:mentat-collective/emmy.git cd emmy

Run this command in the cloned repository:

sh bb clerk-watch

This will open a browser window to http://localhost:7777 with the contents of the documentation notebook. Any edits you make to dev/emmy/notebook.clj will be picked up and displayed in the browser on save.

Background

SICM and FDG can be thought of as spiritual successors to The Structure and Interpretation of Computer Programs, a very influential textas I can attest, since carefully reading this book in my 30s changed my life as a programmer. To see the same techniques applied to differential geometry and physics is an irresistible lure.

Scmutils is an excellent system, but it is written in an older variant of LISP (Scheme) and is tied to a particular implementation of SchemeMIT/GNU Scheme. (There is a port to Guile, but due to the fact that Guile does not support MIT Scheme's apply hooks some glue code is required to run examples from the book in that environment.)

Having the system in Clojure offers a number of advantages. It is not necessary to obtain or prepare a MIT/GNU Scheme executable to execute: only a Java runtime is required. It does not require the X Window System for graphics, as MIT Scheme does. All of the standard tooling for Java and Clojure become available, and this is a lot compared to what we get with MIT/GNU scheme. Clojure support is now extensive in any number of editors and IDEs. Even better, you can interact with the system in the context of a Jupyter notebook.

You can invoke the system from within Java or JavaScript code or use any Java or JS packages you like together with the mathematics system. It's my hope that continuing this project will extend the reach of SICM and FDG by allowing experimentation and collaboration with them in modern environments.

Citing Emmy

To cite this repository, see the "Cite this Repository" link on the top right of the Github page. Citation information is generated from CITATION.cff.

Here is the generated BibTeX entry:

@software{Ritchie_Emmy_Functional_Computer_2016}, author = {Ritchie, Sam and Smith, Colin}, license = {GPL-3.0}, month = {4}, title = {{Emmy: Functional Computer Algebra in Clojure}}, url = {https://github.com/mentat-collective/emmy}, version = {0.32.0}, year = {2016}

In the above BibTeX entry, the version number is intended to be that from resources/EMMY_VERSION, and the year corresponds to the project's open-source release.

License

Copyright 2016-2024 Colin Smith, Sam Ritchie.

Distributed under the GPL v3 license. See LICENSE.

Owner

  • Name: Mentat Collective
  • Login: mentat-collective
  • Kind: organization
  • Location: United States of America

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Ritchie"
  given-names: "Sam"
  orcid: "https://orcid.org/0000-0002-0545-6360"
- family-names: "Smith"
  given-names: "Colin"
title: "Emmy: Functional Computer Algebra in Clojure"
version: 0.23.0
date-released: 2016
type: software
url: "https://github.com/mentat-collective/emmy"
license: GPL-3.0
license-url: "https://www.gnu.org/licenses/gpl-3.0.en.html"
repository-code: "https://github.com/mentat-collective/emmy"

GitHub Events

Total
  • Issues event: 103
  • Watch event: 44
  • Issue comment event: 10
  • Push event: 3
  • Pull request event: 4
  • Fork event: 4
  • Create event: 2
Last Year
  • Issues event: 103
  • Watch event: 44
  • Issue comment event: 10
  • Push event: 3
  • Pull request event: 4
  • Fork event: 4
  • Create event: 2

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 1,168
  • Total Committers: 21
  • Avg Commits per committer: 55.619
  • Development Distribution Score (DDS): 0.36
Past Year
  • Commits: 12
  • Committers: 3
  • Avg Commits per committer: 4.0
  • Development Distribution Score (DDS): 0.167
Top Committers
Name Email Commits
Colin Smith c****h@g****m 748
Sam Ritchie s****9@g****m 207
Sam Ritchie s****e@g****m 182
alexgian a****n@b****k 5
Martin Kavalar mk@k****m 3
Simon Whalen s****n@g****m 3
Henrique Carvalho Alves h****s@g****m 3
Michiel Borkent m****t@g****m 2
SxP s****i 2
kloimhardt m****n@g****t 2
yuhan0 q****m@g****m 1
Aaron Steele e****e@g****m 1
Adam Haber a****r@g****m 1
Blake Miller b****r@g****m 1
Darrick Wiebe d****w@u****i 1
Ingy döt Net i****y@i****t 1
Jonas Emanuel Müller z****i@z****t 1
Stephen C. Gilardi s****i@g****m 1
Teodor Heggelund t****u 1
Yang Le y****5@q****m 1
Zane Shelby z****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 83
  • Total pull requests: 78
  • Average time to close issues: over 1 year
  • Average time to close pull requests: 16 days
  • Total issue authors: 14
  • Total pull request authors: 9
  • Average comments per issue: 1.23
  • Average comments per pull request: 1.4
  • Merged pull requests: 54
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: 29 minutes
  • Issue authors: 5
  • Pull request authors: 3
  • Average comments per issue: 0.2
  • Average comments per pull request: 0.67
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sritchie (63)
  • light-matters (6)
  • alexgian (2)
  • littleredcomputer (2)
  • sdedovic (1)
  • withjak (1)
  • benjamin-asdf (1)
  • vxe (1)
  • maacl (1)
  • hierophantos (1)
  • khinsen (1)
  • kloimhardt (1)
  • teodorlu (1)
  • Hendekagon (1)
Pull Request Authors
  • sritchie (75)
  • littleredcomputer (11)
  • mhuebert (3)
  • eightysteele (2)
  • ingydotnet (2)
  • kloimhardt (2)
  • yang-le (2)
  • yuhan0 (2)
  • alexgian (1)
Top Labels
Issue Labels
enhancement (13) bug (3)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • clojars 5,513 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
clojars.org: org.mentat/emmy

The Emmy Computer Algebra System.

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 5,513 Total
Rankings
Dependent packages count: 7.9%
Stargazers count: 15.1%
Dependent repos count: 25.9%
Average: 37.7%
Forks count: 40.1%
Downloads: 99.5%
Maintainers (1)
Last synced: 5 months ago

Dependencies

.github/workflows/cljs.yaml actions
  • DeLaGuardo/setup-clojure master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-java v2 composite
  • actions/setup-node v2 composite
.github/workflows/coverage.yml actions
  • DeLaGuardo/setup-clojure master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-java v2 composite
  • codecov/codecov-action v1 composite
.github/workflows/kondo.yml actions
  • DeLaGuardo/setup-clojure master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-java v2 composite
  • just-sultanov/setup-babashka v2 composite
.github/workflows/release.yml actions
  • DeLaGuardo/setup-clojure master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-java v2 composite
.github/workflows/workflow.yml actions
  • DeLaGuardo/setup-clojure master composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-java v2 composite
  • just-sultanov/setup-babashka v2 composite
package.json npm
  • markdown-it 12.3.2 development
  • markdown-it-block-image 0.0.3 development
  • markdown-it-sidenote github:gerwitz/markdown-it-sidenote development
  • markdown-it-texmath 0.9.1 development
  • markdown-it-toc-done-right 4.2.0 development
  • source-map-support ^0.5.20 development
  • complex.js ^2.0.11
  • fraction.js ^4.0.12
  • odex ^2.0.4
  • shadow-cljs 2.20.14
.github/workflows/gh-pages.yml actions
  • DeLaGuardo/setup-clojure 4.0 composite
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • just-sultanov/setup-babashka v2 composite
  • peaceiris/actions-gh-pages v3 composite
resources/emmy/clerk/root/package.json npm
  • gh-pages ^3.2.3 development