{"id":29744675,"url":"https://github.com/frogrocketlabs/sicm-scheme-exercises","last_synced_at":"2025-08-21T03:16:55.795Z","repository":{"id":32604444,"uuid":"36189006","full_name":"frogrocketlabs/sicm-scheme-exercises","owner":"frogrocketlabs","description":"Exercises and notes on Structure and Interpretation of Classical Mechanics.","archived":false,"fork":false,"pushed_at":"2022-03-22T09:02:07.000Z","size":13085,"stargazers_count":69,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-26T10:04:47.469Z","etag":null,"topics":["classical-mechanics","lagrangian-mechanics","physics","sicm"],"latest_commit_sha":null,"homepage":null,"language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"python-attrs/attrs","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frogrocketlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"sritchie"}},"created_at":"2015-05-24T19:27:14.000Z","updated_at":"2025-06-30T17:25:51.000Z","dependencies_parsed_at":"2022-08-07T17:46:03.656Z","dependency_job_id":null,"html_url":"https://github.com/frogrocketlabs/sicm-scheme-exercises","commit_stats":null,"previous_names":["sicmutils/sicm-exercises","frogrocketlabs/sicm-scheme-exercises"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frogrocketlabs/sicm-scheme-exercises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frogrocketlabs%2Fsicm-scheme-exercises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frogrocketlabs%2Fsicm-scheme-exercises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frogrocketlabs%2Fsicm-scheme-exercises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frogrocketlabs%2Fsicm-scheme-exercises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frogrocketlabs","download_url":"https://codeload.github.com/frogrocketlabs/sicm-scheme-exercises/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frogrocketlabs%2Fsicm-scheme-exercises/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271420155,"owners_count":24756491,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["classical-mechanics","lagrangian-mechanics","physics","sicm"],"created_at":"2025-07-26T05:31:55.617Z","updated_at":"2025-08-21T03:16:55.779Z","avatar_url":"https://github.com/frogrocketlabs.png","language":"Scheme","funding_links":["https://github.com/sponsors/sritchie"],"categories":[],"sub_categories":[],"readme":"## Structure and Interpretation of Classical Mechanics\n\nWelcome to my solution and notes repository for Sussman and Wisdom's [The\nStructure and Interpretation of Classical Mechanics](https://amzn.to/2LUx62M).\nYou can get a copy of the book on [Amazon](https://amzn.to/2LUx62M), or follow\nalong using this beautiful [HTML version](https://tgvaughan.github.io/sicm/).\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/69635/82737469-6478a880-9cee-11ea-9559-aa0e85a60a5c.png\" alt=\"SICM Cover\"/\u003e\n\u003c/p\u003e\n\n\nI'm working through the exercises for each chapter using [MIT\nScheme](https://www.gnu.org/software/mit-scheme/), and the `scmutils` library\n(also called `mechanics` by the authors and me) that Sussman and Wisdom\ndeveloped for the textbook.\n\nEach chapter gets its own folder, named `ch1`, `ch2`, etc. Inside each folder\nI've included a file for each exercise that required code or benefited from\nexploration in Scheme.\n\nI've also worked hard to make sure that it's easy for *you* to run any of this\ncode, and recreate my work in any of the exercises. I've provided a working copy\nof the `mechanics` library in this repository in `bin/mechanics`. There's a\nsmall amount of work you'll have to do to make the script run, but I've covered\nthat below under [\"Running the Code\"](#running-the-code).\n\n## The Road to Reality\n\nIf you like this sort of thing, you might also consider subscribing to [\"The\nRoad to Reality\"](https://roadtoreality.substack.com/), a newsletter where I\npost primers and lessons on interesting topics in math, physics, machine\nlearning or artificial intelligence, with a heavy emphasis on locking down the\nintuition behind the ideas over mere symbol shuffling.\n\nCheck it out here: https://roadtoreality.substack.com\n\n## Other SICM Resources\n\n- The [course website](https://groups.csail.mit.edu/mac/users/gjs/6946/) for\n  MIT's 6.946, [\"Classical Mechanics: A Computational\n  Approach\"](https://groups.csail.mit.edu/mac/users/gjs/6946/). This is a\n  graduate level course in classical mechanics that uses this textbook. The\n  course page has excellent materials, links to errata, all the goods.\n- [Errata for the 2nd edition of\n  SICM](http://groups.csail.mit.edu/mac/users/gjs/6946/errata.pdf). I've found\n  some more, which I'll add to this page as I go.\n- [The SICM Textbook on Amazon](https://amzn.to/2LUx62M)\n- [Beautiful HTML version of the SICM\n  Textbook](https://tgvaughan.github.io/sicm/). You have to read this!\n- [MIT OpenCourseware page for the Fall 2008 version of the\n  course](https://ocw.mit.edu/courses/earth-atmospheric-and-planetary-sciences/12-620j-classical-mechanics-a-computational-approach-fall-2008/index.htm).\n  This uses the first edition of the textbook. I haven't gone through this page\n  in any detail.\n- [Documentation for `scmutils`, aka\n  `mechanics`](https://github.com/Tipoca/scmutils/blob/master/manual/refman.txt)\n- [SICMUtils](https://github.com/littleredcomputer/sicmutils) a Clojure\n  implementation of the `scmutils` / `mechanics` library. Clojure is brilliant.\n  I may include some examples of code using this library as I go.\n- My Dockerhub pages for the\n  [`mit-scheme`](https://hub.docker.com/r/sritchie/mit-scheme)\n  and [`mechanics`](https://hub.docker.com/r/sritchie/mechanics)\n  Docker images.\n\n## Running Mechanics\n\nYou can interact with any of the utilities or solutions I've written using the\n`bin/mechanics` program in this repository. `bin/mechanics` holds a full,\nworking installation of `mechanics` and MIT Scheme, packaged up inside of a\nDocker container. To make this work, you'll need, at minimum, a working\ninstallation of [Docker](https://www.docker.com/).\n\nIf you want to see graphics (which of course you do!), you'll need an X11 window\nsystem installed. For LaTeX rendering, you'll need the `xdvi` program, which\ncomes with installations of [LaTeX](https://www.latex-project.org/get/).\n\n### OS X Prerequisites\n\nIf you're on a Mac, install [Docker Desktop for\nMac](https://hub.docker.com/editions/community/docker-ce-desktop-mac/) by\nclicking the \"Get Docker\" button on the right side of that page.\n\n[XQuartz](https://www.xquartz.org/) will cover the X11 requirement. Download the\nfile [here](https://www.xquartz.org/) and install it in the usual way.\n\nFinally, install [MacTeX](https://tug.org/mactex/mactex-download.html) and\nafterward make sure that typing `xdvi` at the terminal makes something happen.\n\nOnce you have XQuartz and MacTeX installed, you'll need to configure it to let\n`bin/mechanics` make graphics on your computer from inside the Docker container\nwhere it runs. To set this up,\n\n- launch XQuartz from `/Applications/Utilities/Xquartz`,\n- go into the Preferences menu and navigate to the Security tab\n- make sure that both \"Authenticate Connections\" and \"Allow connections from\n  network clients** is checked\n\n### Linux Prerequisites\n\n[This page](https://docs.docker.com/engine/install/ubuntu/) has a nice guide on\nhow to get Docker installed on Linux. I think the X11 requirement might just\nwork? If you try this, please let me know, or send a PR updating this README.\n\nThe [LaTeX Project](https://www.latex-project.org/get/) main page describes how\nto get LaTeX on Linux. They recommend installing the [TeX\nLive](https://www.tug.org/texlive/) distribution.\n\n### Starting a REPL\n\nOnce you have Docker installed and running, clone this repository onto your machine,\nnavigate into the folder and run `bin/mechanics`:\n\n```\ngit clone https://github.com/sritchie/sicm.git \u0026\u0026 cd sicm\nbin/mechanics\n```\n\nThe first time you run this it should take a while, as you'll have to download\nall of the Docker image requirements. Eventually you'll see an MIT Scheme REPL\nwith the whole `mechanics` library loaded:\n\n```\n127.0.0.1 being added to access control list\nMIT/GNU Scheme running under GNU/Linux\nType `^C' (control-C) followed by `H' to obtain information about interrupts.\n\nCopyright (C) 2019 Massachusetts Institute of Technology\nThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nImage saved on Friday August 30, 2019 at 11:20:36 PM\n  Release 10.1.10 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || SOS 1.8 || XML 1.0 || Edwin 3.117 || X11 1.3 || X11-Screen 1.0 || ScmUtils Mechanics.Summer 2019\n\n1 ]=\u003e\n```\n\nGo ahead and try evaluating some Lisp, using functions from the `mechanics` library:\n\n```scheme\n1 ]=\u003e (square (up 'x 'y 'z))\n#|\n(+ (expt x 2) (expt y 2) (expt z 2))\n|#\n```\n\nYou're all set!\n\n### Testing Graphics via X11\n\nIf you set up XQuartz / X11, you should be able to get LaTeX expressions printing.\n\nTo test this out, run the `bin/mechanics` script and try entering an expression\nlike `(show-expression (+ 'alpha 't))` at the REPL.\n\n```\n$ bin/mechanics\n127.0.0.1 being added to access control list\nMIT/GNU Scheme running under GNU/Linux\nType `^C' (control-C) followed by `H' to obtain information about interrupts.\n\nCopyright (C) 2019 Massachusetts Institute of Technology\nThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nImage saved on Friday August 30, 2019 at 11:20:36 PM\n  Release 10.1.10 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || SOS 1.8 || XML 1.0 || Edwin 3.117 || X11 1.3 || X11-Screen 1.0 || ScmUtils Mechanics.Summer 2019\n\n1 ]=\u003e (show-expression (+ 'alpha 't))\n(+ alpha t)\n```\n\nYou should see a window pop up in XQuartz with a nicely rendered LaTeX\nexpression:\n\n![](https://user-images.githubusercontent.com/69635/82736715-05646500-9ce9-11ea-9227-4db5fee32eb6.png)\n\n\nThe REPL will hang until you close the XQuartz window, so go ahead and do that\nnow.\n\n## Running the Exercises\n\nThe exercises for each chapter live in their own folder, named `ch1`, `ch2`,\netc. Inside each folder I've included a file for each exercise that required\ncode or benefited from exploration in Scheme.\n\nYou can run any code in these folders by starting the REPL `bin/mechanics` from\nthe repository root folder, and calling, for example:\n\n```scheme\n(load \"ch1/ex1-29.scm\")\n```\n\nThis will execute all code in the file located at `ch1/ex1-29.scm`, including\nall side effects and graphics that the file generated. If you see LaTeX\nexpressions pop up, you'll have to close each one to move to the next one.\n\n## Emacs Integration\n\nIf you want to interact more heavily with the code, add more exercises and work\non it yourself, I suggest you switch to a proper text editor with nice support\nfor Scheme. I use [Emacs](https://emacsformacosx.com/), specifically\n[Spacemacs](https://samritchie.io/moving-to-spacemacs-for-scala-and-python/),\nthese days. (Here's my [Spacemacs\nconfiguration](https://github.com/sritchie/spacemacs.d/tree/sritchie/google), if\nthat phrase means anything to you.)\n\nI won't go into a whole spiel about how to set up Emacs, but I will note a\nconfiguration options that I've found very helpful when working on these\nexercises. (If you have guides you like, let me know and I'll link them here.)\n\n### Run Mechanics Inside Emacs\n\nEmacs has amazing built-in support for working with Scheme. I've added a\n`mechanics` function to my Emacs config:\n\n```elisp\n(defun mechanics ()\n    (interactive)\n    (run-scheme \"mechanics\"))\n```\n\n(This works because I've added the `sicm/bin` directory to my path. You'll need\nto do that too, or give this command the full path to the `bin/mechanics`\nprogram.)\n\nWhen I'm in a file in the project, I can type `M-x mechanics`, and Emacs will\nstart up a REPL running the `mechanics` code, with X11 support and everything.\nThen, when I'm working on a file, `C-c C-z` will switch to the repl.\n\nMAKE SURE you run this from the root of the project!! Go to `README.md` or\nsomething and run it there. All of the `load` statements in all of the code\nassume your main directory is the project root, so you'll run into problems if\nyou don't do this.\n\n### Mechanics and Projectile\n\nI actually use a slightly better version of the function above. If you use the\nincredible [Projectile](https://docs.projectile.mx/en/latest/) library for Emacs\nproject navigation (and why wouldn't you??) you can make `mechanics` start\nScheme from the project root every time.\n\nHere's the better version:\n\n```elisp\n(defun mechanics-local ()\n  (interactive)\n  (run-scheme \"mechanics\"))\n\n(defun mechanics ()\n  (interactive)\n  (let ((default-directory (or (projectile-project-root)\n                               default-directory)))\n    (call-interactively #'mechanics-local)))\n```\n\nThis will attempt to use Projectile to launch Scheme in the root of your\nproject, and fall back to the current folder if you're not in a project when you\nrun `M-x mechanics`. Total gold!\n\n## Other Emacs Customizations\n\nThere are a few other customizations that I've found helpful working with\nMIT-Scheme and mechanics. I'll detail them here.\n\n### Prettify Symbols / Lambdas\n\nThis block of configuration code that, in Scheme, changes \"lambda\" appearances\ninto nice, pretty greek symbols. This is called\n[prettify-symbols-mode](https://emacsredux.com/blog/2014/08/25/a-peek-at-emacs-24-dot-4-prettify-symbols-mode/),\nand looks great.\n\n```elisp\n;; This enables nice greek-letter lambdas whenever you type \"lambda\"\n;; anywhere in a Scheme file.\n(global-prettify-symbols-mode 1)\n\n;; Some bonus code to get this working in other language modes:\n(defun enable-pretty-lambdas ()\n  \"Make them beautiful!\"\n  (setq prettify-symbols-alist '((\"lambda\" . 955))))\n\n;; I'm using Racket for a different project, so I wanted the good there too.\n(add-hook 'racket-mode-hook 'enable-pretty-lambdas)\n(add-hook 'racket-repl-mode-hook 'enable-pretty-lambdas)\n```\n\n### Smartparens\n\nI use [smartparens](https://github.com/Fuco1/smartparens) to make sure that my\nparentheses never get out of balance. This is absolutely essential when working\nwith Lisp.\n\nI'm used to the\n[Paredit](http://danmidwood.com/content/2014/11/21/animated-paredit.html)\nkeybindings from years back, so I run this setting to make sure that all of the\nchords burned into my fingers don't have to change:\n\n```elisp\n(sp-use-paredit-bindings)\n```\n\nTo learn how to use these bindings, and what this library can do for you, check\nout Dan Midwood's amazing [Animated Guide to\nParedit](http://danmidwood.com/content/2014/11/21/animated-paredit.html).\n\nHere's a [guide comparing Paredit and\nSmartparens](https://github.com/Fuco1/smartparens/wiki/Paredit-and-smartparens),\nso you don't get caught out by the differences.\n\n\n## Native SCMUtils Installation on OS X\n\nThis method of installation is a little more involved, but if you decide that\nyou want to skip the Docker route and install `mechanics` and MIT Scheme\nnatively on OS X, these are the steps.\n\nThe instructions are\n[here](http://groups.csail.mit.edu/mac/users/gjs/6946/installation.html), but\nlet's get through them more carefully.\n\n- Install MIT Scheme: https://www.gnu.org/software/mit-scheme/\n- Rename the ``MIT-Scheme` application in the Applications folder to\n `MIT-Scheme`, so we don't have to worry about escaping spaces in the terminal.\n- Create a `~/bin` folder and get it on your `$PATH`.\n\nRun the following command to make the `mit-scheme` binary available:\n\n```bash\nln -s /Applications/MIT-Scheme.app/Contents/Resources/mit-scheme ~/bin/mit-scheme\n```\n\nAdd this line to your `~/.bashrc` or `~/.bash_profile`, so that Scheme can see its libraries:\n\n```bash\nexport MITSCHEME_LIBRARY_PATH=/Applications/MIT-Scheme.app/Contents/Resources\n```\n\nTest that this all worked by running `mit-scheme` at a fresh terminal. You should see the following:\n\n```\n$ mit-scheme\nMIT/GNU Scheme running under OS X\nType `^C' (control-C) followed by `H' to obtain information about interrupts.\n\nCopyright (C) 2019 Massachusetts Institute of Technology\nThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nImage saved on Saturday August 10, 2019 at 6:28:48 PM\n  Release 10.1.10 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118\n\n1 ]=\u003e\n```\n\nOnce that's working, it's time to install the SCMUtils / Mechanics library.\n\n### Manual SCMUtils Installation\n\nThe download link for the library lives at the [SICM course\nwebsite](http://groups.csail.mit.edu/mac/users/gjs/6946/installation.html), at\nstep 4. Here's the [direct download\nlink](http://groups.csail.mit.edu/mac/users/gjs/6946/scmutils-20190830.tar.gz)\nif you prefer that.\n\nThe next few steps come from the instructions at the course site:\n\n- Expand this gzipped tar archive by executing `tar xzf\n  scmutils-20190830.tar.gz`. This will make a directory named\n  `scmutils-20190830`.\n- Run `cd scmutils-20190830 \u0026\u0026 ./install.sh` to install `scmutils` into your\n  local Scheme installation's resource directory.\n- Copy the starter script into `~/bin` by running `cp mechanics.sh ~/bin/mechanics`.\n\nTest it all out by running `mechanics`. You should see the following:\n\n```\n$ mechanics\nMIT/GNU Scheme running under OS X\nType `^C' (control-C) followed by `H' to obtain information about interrupts.\n\nCopyright (C) 2019 Massachusetts Institute of Technology\nThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nImage saved on Friday August 30, 2019 at 11:20:36 PM\n  Release 10.1.10 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || SOS 1.8 || XML 1.0 || Edwin 3.117 || X11 1.3 || X11-Screen 1.0 || ScmUtils Mechanics.Summer 2019\n\n1 ]=\u003e\n```\n\nYou're all set now, and can refer back to previous sections for instructions on\nhow to install X11 and LaTeX, work with the exercises, or configure Emacs.\n\n## Thank you!\n\nThanks for following along! If you run into any issues, please file a ticket via\n[Github Issues](https://github.com/sritchie/sicm/issues).\n\nIf you have any questions, or want to send me a note, you can do that at\nsritchie09 at gmail.com.\n\n## License\n\nCopyright 2020, Sam Ritchie.\n\nLicensed under the [Apache License, Version\n2.0](http://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrogrocketlabs%2Fsicm-scheme-exercises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrogrocketlabs%2Fsicm-scheme-exercises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrogrocketlabs%2Fsicm-scheme-exercises/lists"}