{"id":13568550,"url":"https://github.com/mentat-collective/emmy","last_synced_at":"2025-05-14T23:04:34.719Z","repository":{"id":65442018,"uuid":"563976455","full_name":"mentat-collective/emmy","owner":"mentat-collective","description":"The Emmy Computer Algebra System.","archived":false,"fork":false,"pushed_at":"2024-10-29T17:29:17.000Z","size":11188,"stargazers_count":425,"open_issues_count":105,"forks_count":26,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-13T12:51:10.722Z","etag":null,"topics":["automatic-differentiation","calculus","clojure","clojurescript","computer-algebra","differential-geometry","explorable-explanations","hamiltonian","lagrangian-mechanics","mathematics","physics","physics-simulation","sussman","symbolic-math"],"latest_commit_sha":null,"homepage":"https://emmy.mentat.org","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mentat-collective.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"sritchie"}},"created_at":"2022-11-09T18:21:51.000Z","updated_at":"2025-05-01T11:32:38.000Z","dependencies_parsed_at":"2023-09-24T07:17:09.938Z","dependency_job_id":"de6052e1-d3b6-4d75-9b05-ceddfa16a92b","html_url":"https://github.com/mentat-collective/emmy","commit_stats":{"total_commits":1149,"total_committers":20,"mean_commits":57.45,"dds":"0.34899912967798086","last_synced_commit":"13dda79d30e520c91951d32005be3ce819e35d4b"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mentat-collective%2Femmy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mentat-collective%2Femmy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mentat-collective%2Femmy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mentat-collective%2Femmy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mentat-collective","download_url":"https://codeload.github.com/mentat-collective/emmy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243358,"owners_count":22038046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automatic-differentiation","calculus","clojure","clojurescript","computer-algebra","differential-geometry","explorable-explanations","hamiltonian","lagrangian-mechanics","mathematics","physics","physics-simulation","sussman","symbolic-math"],"created_at":"2024-08-01T14:00:28.026Z","updated_at":"2025-05-14T23:04:29.698Z","avatar_url":"https://github.com/mentat-collective.png","language":"Clojure","funding_links":["https://github.com/sponsors/sritchie"],"categories":["Clojure"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mentat-collective/emmy/main/doc/img/logo.png\" width=\"250\" alt=\"Emmy logo\" title=\"Emmy\" /\u003e\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status][build-status]][build-status-url]\n[![License][license]][license-url]\n[![Codecov branch][codecov]][codecov-url]\n[![cljdoc badge][cljdoc]][cljdoc-url]\n[![Clojars Project][clojars]][clojars-url]\n[![Discord Shield][discord]][discord-url]\n\n\u003c/div\u003e\n\nEmmy is a Clojure(Script) implementation of the [scmutils][scmutils-refman-url]\nsystem for math and physics investigations in the Clojure and ClojureScript\nlanguages. Emmy provides facilities for\n\n- [symbolic\n  computation](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/data-types/symbolic-expressions),\n  including state of the art TeX rendering and [expression\n  simplification](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/simplification)\n- [automatic](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/calculus/automatic-differentiation),\n  [numerical](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/numerical-methods/numerical-derivative)\n  and\n  [symbolic](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/calculus/automatic-differentiation)\n  differentiation\n- [numerical integration and\n  optimization](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/numerical-methods)\n- investigations in [differential\n  geometry](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/textbooks/functional-differential-geometry)\n  and [Lagrangian and Hamiltonian\n  mechanics](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/textbooks/structure-and-interpretation-of-classical-mechanics)\n\nAnd implementations of many different [mathematical\nobjects](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/data-types), all built\non a tower of [generic, extensible mathematical\noperations](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/basics/generics).\n\nScmutils is extensively used in the textbooks [The Structure and Interpretation\nof Classical Mechanics][sicm-book-url] and [Functional Differential\nGeometry][fdg-book-url] by G.J. Sussman and J. Wisdom.\n\n\u003e :wave: Need help getting started? Say hi on [Clojurians\n\u003e Slack](http://clojurians.net/) in [#emmy][emmy-slack-url].\n\n## Quickstart\n\n\u003e **Note**\n\u003e Emmy is best experienced in an interactive environment like the\n\u003e [REPL](https://clojure.org/guides/repl/introduction). We [support many\n\u003e environments](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/basics/how-to-use-emmy)\n\u003e with rich support for [TeX](https://en.wikipedia.org/wiki/TeX) rendering and\n\u003e plotting.\n\nInstall `Emmy` into your Clojure(Script) project using the instructions at its\nClojars page:\n\n[![Clojars Project][clojars]][clojars-url]\n\nOr grab the most recent code using a Git dependency:\n\n```clj\n;; Replace $GIT_SHA with the most recent commit:\n{io.github.mentat-collective/emmy\n  {:git/sha \"$GIT_SHA\"}}\n```\n\nRequire `emmy.env` in your Clojure(Script) namespace:\n\n```clj\n(ns my-app\n  (:require [emmy.env :as e :refer :all]))\n```\n\nOr clone this repository:\n\n```sh\ngit clone git@github.com:mentat-collective/emmy.git\ncd emmy\n```\n\nthen install [the Clojure command line\ntool](https://clojure.org/guides/install_clojure) and run the following command\nto launch a REPL with `emmy.env` already loaded:\n\n```sh\nclj -M:test:dev:repl\n```\n\nMath works as expected (see\n[Generics](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/basics/generics) for\nthe full menu of operations), but notice that the numeric tower includes\n[complex\nnumbers](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/data-types/complex),\nand proper ratios in ClojureScript:\n\n```clj\n(- (* 7 (/ 1 2)) 2)\n;;=\u003e 3/2\n\n(asin -10)\n;;=\u003e #emmy/complex [-1.5707963267948966 2.9932228461263786]\n```\n\nSymbols are interpreted as abstract complex numbers, and arithmetic on them\ngenerates symbolic expressions. You can render these with\n[`-\u003eTeX`](https://cljdoc.org/d/org.mentat/emmy/CURRENT/api/emmy.expression.render#-\u003eTeX)\nand\n[`-\u003einfix`](https://cljdoc.org/d/org.mentat/emmy/CURRENT/api/emmy.expression.render#-\u003einfix):\n\n```clojure\n(def render (comp -\u003einfix simplify))\n\n(square (sin (+ 'a 3)))\n;;=\u003e (expt (sin (+ a 3)) 2)\n\n(render (square (sin (+ 'a 3))))\n;;=\u003e \"sin²(a + 3)\"\n```\n\nUse the\n[`D`](https://cljdoc.org/d/org.mentat/emmy/CURRENT/api/emmy.calculus.derivative#D)\noperator to perform [forward-mode automatic\ndifferentiation](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/calculus/automatic-differentiation)\nand\n[`simplify`](https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/simplification) to\ncollapse symbolic expressions into tidy form:\n\n```clojure\n((D cube) 'x)\n;;=\u003e  (+ (* x (+ x x)) (* x x))\n\n(simplify ((D cube) 'x))\n;;=\u003e (* 3 (expt x 2))\n\n(-\u003einfix\n (simplify ((D cube) 'x)))\n;;-\u003e \"3 x²\"\n```\n\nEmmy is based on the engine behind [The Structure and Interpretation of\nClassical Mechanics][sicm-book-url], and has a built-in API for exploring\nLagrangian and Hamiltonian mechanics.\n\nDefine a [Lagrangian](https://en.wikipedia.org/wiki/Lagrangian_mechanics) for a\ncentral potential `U` acting on a particle with mass `m`:\n\n```clojure\n(defn L-central-polar [m U]\n  (fn [[_ [r] [rdot thetadot]]]\n    (- (* 1/2 m\n          (+ (square rdot)\n             (square (* r thetadot))))\n       (U r))))\n```\n\nand generate the two [Euler-Lagrange equations of\nmotion](https://en.wikipedia.org/wiki/Lagrangian_mechanics#Euler–Lagrange_equations_and_Hamilton's_principle)\nfor the `r` and `theta` coordinates:\n\n```clojure\n(let [potential-fn (literal-function 'U)\n      L     (L-central-polar 'm potential-fn)\n      state (up (literal-function 'r)\n                (literal-function 'theta))]\n  (render\n   (((Lagrange-equations L) state) 't)))\n;;=\u003e \"down(- m r(t) (Dθ(t))² + m D²r(t) + DU(r(t)), m (r(t))² D²θ(t) + 2 m r(t) Dr(t) Dθ(t))\"\n```\n\nThere is so much more! This is a dense library, and lots of documentation\nremains to be written. Some suggested next steps, for now:\n\n- Open up the live, interactive [Emmy tutorial on\n  Nextjournal](https://nextjournal.com/try/samritchie/sicmutils), play with the\n  examples above and start to explore on your own.\n- Read the [Emmy Reference Manual][refman-url] (\"refman\") for inspiration. All\n  of the code snippets in the refman will work in the [Nextjournal\n  environment](https://nextjournal.com/try/samritchie/sicmutils). Use the two\n  together.\n- Visit our [CLJDocs][cljdoc-url] page for an introduction and detailed\n  documentation\n- Watch Colin's [\"Physics in Clojure\"][physics-in-clj-talk-url] talk for an overview\n  of Emmy and its implementation\n- Watch Sam's [\"Emmy: Moldable Physics and Lispy Microworlds\"][emmy-talk-url]\n  talk for the motivation behind the visual extensions to Emmy\n- Visit the HTML version of [Structure and Interpretation of Classical\n  Mechanics](https://tgvaughan.github.io/sicm/). Many of the SICM exercises have\n  been worked using Emmy; they live at [this Nextjournal\n  page](https://nextjournal.com/sicm).\n\n## Clerk Support\n\nIf you want to use `Emmy` with [Clerk][clerk-url], check out the [`emmy/clerk`\ntemplate][emmy-clerk-template-url]. This [`deps-new`][deps-new-url] template\nwill generate a Clerk project for you, fully configured to use `Emmy` in your\nClerk notebooks.\n\n## Interactive Documentation via Clerk\n\nThe project's [interactive documentation](https://emmy.mentat.org) was generated\nusing Nextjournal's [Clerk][clerk-url]. If you'd like to edit or play with the\ndocumentation, you'll need to install\n\n- [node.js](https://nodejs.org/en/)\n- The [Clojure command line tool](https://clojure.org/guides/install_clojure)\n- [Babashka](https://github.com/babashka/babashka#installation)\n\nNext, clone the repository:\n\n```bash\ngit clone git@github.com:mentat-collective/emmy.git\ncd emmy\n```\n\nRun this command in the cloned repository:\n\n```sh\nbb clerk-watch\n```\n\nThis will open a browser window to `http://localhost:7777` with the contents of\nthe documentation notebook. Any edits you make to `dev/emmy/notebook.clj`\nwill be picked up and displayed in the browser on save.\n\n## Background\n\n[SICM][sicm-book-url] and [FDG][fdg-book-url] can be thought of as spiritual\nsuccessors to [The Structure and Interpretation of Computer\nPrograms][sicp-book-url], a very influential text—as I can attest, since\ncarefully reading this book in my 30s changed my life as a programmer. To see\nthe same techniques applied to differential geometry and physics is an\nirresistible lure.\n\nScmutils is an excellent system, but it is written in an older variant of LISP\n(Scheme) and is tied to a particular implementation of Scheme—MIT/GNU Scheme.\n(There is a [port to Guile][gscm-url], but due to the fact that Guile does not\nsupport MIT Scheme's [apply\nhooks](https://www.gnu.org/software/mit-scheme/documentation/stable/mit-scheme-ref/Application-Hooks.html)\nsome glue code is required to run examples from the book in that environment.)\n\nHaving the system in Clojure offers a number of advantages. It is not necessary\nto obtain or prepare a MIT/GNU Scheme executable to execute: only a Java runtime\nis required. It does not require the X Window System for graphics, as MIT Scheme\ndoes. All of the standard tooling for Java and Clojure become available, and\nthis is a lot compared to what we get with MIT/GNU scheme. Clojure support is\nnow extensive in any number of editors and IDEs. Even better, you can interact\nwith the system in the context of a [Jupyter notebook](./jupyter).\n\nYou can invoke the system from within Java or JavaScript code or use any Java or\nJS packages you like together with the mathematics system. It's my hope that\ncontinuing this project will extend the reach of SICM and FDG by allowing\nexperimentation and collaboration with them in modern environments.\n\n## Citing Emmy\n\nTo cite this repository, see the \"Cite this Repository\" link on the top right of\nthe Github page. Citation information is generated from\n[`CITATION.cff`](CITATION.cff).\n\nHere is the generated BibTeX entry:\n\n```\n@software{Ritchie_Emmy_Functional_Computer_2016},\nauthor = {Ritchie, Sam and Smith, Colin},\nlicense = {GPL-3.0},\nmonth = {4},\ntitle = {{Emmy: Functional Computer Algebra in Clojure}},\nurl = {https://github.com/mentat-collective/emmy},\nversion = {0.32.0},\nyear = {2016}\n```\n\nIn the above BibTeX entry, the version number is intended to be that from\n[resources/EMMY_VERSION](./resources/EMMY_VERSION), and the year corresponds to\nthe project's open-source release.\n\n## License\n\nCopyright © 2016-2024 Colin Smith, Sam Ritchie.\n\nDistributed under the [GPL v3](LICENSE) license. See [LICENSE](LICENSE).\n\n[build-status-url]: https://github.com/mentat-collective/emmy/actions?query=workflow%3A%22Clojure+CI%22\n[build-status]: https://github.com/mentat-collective/emmy/workflows/Clojure%20CI/badge.svg?branch=main\n[clerk-url]: https://clerk.vision\n[cljdoc-url]: https://cljdoc.org/d/org.mentat/emmy/CURRENT\n[cljdoc]: https://cljdoc.org/badge/org.mentat/emmy\n[clojars-url]: https://clojars.org/org.mentat/emmy\n[clojars]: https://img.shields.io/clojars/v/org.mentat/emmy.svg\n[codecov-url]: https://codecov.io/github/mentat-collective/emmy\n[codecov]: https://img.shields.io/codecov/c/github/mentat-collective/emmy/main.svg?maxAge=3600\n[deps-new-url]: https://github.com/seancorfield/deps-new\n[discord-url]: https://discord.gg/hsRBqGEeQ4\n[discord]: https://img.shields.io/discord/731131562002743336?style=flat\u0026colorA=000000\u0026colorB=000000\u0026label=\u0026logo=discord\n[emmy-clerk-template-url]: https://github.com/mentat-collective/emmy/tree/main/resources/emmy/clerk\n[emmy-slack-url]: https://clojurians.slack.com/archives/C01ECA9AA74\n[emmy-talk-url]: https://www.youtube.com/watch?v=B9kqD8vBuwU\n[fdg-book-url]: https://mitpress.mit.edu/9780262019347/functional-differential-geometry/\n[gscm-url]: http://www.cs.rochester.edu/~gildea/guile-scmutils/\n[license-url]: LICENSE\n[license]: https://img.shields.io/badge/license-GPLv3-brightgreen.svg\n[physics-in-clj-talk-url]: https://www.youtube.com/watch?v=7PoajCqNKpg\n[refman-url]: https://cljdoc.org/d/org.mentat/emmy/CURRENT/doc/reference-manual\n[scmutils-refman-url]: https://groups.csail.mit.edu/mac/users/gjs/6946/refman.txt\n[sicm-book-url]: https://mitpress.mit.edu/9780262028967/structure-and-interpretation-of-classical-mechanics/\n[sicp-book-url]: https://mitpress.mit.edu/9780262510875/structure-and-interpretation-of-computer-programs/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmentat-collective%2Femmy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmentat-collective%2Femmy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmentat-collective%2Femmy/lists"}