Skip to content

hnarayanan/sicm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Working Through Structure and Interpretation of Classical Mechanics

This repository contains some notes on my progress through Structure and Interpretation of Classical Mechanics (Second Edition). This book lies at the intersection of things that matter very much to me: mechanics, mathematics and computation.

The crew behind this book (and the corresponding code) are a curious bunch and they have fun exploring their curiosities. They are slowly becoming my spiritual guides.

These are mostly notes for myself, but it's great if you want to follow along with:

Feel free to get in touch if you'd like to talk about this topic or study together.

Background Material

There are a handful of ways you can access the book:

There is also an MIT OCW course corresponding to it:

The material in this course, and hence the numbering used in the assignments, correspond to the first edition of the book.

The programming language used in this book and the accompanying library (Scheme Mechanics or Scmutils) is called Scheme. If you are interested in learning about it, the following course (and related book) is excellent:

In addition to this, the following courses are also really interesting:

Following Along

Base setup on macOS on Apple Silicon

I happen to work on an Apple Silicon Mac, and part of this repository is a collection of notes and hacks needed to get MIT Scheme and Scmutils working nicely on it.

  1. Install XQuartz. This used to come bundled with Macs previously, but now needs to be installed by hand. You will need this for graphical output.

    Simply download the installer (2.8.5 at the time of writing) and run it to install.

  2. Fetch, unpack and patch recent source code for MIT Scheme. At the time of writing, this is version 12.1. For some technical reasons, there is no native-code support for Apple Silicon, and you need to fetch the SVM1 binaries which work (albeit a little slowly).

    curl -O https://ftp.gnu.org/gnu/mit-scheme/stable.pkg/12.1/mit-scheme-12.1-svm1-64le.tar.gz
    tar -xzf mit-scheme-12.1-svm1-64le.tar.gz
    cd mit-scheme-12.1
    curl -O https://raw.githubusercontent.com/hnarayanan/sicm/main/patches/mit-scheme-12.1.patch
    patch -p1 < mit-scheme-12.1.patch
    
  3. Build and install this patched MIT Scheme. You will want to change /path/to/install/scheme/ below to something that makes sense for you. Just keep it in mind in subsequent steps.

    ./configure --prefix=/path/to/install/scheme/
    make
    make install
    
  4. Adjust some environment variables in ~/.profile to let your shell know about this installation.

    export DISPLAY=:0
    export PATH=/path/to/install/scheme/bin:${PATH}
    export MITSCHEME_LIBRARY_PATH=/path/to/install/scheme/lib/mit-scheme-svm1-64le-12.1
    

    You can open a new shell and test your installation out. Hooray!

    mit-scheme
    
  5. The final step is to fetch and install a recent Scmutils (20230902 at time of writing).

    curl -O https://groups.csail.mit.edu/mac/users/gjs/6946/mechanics-system-installation/svm/scmutils-20230902.tar.gz
    tar -xzf scmutils-20230902.tar.gz
    cd scmutils-20230902
    ./install.sh
    

    This ends up installing a script (called mechanics.sh) that starts Scheme and loads Scmutils as it does so. Since it is put in the same path that the mit-scheme binary was installed in, you can just run it from your shell.

    mechanics.sh
    

    Which greets you with the following. Notice the modules loaded on the last line. If you see these, it means you have it all working.

    MIT/GNU Scheme running under OS X
    Type `^C' (control-C) followed by `H' to obtain information about interrupts.
    
    Copyright (C) 2022 Massachusetts Institute of Technology
    This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.
    
    Image saved on Saturday September 2, 2023 at 2:29:59 AM
      Release 12.1 || SF || CREF || LIAR/svm1 || SOS || XML || Edwin || X11 || X11-Screen || ScmUtils
    

Integration with GNU Emacs

I also happen to use GNU Emacs, so here is some bonus material. If you add the following blocks to your Emacs configuration, they install and configure a package called Geiser that gets a nicer REPL for Scheme with scmutils working within Emacs. This makes hacking along with this book even more fun.

(use-package geiser
  :ensure t
  :config
  (setenv "DISPLAY" ":0")
  (setq geiser-active-implementations '(mit)))

(use-package geiser-mit
  :ensure t
  :config
  (setenv "MITSCHEME_HEAP_SIZE" "100000")
  (setenv "MITSCHEME_LIBRARY_PATH" "/path/to/install/scheme/lib/mit-scheme-svm1-64le-12.1")
  (setenv "MITSCHEME_BAND" "mechanics.com")
  (setq geiser-mit-binary "/path/to/install/scheme/bin/mit-scheme"))

License

This learning repository is licensed under the Creative Commons Attribution 4.0 International License.