Skip to content

Instantly share code, notes, and snippets.

View sritchie's full-sized avatar
🎯
Focusing

Sam Ritchie sritchie

🎯
Focusing
View GitHub Profile
@sritchie
sritchie / refman.adoc
Created December 12, 2020 20:58
SICMUtils Reference Manual (ported from the original)

SICMUTILS Reference Manual

Caution
This is a port of the original reference manual for scmutils over to Clojure and the SICMUtils API. The goal here is to host an annotated version of the original refman.txt, highlighting any difference in functionality, behavior and naming so that folks can transition between the systems. The code here assumes that you’re working at a REPL initialized to the the sicmutils.env namespace.
@sritchie
sritchie / v0.14.0_release_notes.md
Created December 12, 2020 20:56
v0.14.0: tons of new generic operations, refman ported!
  • we have a great documentation site now! cljdoc now hosts a full port of the original scmutils reference manual. All code snippets in the ported refman now work. I've also distributed many of the sections in the reference manual into more topically organized sections in the cljdoc site, so give those a browse and keep your eye out for more expansion there.

Okay, on to the beefy changelog.

A quick note: After the work below, v/nullity? renamed to v/zero?, and v/unity? renamed to v/one? #180. This affects the names listed in the CHANGELOG entries below.

New Generic Functions

This release brings us closer to the interface provided by scmutils.

(defn adaptive
"Accepts two 'integrator' functions of:
- `f`: some integrand
- `a` and `b`: the lower and upper endpoints of integration
- `opts`, a dictionary of configuration options
And returns a new function of the same signature that adaptively subdivides
the region $a, b$ into intervals if integration fails to converge."
([integrator] (adaptive integrator integrator))
@sritchie
sritchie / minimize.cljc
Last active September 3, 2020 01:59
Nelder-Mead multidimensional minimization in Clojure, based on Colin Smith's excellent work!
(ns sicmutils.numerical.minimize
"Implementations of minimization algorithms for single and multiple dimensions."
(:require [sicmutils.util :as u]
[sicmutils.util.stopwatch :as us]
[taoensso.timbre :as log])
#?(:clj
(:import (org.apache.commons.math3.optim.univariate
BrentOptimizer
UnivariateObjectiveFunction
SearchInterval

Exercise 1.15: Equivalence

This is one of the more important exercises in the chapter. The problem asks for a proof that it's possible to absorb a coordinate transformation directly into the Lagrangian. If you can do this, you can express your paths and your forces in whatever coordinates you like, so long as you can transition between them.

I also found that this exposed, and repaired, my weakness with the functional notation that Sussman and Wisdom have used in the book.

The problem states:

Show by direct calculation that the Lagrange equations for $L'$ are satisfied if the Lagrange equations for $L$ are satisfied.

Exercise 1.15: Equivalence

This is one of the more important exercises in the chapter. The problem asks for a proof that it's possible to absorb a coordinate transformation directly into the Lagrangian. If you can do this, you can express your paths and your forces in whatever coordinates you like, so long as you can transition between them.

I also found that this exposed, and repaired, my weakness with the functional notation that Sussman and Wisdom have used in the book.

The problem states:

Show by direct calculation that the Lagrange equations for $L'$ are satisfied if the Lagrange equations for $L$ are satisfied.

(deftest bigint-repro
(testing "[No method in multimethod 'sicmutils.generic/div' for dispatch value: [#object[Number] :sicmutils.polynomial/polynomial]]"
(hermetic-simplify-fixture
(fn []
(sicmutils.generic/simplify
(* 0.5
(/ 1 (* 2 'x)))))))
(testing "TypeError: Cannot mix BigInt and other types, use explicit conversions"
(* 0.5 (u/bigint 2))
from setuptools import find_packages, setup
# This follows the style of Jaxlib installation here:
# https://github.com/google/jax#pip-installation
PYTHON_VERSION = "cp37"
CUDA_VERSION = "cuda101" # alternatives: cuda90, cuda92, cuda100, cuda101
PLATFORM = "linux_x86_64" # alternatives: linux_x86_64
BASE_URL = "https://storage.googleapis.com/jax-releases"
This file has been truncated, but you can view the full file.
#!/usr/bin/env node
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
This file has been truncated, but you can view the full file.
#!/usr/bin/env node
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);